]> gcc.gnu.org Git - gcc.git/blame - gcc/doc/invoke.texi
c++: implement P1492 contracts
[gcc.git] / gcc / doc / invoke.texi
CommitLineData
d77de738
ML
1@c Copyright (C) 1988-2022 Free Software Foundation, Inc.
2@c This is part of the GCC manual.
3@c For copying conditions, see the file gcc.texi.
4
5@ignore
6@c man begin INCLUDE
7@include gcc-vers.texi
8@c man end
9
10@c man begin COPYRIGHT
11Copyright @copyright{} 1988-2022 Free Software Foundation, Inc.
12
13Permission is granted to copy, distribute and/or modify this document
14under the terms of the GNU Free Documentation License, Version 1.3 or
15any later version published by the Free Software Foundation; with the
16Invariant Sections being ``GNU General Public License'' and ``Funding
17Free Software'', the Front-Cover texts being (a) (see below), and with
18the Back-Cover Texts being (b) (see below). A copy of the license is
19included in the gfdl(7) man page.
20
21(a) The FSF's Front-Cover Text is:
22
23 A GNU Manual
24
25(b) The FSF's Back-Cover Text is:
26
27 You have freedom to copy and modify this GNU Manual, like GNU
28 software. Copies published by the Free Software Foundation raise
29 funds for GNU development.
30@c man end
31@c Set file name and title for the man page.
32@setfilename gcc
33@settitle GNU project C and C++ compiler
34@c man begin SYNOPSIS
35gcc [@option{-c}|@option{-S}|@option{-E}] [@option{-std=}@var{standard}]
36 [@option{-g}] [@option{-pg}] [@option{-O}@var{level}]
37 [@option{-W}@var{warn}@dots{}] [@option{-Wpedantic}]
38 [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
39 [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
40 [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}]
41 [@option{-o} @var{outfile}] [@@@var{file}] @var{infile}@dots{}
42
43Only the most useful options are listed here; see below for the
44remainder. @command{g++} accepts mostly the same options as @command{gcc}.
45@c man end
46@c man begin SEEALSO
47gpl(7), gfdl(7), fsf-funding(7),
48cpp(1), gcov(1), as(1), ld(1), gdb(1)
49and the Info entries for @file{gcc}, @file{cpp}, @file{as},
50@file{ld}, @file{binutils} and @file{gdb}.
51@c man end
52@c man begin BUGS
53For instructions on reporting bugs, see
54@w{@value{BUGURL}}.
55@c man end
56@c man begin AUTHOR
57See the Info entry for @command{gcc}, or
58@w{@uref{https://gcc.gnu.org/onlinedocs/gcc/Contributors.html}},
59for contributors to GCC@.
60@c man end
61@end ignore
62
63@node Invoking GCC
64@chapter GCC Command Options
65@cindex GCC command options
66@cindex command options
67@cindex options, GCC command
68
69@c man begin DESCRIPTION
70When you invoke GCC, it normally does preprocessing, compilation,
71assembly and linking. The ``overall options'' allow you to stop this
72process at an intermediate stage. For example, the @option{-c} option
73says not to run the linker. Then the output consists of object files
74output by the assembler.
75@xref{Overall Options,,Options Controlling the Kind of Output}.
76
77Other options are passed on to one or more stages of processing. Some options
78control the preprocessor and others the compiler itself. Yet other
79options control the assembler and linker; most of these are not
80documented here, since you rarely need to use any of them.
81
82@cindex C compilation options
83Most of the command-line options that you can use with GCC are useful
84for C programs; when an option is only useful with another language
85(usually C++), the explanation says so explicitly. If the description
86for a particular option does not mention a source language, you can use
87that option with all supported languages.
88
89@cindex cross compiling
90@cindex specifying machine version
91@cindex specifying compiler version and target machine
92@cindex compiler version, specifying
93@cindex target machine, specifying
94The usual way to run GCC is to run the executable called @command{gcc}, or
95@command{@var{machine}-gcc} when cross-compiling, or
96@command{@var{machine}-gcc-@var{version}} to run a specific version of GCC.
97When you compile C++ programs, you should invoke GCC as @command{g++}
98instead. @xref{Invoking G++,,Compiling C++ Programs},
99for information about the differences in behavior between @command{gcc}
100and @command{g++} when compiling C++ programs.
101
102@cindex grouping options
103@cindex options, grouping
104The @command{gcc} program accepts options and file names as operands. Many
105options have multi-letter names; therefore multiple single-letter options
106may @emph{not} be grouped: @option{-dv} is very different from @w{@samp{-d
107-v}}.
108
109@cindex order of options
110@cindex options, order
111You can mix options and other arguments. For the most part, the order
112you use doesn't matter. Order does matter when you use several
113options of the same kind; for example, if you specify @option{-L} more
114than once, the directories are searched in the order specified. Also,
115the placement of the @option{-l} option is significant.
116
117Many options have long names starting with @samp{-f} or with
118@samp{-W}---for example,
119@option{-fmove-loop-invariants}, @option{-Wformat} and so on. Most of
120these have both positive and negative forms; the negative form of
121@option{-ffoo} is @option{-fno-foo}. This manual documents
122only one of these two forms, whichever one is not the default.
123
124Some options take one or more arguments typically separated either
125by a space or by the equals sign (@samp{=}) from the option name.
126Unless documented otherwise, an argument can be either numeric or
127a string. Numeric arguments must typically be small unsigned decimal
128or hexadecimal integers. Hexadecimal arguments must begin with
129the @samp{0x} prefix. Arguments to options that specify a size
130threshold of some sort may be arbitrarily large decimal or hexadecimal
131integers followed by a byte size suffix designating a multiple of bytes
132such as @code{kB} and @code{KiB} for kilobyte and kibibyte, respectively,
133@code{MB} and @code{MiB} for megabyte and mebibyte, @code{GB} and
134@code{GiB} for gigabyte and gigibyte, and so on. Such arguments are
135designated by @var{byte-size} in the following text. Refer to the NIST,
136IEC, and other relevant national and international standards for the full
137listing and explanation of the binary and decimal byte size prefixes.
138
139@c man end
140
141@xref{Option Index}, for an index to GCC's options.
142
143@menu
144* Option Summary:: Brief list of all options, without explanations.
145* Overall Options:: Controlling the kind of output:
146 an executable, object files, assembler files,
147 or preprocessed source.
148* Invoking G++:: Compiling C++ programs.
149* C Dialect Options:: Controlling the variant of C language compiled.
150* C++ Dialect Options:: Variations on C++.
151* Objective-C and Objective-C++ Dialect Options:: Variations on Objective-C
152 and Objective-C++.
153* Diagnostic Message Formatting Options:: Controlling how diagnostics should
154 be formatted.
155* Warning Options:: How picky should the compiler be?
156* Static Analyzer Options:: More expensive warnings.
157* Debugging Options:: Producing debuggable code.
158* Optimize Options:: How much optimization?
159* Instrumentation Options:: Enabling profiling and extra run-time error checking.
160* Preprocessor Options:: Controlling header files and macro definitions.
161 Also, getting dependency information for Make.
162* Assembler Options:: Passing options to the assembler.
163* Link Options:: Specifying libraries and so on.
164* Directory Options:: Where to find header files and libraries.
165 Where to find the compiler executable files.
166* Code Gen Options:: Specifying conventions for function calls, data layout
167 and register usage.
168* Developer Options:: Printing GCC configuration info, statistics, and
169 debugging dumps.
170* Submodel Options:: Target-specific options, such as compiling for a
171 specific processor variant.
172* Spec Files:: How to pass switches to sub-processes.
173* Environment Variables:: Env vars that affect GCC.
174* Precompiled Headers:: Compiling a header once, and using it many times.
175* C++ Modules:: Experimental C++20 module system.
176@end menu
177
178@c man begin OPTIONS
179
180@node Option Summary
181@section Option Summary
182
183Here is a summary of all the options, grouped by type. Explanations are
184in the following sections.
185
186@table @emph
187@item Overall Options
188@xref{Overall Options,,Options Controlling the Kind of Output}.
189@gccoptlist{-c -S -E -o @var{file} @gol
190-dumpbase @var{dumpbase} -dumpbase-ext @var{auxdropsuf} @gol
191-dumpdir @var{dumppfx} -x @var{language} @gol
192-v -### --help@r{[}=@var{class}@r{[},@dots{}@r{]]} --target-help --version @gol
193-pass-exit-codes -pipe -specs=@var{file} -wrapper @gol
194@@@var{file} -ffile-prefix-map=@var{old}=@var{new} @gol
195-fplugin=@var{file} -fplugin-arg-@var{name}=@var{arg} @gol
196-fdump-ada-spec@r{[}-slim@r{]} -fada-spec-parent=@var{unit} -fdump-go-spec=@var{file}}
197
198@item C Language Options
199@xref{C Dialect Options,,Options Controlling C Dialect}.
200@gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename} @gol
201-fno-asm @gol
202-fno-builtin -fno-builtin-@var{function} -fcond-mismatch @gol
203-ffreestanding -fgimple -fgnu-tm -fgnu89-inline -fhosted @gol
204-flax-vector-conversions -fms-extensions @gol
205-foffload=@var{arg} -foffload-options=@var{arg} @gol
206-fopenacc -fopenacc-dim=@var{geom} @gol
207-fopenmp -fopenmp-simd @gol
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
401-Wno-stringop-truncation @gol
402-Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}malloc@r{]} @gol
403-Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum @gol
404-Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand @gol
405-Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs @gol
406-Wtrivial-auto-var-init -Wtsan -Wtype-limits -Wundef @gol
407-Wuninitialized -Wunknown-pragmas @gol
408-Wunsuffixed-float-constants -Wunused @gol
409-Wunused-but-set-parameter -Wunused-but-set-variable @gol
410-Wunused-const-variable -Wunused-const-variable=@var{n} @gol
411-Wunused-function -Wunused-label -Wunused-local-typedefs @gol
412-Wunused-macros @gol
413-Wunused-parameter -Wno-unused-result @gol
414-Wunused-value -Wunused-variable @gol
415-Wno-varargs -Wvariadic-macros @gol
416-Wvector-operation-performance @gol
417-Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than @gol
418-Wvolatile-register-var -Wwrite-strings @gol
419-Wxor-used-as-pow @gol
420-Wzero-length-bounds}
421
422@item Static Analyzer Options
423@gccoptlist{
424-fanalyzer @gol
425-fanalyzer-call-summaries @gol
426-fanalyzer-checker=@var{name} @gol
427-fno-analyzer-feasibility @gol
428-fanalyzer-fine-grained @gol
429-fno-analyzer-state-merge @gol
430-fno-analyzer-state-purge @gol
431-fanalyzer-transitivity @gol
432-fno-analyzer-undo-inlining @gol
433-fanalyzer-verbose-edges @gol
434-fanalyzer-verbose-state-changes @gol
435-fanalyzer-verbosity=@var{level} @gol
436-fdump-analyzer @gol
437-fdump-analyzer-callgraph @gol
438-fdump-analyzer-exploded-graph @gol
439-fdump-analyzer-exploded-nodes @gol
440-fdump-analyzer-exploded-nodes-2 @gol
441-fdump-analyzer-exploded-nodes-3 @gol
442-fdump-analyzer-exploded-paths @gol
443-fdump-analyzer-feasibility @gol
444-fdump-analyzer-json @gol
445-fdump-analyzer-state-purge @gol
446-fdump-analyzer-stderr @gol
447-fdump-analyzer-supergraph @gol
448-fdump-analyzer-untracked @gol
449-Wno-analyzer-double-fclose @gol
450-Wno-analyzer-double-free @gol
451-Wno-analyzer-exposure-through-output-file @gol
452-Wno-analyzer-exposure-through-uninit-copy @gol
453-Wno-analyzer-fd-access-mode-mismatch @gol
454-Wno-analyzer-fd-double-close @gol
455-Wno-analyzer-fd-leak @gol
86a90006
DM
456-Wno-analyzer-fd-phase-mismatch @gol
457-Wno-analyzer-fd-type-mismatch @gol
d77de738
ML
458-Wno-analyzer-fd-use-after-close @gol
459-Wno-analyzer-fd-use-without-check @gol
460-Wno-analyzer-file-leak @gol
461-Wno-analyzer-free-of-non-heap @gol
462-Wno-analyzer-imprecise-fp-arithmetic @gol
ce51e843 463-Wno-analyzer-infinite-recursion @gol
d77de738
ML
464-Wno-analyzer-jump-through-null @gol
465-Wno-analyzer-malloc-leak @gol
466-Wno-analyzer-mismatching-deallocation @gol
467-Wno-analyzer-null-argument @gol
468-Wno-analyzer-null-dereference @gol
469-Wno-analyzer-out-of-bounds @gol
470-Wno-analyzer-possible-null-argument @gol
471-Wno-analyzer-possible-null-dereference @gol
472-Wno-analyzer-putenv-of-auto-var @gol
473-Wno-analyzer-shift-count-negative @gol
474-Wno-analyzer-shift-count-overflow @gol
475-Wno-analyzer-stale-setjmp-buffer @gol
476-Wno-analyzer-tainted-allocation-size @gol
ce51e843 477-Wno-analyzer-tainted-assertion @gol
d77de738
ML
478-Wno-analyzer-tainted-array-index @gol
479-Wno-analyzer-tainted-divisor @gol
480-Wno-analyzer-tainted-offset @gol
481-Wno-analyzer-tainted-size @gol
482-Wanalyzer-too-complex @gol
483-Wno-analyzer-unsafe-call-within-signal-handler @gol
484-Wno-analyzer-use-after-free @gol
485-Wno-analyzer-use-of-pointer-in-stale-stack-frame @gol
486-Wno-analyzer-use-of-uninitialized-value @gol
487-Wno-analyzer-va-arg-type-mismatch @gol
488-Wno-analyzer-va-list-exhausted @gol
489-Wno-analyzer-va-list-leak @gol
490-Wno-analyzer-va-list-use-after-va-end @gol
491-Wno-analyzer-write-to-const @gol
492-Wno-analyzer-write-to-string-literal @gol
493}
494
495@item C and Objective-C-only Warning Options
496@gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol
497-Wmissing-parameter-type -Wmissing-prototypes -Wnested-externs @gol
498-Wold-style-declaration -Wold-style-definition @gol
499-Wstrict-prototypes -Wtraditional -Wtraditional-conversion @gol
500-Wdeclaration-after-statement -Wpointer-sign}
501
502@item Debugging Options
503@xref{Debugging Options,,Options for Debugging Your Program}.
504@gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version} @gol
505-gbtf -gctf -gctf@var{level} @gol
506-ggdb -grecord-gcc-switches -gno-record-gcc-switches @gol
507-gstrict-dwarf -gno-strict-dwarf @gol
508-gas-loc-support -gno-as-loc-support @gol
509-gas-locview-support -gno-as-locview-support @gol
510-gcolumn-info -gno-column-info -gdwarf32 -gdwarf64 @gol
511-gstatement-frontiers -gno-statement-frontiers @gol
512-gvariable-location-views -gno-variable-location-views @gol
513-ginternal-reset-location-views -gno-internal-reset-location-views @gol
514-ginline-points -gno-inline-points @gol
515-gvms -gz@r{[}=@var{type}@r{]} @gol
516-gsplit-dwarf -gdescribe-dies -gno-describe-dies @gol
517-fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section @gol
518-fno-eliminate-unused-debug-types @gol
519-femit-struct-debug-baseonly -femit-struct-debug-reduced @gol
520-femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} @gol
521-fno-eliminate-unused-debug-symbols -femit-class-debug-always @gol
522-fno-merge-debug-strings -fno-dwarf2-cfi-asm @gol
523-fvar-tracking -fvar-tracking-assignments}
524
525@item Optimization Options
526@xref{Optimize Options,,Options that Control Optimization}.
527@gccoptlist{-faggressive-loop-optimizations @gol
528-falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
529-falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
530-falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
531-falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
532-fno-allocation-dce -fallow-store-data-races @gol
533-fassociative-math -fauto-profile -fauto-profile[=@var{path}] @gol
534-fauto-inc-dec -fbranch-probabilities @gol
535-fcaller-saves @gol
536-fcombine-stack-adjustments -fconserve-stack @gol
537-fcompare-elim -fcprop-registers -fcrossjumping @gol
538-fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules @gol
539-fcx-limited-range @gol
540-fdata-sections -fdce -fdelayed-branch @gol
541-fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively @gol
542-fdevirtualize-at-ltrans -fdse @gol
543-fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects @gol
544-ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style} @gol
545-ffinite-loops @gol
546-fforward-propagate -ffp-contract=@var{style} -ffunction-sections @gol
547-fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity @gol
548-fgcse-sm -fhoist-adjacent-loads -fif-conversion @gol
549-fif-conversion2 -findirect-inlining @gol
550-finline-functions -finline-functions-called-once -finline-limit=@var{n} @gol
551-finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone @gol
552-fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const @gol
553-fipa-reference -fipa-reference-addressable @gol
554-fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm} @gol
555-flive-patching=@var{level} @gol
556-fira-region=@var{region} -fira-hoist-pressure @gol
557-fira-loop-pressure -fno-ira-share-save-slots @gol
558-fno-ira-share-spill-slots @gol
559-fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute @gol
560-fivopts -fkeep-inline-functions -fkeep-static-functions @gol
561-fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage @gol
562-floop-block -floop-interchange -floop-strip-mine @gol
563-floop-unroll-and-jam -floop-nest-optimize @gol
564-floop-parallelize-all -flra-remat -flto -flto-compression-level @gol
565-flto-partition=@var{alg} -fmerge-all-constants @gol
566-fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves @gol
567-fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg @gol
568-fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse @gol
569-fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole @gol
570-fno-peephole2 -fno-printf-return-value -fno-sched-interblock @gol
571-fno-sched-spec -fno-signed-zeros @gol
572-fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss @gol
573-fomit-frame-pointer -foptimize-sibling-calls @gol
574-fpartial-inlining -fpeel-loops -fpredictive-commoning @gol
575-fprefetch-loop-arrays @gol
576-fprofile-correction @gol
577-fprofile-use -fprofile-use=@var{path} -fprofile-partial-training @gol
578-fprofile-values -fprofile-reorder-functions @gol
579-freciprocal-math -free -frename-registers -freorder-blocks @gol
580-freorder-blocks-algorithm=@var{algorithm} @gol
581-freorder-blocks-and-partition -freorder-functions @gol
582-frerun-cse-after-loop -freschedule-modulo-scheduled-loops @gol
583-frounding-math -fsave-optimization-record @gol
584-fsched2-use-superblocks -fsched-pressure @gol
585-fsched-spec-load -fsched-spec-load-dangerous @gol
586-fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}] @gol
587-fsched-group-heuristic -fsched-critical-path-heuristic @gol
588-fsched-spec-insn-heuristic -fsched-rank-heuristic @gol
589-fsched-last-insn-heuristic -fsched-dep-count-heuristic @gol
590-fschedule-fusion @gol
591-fschedule-insns -fschedule-insns2 -fsection-anchors @gol
592-fselective-scheduling -fselective-scheduling2 @gol
593-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops @gol
594-fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate @gol
595-fsignaling-nans @gol
596-fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops@gol
597-fsplit-paths @gol
598-fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt @gol
599-fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing @gol
600-fthread-jumps -ftracer -ftree-bit-ccp @gol
601-ftree-builtin-call-dce -ftree-ccp -ftree-ch @gol
602-ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts @gol
603-ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting @gol
604-ftree-loop-if-convert -ftree-loop-im @gol
605-ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns @gol
606-ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize @gol
607-ftree-loop-vectorize @gol
608-ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta @gol
609-ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra @gol
610-ftree-switch-conversion -ftree-tail-merge @gol
611-ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init @gol
612-funconstrained-commons -funit-at-a-time -funroll-all-loops @gol
613-funroll-loops -funsafe-math-optimizations -funswitch-loops @gol
614-fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt @gol
615-fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs @gol
616--param @var{name}=@var{value}
617-O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz}
618
619@item Program Instrumentation Options
620@xref{Instrumentation Options,,Program Instrumentation Options}.
621@gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage @gol
622-fprofile-abs-path @gol
623-fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path} @gol
624-fprofile-info-section -fprofile-info-section=@var{name} @gol
625-fprofile-note=@var{path} -fprofile-prefix-path=@var{path} @gol
626-fprofile-update=@var{method} -fprofile-filter-files=@var{regex} @gol
627-fprofile-exclude-files=@var{regex} @gol
628-fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} @gol
629-fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} @gol
630-fsanitize-trap -fsanitize-trap=@var{style} @gol
631-fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... @gol
632-fsanitize-undefined-trap-on-error -fbounds-check @gol
633-fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} @gol
634-fharden-compares -fharden-conditional-branches @gol
635-fstack-protector -fstack-protector-all -fstack-protector-strong @gol
636-fstack-protector-explicit -fstack-check @gol
637-fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol
638-fno-stack-limit -fsplit-stack @gol
639-fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} @gol
640-fvtv-counts -fvtv-debug @gol
641-finstrument-functions -finstrument-functions-once @gol
642-finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} @gol
643-finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}} @gol
644-fprofile-prefix-map=@var{old}=@var{new}
645
646@item Preprocessor Options
647@xref{Preprocessor Options,,Options Controlling the Preprocessor}.
648@gccoptlist{-A@var{question}=@var{answer} @gol
649-A-@var{question}@r{[}=@var{answer}@r{]} @gol
650-C -CC -D@var{macro}@r{[}=@var{defn}@r{]} @gol
651-dD -dI -dM -dN -dU @gol
652-fdebug-cpp -fdirectives-only -fdollars-in-identifiers @gol
653-fexec-charset=@var{charset} -fextended-identifiers @gol
654-finput-charset=@var{charset} -flarge-source-files @gol
655-fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth} @gol
656-fno-canonical-system-headers -fpch-deps -fpch-preprocess @gol
657-fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion @gol
658-fwide-exec-charset=@var{charset} -fworking-directory @gol
659-H -imacros @var{file} -include @var{file} @gol
660-M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules @gol
661-no-integrated-cpp -P -pthread -remap @gol
662-traditional -traditional-cpp -trigraphs @gol
663-U@var{macro} -undef @gol
664-Wp,@var{option} -Xpreprocessor @var{option}}
665
666@item Assembler Options
667@xref{Assembler Options,,Passing Options to the Assembler}.
668@gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
669
670@item Linker Options
671@xref{Link Options,,Options for Linking}.
672@gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} @gol
673-nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++ @gol
674-e @var{entry} --entry=@var{entry} @gol
675-pie -pthread -r -rdynamic @gol
676-s -static -static-pie -static-libgcc -static-libstdc++ @gol
677-static-libasan -static-libtsan -static-liblsan -static-libubsan @gol
678-shared -shared-libgcc -symbolic @gol
679-T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol
680-u @var{symbol} -z @var{keyword}}
681
682@item Directory Options
683@xref{Directory Options,,Options for Directory Search}.
684@gccoptlist{-B@var{prefix} -I@var{dir} -I- @gol
685-idirafter @var{dir} @gol
686-imacros @var{file} -imultilib @var{dir} @gol
687-iplugindir=@var{dir} -iprefix @var{file} @gol
688-iquote @var{dir} -isysroot @var{dir} -isystem @var{dir} @gol
689-iwithprefix @var{dir} -iwithprefixbefore @var{dir} @gol
690-L@var{dir} -no-canonical-prefixes --no-sysroot-suffix @gol
691-nostdinc -nostdinc++ --sysroot=@var{dir}}
692
693@item Code Generation Options
694@xref{Code Gen Options,,Options for Code Generation Conventions}.
695@gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} @gol
696-ffixed-@var{reg} -fexceptions @gol
697-fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables @gol
698-fasynchronous-unwind-tables @gol
699-fno-gnu-unique @gol
700-finhibit-size-directive -fcommon -fno-ident @gol
701-fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt @gol
702-fno-jump-tables -fno-bit-tests @gol
703-frecord-gcc-switches @gol
704-freg-struct-return -fshort-enums -fshort-wchar @gol
705-fverbose-asm -fpack-struct[=@var{n}] @gol
706-fleading-underscore -ftls-model=@var{model} @gol
707-fstack-reuse=@var{reuse_level} @gol
708-ftrampolines -ftrapv -fwrapv @gol
709-fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} @gol
710-fstrict-volatile-bitfields -fsync-libcalls}
711
712@item Developer Options
713@xref{Developer Options,,GCC Developer Options}.
714@gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol
715-dumpfullversion -fcallgraph-info@r{[}=su,da@r{]}
716-fchecking -fchecking=@var{n}
717-fdbg-cnt-list @gol -fdbg-cnt=@var{counter-value-list} @gol
718-fdisable-ipa-@var{pass_name} @gol
719-fdisable-rtl-@var{pass_name} @gol
720-fdisable-rtl-@var{pass-name}=@var{range-list} @gol
721-fdisable-tree-@var{pass_name} @gol
722-fdisable-tree-@var{pass-name}=@var{range-list} @gol
723-fdump-debug -fdump-earlydebug @gol
724-fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links @gol
725-fdump-final-insns@r{[}=@var{file}@r{]} @gol
726-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline @gol
727-fdump-lang-all @gol
728-fdump-lang-@var{switch} @gol
729-fdump-lang-@var{switch}-@var{options} @gol
730-fdump-lang-@var{switch}-@var{options}=@var{filename} @gol
731-fdump-passes @gol
732-fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename} @gol
733-fdump-statistics @gol
734-fdump-tree-all @gol
735-fdump-tree-@var{switch} @gol
736-fdump-tree-@var{switch}-@var{options} @gol
737-fdump-tree-@var{switch}-@var{options}=@var{filename} @gol
738-fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second @gol
739-fenable-@var{kind}-@var{pass} @gol
740-fenable-@var{kind}-@var{pass}=@var{range-list} @gol
741-fira-verbose=@var{n} @gol
742-flto-report -flto-report-wpa -fmem-report-wpa @gol
743-fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report @gol
744-fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]} @gol
745-fmultiflags -fprofile-report @gol
746-frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
747-fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose @gol
748-fstats -fstack-usage -ftime-report -ftime-report-details @gol
749-fvar-tracking-assignments-toggle -gtoggle @gol
750-print-file-name=@var{library} -print-libgcc-file-name @gol
751-print-multi-directory -print-multi-lib -print-multi-os-directory @gol
752-print-prog-name=@var{program} -print-search-dirs -Q @gol
753-print-sysroot -print-sysroot-headers-suffix @gol
754-save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}
755
756@item Machine-Dependent Options
757@xref{Submodel Options,,Machine-Dependent Options}.
758@c This list is ordered alphanumerically by subsection name.
759@c Try and put the significant identifier (CPU or system) first,
760@c so users have a clue at guessing where the ones they want will be.
761
762@emph{AArch64 Options}
763@gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian @gol
764-mgeneral-regs-only @gol
765-mcmodel=tiny -mcmodel=small -mcmodel=large @gol
766-mstrict-align -mno-strict-align @gol
767-momit-leaf-frame-pointer @gol
768-mtls-dialect=desc -mtls-dialect=traditional @gol
769-mtls-size=@var{size} @gol
770-mfix-cortex-a53-835769 -mfix-cortex-a53-843419 @gol
771-mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div @gol
772-mpc-relative-literal-loads @gol
773-msign-return-address=@var{scope} @gol
774-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}
775+@var{b-key}]|@var{bti} @gol
776-mharden-sls=@var{opts} @gol
777-march=@var{name} -mcpu=@var{name} -mtune=@var{name} @gol
778-moverride=@var{string} -mverbose-cost-dump @gol
779-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg} @gol
780-mstack-protector-guard-offset=@var{offset} -mtrack-speculation @gol
781-moutline-atomics }
782
783@emph{Adapteva Epiphany Options}
784@gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs @gol
785-mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf @gol
786-msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num} @gol
787-mround-nearest -mlong-calls -mshort-calls -msmall16 @gol
788-mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num} @gol
789-msplit-vecmove-early -m1reg-@var{reg}}
790
791@emph{AMD GCN Options}
792@gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}}
793
794@emph{ARC Options}
795@gccoptlist{-mbarrel-shifter -mjli-always @gol
796-mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700 @gol
797-mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr @gol
798-mea -mno-mpy -mmul32x16 -mmul64 -matomic @gol
799-mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap @gol
800-mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape @gol
801-mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof @gol
802-mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved @gol
803-mrgf-banked-regs -mlpc-width=@var{width} -G @var{num} @gol
804-mvolatile-cache -mtp-regno=@var{regno} @gol
805-malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc @gol
806-mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi @gol
807-mexpand-adddi -mindexed-loads -mlra -mlra-priority-none @gol
808-mlra-priority-compact -mlra-priority-noncompact -mmillicode @gol
809-mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level} @gol
810-mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame @gol
811-munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo} @gol
812-mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index}
813
814@emph{ARM Options}
815@gccoptlist{-mapcs-frame -mno-apcs-frame @gol
816-mabi=@var{name} @gol
817-mapcs-stack-check -mno-apcs-stack-check @gol
818-mapcs-reentrant -mno-apcs-reentrant @gol
819-mgeneral-regs-only @gol
820-msched-prolog -mno-sched-prolog @gol
821-mlittle-endian -mbig-endian @gol
822-mbe8 -mbe32 @gol
823-mfloat-abi=@var{name} @gol
824-mfp16-format=@var{name}
825-mthumb-interwork -mno-thumb-interwork @gol
826-mcpu=@var{name} -march=@var{name} -mfpu=@var{name} @gol
827-mtune=@var{name} -mprint-tune-info @gol
828-mstructure-size-boundary=@var{n} @gol
829-mabort-on-noreturn @gol
830-mlong-calls -mno-long-calls @gol
831-msingle-pic-base -mno-single-pic-base @gol
832-mpic-register=@var{reg} @gol
833-mnop-fun-dllimport @gol
834-mpoke-function-name @gol
835-mthumb -marm -mflip-thumb @gol
836-mtpcs-frame -mtpcs-leaf-frame @gol
837-mcaller-super-interworking -mcallee-super-interworking @gol
838-mtp=@var{name} -mtls-dialect=@var{dialect} @gol
839-mword-relocations @gol
840-mfix-cortex-m3-ldrd @gol
841-mfix-cortex-a57-aes-1742098 @gol
842-mfix-cortex-a72-aes-1655431 @gol
843-munaligned-access @gol
844-mneon-for-64bits @gol
845-mslow-flash-data @gol
846-masm-syntax-unified @gol
847-mrestrict-it @gol
848-mverbose-cost-dump @gol
849-mpure-code @gol
850-mcmse @gol
851-mfix-cmse-cve-2021-35465 @gol
852-mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset} @gol
853-mfdpic}
854
855@emph{AVR Options}
856@gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args @gol
857-mbranch-cost=@var{cost} @gol
858-mcall-prologues -mgas-isr-prologues -mint8 @gol
859-mdouble=@var{bits} -mlong-double=@var{bits} @gol
860-mn_flash=@var{size} -mno-interrupts @gol
861-mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack @gol
862-mfract-convert-truncate @gol
863-mshort-calls -nodevicelib -nodevicespecs @gol
864-Waddr-space-convert -Wmisspelled-isr}
865
866@emph{Blackfin Options}
867@gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} @gol
868-msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer @gol
869-mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly @gol
870-mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library @gol
871-mno-id-shared-library -mshared-library-id=@var{n} @gol
872-mleaf-id-shared-library -mno-leaf-id-shared-library @gol
873-msep-data -mno-sep-data -mlong-calls -mno-long-calls @gol
874-mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram @gol
875-micplb}
876
877@emph{C6X Options}
878@gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu} @gol
879-msim -msdata=@var{sdata-type}}
880
881@emph{CRIS Options}
882@gccoptlist{-mcpu=@var{cpu} -march=@var{cpu}
883-mtune=@var{cpu} -mmax-stack-frame=@var{n} @gol
884-metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects @gol
885-mstack-align -mdata-align -mconst-align @gol
886-m32-bit -m16-bit -m8-bit -mno-prologue-epilogue @gol
887-melf -maout -sim -sim2 @gol
888-mmul-bug-workaround -mno-mul-bug-workaround}
889
890@emph{C-SKY Options}
891@gccoptlist{-march=@var{arch} -mcpu=@var{cpu} @gol
892-mbig-endian -EB -mlittle-endian -EL @gol
893-mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu @gol
894-mfloat-abi=@var{name} @gol
895-melrw -mistack -mmp -mcp -mcache -msecurity -mtrust @gol
896-mdsp -medsp -mvdsp @gol
897-mdiv -msmart -mhigh-registers -manchor @gol
898-mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt @gol
899-mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim}
900
901@emph{Darwin Options}
902@gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal @gol
903-arch_only -bind_at_load -bundle -bundle_loader @gol
904-client_name -compatibility_version -current_version @gol
905-dead_strip @gol
906-dependency-file -dylib_file -dylinker_install_name @gol
907-dynamic -dynamiclib -exported_symbols_list @gol
908-filelist -flat_namespace -force_cpusubtype_ALL @gol
909-force_flat_namespace -headerpad_max_install_names @gol
910-iframework @gol
911-image_base -init -install_name -keep_private_externs @gol
912-multi_module -multiply_defined -multiply_defined_unused @gol
913-noall_load -no_dead_strip_inits_and_terms @gol
914-nofixprebinding -nomultidefs -noprebind -noseglinkedit @gol
915-pagezero_size -prebind -prebind_all_twolevel_modules @gol
916-private_bundle -read_only_relocs -sectalign @gol
917-sectobjectsymbols -whyload -seg1addr @gol
918-sectcreate -sectobjectsymbols -sectorder @gol
919-segaddr -segs_read_only_addr -segs_read_write_addr @gol
920-seg_addr_table -seg_addr_table_filename -seglinkedit @gol
921-segprot -segs_read_only_addr -segs_read_write_addr @gol
922-single_module -static -sub_library -sub_umbrella @gol
923-twolevel_namespace -umbrella -undefined @gol
924-unexported_symbols_list -weak_reference_mismatches @gol
925-whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version} @gol
926-mkernel -mone-byte-bool}
927
928@emph{DEC Alpha Options}
929@gccoptlist{-mno-fp-regs -msoft-float @gol
930-mieee -mieee-with-inexact -mieee-conformant @gol
931-mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} @gol
932-mtrap-precision=@var{mode} -mbuild-constants @gol
933-mcpu=@var{cpu-type} -mtune=@var{cpu-type} @gol
934-mbwx -mmax -mfix -mcix @gol
935-mfloat-vax -mfloat-ieee @gol
936-mexplicit-relocs -msmall-data -mlarge-data @gol
937-msmall-text -mlarge-text @gol
938-mmemory-latency=@var{time}}
939
940@emph{eBPF Options}
941@gccoptlist{-mbig-endian -mlittle-endian -mkernel=@var{version}
942-mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re
943-mjmpext -mjmp32 -malu32 -mcpu=@var{version}}
944
945@emph{FR30 Options}
946@gccoptlist{-msmall-model -mno-lsim}
947
948@emph{FT32 Options}
949@gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm}
950
951@emph{FRV Options}
952@gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 @gol
953-mhard-float -msoft-float @gol
954-malloc-cc -mfixed-cc -mdword -mno-dword @gol
955-mdouble -mno-double @gol
956-mmedia -mno-media -mmuladd -mno-muladd @gol
957-mfdpic -minline-plt -mgprel-ro -multilib-library-pic @gol
958-mlinked-fp -mlong-calls -malign-labels @gol
959-mlibrary-pic -macc-4 -macc-8 @gol
960-mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move @gol
961-moptimize-membar -mno-optimize-membar @gol
962-mscc -mno-scc -mcond-exec -mno-cond-exec @gol
963-mvliw-branch -mno-vliw-branch @gol
964-mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec @gol
965-mno-nested-cond-exec -mtomcat-stats @gol
966-mTLS -mtls @gol
967-mcpu=@var{cpu}}
968
969@emph{GNU/Linux Options}
970@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid @gol
971-tno-android-cc -tno-android-ld}
972
973@emph{H8/300 Options}
974@gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300}
975
976@emph{HPPA Options}
977@gccoptlist{-march=@var{architecture-type} @gol
978-mcaller-copies -mdisable-fpregs -mdisable-indexing @gol
979-mfast-indirect-calls -mgas -mgnu-ld -mhp-ld @gol
980-mfixed-range=@var{register-range} @gol
981-mjump-in-delay -mlinker-opt -mlong-calls @gol
982-mlong-load-store -mno-disable-fpregs @gol
983-mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol
984-mno-jump-in-delay -mno-long-load-store @gol
985-mno-portable-runtime -mno-soft-float @gol
986-mno-space-regs -msoft-float -mpa-risc-1-0 @gol
987-mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol
988-mschedule=@var{cpu-type} -mspace-regs -msio -mwsio @gol
989-munix=@var{unix-std} -nolibdld -static -threads}
990
991@emph{IA-64 Options}
992@gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol
993-mvolatile-asm-stop -mregister-names -msdata -mno-sdata @gol
994-mconstant-gp -mauto-pic -mfused-madd @gol
995-minline-float-divide-min-latency @gol
996-minline-float-divide-max-throughput @gol
997-mno-inline-float-divide @gol
998-minline-int-divide-min-latency @gol
999-minline-int-divide-max-throughput @gol
1000-mno-inline-int-divide @gol
1001-minline-sqrt-min-latency -minline-sqrt-max-throughput @gol
1002-mno-inline-sqrt @gol
1003-mdwarf2-asm -mearly-stop-bits @gol
1004-mfixed-range=@var{register-range} -mtls-size=@var{tls-size} @gol
1005-mtune=@var{cpu-type} -milp32 -mlp64 @gol
1006-msched-br-data-spec -msched-ar-data-spec -msched-control-spec @gol
1007-msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec @gol
1008-msched-spec-ldc -msched-spec-control-ldc @gol
1009-msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns @gol
1010-msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path @gol
1011-msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost @gol
1012-msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}}
1013
1014@emph{LM32 Options}
1015@gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled @gol
1016-msign-extend-enabled -muser-enabled}
1017
1018@emph{LoongArch Options}
1019@gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type} @gol
1020-mfpu=@var{fpu-type} -msoft-float -msingle-float -mdouble-float @gol
1021-mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division @gol
1022-mcond-move-int -mno-cond-move-int @gol
1023-mcond-move-float -mno-cond-move-float @gol
1024-memcpy -mno-memcpy -mstrict-align -mno-strict-align @gol
1025-mmax-inline-memcpy-size=@var{n} @gol
1026-mexplicit-relocs -mno-explicit-relocs @gol
1027-mdirect-extern-access -mno-direct-extern-access @gol
1028-mcmodel=@var{code-model}}
1029
1030@emph{M32R/D Options}
1031@gccoptlist{-m32r2 -m32rx -m32r @gol
1032-mdebug @gol
1033-malign-loops -mno-align-loops @gol
1034-missue-rate=@var{number} @gol
1035-mbranch-cost=@var{number} @gol
1036-mmodel=@var{code-size-model-type} @gol
1037-msdata=@var{sdata-type} @gol
1038-mno-flush-func -mflush-func=@var{name} @gol
1039-mno-flush-trap -mflush-trap=@var{number} @gol
1040-G @var{num}}
1041
1042@emph{M32C Options}
1043@gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
1044
1045@emph{M680x0 Options}
1046@gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune} @gol
1047-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol
1048-m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407 @gol
1049-mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020 @gol
1050-mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort @gol
1051-mno-short -mhard-float -m68881 -msoft-float -mpcrel @gol
1052-malign-int -mstrict-align -msep-data -mno-sep-data @gol
1053-mshared-library-id=n -mid-shared-library -mno-id-shared-library @gol
1054-mxgot -mno-xgot -mlong-jump-table-offsets}
1055
1056@emph{MCore Options}
1057@gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol
1058-mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol
1059-m4byte-functions -mno-4byte-functions -mcallgraph-data @gol
1060-mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol
1061-mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
1062
d77de738
ML
1063@emph{MicroBlaze Options}
1064@gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu} @gol
1065-mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift @gol
1066-mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss @gol
1067-mxl-multiply-high -mxl-float-convert -mxl-float-sqrt @gol
1068-mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model} @gol
1069-mpic-data-is-text-relative}
1070
1071@emph{MIPS Options}
1072@gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} @gol
1073-mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5 @gol
1074-mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6 @gol
1075-mips16 -mno-mips16 -mflip-mips16 @gol
1076-minterlink-compressed -mno-interlink-compressed @gol
1077-minterlink-mips16 -mno-interlink-mips16 @gol
1078-mabi=@var{abi} -mabicalls -mno-abicalls @gol
1079-mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot @gol
1080-mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float @gol
1081-mno-float -msingle-float -mdouble-float @gol
1082-modd-spreg -mno-odd-spreg @gol
1083-mabs=@var{mode} -mnan=@var{encoding} @gol
1084-mdsp -mno-dsp -mdspr2 -mno-dspr2 @gol
1085-mmcu -mmno-mcu @gol
1086-meva -mno-eva @gol
1087-mvirt -mno-virt @gol
1088-mxpa -mno-xpa @gol
1089-mcrc -mno-crc @gol
1090-mginv -mno-ginv @gol
1091-mmicromips -mno-micromips @gol
1092-mmsa -mno-msa @gol
1093-mloongson-mmi -mno-loongson-mmi @gol
1094-mloongson-ext -mno-loongson-ext @gol
1095-mloongson-ext2 -mno-loongson-ext2 @gol
1096-mfpu=@var{fpu-type} @gol
1097-msmartmips -mno-smartmips @gol
1098-mpaired-single -mno-paired-single -mdmx -mno-mdmx @gol
1099-mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc @gol
1100-mlong64 -mlong32 -msym32 -mno-sym32 @gol
1101-G@var{num} -mlocal-sdata -mno-local-sdata @gol
1102-mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt @gol
1103-membedded-data -mno-embedded-data @gol
1104-muninit-const-in-rodata -mno-uninit-const-in-rodata @gol
1105-mcode-readable=@var{setting} @gol
1106-msplit-addresses -mno-split-addresses @gol
1107-mexplicit-relocs -mno-explicit-relocs @gol
1108-mcheck-zero-division -mno-check-zero-division @gol
1109-mdivide-traps -mdivide-breaks @gol
1110-mload-store-pairs -mno-load-store-pairs @gol
1111-munaligned-access -mno-unaligned-access @gol
1112-mmemcpy -mno-memcpy -mlong-calls -mno-long-calls @gol
1113-mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp @gol
1114-mfix-24k -mno-fix-24k @gol
1115-mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 @gol
1116-mfix-r5900 -mno-fix-r5900 @gol
1117-mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000 @gol
1118-mfix-vr4120 -mno-fix-vr4120 @gol
1119-mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1 @gol
1120-mflush-func=@var{func} -mno-flush-func @gol
1121-mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely @gol
1122-mcompact-branches=@var{policy} @gol
1123-mfp-exceptions -mno-fp-exceptions @gol
1124-mvr4130-align -mno-vr4130-align -msynci -mno-synci @gol
1125-mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4 @gol
1126-mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address @gol
1127-mframe-header-opt -mno-frame-header-opt}
1128
1129@emph{MMIX Options}
1130@gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu @gol
1131-mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols @gol
1132-melf -mbranch-predict -mno-branch-predict -mbase-addresses @gol
1133-mno-base-addresses -msingle-exit -mno-single-exit}
1134
1135@emph{MN10300 Options}
1136@gccoptlist{-mmult-bug -mno-mult-bug @gol
1137-mno-am33 -mam33 -mam33-2 -mam34 @gol
1138-mtune=@var{cpu-type} @gol
1139-mreturn-pointer-on-d0 @gol
1140-mno-crt0 -mrelax -mliw -msetlb}
1141
1142@emph{Moxie Options}
1143@gccoptlist{-meb -mel -mmul.x -mno-crt0}
1144
1145@emph{MSP430 Options}
1146@gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax @gol
1147-mwarn-mcu @gol
1148-mcode-region= -mdata-region= @gol
1149-msilicon-errata= -msilicon-errata-warn= @gol
1150-mhwmult= -minrt -mtiny-printf -mmax-inline-shift=}
1151
1152@emph{NDS32 Options}
1153@gccoptlist{-mbig-endian -mlittle-endian @gol
1154-mreduced-regs -mfull-regs @gol
1155-mcmov -mno-cmov @gol
1156-mext-perf -mno-ext-perf @gol
1157-mext-perf2 -mno-ext-perf2 @gol
1158-mext-string -mno-ext-string @gol
1159-mv3push -mno-v3push @gol
1160-m16bit -mno-16bit @gol
1161-misr-vector-size=@var{num} @gol
1162-mcache-block-size=@var{num} @gol
1163-march=@var{arch} @gol
1164-mcmodel=@var{code-model} @gol
1165-mctor-dtor -mrelax}
1166
1167@emph{Nios II Options}
1168@gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt @gol
1169-mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp} @gol
1170-mel -meb @gol
1171-mno-bypass-cache -mbypass-cache @gol
1172-mno-cache-volatile -mcache-volatile @gol
1173-mno-fast-sw-div -mfast-sw-div @gol
1174-mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div @gol
1175-mcustom-@var{insn}=@var{N} -mno-custom-@var{insn} @gol
1176-mcustom-fpu-cfg=@var{name} @gol
1177-mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name} @gol
1178-march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx}
1179
1180@emph{Nvidia PTX Options}
1181@gccoptlist{-m64 -mmainkernel -moptimize}
1182
1183@emph{OpenRISC Options}
1184@gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div @gol
1185-msoft-mul -msoft-div @gol
1186-msoft-float -mhard-float -mdouble-float -munordered-float @gol
1187-mcmov -mror -mrori -msext -msfimm -mshftimm @gol
1188-mcmodel=@var{code-model}}
1189
1190@emph{PDP-11 Options}
1191@gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 @gol
1192-mint32 -mno-int16 -mint16 -mno-int32 @gol
1193-msplit -munix-asm -mdec-asm -mgnu-asm -mlra}
1194
d77de738
ML
1195@emph{PowerPC Options}
1196See RS/6000 and PowerPC Options.
1197
1198@emph{PRU Options}
1199@gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop @gol
f58e6d42 1200-mabi=@var{variant}}
d77de738
ML
1201
1202@emph{RISC-V Options}
1203@gccoptlist{-mbranch-cost=@var{N-instruction} @gol
1204-mplt -mno-plt @gol
1205-mabi=@var{ABI-string} @gol
1206-mfdiv -mno-fdiv @gol
1207-mdiv -mno-div @gol
1208-misa-spec=@var{ISA-spec-string} @gol
1209-march=@var{ISA-string} @gol
1210-mtune=@var{processor-string} @gol
1211-mpreferred-stack-boundary=@var{num} @gol
1212-msmall-data-limit=@var{N-bytes} @gol
1213-msave-restore -mno-save-restore @gol
1214-mshorten-memrefs -mno-shorten-memrefs @gol
1215-mstrict-align -mno-strict-align @gol
1216-mcmodel=medlow -mcmodel=medany @gol
1217-mexplicit-relocs -mno-explicit-relocs @gol
1218-mrelax -mno-relax @gol
1219-mriscv-attribute -mno-riscv-attribute @gol
1220-malign-data=@var{type} @gol
1221-mbig-endian -mlittle-endian @gol
1222-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol
f58e6d42
CM
1223-mstack-protector-guard-offset=@var{offset} @gol
1224-mcsr-check -mno-csr-check}
d77de738
ML
1225
1226@emph{RL78 Options}
1227@gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs @gol
1228-mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14 @gol
1229-m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts}
1230
1231@emph{RS/6000 and PowerPC Options}
1232@gccoptlist{-mcpu=@var{cpu-type} @gol
1233-mtune=@var{cpu-type} @gol
1234-mcmodel=@var{code-model} @gol
1235-mpowerpc64 @gol
1236-maltivec -mno-altivec @gol
1237-mpowerpc-gpopt -mno-powerpc-gpopt @gol
1238-mpowerpc-gfxopt -mno-powerpc-gfxopt @gol
1239-mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd @gol
1240-mfprnd -mno-fprnd @gol
1241-mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp @gol
1242-mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc @gol
1243-m64 -m32 -mxl-compat -mno-xl-compat -mpe @gol
1244-malign-power -malign-natural @gol
1245-msoft-float -mhard-float -mmultiple -mno-multiple @gol
1246-mupdate -mno-update @gol
1247-mavoid-indexed-addresses -mno-avoid-indexed-addresses @gol
1248-mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol
1249-mstrict-align -mno-strict-align -mrelocatable @gol
1250-mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol
1251-mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol
1252-mdynamic-no-pic -mswdiv -msingle-pic-base @gol
1253-mprioritize-restricted-insns=@var{priority} @gol
1254-msched-costly-dep=@var{dependence_type} @gol
1255-minsert-sched-nops=@var{scheme} @gol
1256-mcall-aixdesc -mcall-eabi -mcall-freebsd @gol
1257-mcall-linux -mcall-netbsd -mcall-openbsd @gol
1258-mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi @gol
1259-mtraceback=@var{traceback_type} @gol
1260-maix-struct-return -msvr4-struct-return @gol
1261-mabi=@var{abi-type} -msecure-plt -mbss-plt @gol
1262-mlongcall -mno-longcall -mpltseq -mno-pltseq @gol
1263-mblock-move-inline-limit=@var{num} @gol
1264-mblock-compare-inline-limit=@var{num} @gol
1265-mblock-compare-inline-loop-limit=@var{num} @gol
1266-mno-block-ops-unaligned-vsx @gol
1267-mstring-compare-inline-limit=@var{num} @gol
1268-misel -mno-isel @gol
1269-mvrsave -mno-vrsave @gol
1270-mmulhw -mno-mulhw @gol
1271-mdlmzb -mno-dlmzb @gol
1272-mprototype -mno-prototype @gol
1273-msim -mmvme -mads -myellowknife -memb -msdata @gol
1274-msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num} @gol
1275-mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision @gol
1276-mno-recip-precision @gol
1277-mveclibabi=@var{type} -mfriz -mno-friz @gol
1278-mpointers-to-nested-functions -mno-pointers-to-nested-functions @gol
1279-msave-toc-indirect -mno-save-toc-indirect @gol
1280-mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector @gol
1281-mcrypto -mno-crypto -mhtm -mno-htm @gol
1282-mquad-memory -mno-quad-memory @gol
1283-mquad-memory-atomic -mno-quad-memory-atomic @gol
1284-mcompat-align-parm -mno-compat-align-parm @gol
1285-mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware @gol
1286-mgnu-attribute -mno-gnu-attribute @gol
1287-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol
1288-mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed @gol
1289-mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect @gol
1290-mprivileged -mno-privileged}
1291
1292@emph{RX Options}
1293@gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu@gol
1294-mcpu=@gol
1295-mbig-endian-data -mlittle-endian-data @gol
1296-msmall-data @gol
1297-msim -mno-sim@gol
1298-mas100-syntax -mno-as100-syntax@gol
1299-mrelax@gol
1300-mmax-constant-size=@gol
1301-mint-register=@gol
1302-mpid@gol
1303-mallow-string-insns -mno-allow-string-insns@gol
1304-mjsr@gol
1305-mno-warn-multiple-fast-interrupts@gol
1306-msave-acc-in-interrupts}
1307
1308@emph{S/390 and zSeries Options}
1309@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
1310-mhard-float -msoft-float -mhard-dfp -mno-hard-dfp @gol
1311-mlong-double-64 -mlong-double-128 @gol
1312-mbackchain -mno-backchain -mpacked-stack -mno-packed-stack @gol
1313-msmall-exec -mno-small-exec -mmvcle -mno-mvcle @gol
1314-m64 -m31 -mdebug -mno-debug -mesa -mzarch @gol
1315-mhtm -mvx -mzvector @gol
1316-mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip @gol
1317-mfused-madd -mno-fused-madd @gol
1318-mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard @gol
1319-mhotpatch=@var{halfwords},@var{halfwords}}
1320
d77de738
ML
1321@emph{SH Options}
1322@gccoptlist{-m1 -m2 -m2e @gol
1323-m2a-nofpu -m2a-single-only -m2a-single -m2a @gol
1324-m3 -m3e @gol
1325-m4-nofpu -m4-single-only -m4-single -m4 @gol
1326-m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al @gol
1327-mb -ml -mdalign -mrelax @gol
1328-mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave @gol
1329-mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct @gol
1330-mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy} @gol
1331-mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} @gol
1332-maccumulate-outgoing-args @gol
1333-matomic-model=@var{atomic-model} @gol
1334-mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch @gol
1335-mcbranch-force-delay-slot @gol
1336-mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra @gol
1337-mpretend-cmove -mtas}
1338
1339@emph{Solaris 2 Options}
1340@gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text @gol
1341-pthreads}
1342
1343@emph{SPARC Options}
1344@gccoptlist{-mcpu=@var{cpu-type} @gol
1345-mtune=@var{cpu-type} @gol
1346-mcmodel=@var{code-model} @gol
1347-mmemory-model=@var{mem-model} @gol
1348-m32 -m64 -mapp-regs -mno-app-regs @gol
1349-mfaster-structs -mno-faster-structs -mflat -mno-flat @gol
1350-mfpu -mno-fpu -mhard-float -msoft-float @gol
1351-mhard-quad-float -msoft-quad-float @gol
1352-mstack-bias -mno-stack-bias @gol
1353-mstd-struct-return -mno-std-struct-return @gol
1354-munaligned-doubles -mno-unaligned-doubles @gol
1355-muser-mode -mno-user-mode @gol
1356-mv8plus -mno-v8plus -mvis -mno-vis @gol
1357-mvis2 -mno-vis2 -mvis3 -mno-vis3 @gol
1358-mvis4 -mno-vis4 -mvis4b -mno-vis4b @gol
1359-mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld @gol
1360-mpopc -mno-popc -msubxc -mno-subxc @gol
1361-mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc @gol
1362-mlra -mno-lra}
1363
1364@emph{System V Options}
1365@gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
1366
1367@emph{V850 Options}
1368@gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep @gol
1369-mprolog-function -mno-prolog-function -mspace @gol
1370-mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol
1371-mapp-regs -mno-app-regs @gol
1372-mdisable-callt -mno-disable-callt @gol
1373-mv850e2v3 -mv850e2 -mv850e1 -mv850es @gol
1374-mv850e -mv850 -mv850e3v5 @gol
1375-mloop @gol
1376-mrelax @gol
1377-mlong-jumps @gol
1378-msoft-float @gol
1379-mhard-float @gol
1380-mgcc-abi @gol
1381-mrh850-abi @gol
1382-mbig-switch}
1383
1384@emph{VAX Options}
1385@gccoptlist{-mg -mgnu -munix -mlra}
1386
1387@emph{Visium Options}
1388@gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float @gol
1389-mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode}
1390
1391@emph{VMS Options}
1392@gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64 @gol
1393-mpointer-size=@var{size}}
1394
1395@emph{VxWorks Options}
1396@gccoptlist{-mrtp -non-static -Bstatic -Bdynamic @gol
1397-Xbind-lazy -Xbind-now}
1398
1399@emph{x86 Options}
1400@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
1401-mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default @gol
1402-mfpmath=@var{unit} @gol
1403-masm=@var{dialect} -mno-fancy-math-387 @gol
1404-mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float @gol
1405-mno-wide-multiply -mrtd -malign-double @gol
1406-mpreferred-stack-boundary=@var{num} @gol
1407-mincoming-stack-boundary=@var{num} @gol
1408-mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait @gol
1409-mrecip -mrecip=@var{opt} @gol
1410-mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt} @gol
1411-mmove-max=@var{bits} -mstore-max=@var{bits} @gol
1412-mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx @gol
1413-mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl @gol
1414-mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes @gol
1415-mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd @gol
1416-mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves @gol
1417-msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop @gol
1418-madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp @gol
1419-mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg @gol
1420-mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call @gol
1421-mavx512vbmi2 -mavx512bf16 -menqcmd @gol
1422-mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq @gol
1423-mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid @gol
1424-mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk@gol
1425-mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni@gol
1426-mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16 @gol
1427-mprefetchi -mraoint @gol
1428-mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops @gol
1429-minline-stringops-dynamically -mstringop-strategy=@var{alg} @gol
1430-mkl -mwidekl @gol
1431-mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy} @gol
1432-mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
1433-m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128 @gol
1434-mregparm=@var{num} -msseregparm @gol
1435-mveclibabi=@var{type} -mvect8-ret-in-mem @gol
1436-mpc32 -mpc64 -mpc80 -mstackrealign @gol
1437-momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs @gol
1438-mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} @gol
1439-m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num} @gol
1440-msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv @gol
1441-minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name} @gol
1442-mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
1443-malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
1444-mstack-protector-guard-reg=@var{reg} @gol
1445-mstack-protector-guard-offset=@var{offset} @gol
1446-mstack-protector-guard-symbol=@var{symbol} @gol
1447-mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop @gol
1448-mindirect-branch=@var{choice} -mfunction-return=@var{choice} @gol
1449-mindirect-branch-register -mharden-sls=@var{choice} @gol
ce51e843
ML
1450-mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access @gol
1451-munroll-only-small-loops}
d77de738
ML
1452
1453@emph{x86 Windows Options}
1454@gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
1455-mnop-fun-dllimport -mthread @gol
1456-municode -mwin32 -mwindows -fno-set-stack-executable}
1457
1458@emph{Xstormy16 Options}
1459@gccoptlist{-msim}
1460
1461@emph{Xtensa Options}
1462@gccoptlist{-mconst16 -mno-const16 @gol
1463-mfused-madd -mno-fused-madd @gol
1464-mforce-no-pic @gol
1465-mserialize-volatile -mno-serialize-volatile @gol
1466-mtext-section-literals -mno-text-section-literals @gol
1467-mauto-litpools -mno-auto-litpools @gol
1468-mtarget-align -mno-target-align @gol
1469-mlongcalls -mno-longcalls @gol
1470-mabi=@var{abi-type} @gol
1471-mextra-l32r-costs=@var{cycles}}
1472
1473@emph{zSeries Options}
1474See S/390 and zSeries Options.
1475@end table
1476
1477
1478@node Overall Options
1479@section Options Controlling the Kind of Output
1480
1481Compilation can involve up to four stages: preprocessing, compilation
1482proper, assembly and linking, always in that order. GCC is capable of
1483preprocessing and compiling several files either into several
1484assembler input files, or into one assembler input file; then each
1485assembler input file produces an object file, and linking combines all
1486the object files (those newly compiled, and those specified as input)
1487into an executable file.
1488
1489@cindex file name suffix
1490For any given input file, the file name suffix determines what kind of
1491compilation is done:
1492
1493@table @gcctabopt
1494@item @var{file}.c
1495C source code that must be preprocessed.
1496
1497@item @var{file}.i
1498C source code that should not be preprocessed.
1499
1500@item @var{file}.ii
1501C++ source code that should not be preprocessed.
1502
1503@item @var{file}.m
1504Objective-C source code. Note that you must link with the @file{libobjc}
1505library to make an Objective-C program work.
1506
1507@item @var{file}.mi
1508Objective-C source code that should not be preprocessed.
1509
1510@item @var{file}.mm
1511@itemx @var{file}.M
1512Objective-C++ source code. Note that you must link with the @file{libobjc}
1513library to make an Objective-C++ program work. Note that @samp{.M} refers
1514to a literal capital M@.
1515
1516@item @var{file}.mii
1517Objective-C++ source code that should not be preprocessed.
1518
1519@item @var{file}.h
1520C, C++, Objective-C or Objective-C++ header file to be turned into a
1521precompiled header (default), or C, C++ header file to be turned into an
1522Ada spec (via the @option{-fdump-ada-spec} switch).
1523
1524@item @var{file}.cc
1525@itemx @var{file}.cp
1526@itemx @var{file}.cxx
1527@itemx @var{file}.cpp
1528@itemx @var{file}.CPP
1529@itemx @var{file}.c++
1530@itemx @var{file}.C
1531C++ source code that must be preprocessed. Note that in @samp{.cxx},
1532the last two letters must both be literally @samp{x}. Likewise,
1533@samp{.C} refers to a literal capital C@.
1534
1535@item @var{file}.mm
1536@itemx @var{file}.M
1537Objective-C++ source code that must be preprocessed.
1538
1539@item @var{file}.mii
1540Objective-C++ source code that should not be preprocessed.
1541
1542@item @var{file}.hh
1543@itemx @var{file}.H
1544@itemx @var{file}.hp
1545@itemx @var{file}.hxx
1546@itemx @var{file}.hpp
1547@itemx @var{file}.HPP
1548@itemx @var{file}.h++
1549@itemx @var{file}.tcc
1550C++ header file to be turned into a precompiled header or Ada spec.
1551
1552@item @var{file}.f
1553@itemx @var{file}.for
1554@itemx @var{file}.ftn
1555Fixed form Fortran source code that should not be preprocessed.
1556
1557@item @var{file}.F
1558@itemx @var{file}.FOR
1559@itemx @var{file}.fpp
1560@itemx @var{file}.FPP
1561@itemx @var{file}.FTN
1562Fixed form Fortran source code that must be preprocessed (with the traditional
1563preprocessor).
1564
1565@item @var{file}.f90
1566@itemx @var{file}.f95
1567@itemx @var{file}.f03
1568@itemx @var{file}.f08
1569Free form Fortran source code that should not be preprocessed.
1570
1571@item @var{file}.F90
1572@itemx @var{file}.F95
1573@itemx @var{file}.F03
1574@itemx @var{file}.F08
1575Free form Fortran source code that must be preprocessed (with the
1576traditional preprocessor).
1577
1578@item @var{file}.go
1579Go source code.
1580
1581@item @var{file}.d
1582D source code.
1583
1584@item @var{file}.di
1585D interface file.
1586
1587@item @var{file}.dd
1588D documentation code (Ddoc).
1589
1590@item @var{file}.ads
1591Ada source code file that contains a library unit declaration (a
1592declaration of a package, subprogram, or generic, or a generic
1593instantiation), or a library unit renaming declaration (a package,
1594generic, or subprogram renaming declaration). Such files are also
1595called @dfn{specs}.
1596
1597@item @var{file}.adb
1598Ada source code file containing a library unit body (a subprogram or
1599package body). Such files are also called @dfn{bodies}.
1600
1601@c GCC also knows about some suffixes for languages not yet included:
1602@c Ratfor:
1603@c @var{file}.r
1604
1605@item @var{file}.s
1606Assembler code.
1607
1608@item @var{file}.S
1609@itemx @var{file}.sx
1610Assembler code that must be preprocessed.
1611
1612@item @var{other}
1613An object file to be fed straight into linking.
1614Any file name with no recognized suffix is treated this way.
1615@end table
1616
1617@opindex x
1618You can specify the input language explicitly with the @option{-x} option:
1619
1620@table @gcctabopt
1621@item -x @var{language}
1622Specify explicitly the @var{language} for the following input files
1623(rather than letting the compiler choose a default based on the file
1624name suffix). This option applies to all following input files until
1625the next @option{-x} option. Possible values for @var{language} are:
1626@smallexample
1627c c-header cpp-output
1628c++ c++-header c++-system-header c++-user-header c++-cpp-output
1629objective-c objective-c-header objective-c-cpp-output
1630objective-c++ objective-c++-header objective-c++-cpp-output
1631assembler assembler-with-cpp
1632ada
1633d
1634f77 f77-cpp-input f95 f95-cpp-input
1635go
1636@end smallexample
1637
1638@item -x none
1639Turn off any specification of a language, so that subsequent files are
1640handled according to their file name suffixes (as they are if @option{-x}
1641has not been used at all).
1642@end table
1643
1644If you only want some of the stages of compilation, you can use
1645@option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
1646one of the options @option{-c}, @option{-S}, or @option{-E} to say where
1647@command{gcc} is to stop. Note that some combinations (for example,
1648@samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
1649
1650@table @gcctabopt
1651@item -c
1652@opindex c
1653Compile or assemble the source files, but do not link. The linking
1654stage simply is not done. The ultimate output is in the form of an
1655object file for each source file.
1656
1657By default, the object file name for a source file is made by replacing
1658the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
1659
1660Unrecognized input files, not requiring compilation or assembly, are
1661ignored.
1662
1663@item -S
1664@opindex S
1665Stop after the stage of compilation proper; do not assemble. The output
1666is in the form of an assembler code file for each non-assembler input
1667file specified.
1668
1669By default, the assembler file name for a source file is made by
1670replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
1671
1672Input files that don't require compilation are ignored.
1673
1674@item -E
1675@opindex E
1676Stop after the preprocessing stage; do not run the compiler proper. The
1677output is in the form of preprocessed source code, which is sent to the
1678standard output.
1679
1680Input files that don't require preprocessing are ignored.
1681
1682@cindex output file option
1683@item -o @var{file}
1684@opindex o
1685Place the primary output in file @var{file}. This applies to whatever
1686sort of output is being produced, whether it be an executable file, an
1687object file, an assembler file or preprocessed C code.
1688
1689If @option{-o} is not specified, the default is to put an executable
1690file in @file{a.out}, the object file for
1691@file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
1692assembler file in @file{@var{source}.s}, a precompiled header file in
1693@file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
1694standard output.
1695
1696Though @option{-o} names only the primary output, it also affects the
1697naming of auxiliary and dump outputs. See the examples below. Unless
1698overridden, both auxiliary outputs and dump outputs are placed in the
1699same directory as the primary output. In auxiliary outputs, the suffix
1700of the input file is replaced with that of the auxiliary output file
1701type; in dump outputs, the suffix of the dump file is appended to the
1702input file suffix. In compilation commands, the base name of both
1703auxiliary and dump outputs is that of the primary output; in compile and
1704link commands, the primary output name, minus the executable suffix, is
1705combined with the input file name. If both share the same base name,
1706disregarding the suffix, the result of the combination is that base
1707name, otherwise, they are concatenated, separated by a dash.
1708
1709@smallexample
1710gcc -c foo.c ...
1711@end smallexample
1712
1713will use @file{foo.o} as the primary output, and place aux outputs and
1714dumps next to it, e.g., aux file @file{foo.dwo} for
1715@option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for
1716@option{-fdump-rtl-final}.
1717
1718If a non-linker output file is explicitly specified, aux and dump files
1719by default take the same base name:
1720
1721@smallexample
1722gcc -c foo.c -o dir/foobar.o ...
1723@end smallexample
1724
1725will name aux outputs @file{dir/foobar.*} and dump outputs
1726@file{dir/foobar.c.*}.
1727
1728A linker output will instead prefix aux and dump outputs:
1729
1730@smallexample
1731gcc foo.c bar.c -o dir/foobar ...
1732@end smallexample
1733
1734will generally name aux outputs @file{dir/foobar-foo.*} and
1735@file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and
1736@file{dir/foobar-bar.c.*}.
1737
1738The one exception to the above is when the executable shares the base
1739name with the single input:
1740
1741@smallexample
1742gcc foo.c -o dir/foo ...
1743@end smallexample
1744
1745in which case aux outputs are named @file{dir/foo.*} and dump outputs
1746named @file{dir/foo.c.*}.
1747
1748The location and the names of auxiliary and dump outputs can be adjusted
1749by the options @option{-dumpbase}, @option{-dumpbase-ext},
1750@option{-dumpdir}, @option{-save-temps=cwd}, and
1751@option{-save-temps=obj}.
1752
1753
1754@item -dumpbase @var{dumpbase}
1755@opindex dumpbase
1756This option sets the base name for auxiliary and dump output files. It
1757does not affect the name of the primary output file. Intermediate
1758outputs, when preserved, are not regarded as primary outputs, but as
1759auxiliary outputs:
1760
1761@smallexample
1762gcc -save-temps -S foo.c
1763@end smallexample
1764
1765saves the (no longer) temporary preprocessed file in @file{foo.i}, and
1766then compiles to the (implied) output file @file{foo.s}, whereas:
1767
1768@smallexample
1769gcc -save-temps -dumpbase save-foo -c foo.c
1770@end smallexample
1771
1772preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now
1773an intermediate, thus auxiliary output), and then assembles to the
1774(implied) output file @file{foo.o}.
1775
1776Absent this option, dump and aux files take their names from the input
1777file, or from the (non-linker) output file, if one is explicitly
1778specified: dump output files (e.g. those requested by @option{-fdump-*}
1779options) with the input name suffix, and aux output files (those
1780requested by other non-dump options, e.g. @code{-save-temps},
1781@code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it.
1782
1783Similar suffix differentiation of dump and aux outputs can be attained
1784for explicitly-given @option{-dumpbase basename.suf} by also specifying
1785@option{-dumpbase-ext .suf}.
1786
1787If @var{dumpbase} is explicitly specified with any directory component,
1788any @var{dumppfx} specification (e.g. @option{-dumpdir} or
1789@option{-save-temps=*}) is ignored, and instead of appending to it,
1790@var{dumpbase} fully overrides it:
1791
1792@smallexample
1793gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
1794 -dumpdir pfx- -save-temps=cwd ...
1795@end smallexample
1796
1797creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding
1798@file{dir/} in @option{-o}, the @file{./} prefix implied by
1799@option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}.
1800
1801When @option{-dumpbase} is specified in a command that compiles multiple
1802inputs, or that compiles and then links, it may be combined with
1803@var{dumppfx}, as specified under @option{-dumpdir}. Then, each input
1804file is compiled using the combined @var{dumppfx}, and default values
1805for @var{dumpbase} and @var{auxdropsuf} are computed for each input
1806file:
1807
1808@smallexample
1809gcc foo.c bar.c -c -dumpbase main ...
1810@end smallexample
1811
1812creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids
1813overwriting the auxiliary and dump outputs by using the @var{dumpbase}
1814as a prefix, creating auxiliary and dump outputs named @file{main-foo.*}
1815and @file{main-bar.*}.
1816
1817An empty string specified as @var{dumpbase} avoids the influence of the
1818output basename in the naming of auxiliary and dump outputs during
1819compilation, computing default values :
1820
1821@smallexample
1822gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
1823@end smallexample
1824
1825will name aux outputs @file{dir/foo.*} and dump outputs
1826@file{dir/foo.c.*}. Note how their basenames are taken from the input
1827name, but the directory still defaults to that of the output.
1828
1829The empty-string dumpbase does not prevent the use of the output
1830basename for outputs during linking:
1831
1832@smallexample
1833gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
1834@end smallexample
1835
1836The compilation of the source files will name auxiliary outputs
1837@file{dir/foo.*} and @file{dir/bar.*}, and dump outputs
1838@file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during
1839linking will use @file{dir/foobar.} as the prefix for dumps and
1840auxiliary files.
1841
1842
1843@item -dumpbase-ext @var{auxdropsuf}
1844@opindex dumpbase-ext
1845When forming the name of an auxiliary (but not a dump) output file, drop
1846trailing @var{auxdropsuf} from @var{dumpbase} before appending any
1847suffixes. If not specified, this option defaults to the suffix of a
1848default @var{dumpbase}, i.e., the suffix of the input file when
1849@option{-dumpbase} is not present in the command line, or @var{dumpbase}
1850is combined with @var{dumppfx}.
1851
1852@smallexample
1853gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
1854@end smallexample
1855
1856creates @file{dir/foo.o} as the main output, and generates auxiliary
1857outputs in @file{dir/x-foo.*}, taking the location of the primary
1858output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump
1859outputs retain the suffix: @file{dir/x-foo.c.*}.
1860
1861This option is disregarded if it does not match the suffix of a
1862specified @var{dumpbase}, except as an alternative to the executable
1863suffix when appending the linker output base name to @var{dumppfx}, as
1864specified below:
1865
1866@smallexample
1867gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
1868@end smallexample
1869
1870creates @file{main.out} as the primary output, and avoids overwriting
1871the auxiliary and dump outputs by using the executable name minus
1872@var{auxdropsuf} as a prefix, creating auxiliary outputs named
1873@file{main-foo.*} and @file{main-bar.*} and dump outputs named
1874@file{main-foo.c.*} and @file{main-bar.c.*}.
1875
1876
1877@item -dumpdir @var{dumppfx}
1878@opindex dumpdir
1879When forming the name of an auxiliary or dump output file, use
1880@var{dumppfx} as a prefix:
1881
1882@smallexample
1883gcc -dumpdir pfx- -c foo.c ...
1884@end smallexample
1885
1886creates @file{foo.o} as the primary output, and auxiliary outputs named
1887@file{pfx-foo.*}, combining the given @var{dumppfx} with the default
1888@var{dumpbase} derived from the default primary output, derived in turn
1889from the input name. Dump outputs also take the input name suffix:
1890@file{pfx-foo.c.*}.
1891
1892If @var{dumppfx} is to be used as a directory name, it must end with a
1893directory separator:
1894
1895@smallexample
1896gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
1897@end smallexample
1898
1899creates @file{obj/bar.o} as the primary output, and auxiliary outputs
1900named @file{dir/bar.*}, combining the given @var{dumppfx} with the
1901default @var{dumpbase} derived from the primary output name. Dump
1902outputs also take the input name suffix: @file{dir/bar.c.*}.
1903
1904It defaults to the location of the output file, unless the output
1905file is a special file like @code{/dev/null}. Options
1906@option{-save-temps=cwd} and @option{-save-temps=obj} override this
1907default, just like an explicit @option{-dumpdir} option. In case
1908multiple such options are given, the last one prevails:
1909
1910@smallexample
1911gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
1912@end smallexample
1913
1914outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because
1915@option{-save-temps=*} overrides the @var{dumppfx} given by the earlier
1916@option{-dumpdir} option. It does not matter that @option{=obj} is the
1917default for @option{-save-temps}, nor that the output directory is
1918implicitly the current directory. Dump outputs are named
1919@file{foo.c.*}.
1920
1921When compiling from multiple input files, if @option{-dumpbase} is
1922specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash
1923are appended to (or override, if containing any directory components) an
1924explicit or defaulted @var{dumppfx}, so that each of the multiple
1925compilations gets differently-named aux and dump outputs.
1926
1927@smallexample
1928gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
1929@end smallexample
1930
1931outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and
1932@file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}.
1933Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*}
1934and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the
1935single-input compilation:
1936
1937@smallexample
1938gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
1939@end smallexample
1940
1941that, applying @option{-dumpbase} to a single source, does not compute
1942and append a separate @var{dumpbase} per input file. Its auxiliary and
1943dump outputs go in @file{dir/pfx-main.*}.
1944
1945When compiling and then linking from multiple input files, a defaulted
1946or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}-
1947transformation above (e.g. the compilation of @file{foo.c} and
1948@file{bar.c} above, but without @option{-c}). If neither
1949@option{-dumpdir} nor @option{-dumpbase} are given, the linker output
1950base name, minus @var{auxdropsuf}, if specified, or the executable
1951suffix otherwise, plus a dash is appended to the default @var{dumppfx}
1952instead. Note, however, that unlike earlier cases of linking:
1953
1954@smallexample
1955gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
1956@end smallexample
1957
1958does not append the output name @file{main} to @var{dumppfx}, because
1959@option{-dumpdir} is explicitly specified. The goal is that the
1960explicitly-specified @var{dumppfx} may contain the specified output name
1961as part of the prefix, if desired; only an explicitly-specified
1962@option{-dumpbase} would be combined with it, in order to avoid simply
1963discarding a meaningful option.
1964
1965When compiling and then linking from a single input file, the linker
1966output base name will only be appended to the default @var{dumppfx} as
1967above if it does not share the base name with the single input file
1968name. This has been covered in single-input linking cases above, but
1969not with an explicit @option{-dumpdir} that inhibits the combination,
1970even if overridden by @option{-save-temps=*}:
1971
1972@smallexample
1973gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
1974@end smallexample
1975
1976Auxiliary outputs are named @file{foo.*}, and dump outputs
1977@file{foo.c.*}, in the current working directory as ultimately requested
1978by @option{-save-temps=cwd}.
1979
1980Summing it all up for an intuitive though slightly imprecise data flow:
1981the primary output name is broken into a directory part and a basename
1982part; @var{dumppfx} is set to the former, unless overridden by
1983@option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set
1984to the latter, unless overriden by @option{-dumpbase}. If there are
1985multiple inputs or linking, this @var{dumpbase} may be combined with
1986@var{dumppfx} and taken from each input file. Auxiliary output names
1987for each input are formed by combining @var{dumppfx}, @var{dumpbase}
1988minus suffix, and the auxiliary output suffix; dump output names are
1989only different in that the suffix from @var{dumpbase} is retained.
1990
1991When it comes to auxiliary and dump outputs created during LTO
1992recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as
1993given or as derived from the linker output name but not from inputs,
1994even in cases in which this combination would not otherwise be used as
1995such, is passed down with a trailing period replacing the compiler-added
1996dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper};
1997being involved in linking, this program does not normally get any
1998@option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them.
1999
2000When running sub-compilers, @command{lto-wrapper} appends LTO stage
2001names to the received @var{dumppfx}, ensures it contains a directory
2002component so that it overrides any @option{-dumpdir}, and passes that as
2003@option{-dumpbase} to sub-compilers.
2004
2005@item -v
2006@opindex v
2007Print (on standard error output) the commands executed to run the stages
2008of compilation. Also print the version number of the compiler driver
2009program and of the preprocessor and the compiler proper.
2010
2011@item -###
2012@opindex ###
2013Like @option{-v} except the commands are not executed and arguments
2014are quoted unless they contain only alphanumeric characters or @code{./-_}.
2015This is useful for shell scripts to capture the driver-generated command lines.
2016
2017@item --help
2018@opindex help
2019Print (on the standard output) a description of the command-line options
2020understood by @command{gcc}. If the @option{-v} option is also specified
2021then @option{--help} is also passed on to the various processes
2022invoked by @command{gcc}, so that they can display the command-line options
2023they accept. If the @option{-Wextra} option has also been specified
2024(prior to the @option{--help} option), then command-line options that
2025have no documentation associated with them are also displayed.
2026
2027@item --target-help
2028@opindex target-help
2029Print (on the standard output) a description of target-specific command-line
2030options for each tool. For some targets extra target-specific
2031information may also be printed.
2032
2033@item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
2034Print (on the standard output) a description of the command-line
2035options understood by the compiler that fit into all specified classes
2036and qualifiers. These are the supported classes:
2037
2038@table @asis
2039@item @samp{optimizers}
2040Display all of the optimization options supported by the
2041compiler.
2042
2043@item @samp{warnings}
2044Display all of the options controlling warning messages
2045produced by the compiler.
2046
2047@item @samp{target}
2048Display target-specific options. Unlike the
2049@option{--target-help} option however, target-specific options of the
2050linker and assembler are not displayed. This is because those
2051tools do not currently support the extended @option{--help=} syntax.
2052
2053@item @samp{params}
2054Display the values recognized by the @option{--param}
2055option.
2056
2057@item @var{language}
2058Display the options supported for @var{language}, where
2059@var{language} is the name of one of the languages supported in this
2060version of GCC@. If an option is supported by all languages, one needs
2061to select @samp{common} class.
2062
2063@item @samp{common}
2064Display the options that are common to all languages.
2065@end table
2066
2067These are the supported qualifiers:
2068
2069@table @asis
2070@item @samp{undocumented}
2071Display only those options that are undocumented.
2072
2073@item @samp{joined}
2074Display options taking an argument that appears after an equal
2075sign in the same continuous piece of text, such as:
2076@samp{--help=target}.
2077
2078@item @samp{separate}
2079Display options taking an argument that appears as a separate word
2080following the original option, such as: @samp{-o output-file}.
2081@end table
2082
2083Thus for example to display all the undocumented target-specific
2084switches supported by the compiler, use:
2085
2086@smallexample
2087--help=target,undocumented
2088@end smallexample
2089
2090The sense of a qualifier can be inverted by prefixing it with the
2091@samp{^} character, so for example to display all binary warning
2092options (i.e., ones that are either on or off and that do not take an
2093argument) that have a description, use:
2094
2095@smallexample
2096--help=warnings,^joined,^undocumented
2097@end smallexample
2098
2099The argument to @option{--help=} should not consist solely of inverted
2100qualifiers.
2101
2102Combining several classes is possible, although this usually
2103restricts the output so much that there is nothing to display. One
2104case where it does work, however, is when one of the classes is
2105@var{target}. For example, to display all the target-specific
2106optimization options, use:
2107
2108@smallexample
2109--help=target,optimizers
2110@end smallexample
2111
2112The @option{--help=} option can be repeated on the command line. Each
2113successive use displays its requested class of options, skipping
2114those that have already been displayed. If @option{--help} is also
2115specified anywhere on the command line then this takes precedence
2116over any @option{--help=} option.
2117
2118If the @option{-Q} option appears on the command line before the
2119@option{--help=} option, then the descriptive text displayed by
2120@option{--help=} is changed. Instead of describing the displayed
2121options, an indication is given as to whether the option is enabled,
2122disabled or set to a specific value (assuming that the compiler
2123knows this at the point where the @option{--help=} option is used).
2124
2125Here is a truncated example from the ARM port of @command{gcc}:
2126
2127@smallexample
2128 % gcc -Q -mabi=2 --help=target -c
2129 The following options are target specific:
2130 -mabi= 2
2131 -mabort-on-noreturn [disabled]
2132 -mapcs [disabled]
2133@end smallexample
2134
2135The output is sensitive to the effects of previous command-line
2136options, so for example it is possible to find out which optimizations
2137are enabled at @option{-O2} by using:
2138
2139@smallexample
2140-Q -O2 --help=optimizers
2141@end smallexample
2142
2143Alternatively you can discover which binary optimizations are enabled
2144by @option{-O3} by using:
2145
2146@smallexample
2147gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
2148gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
2149diff /tmp/O2-opts /tmp/O3-opts | grep enabled
2150@end smallexample
2151
2152@item --version
2153@opindex version
2154Display the version number and copyrights of the invoked GCC@.
2155
2156@item -pass-exit-codes
2157@opindex pass-exit-codes
2158Normally the @command{gcc} program exits with the code of 1 if any
2159phase of the compiler returns a non-success return code. If you specify
2160@option{-pass-exit-codes}, the @command{gcc} program instead returns with
2161the numerically highest error produced by any phase returning an error
2162indication. The C, C++, and Fortran front ends return 4 if an internal
2163compiler error is encountered.
2164
2165@item -pipe
2166@opindex pipe
2167Use pipes rather than temporary files for communication between the
2168various stages of compilation. This fails to work on some systems where
2169the assembler is unable to read from a pipe; but the GNU assembler has
2170no trouble.
2171
2172@item -specs=@var{file}
2173@opindex specs
2174Process @var{file} after the compiler reads in the standard @file{specs}
2175file, in order to override the defaults which the @command{gcc} driver
2176program uses when determining what switches to pass to @command{cc1},
2177@command{cc1plus}, @command{as}, @command{ld}, etc. More than one
2178@option{-specs=@var{file}} can be specified on the command line, and they
2179are processed in order, from left to right. @xref{Spec Files}, for
2180information about the format of the @var{file}.
2181
2182@item -wrapper
2183@opindex wrapper
2184Invoke all subcommands under a wrapper program. The name of the
2185wrapper program and its parameters are passed as a comma separated
2186list.
2187
2188@smallexample
2189gcc -c t.c -wrapper gdb,--args
2190@end smallexample
2191
2192@noindent
2193This invokes all subprograms of @command{gcc} under
2194@samp{gdb --args}, thus the invocation of @command{cc1} is
2195@samp{gdb --args cc1 @dots{}}.
2196
2197@item -ffile-prefix-map=@var{old}=@var{new}
2198@opindex ffile-prefix-map
2199When compiling files residing in directory @file{@var{old}}, record
2200any references to them in the result of the compilation as if the
2201files resided in directory @file{@var{new}} instead. Specifying this
2202option is equivalent to specifying all the individual
2203@option{-f*-prefix-map} options. This can be used to make reproducible
11543b27
RP
2204builds that are location independent. Directories referenced by
2205directives are not affected by these options. See also
d77de738
ML
2206@option{-fmacro-prefix-map}, @option{-fdebug-prefix-map} and
2207@option{-fprofile-prefix-map}.
2208
2209@item -fplugin=@var{name}.so
2210@opindex fplugin
2211Load the plugin code in file @var{name}.so, assumed to be a
2212shared object to be dlopen'd by the compiler. The base name of
2213the shared object file is used to identify the plugin for the
2214purposes of argument parsing (See
2215@option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below).
2216Each plugin should define the callback functions specified in the
2217Plugins API.
2218
2219@item -fplugin-arg-@var{name}-@var{key}=@var{value}
2220@opindex fplugin-arg
2221Define an argument called @var{key} with a value of @var{value}
2222for the plugin called @var{name}.
2223
2224@item -fdump-ada-spec@r{[}-slim@r{]}
2225@opindex fdump-ada-spec
2226For C and C++ source and include files, generate corresponding Ada specs.
2227@xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
2228GNAT User's Guide}, which provides detailed documentation on this feature.
2229
2230@item -fada-spec-parent=@var{unit}
2231@opindex fada-spec-parent
2232In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate
2233Ada specs as child units of parent @var{unit}.
2234
2235@item -fdump-go-spec=@var{file}
2236@opindex fdump-go-spec
2237For input files in any language, generate corresponding Go
2238declarations in @var{file}. This generates Go @code{const},
2239@code{type}, @code{var}, and @code{func} declarations which may be a
2240useful way to start writing a Go interface to code written in some
2241other language.
2242
2243@include @value{srcdir}/../libiberty/at-file.texi
2244@end table
2245
2246@node Invoking G++
2247@section Compiling C++ Programs
2248
2249@cindex suffixes for C++ source
2250@cindex C++ source file suffixes
2251C++ source files conventionally use one of the suffixes @samp{.C},
2252@samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
2253@samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
2254@samp{.H}, or (for shared template code) @samp{.tcc}; and
2255preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
2256files with these names and compiles them as C++ programs even if you
2257call the compiler the same way as for compiling C programs (usually
2258with the name @command{gcc}).
2259
2260@findex g++
2261@findex c++
2262However, the use of @command{gcc} does not add the C++ library.
2263@command{g++} is a program that calls GCC and automatically specifies linking
2264against the C++ library. It treats @samp{.c},
2265@samp{.h} and @samp{.i} files as C++ source files instead of C source
2266files unless @option{-x} is used. This program is also useful when
2267precompiling a C header file with a @samp{.h} extension for use in C++
2268compilations. On many systems, @command{g++} is also installed with
2269the name @command{c++}.
2270
2271@cindex invoking @command{g++}
2272When you compile C++ programs, you may specify many of the same
2273command-line options that you use for compiling programs in any
2274language; or command-line options meaningful for C and related
2275languages; or options that are meaningful only for C++ programs.
2276@xref{C Dialect Options,,Options Controlling C Dialect}, for
2277explanations of options for languages related to C@.
2278@xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
2279explanations of options that are meaningful only for C++ programs.
2280
2281@node C Dialect Options
2282@section Options Controlling C Dialect
2283@cindex dialect options
2284@cindex language dialect options
2285@cindex options, dialect
2286
2287The following options control the dialect of C (or languages derived
2288from C, such as C++, Objective-C and Objective-C++) that the compiler
2289accepts:
2290
2291@table @gcctabopt
2292@cindex ANSI support
2293@cindex ISO support
2294@item -ansi
2295@opindex ansi
2296In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
2297equivalent to @option{-std=c++98}.
2298
2299This turns off certain features of GCC that are incompatible with ISO
2300C90 (when compiling C code), or of standard C++ (when compiling C++ code),
2301such as the @code{asm} and @code{typeof} keywords, and
2302predefined macros such as @code{unix} and @code{vax} that identify the
2303type of system you are using. It also enables the undesirable and
2304rarely used ISO trigraph feature. For the C compiler,
2305it disables recognition of C++ style @samp{//} comments as well as
2306the @code{inline} keyword.
2307
2308The alternate keywords @code{__asm__}, @code{__extension__},
2309@code{__inline__} and @code{__typeof__} continue to work despite
2310@option{-ansi}. You would not want to use them in an ISO C program, of
2311course, but it is useful to put them in header files that might be included
2312in compilations done with @option{-ansi}. Alternate predefined macros
2313such as @code{__unix__} and @code{__vax__} are also available, with or
2314without @option{-ansi}.
2315
2316The @option{-ansi} option does not cause non-ISO programs to be
2317rejected gratuitously. For that, @option{-Wpedantic} is required in
2318addition to @option{-ansi}. @xref{Warning Options}.
2319
2320The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
2321option is used. Some header files may notice this macro and refrain
2322from declaring certain functions or defining certain macros that the
2323ISO standard doesn't call for; this is to avoid interfering with any
2324programs that might use these names for other things.
2325
2326Functions that are normally built in but do not have semantics
2327defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
2328functions when @option{-ansi} is used. @xref{Other Builtins,,Other
2329built-in functions provided by GCC}, for details of the functions
2330affected.
2331
2332@item -std=
2333@opindex std
2334Determine the language standard. @xref{Standards,,Language Standards
2335Supported by GCC}, for details of these standard versions. This option
2336is currently only supported when compiling C or C++.
2337
2338The compiler can accept several base standards, such as @samp{c90} or
2339@samp{c++98}, and GNU dialects of those standards, such as
2340@samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the
2341compiler accepts all programs following that standard plus those
2342using GNU extensions that do not contradict it. For example,
2343@option{-std=c90} turns off certain features of GCC that are
2344incompatible with ISO C90, such as the @code{asm} and @code{typeof}
2345keywords, but not other GNU extensions that do not have a meaning in
2346ISO C90, such as omitting the middle term of a @code{?:}
2347expression. On the other hand, when a GNU dialect of a standard is
2348specified, all features supported by the compiler are enabled, even when
2349those features change the meaning of the base standard. As a result, some
2350strict-conforming programs may be rejected. The particular standard
2351is used by @option{-Wpedantic} to identify which features are GNU
2352extensions given that version of the standard. For example
2353@option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//}
2354comments, while @option{-std=gnu99 -Wpedantic} does not.
2355
2356A value for this option must be provided; possible values are
2357
2358@table @samp
2359@item c90
2360@itemx c89
2361@itemx iso9899:1990
2362Support all ISO C90 programs (certain GNU extensions that conflict
2363with ISO C90 are disabled). Same as @option{-ansi} for C code.
2364
2365@item iso9899:199409
2366ISO C90 as modified in amendment 1.
2367
2368@item c99
2369@itemx c9x
2370@itemx iso9899:1999
2371@itemx iso9899:199x
2372ISO C99. This standard is substantially completely supported, modulo
2373bugs and floating-point issues
2374(mainly but not entirely relating to optional C99 features from
2375Annexes F and G). See
2376@w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The
2377names @samp{c9x} and @samp{iso9899:199x} are deprecated.
2378
2379@item c11
2380@itemx c1x
2381@itemx iso9899:2011
2382ISO C11, the 2011 revision of the ISO C standard. This standard is
2383substantially completely supported, modulo bugs, floating-point issues
2384(mainly but not entirely relating to optional C11 features from
2385Annexes F and G) and the optional Annexes K (Bounds-checking
2386interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
2387
2388@item c17
2389@itemx c18
2390@itemx iso9899:2017
2391@itemx iso9899:2018
2392ISO C17, the 2017 revision of the ISO C standard
2393(published in 2018). This standard is
2394same as C11 except for corrections of defects (all of which are also
2395applied with @option{-std=c11}) and a new value of
2396@code{__STDC_VERSION__}, and so is supported to the same extent as C11.
2397
2398@item c2x
2399The next version of the ISO C standard, still under development. The
2400support for this version is experimental and incomplete.
2401
2402@item gnu90
2403@itemx gnu89
2404GNU dialect of ISO C90 (including some C99 features).
2405
2406@item gnu99
2407@itemx gnu9x
2408GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
2409
2410@item gnu11
2411@itemx gnu1x
2412GNU dialect of ISO C11.
2413The name @samp{gnu1x} is deprecated.
2414
2415@item gnu17
2416@itemx gnu18
2417GNU dialect of ISO C17. This is the default for C code.
2418
2419@item gnu2x
2420The next version of the ISO C standard, still under development, plus
2421GNU extensions. The support for this version is experimental and
2422incomplete.
2423
2424@item c++98
2425@itemx c++03
2426The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
2427additional defect reports. Same as @option{-ansi} for C++ code.
2428
2429@item gnu++98
2430@itemx gnu++03
2431GNU dialect of @option{-std=c++98}.
2432
2433@item c++11
2434@itemx c++0x
2435The 2011 ISO C++ standard plus amendments.
2436The name @samp{c++0x} is deprecated.
2437
2438@item gnu++11
2439@itemx gnu++0x
2440GNU dialect of @option{-std=c++11}.
2441The name @samp{gnu++0x} is deprecated.
2442
2443@item c++14
2444@itemx c++1y
2445The 2014 ISO C++ standard plus amendments.
2446The name @samp{c++1y} is deprecated.
2447
2448@item gnu++14
2449@itemx gnu++1y
2450GNU dialect of @option{-std=c++14}.
2451The name @samp{gnu++1y} is deprecated.
2452
2453@item c++17
2454@itemx c++1z
2455The 2017 ISO C++ standard plus amendments.
2456The name @samp{c++1z} is deprecated.
2457
2458@item gnu++17
2459@itemx gnu++1z
2460GNU dialect of @option{-std=c++17}.
2461This is the default for C++ code.
2462The name @samp{gnu++1z} is deprecated.
2463
2464@item c++20
2465@itemx c++2a
2466The 2020 ISO C++ standard plus amendments.
2467Support is experimental, and could change in incompatible ways in
2468future releases.
2469The name @samp{c++2a} is deprecated.
2470
2471@item gnu++20
2472@itemx gnu++2a
2473GNU dialect of @option{-std=c++20}.
2474Support is experimental, and could change in incompatible ways in
2475future releases.
2476The name @samp{gnu++2a} is deprecated.
2477
2478@item c++2b
2479@itemx c++23
2480The next revision of the ISO C++ standard, planned for
24812023. Support is highly experimental, and will almost certainly
2482change in incompatible ways in future releases.
2483
2484@item gnu++2b
2485@itemx gnu++23
2486GNU dialect of @option{-std=c++2b}. Support is highly experimental,
2487and will almost certainly change in incompatible ways in future
2488releases.
2489@end table
2490
2491@item -aux-info @var{filename}
2492@opindex aux-info
2493Output to the given filename prototyped declarations for all functions
2494declared and/or defined in a translation unit, including those in header
2495files. This option is silently ignored in any language other than C@.
2496
2497Besides declarations, the file indicates, in comments, the origin of
2498each declaration (source file and line), whether the declaration was
2499implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
2500@samp{O} for old, respectively, in the first character after the line
2501number and the colon), and whether it came from a declaration or a
2502definition (@samp{C} or @samp{F}, respectively, in the following
2503character). In the case of function definitions, a K&R-style list of
2504arguments followed by their declarations is also provided, inside
2505comments, after the declaration.
2506
2507@item -fno-asm
2508@opindex fno-asm
2509@opindex fasm
2510Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
2511keyword, so that code can use these words as identifiers. You can use
2512the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
2513instead. In C, @option{-ansi} implies @option{-fno-asm}.
2514
2515In C++, @code{inline} is a standard keyword and is not affected by
2516this switch. You may want to use the @option{-fno-gnu-keywords} flag
2517instead, which disables @code{typeof} but not @code{asm} and
2518@code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
2519this switch only affects the @code{asm} and @code{typeof} keywords,
2520since @code{inline} is a standard keyword in ISO C99. In C2X mode
2521(@option{-std=c2x} or @option{-std=gnu2x}), this switch only affects
2522the @code{asm} keyword, since @code{typeof} is a standard keyword in
2523ISO C2X.
2524
2525@item -fno-builtin
2526@itemx -fno-builtin-@var{function}
2527@opindex fno-builtin
2528@opindex fbuiltin
2529@cindex built-in functions
2530Don't recognize built-in functions that do not begin with
2531@samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
2532functions provided by GCC}, for details of the functions affected,
2533including those which are not built-in functions when @option{-ansi} or
2534@option{-std} options for strict ISO C conformance are used because they
2535do not have an ISO standard meaning.
2536
2537GCC normally generates special code to handle certain built-in functions
2538more efficiently; for instance, calls to @code{alloca} may become single
2539instructions which adjust the stack directly, and calls to @code{memcpy}
2540may become inline copy loops. The resulting code is often both smaller
2541and faster, but since the function calls no longer appear as such, you
2542cannot set a breakpoint on those calls, nor can you change the behavior
2543of the functions by linking with a different library. In addition,
2544when a function is recognized as a built-in function, GCC may use
2545information about that function to warn about problems with calls to
2546that function, or to generate more efficient code, even if the
2547resulting code still contains calls to that function. For example,
2548warnings are given with @option{-Wformat} for bad calls to
2549@code{printf} when @code{printf} is built in and @code{strlen} is
2550known not to modify global memory.
2551
2552With the @option{-fno-builtin-@var{function}} option
2553only the built-in function @var{function} is
2554disabled. @var{function} must not begin with @samp{__builtin_}. If a
2555function is named that is not built-in in this version of GCC, this
2556option is ignored. There is no corresponding
2557@option{-fbuiltin-@var{function}} option; if you wish to enable
2558built-in functions selectively when using @option{-fno-builtin} or
2559@option{-ffreestanding}, you may define macros such as:
2560
2561@smallexample
2562#define abs(n) __builtin_abs ((n))
2563#define strcpy(d, s) __builtin_strcpy ((d), (s))
2564@end smallexample
2565
2566@item -fcond-mismatch
2567@opindex fcond-mismatch
2568Allow conditional expressions with mismatched types in the second and
2569third arguments. The value of such an expression is void. This option
2570is not supported for C++.
2571
2572@item -ffreestanding
2573@opindex ffreestanding
2574@cindex hosted environment
2575
2576Assert that compilation targets a freestanding environment. This
2577implies @option{-fno-builtin}. A freestanding environment
2578is one in which the standard library may not exist, and program startup may
2579not necessarily be at @code{main}. The most obvious example is an OS kernel.
2580This is equivalent to @option{-fno-hosted}.
2581
2582@xref{Standards,,Language Standards Supported by GCC}, for details of
2583freestanding and hosted environments.
2584
2585@item -fgimple
2586@opindex fgimple
2587
2588Enable parsing of function definitions marked with @code{__GIMPLE}.
2589This is an experimental feature that allows unit testing of GIMPLE
2590passes.
2591
2592@item -fgnu-tm
2593@opindex fgnu-tm
2594When the option @option{-fgnu-tm} is specified, the compiler
2595generates code for the Linux variant of Intel's current Transactional
2596Memory ABI specification document (Revision 1.1, May 6 2009). This is
2597an experimental feature whose interface may change in future versions
2598of GCC, as the official specification changes. Please note that not
2599all architectures are supported for this feature.
2600
2601For more information on GCC's support for transactional memory,
2602@xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
2603Transactional Memory Library}.
2604
2605Note that the transactional memory feature is not supported with
2606non-call exceptions (@option{-fnon-call-exceptions}).
2607
2608@item -fgnu89-inline
2609@opindex fgnu89-inline
2610The option @option{-fgnu89-inline} tells GCC to use the traditional
2611GNU semantics for @code{inline} functions when in C99 mode.
2612@xref{Inline,,An Inline Function is As Fast As a Macro}.
2613Using this option is roughly equivalent to adding the
2614@code{gnu_inline} function attribute to all inline functions
2615(@pxref{Function Attributes}).
2616
2617The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
2618C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
2619specifies the default behavior).
2620This option is not supported in @option{-std=c90} or
2621@option{-std=gnu90} mode.
2622
2623The preprocessor macros @code{__GNUC_GNU_INLINE__} and
2624@code{__GNUC_STDC_INLINE__} may be used to check which semantics are
2625in effect for @code{inline} functions. @xref{Common Predefined
2626Macros,,,cpp,The C Preprocessor}.
2627
2628@item -fhosted
2629@opindex fhosted
2630@cindex hosted environment
2631
2632Assert that compilation targets a hosted environment. This implies
2633@option{-fbuiltin}. A hosted environment is one in which the
2634entire standard library is available, and in which @code{main} has a return
2635type of @code{int}. Examples are nearly everything except a kernel.
2636This is equivalent to @option{-fno-freestanding}.
2637
2638@item -flax-vector-conversions
2639@opindex flax-vector-conversions
2640Allow implicit conversions between vectors with differing numbers of
2641elements and/or incompatible element types. This option should not be
2642used for new code.
2643
2644@item -fms-extensions
2645@opindex fms-extensions
2646Accept some non-standard constructs used in Microsoft header files.
2647
2648In C++ code, this allows member names in structures to be similar
2649to previous types declarations.
2650
2651@smallexample
2652typedef int UOW;
2653struct ABC @{
2654 UOW UOW;
2655@};
2656@end smallexample
2657
2658Some cases of unnamed fields in structures and unions are only
2659accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
2660fields within structs/unions}, for details.
2661
2662Note that this option is off for all targets except for x86
2663targets using ms-abi.
2664
2665@item -foffload=disable
2666@itemx -foffload=default
2667@itemx -foffload=@var{target-list}
2668@opindex foffload
2669@cindex Offloading targets
2670@cindex OpenACC offloading targets
2671@cindex OpenMP offloading targets
2672Specify for which OpenMP and OpenACC offload targets code should be generated.
2673The default behavior, equivalent to @option{-foffload=default}, is to generate
2674code for all supported offload targets. The @option{-foffload=disable} form
2675generates code only for the host fallback, while
2676@option{-foffload=@var{target-list}} generates code only for the specified
2677comma-separated list of offload targets.
2678
2679Offload targets are specified in GCC's internal target-triplet format. You can
2680run the compiler with @option{-v} to show the list of configured offload targets
2681under @code{OFFLOAD_TARGET_NAMES}.
2682
2683@item -foffload-options=@var{options}
2684@itemx -foffload-options=@var{target-triplet-list}=@var{options}
2685@opindex foffload-options
2686@cindex Offloading options
2687@cindex OpenACC offloading options
2688@cindex OpenMP offloading options
2689
2690With @option{-foffload-options=@var{options}}, GCC passes the specified
2691@var{options} to the compilers for all enabled offloading targets. You can
2692specify options that apply only to a specific target or targets by using
2693the @option{-foffload-options=@var{target-list}=@var{options}} form. The
2694@var{target-list} is a comma-separated list in the same format as for the
2695@option{-foffload=} option.
2696
2697Typical command lines are
2698
2699@smallexample
2700-foffload-options=-lgfortran -foffload-options=-lm
2701-foffload-options="-lgfortran -lm" -foffload-options=nvptx-none=-latomic
2702-foffload-options=amdgcn-amdhsa=-march=gfx906 -foffload-options=-lm
2703@end smallexample
2704
2705@item -fopenacc
2706@opindex fopenacc
2707@cindex OpenACC accelerator programming
2708Enable handling of OpenACC directives @code{#pragma acc} in C/C++ and
2709@code{!$acc} in Fortran. When @option{-fopenacc} is specified, the
2710compiler generates accelerated code according to the OpenACC Application
2711Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option
2712implies @option{-pthread}, and thus is only supported on targets that
2713have support for @option{-pthread}.
2714
2715@item -fopenacc-dim=@var{geom}
2716@opindex fopenacc-dim
2717@cindex OpenACC accelerator programming
2718Specify default compute dimensions for parallel offload regions that do
2719not explicitly specify. The @var{geom} value is a triple of
2720':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size
2721can be omitted, to use a target-specific default value.
2722
2723@item -fopenmp
2724@opindex fopenmp
2725@cindex OpenMP parallel
2726Enable handling of OpenMP directives @code{#pragma omp} in C/C++,
2727@code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++ and
2728@code{!$omp} in Fortran. When @option{-fopenmp} is specified, the
2729compiler generates parallel code according to the OpenMP Application
2730Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option
2731implies @option{-pthread}, and thus is only supported on targets that
2732have support for @option{-pthread}. @option{-fopenmp} implies
2733@option{-fopenmp-simd}.
2734
2735@item -fopenmp-simd
2736@opindex fopenmp-simd
2737@cindex OpenMP SIMD
2738@cindex SIMD
2739Enable handling of OpenMP's @code{simd}, @code{declare simd},
2740@code{declare reduction}, @code{assume}, @code{ordered}, @code{scan},
2741@code{loop} directives and combined or composite directives with
2742@code{simd} as constituent with @code{#pragma omp} in C/C++,
2743@code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++
2744and @code{!$omp} in Fortran. Other OpenMP directives are ignored.
2745
2746@item -fpermitted-flt-eval-methods=@var{style}
2747@opindex fpermitted-flt-eval-methods
2748@opindex fpermitted-flt-eval-methods=c11
2749@opindex fpermitted-flt-eval-methods=ts-18661-3
2750ISO/IEC TS 18661-3 defines new permissible values for
2751@code{FLT_EVAL_METHOD} that indicate that operations and constants with
2752a semantic type that is an interchange or extended format should be
2753evaluated to the precision and range of that type. These new values are
2754a superset of those permitted under C99/C11, which does not specify the
2755meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code
2756conforming to C11 may not have been written expecting the possibility of
2757the new values.
2758
2759@option{-fpermitted-flt-eval-methods} specifies whether the compiler
2760should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11,
2761or the extended set of values specified in ISO/IEC TS 18661-3.
2762
2763@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate.
2764
2765The default when in a standards compliant mode (@option{-std=c11} or similar)
2766is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU
2767dialect (@option{-std=gnu11} or similar) is
2768@option{-fpermitted-flt-eval-methods=ts-18661-3}.
2769
2770@item -fplan9-extensions
2771@opindex fplan9-extensions
2772Accept some non-standard constructs used in Plan 9 code.
2773
2774This enables @option{-fms-extensions}, permits passing pointers to
2775structures with anonymous fields to functions that expect pointers to
2776elements of the type of the field, and permits referring to anonymous
2777fields declared using a typedef. @xref{Unnamed Fields,,Unnamed
2778struct/union fields within structs/unions}, for details. This is only
2779supported for C, not C++.
2780
2781@item -fsigned-bitfields
2782@itemx -funsigned-bitfields
2783@itemx -fno-signed-bitfields
2784@itemx -fno-unsigned-bitfields
2785@opindex fsigned-bitfields
2786@opindex funsigned-bitfields
2787@opindex fno-signed-bitfields
2788@opindex fno-unsigned-bitfields
2789These options control whether a bit-field is signed or unsigned, when the
2790declaration does not use either @code{signed} or @code{unsigned}. By
2791default, such a bit-field is signed, because this is consistent: the
2792basic integer types such as @code{int} are signed types.
2793
2794@item -fsigned-char
2795@opindex fsigned-char
2796Let the type @code{char} be signed, like @code{signed char}.
2797
2798Note that this is equivalent to @option{-fno-unsigned-char}, which is
2799the negative form of @option{-funsigned-char}. Likewise, the option
2800@option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
2801
2802@item -funsigned-char
2803@opindex funsigned-char
2804Let the type @code{char} be unsigned, like @code{unsigned char}.
2805
2806Each kind of machine has a default for what @code{char} should
2807be. It is either like @code{unsigned char} by default or like
2808@code{signed char} by default.
2809
2810Ideally, a portable program should always use @code{signed char} or
2811@code{unsigned char} when it depends on the signedness of an object.
2812But many programs have been written to use plain @code{char} and
2813expect it to be signed, or expect it to be unsigned, depending on the
2814machines they were written for. This option, and its inverse, let you
2815make such a program work with the opposite default.
2816
2817The type @code{char} is always a distinct type from each of
2818@code{signed char} or @code{unsigned char}, even though its behavior
2819is always just like one of those two.
2820
2821@item -fstrict-flex-arrays
2822@opindex fstrict-flex-arrays
2823@opindex fno-strict-flex-arrays
2824Control when to treat the trailing array of a structure as a flexible array
2825member for the purpose of accessing the elements of such an array.
2826The positive form is equivalent to @option{-fstrict-flex-arrays=3}, which is the
2827strictest. A trailing array is treated as a flexible array member only when it
2828is declared as a flexible array member per C99 standard onwards.
2829The negative form is equivalent to @option{-fstrict-flex-arrays=0}, which is the
2830least strict. All trailing arrays of structures are treated as flexible array
2831members.
2832
2833@item -fstrict-flex-arrays=@var{level}
2834@opindex fstrict-flex-arrays=@var{level}
2835Control when to treat the trailing array of a structure as a flexible array
2836member for the purpose of accessing the elements of such an array. The value
2837of @var{level} controls the level of strictness.
2838
2839The possible values of @var{level} are the same as for the
2840@code{strict_flex_array} attribute (@pxref{Variable Attributes}).
2841
2842You can control this behavior for a specific trailing array field of a
2843structure by using the variable attribute @code{strict_flex_array} attribute
2844(@pxref{Variable Attributes}).
2845
2846@item -fsso-struct=@var{endianness}
2847@opindex fsso-struct
2848Set the default scalar storage order of structures and unions to the
2849specified endianness. The accepted values are @samp{big-endian},
2850@samp{little-endian} and @samp{native} for the native endianness of
2851the target (the default). This option is not supported for C++.
2852
2853@strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate
2854code that is not binary compatible with code generated without it if the
2855specified endianness is not the native endianness of the target.
2856@end table
2857
2858@node C++ Dialect Options
2859@section Options Controlling C++ Dialect
2860
2861@cindex compiler options, C++
2862@cindex C++ options, command-line
2863@cindex options, C++
2864This section describes the command-line options that are only meaningful
2865for C++ programs. You can also use most of the GNU compiler options
2866regardless of what language your program is in. For example, you
2867might compile a file @file{firstClass.C} like this:
2868
2869@smallexample
2870g++ -g -fstrict-enums -O -c firstClass.C
2871@end smallexample
2872
2873@noindent
2874In this example, only @option{-fstrict-enums} is an option meant
2875only for C++ programs; you can use the other options with any
2876language supported by GCC@.
2877
2878Some options for compiling C programs, such as @option{-std}, are also
2879relevant for C++ programs.
2880@xref{C Dialect Options,,Options Controlling C Dialect}.
2881
2882Here is a list of options that are @emph{only} for compiling C++ programs:
2883
2884@table @gcctabopt
2885
2886@item -fabi-version=@var{n}
2887@opindex fabi-version
2888Use version @var{n} of the C++ ABI@. The default is version 0.
2889
2890Version 0 refers to the version conforming most closely to
2891the C++ ABI specification. Therefore, the ABI obtained using version 0
2892will change in different versions of G++ as ABI bugs are fixed.
2893
2894Version 1 is the version of the C++ ABI that first appeared in G++ 3.2.
2895
2896Version 2 is the version of the C++ ABI that first appeared in G++
28973.4, and was the default through G++ 4.9.
2898
2899Version 3 corrects an error in mangling a constant address as a
2900template argument.
2901
2902Version 4, which first appeared in G++ 4.5, implements a standard
2903mangling for vector types.
2904
2905Version 5, which first appeared in G++ 4.6, corrects the mangling of
2906attribute const/volatile on function pointer types, decltype of a
2907plain decl, and use of a function parameter in the declaration of
2908another parameter.
2909
2910Version 6, which first appeared in G++ 4.7, corrects the promotion
2911behavior of C++11 scoped enums and the mangling of template argument
2912packs, const/static_cast, prefix ++ and --, and a class scope function
2913used as a template argument.
2914
2915Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a
2916builtin type and corrects the mangling of lambdas in default argument
2917scope.
2918
2919Version 8, which first appeared in G++ 4.9, corrects the substitution
2920behavior of function types with function-cv-qualifiers.
2921
2922Version 9, which first appeared in G++ 5.2, corrects the alignment of
2923@code{nullptr_t}.
2924
2925Version 10, which first appeared in G++ 6.1, adds mangling of
2926attributes that affect type identity, such as ia32 calling convention
2927attributes (e.g.@: @samp{stdcall}).
2928
2929Version 11, which first appeared in G++ 7, corrects the mangling of
2930sizeof... expressions and operator names. For multiple entities with
2931the same name within a function, that are declared in different scopes,
2932the mangling now changes starting with the twelfth occurrence. It also
2933implies @option{-fnew-inheriting-ctors}.
2934
2935Version 12, which first appeared in G++ 8, corrects the calling
2936conventions for empty classes on the x86_64 target and for classes
2937with only deleted copy/move constructors. It accidentally changes the
2938calling convention for classes with a deleted copy constructor and a
2939trivial move constructor.
2940
2941Version 13, which first appeared in G++ 8.2, fixes the accidental
2942change in version 12.
2943
2944Version 14, which first appeared in G++ 10, corrects the mangling of
2945the nullptr expression.
2946
2947Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI
2948tag regression.
2949
2950Version 16, which first appeared in G++ 11, changes the mangling of
2951@code{__alignof__} to be distinct from that of @code{alignof}, and
2952dependent operator names.
2953
2954Version 17, which first appeared in G++ 12, fixes layout of classes
2955that inherit from aggregate classes with default member initializers
2956in C++14 and up.
2957
2958Version 18, which first appeard in G++ 13, fixes manglings of lambdas
2959that have additional context.
2960
2961See also @option{-Wabi}.
2962
2963@item -fabi-compat-version=@var{n}
2964@opindex fabi-compat-version
2965On targets that support strong aliases, G++
2966works around mangling changes by creating an alias with the correct
2967mangled name when defining a symbol with an incorrect mangled name.
2968This switch specifies which ABI version to use for the alias.
2969
2970With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2
2971compatibility). If another ABI version is explicitly selected, this
2972defaults to 0. For compatibility with GCC versions 3.2 through 4.9,
2973use @option{-fabi-compat-version=2}.
2974
2975If this option is not provided but @option{-Wabi=@var{n}} is, that
2976version is used for compatibility aliases. If this option is provided
2977along with @option{-Wabi} (without the version), the version from this
2978option is used for the warning.
2979
2980@item -fno-access-control
2981@opindex fno-access-control
2982@opindex faccess-control
2983Turn off all access checking. This switch is mainly useful for working
2984around bugs in the access control code.
2985
2986@item -faligned-new
2987@opindex faligned-new
2988Enable support for C++17 @code{new} of types that require more
2989alignment than @code{void* ::operator new(std::size_t)} provides. A
2990numeric argument such as @code{-faligned-new=32} can be used to
2991specify how much alignment (in bytes) is provided by that function,
2992but few users will need to override the default of
2993@code{alignof(std::max_align_t)}.
2994
2995This flag is enabled by default for @option{-std=c++17}.
2996
2997@item -fchar8_t
2998@itemx -fno-char8_t
2999@opindex fchar8_t
3000@opindex fno-char8_t
3001Enable support for @code{char8_t} as adopted for C++20. This includes
3002the addition of a new @code{char8_t} fundamental type, changes to the
3003types of UTF-8 string and character literals, new signatures for
3004user-defined literals, associated standard library updates, and new
3005@code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
3006
3007This option enables functions to be overloaded for ordinary and UTF-8
3008strings:
3009
3010@smallexample
3011int f(const char *); // #1
3012int f(const char8_t *); // #2
3013int v1 = f("text"); // Calls #1
3014int v2 = f(u8"text"); // Calls #2
3015@end smallexample
3016
3017@noindent
3018and introduces new signatures for user-defined literals:
3019
3020@smallexample
3021int operator""_udl1(char8_t);
3022int v3 = u8'x'_udl1;
3023int operator""_udl2(const char8_t*, std::size_t);
3024int v4 = u8"text"_udl2;
3025template<typename T, T...> int operator""_udl3();
3026int v5 = u8"text"_udl3;
3027@end smallexample
3028
3029@noindent
3030The change to the types of UTF-8 string and character literals introduces
3031incompatibilities with ISO C++11 and later standards. For example, the
3032following code is well-formed under ISO C++11, but is ill-formed when
3033@option{-fchar8_t} is specified.
3034
3035@smallexample
3036char ca[] = u8"xx"; // error: char-array initialized from wide
3037 // string
3038const char *cp = u8"xx";// error: invalid conversion from
3039 // `const char8_t*' to `const char*'
3040int f(const char*);
3041auto v = f(u8"xx"); // error: invalid conversion from
3042 // `const char8_t*' to `const char*'
3043std::string s@{u8"xx"@}; // error: no matching function for call to
3044 // `std::basic_string<char>::basic_string()'
3045using namespace std::literals;
3046s = u8"xx"s; // error: conversion from
3047 // `basic_string<char8_t>' to non-scalar
3048 // type `basic_string<char>' requested
3049@end smallexample
3050
3051@item -fcheck-new
3052@opindex fcheck-new
3053Check that the pointer returned by @code{operator new} is non-null
3054before attempting to modify the storage allocated. This check is
3055normally unnecessary because the C++ standard specifies that
3056@code{operator new} only returns @code{0} if it is declared
3057@code{throw()}, in which case the compiler always checks the
3058return value even without this option. In all other cases, when
3059@code{operator new} has a non-empty exception specification, memory
3060exhaustion is signalled by throwing @code{std::bad_alloc}. See also
3061@samp{new (nothrow)}.
3062
3063@item -fconcepts
3064@itemx -fconcepts-ts
3065@opindex fconcepts
3066@opindex fconcepts-ts
3067Enable support for the C++ Concepts feature for constraining template
3068arguments. With @option{-std=c++20} and above, Concepts are part of
3069the language standard, so @option{-fconcepts} defaults to on.
3070
3071Some constructs that were allowed by the earlier C++ Extensions for
3072Concepts Technical Specification, ISO 19217 (2015), but didn't make it
3073into the standard, can additionally be enabled by
3074@option{-fconcepts-ts}.
3075
3076@item -fconstexpr-depth=@var{n}
3077@opindex fconstexpr-depth
3078Set the maximum nested evaluation depth for C++11 constexpr functions
3079to @var{n}. A limit is needed to detect endless recursion during
3080constant expression evaluation. The minimum specified by the standard
3081is 512.
3082
3083@item -fconstexpr-cache-depth=@var{n}
3084@opindex fconstexpr-cache-depth
3085Set the maximum level of nested evaluation depth for C++11 constexpr
3086functions that will be cached to @var{n}. This is a heuristic that
3087trades off compilation speed (when the cache avoids repeated
3088calculations) against memory consumption (when the cache grows very
3089large from highly recursive evaluations). The default is 8. Very few
3090users are likely to want to adjust it, but if your code does heavy
3091constexpr calculations you might want to experiment to find which
3092value works best for you.
3093
3094@item -fconstexpr-fp-except
3095@opindex fconstexpr-fp-except
3096Annex F of the C standard specifies that IEC559 floating point
3097exceptions encountered at compile time should not stop compilation.
3098C++ compilers have historically not followed this guidance, instead
3099treating floating point division by zero as non-constant even though
3100it has a well defined value. This flag tells the compiler to give
3101Annex F priority over other rules saying that a particular operation
3102is undefined.
3103
3104@smallexample
3105constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except
3106@end smallexample
3107
3108@item -fconstexpr-loop-limit=@var{n}
3109@opindex fconstexpr-loop-limit
3110Set the maximum number of iterations for a loop in C++14 constexpr functions
3111to @var{n}. A limit is needed to detect infinite loops during
3112constant expression evaluation. The default is 262144 (1<<18).
3113
3114@item -fconstexpr-ops-limit=@var{n}
3115@opindex fconstexpr-ops-limit
3116Set the maximum number of operations during a single constexpr evaluation.
3117Even when number of iterations of a single loop is limited with the above limit,
3118if there are several nested loops and each of them has many iterations but still
3119smaller than the above limit, or if in a body of some loop or even outside
3120of a loop too many expressions need to be evaluated, the resulting constexpr
3121evaluation might take too long.
3122The default is 33554432 (1<<25).
3123
2efb237f
JCI
3124@item -fcontracts
3125@opindex fcontracts
3126Enable experimental support for the C++ Contracts feature, as briefly
3127added to and then removed from the C++20 working paper (N4820). The
3128implementation also includes proposed enhancements from papers P1290,
3129P1332, and P1429. This functionality is intended mostly for those
3130interested in experimentation towards refining the feature to get it
3131into shape for a future C++ standard.
3132
3133On violation of a checked contract, the violation handler is called.
3134Users can replace the violation handler by defining
3135@smallexample
3136void handle_contract_violation (const std::experimental::contract_violation&);
3137@end smallexample
3138
3139There are different sets of additional flags that can be used together
3140to specify which contracts will be checked and how, for N4820
3141contracts, P1332 contracts, or P1429 contracts; these sets cannot be
3142used together.
3143
3144@table @gcctabopt
3145@item -fcontract-mode=[on|off]
3146@opindex fcontract-mode
3147Control whether any contracts have any semantics at all. Defaults to on.
3148
3149@item -fcontract-assumption-mode=[on|off]
3150@opindex fcontract-assumption-mode
3151[N4820] Control whether contracts with level @samp{axiom}
3152should have the assume semantic. Defaults to on.
3153
3154@item -fcontract-build-level=[off|default|audit]
3155@opindex fcontract-build-level
3156[N4820] Specify which level of contracts to generate checks
3157for. Defaults to @samp{default}.
3158
3159@item -fcontract-continuation-mode=[on|off]
3160@opindex fcontract-continuation-mode
3161[N4820] Control whether to allow the program to continue executing
3162after a contract violation. That is, do checked contracts have the
3163@samp{maybe} semantic described below rather than the @samp{never}
3164semantic. Defaults to off.
3165
3166@item -fcontract-role=<name>:<default>,<audit>,<axiom>
3167@opindex fcontract-role
3168[P1332] Specify the concrete semantics for each contract level
3169of a particular contract role.
3170
3171@item -fcontract-semantic=[default|audit|axiom]:<semantic>
3172[P1429] Specify the concrete semantic for a particular
3173contract level.
3174
3175@item -fcontract-strict-declarations=[on|off]
3176@opindex fcontract-strict-declarations
3177Control whether to reject adding contracts to a function after its
3178first declaration. Defaults to off.
3179@end table
3180
3181The possible concrete semantics for that can be specified with
3182@samp{-fcontract-role} or @samp{-fcontract-semantic} are:
3183
3184@table @code
3185@item ignore
3186This contract has no effect.
3187
3188@item assume
3189This contract is treated like C++23 @code{[[assume]]}.
3190
3191@item check_never_continue
3192@itemx never
3193@itemx abort
3194This contract is checked. If it fails, the violation handler is
3195called. If the handler returns, @code{std::terminate} is called.
3196
3197@item check_maybe_continue
3198@itemx maybe
3199This contract is checked. If it fails, the violation handler is
3200called. If the handler returns, execution continues normally.
3201@end table
3202
d77de738
ML
3203@item -fcoroutines
3204@opindex fcoroutines
3205Enable support for the C++ coroutines extension (experimental).
3206
3207@item -fno-elide-constructors
3208@opindex fno-elide-constructors
3209@opindex felide-constructors
3210The C++ standard allows an implementation to omit creating a temporary
3211that is only used to initialize another object of the same type.
3212Specifying this option disables that optimization, and forces G++ to
3213call the copy constructor in all cases. This option also causes G++
3214to call trivial member functions which otherwise would be expanded inline.
3215
3216In C++17, the compiler is required to omit these temporaries, but this
3217option still affects trivial member functions.
3218
3219@item -fno-enforce-eh-specs
3220@opindex fno-enforce-eh-specs
3221@opindex fenforce-eh-specs
3222Don't generate code to check for violation of exception specifications
3223at run time. This option violates the C++ standard, but may be useful
3224for reducing code size in production builds, much like defining
3225@code{NDEBUG}. This does not give user code permission to throw
3226exceptions in violation of the exception specifications; the compiler
3227still optimizes based on the specifications, so throwing an
3228unexpected exception results in undefined behavior at run time.
3229
3230@item -fextern-tls-init
3231@itemx -fno-extern-tls-init
3232@opindex fextern-tls-init
3233@opindex fno-extern-tls-init
3234The C++11 and OpenMP standards allow @code{thread_local} and
3235@code{threadprivate} variables to have dynamic (runtime)
3236initialization. To support this, any use of such a variable goes
3237through a wrapper function that performs any necessary initialization.
3238When the use and definition of the variable are in the same
3239translation unit, this overhead can be optimized away, but when the
3240use is in a different translation unit there is significant overhead
3241even if the variable doesn't actually need dynamic initialization. If
3242the programmer can be sure that no use of the variable in a
3243non-defining TU needs to trigger dynamic initialization (either
3244because the variable is statically initialized, or a use of the
3245variable in the defining TU will be executed before any uses in
3246another TU), they can avoid this overhead with the
3247@option{-fno-extern-tls-init} option.
3248
3249On targets that support symbol aliases, the default is
3250@option{-fextern-tls-init}. On targets that do not support symbol
3251aliases, the default is @option{-fno-extern-tls-init}.
3252
3253@item -ffold-simple-inlines
3254@itemx -fno-fold-simple-inlines
3255@opindex ffold-simple-inlines
3256@opindex fno-fold-simple-inlines
3257Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward},
3258@code{std::addressof} and @code{std::as_const}. In contrast to inlining, this
3259means no debug information will be generated for such calls. Since these
3260functions are rarely interesting to debug, this flag is enabled by default
3261unless @option{-fno-inline} is active.
3262
3263@item -fno-gnu-keywords
3264@opindex fno-gnu-keywords
3265@opindex fgnu-keywords
3266Do not recognize @code{typeof} as a keyword, so that code can use this
3267word as an identifier. You can use the keyword @code{__typeof__} instead.
3268This option is implied by the strict ISO C++ dialects: @option{-ansi},
3269@option{-std=c++98}, @option{-std=c++11}, etc.
3270
3271@item -fimplicit-constexpr
3272@opindex fimplicit-constexpr
3273Make inline functions implicitly constexpr, if they satisfy the
3274requirements for a constexpr function. This option can be used in
3275C++14 mode or later. This can result in initialization changing from
3276dynamic to static and other optimizations.
3277
3278@item -fno-implicit-templates
3279@opindex fno-implicit-templates
3280@opindex fimplicit-templates
3281Never emit code for non-inline templates that are instantiated
3282implicitly (i.e.@: by use); only emit code for explicit instantiations.
3283If you use this option, you must take care to structure your code to
3284include all the necessary explicit instantiations to avoid getting
3285undefined symbols at link time.
3286@xref{Template Instantiation}, for more information.
3287
3288@item -fno-implicit-inline-templates
3289@opindex fno-implicit-inline-templates
3290@opindex fimplicit-inline-templates
3291Don't emit code for implicit instantiations of inline templates, either.
3292The default is to handle inlines differently so that compiles with and
3293without optimization need the same set of explicit instantiations.
3294
3295@item -fno-implement-inlines
3296@opindex fno-implement-inlines
3297@opindex fimplement-inlines
3298To save space, do not emit out-of-line copies of inline functions
3299controlled by @code{#pragma implementation}. This causes linker
3300errors if these functions are not inlined everywhere they are called.
3301
3302@item -fmodules-ts
3303@itemx -fno-modules-ts
3304@opindex fmodules-ts
3305@opindex fno-modules-ts
3306Enable support for C++20 modules (@pxref{C++ Modules}). The
3307@option{-fno-modules-ts} is usually not needed, as that is the
3308default. Even though this is a C++20 feature, it is not currently
3309implicitly enabled by selecting that standard version.
3310
3311@item -fmodule-header
3312@itemx -fmodule-header=user
3313@itemx -fmodule-header=system
3314@opindex fmodule-header
3315Compile a header file to create an importable header unit.
3316
3317@item -fmodule-implicit-inline
3318@opindex fmodule-implicit-inline
3319Member functions defined in their class definitions are not implicitly
3320inline for modular code. This is different to traditional C++
3321behavior, for good reasons. However, it may result in a difficulty
3322during code porting. This option makes such function definitions
3323implicitly inline. It does however generate an ABI incompatibility,
3324so you must use it everywhere or nowhere. (Such definitions outside
3325of a named module remain implicitly inline, regardless.)
3326
3327@item -fno-module-lazy
3328@opindex fno-module-lazy
3329@opindex fmodule-lazy
3330Disable lazy module importing and module mapper creation.
3331
3332@item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
3333@itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...}
3334@itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]}
3335@itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]}
3336@itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]}
3337@itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]}
3338@vindex CXX_MODULE_MAPPER @r{environment variable}
3339@opindex fmodule-mapper
3340An oracle to query for module name to filename mappings. If
3341unspecified the @env{CXX_MODULE_MAPPER} environment variable is used,
3342and if that is unset, an in-process default is provided.
3343
3344@item -fmodule-only
3345@opindex fmodule-only
3346Only emit the Compiled Module Interface, inhibiting any object file.
3347
3348@item -fms-extensions
3349@opindex fms-extensions
3350Disable Wpedantic warnings about constructs used in MFC, such as implicit
3351int and getting a pointer to member function via non-standard syntax.
3352
3353@item -fnew-inheriting-ctors
3354@opindex fnew-inheriting-ctors
3355Enable the P0136 adjustment to the semantics of C++11 constructor
3356inheritance. This is part of C++17 but also considered to be a Defect
3357Report against C++11 and C++14. This flag is enabled by default
3358unless @option{-fabi-version=10} or lower is specified.
3359
3360@item -fnew-ttp-matching
3361@opindex fnew-ttp-matching
3362Enable the P0522 resolution to Core issue 150, template template
3363parameters and default arguments: this allows a template with default
3364template arguments as an argument for a template template parameter
3365with fewer template parameters. This flag is enabled by default for
3366@option{-std=c++17}.
3367
3368@item -fno-nonansi-builtins
3369@opindex fno-nonansi-builtins
3370@opindex fnonansi-builtins
3371Disable built-in declarations of functions that are not mandated by
3372ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
3373@code{index}, @code{bzero}, @code{conjf}, and other related functions.
3374
3375@item -fnothrow-opt
3376@opindex fnothrow-opt
3377Treat a @code{throw()} exception specification as if it were a
3378@code{noexcept} specification to reduce or eliminate the text size
3379overhead relative to a function with no exception specification. If
3380the function has local variables of types with non-trivial
3381destructors, the exception specification actually makes the
3382function smaller because the EH cleanups for those variables can be
3383optimized away. The semantic effect is that an exception thrown out of
3384a function with such an exception specification results in a call
3385to @code{terminate} rather than @code{unexpected}.
3386
3387@item -fno-operator-names
3388@opindex fno-operator-names
3389@opindex foperator-names
3390Do not treat the operator name keywords @code{and}, @code{bitand},
3391@code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
3392synonyms as keywords.
3393
3394@item -fno-optional-diags
3395@opindex fno-optional-diags
3396@opindex foptional-diags
3397Disable diagnostics that the standard says a compiler does not need to
3398issue. Currently, the only such diagnostic issued by G++ is the one for
3399a name having multiple meanings within a class.
3400
3401@item -fpermissive
3402@opindex fpermissive
3403Downgrade some diagnostics about nonconformant code from errors to
3404warnings. Thus, using @option{-fpermissive} allows some
3405nonconforming code to compile.
3406
3407@item -fno-pretty-templates
3408@opindex fno-pretty-templates
3409@opindex fpretty-templates
3410When an error message refers to a specialization of a function
3411template, the compiler normally prints the signature of the
3412template followed by the template arguments and any typedefs or
3413typenames in the signature (e.g.@: @code{void f(T) [with T = int]}
3414rather than @code{void f(int)}) so that it's clear which template is
3415involved. When an error message refers to a specialization of a class
3416template, the compiler omits any template arguments that match
3417the default template arguments for that template. If either of these
3418behaviors make it harder to understand the error message rather than
3419easier, you can use @option{-fno-pretty-templates} to disable them.
3420
3421@item -fno-rtti
3422@opindex fno-rtti
3423@opindex frtti
3424Disable generation of information about every class with virtual
3425functions for use by the C++ run-time type identification features
3426(@code{dynamic_cast} and @code{typeid}). If you don't use those parts
3427of the language, you can save some space by using this flag. Note that
3428exception handling uses the same information, but G++ generates it as
3429needed. The @code{dynamic_cast} operator can still be used for casts that
3430do not require run-time type information, i.e.@: casts to @code{void *} or to
3431unambiguous base classes.
3432
3433Mixing code compiled with @option{-frtti} with that compiled with
3434@option{-fno-rtti} may not work. For example, programs may
3435fail to link if a class compiled with @option{-fno-rtti} is used as a base
3436for a class compiled with @option{-frtti}.
3437
3438@item -fsized-deallocation
3439@opindex fsized-deallocation
3440Enable the built-in global declarations
3441@smallexample
3442void operator delete (void *, std::size_t) noexcept;
3443void operator delete[] (void *, std::size_t) noexcept;
3444@end smallexample
3445as introduced in C++14. This is useful for user-defined replacement
3446deallocation functions that, for example, use the size of the object
3447to make deallocation faster. Enabled by default under
3448@option{-std=c++14} and above. The flag @option{-Wsized-deallocation}
3449warns about places that might want to add a definition.
3450
3451@item -fstrict-enums
3452@opindex fstrict-enums
3453Allow the compiler to optimize using the assumption that a value of
3454enumerated type can only be one of the values of the enumeration (as
3455defined in the C++ standard; basically, a value that can be
3456represented in the minimum number of bits needed to represent all the
3457enumerators). This assumption may not be valid if the program uses a
3458cast to convert an arbitrary integer value to the enumerated type.
3459
3460@item -fstrong-eval-order
3461@opindex fstrong-eval-order
3462Evaluate member access, array subscripting, and shift expressions in
3463left-to-right order, and evaluate assignment in right-to-left order,
3464as adopted for C++17. Enabled by default with @option{-std=c++17}.
3465@option{-fstrong-eval-order=some} enables just the ordering of member
3466access and shift expressions, and is the default without
3467@option{-std=c++17}.
3468
3469@item -ftemplate-backtrace-limit=@var{n}
3470@opindex ftemplate-backtrace-limit
3471Set the maximum number of template instantiation notes for a single
3472warning or error to @var{n}. The default value is 10.
3473
3474@item -ftemplate-depth=@var{n}
3475@opindex ftemplate-depth
3476Set the maximum instantiation depth for template classes to @var{n}.
3477A limit on the template instantiation depth is needed to detect
3478endless recursions during template class instantiation. ANSI/ISO C++
3479conforming programs must not rely on a maximum depth greater than 17
3480(changed to 1024 in C++11). The default value is 900, as the compiler
3481can run out of stack space before hitting 1024 in some situations.
3482
3483@item -fno-threadsafe-statics
3484@opindex fno-threadsafe-statics
3485@opindex fthreadsafe-statics
3486Do not emit the extra code to use the routines specified in the C++
3487ABI for thread-safe initialization of local statics. You can use this
3488option to reduce code size slightly in code that doesn't need to be
3489thread-safe.
3490
3491@item -fuse-cxa-atexit
3492@opindex fuse-cxa-atexit
3493Register destructors for objects with static storage duration with the
3494@code{__cxa_atexit} function rather than the @code{atexit} function.
3495This option is required for fully standards-compliant handling of static
3496destructors, but only works if your C library supports
3497@code{__cxa_atexit}.
3498
3499@item -fno-use-cxa-get-exception-ptr
3500@opindex fno-use-cxa-get-exception-ptr
3501@opindex fuse-cxa-get-exception-ptr
3502Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
3503causes @code{std::uncaught_exception} to be incorrect, but is necessary
3504if the runtime routine is not available.
3505
3506@item -fvisibility-inlines-hidden
3507@opindex fvisibility-inlines-hidden
3508This switch declares that the user does not attempt to compare
3509pointers to inline functions or methods where the addresses of the two functions
3510are taken in different shared objects.
3511
3512The effect of this is that GCC may, effectively, mark inline methods with
3513@code{__attribute__ ((visibility ("hidden")))} so that they do not
3514appear in the export table of a DSO and do not require a PLT indirection
3515when used within the DSO@. Enabling this option can have a dramatic effect
3516on load and link times of a DSO as it massively reduces the size of the
3517dynamic export table when the library makes heavy use of templates.
3518
3519The behavior of this switch is not quite the same as marking the
3520methods as hidden directly, because it does not affect static variables
3521local to the function or cause the compiler to deduce that
3522the function is defined in only one shared object.
3523
3524You may mark a method as having a visibility explicitly to negate the
3525effect of the switch for that method. For example, if you do want to
3526compare pointers to a particular inline method, you might mark it as
3527having default visibility. Marking the enclosing class with explicit
3528visibility has no effect.
3529
3530Explicitly instantiated inline methods are unaffected by this option
3531as their linkage might otherwise cross a shared library boundary.
3532@xref{Template Instantiation}.
3533
3534@item -fvisibility-ms-compat
3535@opindex fvisibility-ms-compat
3536This flag attempts to use visibility settings to make GCC's C++
3537linkage model compatible with that of Microsoft Visual Studio.
3538
3539The flag makes these changes to GCC's linkage model:
3540
3541@enumerate
3542@item
3543It sets the default visibility to @code{hidden}, like
3544@option{-fvisibility=hidden}.
3545
3546@item
3547Types, but not their members, are not hidden by default.
3548
3549@item
3550The One Definition Rule is relaxed for types without explicit
3551visibility specifications that are defined in more than one
3552shared object: those declarations are permitted if they are
3553permitted when this option is not used.
3554@end enumerate
3555
3556In new code it is better to use @option{-fvisibility=hidden} and
3557export those classes that are intended to be externally visible.
3558Unfortunately it is possible for code to rely, perhaps accidentally,
3559on the Visual Studio behavior.
3560
3561Among the consequences of these changes are that static data members
3562of the same type with the same name but defined in different shared
3563objects are different, so changing one does not change the other;
3564and that pointers to function members defined in different shared
3565objects may not compare equal. When this flag is given, it is a
3566violation of the ODR to define types with the same name differently.
3567
3568@item -fno-weak
3569@opindex fno-weak
3570@opindex fweak
3571Do not use weak symbol support, even if it is provided by the linker.
3572By default, G++ uses weak symbols if they are available. This
3573option exists only for testing, and should not be used by end-users;
3574it results in inferior code and has no benefits. This option may
3575be removed in a future release of G++.
3576
3577@item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
3578@opindex fext-numeric-literals
3579@opindex fno-ext-numeric-literals
3580Accept imaginary, fixed-point, or machine-defined
3581literal number suffixes as GNU extensions.
3582When this option is turned off these suffixes are treated
3583as C++11 user-defined literal numeric suffixes.
3584This is on by default for all pre-C++11 dialects and all GNU dialects:
3585@option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
3586@option{-std=gnu++14}.
3587This option is off by default
3588for ISO C++11 onwards (@option{-std=c++11}, ...).
3589
3590@item -nostdinc++
3591@opindex nostdinc++
3592Do not search for header files in the standard directories specific to
3593C++, but do still search the other standard directories. (This option
3594is used when building the C++ library.)
3595
3596@item -flang-info-include-translate
3597@itemx -flang-info-include-translate-not
3598@itemx -flang-info-include-translate=@var{header}
3599@opindex flang-info-include-translate
3600@opindex flang-info-include-translate-not
3601Inform of include translation events. The first will note accepted
3602include translations, the second will note declined include
3603translations. The @var{header} form will inform of include
3604translations relating to that specific header. If @var{header} is of
3605the form @code{"user"} or @code{<system>} it will be resolved to a
3606specific user or system header using the include path.
3607
3608@item -flang-info-module-cmi
3609@itemx -flang-info-module-cmi=@var{module}
3610@opindex flang-info-module-cmi
3611Inform of Compiled Module Interface pathnames. The first will note
3612all read CMI pathnames. The @var{module} form will not reading a
3613specific module's CMI. @var{module} may be a named module or a
3614header-unit (the latter indicated by either being a pathname containing
3615directory separators or enclosed in @code{<>} or @code{""}).
3616
3617@item -stdlib=@var{libstdc++,libc++}
3618@opindex stdlib
3619When G++ is configured to support this option, it allows specification of
3620alternate C++ runtime libraries. Two options are available: @var{libstdc++}
3621(the default, native C++ runtime for G++) and @var{libc++} which is the
3622C++ runtime installed on some operating systems (e.g. Darwin versions from
3623Darwin11 onwards). The option switches G++ to use the headers from the
3624specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
3625when a C++ runtime is required for linking.
3626@end table
3627
3628In addition, these warning options have meanings only for C++ programs:
3629
3630@table @gcctabopt
3631@item -Wabi-tag @r{(C++ and Objective-C++ only)}
3632@opindex Wabi-tag
3633Warn when a type with an ABI tag is used in a context that does not
3634have that ABI tag. See @ref{C++ Attributes} for more information
3635about ABI tags.
3636
3637@item -Wcomma-subscript @r{(C++ and Objective-C++ only)}
3638@opindex Wcomma-subscript
3639@opindex Wno-comma-subscript
3640Warn about uses of a comma expression within a subscripting expression.
3641This usage was deprecated in C++20 and is going to be removed in C++23.
3642However, a comma expression wrapped in @code{( )} is not deprecated. Example:
3643
3644@smallexample
3645@group
3646void f(int *a, int b, int c) @{
3647 a[b,c]; // deprecated in C++20, invalid in C++23
3648 a[(b,c)]; // OK
3649@}
3650@end group
3651@end smallexample
3652
3653In C++23 it is valid to have comma separated expressions in a subscript
3654when an overloaded subscript operator is found and supports the right
3655number and types of arguments. G++ will accept the formerly valid syntax
3656for code that is not valid in C++23 but used to be valid but deprecated
3657in C++20 with a pedantic warning that can be disabled with
3658@option{-Wno-comma-subscript}.
3659
3660Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated},
3661and with @option{-std=c++23} regardless of @option{-Wno-deprecated}.
3662
3663@item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
3664@opindex Wctad-maybe-unsupported
3665@opindex Wno-ctad-maybe-unsupported
3666Warn when performing class template argument deduction (CTAD) on a type with
3667no explicitly written deduction guides. This warning will point out cases
3668where CTAD succeeded only because the compiler synthesized the implicit
3669deduction guides, which might not be what the programmer intended. Certain
3670style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3671types that are designed to support CTAD. This warning can be suppressed with
3672the following pattern:
3673
3674@smallexample
3675struct allow_ctad_t; // any name works
3676template <typename T> struct S @{
3677 S(T) @{ @}
3678@};
3679S(allow_ctad_t) -> S<void>; // guide with incomplete parameter type will never be considered
3680@end smallexample
3681
3682@item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
3683@opindex Wctor-dtor-privacy
3684@opindex Wno-ctor-dtor-privacy
3685Warn when a class seems unusable because all the constructors or
3686destructors in that class are private, and it has neither friends nor
3687public static member functions. Also warn if there are no non-private
3688methods, and there's at least one private member function that isn't
3689a constructor or destructor.
3690
3691@item -Wdangling-reference @r{(C++ and Objective-C++ only)}
3692@opindex Wdangling-reference
3693@opindex Wno-dangling-reference
3694Warn when a reference is bound to a temporary whose lifetime has ended.
3695For example:
3696
3697@smallexample
3698int n = 1;
3699const int& r = std::max(n - 1, n + 1); // r is dangling
3700@end smallexample
3701
3702In the example above, two temporaries are created, one for each
3703argument, and a reference to one of the temporaries is returned.
3704However, both temporaries are destroyed at the end of the full
3705expression, so the reference @code{r} is dangling. This warning
3706also detects dangling references in member initializer lists:
3707
3708@smallexample
3709const int& f(const int& i) @{ return i; @}
3710struct S @{
3711 const int &r; // r is dangling
3712 S() : r(f(10)) @{ @}
3713@};
3714@end smallexample
3715
3716Member functions are checked as well, but only their object argument:
3717
3718@smallexample
3719struct S @{
3720 const S& self () @{ return *this; @}
3721@};
3722const S& s = S().self(); // s is dangling
3723@end smallexample
3724
3725Certain functions are safe in this respect, for example @code{std::use_facet}:
3726they take and return a reference, but they don't return one of its arguments,
3727which can fool the warning. Such functions can be excluded from the warning
3728by wrapping them in a @code{#pragma}:
3729
3730@smallexample
3731#pragma GCC diagnostic push
3732#pragma GCC diagnostic ignored "-Wdangling-reference"
3733const T& foo (const T&) @{ @dots{} @}
3734#pragma GCC diagnostic pop
3735@end smallexample
3736
ce51e843
ML
3737@option{-Wdangling-reference} also warns about code like
3738
3739@smallexample
3740auto p = std::minmax(1, 2);
3741@end smallexample
3742
3743where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
3744both references dangle after the end of the full expression that contains
3745the call to @code{std::minmax}.
3746
d77de738
ML
3747This warning is enabled by @option{-Wall}.
3748
3749@item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
3750@opindex Wdelete-non-virtual-dtor
3751@opindex Wno-delete-non-virtual-dtor
3752Warn when @code{delete} is used to destroy an instance of a class that
3753has virtual functions and non-virtual destructor. It is unsafe to delete
3754an instance of a derived class through a pointer to a base class if the
3755base class does not have a virtual destructor. This warning is enabled
3756by @option{-Wall}.
3757
3758@item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
3759@opindex Wdeprecated-copy
3760@opindex Wno-deprecated-copy
3761Warn that the implicit declaration of a copy constructor or copy
3762assignment operator is deprecated if the class has a user-provided
3763copy constructor or copy assignment operator, in C++11 and up. This
3764warning is enabled by @option{-Wextra}. With
3765@option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3766user-provided destructor.
3767
3768@item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
3769@opindex Wdeprecated-enum-enum-conversion
3770@opindex Wno-deprecated-enum-enum-conversion
3771Disable the warning about the case when the usual arithmetic conversions
3772are applied on operands where one is of enumeration type and the other is
3773of a different enumeration type. This conversion was deprecated in C++20.
3774For example:
3775
3776@smallexample
3777enum E1 @{ e @};
3778enum E2 @{ f @};
3779int k = f - e;
3780@end smallexample
3781
3782@option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3783@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3784by @option{-Wenum-conversion}.
3785
3786@item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
3787@opindex Wdeprecated-enum-float-conversion
3788@opindex Wno-deprecated-enum-float-conversion
3789Disable the warning about the case when the usual arithmetic conversions
3790are applied on operands where one is of enumeration type and the other is
3791of a floating-point type. This conversion was deprecated in C++20. For
3792example:
3793
3794@smallexample
3795enum E1 @{ e @};
3796enum E2 @{ f @};
3797bool b = e <= 3.7;
3798@end smallexample
3799
3800@option{-Wdeprecated-enum-float-conversion} is enabled by default with
3801@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3802by @option{-Wenum-conversion}.
3803
3804@item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
3805@opindex Winit-list-lifetime
3806@opindex Wno-init-list-lifetime
3807Do not warn about uses of @code{std::initializer_list} that are likely
3808to result in dangling pointers. Since the underlying array for an
3809@code{initializer_list} is handled like a normal C++ temporary object,
3810it is easy to inadvertently keep a pointer to the array past the end
3811of the array's lifetime. For example:
3812
3813@itemize @bullet
3814@item
3815If a function returns a temporary @code{initializer_list}, or a local
3816@code{initializer_list} variable, the array's lifetime ends at the end
3817of the return statement, so the value returned has a dangling pointer.
3818
3819@item
3820If a new-expression creates an @code{initializer_list}, the array only
3821lives until the end of the enclosing full-expression, so the
3822@code{initializer_list} in the heap has a dangling pointer.
3823
3824@item
3825When an @code{initializer_list} variable is assigned from a
3826brace-enclosed initializer list, the temporary array created for the
3827right side of the assignment only lives until the end of the
3828full-expression, so at the next statement the @code{initializer_list}
3829variable has a dangling pointer.
3830
3831@smallexample
3832// li's initial underlying array lives as long as li
3833std::initializer_list<int> li = @{ 1,2,3 @};
3834// assignment changes li to point to a temporary array
3835li = @{ 4, 5 @};
3836// now the temporary is gone and li has a dangling pointer
3837int i = li.begin()[0] // undefined behavior
3838@end smallexample
3839
3840@item
3841When a list constructor stores the @code{begin} pointer from the
3842@code{initializer_list} argument, this doesn't extend the lifetime of
3843the array, so if a class variable is constructed from a temporary
3844@code{initializer_list}, the pointer is left dangling by the end of
3845the variable declaration statement.
3846
3847@end itemize
3848
c85f8dbb
MP
3849@item -Winvalid-constexpr
3850@opindex Winvalid-constexpr
3851@opindex Wno-invalid-constexpr
3852
3853Warn when a function never produces a constant expression. In C++20
3854and earlier, for every @code{constexpr} function and function template,
3855there must be at least one set of function arguments in at least one
3856instantiation such that an invocation of the function or constructor
3857could be an evaluated subexpression of a core constant expression.
3858C++23 removed this restriction, so it's possible to have a function
3859or a function template marked @code{constexpr} for which no invocation
3860satisfies the requirements of a core constant expression.
3861
3862This warning is enabled as a pedantic warning by default in C++20 and
3863earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in
3864which case it will be an ordinary warning. For example:
3865
3866@smallexample
3867void f (int& i);
3868constexpr void
3869g (int& i)
3870@{
3871 f(i); // warns by default in C++20, in C++23 only with -Winvalid-constexpr
3872@}
3873@end smallexample
3874
d77de738
ML
3875@item -Winvalid-imported-macros
3876@opindex Winvalid-imported-macros
3877@opindex Wno-invalid-imported-macros
3878Verify all imported macro definitions are valid at the end of
3879compilation. This is not enabled by default, as it requires
3880additional processing to determine. It may be useful when preparing
3881sets of header-units to ensure consistent macros.
3882
3883@item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
3884@opindex Wliteral-suffix
3885@opindex Wno-literal-suffix
3886Do not warn when a string or character literal is followed by a
3887ud-suffix which does not begin with an underscore. As a conforming
3888extension, GCC treats such suffixes as separate preprocessing tokens
3889in order to maintain backwards compatibility with code that uses
3890formatting macros from @code{<inttypes.h>}. For example:
3891
3892@smallexample
3893#define __STDC_FORMAT_MACROS
3894#include <inttypes.h>
3895#include <stdio.h>
3896
3897int main() @{
3898 int64_t i64 = 123;
3899 printf("My int64: %" PRId64"\n", i64);
3900@}
3901@end smallexample
3902
3903In this case, @code{PRId64} is treated as a separate preprocessing token.
3904
3905This option also controls warnings when a user-defined literal
3906operator is declared with a literal suffix identifier that doesn't
3907begin with an underscore. Literal suffix identifiers that don't begin
3908with an underscore are reserved for future standardization.
3909
3910These warnings are enabled by default.
3911
3912@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
3913@opindex Wnarrowing
3914@opindex Wno-narrowing
3915For C++11 and later standards, narrowing conversions are diagnosed by default,
3916as required by the standard. A narrowing conversion from a constant produces
3917an error, and a narrowing conversion from a non-constant produces a warning,
3918but @option{-Wno-narrowing} suppresses the diagnostic.
3919Note that this does not affect the meaning of well-formed code;
3920narrowing conversions are still considered ill-formed in SFINAE contexts.
3921
3922With @option{-Wnarrowing} in C++98, warn when a narrowing
3923conversion prohibited by C++11 occurs within
3924@samp{@{ @}}, e.g.
3925
3926@smallexample
3927int i = @{ 2.2 @}; // error: narrowing from double to int
3928@end smallexample
3929
3930This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
3931
3932@item -Wnoexcept @r{(C++ and Objective-C++ only)}
3933@opindex Wnoexcept
3934@opindex Wno-noexcept
3935Warn when a noexcept-expression evaluates to false because of a call
3936to a function that does not have a non-throwing exception
3937specification (i.e. @code{throw()} or @code{noexcept}) but is known by
3938the compiler to never throw an exception.
3939
3940@item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
3941@opindex Wnoexcept-type
3942@opindex Wno-noexcept-type
3943Warn if the C++17 feature making @code{noexcept} part of a function
3944type changes the mangled name of a symbol relative to C++14. Enabled
3945by @option{-Wabi} and @option{-Wc++17-compat}.
3946
3947As an example:
3948
3949@smallexample
3950template <class T> void f(T t) @{ t(); @};
3951void g() noexcept;
3952void h() @{ f(g); @}
3953@end smallexample
3954
3955@noindent
3956In C++14, @code{f} calls @code{f<void(*)()>}, but in
3957C++17 it calls @code{f<void(*)()noexcept>}.
3958
3959@item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
3960@opindex Wclass-memaccess
3961@opindex Wno-class-memaccess
3962Warn when the destination of a call to a raw memory function such as
3963@code{memset} or @code{memcpy} is an object of class type, and when writing
3964into such an object might bypass the class non-trivial or deleted constructor
3965or copy assignment, violate const-correctness or encapsulation, or corrupt
3966virtual table pointers. Modifying the representation of such objects may
3967violate invariants maintained by member functions of the class. For example,
3968the call to @code{memset} below is undefined because it modifies a non-trivial
3969class object and is, therefore, diagnosed. The safe way to either initialize
3970or clear the storage of objects of such types is by using the appropriate
3971constructor or assignment operator, if one is available.
3972@smallexample
3973std::string str = "abc";
3974memset (&str, 0, sizeof str);
3975@end smallexample
3976The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
3977Explicitly casting the pointer to the class object to @code{void *} or
3978to a type that can be safely accessed by the raw memory function suppresses
3979the warning.
3980
3981@item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
3982@opindex Wnon-virtual-dtor
3983@opindex Wno-non-virtual-dtor
3984Warn when a class has virtual functions and an accessible non-virtual
3985destructor itself or in an accessible polymorphic base class, in which
3986case it is possible but unsafe to delete an instance of a derived
3987class through a pointer to the class itself or base class. This
3988warning is automatically enabled if @option{-Weffc++} is specified.
3989
3990@item -Wregister @r{(C++ and Objective-C++ only)}
3991@opindex Wregister
3992@opindex Wno-register
3993Warn on uses of the @code{register} storage class specifier, except
3994when it is part of the GNU @ref{Explicit Register Variables} extension.
3995The use of the @code{register} keyword as storage class specifier has
3996been deprecated in C++11 and removed in C++17.
3997Enabled by default with @option{-std=c++17}.
3998
3999@item -Wreorder @r{(C++ and Objective-C++ only)}
4000@opindex Wreorder
4001@opindex Wno-reorder
4002@cindex reordering, warning
4003@cindex warning for reordering of member initializers
4004Warn when the order of member initializers given in the code does not
4005match the order in which they must be executed. For instance:
4006
4007@smallexample
4008struct A @{
4009 int i;
4010 int j;
4011 A(): j (0), i (1) @{ @}
4012@};
4013@end smallexample
4014
4015@noindent
4016The compiler rearranges the member initializers for @code{i}
4017and @code{j} to match the declaration order of the members, emitting
4018a warning to that effect. This warning is enabled by @option{-Wall}.
4019
4020@item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
4021@opindex Wpessimizing-move
4022@opindex Wno-pessimizing-move
4023This warning warns when a call to @code{std::move} prevents copy
4024elision. A typical scenario when copy elision can occur is when returning in
4025a function with a class return type, when the expression being returned is the
4026name of a non-volatile automatic object, and is not a function parameter, and
4027has the same type as the function return type.
4028
4029@smallexample
4030struct T @{
4031@dots{}
4032@};
4033T fn()
4034@{
4035 T t;
4036 @dots{}
4037 return std::move (t);
4038@}
4039@end smallexample
4040
4041But in this example, the @code{std::move} call prevents copy elision.
4042
4043This warning is enabled by @option{-Wall}.
4044
4045@item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
4046@opindex Wredundant-move
4047@opindex Wno-redundant-move
4048This warning warns about redundant calls to @code{std::move}; that is, when
4049a move operation would have been performed even without the @code{std::move}
4050call. This happens because the compiler is forced to treat the object as if
4051it were an rvalue in certain situations such as returning a local variable,
4052where copy elision isn't applicable. Consider:
4053
4054@smallexample
4055struct T @{
4056@dots{}
4057@};
4058T fn(T t)
4059@{
4060 @dots{}
4061 return std::move (t);
4062@}
4063@end smallexample
4064
4065Here, the @code{std::move} call is redundant. Because G++ implements Core
4066Issue 1579, another example is:
4067
4068@smallexample
4069struct T @{ // convertible to U
4070@dots{}
4071@};
4072struct U @{
4073@dots{}
4074@};
4075U fn()
4076@{
4077 T t;
4078 @dots{}
4079 return std::move (t);
4080@}
4081@end smallexample
4082In this example, copy elision isn't applicable because the type of the
4083expression being returned and the function return type differ, yet G++
4084treats the return value as if it were designated by an rvalue.
4085
4086This warning is enabled by @option{-Wextra}.
4087
4088@item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
4089@opindex Wrange-loop-construct
4090@opindex Wno-range-loop-construct
4091This warning warns when a C++ range-based for-loop is creating an unnecessary
4092copy. This can happen when the range declaration is not a reference, but
4093probably should be. For example:
4094
4095@smallexample
4096struct S @{ char arr[128]; @};
4097void fn () @{
4098 S arr[5];
4099 for (const auto x : arr) @{ @dots{} @}
4100@}
4101@end smallexample
4102
4103It does not warn when the type being copied is a trivially-copyable type whose
4104size is less than 64 bytes.
4105
4106This warning also warns when a loop variable in a range-based for-loop is
4107initialized with a value of a different type resulting in a copy. For example:
4108
4109@smallexample
4110void fn() @{
4111 int arr[10];
4112 for (const double &x : arr) @{ @dots{} @}
4113@}
4114@end smallexample
4115
4116In the example above, in every iteration of the loop a temporary value of
4117type @code{double} is created and destroyed, to which the reference
4118@code{const double &} is bound.
4119
4120This warning is enabled by @option{-Wall}.
4121
4122@item -Wredundant-tags @r{(C++ and Objective-C++ only)}
4123@opindex Wredundant-tags
4124@opindex Wno-redundant-tags
4125Warn about redundant class-key and enum-key in references to class types
4126and enumerated types in contexts where the key can be eliminated without
4127causing an ambiguity. For example:
4128
4129@smallexample
4130struct foo;
4131struct foo *p; // warn that keyword struct can be eliminated
4132@end smallexample
4133
4134@noindent
4135On the other hand, in this example there is no warning:
4136
4137@smallexample
4138struct foo;
4139void foo (); // "hides" struct foo
4140void bar (struct foo&); // no warning, keyword struct is necessary
4141@end smallexample
4142
4143@item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
4144@opindex Wsubobject-linkage
4145@opindex Wno-subobject-linkage
4146Do not warn
4147if a class type has a base or a field whose type uses the anonymous
4148namespace or depends on a type with no linkage. If a type A depends on
4149a type B with no or internal linkage, defining it in multiple
4150translation units would be an ODR violation because the meaning of B
4151is different in each translation unit. If A only appears in a single
4152translation unit, the best way to silence the warning is to give it
4153internal linkage by putting it in an anonymous namespace as well. The
4154compiler doesn't give this warning for types defined in the main .C
4155file, as those are unlikely to have multiple definitions.
4156@option{-Wsubobject-linkage} is enabled by default.
4157
4158@item -Weffc++ @r{(C++ and Objective-C++ only)}
4159@opindex Weffc++
4160@opindex Wno-effc++
4161Warn about violations of the following style guidelines from Scott Meyers'
4162@cite{Effective C++} series of books:
4163
4164@itemize @bullet
4165@item
4166Define a copy constructor and an assignment operator for classes
4167with dynamically-allocated memory.
4168
4169@item
4170Prefer initialization to assignment in constructors.
4171
4172@item
4173Have @code{operator=} return a reference to @code{*this}.
4174
4175@item
4176Don't try to return a reference when you must return an object.
4177
4178@item
4179Distinguish between prefix and postfix forms of increment and
4180decrement operators.
4181
4182@item
4183Never overload @code{&&}, @code{||}, or @code{,}.
4184
4185@end itemize
4186
4187This option also enables @option{-Wnon-virtual-dtor}, which is also
4188one of the effective C++ recommendations. However, the check is
4189extended to warn about the lack of virtual destructor in accessible
4190non-polymorphic bases classes too.
4191
4192When selecting this option, be aware that the standard library
4193headers do not obey all of these guidelines; use @samp{grep -v}
4194to filter out those warnings.
4195
4196@item -Wno-exceptions @r{(C++ and Objective-C++ only)}
4197@opindex Wexceptions
4198@opindex Wno-exceptions
4199Disable the warning about the case when an exception handler is shadowed by
4200another handler, which can point out a wrong ordering of exception handlers.
4201
4202@item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
4203@opindex Wstrict-null-sentinel
4204@opindex Wno-strict-null-sentinel
4205Warn about the use of an uncasted @code{NULL} as sentinel. When
4206compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
4207to @code{__null}. Although it is a null pointer constant rather than a
4208null pointer, it is guaranteed to be of the same size as a pointer.
4209But this use is not portable across different compilers.
4210
4211@item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
4212@opindex Wno-non-template-friend
4213@opindex Wnon-template-friend
4214Disable warnings when non-template friend functions are declared
4215within a template. In very old versions of GCC that predate implementation
4216of the ISO standard, declarations such as
4217@samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
4218could be interpreted as a particular specialization of a template
4219function; the warning exists to diagnose compatibility problems,
4220and is enabled by default.
4221
4222@item -Wold-style-cast @r{(C++ and Objective-C++ only)}
4223@opindex Wold-style-cast
4224@opindex Wno-old-style-cast
4225Warn if an old-style (C-style) cast to a non-void type is used within
4226a C++ program. The new-style casts (@code{dynamic_cast},
4227@code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4228less vulnerable to unintended effects and much easier to search for.
4229
4230@item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4231@itemx -Woverloaded-virtual=@var{n}
4232@opindex Woverloaded-virtual
4233@opindex Wno-overloaded-virtual
4234@cindex overloaded virtual function, warning
4235@cindex warning for overloaded virtual function
4236Warn when a function declaration hides virtual functions from a
4237base class. For example, in:
4238
4239@smallexample
4240struct A @{
4241 virtual void f();
4242@};
4243
4244struct B: public A @{
4245 void f(int); // does not override
4246@};
4247@end smallexample
4248
4249the @code{A} class version of @code{f} is hidden in @code{B}, and code
4250like:
4251
4252@smallexample
4253B* b;
4254b->f();
4255@end smallexample
4256
4257@noindent
4258fails to compile.
4259
4260The optional level suffix controls the behavior when all the
4261declarations in the derived class override virtual functions in the
4262base class, even if not all of the base functions are overridden:
4263
4264@smallexample
4265struct C @{
4266 virtual void f();
4267 virtual void f(int);
4268@};
4269
4270struct D: public C @{
4271 void f(int); // does override
4272@}
4273@end smallexample
4274
4275This pattern is less likely to be a mistake; if D is only used
4276virtually, the user might have decided that the base class semantics
4277for some of the overloads are fine.
4278
4279At level 1, this case does not warn; at level 2, it does.
4280@option{-Woverloaded-virtual} by itself selects level 2. Level 1 is
4281included in @option{-Wall}.
4282
4283@item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
4284@opindex Wno-pmf-conversions
4285@opindex Wpmf-conversions
4286Disable the diagnostic for converting a bound pointer to member function
4287to a plain pointer.
4288
4289@item -Wsign-promo @r{(C++ and Objective-C++ only)}
4290@opindex Wsign-promo
4291@opindex Wno-sign-promo
4292Warn when overload resolution chooses a promotion from unsigned or
4293enumerated type to a signed type, over a conversion to an unsigned type of
4294the same size. Previous versions of G++ tried to preserve
4295unsignedness, but the standard mandates the current behavior.
4296
4297@item -Wtemplates @r{(C++ and Objective-C++ only)}
4298@opindex Wtemplates
4299@opindex Wno-templates
4300Warn when a primary template declaration is encountered. Some coding
4301rules disallow templates, and this may be used to enforce that rule.
4302The warning is inactive inside a system header file, such as the STL, so
4303one can still use the STL. One may also instantiate or specialize
4304templates.
4305
4306@item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
4307@opindex Wmismatched-new-delete
4308@opindex Wno-mismatched-new-delete
4309Warn for mismatches between calls to @code{operator new} or @code{operator
4310delete} and the corresponding call to the allocation or deallocation function.
4311This includes invocations of C++ @code{operator delete} with pointers
4312returned from either mismatched forms of @code{operator new}, or from other
4313functions that allocate objects for which the @code{operator delete} isn't
4314a suitable deallocator, as well as calls to other deallocation functions
4315with pointers returned from @code{operator new} for which the deallocation
4316function isn't suitable.
4317
4318For example, the @code{delete} expression in the function below is diagnosed
4319because it doesn't match the array form of the @code{new} expression
4320the pointer argument was returned from. Similarly, the call to @code{free}
4321is also diagnosed.
4322
4323@smallexample
4324void f ()
4325@{
4326 int *a = new int[n];
4327 delete a; // warning: mismatch in array forms of expressions
4328
4329 char *p = new char[n];
4330 free (p); // warning: mismatch between new and free
4331@}
4332@end smallexample
4333
4334The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4335involving allocation and deallocation functions other than @code{operator
4336new} and @code{operator delete}.
4337
4338@option{-Wmismatched-new-delete} is included in @option{-Wall}.
4339
4340@item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
4341@opindex Wmismatched-tags
4342@opindex Wno-mismatched-tags
4343Warn for declarations of structs, classes, and class templates and their
4344specializations with a class-key that does not match either the definition
4345or the first declaration if no definition is provided.
4346
4347For example, the declaration of @code{struct Object} in the argument list
4348of @code{draw} triggers the warning. To avoid it, either remove the redundant
4349class-key @code{struct} or replace it with @code{class} to match its definition.
4350@smallexample
4351class Object @{
4352public:
4353 virtual ~Object () = 0;
4354@};
4355void draw (struct Object*);
4356@end smallexample
4357
4358It is not wrong to declare a class with the class-key @code{struct} as
4359the example above shows. The @option{-Wmismatched-tags} option is intended
4360to help achieve a consistent style of class declarations. In code that is
4361intended to be portable to Windows-based compilers the warning helps prevent
4362unresolved references due to the difference in the mangling of symbols
4363declared with different class-keys. The option can be used either on its
4364own or in conjunction with @option{-Wredundant-tags}.
4365
4366@item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
4367@opindex Wmultiple-inheritance
4368@opindex Wno-multiple-inheritance
4369Warn when a class is defined with multiple direct base classes. Some
4370coding rules disallow multiple inheritance, and this may be used to
4371enforce that rule. The warning is inactive inside a system header file,
4372such as the STL, so one can still use the STL. One may also define
4373classes that indirectly use multiple inheritance.
4374
4375@item -Wvirtual-inheritance
4376@opindex Wvirtual-inheritance
4377@opindex Wno-virtual-inheritance
4378Warn when a class is defined with a virtual direct base class. Some
4379coding rules disallow multiple inheritance, and this may be used to
4380enforce that rule. The warning is inactive inside a system header file,
4381such as the STL, so one can still use the STL. One may also define
4382classes that indirectly use virtual inheritance.
4383
4384@item -Wno-virtual-move-assign
4385@opindex Wvirtual-move-assign
4386@opindex Wno-virtual-move-assign
4387Suppress warnings about inheriting from a virtual base with a
4388non-trivial C++11 move assignment operator. This is dangerous because
4389if the virtual base is reachable along more than one path, it is
4390moved multiple times, which can mean both objects end up in the
4391moved-from state. If the move assignment operator is written to avoid
4392moving from a moved-from object, this warning can be disabled.
4393
4394@item -Wnamespaces
4395@opindex Wnamespaces
4396@opindex Wno-namespaces
4397Warn when a namespace definition is opened. Some coding rules disallow
4398namespaces, and this may be used to enforce that rule. The warning is
4399inactive inside a system header file, such as the STL, so one can still
4400use the STL. One may also use using directives and qualified names.
4401
4402@item -Wno-terminate @r{(C++ and Objective-C++ only)}
4403@opindex Wterminate
4404@opindex Wno-terminate
4405Disable the warning about a throw-expression that will immediately
4406result in a call to @code{terminate}.
4407
4408@item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
4409@opindex Wvexing-parse
4410@opindex Wno-vexing-parse
4411Warn about the most vexing parse syntactic ambiguity. This warns about
4412the cases when a declaration looks like a variable definition, but the
4413C++ language requires it to be interpreted as a function declaration.
4414For instance:
4415
4416@smallexample
4417void f(double a) @{
4418 int i(); // extern int i (void);
4419 int n(int(a)); // extern int n (int);
4420@}
4421@end smallexample
4422
4423Another example:
4424
4425@smallexample
4426struct S @{ S(int); @};
4427void f(double a) @{
4428 S x(int(a)); // extern struct S x (int);
4429 S y(int()); // extern struct S y (int (*) (void));
4430 S z(); // extern struct S z (void);
4431@}
4432@end smallexample
4433
4434The warning will suggest options how to deal with such an ambiguity; e.g.,
4435it can suggest removing the parentheses or using braces instead.
4436
4437This warning is enabled by default.
4438
4439@item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
4440@opindex Wno-class-conversion
4441@opindex Wclass-conversion
4442Do not warn when a conversion function converts an
4443object to the same type, to a base class of that type, or to void; such
4444a conversion function will never be called.
4445
4446@item -Wvolatile @r{(C++ and Objective-C++ only)}
4447@opindex Wvolatile
4448@opindex Wno-volatile
4449Warn about deprecated uses of the @code{volatile} qualifier. This includes
4450postfix and prefix @code{++} and @code{--} expressions of
4451@code{volatile}-qualified types, using simple assignments where the left
4452operand is a @code{volatile}-qualified non-class type for their value,
4453compound assignments where the left operand is a @code{volatile}-qualified
4454non-class type, @code{volatile}-qualified function return type,
4455@code{volatile}-qualified parameter type, and structured bindings of a
4456@code{volatile}-qualified type. This usage was deprecated in C++20.
4457
4458Enabled by default with @option{-std=c++20}.
4459
4460@item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)}
4461@opindex Wzero-as-null-pointer-constant
4462@opindex Wno-zero-as-null-pointer-constant
4463Warn when a literal @samp{0} is used as null pointer constant. This can
4464be useful to facilitate the conversion to @code{nullptr} in C++11.
4465
4466@item -Waligned-new
4467@opindex Waligned-new
4468@opindex Wno-aligned-new
4469Warn about a new-expression of a type that requires greater alignment
4470than the @code{alignof(std::max_align_t)} but uses an allocation
4471function without an explicit alignment parameter. This option is
4472enabled by @option{-Wall}.
4473
4474Normally this only warns about global allocation functions, but
4475@option{-Waligned-new=all} also warns about class member allocation
4476functions.
4477
4478@item -Wno-placement-new
4479@itemx -Wplacement-new=@var{n}
4480@opindex Wplacement-new
4481@opindex Wno-placement-new
4482Warn about placement new expressions with undefined behavior, such as
4483constructing an object in a buffer that is smaller than the type of
4484the object. For example, the placement new expression below is diagnosed
4485because it attempts to construct an array of 64 integers in a buffer only
448664 bytes large.
4487@smallexample
4488char buf [64];
4489new (buf) int[64];
4490@end smallexample
4491This warning is enabled by default.
4492
4493@table @gcctabopt
4494@item -Wplacement-new=1
4495This is the default warning level of @option{-Wplacement-new}. At this
4496level the warning is not issued for some strictly undefined constructs that
4497GCC allows as extensions for compatibility with legacy code. For example,
4498the following @code{new} expression is not diagnosed at this level even
4499though it has undefined behavior according to the C++ standard because
4500it writes past the end of the one-element array.
4501@smallexample
4502struct S @{ int n, a[1]; @};
4503S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4504new (s->a)int [32]();
4505@end smallexample
4506
4507@item -Wplacement-new=2
4508At this level, in addition to diagnosing all the same constructs as at level
45091, a diagnostic is also issued for placement new expressions that construct
4510an object in the last member of structure whose type is an array of a single
4511element and whose size is less than the size of the object being constructed.
4512While the previous example would be diagnosed, the following construct makes
4513use of the flexible member array extension to avoid the warning at level 2.
4514@smallexample
4515struct S @{ int n, a[]; @};
4516S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4517new (s->a)int [32]();
4518@end smallexample
4519
4520@end table
4521
4522@item -Wcatch-value
4523@itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
4524@opindex Wcatch-value
4525@opindex Wno-catch-value
4526Warn about catch handlers that do not catch via reference.
4527With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4528warn about polymorphic class types that are caught by value.
4529With @option{-Wcatch-value=2} warn about all class types that are caught
4530by value. With @option{-Wcatch-value=3} warn about all types that are
4531not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4532
4533@item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
4534@opindex Wconditionally-supported
4535@opindex Wno-conditionally-supported
4536Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4537
4538@item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
4539@opindex Wdelete-incomplete
4540@opindex Wno-delete-incomplete
4541Do not warn when deleting a pointer to incomplete type, which may cause
4542undefined behavior at runtime. This warning is enabled by default.
4543
4544@item -Wextra-semi @r{(C++, Objective-C++ only)}
4545@opindex Wextra-semi
4546@opindex Wno-extra-semi
4547Warn about redundant semicolons after in-class function definitions.
4548
4549@item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
4550@opindex Winaccessible-base
4551@opindex Wno-inaccessible-base
4552This option controls warnings
4553when a base class is inaccessible in a class derived from it due to
4554ambiguity. The warning is enabled by default.
4555Note that the warning for ambiguous virtual
4556bases is enabled by the @option{-Wextra} option.
4557@smallexample
4558@group
4559struct A @{ int a; @};
4560
4561struct B : A @{ @};
4562
4563struct C : B, A @{ @};
4564@end group
4565@end smallexample
4566
4567@item -Wno-inherited-variadic-ctor
4568@opindex Winherited-variadic-ctor
4569@opindex Wno-inherited-variadic-ctor
4570Suppress warnings about use of C++11 inheriting constructors when the
4571base class inherited from has a C variadic constructor; the warning is
4572on by default because the ellipsis is not inherited.
4573
4574@item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
4575@opindex Wno-invalid-offsetof
4576@opindex Winvalid-offsetof
4577Suppress warnings from applying the @code{offsetof} macro to a non-POD
4578type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4579to a non-standard-layout type is undefined. In existing C++ implementations,
4580however, @code{offsetof} typically gives meaningful results.
4581This flag is for users who are aware that they are
4582writing nonportable code and who have deliberately chosen to ignore the
4583warning about it.
4584
4585The restrictions on @code{offsetof} may be relaxed in a future version
4586of the C++ standard.
4587
4588@item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
4589@opindex Wsized-deallocation
4590@opindex Wno-sized-deallocation
4591Warn about a definition of an unsized deallocation function
4592@smallexample
4593void operator delete (void *) noexcept;
4594void operator delete[] (void *) noexcept;
4595@end smallexample
4596without a definition of the corresponding sized deallocation function
4597@smallexample
4598void operator delete (void *, std::size_t) noexcept;
4599void operator delete[] (void *, std::size_t) noexcept;
4600@end smallexample
4601or vice versa. Enabled by @option{-Wextra} along with
4602@option{-fsized-deallocation}.
4603
4604@item -Wsuggest-final-types
4605@opindex Wno-suggest-final-types
4606@opindex Wsuggest-final-types
4607Warn about types with virtual methods where code quality would be improved
4608if the type were declared with the C++11 @code{final} specifier,
4609or, if possible,
4610declared in an anonymous namespace. This allows GCC to more aggressively
4611devirtualize the polymorphic calls. This warning is more effective with
4612link-time optimization,
4613where the information about the class hierarchy graph is
4614more complete.
4615
4616@item -Wsuggest-final-methods
4617@opindex Wno-suggest-final-methods
4618@opindex Wsuggest-final-methods
4619Warn about virtual methods where code quality would be improved if the method
4620were declared with the C++11 @code{final} specifier,
4621or, if possible, its type were
4622declared in an anonymous namespace or with the @code{final} specifier.
4623This warning is
4624more effective with link-time optimization, where the information about the
4625class hierarchy graph is more complete. It is recommended to first consider
4626suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4627annotations.
4628
4629@item -Wsuggest-override
4630@opindex Wsuggest-override
4631@opindex Wno-suggest-override
4632Warn about overriding virtual functions that are not marked with the
4633@code{override} keyword.
4634
4635@item -Wuse-after-free
4636@itemx -Wuse-after-free=@var{n}
4637@opindex Wuse-after-free
4638@opindex Wno-use-after-free
4639Warn about uses of pointers to dynamically allocated objects that have
4640been rendered indeterminate by a call to a deallocation function.
4641The warning is enabled at all optimization levels but may yield different
4642results with optimization than without.
4643
4644@table @gcctabopt
4645@item -Wuse-after-free=1
4646At level 1 the warning attempts to diagnose only unconditional uses
4647of pointers made indeterminate by a deallocation call or a successful
4648call to @code{realloc}, regardless of whether or not the call resulted
4649in an actual reallocatio of memory. This includes double-@code{free}
4650calls as well as uses in arithmetic and relational expressions. Although
4651undefined, uses of indeterminate pointers in equality (or inequality)
4652expressions are not diagnosed at this level.
4653@item -Wuse-after-free=2
4654At level 2, in addition to unconditional uses, the warning also diagnoses
4655conditional uses of pointers made indeterminate by a deallocation call.
4656As at level 2, uses in equality (or inequality) expressions are not
4657diagnosed. For example, the second call to @code{free} in the following
4658function is diagnosed at this level:
4659@smallexample
4660struct A @{ int refcount; void *data; @};
4661
4662void release (struct A *p)
4663@{
4664 int refcount = --p->refcount;
4665 free (p);
4666 if (refcount == 0)
4667 free (p->data); // warning: p may be used after free
4668@}
4669@end smallexample
4670@item -Wuse-after-free=3
4671At level 3, the warning also diagnoses uses of indeterminate pointers in
4672equality expressions. All uses of indeterminate pointers are undefined
4673but equality tests sometimes appear after calls to @code{realloc} as
4674an attempt to determine whether the call resulted in relocating the object
4675to a different address. They are diagnosed at a separate level to aid
4676legacy code gradually transition to safe alternatives. For example,
4677the equality test in the function below is diagnosed at this level:
4678@smallexample
4679void adjust_pointers (int**, int);
4680
4681void grow (int **p, int n)
4682@{
4683 int **q = (int**)realloc (p, n *= 2);
4684 if (q == p)
4685 return;
4686 adjust_pointers ((int**)q, n);
4687@}
4688@end smallexample
4689To avoid the warning at this level, store offsets into allocated memory
4690instead of pointers. This approach obviates needing to adjust the stored
4691pointers after reallocation.
4692@end table
4693
4694@option{-Wuse-after-free=2} is included in @option{-Wall}.
4695
4696@item -Wuseless-cast @r{(C++ and Objective-C++ only)}
4697@opindex Wuseless-cast
4698@opindex Wno-useless-cast
4699Warn when an expression is cast to its own type. This warning does not
4700occur when a class object is converted to a non-reference type as that
4701is a way to create a temporary:
4702
4703@smallexample
4704struct S @{ @};
4705void g (S&&);
4706void f (S&& arg)
4707@{
4708 g (S(arg)); // make arg prvalue so that it can bind to S&&
4709@}
4710@end smallexample
4711
4712@item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
4713@opindex Wconversion-null
4714@opindex Wno-conversion-null
4715Do not warn for conversions between @code{NULL} and non-pointer
4716types. @option{-Wconversion-null} is enabled by default.
4717
4718@end table
4719
4720@node Objective-C and Objective-C++ Dialect Options
4721@section Options Controlling Objective-C and Objective-C++ Dialects
4722
4723@cindex compiler options, Objective-C and Objective-C++
4724@cindex Objective-C and Objective-C++ options, command-line
4725@cindex options, Objective-C and Objective-C++
4726(NOTE: This manual does not describe the Objective-C and Objective-C++
4727languages themselves. @xref{Standards,,Language Standards
4728Supported by GCC}, for references.)
4729
4730This section describes the command-line options that are only meaningful
4731for Objective-C and Objective-C++ programs. You can also use most of
4732the language-independent GNU compiler options.
4733For example, you might compile a file @file{some_class.m} like this:
4734
4735@smallexample
4736gcc -g -fgnu-runtime -O -c some_class.m
4737@end smallexample
4738
4739@noindent
4740In this example, @option{-fgnu-runtime} is an option meant only for
4741Objective-C and Objective-C++ programs; you can use the other options with
4742any language supported by GCC@.
4743
4744Note that since Objective-C is an extension of the C language, Objective-C
4745compilations may also use options specific to the C front-end (e.g.,
4746@option{-Wtraditional}). Similarly, Objective-C++ compilations may use
4747C++-specific options (e.g., @option{-Wabi}).
4748
4749Here is a list of options that are @emph{only} for compiling Objective-C
4750and Objective-C++ programs:
4751
4752@table @gcctabopt
4753@item -fconstant-string-class=@var{class-name}
4754@opindex fconstant-string-class
4755Use @var{class-name} as the name of the class to instantiate for each
4756literal string specified with the syntax @code{@@"@dots{}"}. The default
4757class name is @code{NXConstantString} if the GNU runtime is being used, and
4758@code{NSConstantString} if the NeXT runtime is being used (see below). The
4759@option{-fconstant-cfstrings} option, if also present, overrides the
4760@option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals
4761to be laid out as constant CoreFoundation strings.
4762
4763@item -fgnu-runtime
4764@opindex fgnu-runtime
4765Generate object code compatible with the standard GNU Objective-C
4766runtime. This is the default for most types of systems.
4767
4768@item -fnext-runtime
4769@opindex fnext-runtime
4770Generate output compatible with the NeXT runtime. This is the default
4771for NeXT-based systems, including Darwin and Mac OS X@. The macro
4772@code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
4773used.
4774
4775@item -fno-nil-receivers
4776@opindex fno-nil-receivers
4777@opindex fnil-receivers
4778Assume that all Objective-C message dispatches (@code{[receiver
4779message:arg]}) in this translation unit ensure that the receiver is
4780not @code{nil}. This allows for more efficient entry points in the
4781runtime to be used. This option is only available in conjunction with
4782the NeXT runtime and ABI version 0 or 1.
4783
4784@item -fobjc-abi-version=@var{n}
4785@opindex fobjc-abi-version
4786Use version @var{n} of the Objective-C ABI for the selected runtime.
4787This option is currently supported only for the NeXT runtime. In that
4788case, Version 0 is the traditional (32-bit) ABI without support for
4789properties and other Objective-C 2.0 additions. Version 1 is the
4790traditional (32-bit) ABI with support for properties and other
4791Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
4792nothing is specified, the default is Version 0 on 32-bit target
4793machines, and Version 2 on 64-bit target machines.
4794
4795@item -fobjc-call-cxx-cdtors
4796@opindex fobjc-call-cxx-cdtors
4797For each Objective-C class, check if any of its instance variables is a
4798C++ object with a non-trivial default constructor. If so, synthesize a
4799special @code{- (id) .cxx_construct} instance method which runs
4800non-trivial default constructors on any such instance variables, in order,
4801and then return @code{self}. Similarly, check if any instance variable
4802is a C++ object with a non-trivial destructor, and if so, synthesize a
4803special @code{- (void) .cxx_destruct} method which runs
4804all such default destructors, in reverse order.
4805
4806The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
4807methods thusly generated only operate on instance variables
4808declared in the current Objective-C class, and not those inherited
4809from superclasses. It is the responsibility of the Objective-C
4810runtime to invoke all such methods in an object's inheritance
4811hierarchy. The @code{- (id) .cxx_construct} methods are invoked
4812by the runtime immediately after a new object instance is allocated;
4813the @code{- (void) .cxx_destruct} methods are invoked immediately
4814before the runtime deallocates an object instance.
4815
4816As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
4817support for invoking the @code{- (id) .cxx_construct} and
4818@code{- (void) .cxx_destruct} methods.
4819
4820@item -fobjc-direct-dispatch
4821@opindex fobjc-direct-dispatch
4822Allow fast jumps to the message dispatcher. On Darwin this is
4823accomplished via the comm page.
4824
4825@item -fobjc-exceptions
4826@opindex fobjc-exceptions
4827Enable syntactic support for structured exception handling in
4828Objective-C, similar to what is offered by C++. This option
4829is required to use the Objective-C keywords @code{@@try},
4830@code{@@throw}, @code{@@catch}, @code{@@finally} and
4831@code{@@synchronized}. This option is available with both the GNU
4832runtime and the NeXT runtime (but not available in conjunction with
4833the NeXT runtime on Mac OS X 10.2 and earlier).
4834
4835@item -fobjc-gc
4836@opindex fobjc-gc
4837Enable garbage collection (GC) in Objective-C and Objective-C++
4838programs. This option is only available with the NeXT runtime; the
4839GNU runtime has a different garbage collection implementation that
4840does not require special compiler flags.
4841
4842@item -fobjc-nilcheck
4843@opindex fobjc-nilcheck
4844For the NeXT runtime with version 2 of the ABI, check for a nil
4845receiver in method invocations before doing the actual method call.
4846This is the default and can be disabled using
4847@option{-fno-objc-nilcheck}. Class methods and super calls are never
4848checked for nil in this way no matter what this flag is set to.
4849Currently this flag does nothing when the GNU runtime, or an older
4850version of the NeXT runtime ABI, is used.
4851
4852@item -fobjc-std=objc1
4853@opindex fobjc-std
4854Conform to the language syntax of Objective-C 1.0, the language
4855recognized by GCC 4.0. This only affects the Objective-C additions to
4856the C/C++ language; it does not affect conformance to C/C++ standards,
4857which is controlled by the separate C/C++ dialect option flags. When
4858this option is used with the Objective-C or Objective-C++ compiler,
4859any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
4860This is useful if you need to make sure that your Objective-C code can
4861be compiled with older versions of GCC@.
4862
4863@item -freplace-objc-classes
4864@opindex freplace-objc-classes
4865Emit a special marker instructing @command{ld(1)} not to statically link in
4866the resulting object file, and allow @command{dyld(1)} to load it in at
4867run time instead. This is used in conjunction with the Fix-and-Continue
4868debugging mode, where the object file in question may be recompiled and
4869dynamically reloaded in the course of program execution, without the need
4870to restart the program itself. Currently, Fix-and-Continue functionality
4871is only available in conjunction with the NeXT runtime on Mac OS X 10.3
4872and later.
4873
4874@item -fzero-link
4875@opindex fzero-link
4876When compiling for the NeXT runtime, the compiler ordinarily replaces calls
4877to @code{objc_getClass("@dots{}")} (when the name of the class is known at
4878compile time) with static class references that get initialized at load time,
4879which improves run-time performance. Specifying the @option{-fzero-link} flag
4880suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
4881to be retained. This is useful in Zero-Link debugging mode, since it allows
4882for individual class implementations to be modified during program execution.
4883The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
4884regardless of command-line options.
4885
4886@item -fno-local-ivars
4887@opindex fno-local-ivars
4888@opindex flocal-ivars
4889By default instance variables in Objective-C can be accessed as if
4890they were local variables from within the methods of the class they're
4891declared in. This can lead to shadowing between instance variables
4892and other variables declared either locally inside a class method or
4893globally with the same name. Specifying the @option{-fno-local-ivars}
4894flag disables this behavior thus avoiding variable shadowing issues.
4895
4896@item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
4897@opindex fivar-visibility
4898Set the default instance variable visibility to the specified option
4899so that instance variables declared outside the scope of any access
4900modifier directives default to the specified visibility.
4901
4902@item -gen-decls
4903@opindex gen-decls
4904Dump interface declarations for all classes seen in the source file to a
4905file named @file{@var{sourcename}.decl}.
4906
4907@item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
4908@opindex Wassign-intercept
4909@opindex Wno-assign-intercept
4910Warn whenever an Objective-C assignment is being intercepted by the
4911garbage collector.
4912
4913@item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
4914@opindex Wproperty-assign-default
4915@opindex Wno-property-assign-default
4916Do not warn if a property for an Objective-C object has no assign
4917semantics specified.
4918
4919@item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
4920@opindex Wno-protocol
4921@opindex Wprotocol
4922If a class is declared to implement a protocol, a warning is issued for
4923every method in the protocol that is not implemented by the class. The
4924default behavior is to issue a warning for every method not explicitly
4925implemented in the class, even if a method implementation is inherited
4926from the superclass. If you use the @option{-Wno-protocol} option, then
4927methods inherited from the superclass are considered to be implemented,
4928and no warning is issued for them.
4929
4930@item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
4931@opindex Wobjc-root-class
4932Warn if a class interface lacks a superclass. Most classes will inherit
4933from @code{NSObject} (or @code{Object}) for example. When declaring
4934classes intended to be root classes, the warning can be suppressed by
4935marking their interfaces with @code{__attribute__((objc_root_class))}.
4936
4937@item -Wselector @r{(Objective-C and Objective-C++ only)}
4938@opindex Wselector
4939@opindex Wno-selector
4940Warn if multiple methods of different types for the same selector are
4941found during compilation. The check is performed on the list of methods
4942in the final stage of compilation. Additionally, a check is performed
4943for each selector appearing in a @code{@@selector(@dots{})}
4944expression, and a corresponding method for that selector has been found
4945during compilation. Because these checks scan the method table only at
4946the end of compilation, these warnings are not produced if the final
4947stage of compilation is not reached, for example because an error is
4948found during compilation, or because the @option{-fsyntax-only} option is
4949being used.
4950
4951@item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
4952@opindex Wstrict-selector-match
4953@opindex Wno-strict-selector-match
4954Warn if multiple methods with differing argument and/or return types are
4955found for a given selector when attempting to send a message using this
4956selector to a receiver of type @code{id} or @code{Class}. When this flag
4957is off (which is the default behavior), the compiler omits such warnings
4958if any differences found are confined to types that share the same size
4959and alignment.
4960
4961@item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
4962@opindex Wundeclared-selector
4963@opindex Wno-undeclared-selector
4964Warn if a @code{@@selector(@dots{})} expression referring to an
4965undeclared selector is found. A selector is considered undeclared if no
4966method with that name has been declared before the
4967@code{@@selector(@dots{})} expression, either explicitly in an
4968@code{@@interface} or @code{@@protocol} declaration, or implicitly in
4969an @code{@@implementation} section. This option always performs its
4970checks as soon as a @code{@@selector(@dots{})} expression is found,
4971while @option{-Wselector} only performs its checks in the final stage of
4972compilation. This also enforces the coding style convention
4973that methods and selectors must be declared before being used.
4974
4975@item -print-objc-runtime-info
4976@opindex print-objc-runtime-info
4977Generate C header describing the largest structure that is passed by
4978value, if any.
4979
4980@end table
4981
4982@node Diagnostic Message Formatting Options
4983@section Options to Control Diagnostic Messages Formatting
4984@cindex options to control diagnostics formatting
4985@cindex diagnostic messages
4986@cindex message formatting
4987
4988Traditionally, diagnostic messages have been formatted irrespective of
4989the output device's aspect (e.g.@: its width, @dots{}). You can use the
4990options described below
4991to control the formatting algorithm for diagnostic messages,
4992e.g.@: how many characters per line, how often source location
4993information should be reported. Note that some language front ends may not
4994honor these options.
4995
4996@table @gcctabopt
4997@item -fmessage-length=@var{n}
4998@opindex fmessage-length
4999Try to format error messages so that they fit on lines of about
5000@var{n} characters. If @var{n} is zero, then no line-wrapping is
5001done; each error message appears on a single line. This is the
5002default for all front ends.
5003
5004Note - this option also affects the display of the @samp{#error} and
5005@samp{#warning} pre-processor directives, and the @samp{deprecated}
5006function/type/variable attribute. It does not however affect the
5007@samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
5008
5009@item -fdiagnostics-plain-output
5010This option requests that diagnostic output look as plain as possible, which
5011may be useful when running @command{dejagnu} or other utilities that need to
5012parse diagnostics output and prefer that it remain more stable over time.
5013@option{-fdiagnostics-plain-output} is currently equivalent to the following
5014options:
5015@gccoptlist{-fno-diagnostics-show-caret @gol
5016-fno-diagnostics-show-line-numbers @gol
5017-fdiagnostics-color=never @gol
5018-fdiagnostics-urls=never @gol
5019-fdiagnostics-path-format=separate-events}
5020In the future, if GCC changes the default appearance of its diagnostics, the
5021corresponding option to disable the new behavior will be added to this list.
5022
5023@item -fdiagnostics-show-location=once
5024@opindex fdiagnostics-show-location
5025Only meaningful in line-wrapping mode. Instructs the diagnostic messages
5026reporter to emit source location information @emph{once}; that is, in
5027case the message is too long to fit on a single physical line and has to
5028be wrapped, the source location won't be emitted (as prefix) again,
5029over and over, in subsequent continuation lines. This is the default
5030behavior.
5031
5032@item -fdiagnostics-show-location=every-line
5033Only meaningful in line-wrapping mode. Instructs the diagnostic
5034messages reporter to emit the same source location information (as
5035prefix) for physical lines that result from the process of breaking
5036a message which is too long to fit on a single line.
5037
5038@item -fdiagnostics-color[=@var{WHEN}]
5039@itemx -fno-diagnostics-color
5040@opindex fdiagnostics-color
5041@cindex highlight, color
5042@vindex GCC_COLORS @r{environment variable}
5043Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
5044or @samp{auto}. The default depends on how the compiler has been configured,
5045it can be any of the above @var{WHEN} options or also @samp{never}
5046if @env{GCC_COLORS} environment variable isn't present in the environment,
5047and @samp{auto} otherwise.
5048@samp{auto} makes GCC use color only when the standard error is a terminal,
5049and when not executing in an emacs shell.
5050The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
5051aliases for @option{-fdiagnostics-color=always} and
5052@option{-fdiagnostics-color=never}, respectively.
5053
5054The colors are defined by the environment variable @env{GCC_COLORS}.
5055Its value is a colon-separated list of capabilities and Select Graphic
5056Rendition (SGR) substrings. SGR commands are interpreted by the
5057terminal or terminal emulator. (See the section in the documentation
5058of your text terminal for permitted values and their meanings as
5059character attributes.) These substring values are integers in decimal
5060representation and can be concatenated with semicolons.
5061Common values to concatenate include
5062@samp{1} for bold,
5063@samp{4} for underline,
5064@samp{5} for blink,
5065@samp{7} for inverse,
5066@samp{39} for default foreground color,
5067@samp{30} to @samp{37} for foreground colors,
5068@samp{90} to @samp{97} for 16-color mode foreground colors,
5069@samp{38;5;0} to @samp{38;5;255}
5070for 88-color and 256-color modes foreground colors,
5071@samp{49} for default background color,
5072@samp{40} to @samp{47} for background colors,
5073@samp{100} to @samp{107} for 16-color mode background colors,
5074and @samp{48;5;0} to @samp{48;5;255}
5075for 88-color and 256-color modes background colors.
5076
5077The default @env{GCC_COLORS} is
5078@smallexample
5079error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
5080quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
5081diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
5082type-diff=01;32:fnname=01;32:targs=35
5083@end smallexample
5084@noindent
5085where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
5086@samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
5087@samp{01} is bold, and @samp{31} is red.
5088Setting @env{GCC_COLORS} to the empty string disables colors.
5089Supported capabilities are as follows.
5090
5091@table @code
5092@item error=
5093@vindex error GCC_COLORS @r{capability}
5094SGR substring for error: markers.
5095
5096@item warning=
5097@vindex warning GCC_COLORS @r{capability}
5098SGR substring for warning: markers.
5099
5100@item note=
5101@vindex note GCC_COLORS @r{capability}
5102SGR substring for note: markers.
5103
5104@item path=
5105@vindex path GCC_COLORS @r{capability}
5106SGR substring for colorizing paths of control-flow events as printed
5107via @option{-fdiagnostics-path-format=}, such as the identifiers of
5108individual events and lines indicating interprocedural calls and returns.
5109
5110@item range1=
5111@vindex range1 GCC_COLORS @r{capability}
5112SGR substring for first additional range.
5113
5114@item range2=
5115@vindex range2 GCC_COLORS @r{capability}
5116SGR substring for second additional range.
5117
5118@item locus=
5119@vindex locus GCC_COLORS @r{capability}
5120SGR substring for location information, @samp{file:line} or
5121@samp{file:line:column} etc.
5122
5123@item quote=
5124@vindex quote GCC_COLORS @r{capability}
5125SGR substring for information printed within quotes.
5126
5127@item fnname=
5128@vindex fnname GCC_COLORS @r{capability}
5129SGR substring for names of C++ functions.
5130
5131@item targs=
5132@vindex targs GCC_COLORS @r{capability}
5133SGR substring for C++ function template parameter bindings.
5134
5135@item fixit-insert=
5136@vindex fixit-insert GCC_COLORS @r{capability}
5137SGR substring for fix-it hints suggesting text to
5138be inserted or replaced.
5139
5140@item fixit-delete=
5141@vindex fixit-delete GCC_COLORS @r{capability}
5142SGR substring for fix-it hints suggesting text to
5143be deleted.
5144
5145@item diff-filename=
5146@vindex diff-filename GCC_COLORS @r{capability}
5147SGR substring for filename headers within generated patches.
5148
5149@item diff-hunk=
5150@vindex diff-hunk GCC_COLORS @r{capability}
5151SGR substring for the starts of hunks within generated patches.
5152
5153@item diff-delete=
5154@vindex diff-delete GCC_COLORS @r{capability}
5155SGR substring for deleted lines within generated patches.
5156
5157@item diff-insert=
5158@vindex diff-insert GCC_COLORS @r{capability}
5159SGR substring for inserted lines within generated patches.
5160
5161@item type-diff=
5162@vindex type-diff GCC_COLORS @r{capability}
5163SGR substring for highlighting mismatching types within template
5164arguments in the C++ frontend.
5165@end table
5166
5167@item -fdiagnostics-urls[=@var{WHEN}]
5168@opindex fdiagnostics-urls
5169@cindex urls
5170@vindex GCC_URLS @r{environment variable}
5171@vindex TERM_URLS @r{environment variable}
5172Use escape sequences to embed URLs in diagnostics. For example, when
5173@option{-fdiagnostics-show-option} emits text showing the command-line
5174option controlling a diagnostic, embed a URL for documentation of that
5175option.
5176
5177@var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
5178@samp{auto} makes GCC use URL escape sequences only when the standard error
5179is a terminal, and when not executing in an emacs shell or any graphical
5180terminal which is known to be incompatible with this feature, see below.
5181
5182The default depends on how the compiler has been configured.
5183It can be any of the above @var{WHEN} options.
5184
5185GCC can also be configured (via the
5186@option{--with-diagnostics-urls=auto-if-env} configure-time option)
5187so that the default is affected by environment variables.
5188Under such a configuration, GCC defaults to using @samp{auto}
5189if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
5190present and non-empty in the environment of the compiler, or @samp{never}
5191if neither are.
5192
5193However, even with @option{-fdiagnostics-urls=always} the behavior is
5194dependent on those environment variables:
5195If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
5196diagnostics. If set to @samp{st}, URLs use ST escape sequences.
5197If set to @samp{bel}, the default, URLs use BEL escape sequences.
5198Any other non-empty value enables the feature.
5199If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
5200Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
5201BEL is an ASCII character, CTRL-G that usually sounds like a beep.
5202
5203At this time GCC tries to detect also a few terminals that are known to
5204not implement the URL feature, and have bugs or at least had bugs in
5205some versions that are still in use, where the URL escapes are likely
5206to misbehave, i.e. print garbage on the screen.
5207That list is currently xfce4-terminal, certain known to be buggy
5208gnome-terminal versions, the linux console, and mingw.
5209This check can be skipped with the @option{-fdiagnostics-urls=always}.
5210
5211@item -fno-diagnostics-show-option
5212@opindex fno-diagnostics-show-option
5213@opindex fdiagnostics-show-option
5214By default, each diagnostic emitted includes text indicating the
5215command-line option that directly controls the diagnostic (if such an
5216option is known to the diagnostic machinery). Specifying the
5217@option{-fno-diagnostics-show-option} flag suppresses that behavior.
5218
5219@item -fno-diagnostics-show-caret
5220@opindex fno-diagnostics-show-caret
5221@opindex fdiagnostics-show-caret
5222By default, each diagnostic emitted includes the original source line
5223and a caret @samp{^} indicating the column. This option suppresses this
5224information. The source line is truncated to @var{n} characters, if
5225the @option{-fmessage-length=n} option is given. When the output is done
5226to the terminal, the width is limited to the width given by the
5227@env{COLUMNS} environment variable or, if not set, to the terminal width.
5228
5229@item -fno-diagnostics-show-labels
5230@opindex fno-diagnostics-show-labels
5231@opindex fdiagnostics-show-labels
5232By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5233diagnostics can label ranges of source code with pertinent information, such
5234as the types of expressions:
5235
5236@smallexample
5237 printf ("foo %s bar", long_i + long_j);
5238 ~^ ~~~~~~~~~~~~~~~
5239 | |
5240 char * long int
5241@end smallexample
5242
5243This option suppresses the printing of these labels (in the example above,
5244the vertical bars and the ``char *'' and ``long int'' text).
5245
5246@item -fno-diagnostics-show-cwe
5247@opindex fno-diagnostics-show-cwe
5248@opindex fdiagnostics-show-cwe
5249Diagnostic messages can optionally have an associated
5250@uref{https://cwe.mitre.org/index.html, CWE} identifier.
5251GCC itself only provides such metadata for some of the @option{-fanalyzer}
5252diagnostics. GCC plugins may also provide diagnostics with such metadata.
5253By default, if this information is present, it will be printed with
5254the diagnostic. This option suppresses the printing of this metadata.
5255
5256@item -fno-diagnostics-show-rules
5257@opindex fno-diagnostics-show-rules
5258@opindex fdiagnostics-show-rules
5259Diagnostic messages can optionally have rules associated with them, such
5260as from a coding standard, or a specification.
5261GCC itself does not do this for any of its diagnostics, but plugins may do so.
5262By default, if this information is present, it will be printed with
5263the diagnostic. This option suppresses the printing of this metadata.
5264
5265@item -fno-diagnostics-show-line-numbers
5266@opindex fno-diagnostics-show-line-numbers
5267@opindex fdiagnostics-show-line-numbers
5268By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5269a left margin is printed, showing line numbers. This option suppresses this
5270left margin.
5271
5272@item -fdiagnostics-minimum-margin-width=@var{width}
5273@opindex fdiagnostics-minimum-margin-width
5274This option controls the minimum width of the left margin printed by
5275@option{-fdiagnostics-show-line-numbers}. It defaults to 6.
5276
5277@item -fdiagnostics-parseable-fixits
5278@opindex fdiagnostics-parseable-fixits
5279Emit fix-it hints in a machine-parseable format, suitable for consumption
5280by IDEs. For each fix-it, a line will be printed after the relevant
5281diagnostic, starting with the string ``fix-it:''. For example:
5282
5283@smallexample
5284fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
5285@end smallexample
5286
5287The location is expressed as a half-open range, expressed as a count of
5288bytes, starting at byte 1 for the initial column. In the above example,
5289bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
5290given string:
5291
5292@smallexample
529300000000011111111112222222222
529412345678901234567890123456789
5295 gtk_widget_showall (dlg);
5296 ^^^^^^^^^^^^^^^^^^
5297 gtk_widget_show_all
5298@end smallexample
5299
5300The filename and replacement string escape backslash as ``\\", tab as ``\t'',
5301newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
5302(e.g. vertical tab as ``\013'').
5303
5304An empty replacement string indicates that the given range is to be removed.
5305An empty range (e.g. ``45:3-45:3'') indicates that the string is to
5306be inserted at the given position.
5307
5308@item -fdiagnostics-generate-patch
5309@opindex fdiagnostics-generate-patch
5310Print fix-it hints to stderr in unified diff format, after any diagnostics
5311are printed. For example:
5312
5313@smallexample
5314--- test.c
5315+++ test.c
5316@@ -42,5 +42,5 @@
5317
5318 void show_cb(GtkDialog *dlg)
5319 @{
5320- gtk_widget_showall(dlg);
5321+ gtk_widget_show_all(dlg);
5322 @}
5323
5324@end smallexample
5325
5326The diff may or may not be colorized, following the same rules
5327as for diagnostics (see @option{-fdiagnostics-color}).
5328
5329@item -fdiagnostics-show-template-tree
5330@opindex fdiagnostics-show-template-tree
5331
5332In the C++ frontend, when printing diagnostics showing mismatching
5333template types, such as:
5334
5335@smallexample
5336 could not convert 'std::map<int, std::vector<double> >()'
5337 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5338@end smallexample
5339
5340the @option{-fdiagnostics-show-template-tree} flag enables printing a
5341tree-like structure showing the common and differing parts of the types,
5342such as:
5343
5344@smallexample
5345 map<
5346 [...],
5347 vector<
5348 [double != float]>>
5349@end smallexample
5350
5351The parts that differ are highlighted with color (``double'' and
5352``float'' in this case).
5353
5354@item -fno-elide-type
5355@opindex fno-elide-type
5356@opindex felide-type
5357By default when the C++ frontend prints diagnostics showing mismatching
5358template types, common parts of the types are printed as ``[...]'' to
5359simplify the error message. For example:
5360
5361@smallexample
5362 could not convert 'std::map<int, std::vector<double> >()'
5363 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5364@end smallexample
5365
5366Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5367This flag also affects the output of the
5368@option{-fdiagnostics-show-template-tree} flag.
5369
5370@item -fdiagnostics-path-format=@var{KIND}
5371@opindex fdiagnostics-path-format
5372Specify how to print paths of control-flow events for diagnostics that
5373have such a path associated with them.
5374
5375@var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5376the default.
5377
5378@samp{none} means to not print diagnostic paths.
5379
5380@samp{separate-events} means to print a separate ``note'' diagnostic for
5381each event within the diagnostic. For example:
5382
5383@smallexample
5384test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5385test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5386test.c:27:3: note: (2) when 'i < count'
5387test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5388@end smallexample
5389
5390@samp{inline-events} means to print the events ``inline'' within the source
5391code. This view attempts to consolidate the events into runs of
5392sufficiently-close events, printing them as labelled ranges within the source.
5393
5394For example, the same events as above might be printed as:
5395
5396@smallexample
5397 'test': events 1-3
5398 |
5399 | 25 | list = PyList_New(0);
5400 | | ^~~~~~~~~~~~~
5401 | | |
5402 | | (1) when 'PyList_New' fails, returning NULL
5403 | 26 |
5404 | 27 | for (i = 0; i < count; i++) @{
5405 | | ~~~
5406 | | |
5407 | | (2) when 'i < count'
5408 | 28 | item = PyLong_FromLong(random());
5409 | 29 | PyList_Append(list, item);
5410 | | ~~~~~~~~~~~~~~~~~~~~~~~~~
5411 | | |
5412 | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5413 |
5414@end smallexample
5415
5416Interprocedural control flow is shown by grouping the events by stack frame,
5417and using indentation to show how stack frames are nested, pushed, and popped.
5418
5419For example:
5420
5421@smallexample
5422 'test': events 1-2
5423 |
5424 | 133 | @{
5425 | | ^
5426 | | |
5427 | | (1) entering 'test'
5428 | 134 | boxed_int *obj = make_boxed_int (i);
5429 | | ~~~~~~~~~~~~~~~~~~
5430 | | |
5431 | | (2) calling 'make_boxed_int'
5432 |
5433 +--> 'make_boxed_int': events 3-4
5434 |
5435 | 120 | @{
5436 | | ^
5437 | | |
5438 | | (3) entering 'make_boxed_int'
5439 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5440 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5441 | | |
5442 | | (4) calling 'wrapped_malloc'
5443 |
5444 +--> 'wrapped_malloc': events 5-6
5445 |
5446 | 7 | @{
5447 | | ^
5448 | | |
5449 | | (5) entering 'wrapped_malloc'
5450 | 8 | return malloc (size);
5451 | | ~~~~~~~~~~~~~
5452 | | |
5453 | | (6) calling 'malloc'
5454 |
5455 <-------------+
5456 |
5457 'test': event 7
5458 |
5459 | 138 | free_boxed_int (obj);
5460 | | ^~~~~~~~~~~~~~~~~~~~
5461 | | |
5462 | | (7) calling 'free_boxed_int'
5463 |
5464(etc)
5465@end smallexample
5466
5467@item -fdiagnostics-show-path-depths
5468@opindex fdiagnostics-show-path-depths
5469This option provides additional information when printing control-flow paths
5470associated with a diagnostic.
5471
5472If this is option is provided then the stack depth will be printed for
5473each run of events within @option{-fdiagnostics-path-format=inline-events}.
5474If provided with @option{-fdiagnostics-path-format=separate-events}, then
5475the stack depth and function declaration will be appended when printing
5476each event.
5477
5478This is intended for use by GCC developers and plugin developers when
5479debugging diagnostics that report interprocedural control flow.
5480
5481@item -fno-show-column
5482@opindex fno-show-column
5483@opindex fshow-column
5484Do not print column numbers in diagnostics. This may be necessary if
5485diagnostics are being scanned by a program that does not understand the
5486column numbers, such as @command{dejagnu}.
5487
5488@item -fdiagnostics-column-unit=@var{UNIT}
5489@opindex fdiagnostics-column-unit
5490Select the units for the column number. This affects traditional diagnostics
5491(in the absence of @option{-fno-show-column}), as well as JSON format
5492diagnostics if requested.
5493
5494The default @var{UNIT}, @samp{display}, considers the number of display
5495columns occupied by each character. This may be larger than the number
5496of bytes required to encode the character, in the case of tab
5497characters, or it may be smaller, in the case of multibyte characters.
5498For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5499display column, and its UTF-8 encoding requires two bytes; the character
5500``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5501its UTF-8 encoding requires four bytes.
5502
5503Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5504count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5505
5506@item -fdiagnostics-column-origin=@var{ORIGIN}
5507@opindex fdiagnostics-column-origin
5508Select the origin for column numbers, i.e. the column number assigned to the
5509first column. The default value of 1 corresponds to traditional GCC
5510behavior and to the GNU style guide. Some utilities may perform better with an
5511origin of 0; any non-negative value may be specified.
5512
5513@item -fdiagnostics-escape-format=@var{FORMAT}
5514@opindex fdiagnostics-escape-format
5515When GCC prints pertinent source lines for a diagnostic it normally attempts
5516to print the source bytes directly. However, some diagnostics relate to encoding
5517issues in the source file, such as malformed UTF-8, or issues with Unicode
5518normalization. These diagnostics are flagged so that GCC will escape bytes
5519that are not printable ASCII when printing their pertinent source lines.
5520
5521This option controls how such bytes should be escaped.
5522
5523The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5524are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5525correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5526displayed as hexadecimal in the form @samp{<XX>}.
5527
5528For example, a source line containing the string @samp{before} followed by the
5529Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
55300xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
5531the string @samp{after} will be printed for such a diagnostic as:
5532
5533@smallexample
5534 before<U+03C0><BF>after
5535@end smallexample
5536
5537Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
5538in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
5539Unicode characters. For the example above, the following will be printed:
5540
5541@smallexample
5542 before<CF><80><BF>after
5543@end smallexample
5544
5545@item -fdiagnostics-format=@var{FORMAT}
5546@opindex fdiagnostics-format
5547Select a different format for printing diagnostics.
5548@var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file},
5549@samp{json}, @samp{json-stderr}, or @samp{json-file}.
5550
5551The default is @samp{text}.
5552
5553The @samp{sarif-stderr} and @samp{sarif-file} formats both emit
5554diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file
5555named @file{@var{source}.sarif}, respectively.
5556
5557The @samp{json} format is a synonym for @samp{json-stderr}.
5558The @samp{json-stderr} and @samp{json-file} formats are identical, apart from
5559where the JSON is emitted to - with the former, the JSON is emitted to stderr,
5560whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}.
5561
5562The emitted JSON consists of a top-level JSON array containing JSON objects
5563representing the diagnostics. The JSON is emitted as one line, without
5564formatting; the examples below have been formatted for clarity.
5565
5566Diagnostics can have child diagnostics. For example, this error and note:
5567
5568@smallexample
5569misleading-indentation.c:15:3: warning: this 'if' clause does not
5570 guard... [-Wmisleading-indentation]
5571 15 | if (flag)
5572 | ^~
5573misleading-indentation.c:17:5: note: ...this statement, but the latter
5574 is misleadingly indented as if it were guarded by the 'if'
5575 17 | y = 2;
5576 | ^
5577@end smallexample
5578
5579@noindent
5580might be printed in JSON form (after formatting) like this:
5581
5582@smallexample
5583[
5584 @{
5585 "kind": "warning",
5586 "locations": [
5587 @{
5588 "caret": @{
5589 "display-column": 3,
5590 "byte-column": 3,
5591 "column": 3,
5592 "file": "misleading-indentation.c",
5593 "line": 15
5594 @},
5595 "finish": @{
5596 "display-column": 4,
5597 "byte-column": 4,
5598 "column": 4,
5599 "file": "misleading-indentation.c",
5600 "line": 15
5601 @}
5602 @}
5603 ],
5604 "message": "this \u2018if\u2019 clause does not guard...",
5605 "option": "-Wmisleading-indentation",
5606 "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation",
5607 "children": [
5608 @{
5609 "kind": "note",
5610 "locations": [
5611 @{
5612 "caret": @{
5613 "display-column": 5,
5614 "byte-column": 5,
5615 "column": 5,
5616 "file": "misleading-indentation.c",
5617 "line": 17
5618 @}
5619 @}
5620 ],
5621 "escape-source": false,
5622 "message": "...this statement, but the latter is @dots{}"
5623 @}
5624 ]
5625 "escape-source": false,
5626 "column-origin": 1,
5627 @}
5628]
5629@end smallexample
5630
5631@noindent
5632where the @code{note} is a child of the @code{warning}.
5633
5634A diagnostic has a @code{kind}. If this is @code{warning}, then there is
5635an @code{option} key describing the command-line option controlling the
5636warning.
5637
5638A diagnostic can contain zero or more locations. Each location has an
5639optional @code{label} string and up to three positions within it: a
5640@code{caret} position and optional @code{start} and @code{finish} positions.
5641A position is described by a @code{file} name, a @code{line} number, and
5642three numbers indicating a column position:
5643@itemize @bullet
5644
5645@item
5646@code{display-column} counts display columns, accounting for tabs and
5647multibyte characters.
5648
5649@item
5650@code{byte-column} counts raw bytes.
5651
5652@item
5653@code{column} is equal to one of
5654the previous two, as dictated by the @option{-fdiagnostics-column-unit}
5655option.
5656
5657@end itemize
5658All three columns are relative to the origin specified by
5659@option{-fdiagnostics-column-origin}, which is typically equal to 1 but may
5660be set, for instance, to 0 for compatibility with other utilities that
5661number columns from 0. The column origin is recorded in the JSON output in
5662the @code{column-origin} tag. In the remaining examples below, the extra
5663column number outputs have been omitted for brevity.
5664
5665For example, this error:
5666
5667@smallexample
5668bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka
5669 'struct s'@} and 'T' @{aka 'struct t'@})
5670 64 | return callee_4a () + callee_4b ();
5671 | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
5672 | | |
5673 | | T @{aka struct t@}
5674 | S @{aka struct s@}
5675@end smallexample
5676
5677@noindent
5678has three locations. Its primary location is at the ``+'' token at column
567923. It has two secondary locations, describing the left and right-hand sides
5680of the expression, which have labels. It might be printed in JSON form as:
5681
5682@smallexample
5683 @{
5684 "children": [],
5685 "kind": "error",
5686 "locations": [
5687 @{
5688 "caret": @{
5689 "column": 23, "file": "bad-binary-ops.c", "line": 64
5690 @}
5691 @},
5692 @{
5693 "caret": @{
5694 "column": 10, "file": "bad-binary-ops.c", "line": 64
5695 @},
5696 "finish": @{
5697 "column": 21, "file": "bad-binary-ops.c", "line": 64
5698 @},
5699 "label": "S @{aka struct s@}"
5700 @},
5701 @{
5702 "caret": @{
5703 "column": 25, "file": "bad-binary-ops.c", "line": 64
5704 @},
5705 "finish": @{
5706 "column": 36, "file": "bad-binary-ops.c", "line": 64
5707 @},
5708 "label": "T @{aka struct t@}"
5709 @}
5710 ],
5711 "escape-source": false,
5712 "message": "invalid operands to binary + @dots{}"
5713 @}
5714@end smallexample
5715
5716If a diagnostic contains fix-it hints, it has a @code{fixits} array,
5717consisting of half-open intervals, similar to the output of
5718@option{-fdiagnostics-parseable-fixits}. For example, this diagnostic
5719with a replacement fix-it hint:
5720
5721@smallexample
5722demo.c:8:15: error: 'struct s' has no member named 'colour'; did you
5723 mean 'color'?
5724 8 | return ptr->colour;
5725 | ^~~~~~
5726 | color
5727@end smallexample
5728
5729@noindent
5730might be printed in JSON form as:
5731
5732@smallexample
5733 @{
5734 "children": [],
5735 "fixits": [
5736 @{
5737 "next": @{
5738 "column": 21,
5739 "file": "demo.c",
5740 "line": 8
5741 @},
5742 "start": @{
5743 "column": 15,
5744 "file": "demo.c",
5745 "line": 8
5746 @},
5747 "string": "color"
5748 @}
5749 ],
5750 "kind": "error",
5751 "locations": [
5752 @{
5753 "caret": @{
5754 "column": 15,
5755 "file": "demo.c",
5756 "line": 8
5757 @},
5758 "finish": @{
5759 "column": 20,
5760 "file": "demo.c",
5761 "line": 8
5762 @}
5763 @}
5764 ],
5765 "escape-source": false,
5766 "message": "\u2018struct s\u2019 has no member named @dots{}"
5767 @}
5768@end smallexample
5769
5770@noindent
5771where the fix-it hint suggests replacing the text from @code{start} up
5772to but not including @code{next} with @code{string}'s value. Deletions
5773are expressed via an empty value for @code{string}, insertions by
5774having @code{start} equal @code{next}.
5775
5776If the diagnostic has a path of control-flow events associated with it,
5777it has a @code{path} array of objects representing the events. Each
5778event object has a @code{description} string, a @code{location} object,
5779along with a @code{function} string and a @code{depth} number for
5780representing interprocedural paths. The @code{function} represents the
5781current function at that event, and the @code{depth} represents the
5782stack depth relative to some baseline: the higher, the more frames are
5783within the stack.
5784
5785For example, the intraprocedural example shown for
5786@option{-fdiagnostics-path-format=} might have this JSON for its path:
5787
5788@smallexample
5789 "path": [
5790 @{
5791 "depth": 0,
5792 "description": "when 'PyList_New' fails, returning NULL",
5793 "function": "test",
5794 "location": @{
5795 "column": 10,
5796 "file": "test.c",
5797 "line": 25
5798 @}
5799 @},
5800 @{
5801 "depth": 0,
5802 "description": "when 'i < count'",
5803 "function": "test",
5804 "location": @{
5805 "column": 3,
5806 "file": "test.c",
5807 "line": 27
5808 @}
5809 @},
5810 @{
5811 "depth": 0,
5812 "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1",
5813 "function": "test",
5814 "location": @{
5815 "column": 5,
5816 "file": "test.c",
5817 "line": 29
5818 @}
5819 @}
5820 ]
5821@end smallexample
5822
5823Diagnostics have a boolean attribute @code{escape-source}, hinting whether
5824non-ASCII bytes should be escaped when printing the pertinent lines of
5825source code (@code{true} for diagnostics involving source encoding issues).
5826
5827@end table
5828
5829@node Warning Options
5830@section Options to Request or Suppress Warnings
5831@cindex options to control warnings
5832@cindex warning messages
5833@cindex messages, warning
5834@cindex suppressing warnings
5835
5836Warnings are diagnostic messages that report constructions that
5837are not inherently erroneous but that are risky or suggest there
5838may have been an error.
5839
5840The following language-independent options do not enable specific
5841warnings but control the kinds of diagnostics produced by GCC@.
5842
5843@table @gcctabopt
5844@cindex syntax checking
5845@item -fsyntax-only
5846@opindex fsyntax-only
5847Check the code for syntax errors, but don't do anything beyond that.
5848
5849@item -fmax-errors=@var{n}
5850@opindex fmax-errors
5851Limits the maximum number of error messages to @var{n}, at which point
5852GCC bails out rather than attempting to continue processing the source
5853code. If @var{n} is 0 (the default), there is no limit on the number
5854of error messages produced. If @option{-Wfatal-errors} is also
5855specified, then @option{-Wfatal-errors} takes precedence over this
5856option.
5857
5858@item -w
5859@opindex w
5860Inhibit all warning messages.
5861
5862@item -Werror
5863@opindex Werror
5864@opindex Wno-error
5865Make all warnings into errors.
5866
5867@item -Werror=
5868@opindex Werror=
5869@opindex Wno-error=
5870Make the specified warning into an error. The specifier for a warning
5871is appended; for example @option{-Werror=switch} turns the warnings
5872controlled by @option{-Wswitch} into errors. This switch takes a
5873negative form, to be used to negate @option{-Werror} for specific
5874warnings; for example @option{-Wno-error=switch} makes
5875@option{-Wswitch} warnings not be errors, even when @option{-Werror}
5876is in effect.
5877
5878The warning message for each controllable warning includes the
5879option that controls the warning. That option can then be used with
5880@option{-Werror=} and @option{-Wno-error=} as described above.
5881(Printing of the option in the warning message can be disabled using the
5882@option{-fno-diagnostics-show-option} flag.)
5883
5884Note that specifying @option{-Werror=}@var{foo} automatically implies
5885@option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
5886imply anything.
5887
5888@item -Wfatal-errors
5889@opindex Wfatal-errors
5890@opindex Wno-fatal-errors
5891This option causes the compiler to abort compilation on the first error
5892occurred rather than trying to keep going and printing further error
5893messages.
5894
5895@end table
5896
5897You can request many specific warnings with options beginning with
5898@samp{-W}, for example @option{-Wimplicit} to request warnings on
5899implicit declarations. Each of these specific warning options also
5900has a negative form beginning @samp{-Wno-} to turn off warnings; for
5901example, @option{-Wno-implicit}. This manual lists only one of the
5902two forms, whichever is not the default. For further
5903language-specific options also refer to @ref{C++ Dialect Options} and
5904@ref{Objective-C and Objective-C++ Dialect Options}.
5905Additional warnings can be produced by enabling the static analyzer;
5906@xref{Static Analyzer Options}.
5907
5908Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
5909options, such as @option{-Wunused}, which may turn on further options,
5910such as @option{-Wunused-value}. The combined effect of positive and
5911negative forms is that more specific options have priority over less
5912specific ones, independently of their position in the command-line. For
5913options of the same specificity, the last one takes effect. Options
5914enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
5915as if they appeared at the end of the command-line.
5916
5917When an unrecognized warning option is requested (e.g.,
5918@option{-Wunknown-warning}), GCC emits a diagnostic stating
5919that the option is not recognized. However, if the @option{-Wno-} form
5920is used, the behavior is slightly different: no diagnostic is
5921produced for @option{-Wno-unknown-warning} unless other diagnostics
5922are being produced. This allows the use of new @option{-Wno-} options
5923with old compilers, but if something goes wrong, the compiler
5924warns that an unrecognized option is present.
5925
5926The effectiveness of some warnings depends on optimizations also being
5927enabled. For example @option{-Wsuggest-final-types} is more effective
5928with link-time optimization and some instances of other warnings may
5929not be issued at all unless optimization is enabled. While optimization
5930in general improves the efficacy of control and data flow sensitive
5931warnings, in some cases it may also cause false positives.
5932
5933@table @gcctabopt
5934@item -Wpedantic
5935@itemx -pedantic
5936@opindex pedantic
5937@opindex Wpedantic
5938@opindex Wno-pedantic
5939Issue all the warnings demanded by strict ISO C and ISO C++;
5940reject all programs that use forbidden extensions, and some other
5941programs that do not follow ISO C and ISO C++. For ISO C, follows the
5942version of the ISO C standard specified by any @option{-std} option used.
5943
5944Valid ISO C and ISO C++ programs should compile properly with or without
5945this option (though a rare few require @option{-ansi} or a
5946@option{-std} option specifying the required version of ISO C)@. However,
5947without this option, certain GNU extensions and traditional C and C++
5948features are supported as well. With this option, they are rejected.
5949
5950@option{-Wpedantic} does not cause warning messages for use of the
5951alternate keywords whose names begin and end with @samp{__}. This alternate
5952format can also be used to disable warnings for non-ISO @samp{__intN} types,
5953i.e. @samp{__intN__}.
5954Pedantic warnings are also disabled in the expression that follows
5955@code{__extension__}. However, only system header files should use
5956these escape routes; application programs should avoid them.
5957@xref{Alternate Keywords}.
5958
5959Some users try to use @option{-Wpedantic} to check programs for strict ISO
5960C conformance. They soon find that it does not do quite what they want:
5961it finds some non-ISO practices, but not all---only those for which
5962ISO C @emph{requires} a diagnostic, and some others for which
5963diagnostics have been added.
5964
5965A feature to report any failure to conform to ISO C might be useful in
5966some instances, but would require considerable additional work and would
5967be quite different from @option{-Wpedantic}. We don't have plans to
5968support such a feature in the near future.
5969
5970Where the standard specified with @option{-std} represents a GNU
5971extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
5972corresponding @dfn{base standard}, the version of ISO C on which the GNU
5973extended dialect is based. Warnings from @option{-Wpedantic} are given
5974where they are required by the base standard. (It does not make sense
5975for such warnings to be given only for features not in the specified GNU
5976C dialect, since by definition the GNU dialects of C include all
5977features the compiler supports with the given option, and there would be
5978nothing to warn about.)
5979
5980@item -pedantic-errors
5981@opindex pedantic-errors
5982Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
5983requires a diagnostic, in some cases where there is undefined behavior
5984at compile-time and in some other cases that do not prevent compilation
5985of programs that are valid according to the standard. This is not
5986equivalent to @option{-Werror=pedantic}, since there are errors enabled
5987by this option and not enabled by the latter and vice versa.
5988
5989@item -Wall
5990@opindex Wall
5991@opindex Wno-all
5992This enables all the warnings about constructions that some users
5993consider questionable, and that are easy to avoid (or modify to
5994prevent the warning), even in conjunction with macros. This also
5995enables some language-specific warnings described in @ref{C++ Dialect
5996Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
5997
5998@option{-Wall} turns on the following warning flags:
5999
6000@gccoptlist{-Waddress @gol
6001-Warray-bounds=1 @r{(only with} @option{-O2}@r{)} @gol
6002-Warray-compare @gol
6003-Warray-parameter=2 @r{(C and Objective-C only)} @gol
6004-Wbool-compare @gol
6005-Wbool-operation @gol
6006-Wc++11-compat -Wc++14-compat @gol
6007-Wcatch-value @r{(C++ and Objective-C++ only)} @gol
6008-Wchar-subscripts @gol
6009-Wcomment @gol
6010-Wdangling-pointer=2 @gol
6011-Wduplicate-decl-specifier @r{(C and Objective-C only)} @gol
6012-Wenum-compare @r{(in C/ObjC; this is on by default in C++)} @gol
6013-Wenum-int-mismatch @r{(C and Objective-C only)} @gol
6014-Wformat @gol
6015-Wformat-overflow @gol
6016-Wformat-truncation @gol
6017-Wint-in-bool-context @gol
6018-Wimplicit @r{(C and Objective-C only)} @gol
6019-Wimplicit-int @r{(C and Objective-C only)} @gol
6020-Wimplicit-function-declaration @r{(C and Objective-C only)} @gol
6021-Winit-self @r{(only for C++)} @gol
6022-Wlogical-not-parentheses @gol
6023-Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} @gol
6024-Wmaybe-uninitialized @gol
6025-Wmemset-elt-size @gol
6026-Wmemset-transposed-args @gol
6027-Wmisleading-indentation @r{(only for C/C++)} @gol
6028-Wmismatched-dealloc @gol
6029-Wmismatched-new-delete @r{(only for C/C++)} @gol
6030-Wmissing-attributes @gol
6031-Wmissing-braces @r{(only for C/ObjC)} @gol
6032-Wmultistatement-macros @gol
6033-Wnarrowing @r{(only for C++)} @gol
6034-Wnonnull @gol
6035-Wnonnull-compare @gol
6036-Wopenmp-simd @gol
6037-Wparentheses @gol
6038-Wpessimizing-move @r{(only for C++)} @gol
6039-Wpointer-sign @gol
6040-Wrange-loop-construct @r{(only for C++)} @gol
6041-Wreorder @gol
6042-Wrestrict @gol
6043-Wreturn-type @gol
6044-Wself-move @r{(only for C++)} @gol
6045-Wsequence-point @gol
6046-Wsign-compare @r{(only in C++)} @gol
6047-Wsizeof-array-div @gol
6048-Wsizeof-pointer-div @gol
6049-Wsizeof-pointer-memaccess @gol
6050-Wstrict-aliasing @gol
6051-Wstrict-overflow=1 @gol
6052-Wswitch @gol
6053-Wtautological-compare @gol
6054-Wtrigraphs @gol
6055-Wuninitialized @gol
6056-Wunknown-pragmas @gol
6057-Wunused-function @gol
6058-Wunused-label @gol
6059-Wunused-value @gol
6060-Wunused-variable @gol
6061-Wuse-after-free=3 @gol
6062-Wvla-parameter @r{(C and Objective-C only)} @gol
6063-Wvolatile-register-var @gol
6064-Wzero-length-bounds}
6065
6066Note that some warning flags are not implied by @option{-Wall}. Some of
6067them warn about constructions that users generally do not consider
6068questionable, but which occasionally you might wish to check for;
6069others warn about constructions that are necessary or hard to avoid in
6070some cases, and there is no simple way to modify the code to suppress
6071the warning. Some of them are enabled by @option{-Wextra} but many of
6072them must be enabled individually.
6073
6074@item -Wextra
6075@opindex W
6076@opindex Wextra
6077@opindex Wno-extra
6078This enables some extra warning flags that are not enabled by
6079@option{-Wall}. (This option used to be called @option{-W}. The older
6080name is still supported, but the newer name is more descriptive.)
6081
6082@gccoptlist{-Wclobbered @gol
6083-Wcast-function-type @gol
6084-Wdeprecated-copy @r{(C++ only)} @gol
6085-Wempty-body @gol
6086-Wenum-conversion @r{(C only)} @gol
6087-Wignored-qualifiers @gol
6088-Wimplicit-fallthrough=3 @gol
6089-Wmissing-field-initializers @gol
6090-Wmissing-parameter-type @r{(C only)} @gol
6091-Wold-style-declaration @r{(C only)} @gol
6092-Woverride-init @gol
6093-Wsign-compare @r{(C only)} @gol
6094-Wstring-compare @gol
6095-Wredundant-move @r{(only for C++)} @gol
6096-Wtype-limits @gol
6097-Wuninitialized @gol
6098-Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)} @gol
6099-Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)} @gol
6100-Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
6101
6102
6103The option @option{-Wextra} also prints warning messages for the
6104following cases:
6105
6106@itemize @bullet
6107
6108@item
6109A pointer is compared against integer zero with @code{<}, @code{<=},
6110@code{>}, or @code{>=}.
6111
6112@item
6113(C++ only) An enumerator and a non-enumerator both appear in a
6114conditional expression.
6115
6116@item
6117(C++ only) Ambiguous virtual bases.
6118
6119@item
6120(C++ only) Subscripting an array that has been declared @code{register}.
6121
6122@item
6123(C++ only) Taking the address of a variable that has been declared
6124@code{register}.
6125
6126@item
6127(C++ only) A base class is not initialized in the copy constructor
6128of a derived class.
6129
6130@end itemize
6131
6132@item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
6133@opindex Wabi
6134@opindex Wno-abi
6135
6136Warn about code affected by ABI changes. This includes code that may
6137not be compatible with the vendor-neutral C++ ABI as well as the psABI
6138for the particular target.
6139
6140Since G++ now defaults to updating the ABI with each major release,
6141normally @option{-Wabi} warns only about C++ ABI compatibility
6142problems if there is a check added later in a release series for an
6143ABI issue discovered since the initial release. @option{-Wabi} warns
6144about more things if an older ABI version is selected (with
6145@option{-fabi-version=@var{n}}).
6146
6147@option{-Wabi} can also be used with an explicit version number to
6148warn about C++ ABI compatibility with a particular @option{-fabi-version}
6149level, e.g.@: @option{-Wabi=2} to warn about changes relative to
6150@option{-fabi-version=2}.
6151
6152If an explicit version number is provided and
6153@option{-fabi-compat-version} is not specified, the version number
6154from this option is used for compatibility aliases. If no explicit
6155version number is provided with this option, but
6156@option{-fabi-compat-version} is specified, that version number is
6157used for C++ ABI warnings.
6158
6159Although an effort has been made to warn about
6160all such cases, there are probably some cases that are not warned about,
6161even though G++ is generating incompatible code. There may also be
6162cases where warnings are emitted even though the code that is generated
6163is compatible.
6164
6165You should rewrite your code to avoid these warnings if you are
6166concerned about the fact that code generated by G++ may not be binary
6167compatible with code generated by other compilers.
6168
6169Known incompatibilities in @option{-fabi-version=2} (which was the
6170default from GCC 3.4 to 4.9) include:
6171
6172@itemize @bullet
6173
6174@item
6175A template with a non-type template parameter of reference type was
6176mangled incorrectly:
6177@smallexample
6178extern int N;
6179template <int &> struct S @{@};
6180void n (S<N>) @{2@}
6181@end smallexample
6182
6183This was fixed in @option{-fabi-version=3}.
6184
6185@item
6186SIMD vector types declared using @code{__attribute ((vector_size))} were
6187mangled in a non-standard way that does not allow for overloading of
6188functions taking vectors of different sizes.
6189
6190The mangling was changed in @option{-fabi-version=4}.
6191
6192@item
6193@code{__attribute ((const))} and @code{noreturn} were mangled as type
6194qualifiers, and @code{decltype} of a plain declaration was folded away.
6195
6196These mangling issues were fixed in @option{-fabi-version=5}.
6197
6198@item
6199Scoped enumerators passed as arguments to a variadic function are
6200promoted like unscoped enumerators, causing @code{va_arg} to complain.
6201On most targets this does not actually affect the parameter passing
6202ABI, as there is no way to pass an argument smaller than @code{int}.
6203
6204Also, the ABI changed the mangling of template argument packs,
6205@code{const_cast}, @code{static_cast}, prefix increment/decrement, and
6206a class scope function used as a template argument.
6207
6208These issues were corrected in @option{-fabi-version=6}.
6209
6210@item
6211Lambdas in default argument scope were mangled incorrectly, and the
6212ABI changed the mangling of @code{nullptr_t}.
6213
6214These issues were corrected in @option{-fabi-version=7}.
6215
6216@item
6217When mangling a function type with function-cv-qualifiers, the
6218un-qualified function type was incorrectly treated as a substitution
6219candidate.
6220
6221This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
6222
6223@item
6224@code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
6225unaligned accesses. Note that this did not affect the ABI of a
6226function with a @code{nullptr_t} parameter, as parameters have a
6227minimum alignment.
6228
6229This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
6230
6231@item
6232Target-specific attributes that affect the identity of a type, such as
6233ia32 calling conventions on a function type (stdcall, regparm, etc.),
6234did not affect the mangled name, leading to name collisions when
6235function pointers were used as template arguments.
6236
6237This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
6238
6239@end itemize
6240
6241This option also enables warnings about psABI-related changes.
6242The known psABI changes at this point include:
6243
6244@itemize @bullet
6245
6246@item
6247For SysV/x86-64, unions with @code{long double} members are
6248passed in memory as specified in psABI. Prior to GCC 4.4, this was not
6249the case. For example:
6250
6251@smallexample
6252union U @{
6253 long double ld;
6254 int i;
6255@};
6256@end smallexample
6257
6258@noindent
6259@code{union U} is now always passed in memory.
6260
6261@end itemize
6262
6263@item -Wchar-subscripts
6264@opindex Wchar-subscripts
6265@opindex Wno-char-subscripts
6266Warn if an array subscript has type @code{char}. This is a common cause
6267of error, as programmers often forget that this type is signed on some
6268machines.
6269This warning is enabled by @option{-Wall}.
6270
6271@item -Wno-coverage-mismatch
6272@opindex Wno-coverage-mismatch
6273@opindex Wcoverage-mismatch
6274Warn if feedback profiles do not match when using the
6275@option{-fprofile-use} option.
6276If a source file is changed between compiling with @option{-fprofile-generate}
6277and with @option{-fprofile-use}, the files with the profile feedback can fail
6278to match the source file and GCC cannot use the profile feedback
6279information. By default, this warning is enabled and is treated as an
6280error. @option{-Wno-coverage-mismatch} can be used to disable the
6281warning or @option{-Wno-error=coverage-mismatch} can be used to
6282disable the error. Disabling the error for this warning can result in
6283poorly optimized code and is useful only in the
6284case of very minor changes such as bug fixes to an existing code-base.
6285Completely disabling the warning is not recommended.
6286
6287@item -Wno-coverage-invalid-line-number
6288@opindex Wno-coverage-invalid-line-number
6289@opindex Wcoverage-invalid-line-number
6290Warn in case a function ends earlier than it begins due
6291to an invalid linenum macros. The warning is emitted only
6292with @option{--coverage} enabled.
6293
6294By default, this warning is enabled and is treated as an
6295error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
6296warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
6297disable the error.
6298
6299@item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
6300@opindex Wno-cpp
6301@opindex Wcpp
6302Suppress warning messages emitted by @code{#warning} directives.
6303
6304@item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
6305@opindex Wdouble-promotion
6306@opindex Wno-double-promotion
6307Give a warning when a value of type @code{float} is implicitly
6308promoted to @code{double}. CPUs with a 32-bit ``single-precision''
6309floating-point unit implement @code{float} in hardware, but emulate
6310@code{double} in software. On such a machine, doing computations
6311using @code{double} values is much more expensive because of the
6312overhead required for software emulation.
6313
6314It is easy to accidentally do computations with @code{double} because
6315floating-point literals are implicitly of type @code{double}. For
6316example, in:
6317@smallexample
6318@group
6319float area(float radius)
6320@{
6321 return 3.14159 * radius * radius;
6322@}
6323@end group
6324@end smallexample
6325the compiler performs the entire computation with @code{double}
6326because the floating-point literal is a @code{double}.
6327
6328@item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
6329@opindex Wduplicate-decl-specifier
6330@opindex Wno-duplicate-decl-specifier
6331Warn if a declaration has duplicate @code{const}, @code{volatile},
6332@code{restrict} or @code{_Atomic} specifier. This warning is enabled by
6333@option{-Wall}.
6334
6335@item -Wformat
6336@itemx -Wformat=@var{n}
6337@opindex Wformat
6338@opindex Wno-format
6339@opindex ffreestanding
6340@opindex fno-builtin
6341@opindex Wformat=
6342Check calls to @code{printf} and @code{scanf}, etc., to make sure that
6343the arguments supplied have types appropriate to the format string
6344specified, and that the conversions specified in the format string make
6345sense. This includes standard functions, and others specified by format
6346attributes (@pxref{Function Attributes}), in the @code{printf},
6347@code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
6348not in the C standard) families (or other target-specific families).
6349Which functions are checked without format attributes having been
6350specified depends on the standard version selected, and such checks of
6351functions without the attribute specified are disabled by
6352@option{-ffreestanding} or @option{-fno-builtin}.
6353
6354The formats are checked against the format features supported by GNU
6355libc version 2.2. These include all ISO C90 and C99 features, as well
6356as features from the Single Unix Specification and some BSD and GNU
6357extensions. Other library implementations may not support all these
6358features; GCC does not support warning about features that go beyond a
6359particular library's limitations. However, if @option{-Wpedantic} is used
6360with @option{-Wformat}, warnings are given about format features not
6361in the selected standard version (but not for @code{strfmon} formats,
6362since those are not in any version of the C standard). @xref{C Dialect
6363Options,,Options Controlling C Dialect}.
6364
6365@table @gcctabopt
6366@item -Wformat=1
6367@itemx -Wformat
6368@opindex Wformat
6369@opindex Wformat=1
6370Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6371@option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6372@option{-Wformat} also checks for null format arguments for several
6373functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6374aspects of this level of format checking can be disabled by the
6375options: @option{-Wno-format-contains-nul},
6376@option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6377@option{-Wformat} is enabled by @option{-Wall}.
6378
6379@item -Wformat=2
6380@opindex Wformat=2
6381Enable @option{-Wformat} plus additional format checks. Currently
6382equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6383-Wformat-y2k}.
6384@end table
6385
6386@item -Wno-format-contains-nul
6387@opindex Wno-format-contains-nul
6388@opindex Wformat-contains-nul
6389If @option{-Wformat} is specified, do not warn about format strings that
6390contain NUL bytes.
6391
6392@item -Wno-format-extra-args
6393@opindex Wno-format-extra-args
6394@opindex Wformat-extra-args
6395If @option{-Wformat} is specified, do not warn about excess arguments to a
6396@code{printf} or @code{scanf} format function. The C standard specifies
6397that such arguments are ignored.
6398
6399Where the unused arguments lie between used arguments that are
6400specified with @samp{$} operand number specifications, normally
6401warnings are still given, since the implementation could not know what
6402type to pass to @code{va_arg} to skip the unused arguments. However,
6403in the case of @code{scanf} formats, this option suppresses the
6404warning if the unused arguments are all pointers, since the Single
6405Unix Specification says that such unused arguments are allowed.
6406
6407@item -Wformat-overflow
6408@itemx -Wformat-overflow=@var{level}
6409@opindex Wformat-overflow
6410@opindex Wno-format-overflow
6411Warn about calls to formatted input/output functions such as @code{sprintf}
6412and @code{vsprintf} that might overflow the destination buffer. When the
6413exact number of bytes written by a format directive cannot be determined
6414at compile-time it is estimated based on heuristics that depend on the
6415@var{level} argument and on optimization. While enabling optimization
6416will in most cases improve the accuracy of the warning, it may also
6417result in false positives.
6418
6419@table @gcctabopt
6420@item -Wformat-overflow
6421@itemx -Wformat-overflow=1
6422@opindex Wformat-overflow
6423@opindex Wno-format-overflow
6424Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6425employs a conservative approach that warns only about calls that most
6426likely overflow the buffer. At this level, numeric arguments to format
6427directives with unknown values are assumed to have the value of one, and
6428strings of unknown length to be empty. Numeric arguments that are known
6429to be bounded to a subrange of their type, or string arguments whose output
6430is bounded either by their directive's precision or by a finite set of
6431string literals, are assumed to take on the value within the range that
6432results in the most bytes on output. For example, the call to @code{sprintf}
6433below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6434the terminating NUL character (@code{'\0'}) appended by the function
6435to the destination buffer will be written past its end. Increasing
6436the size of the buffer by a single byte is sufficient to avoid the
6437warning, though it may not be sufficient to avoid the overflow.
6438
6439@smallexample
6440void f (int a, int b)
6441@{
6442 char buf [13];
6443 sprintf (buf, "a = %i, b = %i\n", a, b);
6444@}
6445@end smallexample
6446
6447@item -Wformat-overflow=2
6448Level @var{2} warns also about calls that might overflow the destination
6449buffer given an argument of sufficient length or magnitude. At level
6450@var{2}, unknown numeric arguments are assumed to have the minimum
6451representable value for signed types with a precision greater than 1, and
6452the maximum representable value otherwise. Unknown string arguments whose
6453length cannot be assumed to be bounded either by the directive's precision,
6454or by a finite set of string literals they may evaluate to, or the character
6455array they may point to, are assumed to be 1 character long.
6456
6457At level @var{2}, the call in the example above is again diagnosed, but
6458this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6459@code{%i} directive will write some of its digits beyond the end of
6460the destination buffer. To make the call safe regardless of the values
6461of the two variables, the size of the destination buffer must be increased
6462to at least 34 bytes. GCC includes the minimum size of the buffer in
6463an informational note following the warning.
6464
6465An alternative to increasing the size of the destination buffer is to
6466constrain the range of formatted values. The maximum length of string
6467arguments can be bounded by specifying the precision in the format
6468directive. When numeric arguments of format directives can be assumed
6469to be bounded by less than the precision of their type, choosing
6470an appropriate length modifier to the format specifier will reduce
6471the required buffer size. For example, if @var{a} and @var{b} in the
6472example above can be assumed to be within the precision of
6473the @code{short int} type then using either the @code{%hi} format
6474directive or casting the argument to @code{short} reduces the maximum
6475required size of the buffer to 24 bytes.
6476
6477@smallexample
6478void f (int a, int b)
6479@{
6480 char buf [23];
6481 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
6482@}
6483@end smallexample
6484@end table
6485
6486@item -Wno-format-zero-length
6487@opindex Wno-format-zero-length
6488@opindex Wformat-zero-length
6489If @option{-Wformat} is specified, do not warn about zero-length formats.
6490The C standard specifies that zero-length formats are allowed.
6491
6492@item -Wformat-nonliteral
6493@opindex Wformat-nonliteral
6494@opindex Wno-format-nonliteral
6495If @option{-Wformat} is specified, also warn if the format string is not a
6496string literal and so cannot be checked, unless the format function
6497takes its format arguments as a @code{va_list}.
6498
6499@item -Wformat-security
6500@opindex Wformat-security
6501@opindex Wno-format-security
6502If @option{-Wformat} is specified, also warn about uses of format
6503functions that represent possible security problems. At present, this
6504warns about calls to @code{printf} and @code{scanf} functions where the
6505format string is not a string literal and there are no format arguments,
6506as in @code{printf (foo);}. This may be a security hole if the format
6507string came from untrusted input and contains @samp{%n}. (This is
6508currently a subset of what @option{-Wformat-nonliteral} warns about, but
6509in future warnings may be added to @option{-Wformat-security} that are not
6510included in @option{-Wformat-nonliteral}.)
6511
6512@item -Wformat-signedness
6513@opindex Wformat-signedness
6514@opindex Wno-format-signedness
6515If @option{-Wformat} is specified, also warn if the format string
6516requires an unsigned argument and the argument is signed and vice versa.
6517
6518@item -Wformat-truncation
6519@itemx -Wformat-truncation=@var{level}
6520@opindex Wformat-truncation
6521@opindex Wno-format-truncation
6522Warn about calls to formatted input/output functions such as @code{snprintf}
6523and @code{vsnprintf} that might result in output truncation. When the exact
6524number of bytes written by a format directive cannot be determined at
6525compile-time it is estimated based on heuristics that depend on
6526the @var{level} argument and on optimization. While enabling optimization
6527will in most cases improve the accuracy of the warning, it may also result
6528in false positives. Except as noted otherwise, the option uses the same
6529logic @option{-Wformat-overflow}.
6530
6531@table @gcctabopt
6532@item -Wformat-truncation
6533@itemx -Wformat-truncation=1
6534@opindex Wformat-truncation
6535@opindex Wno-format-truncation
6536Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
6537employs a conservative approach that warns only about calls to bounded
6538functions whose return value is unused and that will most likely result
6539in output truncation.
6540
6541@item -Wformat-truncation=2
6542Level @var{2} warns also about calls to bounded functions whose return
6543value is used and that might result in truncation given an argument of
6544sufficient length or magnitude.
6545@end table
6546
6547@item -Wformat-y2k
6548@opindex Wformat-y2k
6549@opindex Wno-format-y2k
6550If @option{-Wformat} is specified, also warn about @code{strftime}
6551formats that may yield only a two-digit year.
6552
6553@item -Wnonnull
6554@opindex Wnonnull
6555@opindex Wno-nonnull
6556Warn about passing a null pointer for arguments marked as
6557requiring a non-null value by the @code{nonnull} function attribute.
6558
6559@option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
6560can be disabled with the @option{-Wno-nonnull} option.
6561
6562@item -Wnonnull-compare
6563@opindex Wnonnull-compare
6564@opindex Wno-nonnull-compare
6565Warn when comparing an argument marked with the @code{nonnull}
6566function attribute against null inside the function.
6567
6568@option{-Wnonnull-compare} is included in @option{-Wall}. It
6569can be disabled with the @option{-Wno-nonnull-compare} option.
6570
6571@item -Wnull-dereference
6572@opindex Wnull-dereference
6573@opindex Wno-null-dereference
6574Warn if the compiler detects paths that trigger erroneous or
6575undefined behavior due to dereferencing a null pointer. This option
6576is only active when @option{-fdelete-null-pointer-checks} is active,
6577which is enabled by optimizations in most targets. The precision of
6578the warnings depends on the optimization options used.
6579
6580@item -Winfinite-recursion
6581@opindex Winfinite-recursion
6582@opindex Wno-infinite-recursion
6583Warn about infinitely recursive calls. The warning is effective at all
6584optimization levels but requires optimization in order to detect infinite
6585recursion in calls between two or more functions.
6586@option{-Winfinite-recursion} is included in @option{-Wall}.
6587
ce51e843
ML
6588Compare with @option{-Wanalyzer-infinite-recursion} which provides a
6589similar diagnostic, but is implemented in a different way (as part of
6590@option{-fanalyzer}).
6591
d77de738
ML
6592@item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
6593@opindex Winit-self
6594@opindex Wno-init-self
6595Warn about uninitialized variables that are initialized with themselves.
6596Note this option can only be used with the @option{-Wuninitialized} option.
6597
6598For example, GCC warns about @code{i} being uninitialized in the
6599following snippet only when @option{-Winit-self} has been specified:
6600@smallexample
6601@group
6602int f()
6603@{
6604 int i = i;
6605 return i;
6606@}
6607@end group
6608@end smallexample
6609
6610This warning is enabled by @option{-Wall} in C++.
6611
6612@item -Wno-implicit-int @r{(C and Objective-C only)}
6613@opindex Wimplicit-int
6614@opindex Wno-implicit-int
6615This option controls warnings when a declaration does not specify a type.
6616This warning is enabled by default in C99 and later dialects of C,
6617and also by @option{-Wall}.
6618
6619@item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
6620@opindex Wimplicit-function-declaration
6621@opindex Wno-implicit-function-declaration
6622This option controls warnings when a function is used before being declared.
6623This warning is enabled by default in C99 and later dialects of C,
6624and also by @option{-Wall}.
6625The warning is made into an error by @option{-pedantic-errors}.
6626
6627@item -Wimplicit @r{(C and Objective-C only)}
6628@opindex Wimplicit
6629@opindex Wno-implicit
6630Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
6631This warning is enabled by @option{-Wall}.
6632
6633@item -Wimplicit-fallthrough
6634@opindex Wimplicit-fallthrough
6635@opindex Wno-implicit-fallthrough
6636@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
6637and @option{-Wno-implicit-fallthrough} is the same as
6638@option{-Wimplicit-fallthrough=0}.
6639
6640@item -Wimplicit-fallthrough=@var{n}
6641@opindex Wimplicit-fallthrough=
6642Warn when a switch case falls through. For example:
6643
6644@smallexample
6645@group
6646switch (cond)
6647 @{
6648 case 1:
6649 a = 1;
6650 break;
6651 case 2:
6652 a = 2;
6653 case 3:
6654 a = 3;
6655 break;
6656 @}
6657@end group
6658@end smallexample
6659
6660This warning does not warn when the last statement of a case cannot
6661fall through, e.g. when there is a return statement or a call to function
6662declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
6663also takes into account control flow statements, such as ifs, and only
6664warns when appropriate. E.g.@:
6665
6666@smallexample
6667@group
6668switch (cond)
6669 @{
6670 case 1:
6671 if (i > 3) @{
6672 bar (5);
6673 break;
6674 @} else if (i < 1) @{
6675 bar (0);
6676 @} else
6677 return;
6678 default:
6679 @dots{}
6680 @}
6681@end group
6682@end smallexample
6683
6684Since there are occasions where a switch case fall through is desirable,
6685GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
6686to be used along with a null statement to suppress this warning that
6687would normally occur:
6688
6689@smallexample
6690@group
6691switch (cond)
6692 @{
6693 case 1:
6694 bar (0);
6695 __attribute__ ((fallthrough));
6696 default:
6697 @dots{}
6698 @}
6699@end group
6700@end smallexample
6701
6702C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
6703warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
6704or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
6705Instead of these attributes, it is also possible to add a fallthrough comment
6706to silence the warning. The whole body of the C or C++ style comment should
6707match the given regular expressions listed below. The option argument @var{n}
6708specifies what kind of comments are accepted:
6709
6710@itemize @bullet
6711
6712@item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
6713
6714@item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
6715expression, any comment is used as fallthrough comment.
6716
6717@item @option{-Wimplicit-fallthrough=2} case insensitively matches
6718@code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
6719
6720@item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
6721following regular expressions:
6722
6723@itemize @bullet
6724
6725@item @code{-fallthrough}
6726
6727@item @code{@@fallthrough@@}
6728
6729@item @code{lint -fallthrough[ \t]*}
6730
6731@item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
6732
6733@item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6734
6735@item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6736
6737@end itemize
6738
6739@item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
6740following regular expressions:
6741
6742@itemize @bullet
6743
6744@item @code{-fallthrough}
6745
6746@item @code{@@fallthrough@@}
6747
6748@item @code{lint -fallthrough[ \t]*}
6749
6750@item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
6751
6752@end itemize
6753
6754@item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
6755fallthrough comments, only attributes disable the warning.
6756
6757@end itemize
6758
6759The comment needs to be followed after optional whitespace and other comments
6760by @code{case} or @code{default} keywords or by a user label that precedes some
6761@code{case} or @code{default} label.
6762
6763@smallexample
6764@group
6765switch (cond)
6766 @{
6767 case 1:
6768 bar (0);
6769 /* FALLTHRU */
6770 default:
6771 @dots{}
6772 @}
6773@end group
6774@end smallexample
6775
6776The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
6777
6778@item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
6779@opindex Wif-not-aligned
6780@opindex Wno-if-not-aligned
6781Control if warnings triggered by the @code{warn_if_not_aligned} attribute
6782should be issued. These warnings are enabled by default.
6783
6784@item -Wignored-qualifiers @r{(C and C++ only)}
6785@opindex Wignored-qualifiers
6786@opindex Wno-ignored-qualifiers
6787Warn if the return type of a function has a type qualifier
6788such as @code{const}. For ISO C such a type qualifier has no effect,
6789since the value returned by a function is not an lvalue.
6790For C++, the warning is only emitted for scalar types or @code{void}.
6791ISO C prohibits qualified @code{void} return types on function
6792definitions, so such return types always receive a warning
6793even without this option.
6794
6795This warning is also enabled by @option{-Wextra}.
6796
6797@item -Wno-ignored-attributes @r{(C and C++ only)}
6798@opindex Wignored-attributes
6799@opindex Wno-ignored-attributes
6800This option controls warnings when an attribute is ignored.
6801This is different from the
6802@option{-Wattributes} option in that it warns whenever the compiler decides
6803to drop an attribute, not that the attribute is either unknown, used in a
6804wrong place, etc. This warning is enabled by default.
6805
6806@item -Wmain
6807@opindex Wmain
6808@opindex Wno-main
6809Warn if the type of @code{main} is suspicious. @code{main} should be
6810a function with external linkage, returning int, taking either zero
6811arguments, two, or three arguments of appropriate types. This warning
6812is enabled by default in C++ and is enabled by either @option{-Wall}
6813or @option{-Wpedantic}.
6814
6815@item -Wmisleading-indentation @r{(C and C++ only)}
6816@opindex Wmisleading-indentation
6817@opindex Wno-misleading-indentation
6818Warn when the indentation of the code does not reflect the block structure.
6819Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
6820@code{for} clauses with a guarded statement that does not use braces,
6821followed by an unguarded statement with the same indentation.
6822
6823In the following example, the call to ``bar'' is misleadingly indented as
6824if it were guarded by the ``if'' conditional.
6825
6826@smallexample
6827 if (some_condition ())
6828 foo ();
6829 bar (); /* Gotcha: this is not guarded by the "if". */
6830@end smallexample
6831
6832In the case of mixed tabs and spaces, the warning uses the
6833@option{-ftabstop=} option to determine if the statements line up
6834(defaulting to 8).
6835
6836The warning is not issued for code involving multiline preprocessor logic
6837such as the following example.
6838
6839@smallexample
6840 if (flagA)
6841 foo (0);
6842#if SOME_CONDITION_THAT_DOES_NOT_HOLD
6843 if (flagB)
6844#endif
6845 foo (1);
6846@end smallexample
6847
6848The warning is not issued after a @code{#line} directive, since this
6849typically indicates autogenerated code, and no assumptions can be made
6850about the layout of the file that the directive references.
6851
6852This warning is enabled by @option{-Wall} in C and C++.
6853
6854@item -Wmissing-attributes
6855@opindex Wmissing-attributes
6856@opindex Wno-missing-attributes
6857Warn when a declaration of a function is missing one or more attributes
6858that a related function is declared with and whose absence may adversely
6859affect the correctness or efficiency of generated code. For example,
6860the warning is issued for declarations of aliases that use attributes
6861to specify less restrictive requirements than those of their targets.
6862This typically represents a potential optimization opportunity.
6863By contrast, the @option{-Wattribute-alias=2} option controls warnings
6864issued when the alias is more restrictive than the target, which could
6865lead to incorrect code generation.
6866Attributes considered include @code{alloc_align}, @code{alloc_size},
6867@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
6868@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
6869@code{returns_nonnull}, and @code{returns_twice}.
6870
6871In C++, the warning is issued when an explicit specialization of a primary
6872template declared with attribute @code{alloc_align}, @code{alloc_size},
6873@code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
6874or @code{nonnull} is declared without it. Attributes @code{deprecated},
6875@code{error}, and @code{warning} suppress the warning.
6876(@pxref{Function Attributes}).
6877
6878You can use the @code{copy} attribute to apply the same
6879set of attributes to a declaration as that on another declaration without
6880explicitly enumerating the attributes. This attribute can be applied
6881to declarations of functions (@pxref{Common Function Attributes}),
6882variables (@pxref{Common Variable Attributes}), or types
6883(@pxref{Common Type Attributes}).
6884
6885@option{-Wmissing-attributes} is enabled by @option{-Wall}.
6886
6887For example, since the declaration of the primary function template
6888below makes use of both attribute @code{malloc} and @code{alloc_size}
6889the declaration of the explicit specialization of the template is
6890diagnosed because it is missing one of the attributes.
6891
6892@smallexample
6893template <class T>
6894T* __attribute__ ((malloc, alloc_size (1)))
6895allocate (size_t);
6896
6897template <>
6898void* __attribute__ ((malloc)) // missing alloc_size
6899allocate<void> (size_t);
6900@end smallexample
6901
6902@item -Wmissing-braces
6903@opindex Wmissing-braces
6904@opindex Wno-missing-braces
6905Warn if an aggregate or union initializer is not fully bracketed. In
6906the following example, the initializer for @code{a} is not fully
6907bracketed, but that for @code{b} is fully bracketed.
6908
6909@smallexample
6910int a[2][2] = @{ 0, 1, 2, 3 @};
6911int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
6912@end smallexample
6913
6914This warning is enabled by @option{-Wall}.
6915
6916@item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
6917@opindex Wmissing-include-dirs
6918@opindex Wno-missing-include-dirs
6919Warn if a user-supplied include directory does not exist. This opions is disabled
6920by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
6921enabled by default by warning for -I and -J, only.
6922
6923@item -Wno-missing-profile
6924@opindex Wmissing-profile
6925@opindex Wno-missing-profile
6926This option controls warnings if feedback profiles are missing when using the
6927@option{-fprofile-use} option.
6928This option diagnoses those cases where a new function or a new file is added
6929between compiling with @option{-fprofile-generate} and with
6930@option{-fprofile-use}, without regenerating the profiles.
6931In these cases, the profile feedback data files do not contain any
6932profile feedback information for
6933the newly added function or file respectively. Also, in the case when profile
6934count data (.gcda) files are removed, GCC cannot use any profile feedback
6935information. In all these cases, warnings are issued to inform you that a
6936profile generation step is due.
6937Ignoring the warning can result in poorly optimized code.
6938@option{-Wno-missing-profile} can be used to
6939disable the warning, but this is not recommended and should be done only
6940when non-existent profile data is justified.
6941
6942@item -Wmismatched-dealloc
6943@opindex Wmismatched-dealloc
6944@opindex Wno-mismatched-dealloc
6945
6946Warn for calls to deallocation functions with pointer arguments returned
6947from from allocations functions for which the former isn't a suitable
6948deallocator. A pair of functions can be associated as matching allocators
6949and deallocators by use of attribute @code{malloc}. Unless disabled by
6950the @option{-fno-builtin} option the standard functions @code{calloc},
6951@code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
6952forms of C++ @code{operator new} and @code{operator delete} are implicitly
6953associated as matching allocators and deallocators. In the following
6954example @code{mydealloc} is the deallocator for pointers returned from
6955@code{myalloc}.
6956
6957@smallexample
6958void mydealloc (void*);
6959
6960__attribute__ ((malloc (mydealloc, 1))) void*
6961myalloc (size_t);
6962
6963void f (void)
6964@{
6965 void *p = myalloc (32);
6966 // @dots{}use p@dots{}
6967 free (p); // warning: not a matching deallocator for myalloc
6968 mydealloc (p); // ok
6969@}
6970@end smallexample
6971
6972In C++, the related option @option{-Wmismatched-new-delete} diagnoses
6973mismatches involving either @code{operator new} or @code{operator delete}.
6974
6975Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
6976
6977@item -Wmultistatement-macros
6978@opindex Wmultistatement-macros
6979@opindex Wno-multistatement-macros
6980Warn about unsafe multiple statement macros that appear to be guarded
6981by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
6982@code{while}, in which only the first statement is actually guarded after
6983the macro is expanded.
6984
6985For example:
6986
6987@smallexample
6988#define DOIT x++; y++
6989if (c)
6990 DOIT;
6991@end smallexample
6992
6993will increment @code{y} unconditionally, not just when @code{c} holds.
6994The can usually be fixed by wrapping the macro in a do-while loop:
6995@smallexample
6996#define DOIT do @{ x++; y++; @} while (0)
6997if (c)
6998 DOIT;
6999@end smallexample
7000
7001This warning is enabled by @option{-Wall} in C and C++.
7002
7003@item -Wparentheses
7004@opindex Wparentheses
7005@opindex Wno-parentheses
7006Warn if parentheses are omitted in certain contexts, such
7007as when there is an assignment in a context where a truth value
7008is expected, or when operators are nested whose precedence people
7009often get confused about.
7010
7011Also warn if a comparison like @code{x<=y<=z} appears; this is
7012equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
7013interpretation from that of ordinary mathematical notation.
7014
7015Also warn for dangerous uses of the GNU extension to
7016@code{?:} with omitted middle operand. When the condition
7017in the @code{?}: operator is a boolean expression, the omitted value is
7018always 1. Often programmers expect it to be a value computed
7019inside the conditional expression instead.
7020
7021For C++ this also warns for some cases of unnecessary parentheses in
7022declarations, which can indicate an attempt at a function call instead
7023of a declaration:
7024@smallexample
7025@{
7026 // Declares a local variable called mymutex.
7027 std::unique_lock<std::mutex> (mymutex);
7028 // User meant std::unique_lock<std::mutex> lock (mymutex);
7029@}
7030@end smallexample
7031
7032This warning is enabled by @option{-Wall}.
7033
7034@item -Wno-self-move @r{(C++ and Objective-C++ only)}
7035@opindex Wself-move
7036@opindex Wno-self-move
7037This warning warns when a value is moved to itself with @code{std::move}.
7038Such a @code{std::move} typically has no effect.
7039
7040@smallexample
7041struct T @{
7042@dots{}
7043@};
7044void fn()
7045@{
7046 T t;
7047 @dots{}
7048 t = std::move (t);
7049@}
7050@end smallexample
7051
7052This warning is enabled by @option{-Wall}.
7053
7054@item -Wsequence-point
7055@opindex Wsequence-point
7056@opindex Wno-sequence-point
7057Warn about code that may have undefined semantics because of violations
7058of sequence point rules in the C and C++ standards.
7059
7060The C and C++ standards define the order in which expressions in a C/C++
7061program are evaluated in terms of @dfn{sequence points}, which represent
7062a partial ordering between the execution of parts of the program: those
7063executed before the sequence point, and those executed after it. These
7064occur after the evaluation of a full expression (one which is not part
7065of a larger expression), after the evaluation of the first operand of a
7066@code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
7067function is called (but after the evaluation of its arguments and the
7068expression denoting the called function), and in certain other places.
7069Other than as expressed by the sequence point rules, the order of
7070evaluation of subexpressions of an expression is not specified. All
7071these rules describe only a partial order rather than a total order,
7072since, for example, if two functions are called within one expression
7073with no sequence point between them, the order in which the functions
7074are called is not specified. However, the standards committee have
7075ruled that function calls do not overlap.
7076
7077It is not specified when between sequence points modifications to the
7078values of objects take effect. Programs whose behavior depends on this
7079have undefined behavior; the C and C++ standards specify that ``Between
7080the previous and next sequence point an object shall have its stored
7081value modified at most once by the evaluation of an expression.
7082Furthermore, the prior value shall be read only to determine the value
7083to be stored.''. If a program breaks these rules, the results on any
7084particular implementation are entirely unpredictable.
7085
7086Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
7087= b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
7088diagnosed by this option, and it may give an occasional false positive
7089result, but in general it has been found fairly effective at detecting
7090this sort of problem in programs.
7091
7092The C++17 standard will define the order of evaluation of operands in
7093more cases: in particular it requires that the right-hand side of an
7094assignment be evaluated before the left-hand side, so the above
7095examples are no longer undefined. But this option will still warn
7096about them, to help people avoid writing code that is undefined in C
7097and earlier revisions of C++.
7098
7099The standard is worded confusingly, therefore there is some debate
7100over the precise meaning of the sequence point rules in subtle cases.
7101Links to discussions of the problem, including proposed formal
7102definitions, may be found on the GCC readings page, at
7103@uref{https://gcc.gnu.org/@/readings.html}.
7104
7105This warning is enabled by @option{-Wall} for C and C++.
7106
7107@item -Wno-return-local-addr
7108@opindex Wno-return-local-addr
7109@opindex Wreturn-local-addr
7110Do not warn about returning a pointer (or in C++, a reference) to a
7111variable that goes out of scope after the function returns.
7112
7113@item -Wreturn-type
7114@opindex Wreturn-type
7115@opindex Wno-return-type
7116Warn whenever a function is defined with a return type that defaults
7117to @code{int}. Also warn about any @code{return} statement with no
7118return value in a function whose return type is not @code{void}
7119(falling off the end of the function body is considered returning
7120without a value).
7121
7122For C only, warn about a @code{return} statement with an expression in a
7123function whose return type is @code{void}, unless the expression type is
7124also @code{void}. As a GNU extension, the latter case is accepted
7125without a warning unless @option{-Wpedantic} is used. Attempting
7126to use the return value of a non-@code{void} function other than @code{main}
7127that flows off the end by reaching the closing curly brace that terminates
7128the function is undefined.
7129
7130Unlike in C, in C++, flowing off the end of a non-@code{void} function other
7131than @code{main} results in undefined behavior even when the value of
7132the function is not used.
7133
7134This warning is enabled by default in C++ and by @option{-Wall} otherwise.
7135
7136@item -Wno-shift-count-negative
7137@opindex Wshift-count-negative
7138@opindex Wno-shift-count-negative
7139Controls warnings if a shift count is negative.
7140This warning is enabled by default.
7141
7142@item -Wno-shift-count-overflow
7143@opindex Wshift-count-overflow
7144@opindex Wno-shift-count-overflow
7145Controls warnings if a shift count is greater than or equal to the bit width
7146of the type. This warning is enabled by default.
7147
7148@item -Wshift-negative-value
7149@opindex Wshift-negative-value
7150@opindex Wno-shift-negative-value
7151Warn if left shifting a negative value. This warning is enabled by
7152@option{-Wextra} in C99 (and newer) and C++11 to C++17 modes.
7153
7154@item -Wno-shift-overflow
7155@itemx -Wshift-overflow=@var{n}
7156@opindex Wshift-overflow
7157@opindex Wno-shift-overflow
7158These options control warnings about left shift overflows.
7159
7160@table @gcctabopt
7161@item -Wshift-overflow=1
7162This is the warning level of @option{-Wshift-overflow} and is enabled
7163by default in C99 and C++11 modes (and newer). This warning level does
7164not warn about left-shifting 1 into the sign bit. (However, in C, such
7165an overflow is still rejected in contexts where an integer constant expression
7166is required.) No warning is emitted in C++20 mode (and newer), as signed left
7167shifts always wrap.
7168
7169@item -Wshift-overflow=2
7170This warning level also warns about left-shifting 1 into the sign bit,
7171unless C++14 mode (or newer) is active.
7172@end table
7173
7174@item -Wswitch
7175@opindex Wswitch
7176@opindex Wno-switch
7177Warn whenever a @code{switch} statement has an index of enumerated type
7178and lacks a @code{case} for one or more of the named codes of that
7179enumeration. (The presence of a @code{default} label prevents this
7180warning.) @code{case} labels outside the enumeration range also
7181provoke warnings when this option is used (even if there is a
7182@code{default} label).
7183This warning is enabled by @option{-Wall}.
7184
7185@item -Wswitch-default
7186@opindex Wswitch-default
7187@opindex Wno-switch-default
7188Warn whenever a @code{switch} statement does not have a @code{default}
7189case.
7190
7191@item -Wswitch-enum
7192@opindex Wswitch-enum
7193@opindex Wno-switch-enum
7194Warn whenever a @code{switch} statement has an index of enumerated type
7195and lacks a @code{case} for one or more of the named codes of that
7196enumeration. @code{case} labels outside the enumeration range also
7197provoke warnings when this option is used. The only difference
7198between @option{-Wswitch} and this option is that this option gives a
7199warning about an omitted enumeration code even if there is a
7200@code{default} label.
7201
7202@item -Wno-switch-bool
7203@opindex Wswitch-bool
7204@opindex Wno-switch-bool
7205Do not warn when a @code{switch} statement has an index of boolean type
7206and the case values are outside the range of a boolean type.
7207It is possible to suppress this warning by casting the controlling
7208expression to a type other than @code{bool}. For example:
7209@smallexample
7210@group
7211switch ((int) (a == 4))
7212 @{
7213 @dots{}
7214 @}
7215@end group
7216@end smallexample
7217This warning is enabled by default for C and C++ programs.
7218
7219@item -Wno-switch-outside-range
7220@opindex Wswitch-outside-range
7221@opindex Wno-switch-outside-range
7222This option controls warnings when a @code{switch} case has a value
7223that is outside of its
7224respective type range. This warning is enabled by default for
7225C and C++ programs.
7226
7227@item -Wno-switch-unreachable
7228@opindex Wswitch-unreachable
7229@opindex Wno-switch-unreachable
7230Do not warn when a @code{switch} statement contains statements between the
7231controlling expression and the first case label, which will never be
7232executed. For example:
7233@smallexample
7234@group
7235switch (cond)
7236 @{
7237 i = 15;
7238 @dots{}
7239 case 5:
7240 @dots{}
7241 @}
7242@end group
7243@end smallexample
7244@option{-Wswitch-unreachable} does not warn if the statement between the
7245controlling expression and the first case label is just a declaration:
7246@smallexample
7247@group
7248switch (cond)
7249 @{
7250 int i;
7251 @dots{}
7252 case 5:
7253 i = 5;
7254 @dots{}
7255 @}
7256@end group
7257@end smallexample
7258This warning is enabled by default for C and C++ programs.
7259
7260@item -Wsync-nand @r{(C and C++ only)}
7261@opindex Wsync-nand
7262@opindex Wno-sync-nand
7263Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
7264built-in functions are used. These functions changed semantics in GCC 4.4.
7265
7266@item -Wtrivial-auto-var-init
7267@opindex Wtrivial-auto-var-init
7268@opindex Wno-trivial-auto-var-init
7269Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic
7270variable. A common situation is an automatic variable that is declared
7271between the controlling expression and the first case label of a @code{switch}
7272statement.
7273
7274@item -Wunused-but-set-parameter
7275@opindex Wunused-but-set-parameter
7276@opindex Wno-unused-but-set-parameter
7277Warn whenever a function parameter is assigned to, but otherwise unused
7278(aside from its declaration).
7279
7280To suppress this warning use the @code{unused} attribute
7281(@pxref{Variable Attributes}).
7282
7283This warning is also enabled by @option{-Wunused} together with
7284@option{-Wextra}.
7285
7286@item -Wunused-but-set-variable
7287@opindex Wunused-but-set-variable
7288@opindex Wno-unused-but-set-variable
7289Warn whenever a local variable is assigned to, but otherwise unused
7290(aside from its declaration).
7291This warning is enabled by @option{-Wall}.
7292
7293To suppress this warning use the @code{unused} attribute
7294(@pxref{Variable Attributes}).
7295
7296This warning is also enabled by @option{-Wunused}, which is enabled
7297by @option{-Wall}.
7298
7299@item -Wunused-function
7300@opindex Wunused-function
7301@opindex Wno-unused-function
7302Warn whenever a static function is declared but not defined or a
7303non-inline static function is unused.
7304This warning is enabled by @option{-Wall}.
7305
7306@item -Wunused-label
7307@opindex Wunused-label
7308@opindex Wno-unused-label
7309Warn whenever a label is declared but not used.
7310This warning is enabled by @option{-Wall}.
7311
7312To suppress this warning use the @code{unused} attribute
7313(@pxref{Variable Attributes}).
7314
7315@item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
7316@opindex Wunused-local-typedefs
7317@opindex Wno-unused-local-typedefs
7318Warn when a typedef locally defined in a function is not used.
7319This warning is enabled by @option{-Wall}.
7320
7321@item -Wunused-parameter
7322@opindex Wunused-parameter
7323@opindex Wno-unused-parameter
7324Warn whenever a function parameter is unused aside from its declaration.
7325
7326To suppress this warning use the @code{unused} attribute
7327(@pxref{Variable Attributes}).
7328
7329@item -Wno-unused-result
7330@opindex Wunused-result
7331@opindex Wno-unused-result
7332Do not warn if a caller of a function marked with attribute
7333@code{warn_unused_result} (@pxref{Function Attributes}) does not use
7334its return value. The default is @option{-Wunused-result}.
7335
7336@item -Wunused-variable
7337@opindex Wunused-variable
7338@opindex Wno-unused-variable
7339Warn whenever a local or static variable is unused aside from its
7340declaration. This option implies @option{-Wunused-const-variable=1} for C,
7341but not for C++. This warning is enabled by @option{-Wall}.
7342
7343To suppress this warning use the @code{unused} attribute
7344(@pxref{Variable Attributes}).
7345
7346@item -Wunused-const-variable
7347@itemx -Wunused-const-variable=@var{n}
7348@opindex Wunused-const-variable
7349@opindex Wno-unused-const-variable
7350Warn whenever a constant static variable is unused aside from its declaration.
7351@option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable}
7352for C, but not for C++. In C this declares variable storage, but in C++ this
7353is not an error since const variables take the place of @code{#define}s.
7354
7355To suppress this warning use the @code{unused} attribute
7356(@pxref{Variable Attributes}).
7357
7358@table @gcctabopt
7359@item -Wunused-const-variable=1
7360This is the warning level that is enabled by @option{-Wunused-variable} for
7361C. It warns only about unused static const variables defined in the main
7362compilation unit, but not about static const variables declared in any
7363header included.
7364
7365@item -Wunused-const-variable=2
7366This warning level also warns for unused constant static variables in
7367headers (excluding system headers). This is the warning level of
7368@option{-Wunused-const-variable} and must be explicitly requested since
7369in C++ this isn't an error and in C it might be harder to clean up all
7370headers included.
7371@end table
7372
7373@item -Wunused-value
7374@opindex Wunused-value
7375@opindex Wno-unused-value
7376Warn whenever a statement computes a result that is explicitly not
7377used. To suppress this warning cast the unused expression to
7378@code{void}. This includes an expression-statement or the left-hand
7379side of a comma expression that contains no side effects. For example,
7380an expression such as @code{x[i,j]} causes a warning, while
7381@code{x[(void)i,j]} does not.
7382
7383This warning is enabled by @option{-Wall}.
7384
7385@item -Wunused
7386@opindex Wunused
7387@opindex Wno-unused
7388All the above @option{-Wunused} options combined.
7389
7390In order to get a warning about an unused function parameter, you must
7391either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
7392@option{-Wunused}), or separately specify @option{-Wunused-parameter}.
7393
7394@item -Wuninitialized
7395@opindex Wuninitialized
7396@opindex Wno-uninitialized
7397Warn if an object with automatic or allocated storage duration is used
7398without having been initialized. In C++, also warn if a non-static
7399reference or non-static @code{const} member appears in a class without
7400constructors.
7401
7402In addition, passing a pointer (or in C++, a reference) to an uninitialized
7403object to a @code{const}-qualified argument of a built-in function known to
7404read the object is also diagnosed by this warning.
7405(@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
7406
7407If you want to warn about code that uses the uninitialized value of the
7408variable in its own initializer, use the @option{-Winit-self} option.
7409
7410These warnings occur for individual uninitialized elements of
7411structure, union or array variables as well as for variables that are
7412uninitialized as a whole. They do not occur for variables or elements
7413declared @code{volatile}. Because these warnings depend on
7414optimization, the exact variables or elements for which there are
7415warnings depend on the precise optimization options and version of GCC
7416used.
7417
7418Note that there may be no warning about a variable that is used only
7419to compute a value that itself is never used, because such
7420computations may be deleted by data flow analysis before the warnings
7421are printed.
7422
7423In C++, this warning also warns about using uninitialized objects in
7424member-initializer-lists. For example, GCC warns about @code{b} being
7425uninitialized in the following snippet:
7426
7427@smallexample
7428struct A @{
7429 int a;
7430 int b;
7431 A() : a(b) @{ @}
7432@};
7433@end smallexample
7434
7435@item -Wno-invalid-memory-model
7436@opindex Winvalid-memory-model
7437@opindex Wno-invalid-memory-model
7438This option controls warnings
7439for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
7440and the C11 atomic generic functions with a memory consistency argument
7441that is either invalid for the operation or outside the range of values
7442of the @code{memory_order} enumeration. For example, since the
7443@code{__atomic_store} and @code{__atomic_store_n} built-ins are only
7444defined for the relaxed, release, and sequentially consistent memory
7445orders the following code is diagnosed:
7446
7447@smallexample
7448void store (int *i)
7449@{
7450 __atomic_store_n (i, 0, memory_order_consume);
7451@}
7452@end smallexample
7453
7454@option{-Winvalid-memory-model} is enabled by default.
7455
7456@item -Wmaybe-uninitialized
7457@opindex Wmaybe-uninitialized
7458@opindex Wno-maybe-uninitialized
7459For an object with automatic or allocated storage duration, if there exists
7460a path from the function entry to a use of the object that is initialized,
7461but there exist some other paths for which the object is not initialized,
7462the compiler emits a warning if it cannot prove the uninitialized paths
7463are not executed at run time.
7464
7465In addition, passing a pointer (or in C++, a reference) to an uninitialized
7466object to a @code{const}-qualified function argument is also diagnosed by
7467this warning. (@option{-Wuninitialized} is issued for built-in functions
7468known to read the object.) Annotating the function with attribute
7469@code{access (none)} indicates that the argument isn't used to access
7470the object and avoids the warning (@pxref{Common Function Attributes}).
7471
7472These warnings are only possible in optimizing compilation, because otherwise
7473GCC does not keep track of the state of variables.
7474
7475These warnings are made optional because GCC may not be able to determine when
7476the code is correct in spite of appearing to have an error. Here is one
7477example of how this can happen:
7478
7479@smallexample
7480@group
7481@{
7482 int x;
7483 switch (y)
7484 @{
7485 case 1: x = 1;
7486 break;
7487 case 2: x = 4;
7488 break;
7489 case 3: x = 5;
7490 @}
7491 foo (x);
7492@}
7493@end group
7494@end smallexample
7495
7496@noindent
7497If the value of @code{y} is always 1, 2 or 3, then @code{x} is
7498always initialized, but GCC doesn't know this. To suppress the
7499warning, you need to provide a default case with assert(0) or
7500similar code.
7501
7502@cindex @code{longjmp} warnings
7503This option also warns when a non-volatile automatic variable might be
7504changed by a call to @code{longjmp}.
7505The compiler sees only the calls to @code{setjmp}. It cannot know
7506where @code{longjmp} will be called; in fact, a signal handler could
7507call it at any point in the code. As a result, you may get a warning
7508even when there is in fact no problem because @code{longjmp} cannot
7509in fact be called at the place that would cause a problem.
7510
7511Some spurious warnings can be avoided if you declare all the functions
7512you use that never return as @code{noreturn}. @xref{Function
7513Attributes}.
7514
7515This warning is enabled by @option{-Wall} or @option{-Wextra}.
7516
7517@item -Wunknown-pragmas
7518@opindex Wunknown-pragmas
7519@opindex Wno-unknown-pragmas
7520@cindex warning for unknown pragmas
7521@cindex unknown pragmas, warning
7522@cindex pragmas, warning of unknown
7523Warn when a @code{#pragma} directive is encountered that is not understood by
7524GCC@. If this command-line option is used, warnings are even issued
7525for unknown pragmas in system header files. This is not the case if
7526the warnings are only enabled by the @option{-Wall} command-line option.
7527
7528@item -Wno-pragmas
7529@opindex Wno-pragmas
7530@opindex Wpragmas
7531Do not warn about misuses of pragmas, such as incorrect parameters,
7532invalid syntax, or conflicts between pragmas. See also
7533@option{-Wunknown-pragmas}.
7534
7535@item -Wno-prio-ctor-dtor
7536@opindex Wno-prio-ctor-dtor
7537@opindex Wprio-ctor-dtor
7538Do not warn if a priority from 0 to 100 is used for constructor or destructor.
7539The use of constructor and destructor attributes allow you to assign a
7540priority to the constructor/destructor to control its order of execution
7541before @code{main} is called or after it returns. The priority values must be
7542greater than 100 as the compiler reserves priority values between 0--100 for
7543the implementation.
7544
7545@item -Wstrict-aliasing
7546@opindex Wstrict-aliasing
7547@opindex Wno-strict-aliasing
7548This option is only active when @option{-fstrict-aliasing} is active.
7549It warns about code that might break the strict aliasing rules that the
7550compiler is using for optimization. The warning does not catch all
7551cases, but does attempt to catch the more common pitfalls. It is
7552included in @option{-Wall}.
7553It is equivalent to @option{-Wstrict-aliasing=3}
7554
7555@item -Wstrict-aliasing=n
7556@opindex Wstrict-aliasing=n
7557This option is only active when @option{-fstrict-aliasing} is active.
7558It warns about code that might break the strict aliasing rules that the
7559compiler is using for optimization.
7560Higher levels correspond to higher accuracy (fewer false positives).
7561Higher levels also correspond to more effort, similar to the way @option{-O}
7562works.
7563@option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
7564
7565Level 1: Most aggressive, quick, least accurate.
7566Possibly useful when higher levels
7567do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
7568false negatives. However, it has many false positives.
7569Warns for all pointer conversions between possibly incompatible types,
7570even if never dereferenced. Runs in the front end only.
7571
7572Level 2: Aggressive, quick, not too precise.
7573May still have many false positives (not as many as level 1 though),
7574and few false negatives (but possibly more than level 1).
7575Unlike level 1, it only warns when an address is taken. Warns about
7576incomplete types. Runs in the front end only.
7577
7578Level 3 (default for @option{-Wstrict-aliasing}):
7579Should have very few false positives and few false
7580negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
7581Takes care of the common pun+dereference pattern in the front end:
7582@code{*(int*)&some_float}.
7583If optimization is enabled, it also runs in the back end, where it deals
7584with multiple statement cases using flow-sensitive points-to information.
7585Only warns when the converted pointer is dereferenced.
7586Does not warn about incomplete types.
7587
7588@item -Wstrict-overflow
7589@itemx -Wstrict-overflow=@var{n}
7590@opindex Wstrict-overflow
7591@opindex Wno-strict-overflow
7592This option is only active when signed overflow is undefined.
7593It warns about cases where the compiler optimizes based on the
7594assumption that signed overflow does not occur. Note that it does not
7595warn about all cases where the code might overflow: it only warns
7596about cases where the compiler implements some optimization. Thus
7597this warning depends on the optimization level.
7598
7599An optimization that assumes that signed overflow does not occur is
7600perfectly safe if the values of the variables involved are such that
7601overflow never does, in fact, occur. Therefore this warning can
7602easily give a false positive: a warning about code that is not
7603actually a problem. To help focus on important issues, several
7604warning levels are defined. No warnings are issued for the use of
7605undefined signed overflow when estimating how many iterations a loop
7606requires, in particular when determining whether a loop will be
7607executed at all.
7608
7609@table @gcctabopt
7610@item -Wstrict-overflow=1
7611Warn about cases that are both questionable and easy to avoid. For
7612example the compiler simplifies
7613@code{x + 1 > x} to @code{1}. This level of
7614@option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
7615are not, and must be explicitly requested.
7616
7617@item -Wstrict-overflow=2
7618Also warn about other cases where a comparison is simplified to a
7619constant. For example: @code{abs (x) >= 0}. This can only be
7620simplified when signed integer overflow is undefined, because
7621@code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
7622zero. @option{-Wstrict-overflow} (with no level) is the same as
7623@option{-Wstrict-overflow=2}.
7624
7625@item -Wstrict-overflow=3
7626Also warn about other cases where a comparison is simplified. For
7627example: @code{x + 1 > 1} is simplified to @code{x > 0}.
7628
7629@item -Wstrict-overflow=4
7630Also warn about other simplifications not covered by the above cases.
7631For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
7632
7633@item -Wstrict-overflow=5
7634Also warn about cases where the compiler reduces the magnitude of a
7635constant involved in a comparison. For example: @code{x + 2 > y} is
7636simplified to @code{x + 1 >= y}. This is reported only at the
7637highest warning level because this simplification applies to many
7638comparisons, so this warning level gives a very large number of
7639false positives.
7640@end table
7641
7642@item -Wstring-compare
7643@opindex Wstring-compare
7644@opindex Wno-string-compare
7645Warn for calls to @code{strcmp} and @code{strncmp} whose result is
7646determined to be either zero or non-zero in tests for such equality
7647owing to the length of one argument being greater than the size of
7648the array the other argument is stored in (or the bound in the case
7649of @code{strncmp}). Such calls could be mistakes. For example,
7650the call to @code{strcmp} below is diagnosed because its result is
7651necessarily non-zero irrespective of the contents of the array @code{a}.
7652
7653@smallexample
7654extern char a[4];
7655void f (char *d)
7656@{
7657 strcpy (d, "string");
7658 @dots{}
7659 if (0 == strcmp (a, d)) // cannot be true
7660 puts ("a and d are the same");
7661@}
7662@end smallexample
7663
7664@option{-Wstring-compare} is enabled by @option{-Wextra}.
7665
7666@item -Wno-stringop-overflow
7667@item -Wstringop-overflow
7668@itemx -Wstringop-overflow=@var{type}
7669@opindex Wstringop-overflow
7670@opindex Wno-stringop-overflow
7671Warn for calls to string manipulation functions such as @code{memcpy} and
7672@code{strcpy} that are determined to overflow the destination buffer. The
7673optional argument is one greater than the type of Object Size Checking to
7674perform to determine the size of the destination. @xref{Object Size Checking}.
7675The argument is meaningful only for functions that operate on character arrays
7676but not for raw memory functions like @code{memcpy} which always make use
7677of Object Size type-0. The option also warns for calls that specify a size
7678in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
7679The option produces the best results with optimization enabled but can detect
7680a small subset of simple buffer overflows even without optimization in
7681calls to the GCC built-in functions like @code{__builtin_memcpy} that
7682correspond to the standard functions. In any case, the option warns about
7683just a subset of buffer overflows detected by the corresponding overflow
7684checking built-ins. For example, the option issues a warning for
7685the @code{strcpy} call below because it copies at least 5 characters
7686(the string @code{"blue"} including the terminating NUL) into the buffer
7687of size 4.
7688
7689@smallexample
7690enum Color @{ blue, purple, yellow @};
7691const char* f (enum Color clr)
7692@{
7693 static char buf [4];
7694 const char *str;
7695 switch (clr)
7696 @{
7697 case blue: str = "blue"; break;
7698 case purple: str = "purple"; break;
7699 case yellow: str = "yellow"; break;
7700 @}
7701
7702 return strcpy (buf, str); // warning here
7703@}
7704@end smallexample
7705
7706Option @option{-Wstringop-overflow=2} is enabled by default.
7707
7708@table @gcctabopt
7709@item -Wstringop-overflow
7710@itemx -Wstringop-overflow=1
7711@opindex Wstringop-overflow
7712@opindex Wno-stringop-overflow
7713The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
7714to determine the sizes of destination objects. At this setting the option
7715does not warn for writes past the end of subobjects of larger objects accessed
7716by pointers unless the size of the largest surrounding object is known. When
7717the destination may be one of several objects it is assumed to be the largest
7718one of them. On Linux systems, when optimization is enabled at this setting
7719the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
7720is defined to a non-zero value.
7721
7722@item -Wstringop-overflow=2
7723The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
7724to determine the sizes of destination objects. At this setting the option
7725warns about overflows when writing to members of the largest complete
7726objects whose exact size is known. However, it does not warn for excessive
7727writes to the same members of unknown objects referenced by pointers since
7728they may point to arrays containing unknown numbers of elements. This is
7729the default setting of the option.
7730
7731@item -Wstringop-overflow=3
7732The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
7733to determine the sizes of destination objects. At this setting the option
7734warns about overflowing the smallest object or data member. This is the
7735most restrictive setting of the option that may result in warnings for safe
7736code.
7737
7738@item -Wstringop-overflow=4
7739The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
7740to determine the sizes of destination objects. At this setting the option
7741warns about overflowing any data members, and when the destination is
7742one of several objects it uses the size of the largest of them to decide
7743whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
7744setting of the option may result in warnings for benign code.
7745@end table
7746
7747@item -Wno-stringop-overread
7748@opindex Wstringop-overread
7749@opindex Wno-stringop-overread
7750Warn for calls to string manipulation functions such as @code{memchr}, or
7751@code{strcpy} that are determined to read past the end of the source
7752sequence.
7753
7754Option @option{-Wstringop-overread} is enabled by default.
7755
7756@item -Wno-stringop-truncation
7757@opindex Wstringop-truncation
7758@opindex Wno-stringop-truncation
7759Do not warn for calls to bounded string manipulation functions
7760such as @code{strncat},
7761@code{strncpy}, and @code{stpncpy} that may either truncate the copied string
7762or leave the destination unchanged.
7763
7764In the following example, the call to @code{strncat} specifies a bound that
7765is less than the length of the source string. As a result, the copy of
7766the source will be truncated and so the call is diagnosed. To avoid the
7767warning use @code{bufsize - strlen (buf) - 1)} as the bound.
7768
7769@smallexample
7770void append (char *buf, size_t bufsize)
7771@{
7772 strncat (buf, ".txt", 3);
7773@}
7774@end smallexample
7775
7776As another example, the following call to @code{strncpy} results in copying
7777to @code{d} just the characters preceding the terminating NUL, without
7778appending the NUL to the end. Assuming the result of @code{strncpy} is
7779necessarily a NUL-terminated string is a common mistake, and so the call
7780is diagnosed. To avoid the warning when the result is not expected to be
7781NUL-terminated, call @code{memcpy} instead.
7782
7783@smallexample
7784void copy (char *d, const char *s)
7785@{
7786 strncpy (d, s, strlen (s));
7787@}
7788@end smallexample
7789
7790In the following example, the call to @code{strncpy} specifies the size
7791of the destination buffer as the bound. If the length of the source
7792string is equal to or greater than this size the result of the copy will
7793not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
7794the warning, specify @code{sizeof buf - 1} as the bound and set the last
7795element of the buffer to @code{NUL}.
7796
7797@smallexample
7798void copy (const char *s)
7799@{
7800 char buf[80];
7801 strncpy (buf, s, sizeof buf);
7802 @dots{}
7803@}
7804@end smallexample
7805
7806In situations where a character array is intended to store a sequence
7807of bytes with no terminating @code{NUL} such an array may be annotated
7808with attribute @code{nonstring} to avoid this warning. Such arrays,
7809however, are not suitable arguments to functions that expect
7810@code{NUL}-terminated strings. To help detect accidental misuses of
7811such arrays GCC issues warnings unless it can prove that the use is
7812safe. @xref{Common Variable Attributes}.
7813
7814@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}
7815@opindex Wsuggest-attribute=
7816@opindex Wno-suggest-attribute=
7817Warn for cases where adding an attribute may be beneficial. The
7818attributes currently supported are listed below.
7819
7820@table @gcctabopt
7821@item -Wsuggest-attribute=pure
7822@itemx -Wsuggest-attribute=const
7823@itemx -Wsuggest-attribute=noreturn
7824@itemx -Wmissing-noreturn
7825@itemx -Wsuggest-attribute=malloc
7826@opindex Wsuggest-attribute=pure
7827@opindex Wno-suggest-attribute=pure
7828@opindex Wsuggest-attribute=const
7829@opindex Wno-suggest-attribute=const
7830@opindex Wsuggest-attribute=noreturn
7831@opindex Wno-suggest-attribute=noreturn
7832@opindex Wmissing-noreturn
7833@opindex Wno-missing-noreturn
7834@opindex Wsuggest-attribute=malloc
7835@opindex Wno-suggest-attribute=malloc
7836
7837Warn about functions that might be candidates for attributes
7838@code{pure}, @code{const} or @code{noreturn} or @code{malloc}. The compiler
7839only warns for functions visible in other compilation units or (in the case of
7840@code{pure} and @code{const}) if it cannot prove that the function returns
7841normally. A function returns normally if it doesn't contain an infinite loop or
7842return abnormally by throwing, calling @code{abort} or trapping. This analysis
7843requires option @option{-fipa-pure-const}, which is enabled by default at
7844@option{-O} and higher. Higher optimization levels improve the accuracy
7845of the analysis.
7846
7847@item -Wsuggest-attribute=format
7848@itemx -Wmissing-format-attribute
7849@opindex Wsuggest-attribute=format
7850@opindex Wmissing-format-attribute
7851@opindex Wno-suggest-attribute=format
7852@opindex Wno-missing-format-attribute
7853@opindex Wformat
7854@opindex Wno-format
7855
7856Warn about function pointers that might be candidates for @code{format}
7857attributes. Note these are only possible candidates, not absolute ones.
7858GCC guesses that function pointers with @code{format} attributes that
7859are used in assignment, initialization, parameter passing or return
7860statements should have a corresponding @code{format} attribute in the
7861resulting type. I.e.@: the left-hand side of the assignment or
7862initialization, the type of the parameter variable, or the return type
7863of the containing function respectively should also have a @code{format}
7864attribute to avoid the warning.
7865
7866GCC also warns about function definitions that might be
7867candidates for @code{format} attributes. Again, these are only
7868possible candidates. GCC guesses that @code{format} attributes
7869might be appropriate for any function that calls a function like
7870@code{vprintf} or @code{vscanf}, but this might not always be the
7871case, and some functions for which @code{format} attributes are
7872appropriate may not be detected.
7873
7874@item -Wsuggest-attribute=cold
7875@opindex Wsuggest-attribute=cold
7876@opindex Wno-suggest-attribute=cold
7877
7878Warn about functions that might be candidates for @code{cold} attribute. This
7879is based on static detection and generally only warns about functions which
7880always leads to a call to another @code{cold} function such as wrappers of
7881C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
7882@end table
7883
7884@item -Walloc-zero
7885@opindex Wno-alloc-zero
7886@opindex Walloc-zero
7887Warn about calls to allocation functions decorated with attribute
7888@code{alloc_size} that specify zero bytes, including those to the built-in
7889forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
7890@code{malloc}, and @code{realloc}. Because the behavior of these functions
7891when called with a zero size differs among implementations (and in the case
7892of @code{realloc} has been deprecated) relying on it may result in subtle
7893portability bugs and should be avoided.
7894
7895@item -Walloc-size-larger-than=@var{byte-size}
7896@opindex Walloc-size-larger-than=
7897@opindex Wno-alloc-size-larger-than
7898Warn about calls to functions decorated with attribute @code{alloc_size}
7899that attempt to allocate objects larger than the specified number of bytes,
7900or where the result of the size computation in an integer type with infinite
7901precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
7902@option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
7903Warnings controlled by the option can be disabled either by specifying
7904@var{byte-size} of @samp{SIZE_MAX} or more or by
7905@option{-Wno-alloc-size-larger-than}.
7906@xref{Function Attributes}.
7907
7908@item -Wno-alloc-size-larger-than
7909@opindex Wno-alloc-size-larger-than
7910Disable @option{-Walloc-size-larger-than=} warnings. The option is
7911equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
7912larger.
7913
7914@item -Walloca
7915@opindex Wno-alloca
7916@opindex Walloca
7917This option warns on all uses of @code{alloca} in the source.
7918
7919@item -Walloca-larger-than=@var{byte-size}
7920@opindex Walloca-larger-than=
7921@opindex Wno-alloca-larger-than
7922This option warns on calls to @code{alloca} with an integer argument whose
7923value is either zero, or that is not bounded by a controlling predicate
7924that limits its value to at most @var{byte-size}. It also warns for calls
7925to @code{alloca} where the bound value is unknown. Arguments of non-integer
7926types are considered unbounded even if they appear to be constrained to
7927the expected range.
7928
7929For example, a bounded case of @code{alloca} could be:
7930
7931@smallexample
7932void func (size_t n)
7933@{
7934 void *p;
7935 if (n <= 1000)
7936 p = alloca (n);
7937 else
7938 p = malloc (n);
7939 f (p);
7940@}
7941@end smallexample
7942
7943In the above example, passing @code{-Walloca-larger-than=1000} would not
7944issue a warning because the call to @code{alloca} is known to be at most
79451000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
7946the compiler would emit a warning.
7947
7948Unbounded uses, on the other hand, are uses of @code{alloca} with no
7949controlling predicate constraining its integer argument. For example:
7950
7951@smallexample
7952void func ()
7953@{
7954 void *p = alloca (n);
7955 f (p);
7956@}
7957@end smallexample
7958
7959If @code{-Walloca-larger-than=500} were passed, the above would trigger
7960a warning, but this time because of the lack of bounds checking.
7961
7962Note, that even seemingly correct code involving signed integers could
7963cause a warning:
7964
7965@smallexample
7966void func (signed int n)
7967@{
7968 if (n < 500)
7969 @{
7970 p = alloca (n);
7971 f (p);
7972 @}
7973@}
7974@end smallexample
7975
7976In the above example, @var{n} could be negative, causing a larger than
7977expected argument to be implicitly cast into the @code{alloca} call.
7978
7979This option also warns when @code{alloca} is used in a loop.
7980
7981@option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
7982but is usually only effective when @option{-ftree-vrp} is active (default
7983for @option{-O2} and above).
7984
7985See also @option{-Wvla-larger-than=}@samp{byte-size}.
7986
7987@item -Wno-alloca-larger-than
7988@opindex Wno-alloca-larger-than
7989Disable @option{-Walloca-larger-than=} warnings. The option is
7990equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
7991
7992@item -Warith-conversion
7993@opindex Warith-conversion
7994@opindex Wno-arith-conversion
7995Do warn about implicit conversions from arithmetic operations even
7996when conversion of the operands to the same type cannot change their
7997values. This affects warnings from @option{-Wconversion},
7998@option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
7999
8000@smallexample
8001@group
8002void f (char c, int i)
8003@{
8004 c = c + i; // warns with @option{-Wconversion}
8005 c = c + 1; // only warns with @option{-Warith-conversion}
8006@}
8007@end group
8008@end smallexample
8009
8010@item -Warray-bounds
8011@itemx -Warray-bounds=@var{n}
8012@opindex Wno-array-bounds
8013@opindex Warray-bounds
8014Warn about out of bounds subscripts or offsets into arrays. This warning
8015is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp}
8016is active (the default for @option{-O2} and above) but a subset of instances
8017are issued even without optimization.
8018
8019@table @gcctabopt
8020@item -Warray-bounds=1
8021This is the default warning level of @option{-Warray-bounds} and is enabled
8022by @option{-Wall}; higher levels are not, and must be explicitly requested.
8023
8024@item -Warray-bounds=2
8025This warning level also warns about out of bounds accesses to trailing
8026struct members of one-element array types (@pxref{Zero Length}) and about
8027the intermediate results of pointer arithmetic that may yield out of bounds
8028values. This warning level may give a larger number of false positives and
8029is deactivated by default.
8030@end table
8031
8032@item -Warray-compare
8033@opindex Warray-compare
8034@opindex Wno-array-compare
8035Warn about equality and relational comparisons between two operands of array
8036type. This comparison was deprecated in C++20. For example:
8037
8038@smallexample
8039int arr1[5];
8040int arr2[5];
8041bool same = arr1 == arr2;
8042@end smallexample
8043
8044@option{-Warray-compare} is enabled by @option{-Wall}.
8045
8046@item -Warray-parameter
8047@itemx -Warray-parameter=@var{n}
8048@opindex Wno-array-parameter
8049Warn about redeclarations of functions involving arguments of array or
8050pointer types of inconsistent kinds or forms, and enable the detection
8051of out-of-bounds accesses to such parameters by warnings such as
8052@option{-Warray-bounds}.
8053
8054If the first function declaration uses the array form the bound specified
8055in the array is assumed to be the minimum number of elements expected to
8056be provided in calls to the function and the maximum number of elements
8057accessed by it. Failing to provide arguments of sufficient size or accessing
8058more than the maximum number of elements may be diagnosed by warnings such
8059as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies
8060involving array parameters declared using the @code{T[static N]} form.
8061
8062For example, the warning triggers for the following redeclarations because
8063the first one allows an array of any size to be passed to @code{f} while
8064the second one with the keyword @code{static} specifies that the array
8065argument must have at least four elements.
8066
8067@smallexample
8068void f (int[static 4]);
8069void f (int[]); // warning (inconsistent array form)
8070
8071void g (void)
8072@{
8073 int *p = (int *)malloc (4);
8074 f (p); // warning (array too small)
8075 @dots{}
8076@}
8077@end smallexample
8078
8079At level 2 the warning also triggers for redeclarations involving any other
8080inconsistency in array or pointer argument forms denoting array sizes.
8081Pointers and arrays of unspecified bound are considered equivalent and do
8082not trigger a warning.
8083
8084@smallexample
8085void g (int*);
8086void g (int[]); // no warning
8087void g (int[8]); // warning (inconsistent array bound)
8088@end smallexample
8089
8090@option{-Warray-parameter=2} is included in @option{-Wall}. The
8091@option{-Wvla-parameter} option triggers warnings for similar inconsistencies
8092involving Variable Length Array arguments.
8093
8094@item -Wattribute-alias=@var{n}
8095@itemx -Wno-attribute-alias
8096@opindex Wattribute-alias
8097@opindex Wno-attribute-alias
8098Warn about declarations using the @code{alias} and similar attributes whose
8099target is incompatible with the type of the alias.
8100@xref{Function Attributes,,Declaring Attributes of Functions}.
8101
8102@table @gcctabopt
8103@item -Wattribute-alias=1
8104The default warning level of the @option{-Wattribute-alias} option diagnoses
8105incompatibilities between the type of the alias declaration and that of its
8106target. Such incompatibilities are typically indicative of bugs.
8107
8108@item -Wattribute-alias=2
8109
8110At this level @option{-Wattribute-alias} also diagnoses cases where
8111the attributes of the alias declaration are more restrictive than the
8112attributes applied to its target. These mismatches can potentially
8113result in incorrect code generation. In other cases they may be
8114benign and could be resolved simply by adding the missing attribute to
8115the target. For comparison, see the @option{-Wmissing-attributes}
8116option, which controls diagnostics when the alias declaration is less
8117restrictive than the target, rather than more restrictive.
8118
8119Attributes considered include @code{alloc_align}, @code{alloc_size},
8120@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
8121@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
8122@code{returns_nonnull}, and @code{returns_twice}.
8123@end table
8124
8125@option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
8126This is the default. You can disable these warnings with either
8127@option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
8128
8129@item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
8130@opindex Wbidi-chars=
8131@opindex Wbidi-chars
8132@opindex Wno-bidi-chars
8133Warn about possibly misleading UTF-8 bidirectional control characters in
8134comments, string literals, character constants, and identifiers. Such
8135characters can change left-to-right writing direction into right-to-left
8136(and vice versa), which can cause confusion between the logical order and
8137visual order. This may be dangerous; for instance, it may seem that a piece
8138of code is not commented out, whereas it in fact is.
8139
8140There are three levels of warning supported by GCC@. The default is
8141@option{-Wbidi-chars=unpaired}, which warns about improperly terminated
8142bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
8143@option{-Wbidi-chars=any} warns about any use of bidirectional control
8144characters.
8145
8146By default, this warning does not warn about UCNs. It is, however, possible
8147to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or
8148@option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid,
8149and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous
8150@option{-Wbidi-chars=any} was specified.
8151
8152@item -Wbool-compare
8153@opindex Wno-bool-compare
8154@opindex Wbool-compare
8155Warn about boolean expression compared with an integer value different from
8156@code{true}/@code{false}. For instance, the following comparison is
8157always false:
8158@smallexample
8159int n = 5;
8160@dots{}
8161if ((n > 1) == 2) @{ @dots{} @}
8162@end smallexample
8163This warning is enabled by @option{-Wall}.
8164
8165@item -Wbool-operation
8166@opindex Wno-bool-operation
8167@opindex Wbool-operation
8168Warn about suspicious operations on expressions of a boolean type. For
8169instance, bitwise negation of a boolean is very likely a bug in the program.
8170For C, this warning also warns about incrementing or decrementing a boolean,
8171which rarely makes sense. (In C++, decrementing a boolean is always invalid.
8172Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
8173
8174This warning is enabled by @option{-Wall}.
8175
8176@item -Wduplicated-branches
8177@opindex Wno-duplicated-branches
8178@opindex Wduplicated-branches
8179Warn when an if-else has identical branches. This warning detects cases like
8180@smallexample
8181if (p != NULL)
8182 return 0;
8183else
8184 return 0;
8185@end smallexample
8186It doesn't warn when both branches contain just a null statement. This warning
8187also warn for conditional operators:
8188@smallexample
8189 int i = x ? *p : *p;
8190@end smallexample
8191
8192@item -Wduplicated-cond
8193@opindex Wno-duplicated-cond
8194@opindex Wduplicated-cond
8195Warn about duplicated conditions in an if-else-if chain. For instance,
8196warn for the following code:
8197@smallexample
8198if (p->q != NULL) @{ @dots{} @}
8199else if (p->q != NULL) @{ @dots{} @}
8200@end smallexample
8201
8202@item -Wframe-address
8203@opindex Wno-frame-address
8204@opindex Wframe-address
8205Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
8206is called with an argument greater than 0. Such calls may return indeterminate
8207values or crash the program. The warning is included in @option{-Wall}.
8208
8209@item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
8210@opindex Wno-discarded-qualifiers
8211@opindex Wdiscarded-qualifiers
8212Do not warn if type qualifiers on pointers are being discarded.
8213Typically, the compiler warns if a @code{const char *} variable is
8214passed to a function that takes a @code{char *} parameter. This option
8215can be used to suppress such a warning.
8216
8217@item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
8218@opindex Wno-discarded-array-qualifiers
8219@opindex Wdiscarded-array-qualifiers
8220Do not warn if type qualifiers on arrays which are pointer targets
8221are being discarded. Typically, the compiler warns if a
8222@code{const int (*)[]} variable is passed to a function that
8223takes a @code{int (*)[]} parameter. This option can be used to
8224suppress such a warning.
8225
8226@item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
8227@opindex Wno-incompatible-pointer-types
8228@opindex Wincompatible-pointer-types
8229Do not warn when there is a conversion between pointers that have incompatible
8230types. This warning is for cases not covered by @option{-Wno-pointer-sign},
8231which warns for pointer argument passing or assignment with different
8232signedness.
8233
8234@item -Wno-int-conversion @r{(C and Objective-C only)}
8235@opindex Wno-int-conversion
8236@opindex Wint-conversion
8237Do not warn about incompatible integer to pointer and pointer to integer
8238conversions. This warning is about implicit conversions; for explicit
8239conversions the warnings @option{-Wno-int-to-pointer-cast} and
8240@option{-Wno-pointer-to-int-cast} may be used.
8241
8242@item -Wzero-length-bounds
8243@opindex Wzero-length-bounds
8244@opindex Wzero-length-bounds
8245Warn about accesses to elements of zero-length array members that might
8246overlap other members of the same object. Declaring interior zero-length
8247arrays is discouraged because accesses to them are undefined. See
8248@xref{Zero Length}.
8249
8250For example, the first two stores in function @code{bad} are diagnosed
8251because the array elements overlap the subsequent members @code{b} and
8252@code{c}. The third store is diagnosed by @option{-Warray-bounds}
8253because it is beyond the bounds of the enclosing object.
8254
8255@smallexample
8256struct X @{ int a[0]; int b, c; @};
8257struct X x;
8258
8259void bad (void)
8260@{
8261 x.a[0] = 0; // -Wzero-length-bounds
8262 x.a[1] = 1; // -Wzero-length-bounds
8263 x.a[2] = 2; // -Warray-bounds
8264@}
8265@end smallexample
8266
8267Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
8268
8269@item -Wno-div-by-zero
8270@opindex Wno-div-by-zero
8271@opindex Wdiv-by-zero
8272Do not warn about compile-time integer division by zero. Floating-point
8273division by zero is not warned about, as it can be a legitimate way of
8274obtaining infinities and NaNs.
8275
8276@item -Wsystem-headers
8277@opindex Wsystem-headers
8278@opindex Wno-system-headers
8279@cindex warnings from system headers
8280@cindex system headers, warnings from
8281Print warning messages for constructs found in system header files.
8282Warnings from system headers are normally suppressed, on the assumption
8283that they usually do not indicate real problems and would only make the
8284compiler output harder to read. Using this command-line option tells
8285GCC to emit warnings from system headers as if they occurred in user
8286code. However, note that using @option{-Wall} in conjunction with this
8287option does @emph{not} warn about unknown pragmas in system
8288headers---for that, @option{-Wunknown-pragmas} must also be used.
8289
8290@item -Wtautological-compare
8291@opindex Wtautological-compare
8292@opindex Wno-tautological-compare
8293Warn if a self-comparison always evaluates to true or false. This
8294warning detects various mistakes such as:
8295@smallexample
8296int i = 1;
8297@dots{}
8298if (i > i) @{ @dots{} @}
8299@end smallexample
8300
8301This warning also warns about bitwise comparisons that always evaluate
8302to true or false, for instance:
8303@smallexample
8304if ((a & 16) == 10) @{ @dots{} @}
8305@end smallexample
8306will always be false.
8307
8308This warning is enabled by @option{-Wall}.
8309
8310@item -Wtrampolines
8311@opindex Wtrampolines
8312@opindex Wno-trampolines
8313Warn about trampolines generated for pointers to nested functions.
8314A trampoline is a small piece of data or code that is created at run
8315time on the stack when the address of a nested function is taken, and is
8316used to call the nested function indirectly. For some targets, it is
8317made up of data only and thus requires no special treatment. But, for
8318most targets, it is made up of code and thus requires the stack to be
8319made executable in order for the program to work properly.
8320
8321@item -Wfloat-equal
8322@opindex Wfloat-equal
8323@opindex Wno-float-equal
8324Warn if floating-point values are used in equality comparisons.
8325
8326The idea behind this is that sometimes it is convenient (for the
8327programmer) to consider floating-point values as approximations to
8328infinitely precise real numbers. If you are doing this, then you need
8329to compute (by analyzing the code, or in some other way) the maximum or
8330likely maximum error that the computation introduces, and allow for it
8331when performing comparisons (and when producing output, but that's a
8332different problem). In particular, instead of testing for equality, you
8333should check to see whether the two values have ranges that overlap; and
8334this is done with the relational operators, so equality comparisons are
8335probably mistaken.
8336
8337@item -Wtraditional @r{(C and Objective-C only)}
8338@opindex Wtraditional
8339@opindex Wno-traditional
8340Warn about certain constructs that behave differently in traditional and
8341ISO C@. Also warn about ISO C constructs that have no traditional C
8342equivalent, and/or problematic constructs that should be avoided.
8343
8344@itemize @bullet
8345@item
8346Macro parameters that appear within string literals in the macro body.
8347In traditional C macro replacement takes place within string literals,
8348but in ISO C it does not.
8349
8350@item
8351In traditional C, some preprocessor directives did not exist.
8352Traditional preprocessors only considered a line to be a directive
8353if the @samp{#} appeared in column 1 on the line. Therefore
8354@option{-Wtraditional} warns about directives that traditional C
8355understands but ignores because the @samp{#} does not appear as the
8356first character on the line. It also suggests you hide directives like
8357@code{#pragma} not understood by traditional C by indenting them. Some
8358traditional implementations do not recognize @code{#elif}, so this option
8359suggests avoiding it altogether.
8360
8361@item
8362A function-like macro that appears without arguments.
8363
8364@item
8365The unary plus operator.
8366
8367@item
8368The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
8369constant suffixes. (Traditional C does support the @samp{L} suffix on integer
8370constants.) Note, these suffixes appear in macros defined in the system
8371headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
8372Use of these macros in user code might normally lead to spurious
8373warnings, however GCC's integrated preprocessor has enough context to
8374avoid warning in these cases.
8375
8376@item
8377A function declared external in one block and then used after the end of
8378the block.
8379
8380@item
8381A @code{switch} statement has an operand of type @code{long}.
8382
8383@item
8384A non-@code{static} function declaration follows a @code{static} one.
8385This construct is not accepted by some traditional C compilers.
8386
8387@item
8388The ISO type of an integer constant has a different width or
8389signedness from its traditional type. This warning is only issued if
8390the base of the constant is ten. I.e.@: hexadecimal or octal values, which
8391typically represent bit patterns, are not warned about.
8392
8393@item
8394Usage of ISO string concatenation is detected.
8395
8396@item
8397Initialization of automatic aggregates.
8398
8399@item
8400Identifier conflicts with labels. Traditional C lacks a separate
8401namespace for labels.
8402
8403@item
8404Initialization of unions. If the initializer is zero, the warning is
8405omitted. This is done under the assumption that the zero initializer in
8406user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
8407initializer warnings and relies on default initialization to zero in the
8408traditional C case.
8409
8410@item
8411Conversions by prototypes between fixed/floating-point values and vice
8412versa. The absence of these prototypes when compiling with traditional
8413C causes serious problems. This is a subset of the possible
8414conversion warnings; for the full set use @option{-Wtraditional-conversion}.
8415
8416@item
8417Use of ISO C style function definitions. This warning intentionally is
8418@emph{not} issued for prototype declarations or variadic functions
8419because these ISO C features appear in your code when using
8420libiberty's traditional C compatibility macros, @code{PARAMS} and
8421@code{VPARAMS}. This warning is also bypassed for nested functions
8422because that feature is already a GCC extension and thus not relevant to
8423traditional C compatibility.
8424@end itemize
8425
8426@item -Wtraditional-conversion @r{(C and Objective-C only)}
8427@opindex Wtraditional-conversion
8428@opindex Wno-traditional-conversion
8429Warn if a prototype causes a type conversion that is different from what
8430would happen to the same argument in the absence of a prototype. This
8431includes conversions of fixed point to floating and vice versa, and
8432conversions changing the width or signedness of a fixed-point argument
8433except when the same as the default promotion.
8434
8435@item -Wdeclaration-after-statement @r{(C and Objective-C only)}
8436@opindex Wdeclaration-after-statement
8437@opindex Wno-declaration-after-statement
8438Warn when a declaration is found after a statement in a block. This
8439construct, known from C++, was introduced with ISO C99 and is by default
8440allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
8441
8442@item -Wshadow
8443@opindex Wshadow
8444@opindex Wno-shadow
8445Warn whenever a local variable or type declaration shadows another
8446variable, parameter, type, class member (in C++), or instance variable
8447(in Objective-C) or whenever a built-in function is shadowed. Note
8448that in C++, the compiler warns if a local variable shadows an
8449explicit typedef, but not if it shadows a struct/class/enum.
8450If this warning is enabled, it includes also all instances of
8451local shadowing. This means that @option{-Wno-shadow=local}
8452and @option{-Wno-shadow=compatible-local} are ignored when
8453@option{-Wshadow} is used.
8454Same as @option{-Wshadow=global}.
8455
8456@item -Wno-shadow-ivar @r{(Objective-C only)}
8457@opindex Wno-shadow-ivar
8458@opindex Wshadow-ivar
8459Do not warn whenever a local variable shadows an instance variable in an
8460Objective-C method.
8461
8462@item -Wshadow=global
8463@opindex Wshadow=global
8464Warn for any shadowing.
8465Same as @option{-Wshadow}.
8466
8467@item -Wshadow=local
8468@opindex Wshadow=local
8469Warn when a local variable shadows another local variable or parameter.
8470
8471@item -Wshadow=compatible-local
8472@opindex Wshadow=compatible-local
8473Warn when a local variable shadows another local variable or parameter
8474whose type is compatible with that of the shadowing variable. In C++,
8475type compatibility here means the type of the shadowing variable can be
8476converted to that of the shadowed variable. The creation of this flag
8477(in addition to @option{-Wshadow=local}) is based on the idea that when
8478a local variable shadows another one of incompatible type, it is most
8479likely intentional, not a bug or typo, as shown in the following example:
8480
8481@smallexample
8482@group
8483for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
8484@{
8485 for (int i = 0; i < N; ++i)
8486 @{
8487 ...
8488 @}
8489 ...
8490@}
8491@end group
8492@end smallexample
8493
8494Since the two variable @code{i} in the example above have incompatible types,
8495enabling only @option{-Wshadow=compatible-local} does not emit a warning.
8496Because their types are incompatible, if a programmer accidentally uses one
8497in place of the other, type checking is expected to catch that and emit an
8498error or warning. Use of this flag instead of @option{-Wshadow=local} can
8499possibly reduce the number of warnings triggered by intentional shadowing.
8500Note that this also means that shadowing @code{const char *i} by
8501@code{char *i} does not emit a warning.
8502
8503This warning is also enabled by @option{-Wshadow=local}.
8504
8505@item -Wlarger-than=@var{byte-size}
8506@opindex Wlarger-than=
8507@opindex Wlarger-than-@var{byte-size}
8508Warn whenever an object is defined whose size exceeds @var{byte-size}.
8509@option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8510Warnings controlled by the option can be disabled either by specifying
8511@var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
8512
8513Also warn for calls to bounded functions such as @code{memchr} or
8514@code{strnlen} that specify a bound greater than the largest possible
8515object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
8516can only be disabled by @option{-Wno-larger-than}.
8517
8518@item -Wno-larger-than
8519@opindex Wno-larger-than
8520Disable @option{-Wlarger-than=} warnings. The option is equivalent
8521to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
8522
8523@item -Wframe-larger-than=@var{byte-size}
8524@opindex Wframe-larger-than=
8525@opindex Wno-frame-larger-than
8526Warn if the size of a function frame exceeds @var{byte-size}.
8527The computation done to determine the stack frame size is approximate
8528and not conservative.
8529The actual requirements may be somewhat greater than @var{byte-size}
8530even if you do not get a warning. In addition, any space allocated
8531via @code{alloca}, variable-length arrays, or related constructs
8532is not included by the compiler when determining
8533whether or not to issue a warning.
8534@option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8535Warnings controlled by the option can be disabled either by specifying
8536@var{byte-size} of @samp{SIZE_MAX} or more or by
8537@option{-Wno-frame-larger-than}.
8538
8539@item -Wno-frame-larger-than
8540@opindex Wno-frame-larger-than
8541Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
8542to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
8543
8544@item -Wfree-nonheap-object
8545@opindex Wfree-nonheap-object
8546@opindex Wno-free-nonheap-object
8547Warn when attempting to deallocate an object that was either not allocated
8548on the heap, or by using a pointer that was not returned from a prior call
8549to the corresponding allocation function. For example, because the call
8550to @code{stpcpy} returns a pointer to the terminating nul character and
8551not to the beginning of the object, the call to @code{free} below is
8552diagnosed.
8553
8554@smallexample
8555void f (char *p)
8556@{
8557 p = stpcpy (p, "abc");
8558 // ...
8559 free (p); // warning
8560@}
8561@end smallexample
8562
8563@option{-Wfree-nonheap-object} is included in @option{-Wall}.
8564
8565@item -Wstack-usage=@var{byte-size}
8566@opindex Wstack-usage
8567@opindex Wno-stack-usage
8568Warn if the stack usage of a function might exceed @var{byte-size}.
8569The computation done to determine the stack usage is conservative.
8570Any space allocated via @code{alloca}, variable-length arrays, or related
8571constructs is included by the compiler when determining whether or not to
8572issue a warning.
8573
8574The message is in keeping with the output of @option{-fstack-usage}.
8575
8576@itemize
8577@item
8578If the stack usage is fully static but exceeds the specified amount, it's:
8579
8580@smallexample
8581 warning: stack usage is 1120 bytes
8582@end smallexample
8583@item
8584If the stack usage is (partly) dynamic but bounded, it's:
8585
8586@smallexample
8587 warning: stack usage might be 1648 bytes
8588@end smallexample
8589@item
8590If the stack usage is (partly) dynamic and not bounded, it's:
8591
8592@smallexample
8593 warning: stack usage might be unbounded
8594@end smallexample
8595@end itemize
8596
8597@option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
8598Warnings controlled by the option can be disabled either by specifying
8599@var{byte-size} of @samp{SIZE_MAX} or more or by
8600@option{-Wno-stack-usage}.
8601
8602@item -Wno-stack-usage
8603@opindex Wno-stack-usage
8604Disable @option{-Wstack-usage=} warnings. The option is equivalent
8605to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
8606
8607@item -Wunsafe-loop-optimizations
8608@opindex Wunsafe-loop-optimizations
8609@opindex Wno-unsafe-loop-optimizations
8610Warn if the loop cannot be optimized because the compiler cannot
8611assume anything on the bounds of the loop indices. With
8612@option{-funsafe-loop-optimizations} warn if the compiler makes
8613such assumptions.
8614
8615@item -Wno-pedantic-ms-format @r{(MinGW targets only)}
8616@opindex Wno-pedantic-ms-format
8617@opindex Wpedantic-ms-format
8618When used in combination with @option{-Wformat}
8619and @option{-pedantic} without GNU extensions, this option
8620disables the warnings about non-ISO @code{printf} / @code{scanf} format
8621width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
8622which depend on the MS runtime.
8623
8624@item -Wpointer-arith
8625@opindex Wpointer-arith
8626@opindex Wno-pointer-arith
8627Warn about anything that depends on the ``size of'' a function type or
8628of @code{void}. GNU C assigns these types a size of 1, for
8629convenience in calculations with @code{void *} pointers and pointers
8630to functions. In C++, warn also when an arithmetic operation involves
8631@code{NULL}. This warning is also enabled by @option{-Wpedantic}.
8632
8633@item -Wno-pointer-compare
8634@opindex Wpointer-compare
8635@opindex Wno-pointer-compare
8636Do not warn if a pointer is compared with a zero character constant.
8637This usually
8638means that the pointer was meant to be dereferenced. For example:
8639
8640@smallexample
8641const char *p = foo ();
8642if (p == '\0')
8643 return 42;
8644@end smallexample
8645
8646Note that the code above is invalid in C++11.
8647
8648This warning is enabled by default.
8649
8650@item -Wtsan
8651@opindex Wtsan
8652@opindex Wno-tsan
8653Warn about unsupported features in ThreadSanitizer.
8654
8655ThreadSanitizer does not support @code{std::atomic_thread_fence} and
8656can report false positives.
8657
8658This warning is enabled by default.
8659
8660@item -Wtype-limits
8661@opindex Wtype-limits
8662@opindex Wno-type-limits
8663Warn if a comparison is always true or always false due to the limited
8664range of the data type, but do not warn for constant expressions. For
8665example, warn if an unsigned variable is compared against zero with
8666@code{<} or @code{>=}. This warning is also enabled by
8667@option{-Wextra}.
8668
8669@item -Wabsolute-value @r{(C and Objective-C only)}
8670@opindex Wabsolute-value
8671@opindex Wno-absolute-value
8672Warn for calls to standard functions that compute the absolute value
8673of an argument when a more appropriate standard function is available.
8674For example, calling @code{abs(3.14)} triggers the warning because the
8675appropriate function to call to compute the absolute value of a double
8676argument is @code{fabs}. The option also triggers warnings when the
8677argument in a call to such a function has an unsigned type. This
8678warning can be suppressed with an explicit type cast and it is also
8679enabled by @option{-Wextra}.
8680
8681@include cppwarnopts.texi
8682
8683@item -Wbad-function-cast @r{(C and Objective-C only)}
8684@opindex Wbad-function-cast
8685@opindex Wno-bad-function-cast
8686Warn when a function call is cast to a non-matching type.
8687For example, warn if a call to a function returning an integer type
8688is cast to a pointer type.
8689
8690@item -Wc90-c99-compat @r{(C and Objective-C only)}
8691@opindex Wc90-c99-compat
8692@opindex Wno-c90-c99-compat
8693Warn about features not present in ISO C90, but present in ISO C99.
8694For instance, warn about use of variable length arrays, @code{long long}
8695type, @code{bool} type, compound literals, designated initializers, and so
8696on. This option is independent of the standards mode. Warnings are disabled
8697in the expression that follows @code{__extension__}.
8698
8699@item -Wc99-c11-compat @r{(C and Objective-C only)}
8700@opindex Wc99-c11-compat
8701@opindex Wno-c99-c11-compat
8702Warn about features not present in ISO C99, but present in ISO C11.
8703For instance, warn about use of anonymous structures and unions,
8704@code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
8705@code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
8706and so on. This option is independent of the standards mode. Warnings are
8707disabled in the expression that follows @code{__extension__}.
8708
8709@item -Wc11-c2x-compat @r{(C and Objective-C only)}
8710@opindex Wc11-c2x-compat
8711@opindex Wno-c11-c2x-compat
8712Warn about features not present in ISO C11, but present in ISO C2X.
8713For instance, warn about omitting the string in @code{_Static_assert},
8714use of @samp{[[]]} syntax for attributes, use of decimal
8715floating-point types, and so on. This option is independent of the
8716standards mode. Warnings are disabled in the expression that follows
8717@code{__extension__}.
8718
8719@item -Wc++-compat @r{(C and Objective-C only)}
8720@opindex Wc++-compat
8721@opindex Wno-c++-compat
8722Warn about ISO C constructs that are outside of the common subset of
8723ISO C and ISO C++, e.g.@: request for implicit conversion from
8724@code{void *} to a pointer to non-@code{void} type.
8725
8726@item -Wc++11-compat @r{(C++ and Objective-C++ only)}
8727@opindex Wc++11-compat
8728@opindex Wno-c++11-compat
8729Warn about C++ constructs whose meaning differs between ISO C++ 1998
8730and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
8731in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
8732enabled by @option{-Wall}.
8733
8734@item -Wc++14-compat @r{(C++ and Objective-C++ only)}
8735@opindex Wc++14-compat
8736@opindex Wno-c++14-compat
8737Warn about C++ constructs whose meaning differs between ISO C++ 2011
8738and ISO C++ 2014. This warning is enabled by @option{-Wall}.
8739
8740@item -Wc++17-compat @r{(C++ and Objective-C++ only)}
8741@opindex Wc++17-compat
8742@opindex Wno-c++17-compat
8743Warn about C++ constructs whose meaning differs between ISO C++ 2014
8744and ISO C++ 2017. This warning is enabled by @option{-Wall}.
8745
8746@item -Wc++20-compat @r{(C++ and Objective-C++ only)}
8747@opindex Wc++20-compat
8748@opindex Wno-c++20-compat
8749Warn about C++ constructs whose meaning differs between ISO C++ 2017
8750and ISO C++ 2020. This warning is enabled by @option{-Wall}.
8751
8752@item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
8753@opindex Wc++11-extensions
8754@opindex Wno-c++11-extensions
8755Do not warn about C++11 constructs in code being compiled using
8756an older C++ standard. Even without this option, some C++11 constructs
8757will only be diagnosed if @option{-Wpedantic} is used.
8758
8759@item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
8760@opindex Wc++14-extensions
8761@opindex Wno-c++14-extensions
8762Do not warn about C++14 constructs in code being compiled using
8763an older C++ standard. Even without this option, some C++14 constructs
8764will only be diagnosed if @option{-Wpedantic} is used.
8765
8766@item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
8767@opindex Wc++17-extensions
8768@opindex Wno-c++17-extensions
8769Do not warn about C++17 constructs in code being compiled using
8770an older C++ standard. Even without this option, some C++17 constructs
8771will only be diagnosed if @option{-Wpedantic} is used.
8772
8773@item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
8774@opindex Wc++20-extensions
8775@opindex Wno-c++20-extensions
8776Do not warn about C++20 constructs in code being compiled using
8777an older C++ standard. Even without this option, some C++20 constructs
8778will only be diagnosed if @option{-Wpedantic} is used.
8779
8780@item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
8781@opindex Wc++23-extensions
8782@opindex Wno-c++23-extensions
8783Do not warn about C++23 constructs in code being compiled using
8784an older C++ standard. Even without this option, some C++23 constructs
8785will only be diagnosed if @option{-Wpedantic} is used.
8786
8787@item -Wcast-qual
8788@opindex Wcast-qual
8789@opindex Wno-cast-qual
8790Warn whenever a pointer is cast so as to remove a type qualifier from
8791the target type. For example, warn if a @code{const char *} is cast
8792to an ordinary @code{char *}.
8793
8794Also warn when making a cast that introduces a type qualifier in an
8795unsafe way. For example, casting @code{char **} to @code{const char **}
8796is unsafe, as in this example:
8797
8798@smallexample
8799 /* p is char ** value. */
8800 const char **q = (const char **) p;
8801 /* Assignment of readonly string to const char * is OK. */
8802 *q = "string";
8803 /* Now char** pointer points to read-only memory. */
8804 **p = 'b';
8805@end smallexample
8806
8807@item -Wcast-align
8808@opindex Wcast-align
8809@opindex Wno-cast-align
8810Warn whenever a pointer is cast such that the required alignment of the
8811target is increased. For example, warn if a @code{char *} is cast to
8812an @code{int *} on machines where integers can only be accessed at
8813two- or four-byte boundaries.
8814
8815@item -Wcast-align=strict
8816@opindex Wcast-align=strict
8817Warn whenever a pointer is cast such that the required alignment of the
8818target is increased. For example, warn if a @code{char *} is cast to
8819an @code{int *} regardless of the target machine.
8820
8821@item -Wcast-function-type
8822@opindex Wcast-function-type
8823@opindex Wno-cast-function-type
8824Warn when a function pointer is cast to an incompatible function pointer.
8825In a cast involving function types with a variable argument list only
8826the types of initial arguments that are provided are considered.
8827Any parameter of pointer-type matches any other pointer-type. Any benign
8828differences in integral types are ignored, like @code{int} vs.@: @code{long}
8829on ILP32 targets. Likewise type qualifiers are ignored. The function
8830type @code{void (*) (void)} is special and matches everything, which can
8831be used to suppress this warning.
8832In a cast involving pointer to member types this warning warns whenever
8833the type cast is changing the pointer to member type.
8834This warning is enabled by @option{-Wextra}.
8835
8836@item -Wwrite-strings
8837@opindex Wwrite-strings
8838@opindex Wno-write-strings
8839When compiling C, give string constants the type @code{const
8840char[@var{length}]} so that copying the address of one into a
8841non-@code{const} @code{char *} pointer produces a warning. These
8842warnings help you find at compile time code that can try to write
8843into a string constant, but only if you have been very careful about
8844using @code{const} in declarations and prototypes. Otherwise, it is
8845just a nuisance. This is why we did not make @option{-Wall} request
8846these warnings.
8847
8848When compiling C++, warn about the deprecated conversion from string
8849literals to @code{char *}. This warning is enabled by default for C++
8850programs.
8851
8852@item -Wclobbered
8853@opindex Wclobbered
8854@opindex Wno-clobbered
8855Warn for variables that might be changed by @code{longjmp} or
8856@code{vfork}. This warning is also enabled by @option{-Wextra}.
8857
8858@item -Wconversion
8859@opindex Wconversion
8860@opindex Wno-conversion
8861Warn for implicit conversions that may alter a value. This includes
8862conversions between real and integer, like @code{abs (x)} when
8863@code{x} is @code{double}; conversions between signed and unsigned,
8864like @code{unsigned ui = -1}; and conversions to smaller types, like
8865@code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
8866((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
8867changed by the conversion like in @code{abs (2.0)}. Warnings about
8868conversions between signed and unsigned integers can be disabled by
8869using @option{-Wno-sign-conversion}.
8870
8871For C++, also warn for confusing overload resolution for user-defined
8872conversions; and conversions that never use a type conversion
8873operator: conversions to @code{void}, the same type, a base class or a
8874reference to them. Warnings about conversions between signed and
8875unsigned integers are disabled by default in C++ unless
8876@option{-Wsign-conversion} is explicitly enabled.
8877
8878Warnings about conversion from arithmetic on a small type back to that
8879type are only given with @option{-Warith-conversion}.
8880
8881@item -Wdangling-else
8882@opindex Wdangling-else
8883@opindex Wno-dangling-else
8884Warn about constructions where there may be confusion to which
8885@code{if} statement an @code{else} branch belongs. Here is an example of
8886such a case:
8887
8888@smallexample
8889@group
8890@{
8891 if (a)
8892 if (b)
8893 foo ();
8894 else
8895 bar ();
8896@}
8897@end group
8898@end smallexample
8899
8900In C/C++, every @code{else} branch belongs to the innermost possible
8901@code{if} statement, which in this example is @code{if (b)}. This is
8902often not what the programmer expected, as illustrated in the above
8903example by indentation the programmer chose. When there is the
8904potential for this confusion, GCC issues a warning when this flag
8905is specified. To eliminate the warning, add explicit braces around
8906the innermost @code{if} statement so there is no way the @code{else}
8907can belong to the enclosing @code{if}. The resulting code
8908looks like this:
8909
8910@smallexample
8911@group
8912@{
8913 if (a)
8914 @{
8915 if (b)
8916 foo ();
8917 else
8918 bar ();
8919 @}
8920@}
8921@end group
8922@end smallexample
8923
8924This warning is enabled by @option{-Wparentheses}.
8925
8926@item -Wdangling-pointer
8927@itemx -Wdangling-pointer=@var{n}
8928@opindex Wdangling-pointer
8929@opindex Wno-dangling-pointer
8930Warn about uses of pointers (or C++ references) to objects with automatic
8931storage duration after their lifetime has ended. This includes local
8932variables declared in nested blocks, compound literals and other unnamed
8933temporary objects. In addition, warn about storing the address of such
8934objects in escaped pointers. The warning is enabled at all optimization
8935levels but may yield different results with optimization than without.
8936
8937@table @gcctabopt
8938@item -Wdangling-pointer=1
8939At level 1 the warning diagnoses only unconditional uses of dangling pointers.
8940For example
8941@smallexample
8942int f (int c1, int c2, x)
8943@{
8944 char *p = strchr ((char[])@{ c1, c2 @}, c3);
8945 return p ? *p : 'x'; // warning: dangling pointer to a compound literal
8946@}
8947@end smallexample
8948In the following function the store of the address of the local variable
8949@code{x} in the escaped pointer @code{*p} also triggers the warning.
8950@smallexample
8951void g (int **p)
8952@{
8953 int x = 7;
8954 *p = &x; // warning: storing the address of a local variable in *p
8955@}
8956@end smallexample
8957
8958@item -Wdangling-pointer=2
8959At level 2, in addition to unconditional uses the warning also diagnoses
8960conditional uses of dangling pointers.
8961
8962For example, because the array @var{a} in the following function is out of
8963scope when the pointer @var{s} that was set to point is used, the warning
8964triggers at this level.
8965
8966@smallexample
8967void f (char *s)
8968@{
8969 if (!s)
8970 @{
8971 char a[12] = "tmpname";
8972 s = a;
8973 @}
8974 strcat (s, ".tmp"); // warning: dangling pointer to a may be used
8975 ...
8976@}
8977@end smallexample
8978@end table
8979
8980@option{-Wdangling-pointer=2} is included in @option{-Wall}.
8981
8982@item -Wdate-time
8983@opindex Wdate-time
8984@opindex Wno-date-time
8985Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
8986are encountered as they might prevent bit-wise-identical reproducible
8987compilations.
8988
8989@item -Wempty-body
8990@opindex Wempty-body
8991@opindex Wno-empty-body
8992Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
8993while} statement. This warning is also enabled by @option{-Wextra}.
8994
8995@item -Wno-endif-labels
8996@opindex Wendif-labels
8997@opindex Wno-endif-labels
8998Do not warn about stray tokens after @code{#else} and @code{#endif}.
8999
9000@item -Wenum-compare
9001@opindex Wenum-compare
9002@opindex Wno-enum-compare
9003Warn about a comparison between values of different enumerated types.
9004In C++ enumerated type mismatches in conditional expressions are also
9005diagnosed and the warning is enabled by default. In C this warning is
9006enabled by @option{-Wall}.
9007
9008@item -Wenum-conversion
9009@opindex Wenum-conversion
9010@opindex Wno-enum-conversion
9011Warn when a value of enumerated type is implicitly converted to a
9012different enumerated type. This warning is enabled by @option{-Wextra}
9013in C@.
9014
9015@item -Wenum-int-mismatch @r{(C and Objective-C only)}
9016@opindex Wenum-int-mismatch
9017@opindex Wno-enum-int-mismatch
9018Warn about mismatches between an enumerated type and an integer type in
9019declarations. For example:
9020
9021@smallexample
9022enum E @{ l = -1, z = 0, g = 1 @};
9023int foo(void);
9024enum E foo(void);
9025@end smallexample
9026
9027In C, an enumerated type is compatible with @code{char}, a signed
9028integer type, or an unsigned integer type. However, since the choice
9029of the underlying type of an enumerated type is implementation-defined,
9030such mismatches may cause portability issues. In C++, such mismatches
9031are an error. In C, this warning is enabled by @option{-Wall} and
9032@option{-Wc++-compat}.
9033
9034@item -Wjump-misses-init @r{(C, Objective-C only)}
9035@opindex Wjump-misses-init
9036@opindex Wno-jump-misses-init
9037Warn if a @code{goto} statement or a @code{switch} statement jumps
9038forward across the initialization of a variable, or jumps backward to a
9039label after the variable has been initialized. This only warns about
9040variables that are initialized when they are declared. This warning is
9041only supported for C and Objective-C; in C++ this sort of branch is an
9042error in any case.
9043
9044@option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
9045can be disabled with the @option{-Wno-jump-misses-init} option.
9046
9047@item -Wsign-compare
9048@opindex Wsign-compare
9049@opindex Wno-sign-compare
9050@cindex warning for comparison of signed and unsigned values
9051@cindex comparison of signed and unsigned values, warning
9052@cindex signed and unsigned values, comparison warning
9053Warn when a comparison between signed and unsigned values could produce
9054an incorrect result when the signed value is converted to unsigned.
9055In C++, this warning is also enabled by @option{-Wall}. In C, it is
9056also enabled by @option{-Wextra}.
9057
9058@item -Wsign-conversion
9059@opindex Wsign-conversion
9060@opindex Wno-sign-conversion
9061Warn for implicit conversions that may change the sign of an integer
9062value, like assigning a signed integer expression to an unsigned
9063integer variable. An explicit cast silences the warning. In C, this
9064option is enabled also by @option{-Wconversion}.
9065
9066@item -Wfloat-conversion
9067@opindex Wfloat-conversion
9068@opindex Wno-float-conversion
9069Warn for implicit conversions that reduce the precision of a real value.
9070This includes conversions from real to integer, and from higher precision
9071real to lower precision real values. This option is also enabled by
9072@option{-Wconversion}.
9073
9074@item -Wno-scalar-storage-order
9075@opindex Wno-scalar-storage-order
9076@opindex Wscalar-storage-order
9077Do not warn on suspicious constructs involving reverse scalar storage order.
9078
9079@item -Wsizeof-array-div
9080@opindex Wsizeof-array-div
9081@opindex Wno-sizeof-array-div
9082Warn about divisions of two sizeof operators when the first one is applied
9083to an array and the divisor does not equal the size of the array element.
9084In such a case, the computation will not yield the number of elements in the
9085array, which is likely what the user intended. This warning warns e.g. about
9086@smallexample
9087int fn ()
9088@{
9089 int arr[10];
9090 return sizeof (arr) / sizeof (short);
9091@}
9092@end smallexample
9093
9094This warning is enabled by @option{-Wall}.
9095
9096@item -Wsizeof-pointer-div
9097@opindex Wsizeof-pointer-div
9098@opindex Wno-sizeof-pointer-div
9099Warn for suspicious divisions of two sizeof expressions that divide
9100the pointer size by the element size, which is the usual way to compute
9101the array size but won't work out correctly with pointers. This warning
9102warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
9103not an array, but a pointer. This warning is enabled by @option{-Wall}.
9104
9105@item -Wsizeof-pointer-memaccess
9106@opindex Wsizeof-pointer-memaccess
9107@opindex Wno-sizeof-pointer-memaccess
9108Warn for suspicious length parameters to certain string and memory built-in
9109functions if the argument uses @code{sizeof}. This warning triggers for
9110example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
9111an array, but a pointer, and suggests a possible fix, or about
9112@code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
9113also warns about calls to bounded string copy functions like @code{strncat}
9114or @code{strncpy} that specify as the bound a @code{sizeof} expression of
9115the source array. For example, in the following function the call to
9116@code{strncat} specifies the size of the source string as the bound. That
9117is almost certainly a mistake and so the call is diagnosed.
9118@smallexample
9119void make_file (const char *name)
9120@{
9121 char path[PATH_MAX];
9122 strncpy (path, name, sizeof path - 1);
9123 strncat (path, ".text", sizeof ".text");
9124 @dots{}
9125@}
9126@end smallexample
9127
9128The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
9129
9130@item -Wno-sizeof-array-argument
9131@opindex Wsizeof-array-argument
9132@opindex Wno-sizeof-array-argument
9133Do not warn when the @code{sizeof} operator is applied to a parameter that is
9134declared as an array in a function definition. This warning is enabled by
9135default for C and C++ programs.
9136
9137@item -Wmemset-elt-size
9138@opindex Wmemset-elt-size
9139@opindex Wno-memset-elt-size
9140Warn for suspicious calls to the @code{memset} built-in function, if the
9141first argument references an array, and the third argument is a number
9142equal to the number of elements, but not equal to the size of the array
9143in memory. This indicates that the user has omitted a multiplication by
9144the element size. This warning is enabled by @option{-Wall}.
9145
9146@item -Wmemset-transposed-args
9147@opindex Wmemset-transposed-args
9148@opindex Wno-memset-transposed-args
9149Warn for suspicious calls to the @code{memset} built-in function where
9150the second argument is not zero and the third argument is zero. For
9151example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
9152@code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
9153is only emitted if the third argument is a literal zero. Otherwise, if
9154it is an expression that is folded to zero, or a cast of zero to some
9155type, it is far less likely that the arguments have been mistakenly
9156transposed and no warning is emitted. This warning is enabled
9157by @option{-Wall}.
9158
9159@item -Waddress
9160@opindex Waddress
9161@opindex Wno-address
9162Warn about suspicious uses of address expressions. These include comparing
9163the address of a function or a declared object to the null pointer constant
9164such as in
9165@smallexample
9166void f (void);
9167void g (void)
9168@{
9169 if (!f) // warning: expression evaluates to false
9170 abort ();
9171@}
9172@end smallexample
9173comparisons of a pointer to a string literal, such as in
9174@smallexample
9175void f (const char *x)
9176@{
9177 if (x == "abc") // warning: expression evaluates to false
9178 puts ("equal");
9179@}
9180@end smallexample
9181and tests of the results of pointer addition or subtraction for equality
9182to null, such as in
9183@smallexample
9184void f (const int *p, int i)
9185@{
9186 return p + i == NULL;
9187@}
9188@end smallexample
9189Such uses typically indicate a programmer error: the address of most
9190functions and objects necessarily evaluates to true (the exception are
9191weak symbols), so their use in a conditional might indicate missing
9192parentheses in a function call or a missing dereference in an array
9193expression. The subset of the warning for object pointers can be
9194suppressed by casting the pointer operand to an integer type such
9195as @code{intptr_t} or @code{uintptr_t}.
9196Comparisons against string literals result in unspecified behavior
9197and are not portable, and suggest the intent was to call @code{strcmp}.
9198The warning is suppressed if the suspicious expression is the result
9199of macro expansion.
9200@option{-Waddress} warning is enabled by @option{-Wall}.
9201
9202@item -Wno-address-of-packed-member
9203@opindex Waddress-of-packed-member
9204@opindex Wno-address-of-packed-member
9205Do not warn when the address of packed member of struct or union is taken,
9206which usually results in an unaligned pointer value. This is
9207enabled by default.
9208
9209@item -Wlogical-op
9210@opindex Wlogical-op
9211@opindex Wno-logical-op
9212Warn about suspicious uses of logical operators in expressions.
9213This includes using logical operators in contexts where a
9214bit-wise operator is likely to be expected. Also warns when
9215the operands of a logical operator are the same:
9216@smallexample
9217extern int a;
9218if (a < 0 && a < 0) @{ @dots{} @}
9219@end smallexample
9220
9221@item -Wlogical-not-parentheses
9222@opindex Wlogical-not-parentheses
9223@opindex Wno-logical-not-parentheses
9224Warn about logical not used on the left hand side operand of a comparison.
9225This option does not warn if the right operand is considered to be a boolean
9226expression. Its purpose is to detect suspicious code like the following:
9227@smallexample
9228int a;
9229@dots{}
9230if (!a > 1) @{ @dots{} @}
9231@end smallexample
9232
9233It is possible to suppress the warning by wrapping the LHS into
9234parentheses:
9235@smallexample
9236if ((!a) > 1) @{ @dots{} @}
9237@end smallexample
9238
9239This warning is enabled by @option{-Wall}.
9240
9241@item -Waggregate-return
9242@opindex Waggregate-return
9243@opindex Wno-aggregate-return
9244Warn if any functions that return structures or unions are defined or
9245called. (In languages where you can return an array, this also elicits
9246a warning.)
9247
9248@item -Wno-aggressive-loop-optimizations
9249@opindex Wno-aggressive-loop-optimizations
9250@opindex Waggressive-loop-optimizations
9251Warn if in a loop with constant number of iterations the compiler detects
9252undefined behavior in some statement during one or more of the iterations.
9253
9254@item -Wno-attributes
9255@opindex Wno-attributes
9256@opindex Wattributes
9257Do not warn if an unexpected @code{__attribute__} is used, such as
9258unrecognized attributes, function attributes applied to variables,
9259etc. This does not stop errors for incorrect use of supported
9260attributes.
9261
9262Additionally, using @option{-Wno-attributes=}, it is possible to suppress
9263warnings about unknown scoped attributes (in C++11 and C2X). For example,
9264@option{-Wno-attributes=vendor::attr} disables warning about the following
9265declaration:
9266
9267@smallexample
9268[[vendor::attr]] void f();
9269@end smallexample
9270
9271It is also possible to disable warning about all attributes in a namespace
9272using @option{-Wno-attributes=vendor::} which prevents warning about both
9273of these declarations:
9274
9275@smallexample
9276[[vendor::safe]] void f();
9277[[vendor::unsafe]] void f2();
9278@end smallexample
9279
9280Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
9281
9282@item -Wno-builtin-declaration-mismatch
9283@opindex Wno-builtin-declaration-mismatch
9284@opindex Wbuiltin-declaration-mismatch
9285Warn if a built-in function is declared with an incompatible signature
9286or as a non-function, or when a built-in function declared with a type
9287that does not include a prototype is called with arguments whose promoted
9288types do not match those expected by the function. When @option{-Wextra}
9289is specified, also warn when a built-in function that takes arguments is
9290declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
9291warning is enabled by default. To avoid the warning include the appropriate
9292header to bring the prototypes of built-in functions into scope.
9293
9294For example, the call to @code{memset} below is diagnosed by the warning
9295because the function expects a value of type @code{size_t} as its argument
9296but the type of @code{32} is @code{int}. With @option{-Wextra},
9297the declaration of the function is diagnosed as well.
9298@smallexample
9299extern void* memset ();
9300void f (void *d)
9301@{
9302 memset (d, '\0', 32);
9303@}
9304@end smallexample
9305
9306@item -Wno-builtin-macro-redefined
9307@opindex Wno-builtin-macro-redefined
9308@opindex Wbuiltin-macro-redefined
9309Do not warn if certain built-in macros are redefined. This suppresses
9310warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
9311@code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
9312
9313@item -Wstrict-prototypes @r{(C and Objective-C only)}
9314@opindex Wstrict-prototypes
9315@opindex Wno-strict-prototypes
9316Warn if a function is declared or defined without specifying the
9317argument types. (An old-style function definition is permitted without
9318a warning if preceded by a declaration that specifies the argument
9319types.)
9320
9321@item -Wold-style-declaration @r{(C and Objective-C only)}
9322@opindex Wold-style-declaration
9323@opindex Wno-old-style-declaration
9324Warn for obsolescent usages, according to the C Standard, in a
9325declaration. For example, warn if storage-class specifiers like
9326@code{static} are not the first things in a declaration. This warning
9327is also enabled by @option{-Wextra}.
9328
9329@item -Wold-style-definition @r{(C and Objective-C only)}
9330@opindex Wold-style-definition
9331@opindex Wno-old-style-definition
9332Warn if an old-style function definition is used. A warning is given
9333even if there is a previous prototype. A definition using @samp{()}
9334is not considered an old-style definition in C2X mode, because it is
9335equivalent to @samp{(void)} in that case, but is considered an
9336old-style definition for older standards.
9337
9338@item -Wmissing-parameter-type @r{(C and Objective-C only)}
9339@opindex Wmissing-parameter-type
9340@opindex Wno-missing-parameter-type
9341A function parameter is declared without a type specifier in K&R-style
9342functions:
9343
9344@smallexample
9345void foo(bar) @{ @}
9346@end smallexample
9347
9348This warning is also enabled by @option{-Wextra}.
9349
9350@item -Wmissing-prototypes @r{(C and Objective-C only)}
9351@opindex Wmissing-prototypes
9352@opindex Wno-missing-prototypes
9353Warn if a global function is defined without a previous prototype
9354declaration. This warning is issued even if the definition itself
9355provides a prototype. Use this option to detect global functions
9356that do not have a matching prototype declaration in a header file.
9357This option is not valid for C++ because all function declarations
9358provide prototypes and a non-matching declaration declares an
9359overload rather than conflict with an earlier declaration.
9360Use @option{-Wmissing-declarations} to detect missing declarations in C++.
9361
9362@item -Wmissing-declarations
9363@opindex Wmissing-declarations
9364@opindex Wno-missing-declarations
9365Warn if a global function is defined without a previous declaration.
9366Do so even if the definition itself provides a prototype.
9367Use this option to detect global functions that are not declared in
9368header files. In C, no warnings are issued for functions with previous
9369non-prototype declarations; use @option{-Wmissing-prototypes} to detect
9370missing prototypes. In C++, no warnings are issued for function templates,
9371or for inline functions, or for functions in anonymous namespaces.
9372
9373@item -Wmissing-field-initializers
9374@opindex Wmissing-field-initializers
9375@opindex Wno-missing-field-initializers
9376@opindex W
9377@opindex Wextra
9378@opindex Wno-extra
9379Warn if a structure's initializer has some fields missing. For
9380example, the following code causes such a warning, because
9381@code{x.h} is implicitly zero:
9382
9383@smallexample
9384struct s @{ int f, g, h; @};
9385struct s x = @{ 3, 4 @};
9386@end smallexample
9387
9388This option does not warn about designated initializers, so the following
9389modification does not trigger a warning:
9390
9391@smallexample
9392struct s @{ int f, g, h; @};
9393struct s x = @{ .f = 3, .g = 4 @};
9394@end smallexample
9395
9396In C this option does not warn about the universal zero initializer
9397@samp{@{ 0 @}}:
9398
9399@smallexample
9400struct s @{ int f, g, h; @};
9401struct s x = @{ 0 @};
9402@end smallexample
9403
9404Likewise, in C++ this option does not warn about the empty @{ @}
9405initializer, for example:
9406
9407@smallexample
9408struct s @{ int f, g, h; @};
9409s x = @{ @};
9410@end smallexample
9411
9412This warning is included in @option{-Wextra}. To get other @option{-Wextra}
9413warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
9414
9415@item -Wno-missing-requires
9416@opindex Wmissing-requires
9417@opindex Wno-missing-requires
9418
9419By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
9420
9421@smallexample
9422bool satisfied = requires @{ C<T> @};
9423@end smallexample
9424
9425Here @samp{satisfied} will be true if @samp{C<T>} is a valid
9426expression, which it is for all T. Presumably the user meant to write
9427
9428@smallexample
9429bool satisfied = requires @{ requires C<T> @};
9430@end smallexample
9431
9432so @samp{satisfied} is only true if concept @samp{C} is satisfied for
9433type @samp{T}.
9434
9435This warning can be disabled with @option{-Wno-missing-requires}.
9436
9437@item -Wno-missing-template-keyword
9438@opindex Wmissing-template-keyword
9439@opindex Wno-missing-template-keyword
9440
9441The member access tokens ., -> and :: must be followed by the @code{template}
9442keyword if the parent object is dependent and the member being named is a
9443template.
9444
9445@smallexample
9446template <class X>
9447void DoStuff (X x)
9448@{
9449 x.template DoSomeOtherStuff<X>(); // Good.
9450 x.DoMoreStuff<X>(); // Warning, x is dependent.
9451@}
9452@end smallexample
9453
9454In rare cases it is possible to get false positives. To silence this, wrap
9455the expression in parentheses. For example, the following is treated as a
9456template, even where m and N are integers:
9457
9458@smallexample
9459void NotATemplate (my_class t)
9460@{
9461 int N = 5;
9462
9463 bool test = t.m < N > (0); // Treated as a template.
9464 test = (t.m < N) > (0); // Same meaning, but not treated as a template.
9465@}
9466@end smallexample
9467
9468This warning can be disabled with @option{-Wno-missing-template-keyword}.
9469
9470@item -Wno-multichar
9471@opindex Wno-multichar
9472@opindex Wmultichar
9473Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
9474Usually they indicate a typo in the user's code, as they have
9475implementation-defined values, and should not be used in portable code.
9476
9477@item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
9478@opindex Wnormalized=
9479@opindex Wnormalized
9480@opindex Wno-normalized
9481@cindex NFC
9482@cindex NFKC
9483@cindex character set, input normalization
9484In ISO C and ISO C++, two identifiers are different if they are
9485different sequences of characters. However, sometimes when characters
9486outside the basic ASCII character set are used, you can have two
9487different character sequences that look the same. To avoid confusion,
9488the ISO 10646 standard sets out some @dfn{normalization rules} which
9489when applied ensure that two sequences that look the same are turned into
9490the same sequence. GCC can warn you if you are using identifiers that
9491have not been normalized; this option controls that warning.
9492
9493There are four levels of warning supported by GCC@. The default is
9494@option{-Wnormalized=nfc}, which warns about any identifier that is
9495not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
9496recommended form for most uses. It is equivalent to
9497@option{-Wnormalized}.
9498
9499Unfortunately, there are some characters allowed in identifiers by
9500ISO C and ISO C++ that, when turned into NFC, are not allowed in
9501identifiers. That is, there's no way to use these symbols in portable
9502ISO C or C++ and have all your identifiers in NFC@.
9503@option{-Wnormalized=id} suppresses the warning for these characters.
9504It is hoped that future versions of the standards involved will correct
9505this, which is why this option is not the default.
9506
9507You can switch the warning off for all characters by writing
9508@option{-Wnormalized=none} or @option{-Wno-normalized}. You should
9509only do this if you are using some other normalization scheme (like
9510``D''), because otherwise you can easily create bugs that are
9511literally impossible to see.
9512
9513Some characters in ISO 10646 have distinct meanings but look identical
9514in some fonts or display methodologies, especially once formatting has
9515been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
9516LETTER N'', displays just like a regular @code{n} that has been
9517placed in a superscript. ISO 10646 defines the @dfn{NFKC}
9518normalization scheme to convert all these into a standard form as
9519well, and GCC warns if your code is not in NFKC if you use
9520@option{-Wnormalized=nfkc}. This warning is comparable to warning
9521about every identifier that contains the letter O because it might be
9522confused with the digit 0, and so is not the default, but may be
9523useful as a local coding convention if the programming environment
9524cannot be fixed to display these characters distinctly.
9525
9526@item -Wno-attribute-warning
9527@opindex Wno-attribute-warning
9528@opindex Wattribute-warning
9529Do not warn about usage of functions (@pxref{Function Attributes})
9530declared with @code{warning} attribute. By default, this warning is
9531enabled. @option{-Wno-attribute-warning} can be used to disable the
9532warning or @option{-Wno-error=attribute-warning} can be used to
9533disable the error when compiled with @option{-Werror} flag.
9534
9535@item -Wno-deprecated
9536@opindex Wno-deprecated
9537@opindex Wdeprecated
9538Do not warn about usage of deprecated features. @xref{Deprecated Features}.
9539
9540@item -Wno-deprecated-declarations
9541@opindex Wno-deprecated-declarations
9542@opindex Wdeprecated-declarations
9543Do not warn about uses of functions (@pxref{Function Attributes}),
9544variables (@pxref{Variable Attributes}), and types (@pxref{Type
9545Attributes}) marked as deprecated by using the @code{deprecated}
9546attribute.
9547
9548@item -Wno-overflow
9549@opindex Wno-overflow
9550@opindex Woverflow
9551Do not warn about compile-time overflow in constant expressions.
9552
9553@item -Wno-odr
9554@opindex Wno-odr
9555@opindex Wodr
9556Warn about One Definition Rule violations during link-time optimization.
9557Enabled by default.
9558
9559@item -Wopenacc-parallelism
9560@opindex Wopenacc-parallelism
9561@opindex Wno-openacc-parallelism
9562@cindex OpenACC accelerator programming
9563Warn about potentially suboptimal choices related to OpenACC parallelism.
9564
9565@item -Wopenmp-simd
9566@opindex Wopenmp-simd
9567@opindex Wno-openmp-simd
9568Warn if the vectorizer cost model overrides the OpenMP
9569simd directive set by user. The @option{-fsimd-cost-model=unlimited}
9570option can be used to relax the cost model.
9571
9572@item -Woverride-init @r{(C and Objective-C only)}
9573@opindex Woverride-init
9574@opindex Wno-override-init
9575@opindex W
9576@opindex Wextra
9577@opindex Wno-extra
9578Warn if an initialized field without side effects is overridden when
9579using designated initializers (@pxref{Designated Inits, , Designated
9580Initializers}).
9581
9582This warning is included in @option{-Wextra}. To get other
9583@option{-Wextra} warnings without this one, use @option{-Wextra
9584-Wno-override-init}.
9585
9586@item -Wno-override-init-side-effects @r{(C and Objective-C only)}
9587@opindex Woverride-init-side-effects
9588@opindex Wno-override-init-side-effects
9589Do not warn if an initialized field with side effects is overridden when
9590using designated initializers (@pxref{Designated Inits, , Designated
9591Initializers}). This warning is enabled by default.
9592
9593@item -Wpacked
9594@opindex Wpacked
9595@opindex Wno-packed
9596Warn if a structure is given the packed attribute, but the packed
9597attribute has no effect on the layout or size of the structure.
9598Such structures may be mis-aligned for little benefit. For
9599instance, in this code, the variable @code{f.x} in @code{struct bar}
9600is misaligned even though @code{struct bar} does not itself
9601have the packed attribute:
9602
9603@smallexample
9604@group
9605struct foo @{
9606 int x;
9607 char a, b, c, d;
9608@} __attribute__((packed));
9609struct bar @{
9610 char z;
9611 struct foo f;
9612@};
9613@end group
9614@end smallexample
9615
9616@item -Wnopacked-bitfield-compat
9617@opindex Wpacked-bitfield-compat
9618@opindex Wno-packed-bitfield-compat
9619The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
9620on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
9621the change can lead to differences in the structure layout. GCC
9622informs you when the offset of such a field has changed in GCC 4.4.
9623For example there is no longer a 4-bit padding between field @code{a}
9624and @code{b} in this structure:
9625
9626@smallexample
9627struct foo
9628@{
9629 char a:4;
9630 char b:8;
9631@} __attribute__ ((packed));
9632@end smallexample
9633
9634This warning is enabled by default. Use
9635@option{-Wno-packed-bitfield-compat} to disable this warning.
9636
9637@item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
9638@opindex Wpacked-not-aligned
9639@opindex Wno-packed-not-aligned
9640Warn if a structure field with explicitly specified alignment in a
9641packed struct or union is misaligned. For example, a warning will
9642be issued on @code{struct S}, like, @code{warning: alignment 1 of
9643'struct S' is less than 8}, in this code:
9644
9645@smallexample
9646@group
9647struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
9648struct __attribute__ ((packed)) S @{
9649 struct S8 s8;
9650@};
9651@end group
9652@end smallexample
9653
9654This warning is enabled by @option{-Wall}.
9655
9656@item -Wpadded
9657@opindex Wpadded
9658@opindex Wno-padded
9659Warn if padding is included in a structure, either to align an element
9660of the structure or to align the whole structure. Sometimes when this
9661happens it is possible to rearrange the fields of the structure to
9662reduce the padding and so make the structure smaller.
9663
9664@item -Wredundant-decls
9665@opindex Wredundant-decls
9666@opindex Wno-redundant-decls
9667Warn if anything is declared more than once in the same scope, even in
9668cases where multiple declaration is valid and changes nothing.
9669
9670@item -Wrestrict
9671@opindex Wrestrict
9672@opindex Wno-restrict
9673Warn when an object referenced by a @code{restrict}-qualified parameter
9674(or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
9675argument, or when copies between such objects overlap. For example,
9676the call to the @code{strcpy} function below attempts to truncate the string
9677by replacing its initial characters with the last four. However, because
9678the call writes the terminating NUL into @code{a[4]}, the copies overlap and
9679the call is diagnosed.
9680
9681@smallexample
9682void foo (void)
9683@{
9684 char a[] = "abcd1234";
9685 strcpy (a, a + 4);
9686 @dots{}
9687@}
9688@end smallexample
9689The @option{-Wrestrict} option detects some instances of simple overlap
9690even without optimization but works best at @option{-O2} and above. It
9691is included in @option{-Wall}.
9692
9693@item -Wnested-externs @r{(C and Objective-C only)}
9694@opindex Wnested-externs
9695@opindex Wno-nested-externs
9696Warn if an @code{extern} declaration is encountered within a function.
9697
9698@item -Winline
9699@opindex Winline
9700@opindex Wno-inline
9701Warn if a function that is declared as inline cannot be inlined.
9702Even with this option, the compiler does not warn about failures to
9703inline functions declared in system headers.
9704
9705The compiler uses a variety of heuristics to determine whether or not
9706to inline a function. For example, the compiler takes into account
9707the size of the function being inlined and the amount of inlining
9708that has already been done in the current function. Therefore,
9709seemingly insignificant changes in the source program can cause the
9710warnings produced by @option{-Winline} to appear or disappear.
9711
9712@item -Winterference-size
9713@opindex Winterference-size
9714Warn about use of C++17 @code{std::hardware_destructive_interference_size}
9715without specifying its value with @option{--param destructive-interference-size}.
9716Also warn about questionable values for that option.
9717
9718This variable is intended to be used for controlling class layout, to
9719avoid false sharing in concurrent code:
9720
9721@smallexample
9722struct independent_fields @{
9723 alignas(std::hardware_destructive_interference_size) std::atomic<int> one;
9724 alignas(std::hardware_destructive_interference_size) std::atomic<int> two;
9725@};
9726@end smallexample
9727
9728Here @samp{one} and @samp{two} are intended to be far enough apart
9729that stores to one won't require accesses to the other to reload the
9730cache line.
9731
9732By default, @option{--param destructive-interference-size} and
9733@option{--param constructive-interference-size} are set based on the
9734current @option{-mtune} option, typically to the L1 cache line size
9735for the particular target CPU, sometimes to a range if tuning for a
9736generic target. So all translation units that depend on ABI
9737compatibility for the use of these variables must be compiled with
9738the same @option{-mtune} (or @option{-mcpu}).
9739
9740If ABI stability is important, such as if the use is in a header for a
9741library, you should probably not use the hardware interference size
9742variables at all. Alternatively, you can force a particular value
9743with @option{--param}.
9744
9745If you are confident that your use of the variable does not affect ABI
9746outside a single build of your project, you can turn off the warning
9747with @option{-Wno-interference-size}.
9748
9749@item -Wint-in-bool-context
9750@opindex Wint-in-bool-context
9751@opindex Wno-int-in-bool-context
9752Warn for suspicious use of integer values where boolean values are expected,
9753such as conditional expressions (?:) using non-boolean integer constants in
9754boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
9755integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
9756for all kinds of multiplications regardless of the data type.
9757This warning is enabled by @option{-Wall}.
9758
9759@item -Wno-int-to-pointer-cast
9760@opindex Wno-int-to-pointer-cast
9761@opindex Wint-to-pointer-cast
9762Suppress warnings from casts to pointer type of an integer of a
9763different size. In C++, casting to a pointer type of smaller size is
9764an error. @option{Wint-to-pointer-cast} is enabled by default.
9765
9766
9767@item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
9768@opindex Wno-pointer-to-int-cast
9769@opindex Wpointer-to-int-cast
9770Suppress warnings from casts from a pointer to an integer type of a
9771different size.
9772
9773@item -Winvalid-pch
9774@opindex Winvalid-pch
9775@opindex Wno-invalid-pch
9776Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
9777the search path but cannot be used.
9778
9779@item -Winvalid-utf8
9780@opindex Winvalid-utf8
9781@opindex Wno-invalid-utf8
9782Warn if an invalid UTF-8 character is found.
9783This warning is on by default for C++23 if @option{-finput-charset=UTF-8}
9784is used and turned into error with @option{-pedantic-errors}.
9785
9786@item -Wno-unicode
9787@opindex Wunicode
9788@opindex Wno-unicode
9789Don't diagnose invalid forms of delimited or named escape sequences which are
9790treated as separate tokens. @option{Wunicode} is enabled by default.
9791
9792@item -Wlong-long
9793@opindex Wlong-long
9794@opindex Wno-long-long
9795Warn if @code{long long} type is used. This is enabled by either
9796@option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
9797modes. To inhibit the warning messages, use @option{-Wno-long-long}.
9798
9799@item -Wvariadic-macros
9800@opindex Wvariadic-macros
9801@opindex Wno-variadic-macros
9802Warn if variadic macros are used in ISO C90 mode, or if the GNU
9803alternate syntax is used in ISO C99 mode. This is enabled by either
9804@option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
9805messages, use @option{-Wno-variadic-macros}.
9806
9807@item -Wno-varargs
9808@opindex Wvarargs
9809@opindex Wno-varargs
9810Do not warn upon questionable usage of the macros used to handle variable
9811arguments like @code{va_start}. These warnings are enabled by default.
9812
9813@item -Wvector-operation-performance
9814@opindex Wvector-operation-performance
9815@opindex Wno-vector-operation-performance
9816Warn if vector operation is not implemented via SIMD capabilities of the
9817architecture. Mainly useful for the performance tuning.
9818Vector operation can be implemented @code{piecewise}, which means that the
9819scalar operation is performed on every vector element;
9820@code{in parallel}, which means that the vector operation is implemented
9821using scalars of wider type, which normally is more performance efficient;
9822and @code{as a single scalar}, which means that vector fits into a
9823scalar type.
9824
9825@item -Wvla
9826@opindex Wvla
9827@opindex Wno-vla
9828Warn if a variable-length array is used in the code.
9829@option{-Wno-vla} prevents the @option{-Wpedantic} warning of
9830the variable-length array.
9831
9832@item -Wvla-larger-than=@var{byte-size}
9833@opindex Wvla-larger-than=
9834@opindex Wno-vla-larger-than
9835If this option is used, the compiler warns for declarations of
9836variable-length arrays whose size is either unbounded, or bounded
9837by an argument that allows the array size to exceed @var{byte-size}
9838bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
9839works, but with variable-length arrays.
9840
9841Note that GCC may optimize small variable-length arrays of a known
9842value into plain arrays, so this warning may not get triggered for
9843such arrays.
9844
9845@option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
9846is typically only effective when @option{-ftree-vrp} is active (default
9847for @option{-O2} and above).
9848
9849See also @option{-Walloca-larger-than=@var{byte-size}}.
9850
9851@item -Wno-vla-larger-than
9852@opindex Wno-vla-larger-than
9853Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
9854to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
9855
9856@item -Wvla-parameter
9857@opindex Wno-vla-parameter
9858Warn about redeclarations of functions involving arguments of Variable
9859Length Array types of inconsistent kinds or forms, and enable the detection
9860of out-of-bounds accesses to such parameters by warnings such as
9861@option{-Warray-bounds}.
9862
9863If the first function declaration uses the VLA form the bound specified
9864in the array is assumed to be the minimum number of elements expected to
9865be provided in calls to the function and the maximum number of elements
9866accessed by it. Failing to provide arguments of sufficient size or
9867accessing more than the maximum number of elements may be diagnosed.
9868
9869For example, the warning triggers for the following redeclarations because
9870the first one allows an array of any size to be passed to @code{f} while
9871the second one specifies that the array argument must have at least @code{n}
9872elements. In addition, calling @code{f} with the associated VLA bound
9873parameter in excess of the actual VLA bound triggers a warning as well.
9874
9875@smallexample
9876void f (int n, int[n]);
9877void f (int, int[]); // warning: argument 2 previously declared as a VLA
9878
9879void g (int n)
9880@{
9881 if (n > 4)
9882 return;
9883 int a[n];
9884 f (sizeof a, a); // warning: access to a by f may be out of bounds
9885 @dots{}
9886@}
9887
9888@end smallexample
9889
9890@option{-Wvla-parameter} is included in @option{-Wall}. The
9891@option{-Warray-parameter} option triggers warnings for similar problems
9892involving ordinary array arguments.
9893
9894@item -Wvolatile-register-var
9895@opindex Wvolatile-register-var
9896@opindex Wno-volatile-register-var
9897Warn if a register variable is declared volatile. The volatile
9898modifier does not inhibit all optimizations that may eliminate reads
9899and/or writes to register variables. This warning is enabled by
9900@option{-Wall}.
9901
9902@item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)}
9903@opindex Wxor-used-as-pow
9904@opindex Wno-xor-used-as-pow
9905Warn about uses of @code{^}, the exclusive or operator, where it appears
9906the user meant exponentiation. Specifically, the warning occurs when the
9907left-hand side is the decimal constant 2 or 10 and the right-hand side
9908is also a decimal constant.
9909
9910In C and C++, @code{^} means exclusive or, whereas in some other languages
9911(e.g. TeX and some versions of BASIC) it means exponentiation.
9912
9913This warning is enabled by default. It can be silenced by converting one
9914of the operands to hexadecimal.
9915
9916@item -Wdisabled-optimization
9917@opindex Wdisabled-optimization
9918@opindex Wno-disabled-optimization
9919Warn if a requested optimization pass is disabled. This warning does
9920not generally indicate that there is anything wrong with your code; it
9921merely indicates that GCC's optimizers are unable to handle the code
9922effectively. Often, the problem is that your code is too big or too
9923complex; GCC refuses to optimize programs when the optimization
9924itself is likely to take inordinate amounts of time.
9925
9926@item -Wpointer-sign @r{(C and Objective-C only)}
9927@opindex Wpointer-sign
9928@opindex Wno-pointer-sign
9929Warn for pointer argument passing or assignment with different signedness.
9930This option is only supported for C and Objective-C@. It is implied by
9931@option{-Wall} and by @option{-Wpedantic}, which can be disabled with
9932@option{-Wno-pointer-sign}.
9933
9934@item -Wstack-protector
9935@opindex Wstack-protector
9936@opindex Wno-stack-protector
9937This option is only active when @option{-fstack-protector} is active. It
9938warns about functions that are not protected against stack smashing.
9939
9940@item -Woverlength-strings
9941@opindex Woverlength-strings
9942@opindex Wno-overlength-strings
9943Warn about string constants that are longer than the ``minimum
9944maximum'' length specified in the C standard. Modern compilers
9945generally allow string constants that are much longer than the
9946standard's minimum limit, but very portable programs should avoid
9947using longer strings.
9948
9949The limit applies @emph{after} string constant concatenation, and does
9950not count the trailing NUL@. In C90, the limit was 509 characters; in
9951C99, it was raised to 4095. C++98 does not specify a normative
9952minimum maximum, so we do not diagnose overlength strings in C++@.
9953
9954This option is implied by @option{-Wpedantic}, and can be disabled with
9955@option{-Wno-overlength-strings}.
9956
9957@item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
9958@opindex Wunsuffixed-float-constants
9959@opindex Wno-unsuffixed-float-constants
9960
9961Issue a warning for any floating constant that does not have
9962a suffix. When used together with @option{-Wsystem-headers} it
9963warns about such constants in system header files. This can be useful
9964when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
9965from the decimal floating-point extension to C99.
9966
9967@item -Wno-lto-type-mismatch
9968@opindex Wlto-type-mismatch
9969@opindex Wno-lto-type-mismatch
9970
9971During the link-time optimization, do not warn about type mismatches in
9972global declarations from different compilation units.
9973Requires @option{-flto} to be enabled. Enabled by default.
9974
9975@item -Wno-designated-init @r{(C and Objective-C only)}
9976@opindex Wdesignated-init
9977@opindex Wno-designated-init
9978Suppress warnings when a positional initializer is used to initialize
9979a structure that has been marked with the @code{designated_init}
9980attribute.
9981
9982@end table
9983
9984@node Static Analyzer Options
9985@section Options That Control Static Analysis
9986
9987@table @gcctabopt
9988@item -fanalyzer
9989@opindex analyzer
9990@opindex fanalyzer
9991@opindex fno-analyzer
9992This option enables an static analysis of program flow which looks
9993for ``interesting'' interprocedural paths through the
9994code, and issues warnings for problems found on them.
9995
9996This analysis is much more expensive than other GCC warnings.
9997
9998Enabling this option effectively enables the following warnings:
9999
10000@gccoptlist{ @gol
10001-Wanalyzer-allocation-size @gol
ce51e843 10002-Wanalyzer-deref-before-check @gol
d77de738
ML
10003-Wanalyzer-double-fclose @gol
10004-Wanalyzer-double-free @gol
10005-Wanalyzer-exposure-through-output-file @gol
10006-Wanalyzer-exposure-through-uninit-copy @gol
10007-Wanalyzer-fd-access-mode-mismatch @gol
10008-Wanalyzer-fd-double-close @gol
10009-Wanalyzer-fd-leak @gol
86a90006
DM
10010-Wanalyzer-fd-phase-mismatch @gol
10011-Wanalyzer-fd-type-mismatch @gol
d77de738
ML
10012-Wanalyzer-fd-use-after-close @gol
10013-Wanalyzer-fd-use-without-check @gol
10014-Wanalyzer-file-leak @gol
10015-Wanalyzer-free-of-non-heap @gol
10016-Wanalyzer-imprecise-fp-arithmetic @gol
ce51e843 10017-Wanalyzer-infinite-recursion @gol
d77de738
ML
10018-Wanalyzer-jump-through-null @gol
10019-Wanalyzer-malloc-leak @gol
10020-Wanalyzer-mismatching-deallocation @gol
10021-Wanalyzer-null-argument @gol
10022-Wanalyzer-null-dereference @gol
10023-Wanalyzer-out-of-bounds @gol
10024-Wanalyzer-possible-null-argument @gol
10025-Wanalyzer-possible-null-dereference @gol
10026-Wanalyzer-putenv-of-auto-var @gol
10027-Wanalyzer-shift-count-negative @gol
10028-Wanalyzer-shift-count-overflow @gol
10029-Wanalyzer-stale-setjmp-buffer @gol
10030-Wanalyzer-unsafe-call-within-signal-handler @gol
10031-Wanalyzer-use-after-free @gol
10032-Wanalyzer-use-of-pointer-in-stale-stack-frame @gol
10033-Wanalyzer-use-of-uninitialized-value @gol
10034-Wanalyzer-va-arg-type-mismatch @gol
10035-Wanalyzer-va-list-exhausted @gol
10036-Wanalyzer-va-list-leak @gol
10037-Wanalyzer-va-list-use-after-va-end @gol
10038-Wanalyzer-write-to-const @gol
10039-Wanalyzer-write-to-string-literal @gol
10040}
10041@ignore
10042-Wanalyzer-tainted-allocation-size @gol
10043-Wanalyzer-tainted-array-index @gol
10044-Wanalyzer-tainted-divisor @gol
10045-Wanalyzer-tainted-offset @gol
10046-Wanalyzer-tainted-size @gol
10047@end ignore
10048
10049This option is only available if GCC was configured with analyzer
10050support enabled.
10051
10052@item -Wanalyzer-too-complex
10053@opindex Wanalyzer-too-complex
10054@opindex Wno-analyzer-too-complex
10055If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
10056to attempt to explore the control flow and data flow in the program,
10057but these can be defeated by sufficiently complicated code.
10058
10059By default, the analysis silently stops if the code is too
10060complicated for the analyzer to fully explore and it reaches an internal
10061limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
10062
10063@item -Wno-analyzer-allocation-size
10064@opindex Wanalyzer-allocation-size
10065@opindex Wno-analyzer-allocation-size
10066This warning requires @option{-fanalyzer}, which enables it; use
10067@option{-Wno-analyzer-allocation-size}
10068to disable it.
10069
10070This diagnostic warns for paths through the code in which a pointer to
10071a buffer is assigned to point at a buffer with a size that is not a
10072multiple of @code{sizeof (*pointer)}.
10073
10074See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}.
10075
ce51e843
ML
10076@item -Wno-analyzer-deref-before-check
10077@opindex Wanalyzer-deref-before-check
10078@opindex Wno-analyzer-deref-before-check
10079This warning requires @option{-fanalyzer}, which enables it; use
10080@option{-Wno-analyzer-deref-before-check}
10081to disable it.
10082
10083This diagnostic warns for paths through the code in which a pointer
10084is checked for @code{NULL} *after* it has already been
10085dereferenced, suggesting that the pointer could have been NULL.
10086Such cases suggest that the check for NULL is either redundant,
10087or that it needs to be moved to before the pointer is dereferenced.
10088
10089This diagnostic also considers values passed to a function argument
10090marked with @code{__attribute__((nonnull))} as requiring a non-NULL
10091value, and thus will complain if such values are checked for @code{NULL}
10092after returning from such a function call.
10093
10094This diagnostic is unlikely to be reported when any level of optimization
10095is enabled, as GCC's optimization logic will typically consider such
10096checks for NULL as being redundant, and optimize them away before the
10097analyzer "sees" them. Hence optimization should be disabled when
10098attempting to trigger this diagnostic.
10099
d77de738
ML
10100@item -Wno-analyzer-double-fclose
10101@opindex Wanalyzer-double-fclose
10102@opindex Wno-analyzer-double-fclose
10103This warning requires @option{-fanalyzer}, which enables it; use
10104@option{-Wno-analyzer-double-fclose} to disable it.
10105
10106This diagnostic warns for paths through the code in which a @code{FILE *}
10107can have @code{fclose} called on it more than once.
10108
10109See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10110
10111@item -Wno-analyzer-double-free
10112@opindex Wanalyzer-double-free
10113@opindex Wno-analyzer-double-free
10114This warning requires @option{-fanalyzer}, which enables it; use
10115@option{-Wno-analyzer-double-free} to disable it.
10116
10117This diagnostic warns for paths through the code in which a pointer
10118can have a deallocator called on it more than once, either @code{free},
10119or a deallocator referenced by attribute @code{malloc}.
10120
10121See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}.
10122
10123@item -Wno-analyzer-exposure-through-output-file
10124@opindex Wanalyzer-exposure-through-output-file
10125@opindex Wno-analyzer-exposure-through-output-file
10126This warning requires @option{-fanalyzer}, which enables it; use
10127@option{-Wno-analyzer-exposure-through-output-file}
10128to disable it.
10129
10130This diagnostic warns for paths through the code in which a
10131security-sensitive value is written to an output file
10132(such as writing a password to a log file).
10133
10134See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}.
10135
10136@item -Wanalyzer-exposure-through-uninit-copy
10137@opindex Wanalyzer-exposure-through-uninit-copy
10138@opindex Wno-analyzer-exposure-through-uninit-copy
10139This warning requires both @option{-fanalyzer} and the use of a plugin
10140to specify a function that copies across a ``trust boundary''. Use
10141@option{-Wno-analyzer-exposure-through-uninit-copy} to disable it.
10142
10143This diagnostic warns for ``infoleaks'' - paths through the code in which
10144uninitialized values are copied across a security boundary
10145(such as code within an OS kernel that copies a partially-initialized
10146struct on the stack to user space).
10147
10148See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}.
10149
10150@item -Wno-analyzer-fd-access-mode-mismatch
10151@opindex Wanalyzer-fd-access-mode-mismatch
10152@opindex Wno-analyzer-fd-access-mode-mismatch
10153This warning requires @option{-fanalyzer}, which enables it; use
10154@option{-Wno-analyzer-fd-access-mode-mismatch}
10155to disable it.
10156
10157This diagnostic warns for paths through code in which a
10158@code{read} on a write-only file descriptor is attempted, or vice versa.
10159
10160This diagnostic also warns for code paths in a which a function with attribute
10161@code{fd_arg_read (N)} is called with a file descriptor opened with
10162@code{O_WRONLY} at referenced argument @code{N} or a function with attribute
10163@code{fd_arg_write (N)} is called with a file descriptor opened with
10164@code{O_RDONLY} at referenced argument @var{N}.
10165
10166@item -Wno-analyzer-fd-double-close
10167@opindex Wanalyzer-fd-double-close
10168@opindex Wno-analyzer-fd-double-close
10169This warning requires @option{-fanalyzer}, which enables it; use
10170@option{-Wno-analyzer-fd-double-close}
10171to disable it.
10172
10173This diagnostic warns for paths through code in which a
10174file descriptor can be closed 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-fd-leak
10179@opindex Wanalyzer-fd-leak
10180@opindex Wno-analyzer-fd-leak
10181This warning requires @option{-fanalyzer}, which enables it; use
10182@option{-Wno-analyzer-fd-leak}
10183to disable it.
10184
10185This diagnostic warns for paths through code in which an
10186open file descriptor is leaked.
10187
10188See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10189
86a90006
DM
10190@item -Wno-analyzer-fd-phase-mismatch
10191@opindex Wanalyzer-fd-phase-mismatch
10192@opindex Wno-analyzer-fd-phase-mismatch
10193This warning requires @option{-fanalyzer}, which enables it; use
10194@option{-Wno-analyzer-fd-phase-mismatch}
10195to disable it.
10196
10197This diagnostic warns for paths through code in which an operation is
10198attempted in the wrong phase of a file descriptor's lifetime.
10199For example, it will warn on attempts to call @code{accept} on a stream
10200socket that has not yet had @code{listen} successfully called on it.
10201
10202See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}.
10203
10204@item -Wno-analyzer-fd-type-mismatch
10205@opindex Wanalyzer-fd-type-mismatch
10206@opindex Wno-analyzer-fd-type-mismatch
10207This warning requires @option{-fanalyzer}, which enables it; use
10208@option{-Wno-analyzer-fd-type-mismatch}
10209to disable it.
10210
10211This diagnostic warns for paths through code in which an
10212operation is attempted on the wrong type of file descriptor.
10213For example, it will warn on attempts to use socket operations
10214on a file descriptor obtained via @code{open}, or when attempting
10215to use a stream socket operation on a datagram socket.
10216
d77de738
ML
10217@item -Wno-analyzer-fd-use-after-close
10218@opindex Wanalyzer-fd-use-after-close
10219@opindex Wno-analyzer-fd-use-after-close
10220This warning requires @option{-fanalyzer}, which enables it; use
10221@option{-Wno-analyzer-fd-use-after-close}
10222to disable it.
10223
10224This diagnostic warns for paths through code in which a
10225read or write is called on a closed file descriptor.
10226
10227This diagnostic also warns for paths through code in which
10228a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10229or @code{fd_arg_write (N)} is called with a closed file descriptor at
10230referenced argument @code{N}.
10231
10232@item -Wno-analyzer-fd-use-without-check
10233@opindex Wanalyzer-fd-use-without-check
10234@opindex Wno-analyzer-fd-use-without-check
10235This warning requires @option{-fanalyzer}, which enables it; use
10236@option{-Wno-analyzer-fd-use-without-check}
10237to disable it.
10238
10239This diagnostic warns for paths through code in which a
10240file descriptor is used without being checked for validity.
10241
10242This diagnostic also warns for paths through code in which
10243a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10244or @code{fd_arg_write (N)} is called with a file descriptor, at referenced
10245argument @code{N}, without being checked for validity.
10246
10247@item -Wno-analyzer-file-leak
10248@opindex Wanalyzer-file-leak
10249@opindex Wno-analyzer-file-leak
10250This warning requires @option{-fanalyzer}, which enables it; use
10251@option{-Wno-analyzer-file-leak}
10252to disable it.
10253
10254This diagnostic warns for paths through the code in which a
10255@code{<stdio.h>} @code{FILE *} stream object is leaked.
10256
10257See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10258
10259@item -Wno-analyzer-free-of-non-heap
10260@opindex Wanalyzer-free-of-non-heap
10261@opindex Wno-analyzer-free-of-non-heap
10262This warning requires @option{-fanalyzer}, which enables it; use
10263@option{-Wno-analyzer-free-of-non-heap}
10264to disable it.
10265
10266This diagnostic warns for paths through the code in which @code{free}
10267is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
10268
10269See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}.
10270
10271@item -Wno-analyzer-imprecise-fp-arithmetic
10272@opindex Wanalyzer-imprecise-fp-arithmetic
10273@opindex Wno-analyzer-imprecise-fp-arithmetic
10274This warning requires @option{-fanalyzer}, which enables it; use
10275@option{-Wno-analyzer-imprecise-fp-arithmetic}
10276to disable it.
10277
10278This diagnostic warns for paths through the code in which floating-point
10279arithmetic is used in locations where precise computation is needed. This
10280diagnostic only warns on use of floating-point operands inside the
10281calculation of an allocation size at the moment.
10282
ce51e843
ML
10283@item -Wno-analyzer-infinite-recursion
10284@opindex Wanalyzer-infinite-recursion
10285@opindex Wno-analyzer-infinite-recursion
10286This warning requires @option{-fanalyzer}, which enables it; use
10287@option{-Wno-analyzer-infinite-recursion} to disable it.
10288
10289This diagnostics warns for paths through the code which appear to
10290lead to infinite recursion.
10291
10292Specifically, when the analyzer "sees" a recursive call, it will compare
10293the state of memory at the entry to the new frame with that at the entry
10294to the previous frame of that function on the stack. The warning is
10295issued if nothing in memory appears to be changing; any changes observed
10296to parameters or globals are assumed to lead to termination of the
10297recursion and thus suppress the warning.
10298
10299This diagnostic is likely to miss cases of infinite recursion that
10300are convered to iteration by the optimizer before the analyzer "sees"
10301them. Hence optimization should be disabled when attempting to trigger
10302this diagnostic.
10303
10304Compare with @option{-Winfinite-recursion}, which provides a similar
10305diagnostic, but is implemented in a different way.
10306
d77de738
ML
10307@item -Wno-analyzer-jump-through-null
10308@opindex Wanalyzer-jump-through-null
10309@opindex Wno-analyzer-jump-through-null
10310This warning requires @option{-fanalyzer}, which enables it; use
10311@option{-Wno-analyzer-jump-through-null}
10312to disable it.
10313
10314This diagnostic warns for paths through the code in which a @code{NULL}
10315function pointer is called.
10316
10317@item -Wno-analyzer-malloc-leak
10318@opindex Wanalyzer-malloc-leak
10319@opindex Wno-analyzer-malloc-leak
10320This warning requires @option{-fanalyzer}, which enables it; use
10321@option{-Wno-analyzer-malloc-leak}
10322to disable it.
10323
10324This diagnostic warns for paths through the code in which a
10325pointer allocated via an allocator is leaked: either @code{malloc},
10326or a function marked with attribute @code{malloc}.
10327
10328See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}.
10329
10330@item -Wno-analyzer-mismatching-deallocation
10331@opindex Wanalyzer-mismatching-deallocation
10332@opindex Wno-analyzer-mismatching-deallocation
10333This warning requires @option{-fanalyzer}, which enables it; use
10334@option{-Wno-analyzer-mismatching-deallocation}
10335to disable it.
10336
10337This diagnostic warns for paths through the code in which the
10338wrong deallocation function is called on a pointer value, based on
10339which function was used to allocate the pointer value. The diagnostic
10340will warn about mismatches between @code{free}, scalar @code{delete}
10341and vector @code{delete[]}, and those marked as allocator/deallocator
10342pairs using attribute @code{malloc}.
10343
10344See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}.
10345
10346@item -Wno-analyzer-out-of-bounds
10347@opindex Wanalyzer-out-of-bounds
10348@opindex Wno-analyzer-out-of-bounds
10349This warning requires @option{-fanalyzer} to enable it; use
10350@option{-Wno-analyzer-out-of-bounds} to disable it.
10351
10352This diagnostic warns for path through the code in which a buffer is
10353definitely read or written out-of-bounds. The diagnostic applies for
10354cases where the analyzer is able to determine a constant offset and for
10355accesses past the end of a buffer, also a constant capacity. Further,
10356the diagnostic does limited checking for accesses past the end when the
10357offset as well as the capacity is symbolic.
10358
10359See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}.
10360
10361@item -Wno-analyzer-possible-null-argument
10362@opindex Wanalyzer-possible-null-argument
10363@opindex Wno-analyzer-possible-null-argument
10364This warning requires @option{-fanalyzer}, which enables it; use
10365@option{-Wno-analyzer-possible-null-argument} to disable it.
10366
10367This diagnostic warns for paths through the code in which a
10368possibly-NULL value is passed to a function argument marked
10369with @code{__attribute__((nonnull))} as requiring a non-NULL
10370value.
10371
10372See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10373
10374@item -Wno-analyzer-possible-null-dereference
10375@opindex Wanalyzer-possible-null-dereference
10376@opindex Wno-analyzer-possible-null-dereference
10377This warning requires @option{-fanalyzer}, which enables it; use
10378@option{-Wno-analyzer-possible-null-dereference} to disable it.
10379
10380This diagnostic warns for paths through the code in which a
10381possibly-NULL value is dereferenced.
10382
10383See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10384
10385@item -Wno-analyzer-null-argument
10386@opindex Wanalyzer-null-argument
10387@opindex Wno-analyzer-null-argument
10388This warning requires @option{-fanalyzer}, which enables it; use
10389@option{-Wno-analyzer-null-argument} to disable it.
10390
10391This diagnostic warns for paths through the code in which a
10392value known to be NULL is passed to a function argument marked
10393with @code{__attribute__((nonnull))} as requiring a non-NULL
10394value.
10395
10396See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10397
10398@item -Wno-analyzer-null-dereference
10399@opindex Wanalyzer-null-dereference
10400@opindex Wno-analyzer-null-dereference
10401This warning requires @option{-fanalyzer}, which enables it; use
10402@option{-Wno-analyzer-null-dereference} to disable it.
10403
10404This diagnostic warns for paths through the code in which a
10405value known to be NULL is dereferenced.
10406
10407See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10408
10409@item -Wno-analyzer-putenv-of-auto-var
10410@opindex Wanalyzer-putenv-of-auto-var
10411@opindex Wno-analyzer-putenv-of-auto-var
10412This warning requires @option{-fanalyzer}, which enables it; use
10413@option{-Wno-analyzer-putenv-of-auto-var} to disable it.
10414
10415This diagnostic warns for paths through the code in which a
10416call to @code{putenv} is passed a pointer to an automatic variable
10417or an on-stack buffer.
10418
10419See @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}.
10420
10421@item -Wno-analyzer-shift-count-negative
10422@opindex Wanalyzer-shift-count-negative
10423@opindex Wno-analyzer-shift-count-negative
10424This warning requires @option{-fanalyzer}, which enables it; use
10425@option{-Wno-analyzer-shift-count-negative} to disable it.
10426
10427This diagnostic warns for paths through the code in which a
10428shift is attempted with a negative count. It is analogous to
10429the @option{-Wshift-count-negative} diagnostic implemented in
10430the C/C++ front ends, but is implemented based on analyzing
10431interprocedural paths, rather than merely parsing the syntax tree.
10432However, the analyzer does not prioritize detection of such paths, so
10433false negatives are more likely relative to other warnings.
10434
10435@item -Wno-analyzer-shift-count-overflow
10436@opindex Wanalyzer-shift-count-overflow
10437@opindex Wno-analyzer-shift-count-overflow
10438This warning requires @option{-fanalyzer}, which enables it; use
10439@option{-Wno-analyzer-shift-count-overflow} to disable it.
10440
10441This diagnostic warns for paths through the code in which a
10442shift is attempted with a count greater than or equal to the
10443precision of the operand's type. It is analogous to
10444the @option{-Wshift-count-overflow} diagnostic implemented in
10445the C/C++ front ends, but is implemented based on analyzing
10446interprocedural paths, rather than merely parsing the syntax tree.
10447However, the analyzer does not prioritize detection of such paths, so
10448false negatives are more likely relative to other warnings.
10449
10450@item -Wno-analyzer-stale-setjmp-buffer
10451@opindex Wanalyzer-stale-setjmp-buffer
10452@opindex Wno-analyzer-stale-setjmp-buffer
10453This warning requires @option{-fanalyzer}, which enables it; use
10454@option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
10455
10456This diagnostic warns for paths through the code in which
10457@code{longjmp} is called to rewind to a @code{jmp_buf} relating
10458to a @code{setjmp} call in a function that has returned.
10459
10460When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
10461location, it records the stack frame. The stack frame becomes invalid
10462when the function containing the @code{setjmp} call returns. Attempting
10463to rewind to it via @code{longjmp} would reference a stack frame that
10464no longer exists, and likely lead to a crash (or worse).
10465
10466@item -Wno-analyzer-tainted-allocation-size
10467@opindex Wanalyzer-tainted-allocation-size
10468@opindex Wno-analyzer-tainted-allocation-size
10469This warning requires both @option{-fanalyzer} and
10470@option{-fanalyzer-checker=taint} to enable it;
10471use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
10472
10473This diagnostic warns for paths through the code in which a value
10474that could be under an attacker's control is used as the size
10475of an allocation without being sanitized, so that an attacker could
10476inject an excessively large allocation and potentially cause a denial
10477of service attack.
10478
10479See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
10480
ce51e843
ML
10481@item -Wno-analyzer-tainted-assertion
10482@opindex Wanalyzer-tainted-assertion
10483@opindex Wno-analyzer-tainted-assertion
10484
10485This warning requires both @option{-fanalyzer} and
10486@option{-fanalyzer-checker=taint} to enable it;
10487use @option{-Wno-analyzer-tainted-assertion} to disable it.
10488
10489This diagnostic warns for paths through the code in which a value
10490that could be under an attacker's control is used as part of a
10491condition without being first sanitized, and that condition guards a
10492call to a function marked with attribute @code{noreturn}
10493(such as the function @code{__builtin_unreachable}). Such functions
10494typically indicate abnormal termination of the program, such as for
10495assertion failure handlers. For example:
10496
10497@smallexample
10498assert (some_tainted_value < SOME_LIMIT);
10499@end smallexample
10500
10501In such cases:
10502
10503@itemize
10504@item
10505when assertion-checking is enabled: an attacker could trigger
10506a denial of service by injecting an assertion failure
10507
10508@item
10509when assertion-checking is disabled, such as by defining @code{NDEBUG},
10510an attacker could inject data that subverts the process, since it
10511presumably violates a precondition that is being assumed by the code.
10512
10513@end itemize
10514
10515Note that when assertion-checking is disabled, the assertions are
10516typically removed by the preprocessor before the analyzer has a chance
10517to "see" them, so this diagnostic can only generate warnings on builds
10518in which assertion-checking is enabled.
10519
10520For the purpose of this warning, any function marked with attribute
10521@code{noreturn} is considered as a possible assertion failure
10522handler, including @code{__builtin_unreachable}. Note that these functions
10523are sometimes removed by the optimizer before the analyzer "sees" them.
10524Hence optimization should be disabled when attempting to trigger this
10525diagnostic.
10526
10527See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}.
10528
10529The warning can also report problematic constructions such as
10530
10531@smallexample
10532switch (some_tainted_value) @{
10533case 0:
10534 /* [...etc; various valid cases omitted...] */
10535 break;
10536
10537default:
10538 __builtin_unreachable (); /* BUG: attacker can trigger this */
10539@}
10540@end smallexample
10541
10542despite the above not being an assertion failure, strictly speaking.
10543
d77de738
ML
10544@item -Wno-analyzer-tainted-array-index
10545@opindex Wanalyzer-tainted-array-index
10546@opindex Wno-analyzer-tainted-array-index
10547This warning requires both @option{-fanalyzer} and
10548@option{-fanalyzer-checker=taint} to enable it;
10549use @option{-Wno-analyzer-tainted-array-index} to disable it.
10550
10551This diagnostic warns for paths through the code in which a value
10552that could be under an attacker's control is used as the index
10553of an array access without being sanitized, so that an attacker
10554could inject an out-of-bounds access.
10555
10556See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10557
10558@item -Wno-analyzer-tainted-divisor
10559@opindex Wanalyzer-tainted-divisor
10560@opindex Wno-analyzer-tainted-divisor
10561This warning requires both @option{-fanalyzer} and
10562@option{-fanalyzer-checker=taint} to enable it;
10563use @option{-Wno-analyzer-tainted-divisor} to disable it.
10564
10565This diagnostic warns for paths through the code in which a value
10566that could be under an attacker's control is used as the divisor
10567in a division or modulus operation without being sanitized, so that
10568an attacker could inject a division-by-zero.
10569
10570See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}.
10571
10572@item -Wno-analyzer-tainted-offset
10573@opindex Wanalyzer-tainted-offset
10574@opindex Wno-analyzer-tainted-offset
10575This warning requires both @option{-fanalyzer} and
10576@option{-fanalyzer-checker=taint} to enable it;
10577use @option{-Wno-analyzer-tainted-offset} to disable it.
10578
10579This diagnostic warns for paths through the code in which a value
10580that could be under an attacker's control is used as a pointer offset
10581without being sanitized, so that an attacker could inject an out-of-bounds
10582access.
10583
10584See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
10585
10586@item -Wno-analyzer-tainted-size
10587@opindex Wanalyzer-tainted-size
10588@opindex Wno-analyzer-tainted-size
10589This warning requires both @option{-fanalyzer} and
10590@option{-fanalyzer-checker=taint} to enable it;
10591use @option{-Wno-analyzer-tainted-size} to disable it.
10592
10593This diagnostic warns for paths through the code in which a value
10594that could be under an attacker's control is used as the size of
10595an operation such as @code{memset} without being sanitized, so that an
10596attacker could inject an out-of-bounds access.
10597
10598See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10599
10600@item -Wno-analyzer-unsafe-call-within-signal-handler
10601@opindex Wanalyzer-unsafe-call-within-signal-handler
10602@opindex Wno-analyzer-unsafe-call-within-signal-handler
10603This warning requires @option{-fanalyzer}, which enables it; use
10604@option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
10605
10606This diagnostic warns for paths through the code in which a
10607function known to be async-signal-unsafe (such as @code{fprintf}) is
10608called from a signal handler.
10609
10610See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}.
10611
10612@item -Wno-analyzer-use-after-free
10613@opindex Wanalyzer-use-after-free
10614@opindex Wno-analyzer-use-after-free
10615This warning requires @option{-fanalyzer}, which enables it; use
10616@option{-Wno-analyzer-use-after-free} to disable it.
10617
10618This diagnostic warns for paths through the code in which a
10619pointer is used after a deallocator is called on it: either @code{free},
10620or a deallocator referenced by attribute @code{malloc}.
10621
10622See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}.
10623
10624@item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
10625@opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
10626@opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
10627This warning requires @option{-fanalyzer}, which enables it; use
10628@option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
10629to disable it.
10630
10631This diagnostic warns for paths through the code in which a pointer
10632is dereferenced that points to a variable in a stale stack frame.
10633
10634@item -Wno-analyzer-va-arg-type-mismatch
10635@opindex Wanalyzer-va-arg-type-mismatch
10636@opindex Wno-analyzer-va-arg-type-mismatch
10637This warning requires @option{-fanalyzer}, which enables it; use
10638@option{-Wno-analyzer-va-arg-type-mismatch}
10639to disable it.
10640
10641This diagnostic warns for interprocedural paths through the code for which
10642the analyzer detects an attempt to use @code{va_arg} to extract a value
10643passed to a variadic call, but uses a type that does not match that of
10644the expression passed to the call.
10645
10646See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}.
10647
10648@item -Wno-analyzer-va-list-exhausted
10649@opindex Wanalyzer-va-list-exhausted
10650@opindex Wno-analyzer-va-list-exhausted
10651This warning requires @option{-fanalyzer}, which enables it; use
10652@option{-Wno-analyzer-va-list-exhausted}
10653to disable it.
10654
10655This diagnostic warns for interprocedural paths through the code for which
10656the analyzer detects an attempt to use @code{va_arg} to access the next
10657value passed to a variadic call, but all of the values in the
10658@code{va_list} have already been consumed.
10659
10660See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}.
10661
10662@item -Wno-analyzer-va-list-leak
10663@opindex Wanalyzer-va-list-leak
10664@opindex Wno-analyzer-va-list-leak
10665This warning requires @option{-fanalyzer}, which enables it; use
10666@option{-Wno-analyzer-va-list-leak}
10667to disable it.
10668
10669This diagnostic warns for interprocedural paths through the code for which
10670the analyzer detects that @code{va_start} or @code{va_copy} has been called
10671on a @code{va_list} without a corresponding call to @code{va_end}.
10672
10673@item -Wno-analyzer-va-list-use-after-va-end
10674@opindex Wanalyzer-va-list-use-after-va-end
10675@opindex Wno-analyzer-va-list-use-after-va-end
10676This warning requires @option{-fanalyzer}, which enables it; use
10677@option{-Wno-analyzer-va-list-use-after-va-end}
10678to disable it.
10679
10680This diagnostic warns for interprocedural paths through the code for which
10681the analyzer detects an attempt to use a @code{va_list} after
10682@code{va_end} has been called on it.
10683@code{va_list}.
10684
10685@item -Wno-analyzer-write-to-const
10686@opindex Wanalyzer-write-to-const
10687@opindex Wno-analyzer-write-to-const
10688This warning requires @option{-fanalyzer}, which enables it; use
10689@option{-Wno-analyzer-write-to-const}
10690to disable it.
10691
10692This diagnostic warns for paths through the code in which the analyzer
10693detects an attempt to write through a pointer to a @code{const} object.
10694However, the analyzer does not prioritize detection of such paths, so
10695false negatives are more likely relative to other warnings.
10696
10697@item -Wno-analyzer-write-to-string-literal
10698@opindex Wanalyzer-write-to-string-literal
10699@opindex Wno-analyzer-write-to-string-literal
10700This warning requires @option{-fanalyzer}, which enables it; use
10701@option{-Wno-analyzer-write-to-string-literal}
10702to disable it.
10703
10704This diagnostic warns for paths through the code in which the analyzer
10705detects an attempt to write through a pointer to a string literal.
10706However, the analyzer does not prioritize detection of such paths, so
10707false negatives are more likely relative to other warnings.
10708
10709@item -Wno-analyzer-use-of-uninitialized-value
10710@opindex Wanalyzer-use-of-uninitialized-value
10711@opindex Wno-analyzer-use-of-uninitialized-value
10712This warning requires @option{-fanalyzer}, which enables it; use
10713@option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
10714
10715This diagnostic warns for paths through the code in which an uninitialized
10716value is used.
10717
10718See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}.
10719
10720@end table
10721
10722The analyzer has hardcoded knowledge about the behavior of the following
10723memory-management functions:
10724
10725@itemize @bullet
10726@item @code{alloca}
10727@item The built-in functions @code{__builtin_alloc},
10728@code{__builtin_alloc_with_align}, @item @code{__builtin_calloc},
10729@code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy},
10730@code{__builtin_memcpy_chk}, @code{__builtin_memset},
10731@code{__builtin_memset_chk}, @code{__builtin_realloc},
10732@code{__builtin_stack_restore}, and @code{__builtin_stack_save}
10733@item @code{calloc}
10734@item @code{free}
10735@item @code{malloc}
10736@item @code{memset}
10737@item @code{operator delete}
10738@item @code{operator delete []}
10739@item @code{operator new}
10740@item @code{operator new []}
10741@item @code{realloc}
10742@item @code{strdup}
10743@item @code{strndup}
10744@end itemize
10745
10746of the following functions for working with file descriptors:
10747
10748@itemize @bullet
10749@item @code{open}
10750@item @code{close}
10751@item @code{creat}
10752@item @code{dup}, @code{dup2} and @code{dup3}
10753@item @code{pipe}, and @code{pipe2}
10754@item @code{read}
10755@item @code{write}
86a90006 10756@item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect}
d77de738
ML
10757@end itemize
10758
10759of the following functions for working with @code{<stdio.h>} streams:
10760@itemize @bullet
10761@item The built-in functions @code{__builtin_fprintf},
10762@code{__builtin_fprintf_unlocked}, @code{__builtin_fputc},
10763@code{__builtin_fputc_unlocked}, @code{__builtin_fputs},
10764@code{__builtin_fputs_unlocked}, @code{__builtin_fwrite},
10765@code{__builtin_fwrite_unlocked}, @code{__builtin_printf},
10766@code{__builtin_printf_unlocked}, @code{__builtin_putc},
10767@code{__builtin_putchar}, @code{__builtin_putchar_unlocked},
10768@code{__builtin_putc_unlocked}, @code{__builtin_puts},
10769@code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and
10770@code{__builtin_vprintf}
10771@item @code{fopen}
10772@item @code{fclose}
10773@item @code{fgets}
10774@item @code{fgets_unlocked}
10775@item @code{fread}
10776@item @code{getchar}
10777@item @code{fprintf}
10778@item @code{printf}
10779@item @code{fwrite}
10780@end itemize
10781
10782and of the following functions:
10783
10784@itemize @bullet
10785@item The built-in functions @code{__builtin_expect},
10786@code{__builtin_expect_with_probability}, @code{__builtin_strchr},
10787@code{__builtin_strcpy}, @code{__builtin_strcpy_chk},
10788@code{__builtin_strlen}, @code{__builtin_va_copy}, and
10789@code{__builtin_va_start}
10790@item The GNU extensions @code{error} and @code{error_at_line}
10791@item @code{getpass}
10792@item @code{longjmp}
10793@item @code{putenv}
10794@item @code{setjmp}
10795@item @code{siglongjmp}
10796@item @code{signal}
10797@item @code{sigsetjmp}
10798@item @code{strchr}
10799@item @code{strlen}
10800@end itemize
10801
10802In addition, various functions with an @code{__analyzer_} prefix have
10803special meaning to the analyzer, described in the GCC Internals manual.
10804
10805Pertinent parameters for controlling the exploration are:
10806@option{--param analyzer-bb-explosion-factor=@var{value}},
10807@option{--param analyzer-max-enodes-per-program-point=@var{value}},
10808@option{--param analyzer-max-recursion-depth=@var{value}}, and
10809@option{--param analyzer-min-snodes-for-call-summary=@var{value}}.
10810
10811The following options control the analyzer.
10812
10813@table @gcctabopt
10814
10815@item -fanalyzer-call-summaries
10816@opindex fanalyzer-call-summaries
10817@opindex fno-analyzer-call-summaries
10818Simplify interprocedural analysis by computing the effect of certain calls,
10819rather than exploring all paths through the function from callsite to each
10820possible return.
10821
10822If enabled, call summaries are only used for functions with more than one
10823call site, and that are sufficiently complicated (as per
10824@option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
10825
10826@item -fanalyzer-checker=@var{name}
10827@opindex fanalyzer-checker
10828Restrict the analyzer to run just the named checker, and enable it.
10829
10830Some checkers are disabled by default (even with @option{-fanalyzer}),
10831such as the @code{taint} checker that implements
10832@option{-Wanalyzer-tainted-array-index}, and this option is required
10833to enable them.
10834
10835@emph{Note:} currently, @option{-fanalyzer-checker=taint} disables the
10836following warnings from @option{-fanalyzer}:
10837
10838@gccoptlist{ @gol
ce51e843 10839-Wanalyzer-deref-before-check @gol
d77de738
ML
10840-Wanalyzer-double-fclose @gol
10841-Wanalyzer-double-free @gol
10842-Wanalyzer-exposure-through-output-file @gol
10843-Wanalyzer-fd-access-mode-mismatch @gol
10844-Wanalyzer-fd-double-close @gol
10845-Wanalyzer-fd-leak @gol
10846-Wanalyzer-fd-use-after-close @gol
10847-Wanalyzer-fd-use-without-check @gol
10848-Wanalyzer-file-leak @gol
10849-Wanalyzer-free-of-non-heap @gol
10850-Wanalyzer-malloc-leak @gol
10851-Wanalyzer-mismatching-deallocation @gol
10852-Wanalyzer-null-argument @gol
10853-Wanalyzer-null-dereference @gol
10854-Wanalyzer-possible-null-argument @gol
10855-Wanalyzer-possible-null-dereference @gol
10856-Wanalyzer-unsafe-call-within-signal-handler @gol
10857-Wanalyzer-use-after-free @gol
10858-Wanalyzer-va-list-leak @gol
10859-Wanalyzer-va-list-use-after-va-end @gol
10860}
10861
10862@item -fno-analyzer-feasibility
10863@opindex fanalyzer-feasibility
10864@opindex fno-analyzer-feasibility
10865This option is intended for analyzer developers.
10866
10867By default the analyzer verifies that there is a feasible control flow path
10868for each diagnostic it emits: that the conditions that hold are not mutually
10869exclusive. Diagnostics for which no feasible path can be found are rejected.
10870This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
10871debugging issues in this code.
10872
10873@item -fanalyzer-fine-grained
10874@opindex fanalyzer-fine-grained
10875@opindex fno-analyzer-fine-grained
10876This option is intended for analyzer developers.
10877
10878Internally the analyzer builds an ``exploded graph'' that combines
10879control flow graphs with data flow information.
10880
10881By default, an edge in this graph can contain the effects of a run
10882of multiple statements within a basic block. With
10883@option{-fanalyzer-fine-grained}, each statement gets its own edge.
10884
10885@item -fanalyzer-show-duplicate-count
10886@opindex fanalyzer-show-duplicate-count
10887@opindex fno-analyzer-show-duplicate-count
10888This option is intended for analyzer developers: if multiple diagnostics
10889have been detected as being duplicates of each other, it emits a note when
10890reporting the best diagnostic, giving the number of additional diagnostics
10891that were suppressed by the deduplication logic.
10892
10893@item -fno-analyzer-state-merge
10894@opindex fanalyzer-state-merge
10895@opindex fno-analyzer-state-merge
10896This option is intended for analyzer developers.
10897
10898By default the analyzer attempts to simplify analysis by merging
10899sufficiently similar states at each program point as it builds its
10900``exploded graph''. With @option{-fno-analyzer-state-merge} this
10901merging can be suppressed, for debugging state-handling issues.
10902
10903@item -fno-analyzer-state-purge
10904@opindex fanalyzer-state-purge
10905@opindex fno-analyzer-state-purge
10906This option is intended for analyzer developers.
10907
10908By default the analyzer attempts to simplify analysis by purging
10909aspects of state at a program point that appear to no longer be relevant
10910e.g. the values of locals that aren't accessed later in the function
10911and which aren't relevant to leak analysis.
10912
10913With @option{-fno-analyzer-state-purge} this purging of state can
10914be suppressed, for debugging state-handling issues.
10915
10916@item -fanalyzer-transitivity
10917@opindex fanalyzer-transitivity
10918@opindex fno-analyzer-transitivity
10919This option enables transitivity of constraints within the analyzer.
10920
10921@item -fno-analyzer-undo-inlining
10922@opindex fanalyzer-undo-inlining
10923@opindex fno-analyzer-undo-inlining
10924This option is intended for analyzer developers.
10925
10926@option{-fanalyzer} runs relatively late compared to other code analysis
10927tools, and some optimizations have already been applied to the code. In
10928particular function inlining may have occurred, leading to the
10929interprocedural execution paths emitted by the analyzer containing
10930function frames that don't correspond to those in the original source
10931code.
10932
10933By default the analyzer attempts to reconstruct the original function
10934frames, and to emit events showing the inlined calls.
10935
10936With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct
10937the original frame information can be be disabled, which may be of help
10938when debugging issues in the analyzer.
10939
10940@item -fanalyzer-verbose-edges
10941This option is intended for analyzer developers. It enables more
10942verbose, lower-level detail in the descriptions of control flow
10943within diagnostic paths.
10944
10945@item -fanalyzer-verbose-state-changes
10946This option is intended for analyzer developers. It enables more
10947verbose, lower-level detail in the descriptions of events relating
10948to state machines within diagnostic paths.
10949
10950@item -fanalyzer-verbosity=@var{level}
10951This option controls the complexity of the control flow paths that are
10952emitted for analyzer diagnostics.
10953
10954The @var{level} can be one of:
10955
10956@table @samp
10957@item 0
10958At this level, interprocedural call and return events are displayed,
10959along with the most pertinent state-change events relating to
10960a diagnostic. For example, for a double-@code{free} diagnostic,
10961both calls to @code{free} will be shown.
10962
10963@item 1
10964As per the previous level, but also show events for the entry
10965to each function.
10966
10967@item 2
10968As per the previous level, but also show events relating to
10969control flow that are significant to triggering the issue
10970(e.g. ``true path taken'' at a conditional).
10971
10972This level is the default.
10973
10974@item 3
10975As per the previous level, but show all control flow events, not
10976just significant ones.
10977
10978@item 4
10979This level is intended for analyzer developers; it adds various
10980other events intended for debugging the analyzer.
10981
10982@end table
10983
10984@item -fdump-analyzer
10985@opindex fdump-analyzer
10986Dump internal details about what the analyzer is doing to
10987@file{@var{file}.analyzer.txt}.
10988This option is overridden by @option{-fdump-analyzer-stderr}.
10989
10990@item -fdump-analyzer-stderr
10991@opindex fdump-analyzer-stderr
10992Dump internal details about what the analyzer is doing to stderr.
10993This option overrides @option{-fdump-analyzer}.
10994
10995@item -fdump-analyzer-callgraph
10996@opindex fdump-analyzer-callgraph
10997Dump a representation of the call graph suitable for viewing with
10998GraphViz to @file{@var{file}.callgraph.dot}.
10999
11000@item -fdump-analyzer-exploded-graph
11001@opindex fdump-analyzer-exploded-graph
11002Dump a representation of the ``exploded graph'' suitable for viewing with
11003GraphViz to @file{@var{file}.eg.dot}.
11004Nodes are color-coded based on state-machine states to emphasize
11005state changes.
11006
11007@item -fdump-analyzer-exploded-nodes
11008@opindex dump-analyzer-exploded-nodes
11009Emit diagnostics showing where nodes in the ``exploded graph'' are
11010in relation to the program source.
11011
11012@item -fdump-analyzer-exploded-nodes-2
11013@opindex dump-analyzer-exploded-nodes-2
11014Dump a textual representation of the ``exploded graph'' to
11015@file{@var{file}.eg.txt}.
11016
11017@item -fdump-analyzer-exploded-nodes-3
11018@opindex dump-analyzer-exploded-nodes-3
11019Dump a textual representation of the ``exploded graph'' to
11020one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
11021This is typically a large number of dump files.
11022
11023@item -fdump-analyzer-exploded-paths
11024@opindex fdump-analyzer-exploded-paths
11025Dump a textual representation of the ``exploded path'' for each
11026diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
11027
11028@item -fdump-analyzer-feasibility
11029@opindex dump-analyzer-feasibility
11030Dump internal details about the analyzer's search for feasible paths.
11031The details are written in a form suitable for viewing with GraphViz
11032to filenames of the form @file{@var{file}.*.fg.dot},
11033@file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
11034
11035@item -fdump-analyzer-json
11036@opindex fdump-analyzer-json
11037Dump a compressed JSON representation of analyzer internals to
11038@file{@var{file}.analyzer.json.gz}. The precise format is subject
11039to change.
11040
11041@item -fdump-analyzer-state-purge
11042@opindex fdump-analyzer-state-purge
11043As per @option{-fdump-analyzer-supergraph}, dump a representation of the
11044``supergraph'' suitable for viewing with GraphViz, but annotate the
11045graph with information on what state will be purged at each node.
11046The graph is written to @file{@var{file}.state-purge.dot}.
11047
11048@item -fdump-analyzer-supergraph
11049@opindex fdump-analyzer-supergraph
11050Dump representations of the ``supergraph'' suitable for viewing with
11051GraphViz to @file{@var{file}.supergraph.dot} and to
11052@file{@var{file}.supergraph-eg.dot}. These show all of the
11053control flow graphs in the program, with interprocedural edges for
11054calls and returns. The second dump contains annotations showing nodes
11055in the ``exploded graph'' and diagnostics associated with them.
11056
11057@item -fdump-analyzer-untracked
11058@opindex fdump-analyzer-untracked
11059Emit custom warnings with internal details intended for analyzer developers.
11060
11061@end table
11062
11063@node Debugging Options
11064@section Options for Debugging Your Program
11065@cindex options, debugging
11066@cindex debugging information options
11067
11068To tell GCC to emit extra information for use by a debugger, in almost
11069all cases you need only to add @option{-g} to your other options. Some debug
11070formats can co-exist (like DWARF with CTF) when each of them is enabled
11071explicitly by adding the respective command line option to your other options.
11072
11073GCC allows you to use @option{-g} with
11074@option{-O}. The shortcuts taken by optimized code may occasionally
11075be surprising: some variables you declared may not exist
11076at all; flow of control may briefly move where you did not expect it;
11077some statements may not be executed because they compute constant
11078results or their values are already at hand; some statements may
11079execute in different places because they have been moved out of loops.
11080Nevertheless it is possible to debug optimized output. This makes
11081it reasonable to use the optimizer for programs that might have bugs.
11082
11083If you are not using some other optimization option, consider
11084using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
11085With no @option{-O} option at all, some compiler passes that collect
11086information useful for debugging do not run at all, so that
11087@option{-Og} may result in a better debugging experience.
11088
11089@table @gcctabopt
11090@item -g
11091@opindex g
11092Produce debugging information in the operating system's native format
11093(stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
11094information.
11095
11096On most systems that use stabs format, @option{-g} enables use of extra
11097debugging information that only GDB can use; this extra information
11098makes debugging work better in GDB but probably makes other debuggers
11099crash or refuse to read the program. If you want to control for certain whether
11100to generate the extra information, use @option{-gvms} (see below).
11101
11102@item -ggdb
11103@opindex ggdb
11104Produce debugging information for use by GDB@. This means to use the
11105most expressive format available (DWARF, stabs, or the native format
11106if neither of those are supported), including GDB extensions if at all
11107possible.
11108
11109@item -gdwarf
11110@itemx -gdwarf-@var{version}
11111@opindex gdwarf
11112Produce debugging information in DWARF format (if that is supported).
11113The value of @var{version} may be either 2, 3, 4 or 5; the default
11114version for most targets is 5 (with the exception of VxWorks, TPF and
11115Darwin/Mac OS X, which default to version 2, and AIX, which defaults
11116to version 4).
11117
11118Note that with DWARF Version 2, some ports require and always
11119use some non-conflicting DWARF 3 extensions in the unwind tables.
11120
11121Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
11122for maximum benefit. Version 5 requires GDB 8.0 or higher.
11123
11124GCC no longer supports DWARF Version 1, which is substantially
11125different than Version 2 and later. For historical reasons, some
11126other DWARF-related options such as
11127@option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
11128in their names, but apply to all currently-supported versions of DWARF.
11129
11130@item -gbtf
11131@opindex gbtf
11132Request BTF debug information. BTF is the default debugging format for the
11133eBPF target. On other targets, like x86, BTF debug information can be
11134generated along with DWARF debug information when both of the debug formats are
11135enabled explicitly via their respective command line options.
11136
11137@item -gctf
11138@itemx -gctf@var{level}
11139@opindex gctf
11140Request CTF debug information and use level to specify how much CTF debug
11141information should be produced. If @option{-gctf} is specified
11142without a value for level, the default level of CTF debug information is 2.
11143
11144CTF debug information can be generated along with DWARF debug information when
11145both of the debug formats are enabled explicitly via their respective command
11146line options.
11147
11148Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
11149negates @option{-gctf}.
11150
11151Level 1 produces CTF information for tracebacks only. This includes callsite
11152information, but does not include type information.
11153
11154Level 2 produces type information for entities (functions, data objects etc.)
11155at file-scope or global-scope only.
11156
11157@item -gvms
11158@opindex gvms
11159Produce debugging information in Alpha/VMS debug format (if that is
11160supported). This is the format used by DEBUG on Alpha/VMS systems.
11161
11162@item -g@var{level}
11163@itemx -ggdb@var{level}
11164@itemx -gvms@var{level}
11165Request debugging information and also use @var{level} to specify how
11166much information. The default level is 2.
11167
11168Level 0 produces no debug information at all. Thus, @option{-g0} negates
11169@option{-g}.
11170
11171Level 1 produces minimal information, enough for making backtraces in
11172parts of the program that you don't plan to debug. This includes
11173descriptions of functions and external variables, and line number
11174tables, but no information about local variables.
11175
11176Level 3 includes extra information, such as all the macro definitions
11177present in the program. Some debuggers support macro expansion when
11178you use @option{-g3}.
11179
11180If you use multiple @option{-g} options, with or without level numbers,
11181the last such option is the one that is effective.
11182
11183@option{-gdwarf} does not accept a concatenated debug level, to avoid
11184confusion with @option{-gdwarf-@var{level}}.
11185Instead use an additional @option{-g@var{level}} option to change the
11186debug level for DWARF.
11187
11188@item -fno-eliminate-unused-debug-symbols
11189@opindex feliminate-unused-debug-symbols
11190@opindex fno-eliminate-unused-debug-symbols
11191By default, no debug information is produced for symbols that are not actually
11192used. Use this option if you want debug information for all symbols.
11193
11194@item -femit-class-debug-always
11195@opindex femit-class-debug-always
11196Instead of emitting debugging information for a C++ class in only one
11197object file, emit it in all object files using the class. This option
11198should be used only with debuggers that are unable to handle the way GCC
11199normally emits debugging information for classes because using this
11200option increases the size of debugging information by as much as a
11201factor of two.
11202
11203@item -fno-merge-debug-strings
11204@opindex fmerge-debug-strings
11205@opindex fno-merge-debug-strings
11206Direct the linker to not merge together strings in the debugging
11207information that are identical in different object files. Merging is
11208not supported by all assemblers or linkers. Merging decreases the size
11209of the debug information in the output file at the cost of increasing
11210link processing time. Merging is enabled by default.
11211
11212@item -fdebug-prefix-map=@var{old}=@var{new}
11213@opindex fdebug-prefix-map
11214When compiling files residing in directory @file{@var{old}}, record
11215debugging information describing them as if the files resided in
11216directory @file{@var{new}} instead. This can be used to replace a
11217build-time path with an install-time path in the debug info. It can
11218also be used to change an absolute path to a relative path by using
11219@file{.} for @var{new}. This can give more reproducible builds, which
11220are location independent, but may require an extra command to tell GDB
11221where to find the source files. See also @option{-ffile-prefix-map}.
11222
11223@item -fvar-tracking
11224@opindex fvar-tracking
11225Run variable tracking pass. It computes where variables are stored at each
11226position in code. Better debugging information is then generated
11227(if the debugging information format supports this information).
11228
11229It is enabled by default when compiling with optimization (@option{-Os},
11230@option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
11231the debug info format supports it.
11232
11233@item -fvar-tracking-assignments
11234@opindex fvar-tracking-assignments
11235@opindex fno-var-tracking-assignments
11236Annotate assignments to user variables early in the compilation and
11237attempt to carry the annotations over throughout the compilation all the
11238way to the end, in an attempt to improve debug information while
11239optimizing. Use of @option{-gdwarf-4} is recommended along with it.
11240
11241It can be enabled even if var-tracking is disabled, in which case
11242annotations are created and maintained, but discarded at the end.
11243By default, this flag is enabled together with @option{-fvar-tracking},
11244except when selective scheduling is enabled.
11245
11246@item -gsplit-dwarf
11247@opindex gsplit-dwarf
11248If DWARF debugging information is enabled, separate as much debugging
11249information as possible into a separate output file with the extension
11250@file{.dwo}. This option allows the build system to avoid linking files with
11251debug information. To be useful, this option requires a debugger capable of
11252reading @file{.dwo} files.
11253
11254@item -gdwarf32
11255@itemx -gdwarf64
11256@opindex gdwarf32
11257@opindex gdwarf64
11258If DWARF debugging information is enabled, the @option{-gdwarf32} selects
11259the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
11260DWARF format. The default is target specific, on most targets it is
11261@option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
11262can't support more than 2GiB of debug information in any of the DWARF
11263debug information sections. The 64-bit DWARF format allows larger debug
11264information and might not be well supported by all consumers yet.
11265
11266@item -gdescribe-dies
11267@opindex gdescribe-dies
11268Add description attributes to some DWARF DIEs that have no name attribute,
11269such as artificial variables, external references and call site
11270parameter DIEs.
11271
11272@item -gpubnames
11273@opindex gpubnames
11274Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
11275
11276@item -ggnu-pubnames
11277@opindex ggnu-pubnames
11278Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
11279suitable for conversion into a GDB@ index. This option is only useful
11280with a linker that can produce GDB@ index version 7.
11281
11282@item -fdebug-types-section
11283@opindex fdebug-types-section
11284@opindex fno-debug-types-section
11285When using DWARF Version 4 or higher, type DIEs can be put into
11286their own @code{.debug_types} section instead of making them part of the
11287@code{.debug_info} section. It is more efficient to put them in a separate
11288comdat section since the linker can then remove duplicates.
11289But not all DWARF consumers support @code{.debug_types} sections yet
11290and on some objects @code{.debug_types} produces larger instead of smaller
11291debugging information.
11292
11293@item -grecord-gcc-switches
11294@itemx -gno-record-gcc-switches
11295@opindex grecord-gcc-switches
11296@opindex gno-record-gcc-switches
11297This switch causes the command-line options used to invoke the
11298compiler that may affect code generation to be appended to the
11299DW_AT_producer attribute in DWARF debugging information. The options
11300are concatenated with spaces separating them from each other and from
11301the compiler version.
11302It is enabled by default.
11303See also @option{-frecord-gcc-switches} for another
11304way of storing compiler options into the object file.
11305
11306@item -gstrict-dwarf
11307@opindex gstrict-dwarf
11308Disallow using extensions of later DWARF standard version than selected
11309with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
11310DWARF extensions from later standard versions is allowed.
11311
11312@item -gno-strict-dwarf
11313@opindex gno-strict-dwarf
11314Allow using extensions of later DWARF standard version than selected with
11315@option{-gdwarf-@var{version}}.
11316
11317@item -gas-loc-support
11318@opindex gas-loc-support
11319Inform the compiler that the assembler supports @code{.loc} directives.
11320It may then use them for the assembler to generate DWARF2+ line number
11321tables.
11322
11323This is generally desirable, because assembler-generated line-number
11324tables are a lot more compact than those the compiler can generate
11325itself.
11326
11327This option will be enabled by default if, at GCC configure time, the
11328assembler was found to support such directives.
11329
11330@item -gno-as-loc-support
11331@opindex gno-as-loc-support
11332Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
11333line number tables are to be generated.
11334
11335@item -gas-locview-support
11336@opindex gas-locview-support
11337Inform the compiler that the assembler supports @code{view} assignment
11338and reset assertion checking in @code{.loc} directives.
11339
11340This option will be enabled by default if, at GCC configure time, the
11341assembler was found to support them.
11342
11343@item -gno-as-locview-support
11344Force GCC to assign view numbers internally, if
11345@option{-gvariable-location-views} are explicitly requested.
11346
11347@item -gcolumn-info
11348@itemx -gno-column-info
11349@opindex gcolumn-info
11350@opindex gno-column-info
11351Emit location column information into DWARF debugging information, rather
11352than just file and line.
11353This option is enabled by default.
11354
11355@item -gstatement-frontiers
11356@itemx -gno-statement-frontiers
11357@opindex gstatement-frontiers
11358@opindex gno-statement-frontiers
11359This option causes GCC to create markers in the internal representation
11360at the beginning of statements, and to keep them roughly in place
11361throughout compilation, using them to guide the output of @code{is_stmt}
11362markers in the line number table. This is enabled by default when
11363compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
11364@dots{}), and outputting DWARF 2 debug information at the normal level.
11365
11366@item -gvariable-location-views
11367@itemx -gvariable-location-views=incompat5
11368@itemx -gno-variable-location-views
11369@opindex gvariable-location-views
11370@opindex gvariable-location-views=incompat5
11371@opindex gno-variable-location-views
11372Augment variable location lists with progressive view numbers implied
11373from the line number table. This enables debug information consumers to
11374inspect state at certain points of the program, even if no instructions
11375associated with the corresponding source locations are present at that
11376point. If the assembler lacks support for view numbers in line number
11377tables, this will cause the compiler to emit the line number table,
11378which generally makes them somewhat less compact. The augmented line
11379number tables and location lists are fully backward-compatible, so they
11380can be consumed by debug information consumers that are not aware of
11381these augmentations, but they won't derive any benefit from them either.
11382
11383This is enabled by default when outputting DWARF 2 debug information at
11384the normal level, as long as there is assembler support,
11385@option{-fvar-tracking-assignments} is enabled and
11386@option{-gstrict-dwarf} is not. When assembler support is not
11387available, this may still be enabled, but it will force GCC to output
11388internal line number tables, and if
11389@option{-ginternal-reset-location-views} is not enabled, that will most
11390certainly lead to silently mismatching location views.
11391
11392There is a proposed representation for view numbers that is not backward
11393compatible with the location list format introduced in DWARF 5, that can
11394be enabled with @option{-gvariable-location-views=incompat5}. This
11395option may be removed in the future, is only provided as a reference
11396implementation of the proposed representation. Debug information
11397consumers are not expected to support this extended format, and they
11398would be rendered unable to decode location lists using it.
11399
11400@item -ginternal-reset-location-views
11401@itemx -gno-internal-reset-location-views
11402@opindex ginternal-reset-location-views
11403@opindex gno-internal-reset-location-views
11404Attempt to determine location views that can be omitted from location
11405view lists. This requires the compiler to have very accurate insn
11406length estimates, which isn't always the case, and it may cause
11407incorrect view lists to be generated silently when using an assembler
11408that does not support location view lists. The GNU assembler will flag
11409any such error as a @code{view number mismatch}. This is only enabled
11410on ports that define a reliable estimation function.
11411
11412@item -ginline-points
11413@itemx -gno-inline-points
11414@opindex ginline-points
11415@opindex gno-inline-points
11416Generate extended debug information for inlined functions. Location
11417view tracking markers are inserted at inlined entry points, so that
11418address and view numbers can be computed and output in debug
11419information. This can be enabled independently of location views, in
11420which case the view numbers won't be output, but it can only be enabled
11421along with statement frontiers, and it is only enabled by default if
11422location views are enabled.
11423
11424@item -gz@r{[}=@var{type}@r{]}
11425@opindex gz
11426Produce compressed debug sections in DWARF format, if that is supported.
11427If @var{type} is not given, the default type depends on the capabilities
11428of the assembler and linker used. @var{type} may be one of
11429@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
11430compression in ELF gABI format). If the linker doesn't support writing
11431compressed debug sections, the option is rejected. Otherwise, if the
11432assembler does not support them, @option{-gz} is silently ignored when
11433producing object files.
11434
11435@item -femit-struct-debug-baseonly
11436@opindex femit-struct-debug-baseonly
11437Emit debug information for struct-like types
11438only when the base name of the compilation source file
11439matches the base name of file in which the struct is defined.
11440
11441This option substantially reduces the size of debugging information,
11442but at significant potential loss in type information to the debugger.
11443See @option{-femit-struct-debug-reduced} for a less aggressive option.
11444See @option{-femit-struct-debug-detailed} for more detailed control.
11445
11446This option works only with DWARF debug output.
11447
11448@item -femit-struct-debug-reduced
11449@opindex femit-struct-debug-reduced
11450Emit debug information for struct-like types
11451only when the base name of the compilation source file
11452matches the base name of file in which the type is defined,
11453unless the struct is a template or defined in a system header.
11454
11455This option significantly reduces the size of debugging information,
11456with some potential loss in type information to the debugger.
11457See @option{-femit-struct-debug-baseonly} for a more aggressive option.
11458See @option{-femit-struct-debug-detailed} for more detailed control.
11459
11460This option works only with DWARF debug output.
11461
11462@item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
11463@opindex femit-struct-debug-detailed
11464Specify the struct-like types
11465for which the compiler generates debug information.
11466The intent is to reduce duplicate struct debug information
11467between different object files within the same program.
11468
11469This option is a detailed version of
11470@option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
11471which serves for most needs.
11472
11473A specification has the syntax@*
11474[@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
11475
11476The optional first word limits the specification to
11477structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
11478A struct type is used directly when it is the type of a variable, member.
11479Indirect uses arise through pointers to structs.
11480That is, when use of an incomplete struct is valid, the use is indirect.
11481An example is
11482@samp{struct one direct; struct two * indirect;}.
11483
11484The optional second word limits the specification to
11485ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
11486Generic structs are a bit complicated to explain.
11487For C++, these are non-explicit specializations of template classes,
11488or non-template classes within the above.
11489Other programming languages have generics,
11490but @option{-femit-struct-debug-detailed} does not yet implement them.
11491
11492The third word specifies the source files for those
11493structs for which the compiler should emit debug information.
11494The values @samp{none} and @samp{any} have the normal meaning.
11495The value @samp{base} means that
11496the base of name of the file in which the type declaration appears
11497must match the base of the name of the main compilation file.
11498In practice, this means that when compiling @file{foo.c}, debug information
11499is generated for types declared in that file and @file{foo.h},
11500but not other header files.
11501The value @samp{sys} means those types satisfying @samp{base}
11502or declared in system or compiler headers.
11503
11504You may need to experiment to determine the best settings for your application.
11505
11506The default is @option{-femit-struct-debug-detailed=all}.
11507
11508This option works only with DWARF debug output.
11509
11510@item -fno-dwarf2-cfi-asm
11511@opindex fdwarf2-cfi-asm
11512@opindex fno-dwarf2-cfi-asm
11513Emit DWARF unwind info as compiler generated @code{.eh_frame} section
11514instead of using GAS @code{.cfi_*} directives.
11515
11516@item -fno-eliminate-unused-debug-types
11517@opindex feliminate-unused-debug-types
11518@opindex fno-eliminate-unused-debug-types
11519Normally, when producing DWARF output, GCC avoids producing debug symbol
11520output for types that are nowhere used in the source file being compiled.
11521Sometimes it is useful to have GCC emit debugging
11522information for all types declared in a compilation
11523unit, regardless of whether or not they are actually used
11524in that compilation unit, for example
11525if, in the debugger, you want to cast a value to a type that is
11526not actually used in your program (but is declared). More often,
11527however, this results in a significant amount of wasted space.
11528@end table
11529
11530@node Optimize Options
11531@section Options That Control Optimization
11532@cindex optimize options
11533@cindex options, optimization
11534
11535These options control various sorts of optimizations.
11536
11537Without any optimization option, the compiler's goal is to reduce the
11538cost of compilation and to make debugging produce the expected
11539results. Statements are independent: if you stop the program with a
11540breakpoint between statements, you can then assign a new value to any
11541variable or change the program counter to any other statement in the
11542function and get exactly the results you expect from the source
11543code.
11544
11545Turning on optimization flags makes the compiler attempt to improve
11546the performance and/or code size at the expense of compilation time
11547and possibly the ability to debug the program.
11548
11549The compiler performs optimization based on the knowledge it has of the
11550program. Compiling multiple files at once to a single output file mode allows
11551the compiler to use information gained from all of the files when compiling
11552each of them.
11553
11554Not all optimizations are controlled directly by a flag. Only
11555optimizations that have a flag are listed in this section.
11556
11557Most optimizations are completely disabled at @option{-O0} or if an
11558@option{-O} level is not set on the command line, even if individual
11559optimization flags are specified. Similarly, @option{-Og} suppresses
11560many optimization passes.
11561
11562Depending on the target and how GCC was configured, a slightly different
11563set of optimizations may be enabled at each @option{-O} level than
11564those listed here. You can invoke GCC with @option{-Q --help=optimizers}
11565to find out the exact set of optimizations that are enabled at each level.
11566@xref{Overall Options}, for examples.
11567
11568@table @gcctabopt
11569@item -O
11570@itemx -O1
11571@opindex O
11572@opindex O1
11573Optimize. Optimizing compilation takes somewhat more time, and a lot
11574more memory for a large function.
11575
11576With @option{-O}, the compiler tries to reduce code size and execution
11577time, without performing any optimizations that take a great deal of
11578compilation time.
11579
11580@c Note that in addition to the default_options_table list in opts.cc,
11581@c several optimization flags default to true but control optimization
11582@c passes that are explicitly disabled at -O0.
11583
11584@option{-O} turns on the following optimization flags:
11585
11586@c Please keep the following list alphabetized.
11587@gccoptlist{-fauto-inc-dec @gol
11588-fbranch-count-reg @gol
11589-fcombine-stack-adjustments @gol
11590-fcompare-elim @gol
11591-fcprop-registers @gol
11592-fdce @gol
11593-fdefer-pop @gol
11594-fdelayed-branch @gol
11595-fdse @gol
11596-fforward-propagate @gol
11597-fguess-branch-probability @gol
11598-fif-conversion @gol
11599-fif-conversion2 @gol
11600-finline-functions-called-once @gol
11601-fipa-modref @gol
11602-fipa-profile @gol
11603-fipa-pure-const @gol
11604-fipa-reference @gol
11605-fipa-reference-addressable @gol
11606-fmerge-constants @gol
11607-fmove-loop-invariants @gol
11608-fmove-loop-stores@gol
11609-fomit-frame-pointer @gol
11610-freorder-blocks @gol
11611-fshrink-wrap @gol
11612-fshrink-wrap-separate @gol
11613-fsplit-wide-types @gol
11614-fssa-backprop @gol
11615-fssa-phiopt @gol
11616-ftree-bit-ccp @gol
11617-ftree-ccp @gol
11618-ftree-ch @gol
11619-ftree-coalesce-vars @gol
11620-ftree-copy-prop @gol
11621-ftree-dce @gol
11622-ftree-dominator-opts @gol
11623-ftree-dse @gol
11624-ftree-forwprop @gol
11625-ftree-fre @gol
11626-ftree-phiprop @gol
11627-ftree-pta @gol
11628-ftree-scev-cprop @gol
11629-ftree-sink @gol
11630-ftree-slsr @gol
11631-ftree-sra @gol
11632-ftree-ter @gol
11633-funit-at-a-time}
11634
11635@item -O2
11636@opindex O2
11637Optimize even more. GCC performs nearly all supported optimizations
11638that do not involve a space-speed tradeoff.
11639As compared to @option{-O}, this option increases both compilation time
11640and the performance of the generated code.
11641
11642@option{-O2} turns on all optimization flags specified by @option{-O1}. It
11643also turns on the following optimization flags:
11644
11645@c Please keep the following list alphabetized!
11646@gccoptlist{-falign-functions -falign-jumps @gol
11647-falign-labels -falign-loops @gol
11648-fcaller-saves @gol
11649-fcode-hoisting @gol
11650-fcrossjumping @gol
11651-fcse-follow-jumps -fcse-skip-blocks @gol
11652-fdelete-null-pointer-checks @gol
11653-fdevirtualize -fdevirtualize-speculatively @gol
11654-fexpensive-optimizations @gol
11655-ffinite-loops @gol
11656-fgcse -fgcse-lm @gol
11657-fhoist-adjacent-loads @gol
11658-finline-functions @gol
11659-finline-small-functions @gol
11660-findirect-inlining @gol
11661-fipa-bit-cp -fipa-cp -fipa-icf @gol
11662-fipa-ra -fipa-sra -fipa-vrp @gol
11663-fisolate-erroneous-paths-dereference @gol
11664-flra-remat @gol
11665-foptimize-sibling-calls @gol
11666-foptimize-strlen @gol
11667-fpartial-inlining @gol
11668-fpeephole2 @gol
11669-freorder-blocks-algorithm=stc @gol
11670-freorder-blocks-and-partition -freorder-functions @gol
11671-frerun-cse-after-loop @gol
11672-fschedule-insns -fschedule-insns2 @gol
11673-fsched-interblock -fsched-spec @gol
11674-fstore-merging @gol
11675-fstrict-aliasing @gol
11676-fthread-jumps @gol
11677-ftree-builtin-call-dce @gol
11678-ftree-loop-vectorize @gol
11679-ftree-pre @gol
11680-ftree-slp-vectorize @gol
11681-ftree-switch-conversion -ftree-tail-merge @gol
11682-ftree-vrp @gol
11683-fvect-cost-model=very-cheap}
11684
11685Please note the warning under @option{-fgcse} about
11686invoking @option{-O2} on programs that use computed gotos.
11687
11688@item -O3
11689@opindex O3
11690Optimize yet more. @option{-O3} turns on all optimizations specified
11691by @option{-O2} and also turns on the following optimization flags:
11692
11693@c Please keep the following list alphabetized!
11694@gccoptlist{-fgcse-after-reload @gol
11695-fipa-cp-clone
11696-floop-interchange @gol
11697-floop-unroll-and-jam @gol
11698-fpeel-loops @gol
11699-fpredictive-commoning @gol
11700-fsplit-loops @gol
11701-fsplit-paths @gol
11702-ftree-loop-distribution @gol
11703-ftree-partial-pre @gol
11704-funswitch-loops @gol
11705-fvect-cost-model=dynamic @gol
11706-fversion-loops-for-strides}
11707
11708@item -O0
11709@opindex O0
11710Reduce compilation time and make debugging produce the expected
11711results. This is the default.
11712
11713@item -Os
11714@opindex Os
11715Optimize for size. @option{-Os} enables all @option{-O2} optimizations
11716except those that often increase code size:
11717
11718@gccoptlist{-falign-functions -falign-jumps @gol
11719-falign-labels -falign-loops @gol
11720-fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
11721
11722It also enables @option{-finline-functions}, causes the compiler to tune for
11723code size rather than execution speed, and performs further optimizations
11724designed to reduce code size.
11725
11726@item -Ofast
11727@opindex Ofast
11728Disregard strict standards compliance. @option{-Ofast} enables all
11729@option{-O3} optimizations. It also enables optimizations that are not
11730valid for all standard-compliant programs.
11731It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
11732and the Fortran-specific @option{-fstack-arrays}, unless
11733@option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
11734It turns off @option{-fsemantic-interposition}.
11735
11736@item -Og
11737@opindex Og
11738Optimize debugging experience. @option{-Og} should be the optimization
11739level of choice for the standard edit-compile-debug cycle, offering
11740a reasonable level of optimization while maintaining fast compilation
11741and a good debugging experience. It is a better choice than @option{-O0}
11742for producing debuggable code because some compiler passes
11743that collect debug information are disabled at @option{-O0}.
11744
11745Like @option{-O0}, @option{-Og} completely disables a number of
11746optimization passes so that individual options controlling them have
11747no effect. Otherwise @option{-Og} enables all @option{-O1}
11748optimization flags except for those that may interfere with debugging:
11749
11750@gccoptlist{-fbranch-count-reg -fdelayed-branch @gol
11751-fdse -fif-conversion -fif-conversion2 @gol
11752-finline-functions-called-once @gol
11753-fmove-loop-invariants -fmove-loop-stores -fssa-phiopt @gol
11754-ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
11755
11756@item -Oz
11757@opindex Oz
11758Optimize aggressively for size rather than speed. This may increase
11759the number of instructions executed if those instructions require
11760fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
11761including enabling most @option{-O2} optimizations.
11762
11763@end table
11764
11765If you use multiple @option{-O} options, with or without level numbers,
11766the last such option is the one that is effective.
11767
11768Options of the form @option{-f@var{flag}} specify machine-independent
11769flags. Most flags have both positive and negative forms; the negative
11770form of @option{-ffoo} is @option{-fno-foo}. In the table
11771below, only one of the forms is listed---the one you typically
11772use. You can figure out the other form by either removing @samp{no-}
11773or adding it.
11774
11775The following options control specific optimizations. They are either
11776activated by @option{-O} options or are related to ones that are. You
11777can use the following flags in the rare cases when ``fine-tuning'' of
11778optimizations to be performed is desired.
11779
11780@table @gcctabopt
11781@item -fno-defer-pop
11782@opindex fno-defer-pop
11783@opindex fdefer-pop
11784For machines that must pop arguments after a function call, always pop
11785the arguments as soon as each function returns.
11786At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
11787this allows the compiler to let arguments accumulate on the stack for several
11788function calls and pop them all at once.
11789
11790@item -fforward-propagate
11791@opindex fforward-propagate
11792Perform a forward propagation pass on RTL@. The pass tries to combine two
11793instructions and checks if the result can be simplified. If loop unrolling
11794is active, two passes are performed and the second is scheduled after
11795loop unrolling.
11796
11797This option is enabled by default at optimization levels @option{-O1},
11798@option{-O2}, @option{-O3}, @option{-Os}.
11799
11800@item -ffp-contract=@var{style}
11801@opindex ffp-contract
11802@option{-ffp-contract=off} disables floating-point expression contraction.
11803@option{-ffp-contract=fast} enables floating-point expression contraction
11804such as forming of fused multiply-add operations if the target has
11805native support for them.
11806@option{-ffp-contract=on} enables floating-point expression contraction
11807if allowed by the language standard. This is currently not implemented
11808and treated equal to @option{-ffp-contract=off}.
11809
11810The default is @option{-ffp-contract=fast}.
11811
11812@item -fomit-frame-pointer
11813@opindex fomit-frame-pointer
11814Omit the frame pointer in functions that don't need one. This avoids the
11815instructions to save, set up and restore the frame pointer; on many targets
11816it also makes an extra register available.
11817
11818On some targets this flag has no effect because the standard calling sequence
11819always uses a frame pointer, so it cannot be omitted.
11820
11821Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
11822is used in all functions. Several targets always omit the frame pointer in
11823leaf functions.
11824
11825Enabled by default at @option{-O1} and higher.
11826
11827@item -foptimize-sibling-calls
11828@opindex foptimize-sibling-calls
11829Optimize sibling and tail recursive calls.
11830
11831Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11832
11833@item -foptimize-strlen
11834@opindex foptimize-strlen
11835Optimize various standard C string functions (e.g.@: @code{strlen},
11836@code{strchr} or @code{strcpy}) and
11837their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
11838
11839Enabled at levels @option{-O2}, @option{-O3}.
11840
11841@item -fno-inline
11842@opindex fno-inline
11843@opindex finline
11844Do not expand any functions inline apart from those marked with
11845the @code{always_inline} attribute. This is the default when not
11846optimizing.
11847
11848Single functions can be exempted from inlining by marking them
11849with the @code{noinline} attribute.
11850
11851@item -finline-small-functions
11852@opindex finline-small-functions
11853Integrate functions into their callers when their body is smaller than expected
11854function call code (so overall size of program gets smaller). The compiler
11855heuristically decides which functions are simple enough to be worth integrating
11856in this way. This inlining applies to all functions, even those not declared
11857inline.
11858
11859Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11860
11861@item -findirect-inlining
11862@opindex findirect-inlining
11863Inline also indirect calls that are discovered to be known at compile
11864time thanks to previous inlining. This option has any effect only
11865when inlining itself is turned on by the @option{-finline-functions}
11866or @option{-finline-small-functions} options.
11867
11868Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11869
11870@item -finline-functions
11871@opindex finline-functions
11872Consider all functions for inlining, even if they are not declared inline.
11873The compiler heuristically decides which functions are worth integrating
11874in this way.
11875
11876If all calls to a given function are integrated, and the function is
11877declared @code{static}, then the function is normally not output as
11878assembler code in its own right.
11879
11880Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
11881by @option{-fprofile-use} and @option{-fauto-profile}.
11882
11883@item -finline-functions-called-once
11884@opindex finline-functions-called-once
11885Consider all @code{static} functions called once for inlining into their
11886caller even if they are not marked @code{inline}. If a call to a given
11887function is integrated, then the function is not output as assembler code
11888in its own right.
11889
11890Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
11891but not @option{-Og}.
11892
11893@item -fearly-inlining
11894@opindex fearly-inlining
11895Inline functions marked by @code{always_inline} and functions whose body seems
11896smaller than the function call overhead early before doing
11897@option{-fprofile-generate} instrumentation and real inlining pass. Doing so
11898makes profiling significantly cheaper and usually inlining faster on programs
11899having large chains of nested wrapper functions.
11900
11901Enabled by default.
11902
11903@item -fipa-sra
11904@opindex fipa-sra
11905Perform interprocedural scalar replacement of aggregates, removal of
11906unused parameters and replacement of parameters passed by reference
11907by parameters passed by value.
11908
11909Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
11910
11911@item -finline-limit=@var{n}
11912@opindex finline-limit
11913By default, GCC limits the size of functions that can be inlined. This flag
11914allows coarse control of this limit. @var{n} is the size of functions that
11915can be inlined in number of pseudo instructions.
11916
11917Inlining is actually controlled by a number of parameters, which may be
11918specified individually by using @option{--param @var{name}=@var{value}}.
11919The @option{-finline-limit=@var{n}} option sets some of these parameters
11920as follows:
11921
11922@table @gcctabopt
11923@item max-inline-insns-single
11924is set to @var{n}/2.
11925@item max-inline-insns-auto
11926is set to @var{n}/2.
11927@end table
11928
11929See below for a documentation of the individual
11930parameters controlling inlining and for the defaults of these parameters.
11931
11932@emph{Note:} there may be no value to @option{-finline-limit} that results
11933in default behavior.
11934
11935@emph{Note:} pseudo instruction represents, in this particular context, an
11936abstract measurement of function's size. In no way does it represent a count
11937of assembly instructions and as such its exact meaning might change from one
11938release to an another.
11939
11940@item -fno-keep-inline-dllexport
11941@opindex fno-keep-inline-dllexport
11942@opindex fkeep-inline-dllexport
11943This is a more fine-grained version of @option{-fkeep-inline-functions},
11944which applies only to functions that are declared using the @code{dllexport}
11945attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
11946Functions}.
11947
11948@item -fkeep-inline-functions
11949@opindex fkeep-inline-functions
11950In C, emit @code{static} functions that are declared @code{inline}
11951into the object file, even if the function has been inlined into all
11952of its callers. This switch does not affect functions using the
11953@code{extern inline} extension in GNU C90@. In C++, emit any and all
11954inline functions into the object file.
11955
11956@item -fkeep-static-functions
11957@opindex fkeep-static-functions
11958Emit @code{static} functions into the object file, even if the function
11959is never used.
11960
11961@item -fkeep-static-consts
11962@opindex fkeep-static-consts
11963Emit variables declared @code{static const} when optimization isn't turned
11964on, even if the variables aren't referenced.
11965
11966GCC enables this option by default. If you want to force the compiler to
11967check if a variable is referenced, regardless of whether or not
11968optimization is turned on, use the @option{-fno-keep-static-consts} option.
11969
11970@item -fmerge-constants
11971@opindex fmerge-constants
11972Attempt to merge identical constants (string constants and floating-point
11973constants) across compilation units.
11974
11975This option is the default for optimized compilation if the assembler and
11976linker support it. Use @option{-fno-merge-constants} to inhibit this
11977behavior.
11978
11979Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
11980
11981@item -fmerge-all-constants
11982@opindex fmerge-all-constants
11983Attempt to merge identical constants and identical variables.
11984
11985This option implies @option{-fmerge-constants}. In addition to
11986@option{-fmerge-constants} this considers e.g.@: even constant initialized
11987arrays or initialized constant variables with integral or floating-point
11988types. Languages like C or C++ require each variable, including multiple
11989instances of the same variable in recursive calls, to have distinct locations,
11990so using this option results in non-conforming
11991behavior.
11992
11993@item -fmodulo-sched
11994@opindex fmodulo-sched
11995Perform swing modulo scheduling immediately before the first scheduling
11996pass. This pass looks at innermost loops and reorders their
11997instructions by overlapping different iterations.
11998
11999@item -fmodulo-sched-allow-regmoves
12000@opindex fmodulo-sched-allow-regmoves
12001Perform more aggressive SMS-based modulo scheduling with register moves
12002allowed. By setting this flag certain anti-dependences edges are
12003deleted, which triggers the generation of reg-moves based on the
12004life-range analysis. This option is effective only with
12005@option{-fmodulo-sched} enabled.
12006
12007@item -fno-branch-count-reg
12008@opindex fno-branch-count-reg
12009@opindex fbranch-count-reg
12010Disable the optimization pass that scans for opportunities to use
12011``decrement and branch'' instructions on a count register instead of
12012instruction sequences that decrement a register, compare it against zero, and
12013then branch based upon the result. This option is only meaningful on
12014architectures that support such instructions, which include x86, PowerPC,
12015IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
12016doesn't remove the decrement and branch instructions from the generated
12017instruction stream introduced by other optimization passes.
12018
12019The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
12020except for @option{-Og}.
12021
12022@item -fno-function-cse
12023@opindex fno-function-cse
12024@opindex ffunction-cse
12025Do not put function addresses in registers; make each instruction that
12026calls a constant function contain the function's address explicitly.
12027
12028This option results in less efficient code, but some strange hacks
12029that alter the assembler output may be confused by the optimizations
12030performed when this option is not used.
12031
12032The default is @option{-ffunction-cse}
12033
12034@item -fno-zero-initialized-in-bss
12035@opindex fno-zero-initialized-in-bss
12036@opindex fzero-initialized-in-bss
12037If the target supports a BSS section, GCC by default puts variables that
12038are initialized to zero into BSS@. This can save space in the resulting
12039code.
12040
12041This option turns off this behavior because some programs explicitly
12042rely on variables going to the data section---e.g., so that the
12043resulting executable can find the beginning of that section and/or make
12044assumptions based on that.
12045
12046The default is @option{-fzero-initialized-in-bss}.
12047
12048@item -fthread-jumps
12049@opindex fthread-jumps
12050Perform optimizations that check to see if a jump branches to a
12051location where another comparison subsumed by the first is found. If
12052so, the first branch is redirected to either the destination of the
12053second branch or a point immediately following it, depending on whether
12054the condition is known to be true or false.
12055
12056Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12057
12058@item -fsplit-wide-types
12059@opindex fsplit-wide-types
12060When using a type that occupies multiple registers, such as @code{long
12061long} on a 32-bit system, split the registers apart and allocate them
12062independently. This normally generates better code for those types,
12063but may make debugging more difficult.
12064
12065Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
12066@option{-Os}.
12067
12068@item -fsplit-wide-types-early
12069@opindex fsplit-wide-types-early
12070Fully split wide types early, instead of very late.
12071This option has no effect unless @option{-fsplit-wide-types} is turned on.
12072
12073This is the default on some targets.
12074
12075@item -fcse-follow-jumps
12076@opindex fcse-follow-jumps
12077In common subexpression elimination (CSE), scan through jump instructions
12078when the target of the jump is not reached by any other path. For
12079example, when CSE encounters an @code{if} statement with an
12080@code{else} clause, CSE follows the jump when the condition
12081tested is false.
12082
12083Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12084
12085@item -fcse-skip-blocks
12086@opindex fcse-skip-blocks
12087This is similar to @option{-fcse-follow-jumps}, but causes CSE to
12088follow jumps that conditionally skip over blocks. When CSE
12089encounters a simple @code{if} statement with no else clause,
12090@option{-fcse-skip-blocks} causes CSE to follow the jump around the
12091body of the @code{if}.
12092
12093Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12094
12095@item -frerun-cse-after-loop
12096@opindex frerun-cse-after-loop
12097Re-run common subexpression elimination after loop optimizations are
12098performed.
12099
12100Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12101
12102@item -fgcse
12103@opindex fgcse
12104Perform a global common subexpression elimination pass.
12105This pass also performs global constant and copy propagation.
12106
12107@emph{Note:} When compiling a program using computed gotos, a GCC
12108extension, you may get better run-time performance if you disable
12109the global common subexpression elimination pass by adding
12110@option{-fno-gcse} to the command line.
12111
12112Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12113
12114@item -fgcse-lm
12115@opindex fgcse-lm
12116When @option{-fgcse-lm} is enabled, global common subexpression elimination
12117attempts to move loads that are only killed by stores into themselves. This
12118allows a loop containing a load/store sequence to be changed to a load outside
12119the loop, and a copy/store within the loop.
12120
12121Enabled by default when @option{-fgcse} is enabled.
12122
12123@item -fgcse-sm
12124@opindex fgcse-sm
12125When @option{-fgcse-sm} is enabled, a store motion pass is run after
12126global common subexpression elimination. This pass attempts to move
12127stores out of loops. When used in conjunction with @option{-fgcse-lm},
12128loops containing a load/store sequence can be changed to a load before
12129the loop and a store after the loop.
12130
12131Not enabled at any optimization level.
12132
12133@item -fgcse-las
12134@opindex fgcse-las
12135When @option{-fgcse-las} is enabled, the global common subexpression
12136elimination pass eliminates redundant loads that come after stores to the
12137same memory location (both partial and full redundancies).
12138
12139Not enabled at any optimization level.
12140
12141@item -fgcse-after-reload
12142@opindex fgcse-after-reload
12143When @option{-fgcse-after-reload} is enabled, a redundant load elimination
12144pass is performed after reload. The purpose of this pass is to clean up
12145redundant spilling.
12146
12147Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
12148
12149@item -faggressive-loop-optimizations
12150@opindex faggressive-loop-optimizations
12151This option tells the loop optimizer to use language constraints to
12152derive bounds for the number of iterations of a loop. This assumes that
12153loop code does not invoke undefined behavior by for example causing signed
12154integer overflows or out-of-bound array accesses. The bounds for the
12155number of iterations of a loop are used to guide loop unrolling and peeling
12156and loop exit test optimizations.
12157This option is enabled by default.
12158
12159@item -funconstrained-commons
12160@opindex funconstrained-commons
12161This option tells the compiler that variables declared in common blocks
12162(e.g.@: Fortran) may later be overridden with longer trailing arrays. This
12163prevents certain optimizations that depend on knowing the array bounds.
12164
12165@item -fcrossjumping
12166@opindex fcrossjumping
12167Perform cross-jumping transformation.
12168This transformation unifies equivalent code and saves code size. The
12169resulting code may or may not perform better than without cross-jumping.
12170
12171Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12172
12173@item -fauto-inc-dec
12174@opindex fauto-inc-dec
12175Combine increments or decrements of addresses with memory accesses.
12176This pass is always skipped on architectures that do not have
12177instructions to support this. Enabled by default at @option{-O1} and
12178higher on architectures that support this.
12179
12180@item -fdce
12181@opindex fdce
12182Perform dead code elimination (DCE) on RTL@.
12183Enabled by default at @option{-O1} and higher.
12184
12185@item -fdse
12186@opindex fdse
12187Perform dead store elimination (DSE) on RTL@.
12188Enabled by default at @option{-O1} and higher.
12189
12190@item -fif-conversion
12191@opindex fif-conversion
12192Attempt to transform conditional jumps into branch-less equivalents. This
12193includes use of conditional moves, min, max, set flags and abs instructions, and
12194some tricks doable by standard arithmetics. The use of conditional execution
12195on chips where it is available is controlled by @option{-fif-conversion2}.
12196
12197Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12198not with @option{-Og}.
12199
12200@item -fif-conversion2
12201@opindex fif-conversion2
12202Use conditional execution (where available) to transform conditional jumps into
12203branch-less equivalents.
12204
12205Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12206not with @option{-Og}.
12207
12208@item -fdeclone-ctor-dtor
12209@opindex fdeclone-ctor-dtor
12210The C++ ABI requires multiple entry points for constructors and
12211destructors: one for a base subobject, one for a complete object, and
12212one for a virtual destructor that calls operator delete afterwards.
12213For a hierarchy with virtual bases, the base and complete variants are
12214clones, which means two copies of the function. With this option, the
12215base and complete variants are changed to be thunks that call a common
12216implementation.
12217
12218Enabled by @option{-Os}.
12219
12220@item -fdelete-null-pointer-checks
12221@opindex fdelete-null-pointer-checks
12222Assume that programs cannot safely dereference null pointers, and that
12223no code or data element resides at address zero.
12224This option enables simple constant
12225folding optimizations at all optimization levels. In addition, other
12226optimization passes in GCC use this flag to control global dataflow
12227analyses that eliminate useless checks for null pointers; these assume
12228that a memory access to address zero always results in a trap, so
12229that if a pointer is checked after it has already been dereferenced,
12230it cannot be null.
12231
12232Note however that in some environments this assumption is not true.
12233Use @option{-fno-delete-null-pointer-checks} to disable this optimization
12234for programs that depend on that behavior.
12235
12236This option is enabled by default on most targets. On Nios II ELF, it
12237defaults to off. On AVR and MSP430, this option is completely disabled.
12238
12239Passes that use the dataflow information
12240are enabled independently at different optimization levels.
12241
12242@item -fdevirtualize
12243@opindex fdevirtualize
12244Attempt to convert calls to virtual functions to direct calls. This
12245is done both within a procedure and interprocedurally as part of
12246indirect inlining (@option{-findirect-inlining}) and interprocedural constant
12247propagation (@option{-fipa-cp}).
12248Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12249
12250@item -fdevirtualize-speculatively
12251@opindex fdevirtualize-speculatively
12252Attempt to convert calls to virtual functions to speculative direct calls.
12253Based on the analysis of the type inheritance graph, determine for a given call
12254the set of likely targets. If the set is small, preferably of size 1, change
12255the call into a conditional deciding between direct and indirect calls. The
12256speculative calls enable more optimizations, such as inlining. When they seem
12257useless after further optimization, they are converted back into original form.
12258
12259@item -fdevirtualize-at-ltrans
12260@opindex fdevirtualize-at-ltrans
12261Stream extra information needed for aggressive devirtualization when running
12262the link-time optimizer in local transformation mode.
12263This option enables more devirtualization but
12264significantly increases the size of streamed data. For this reason it is
12265disabled by default.
12266
12267@item -fexpensive-optimizations
12268@opindex fexpensive-optimizations
12269Perform a number of minor optimizations that are relatively expensive.
12270
12271Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12272
12273@item -free
12274@opindex free
12275Attempt to remove redundant extension instructions. This is especially
12276helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
12277registers after writing to their lower 32-bit half.
12278
12279Enabled for Alpha, AArch64 and x86 at levels @option{-O2},
12280@option{-O3}, @option{-Os}.
12281
12282@item -fno-lifetime-dse
12283@opindex fno-lifetime-dse
12284@opindex flifetime-dse
12285In C++ the value of an object is only affected by changes within its
12286lifetime: when the constructor begins, the object has an indeterminate
12287value, and any changes during the lifetime of the object are dead when
12288the object is destroyed. Normally dead store elimination will take
12289advantage of this; if your code relies on the value of the object
12290storage persisting beyond the lifetime of the object, you can use this
12291flag to disable this optimization. To preserve stores before the
12292constructor starts (e.g.@: because your operator new clears the object
12293storage) but still treat the object as dead after the destructor, you
12294can use @option{-flifetime-dse=1}. The default behavior can be
12295explicitly selected with @option{-flifetime-dse=2}.
12296@option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
12297
12298@item -flive-range-shrinkage
12299@opindex flive-range-shrinkage
12300Attempt to decrease register pressure through register live range
12301shrinkage. This is helpful for fast processors with small or moderate
12302size register sets.
12303
12304@item -fira-algorithm=@var{algorithm}
12305@opindex fira-algorithm
12306Use the specified coloring algorithm for the integrated register
12307allocator. The @var{algorithm} argument can be @samp{priority}, which
12308specifies Chow's priority coloring, or @samp{CB}, which specifies
12309Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
12310for all architectures, but for those targets that do support it, it is
12311the default because it generates better code.
12312
12313@item -fira-region=@var{region}
12314@opindex fira-region
12315Use specified regions for the integrated register allocator. The
12316@var{region} argument should be one of the following:
12317
12318@table @samp
12319
12320@item all
12321Use all loops as register allocation regions.
12322This can give the best results for machines with a small and/or
12323irregular register set.
12324
12325@item mixed
12326Use all loops except for loops with small register pressure
12327as the regions. This value usually gives
12328the best results in most cases and for most architectures,
12329and is enabled by default when compiling with optimization for speed
12330(@option{-O}, @option{-O2}, @dots{}).
12331
12332@item one
12333Use all functions as a single region.
12334This typically results in the smallest code size, and is enabled by default for
12335@option{-Os} or @option{-O0}.
12336
12337@end table
12338
12339@item -fira-hoist-pressure
12340@opindex fira-hoist-pressure
12341Use IRA to evaluate register pressure in the code hoisting pass for
12342decisions to hoist expressions. This option usually results in smaller
12343code, but it can slow the compiler down.
12344
12345This option is enabled at level @option{-Os} for all targets.
12346
12347@item -fira-loop-pressure
12348@opindex fira-loop-pressure
12349Use IRA to evaluate register pressure in loops for decisions to move
12350loop invariants. This option usually results in generation
12351of faster and smaller code on machines with large register files (>= 32
12352registers), but it can slow the compiler down.
12353
12354This option is enabled at level @option{-O3} for some targets.
12355
12356@item -fno-ira-share-save-slots
12357@opindex fno-ira-share-save-slots
12358@opindex fira-share-save-slots
12359Disable sharing of stack slots used for saving call-used hard
12360registers living through a call. Each hard register gets a
12361separate stack slot, and as a result function stack frames are
12362larger.
12363
12364@item -fno-ira-share-spill-slots
12365@opindex fno-ira-share-spill-slots
12366@opindex fira-share-spill-slots
12367Disable sharing of stack slots allocated for pseudo-registers. Each
12368pseudo-register that does not get a hard register gets a separate
12369stack slot, and as a result function stack frames are larger.
12370
12371@item -flra-remat
12372@opindex flra-remat
12373Enable CFG-sensitive rematerialization in LRA. Instead of loading
12374values of spilled pseudos, LRA tries to rematerialize (recalculate)
12375values if it is profitable.
12376
12377Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12378
12379@item -fdelayed-branch
12380@opindex fdelayed-branch
12381If supported for the target machine, attempt to reorder instructions
12382to exploit instruction slots available after delayed branch
12383instructions.
12384
12385Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
12386but not at @option{-Og}.
12387
12388@item -fschedule-insns
12389@opindex fschedule-insns
12390If supported for the target machine, attempt to reorder instructions to
12391eliminate execution stalls due to required data being unavailable. This
12392helps machines that have slow floating point or memory load instructions
12393by allowing other instructions to be issued until the result of the load
12394or floating-point instruction is required.
12395
12396Enabled at levels @option{-O2}, @option{-O3}.
12397
12398@item -fschedule-insns2
12399@opindex fschedule-insns2
12400Similar to @option{-fschedule-insns}, but requests an additional pass of
12401instruction scheduling after register allocation has been done. This is
12402especially useful on machines with a relatively small number of
12403registers and where memory load instructions take more than one cycle.
12404
12405Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12406
12407@item -fno-sched-interblock
12408@opindex fno-sched-interblock
12409@opindex fsched-interblock
12410Disable instruction scheduling across basic blocks, which
12411is normally enabled when scheduling before register allocation, i.e.@:
12412with @option{-fschedule-insns} or at @option{-O2} or higher.
12413
12414@item -fno-sched-spec
12415@opindex fno-sched-spec
12416@opindex fsched-spec
12417Disable speculative motion of non-load instructions, which
12418is normally enabled when scheduling before register allocation, i.e.@:
12419with @option{-fschedule-insns} or at @option{-O2} or higher.
12420
12421@item -fsched-pressure
12422@opindex fsched-pressure
12423Enable register pressure sensitive insn scheduling before register
12424allocation. This only makes sense when scheduling before register
12425allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
12426@option{-O2} or higher. Usage of this option can improve the
12427generated code and decrease its size by preventing register pressure
12428increase above the number of available hard registers and subsequent
12429spills in register allocation.
12430
12431@item -fsched-spec-load
12432@opindex fsched-spec-load
12433Allow speculative motion of some load instructions. This only makes
12434sense when scheduling before register allocation, i.e.@: with
12435@option{-fschedule-insns} or at @option{-O2} or higher.
12436
12437@item -fsched-spec-load-dangerous
12438@opindex fsched-spec-load-dangerous
12439Allow speculative motion of more load instructions. This only makes
12440sense when scheduling before register allocation, i.e.@: with
12441@option{-fschedule-insns} or at @option{-O2} or higher.
12442
12443@item -fsched-stalled-insns
12444@itemx -fsched-stalled-insns=@var{n}
12445@opindex fsched-stalled-insns
12446Define how many insns (if any) can be moved prematurely from the queue
12447of stalled insns into the ready list during the second scheduling pass.
12448@option{-fno-sched-stalled-insns} means that no insns are moved
12449prematurely, @option{-fsched-stalled-insns=0} means there is no limit
12450on how many queued insns can be moved prematurely.
12451@option{-fsched-stalled-insns} without a value is equivalent to
12452@option{-fsched-stalled-insns=1}.
12453
12454@item -fsched-stalled-insns-dep
12455@itemx -fsched-stalled-insns-dep=@var{n}
12456@opindex fsched-stalled-insns-dep
12457Define how many insn groups (cycles) are examined for a dependency
12458on a stalled insn that is a candidate for premature removal from the queue
12459of stalled insns. This has an effect only during the second scheduling pass,
12460and only if @option{-fsched-stalled-insns} is used.
12461@option{-fno-sched-stalled-insns-dep} is equivalent to
12462@option{-fsched-stalled-insns-dep=0}.
12463@option{-fsched-stalled-insns-dep} without a value is equivalent to
12464@option{-fsched-stalled-insns-dep=1}.
12465
12466@item -fsched2-use-superblocks
12467@opindex fsched2-use-superblocks
12468When scheduling after register allocation, use superblock scheduling.
12469This allows motion across basic block boundaries,
12470resulting in faster schedules. This option is experimental, as not all machine
12471descriptions used by GCC model the CPU closely enough to avoid unreliable
12472results from the algorithm.
12473
12474This only makes sense when scheduling after register allocation, i.e.@: with
12475@option{-fschedule-insns2} or at @option{-O2} or higher.
12476
12477@item -fsched-group-heuristic
12478@opindex fsched-group-heuristic
12479Enable the group heuristic in the scheduler. This heuristic favors
12480the instruction that belongs to a schedule group. This is enabled
12481by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12482or @option{-fschedule-insns2} or at @option{-O2} or higher.
12483
12484@item -fsched-critical-path-heuristic
12485@opindex fsched-critical-path-heuristic
12486Enable the critical-path heuristic in the scheduler. This heuristic favors
12487instructions on the critical path. This is enabled by default when
12488scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12489or @option{-fschedule-insns2} or at @option{-O2} or higher.
12490
12491@item -fsched-spec-insn-heuristic
12492@opindex fsched-spec-insn-heuristic
12493Enable the speculative instruction heuristic in the scheduler. This
12494heuristic favors speculative instructions with greater dependency weakness.
12495This is enabled by default when scheduling is enabled, i.e.@:
12496with @option{-fschedule-insns} or @option{-fschedule-insns2}
12497or at @option{-O2} or higher.
12498
12499@item -fsched-rank-heuristic
12500@opindex fsched-rank-heuristic
12501Enable the rank heuristic in the scheduler. This heuristic favors
12502the instruction belonging to a basic block with greater size or frequency.
12503This is enabled by default when scheduling is enabled, i.e.@:
12504with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12505at @option{-O2} or higher.
12506
12507@item -fsched-last-insn-heuristic
12508@opindex fsched-last-insn-heuristic
12509Enable the last-instruction heuristic in the scheduler. This heuristic
12510favors the instruction that is less dependent on the last instruction
12511scheduled. This is enabled by default when scheduling is enabled,
12512i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12513at @option{-O2} or higher.
12514
12515@item -fsched-dep-count-heuristic
12516@opindex fsched-dep-count-heuristic
12517Enable the dependent-count heuristic in the scheduler. This heuristic
12518favors the instruction that has more instructions depending on it.
12519This is enabled by default when scheduling is enabled, i.e.@:
12520with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12521at @option{-O2} or higher.
12522
12523@item -freschedule-modulo-scheduled-loops
12524@opindex freschedule-modulo-scheduled-loops
12525Modulo scheduling is performed before traditional scheduling. If a loop
12526is modulo scheduled, later scheduling passes may change its schedule.
12527Use this option to control that behavior.
12528
12529@item -fselective-scheduling
12530@opindex fselective-scheduling
12531Schedule instructions using selective scheduling algorithm. Selective
12532scheduling runs instead of the first scheduler pass.
12533
12534@item -fselective-scheduling2
12535@opindex fselective-scheduling2
12536Schedule instructions using selective scheduling algorithm. Selective
12537scheduling runs instead of the second scheduler pass.
12538
12539@item -fsel-sched-pipelining
12540@opindex fsel-sched-pipelining
12541Enable software pipelining of innermost loops during selective scheduling.
12542This option has no effect unless one of @option{-fselective-scheduling} or
12543@option{-fselective-scheduling2} is turned on.
12544
12545@item -fsel-sched-pipelining-outer-loops
12546@opindex fsel-sched-pipelining-outer-loops
12547When pipelining loops during selective scheduling, also pipeline outer loops.
12548This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
12549
12550@item -fsemantic-interposition
12551@opindex fsemantic-interposition
12552Some object formats, like ELF, allow interposing of symbols by the
12553dynamic linker.
12554This means that for symbols exported from the DSO, the compiler cannot perform
12555interprocedural propagation, inlining and other optimizations in anticipation
12556that the function or variable in question may change. While this feature is
12557useful, for example, to rewrite memory allocation functions by a debugging
12558implementation, it is expensive in the terms of code quality.
12559With @option{-fno-semantic-interposition} the compiler assumes that
12560if interposition happens for functions the overwriting function will have
12561precisely the same semantics (and side effects).
12562Similarly if interposition happens
12563for variables, the constructor of the variable will be the same. The flag
12564has no effect for functions explicitly declared inline
12565(where it is never allowed for interposition to change semantics)
12566and for symbols explicitly declared weak.
12567
12568@item -fshrink-wrap
12569@opindex fshrink-wrap
12570Emit function prologues only before parts of the function that need it,
12571rather than at the top of the function. This flag is enabled by default at
12572@option{-O} and higher.
12573
12574@item -fshrink-wrap-separate
12575@opindex fshrink-wrap-separate
12576Shrink-wrap separate parts of the prologue and epilogue separately, so that
12577those parts are only executed when needed.
12578This option is on by default, but has no effect unless @option{-fshrink-wrap}
12579is also turned on and the target supports this.
12580
12581@item -fcaller-saves
12582@opindex fcaller-saves
12583Enable allocation of values to registers that are clobbered by
12584function calls, by emitting extra instructions to save and restore the
12585registers around such calls. Such allocation is done only when it
12586seems to result in better code.
12587
12588This option is always enabled by default on certain machines, usually
12589those which have no call-preserved registers to use instead.
12590
12591Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12592
12593@item -fcombine-stack-adjustments
12594@opindex fcombine-stack-adjustments
12595Tracks stack adjustments (pushes and pops) and stack memory references
12596and then tries to find ways to combine them.
12597
12598Enabled by default at @option{-O1} and higher.
12599
12600@item -fipa-ra
12601@opindex fipa-ra
12602Use caller save registers for allocation if those registers are not used by
12603any called function. In that case it is not necessary to save and restore
12604them around calls. This is only possible if called functions are part of
12605same compilation unit as current function and they are compiled before it.
12606
12607Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
12608is disabled if generated code will be instrumented for profiling
12609(@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
12610exactly (this happens on targets that do not expose prologues
12611and epilogues in RTL).
12612
12613@item -fconserve-stack
12614@opindex fconserve-stack
12615Attempt to minimize stack usage. The compiler attempts to use less
12616stack space, even if that makes the program slower. This option
12617implies setting the @option{large-stack-frame} parameter to 100
12618and the @option{large-stack-frame-growth} parameter to 400.
12619
12620@item -ftree-reassoc
12621@opindex ftree-reassoc
12622Perform reassociation on trees. This flag is enabled by default
12623at @option{-O1} and higher.
12624
12625@item -fcode-hoisting
12626@opindex fcode-hoisting
12627Perform code hoisting. Code hoisting tries to move the
12628evaluation of expressions executed on all paths to the function exit
12629as early as possible. This is especially useful as a code size
12630optimization, but it often helps for code speed as well.
12631This flag is enabled by default at @option{-O2} and higher.
12632
12633@item -ftree-pre
12634@opindex ftree-pre
12635Perform partial redundancy elimination (PRE) on trees. This flag is
12636enabled by default at @option{-O2} and @option{-O3}.
12637
12638@item -ftree-partial-pre
12639@opindex ftree-partial-pre
12640Make partial redundancy elimination (PRE) more aggressive. This flag is
12641enabled by default at @option{-O3}.
12642
12643@item -ftree-forwprop
12644@opindex ftree-forwprop
12645Perform forward propagation on trees. This flag is enabled by default
12646at @option{-O1} and higher.
12647
12648@item -ftree-fre
12649@opindex ftree-fre
12650Perform full redundancy elimination (FRE) on trees. The difference
12651between FRE and PRE is that FRE only considers expressions
12652that are computed on all paths leading to the redundant computation.
12653This analysis is faster than PRE, though it exposes fewer redundancies.
12654This flag is enabled by default at @option{-O1} and higher.
12655
12656@item -ftree-phiprop
12657@opindex ftree-phiprop
12658Perform hoisting of loads from conditional pointers on trees. This
12659pass is enabled by default at @option{-O1} and higher.
12660
12661@item -fhoist-adjacent-loads
12662@opindex fhoist-adjacent-loads
12663Speculatively hoist loads from both branches of an if-then-else if the
12664loads are from adjacent locations in the same structure and the target
12665architecture has a conditional move instruction. This flag is enabled
12666by default at @option{-O2} and higher.
12667
12668@item -ftree-copy-prop
12669@opindex ftree-copy-prop
12670Perform copy propagation on trees. This pass eliminates unnecessary
12671copy operations. This flag is enabled by default at @option{-O1} and
12672higher.
12673
12674@item -fipa-pure-const
12675@opindex fipa-pure-const
12676Discover which functions are pure or constant.
12677Enabled by default at @option{-O1} and higher.
12678
12679@item -fipa-reference
12680@opindex fipa-reference
12681Discover which static variables do not escape the
12682compilation unit.
12683Enabled by default at @option{-O1} and higher.
12684
12685@item -fipa-reference-addressable
12686@opindex fipa-reference-addressable
12687Discover read-only, write-only and non-addressable static variables.
12688Enabled by default at @option{-O1} and higher.
12689
12690@item -fipa-stack-alignment
12691@opindex fipa-stack-alignment
12692Reduce stack alignment on call sites if possible.
12693Enabled by default.
12694
12695@item -fipa-pta
12696@opindex fipa-pta
12697Perform interprocedural pointer analysis and interprocedural modification
12698and reference analysis. This option can cause excessive memory and
12699compile-time usage on large compilation units. It is not enabled by
12700default at any optimization level.
12701
12702@item -fipa-profile
12703@opindex fipa-profile
12704Perform interprocedural profile propagation. The functions called only from
12705cold functions are marked as cold. Also functions executed once (such as
12706@code{cold}, @code{noreturn}, static constructors or destructors) are
12707identified. Cold functions and loop less parts of functions executed once are
12708then optimized for size.
12709Enabled by default at @option{-O1} and higher.
12710
12711@item -fipa-modref
12712@opindex fipa-modref
12713Perform interprocedural mod/ref analysis. This optimization analyzes the side
12714effects of functions (memory locations that are modified or referenced) and
12715enables better optimization across the function call boundary. This flag is
12716enabled by default at @option{-O1} and higher.
12717
12718@item -fipa-cp
12719@opindex fipa-cp
12720Perform interprocedural constant propagation.
12721This optimization analyzes the program to determine when values passed
12722to functions are constants and then optimizes accordingly.
12723This optimization can substantially increase performance
12724if the application has constants passed to functions.
12725This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
12726It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12727
12728@item -fipa-cp-clone
12729@opindex fipa-cp-clone
12730Perform function cloning to make interprocedural constant propagation stronger.
12731When enabled, interprocedural constant propagation performs function cloning
12732when externally visible function can be called with constant arguments.
12733Because this optimization can create multiple copies of functions,
12734it may significantly increase code size
12735(see @option{--param ipa-cp-unit-growth=@var{value}}).
12736This flag is enabled by default at @option{-O3}.
12737It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12738
12739@item -fipa-bit-cp
12740@opindex fipa-bit-cp
12741When enabled, perform interprocedural bitwise constant
12742propagation. This flag is enabled by default at @option{-O2} and
12743by @option{-fprofile-use} and @option{-fauto-profile}.
12744It requires that @option{-fipa-cp} is enabled.
12745
12746@item -fipa-vrp
12747@opindex fipa-vrp
12748When enabled, perform interprocedural propagation of value
12749ranges. This flag is enabled by default at @option{-O2}. It requires
12750that @option{-fipa-cp} is enabled.
12751
12752@item -fipa-icf
12753@opindex fipa-icf
12754Perform Identical Code Folding for functions and read-only variables.
12755The optimization reduces code size and may disturb unwind stacks by replacing
12756a function by equivalent one with a different name. The optimization works
12757more effectively with link-time optimization enabled.
12758
12759Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
12760works on different levels and thus the optimizations are not same - there are
12761equivalences that are found only by GCC and equivalences found only by Gold.
12762
12763This flag is enabled by default at @option{-O2} and @option{-Os}.
12764
12765@item -flive-patching=@var{level}
12766@opindex flive-patching
12767Control GCC's optimizations to produce output suitable for live-patching.
12768
12769If the compiler's optimization uses a function's body or information extracted
12770from its body to optimize/change another function, the latter is called an
12771impacted function of the former. If a function is patched, its impacted
12772functions should be patched too.
12773
12774The impacted functions are determined by the compiler's interprocedural
12775optimizations. For example, a caller is impacted when inlining a function
12776into its caller,
12777cloning a function and changing its caller to call this new clone,
12778or extracting a function's pureness/constness information to optimize
12779its direct or indirect callers, etc.
12780
12781Usually, the more IPA optimizations enabled, the larger the number of
12782impacted functions for each function. In order to control the number of
12783impacted functions and more easily compute the list of impacted function,
12784IPA optimizations can be partially enabled at two different levels.
12785
12786The @var{level} argument should be one of the following:
12787
12788@table @samp
12789
12790@item inline-clone
12791
12792Only enable inlining and cloning optimizations, which includes inlining,
12793cloning, interprocedural scalar replacement of aggregates and partial inlining.
12794As a result, when patching a function, all its callers and its clones'
12795callers are impacted, therefore need to be patched as well.
12796
12797@option{-flive-patching=inline-clone} disables the following optimization flags:
12798@gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra @gol
12799-fipa-icf -fipa-icf-functions -fipa-icf-variables @gol
12800-fipa-bit-cp -fipa-vrp -fipa-pure-const -fipa-reference-addressable @gol
12801-fipa-stack-alignment -fipa-modref}
12802
12803@item inline-only-static
12804
12805Only enable inlining of static functions.
12806As a result, when patching a static function, all its callers are impacted
12807and so need to be patched as well.
12808
12809In addition to all the flags that @option{-flive-patching=inline-clone}
12810disables,
12811@option{-flive-patching=inline-only-static} disables the following additional
12812optimization flags:
12813@gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
12814
12815@end table
12816
12817When @option{-flive-patching} is specified without any value, the default value
12818is @var{inline-clone}.
12819
12820This flag is disabled by default.
12821
12822Note that @option{-flive-patching} is not supported with link-time optimization
12823(@option{-flto}).
12824
12825@item -fisolate-erroneous-paths-dereference
12826@opindex fisolate-erroneous-paths-dereference
12827Detect paths that trigger erroneous or undefined behavior due to
12828dereferencing a null pointer. Isolate those paths from the main control
12829flow and turn the statement with erroneous or undefined behavior into a trap.
12830This flag is enabled by default at @option{-O2} and higher and depends on
12831@option{-fdelete-null-pointer-checks} also being enabled.
12832
12833@item -fisolate-erroneous-paths-attribute
12834@opindex fisolate-erroneous-paths-attribute
12835Detect paths that trigger erroneous or undefined behavior due to a null value
12836being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
12837attribute. Isolate those paths from the main control flow and turn the
12838statement with erroneous or undefined behavior into a trap. This is not
12839currently enabled, but may be enabled by @option{-O2} in the future.
12840
12841@item -ftree-sink
12842@opindex ftree-sink
12843Perform forward store motion on trees. This flag is
12844enabled by default at @option{-O1} and higher.
12845
12846@item -ftree-bit-ccp
12847@opindex ftree-bit-ccp
12848Perform sparse conditional bit constant propagation on trees and propagate
12849pointer alignment information.
12850This pass only operates on local scalar variables and is enabled by default
12851at @option{-O1} and higher, except for @option{-Og}.
12852It requires that @option{-ftree-ccp} is enabled.
12853
12854@item -ftree-ccp
12855@opindex ftree-ccp
12856Perform sparse conditional constant propagation (CCP) on trees. This
12857pass only operates on local scalar variables and is enabled by default
12858at @option{-O1} and higher.
12859
12860@item -fssa-backprop
12861@opindex fssa-backprop
12862Propagate information about uses of a value up the definition chain
12863in order to simplify the definitions. For example, this pass strips
12864sign operations if the sign of a value never matters. The flag is
12865enabled by default at @option{-O1} and higher.
12866
12867@item -fssa-phiopt
12868@opindex fssa-phiopt
12869Perform pattern matching on SSA PHI nodes to optimize conditional
12870code. This pass is enabled by default at @option{-O1} and higher,
12871except for @option{-Og}.
12872
12873@item -ftree-switch-conversion
12874@opindex ftree-switch-conversion
12875Perform conversion of simple initializations in a switch to
12876initializations from a scalar array. This flag is enabled by default
12877at @option{-O2} and higher.
12878
12879@item -ftree-tail-merge
12880@opindex ftree-tail-merge
12881Look for identical code sequences. When found, replace one with a jump to the
12882other. This optimization is known as tail merging or cross jumping. This flag
12883is enabled by default at @option{-O2} and higher. The compilation time
12884in this pass can
12885be limited using @option{max-tail-merge-comparisons} parameter and
12886@option{max-tail-merge-iterations} parameter.
12887
12888@item -ftree-dce
12889@opindex ftree-dce
12890Perform dead code elimination (DCE) on trees. This flag is enabled by
12891default at @option{-O1} and higher.
12892
12893@item -ftree-builtin-call-dce
12894@opindex ftree-builtin-call-dce
12895Perform conditional dead code elimination (DCE) for calls to built-in functions
12896that may set @code{errno} but are otherwise free of side effects. This flag is
12897enabled by default at @option{-O2} and higher if @option{-Os} is not also
12898specified.
12899
12900@item -ffinite-loops
12901@opindex ffinite-loops
12902@opindex fno-finite-loops
12903Assume that a loop with an exit will eventually take the exit and not loop
12904indefinitely. This allows the compiler to remove loops that otherwise have
12905no side-effects, not considering eventual endless looping as such.
12906
12907This option is enabled by default at @option{-O2} for C++ with -std=c++11
12908or higher.
12909
12910@item -ftree-dominator-opts
12911@opindex ftree-dominator-opts
12912Perform a variety of simple scalar cleanups (constant/copy
12913propagation, redundancy elimination, range propagation and expression
12914simplification) based on a dominator tree traversal. This also
12915performs jump threading (to reduce jumps to jumps). This flag is
12916enabled by default at @option{-O1} and higher.
12917
12918@item -ftree-dse
12919@opindex ftree-dse
12920Perform dead store elimination (DSE) on trees. A dead store is a store into
12921a memory location that is later overwritten by another store without
12922any intervening loads. In this case the earlier store can be deleted. This
12923flag is enabled by default at @option{-O1} and higher.
12924
12925@item -ftree-ch
12926@opindex ftree-ch
12927Perform loop header copying on trees. This is beneficial since it increases
12928effectiveness of code motion optimizations. It also saves one jump. This flag
12929is enabled by default at @option{-O1} and higher. It is not enabled
12930for @option{-Os}, since it usually increases code size.
12931
12932@item -ftree-loop-optimize
12933@opindex ftree-loop-optimize
12934Perform loop optimizations on trees. This flag is enabled by default
12935at @option{-O1} and higher.
12936
12937@item -ftree-loop-linear
12938@itemx -floop-strip-mine
12939@itemx -floop-block
12940@opindex ftree-loop-linear
12941@opindex floop-strip-mine
12942@opindex floop-block
12943Perform loop nest optimizations. Same as
12944@option{-floop-nest-optimize}. To use this code transformation, GCC has
12945to be configured with @option{--with-isl} to enable the Graphite loop
12946transformation infrastructure.
12947
12948@item -fgraphite-identity
12949@opindex fgraphite-identity
12950Enable the identity transformation for graphite. For every SCoP we generate
12951the polyhedral representation and transform it back to gimple. Using
12952@option{-fgraphite-identity} we can check the costs or benefits of the
12953GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
12954are also performed by the code generator isl, like index splitting and
12955dead code elimination in loops.
12956
12957@item -floop-nest-optimize
12958@opindex floop-nest-optimize
12959Enable the isl based loop nest optimizer. This is a generic loop nest
12960optimizer based on the Pluto optimization algorithms. It calculates a loop
12961structure optimized for data-locality and parallelism. This option
12962is experimental.
12963
12964@item -floop-parallelize-all
12965@opindex floop-parallelize-all
12966Use the Graphite data dependence analysis to identify loops that can
12967be parallelized. Parallelize all the loops that can be analyzed to
12968not contain loop carried dependences without checking that it is
12969profitable to parallelize the loops.
12970
12971@item -ftree-coalesce-vars
12972@opindex ftree-coalesce-vars
12973While transforming the program out of the SSA representation, attempt to
12974reduce copying by coalescing versions of different user-defined
12975variables, instead of just compiler temporaries. This may severely
12976limit the ability to debug an optimized program compiled with
12977@option{-fno-var-tracking-assignments}. In the negated form, this flag
12978prevents SSA coalescing of user variables. This option is enabled by
12979default if optimization is enabled, and it does very little otherwise.
12980
12981@item -ftree-loop-if-convert
12982@opindex ftree-loop-if-convert
12983Attempt to transform conditional jumps in the innermost loops to
12984branch-less equivalents. The intent is to remove control-flow from
12985the innermost loops in order to improve the ability of the
12986vectorization pass to handle these loops. This is enabled by default
12987if vectorization is enabled.
12988
12989@item -ftree-loop-distribution
12990@opindex ftree-loop-distribution
12991Perform loop distribution. This flag can improve cache performance on
12992big loop bodies and allow further loop optimizations, like
12993parallelization or vectorization, to take place. For example, the loop
12994@smallexample
12995DO I = 1, N
12996 A(I) = B(I) + C
12997 D(I) = E(I) * F
12998ENDDO
12999@end smallexample
13000is transformed to
13001@smallexample
13002DO I = 1, N
13003 A(I) = B(I) + C
13004ENDDO
13005DO I = 1, N
13006 D(I) = E(I) * F
13007ENDDO
13008@end smallexample
13009This flag is enabled by default at @option{-O3}.
13010It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13011
13012@item -ftree-loop-distribute-patterns
13013@opindex ftree-loop-distribute-patterns
13014Perform loop distribution of patterns that can be code generated with
13015calls to a library. This flag is enabled by default at @option{-O2} and
13016higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
13017
13018This pass distributes the initialization loops and generates a call to
13019memset zero. For example, the loop
13020@smallexample
13021DO I = 1, N
13022 A(I) = 0
13023 B(I) = A(I) + I
13024ENDDO
13025@end smallexample
13026is transformed to
13027@smallexample
13028DO I = 1, N
13029 A(I) = 0
13030ENDDO
13031DO I = 1, N
13032 B(I) = A(I) + I
13033ENDDO
13034@end smallexample
13035and the initialization loop is transformed into a call to memset zero.
13036This flag is enabled by default at @option{-O3}.
13037It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13038
13039@item -floop-interchange
13040@opindex floop-interchange
13041Perform loop interchange outside of graphite. This flag can improve cache
13042performance on loop nest and allow further loop optimizations, like
13043vectorization, to take place. For example, the loop
13044@smallexample
13045for (int i = 0; i < N; i++)
13046 for (int j = 0; j < N; j++)
13047 for (int k = 0; k < N; k++)
13048 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13049@end smallexample
13050is transformed to
13051@smallexample
13052for (int i = 0; i < N; i++)
13053 for (int k = 0; k < N; k++)
13054 for (int j = 0; j < N; j++)
13055 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13056@end smallexample
13057This flag is enabled by default at @option{-O3}.
13058It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13059
13060@item -floop-unroll-and-jam
13061@opindex floop-unroll-and-jam
13062Apply unroll and jam transformations on feasible loops. In a loop
13063nest this unrolls the outer loop by some factor and fuses the resulting
13064multiple inner loops. This flag is enabled by default at @option{-O3}.
13065It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13066
13067@item -ftree-loop-im
13068@opindex ftree-loop-im
13069Perform loop invariant motion on trees. This pass moves only invariants that
13070are hard to handle at RTL level (function calls, operations that expand to
13071nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
13072operands of conditions that are invariant out of the loop, so that we can use
13073just trivial invariantness analysis in loop unswitching. The pass also includes
13074store motion.
13075
13076@item -ftree-loop-ivcanon
13077@opindex ftree-loop-ivcanon
13078Create a canonical counter for number of iterations in loops for which
13079determining number of iterations requires complicated analysis. Later
13080optimizations then may determine the number easily. Useful especially
13081in connection with unrolling.
13082
13083@item -ftree-scev-cprop
13084@opindex ftree-scev-cprop
13085Perform final value replacement. If a variable is modified in a loop
13086in such a way that its value when exiting the loop can be determined using
13087only its initial value and the number of loop iterations, replace uses of
13088the final value by such a computation, provided it is sufficiently cheap.
13089This reduces data dependencies and may allow further simplifications.
13090Enabled by default at @option{-O1} and higher.
13091
13092@item -fivopts
13093@opindex fivopts
13094Perform induction variable optimizations (strength reduction, induction
13095variable merging and induction variable elimination) on trees.
13096
13097@item -ftree-parallelize-loops=n
13098@opindex ftree-parallelize-loops
13099Parallelize loops, i.e., split their iteration space to run in n threads.
13100This is only possible for loops whose iterations are independent
13101and can be arbitrarily reordered. The optimization is only
13102profitable on multiprocessor machines, for loops that are CPU-intensive,
13103rather than constrained e.g.@: by memory bandwidth. This option
13104implies @option{-pthread}, and thus is only supported on targets
13105that have support for @option{-pthread}.
13106
13107@item -ftree-pta
13108@opindex ftree-pta
13109Perform function-local points-to analysis on trees. This flag is
13110enabled by default at @option{-O1} and higher, except for @option{-Og}.
13111
13112@item -ftree-sra
13113@opindex ftree-sra
13114Perform scalar replacement of aggregates. This pass replaces structure
13115references with scalars to prevent committing structures to memory too
13116early. This flag is enabled by default at @option{-O1} and higher,
13117except for @option{-Og}.
13118
13119@item -fstore-merging
13120@opindex fstore-merging
13121Perform merging of narrow stores to consecutive memory addresses. This pass
13122merges contiguous stores of immediate values narrower than a word into fewer
13123wider stores to reduce the number of instructions. This is enabled by default
13124at @option{-O2} and higher as well as @option{-Os}.
13125
13126@item -ftree-ter
13127@opindex ftree-ter
13128Perform temporary expression replacement during the SSA->normal phase. Single
13129use/single def temporaries are replaced at their use location with their
13130defining expression. This results in non-GIMPLE code, but gives the expanders
13131much more complex trees to work on resulting in better RTL generation. This is
13132enabled by default at @option{-O1} and higher.
13133
13134@item -ftree-slsr
13135@opindex ftree-slsr
13136Perform straight-line strength reduction on trees. This recognizes related
13137expressions involving multiplications and replaces them by less expensive
13138calculations when possible. This is enabled by default at @option{-O1} and
13139higher.
13140
13141@item -ftree-vectorize
13142@opindex ftree-vectorize
13143Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
13144and @option{-ftree-slp-vectorize} if not explicitly specified.
13145
13146@item -ftree-loop-vectorize
13147@opindex ftree-loop-vectorize
13148Perform loop vectorization on trees. This flag is enabled by default at
13149@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13150and @option{-fauto-profile}.
13151
13152@item -ftree-slp-vectorize
13153@opindex ftree-slp-vectorize
13154Perform basic block vectorization on trees. This flag is enabled by default at
13155@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13156and @option{-fauto-profile}.
13157
13158@item -ftrivial-auto-var-init=@var{choice}
13159@opindex ftrivial-auto-var-init
13160Initialize automatic variables with either a pattern or with zeroes to increase
13161the security and predictability of a program by preventing uninitialized memory
13162disclosure and use.
13163GCC still considers an automatic variable that doesn't have an explicit
13164initializer as uninitialized, @option{-Wuninitialized} and
13165@option{-Wanalyzer-use-of-uninitialized-value} will still report
13166warning messages on such automatic variables.
13167With this option, GCC will also initialize any padding of automatic variables
13168that have structure or union types to zeroes.
13169However, the current implementation cannot initialize automatic variables that
13170are declared between the controlling expression and the first case of a
13171@code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all
13172such cases.
13173
13174The three values of @var{choice} are:
13175
13176@itemize @bullet
13177@item
13178@samp{uninitialized} doesn't initialize any automatic variables.
13179This is C and C++'s default.
13180
13181@item
13182@samp{pattern} Initialize automatic variables with values which will likely
13183transform logic bugs into crashes down the line, are easily recognized in a
13184crash dump and without being values that programmers can rely on for useful
13185program semantics.
13186The current value is byte-repeatable pattern with byte "0xFE".
13187The values used for pattern initialization might be changed in the future.
13188
13189@item
13190@samp{zero} Initialize automatic variables with zeroes.
13191@end itemize
13192
13193The default is @samp{uninitialized}.
13194
13195You can control this behavior for a specific variable by using the variable
13196attribute @code{uninitialized} (@pxref{Variable Attributes}).
13197
13198@item -fvect-cost-model=@var{model}
13199@opindex fvect-cost-model
13200Alter the cost model used for vectorization. The @var{model} argument
13201should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
13202@samp{very-cheap}.
13203With the @samp{unlimited} model the vectorized code-path is assumed
13204to be profitable while with the @samp{dynamic} model a runtime check
13205guards the vectorized code-path to enable it only for iteration
13206counts that will likely execute faster than when executing the original
13207scalar loop. The @samp{cheap} model disables vectorization of
13208loops where doing so would be cost prohibitive for example due to
13209required runtime checks for data dependence or alignment but otherwise
13210is equal to the @samp{dynamic} model. The @samp{very-cheap} model only
13211allows vectorization if the vector code would entirely replace the
13212scalar code that is being vectorized. For example, if each iteration
13213of a vectorized loop would only be able to handle exactly four iterations
13214of the scalar loop, the @samp{very-cheap} model would only allow
13215vectorization if the scalar iteration count is known to be a multiple
13216of four.
13217
13218The default cost model depends on other optimization flags and is
13219either @samp{dynamic} or @samp{cheap}.
13220
13221@item -fsimd-cost-model=@var{model}
13222@opindex fsimd-cost-model
13223Alter the cost model used for vectorization of loops marked with the OpenMP
13224simd directive. The @var{model} argument should be one of
13225@samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
13226have the same meaning as described in @option{-fvect-cost-model} and by
13227default a cost model defined with @option{-fvect-cost-model} is used.
13228
13229@item -ftree-vrp
13230@opindex ftree-vrp
13231Perform Value Range Propagation on trees. This is similar to the
13232constant propagation pass, but instead of values, ranges of values are
13233propagated. This allows the optimizers to remove unnecessary range
13234checks like array bound checks and null pointer checks. This is
13235enabled by default at @option{-O2} and higher. Null pointer check
13236elimination is only done if @option{-fdelete-null-pointer-checks} is
13237enabled.
13238
13239@item -fsplit-paths
13240@opindex fsplit-paths
13241Split paths leading to loop backedges. This can improve dead code
13242elimination and common subexpression elimination. This is enabled by
13243default at @option{-O3} and above.
13244
13245@item -fsplit-ivs-in-unroller
13246@opindex fsplit-ivs-in-unroller
13247Enables expression of values of induction variables in later iterations
13248of the unrolled loop using the value in the first iteration. This breaks
13249long dependency chains, thus improving efficiency of the scheduling passes.
13250
13251A combination of @option{-fweb} and CSE is often sufficient to obtain the
13252same effect. However, that is not reliable in cases where the loop body
13253is more complicated than a single basic block. It also does not work at all
13254on some architectures due to restrictions in the CSE pass.
13255
13256This optimization is enabled by default.
13257
13258@item -fvariable-expansion-in-unroller
13259@opindex fvariable-expansion-in-unroller
13260With this option, the compiler creates multiple copies of some
13261local variables when unrolling a loop, which can result in superior code.
13262
13263This optimization is enabled by default for PowerPC targets, but disabled
13264by default otherwise.
13265
13266@item -fpartial-inlining
13267@opindex fpartial-inlining
13268Inline parts of functions. This option has any effect only
13269when inlining itself is turned on by the @option{-finline-functions}
13270or @option{-finline-small-functions} options.
13271
13272Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13273
13274@item -fpredictive-commoning
13275@opindex fpredictive-commoning
13276Perform predictive commoning optimization, i.e., reusing computations
13277(especially memory loads and stores) performed in previous
13278iterations of loops.
13279
13280This option is enabled at level @option{-O3}.
13281It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13282
13283@item -fprefetch-loop-arrays
13284@opindex fprefetch-loop-arrays
13285If supported by the target machine, generate instructions to prefetch
13286memory to improve the performance of loops that access large arrays.
13287
13288This option may generate better or worse code; results are highly
13289dependent on the structure of loops within the source code.
13290
13291Disabled at level @option{-Os}.
13292
13293@item -fno-printf-return-value
13294@opindex fno-printf-return-value
13295@opindex fprintf-return-value
13296Do not substitute constants for known return value of formatted output
13297functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
13298@code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
13299transformation allows GCC to optimize or even eliminate branches based
13300on the known return value of these functions called with arguments that
13301are either constant, or whose values are known to be in a range that
13302makes determining the exact return value possible. For example, when
13303@option{-fprintf-return-value} is in effect, both the branch and the
13304body of the @code{if} statement (but not the call to @code{snprint})
13305can be optimized away when @code{i} is a 32-bit or smaller integer
13306because the return value is guaranteed to be at most 8.
13307
13308@smallexample
13309char buf[9];
13310if (snprintf (buf, "%08x", i) >= sizeof buf)
13311 @dots{}
13312@end smallexample
13313
13314The @option{-fprintf-return-value} option relies on other optimizations
13315and yields best results with @option{-O2} and above. It works in tandem
13316with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
13317options. The @option{-fprintf-return-value} option is enabled by default.
13318
13319@item -fno-peephole
13320@itemx -fno-peephole2
13321@opindex fno-peephole
13322@opindex fpeephole
13323@opindex fno-peephole2
13324@opindex fpeephole2
13325Disable any machine-specific peephole optimizations. The difference
13326between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
13327are implemented in the compiler; some targets use one, some use the
13328other, a few use both.
13329
13330@option{-fpeephole} is enabled by default.
13331@option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13332
13333@item -fno-guess-branch-probability
13334@opindex fno-guess-branch-probability
13335@opindex fguess-branch-probability
13336Do not guess branch probabilities using heuristics.
13337
13338GCC uses heuristics to guess branch probabilities if they are
13339not provided by profiling feedback (@option{-fprofile-arcs}). These
13340heuristics are based on the control flow graph. If some branch probabilities
13341are specified by @code{__builtin_expect}, then the heuristics are
13342used to guess branch probabilities for the rest of the control flow graph,
13343taking the @code{__builtin_expect} info into account. The interactions
13344between the heuristics and @code{__builtin_expect} can be complex, and in
13345some cases, it may be useful to disable the heuristics so that the effects
13346of @code{__builtin_expect} are easier to understand.
13347
13348It is also possible to specify expected probability of the expression
13349with @code{__builtin_expect_with_probability} built-in function.
13350
13351The default is @option{-fguess-branch-probability} at levels
13352@option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
13353
13354@item -freorder-blocks
13355@opindex freorder-blocks
13356Reorder basic blocks in the compiled function in order to reduce number of
13357taken branches and improve code locality.
13358
13359Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13360
13361@item -freorder-blocks-algorithm=@var{algorithm}
13362@opindex freorder-blocks-algorithm
13363Use the specified algorithm for basic block reordering. The
13364@var{algorithm} argument can be @samp{simple}, which does not increase
13365code size (except sometimes due to secondary effects like alignment),
13366or @samp{stc}, the ``software trace cache'' algorithm, which tries to
13367put all often executed code together, minimizing the number of branches
13368executed by making extra copies of code.
13369
13370The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
13371@samp{stc} at levels @option{-O2}, @option{-O3}.
13372
13373@item -freorder-blocks-and-partition
13374@opindex freorder-blocks-and-partition
13375In addition to reordering basic blocks in the compiled function, in order
13376to reduce number of taken branches, partitions hot and cold basic blocks
13377into separate sections of the assembly and @file{.o} files, to improve
13378paging and cache locality performance.
13379
13380This optimization is automatically turned off in the presence of
13381exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
13382section attribute and on any architecture that does not support named
13383sections. When @option{-fsplit-stack} is used this option is not
13384enabled by default (to avoid linker errors), but may be enabled
13385explicitly (if using a working linker).
13386
13387Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
13388
13389@item -freorder-functions
13390@opindex freorder-functions
13391Reorder functions in the object file in order to
13392improve code locality. This is implemented by using special
13393subsections @code{.text.hot} for most frequently executed functions and
13394@code{.text.unlikely} for unlikely executed functions. Reordering is done by
13395the linker so object file format must support named sections and linker must
13396place them in a reasonable way.
13397
13398This option isn't effective unless you either provide profile feedback
13399(see @option{-fprofile-arcs} for details) or manually annotate functions with
13400@code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
13401
13402Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13403
13404@item -fstrict-aliasing
13405@opindex fstrict-aliasing
13406Allow the compiler to assume the strictest aliasing rules applicable to
13407the language being compiled. For C (and C++), this activates
13408optimizations based on the type of expressions. In particular, an
13409object of one type is assumed never to reside at the same address as an
13410object of a different type, unless the types are almost the same. For
13411example, an @code{unsigned int} can alias an @code{int}, but not a
13412@code{void*} or a @code{double}. A character type may alias any other
13413type.
13414
13415@anchor{Type-punning}Pay special attention to code like this:
13416@smallexample
13417union a_union @{
13418 int i;
13419 double d;
13420@};
13421
13422int f() @{
13423 union a_union t;
13424 t.d = 3.0;
13425 return t.i;
13426@}
13427@end smallexample
13428The practice of reading from a different union member than the one most
13429recently written to (called ``type-punning'') is common. Even with
13430@option{-fstrict-aliasing}, type-punning is allowed, provided the memory
13431is accessed through the union type. So, the code above works as
13432expected. @xref{Structures unions enumerations and bit-fields
13433implementation}. However, this code might not:
13434@smallexample
13435int f() @{
13436 union a_union t;
13437 int* ip;
13438 t.d = 3.0;
13439 ip = &t.i;
13440 return *ip;
13441@}
13442@end smallexample
13443
13444Similarly, access by taking the address, casting the resulting pointer
13445and dereferencing the result has undefined behavior, even if the cast
13446uses a union type, e.g.:
13447@smallexample
13448int f() @{
13449 double d = 3.0;
13450 return ((union a_union *) &d)->i;
13451@}
13452@end smallexample
13453
13454The @option{-fstrict-aliasing} option is enabled at levels
13455@option{-O2}, @option{-O3}, @option{-Os}.
13456
13457@item -fipa-strict-aliasing
13458@opindex fipa-strict-aliasing
13459Controls whether rules of @option{-fstrict-aliasing} are applied across
13460function boundaries. Note that if multiple functions gets inlined into a
13461single function the memory accesses are no longer considered to be crossing a
13462function boundary.
13463
13464The @option{-fipa-strict-aliasing} option is enabled by default and is
13465effective only in combination with @option{-fstrict-aliasing}.
13466
13467@item -falign-functions
13468@itemx -falign-functions=@var{n}
13469@itemx -falign-functions=@var{n}:@var{m}
13470@itemx -falign-functions=@var{n}:@var{m}:@var{n2}
13471@itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
13472@opindex falign-functions
13473Align the start of functions to the next power-of-two greater than or
13474equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
13475least the first @var{m} bytes of the function can be fetched by the CPU
13476without crossing an @var{n}-byte alignment boundary.
13477
13478If @var{m} is not specified, it defaults to @var{n}.
13479
13480Examples: @option{-falign-functions=32} aligns functions to the next
1348132-byte boundary, @option{-falign-functions=24} aligns to the next
1348232-byte boundary only if this can be done by skipping 23 bytes or less,
13483@option{-falign-functions=32:7} aligns to the next
1348432-byte boundary only if this can be done by skipping 6 bytes or less.
13485
13486The second pair of @var{n2}:@var{m2} values allows you to specify
13487a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
13488the next 64-byte boundary if this can be done by skipping 6 bytes or less,
13489otherwise aligns to the next 32-byte boundary if this can be done
13490by skipping 2 bytes or less.
13491If @var{m2} is not specified, it defaults to @var{n2}.
13492
13493Some assemblers only support this flag when @var{n} is a power of two;
13494in that case, it is rounded up.
13495
13496@option{-fno-align-functions} and @option{-falign-functions=1} are
13497equivalent and mean that functions are not aligned.
13498
13499If @var{n} is not specified or is zero, use a machine-dependent default.
13500The maximum allowed @var{n} option value is 65536.
13501
13502Enabled at levels @option{-O2}, @option{-O3}.
13503
13504@item -flimit-function-alignment
13505If this option is enabled, the compiler tries to avoid unnecessarily
13506overaligning functions. It attempts to instruct the assembler to align
13507by the amount specified by @option{-falign-functions}, but not to
13508skip more bytes than the size of the function.
13509
13510@item -falign-labels
13511@itemx -falign-labels=@var{n}
13512@itemx -falign-labels=@var{n}:@var{m}
13513@itemx -falign-labels=@var{n}:@var{m}:@var{n2}
13514@itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
13515@opindex falign-labels
13516Align all branch targets to a power-of-two boundary.
13517
13518Parameters of this option are analogous to the @option{-falign-functions} option.
13519@option{-fno-align-labels} and @option{-falign-labels=1} are
13520equivalent and mean that labels are not aligned.
13521
13522If @option{-falign-loops} or @option{-falign-jumps} are applicable and
13523are greater than this value, then their values are used instead.
13524
13525If @var{n} is not specified or is zero, use a machine-dependent default
13526which is very likely to be @samp{1}, meaning no alignment.
13527The maximum allowed @var{n} option value is 65536.
13528
13529Enabled at levels @option{-O2}, @option{-O3}.
13530
13531@item -falign-loops
13532@itemx -falign-loops=@var{n}
13533@itemx -falign-loops=@var{n}:@var{m}
13534@itemx -falign-loops=@var{n}:@var{m}:@var{n2}
13535@itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
13536@opindex falign-loops
13537Align loops to a power-of-two boundary. If the loops are executed
13538many times, this makes up for any execution of the dummy padding
13539instructions.
13540
13541If @option{-falign-labels} is greater than this value, then its value
13542is used instead.
13543
13544Parameters of this option are analogous to the @option{-falign-functions} option.
13545@option{-fno-align-loops} and @option{-falign-loops=1} are
13546equivalent and mean that loops are not aligned.
13547The maximum allowed @var{n} option value is 65536.
13548
13549If @var{n} is not specified or is zero, use a machine-dependent default.
13550
13551Enabled at levels @option{-O2}, @option{-O3}.
13552
13553@item -falign-jumps
13554@itemx -falign-jumps=@var{n}
13555@itemx -falign-jumps=@var{n}:@var{m}
13556@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
13557@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
13558@opindex falign-jumps
13559Align branch targets to a power-of-two boundary, for branch targets
13560where the targets can only be reached by jumping. In this case,
13561no dummy operations need be executed.
13562
13563If @option{-falign-labels} is greater than this value, then its value
13564is used instead.
13565
13566Parameters of this option are analogous to the @option{-falign-functions} option.
13567@option{-fno-align-jumps} and @option{-falign-jumps=1} are
13568equivalent and mean that loops are not aligned.
13569
13570If @var{n} is not specified or is zero, use a machine-dependent default.
13571The maximum allowed @var{n} option value is 65536.
13572
13573Enabled at levels @option{-O2}, @option{-O3}.
13574
13575@item -fno-allocation-dce
13576@opindex fno-allocation-dce
13577Do not remove unused C++ allocations in dead code elimination.
13578
13579@item -fallow-store-data-races
13580@opindex fallow-store-data-races
13581Allow the compiler to perform optimizations that may introduce new data races
13582on stores, without proving that the variable cannot be concurrently accessed
13583by other threads. Does not affect optimization of local data. It is safe to
13584use this option if it is known that global data will not be accessed by
13585multiple threads.
13586
13587Examples of optimizations enabled by @option{-fallow-store-data-races} include
13588hoisting or if-conversions that may cause a value that was already in memory
13589to be re-written with that same value. Such re-writing is safe in a single
13590threaded context but may be unsafe in a multi-threaded context. Note that on
13591some processors, if-conversions may be required in order to enable
13592vectorization.
13593
13594Enabled at level @option{-Ofast}.
13595
13596@item -funit-at-a-time
13597@opindex funit-at-a-time
13598This option is left for compatibility reasons. @option{-funit-at-a-time}
13599has no effect, while @option{-fno-unit-at-a-time} implies
13600@option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
13601
13602Enabled by default.
13603
13604@item -fno-toplevel-reorder
13605@opindex fno-toplevel-reorder
13606@opindex ftoplevel-reorder
13607Do not reorder top-level functions, variables, and @code{asm}
13608statements. Output them in the same order that they appear in the
13609input file. When this option is used, unreferenced static variables
13610are not removed. This option is intended to support existing code
13611that relies on a particular ordering. For new code, it is better to
13612use attributes when possible.
13613
13614@option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
13615also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
13616Additionally @option{-fno-toplevel-reorder} implies
13617@option{-fno-section-anchors}.
13618
13619@item -funreachable-traps
13620@opindex funreachable-traps
13621With this option, the compiler turns calls to
13622@code{__builtin_unreachable} into traps, instead of using them for
13623optimization. This also affects any such calls implicitly generated
13624by the compiler.
13625
13626This option has the same effect as @option{-fsanitize=unreachable
13627-fsanitize-trap=unreachable}, but does not affect the values of those
13628options. If @option{-fsanitize=unreachable} is enabled, that option
13629takes priority over this one.
13630
13631This option is enabled by default at @option{-O0} and @option{-Og}.
13632
13633@item -fweb
13634@opindex fweb
13635Constructs webs as commonly used for register allocation purposes and assign
13636each web individual pseudo register. This allows the register allocation pass
13637to operate on pseudos directly, but also strengthens several other optimization
13638passes, such as CSE, loop optimizer and trivial dead code remover. It can,
13639however, make debugging impossible, since variables no longer stay in a
13640``home register''.
13641
13642Enabled by default with @option{-funroll-loops}.
13643
13644@item -fwhole-program
13645@opindex fwhole-program
13646Assume that the current compilation unit represents the whole program being
13647compiled. All public functions and variables with the exception of @code{main}
13648and those merged by attribute @code{externally_visible} become static functions
13649and in effect are optimized more aggressively by interprocedural optimizers.
13650
13651This option should not be used in combination with @option{-flto}.
13652Instead relying on a linker plugin should provide safer and more precise
13653information.
13654
13655@item -flto[=@var{n}]
13656@opindex flto
13657This option runs the standard link-time optimizer. When invoked
13658with source code, it generates GIMPLE (one of GCC's internal
13659representations) and writes it to special ELF sections in the object
13660file. When the object files are linked together, all the function
13661bodies are read from these ELF sections and instantiated as if they
13662had been part of the same translation unit.
13663
13664To use the link-time optimizer, @option{-flto} and optimization
13665options should be specified at compile time and during the final link.
13666It is recommended that you compile all the files participating in the
13667same link with the same options and also specify those options at
13668link time.
13669For example:
13670
13671@smallexample
13672gcc -c -O2 -flto foo.c
13673gcc -c -O2 -flto bar.c
13674gcc -o myprog -flto -O2 foo.o bar.o
13675@end smallexample
13676
13677The first two invocations to GCC save a bytecode representation
13678of GIMPLE into special ELF sections inside @file{foo.o} and
13679@file{bar.o}. The final invocation reads the GIMPLE bytecode from
13680@file{foo.o} and @file{bar.o}, merges the two files into a single
13681internal image, and compiles the result as usual. Since both
13682@file{foo.o} and @file{bar.o} are merged into a single image, this
13683causes all the interprocedural analyses and optimizations in GCC to
13684work across the two files as if they were a single one. This means,
13685for example, that the inliner is able to inline functions in
13686@file{bar.o} into functions in @file{foo.o} and vice-versa.
13687
13688Another (simpler) way to enable link-time optimization is:
13689
13690@smallexample
13691gcc -o myprog -flto -O2 foo.c bar.c
13692@end smallexample
13693
13694The above generates bytecode for @file{foo.c} and @file{bar.c},
13695merges them together into a single GIMPLE representation and optimizes
13696them as usual to produce @file{myprog}.
13697
13698The important thing to keep in mind is that to enable link-time
13699optimizations you need to use the GCC driver to perform the link step.
13700GCC automatically performs link-time optimization if any of the
13701objects involved were compiled with the @option{-flto} command-line option.
13702You can always override
13703the automatic decision to do link-time optimization
13704by passing @option{-fno-lto} to the link command.
13705
13706To make whole program optimization effective, it is necessary to make
13707certain whole program assumptions. The compiler needs to know
13708what functions and variables can be accessed by libraries and runtime
13709outside of the link-time optimized unit. When supported by the linker,
13710the linker plugin (see @option{-fuse-linker-plugin}) passes information
13711to the compiler about used and externally visible symbols. When
13712the linker plugin is not available, @option{-fwhole-program} should be
13713used to allow the compiler to make these assumptions, which leads
13714to more aggressive optimization decisions.
13715
13716When a file is compiled with @option{-flto} without
13717@option{-fuse-linker-plugin}, the generated object file is larger than
13718a regular object file because it contains GIMPLE bytecodes and the usual
13719final code (see @option{-ffat-lto-objects}). This means that
13720object files with LTO information can be linked as normal object
13721files; if @option{-fno-lto} is passed to the linker, no
13722interprocedural optimizations are applied. Note that when
13723@option{-fno-fat-lto-objects} is enabled the compile stage is faster
13724but you cannot perform a regular, non-LTO link on them.
13725
13726When producing the final binary, GCC only
13727applies link-time optimizations to those files that contain bytecode.
13728Therefore, you can mix and match object files and libraries with
13729GIMPLE bytecodes and final object code. GCC automatically selects
13730which files to optimize in LTO mode and which files to link without
13731further processing.
13732
13733Generally, options specified at link time override those
13734specified at compile time, although in some cases GCC attempts to infer
13735link-time options from the settings used to compile the input files.
13736
13737If you do not specify an optimization level option @option{-O} at
13738link time, then GCC uses the highest optimization level
13739used when compiling the object files. Note that it is generally
13740ineffective to specify an optimization level option only at link time and
13741not at compile time, for two reasons. First, compiling without
13742optimization suppresses compiler passes that gather information
13743needed for effective optimization at link time. Second, some early
13744optimization passes can be performed only at compile time and
13745not at link time.
13746
13747There are some code generation flags preserved by GCC when
13748generating bytecodes, as they need to be used during the final link.
13749Currently, the following options and their settings are taken from
13750the first object file that explicitly specifies them:
13751@option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
13752@option{-fgnu-tm} and all the @option{-m} target flags.
13753
13754The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
13755@option{-fPIE} are combined based on the following scheme:
13756
13757@smallexample
13758@option{-fPIC} + @option{-fpic} = @option{-fpic}
13759@option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
13760@option{-fpic/-fPIC} + (no option) = (no option)
13761@option{-fPIC} + @option{-fPIE} = @option{-fPIE}
13762@option{-fpic} + @option{-fPIE} = @option{-fpie}
13763@option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
13764@end smallexample
13765
13766Certain ABI-changing flags are required to match in all compilation units,
13767and trying to override this at link time with a conflicting value
13768is ignored. This includes options such as @option{-freg-struct-return}
13769and @option{-fpcc-struct-return}.
13770
13771Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
13772@option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
13773are passed through to the link stage and merged conservatively for
13774conflicting translation units. Specifically
13775@option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
13776precedence; and for example @option{-ffp-contract=off} takes precedence
13777over @option{-ffp-contract=fast}. You can override them at link time.
13778
13779Diagnostic options such as @option{-Wstringop-overflow} are passed
13780through to the link stage and their setting matches that of the
13781compile-step at function granularity. Note that this matters only
13782for diagnostics emitted during optimization. Note that code
13783transforms such as inlining can lead to warnings being enabled
13784or disabled for regions if code not consistent with the setting
13785at compile time.
13786
13787When you need to pass options to the assembler via @option{-Wa} or
13788@option{-Xassembler} make sure to either compile such translation
13789units with @option{-fno-lto} or consistently use the same assembler
13790options on all translation units. You can alternatively also
13791specify assembler options at LTO link time.
13792
13793To enable debug info generation you need to supply @option{-g} at
13794compile time. If any of the input files at link time were built
13795with debug info generation enabled the link will enable debug info
13796generation as well. Any elaborate debug info settings
13797like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
13798at the linker command line and mixing different settings in different
13799translation units is discouraged.
13800
13801If LTO encounters objects with C linkage declared with incompatible
13802types in separate translation units to be linked together (undefined
13803behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
13804issued. The behavior is still undefined at run time. Similar
13805diagnostics may be raised for other languages.
13806
13807Another feature of LTO is that it is possible to apply interprocedural
13808optimizations on files written in different languages:
13809
13810@smallexample
13811gcc -c -flto foo.c
13812g++ -c -flto bar.cc
13813gfortran -c -flto baz.f90
13814g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
13815@end smallexample
13816
13817Notice that the final link is done with @command{g++} to get the C++
13818runtime libraries and @option{-lgfortran} is added to get the Fortran
13819runtime libraries. In general, when mixing languages in LTO mode, you
13820should use the same link command options as when mixing languages in a
13821regular (non-LTO) compilation.
13822
13823If object files containing GIMPLE bytecode are stored in a library archive, say
13824@file{libfoo.a}, it is possible to extract and use them in an LTO link if you
13825are using a linker with plugin support. To create static libraries suitable
13826for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
13827and @command{ranlib};
13828to show the symbols of object files with GIMPLE bytecode, use
13829@command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
13830and @command{nm} have been compiled with plugin support. At link time, use the
13831flag @option{-fuse-linker-plugin} to ensure that the library participates in
13832the LTO optimization process:
13833
13834@smallexample
13835gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
13836@end smallexample
13837
13838With the linker plugin enabled, the linker extracts the needed
13839GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
13840to make them part of the aggregated GIMPLE image to be optimized.
13841
13842If you are not using a linker with plugin support and/or do not
13843enable the linker plugin, then the objects inside @file{libfoo.a}
13844are extracted and linked as usual, but they do not participate
13845in the LTO optimization process. In order to make a static library suitable
13846for both LTO optimization and usual linkage, compile its object files with
13847@option{-flto} @option{-ffat-lto-objects}.
13848
13849Link-time optimizations do not require the presence of the whole program to
13850operate. If the program does not require any symbols to be exported, it is
13851possible to combine @option{-flto} and @option{-fwhole-program} to allow
13852the interprocedural optimizers to use more aggressive assumptions which may
13853lead to improved optimization opportunities.
13854Use of @option{-fwhole-program} is not needed when linker plugin is
13855active (see @option{-fuse-linker-plugin}).
13856
13857The current implementation of LTO makes no
13858attempt to generate bytecode that is portable between different
13859types of hosts. The bytecode files are versioned and there is a
13860strict version check, so bytecode files generated in one version of
13861GCC do not work with an older or newer version of GCC.
13862
13863Link-time optimization does not work well with generation of debugging
13864information on systems other than those using a combination of ELF and
13865DWARF.
13866
13867If you specify the optional @var{n}, the optimization and code
13868generation done at link time is executed in parallel using @var{n}
13869parallel jobs by utilizing an installed @command{make} program. The
13870environment variable @env{MAKE} may be used to override the program
13871used.
13872
13873You can also specify @option{-flto=jobserver} to use GNU make's
13874job server mode to determine the number of parallel jobs. This
13875is useful when the Makefile calling GCC is already executing in parallel.
13876You must prepend a @samp{+} to the command recipe in the parent Makefile
13877for this to work. This option likely only works if @env{MAKE} is
13878GNU make. Even without the option value, GCC tries to automatically
13879detect a running GNU make's job server.
13880
13881Use @option{-flto=auto} to use GNU make's job server, if available,
13882or otherwise fall back to autodetection of the number of CPU threads
13883present in your system.
13884
13885@item -flto-partition=@var{alg}
13886@opindex flto-partition
13887Specify the partitioning algorithm used by the link-time optimizer.
13888The value is either @samp{1to1} to specify a partitioning mirroring
13889the original source files or @samp{balanced} to specify partitioning
13890into equally sized chunks (whenever possible) or @samp{max} to create
13891new partition for every symbol where possible. Specifying @samp{none}
13892as an algorithm disables partitioning and streaming completely.
13893The default value is @samp{balanced}. While @samp{1to1} can be used
13894as an workaround for various code ordering issues, the @samp{max}
13895partitioning is intended for internal testing only.
13896The value @samp{one} specifies that exactly one partition should be
13897used while the value @samp{none} bypasses partitioning and executes
13898the link-time optimization step directly from the WPA phase.
13899
13900@item -flto-compression-level=@var{n}
13901@opindex flto-compression-level
13902This option specifies the level of compression used for intermediate
13903language written to LTO object files, and is only meaningful in
13904conjunction with LTO mode (@option{-flto}). GCC currently supports two
13905LTO compression algorithms. For zstd, valid values are 0 (no compression)
13906to 19 (maximum compression), while zlib supports values from 0 to 9.
13907Values outside this range are clamped to either minimum or maximum
13908of the supported values. If the option is not given,
13909a default balanced compression setting is used.
13910
13911@item -fuse-linker-plugin
13912@opindex fuse-linker-plugin
13913Enables the use of a linker plugin during link-time optimization. This
13914option relies on plugin support in the linker, which is available in gold
13915or in GNU ld 2.21 or newer.
13916
13917This option enables the extraction of object files with GIMPLE bytecode out
13918of library archives. This improves the quality of optimization by exposing
13919more code to the link-time optimizer. This information specifies what
13920symbols can be accessed externally (by non-LTO object or during dynamic
13921linking). Resulting code quality improvements on binaries (and shared
13922libraries that use hidden visibility) are similar to @option{-fwhole-program}.
13923See @option{-flto} for a description of the effect of this flag and how to
13924use it.
13925
13926This option is enabled by default when LTO support in GCC is enabled
13927and GCC was configured for use with
13928a linker supporting plugins (GNU ld 2.21 or newer or gold).
13929
13930@item -ffat-lto-objects
13931@opindex ffat-lto-objects
13932Fat LTO objects are object files that contain both the intermediate language
13933and the object code. This makes them usable for both LTO linking and normal
13934linking. This option is effective only when compiling with @option{-flto}
13935and is ignored at link time.
13936
13937@option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
13938requires the complete toolchain to be aware of LTO. It requires a linker with
13939linker plugin support for basic functionality. Additionally,
13940@command{nm}, @command{ar} and @command{ranlib}
13941need to support linker plugins to allow a full-featured build environment
13942(capable of building static libraries etc). GCC provides the @command{gcc-ar},
13943@command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
13944to these tools. With non fat LTO makefiles need to be modified to use them.
13945
13946Note that modern binutils provide plugin auto-load mechanism.
13947Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
13948effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
13949@command{gcc-ranlib}).
13950
13951The default is @option{-fno-fat-lto-objects} on targets with linker plugin
13952support.
13953
13954@item -fcompare-elim
13955@opindex fcompare-elim
13956After register allocation and post-register allocation instruction splitting,
13957identify arithmetic instructions that compute processor flags similar to a
13958comparison operation based on that arithmetic. If possible, eliminate the
13959explicit comparison operation.
13960
13961This pass only applies to certain targets that cannot explicitly represent
13962the comparison operation before register allocation is complete.
13963
13964Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13965
13966@item -fcprop-registers
13967@opindex fcprop-registers
13968After register allocation and post-register allocation instruction splitting,
13969perform a copy-propagation pass to try to reduce scheduling dependencies
13970and occasionally eliminate the copy.
13971
13972Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13973
13974@item -fprofile-correction
13975@opindex fprofile-correction
13976Profiles collected using an instrumented binary for multi-threaded programs may
13977be inconsistent due to missed counter updates. When this option is specified,
13978GCC uses heuristics to correct or smooth out such inconsistencies. By
13979default, GCC emits an error message when an inconsistent profile is detected.
13980
13981This option is enabled by @option{-fauto-profile}.
13982
13983@item -fprofile-partial-training
13984@opindex fprofile-partial-training
13985With @code{-fprofile-use} all portions of programs not executed during train
13986run are optimized agressively for size rather than speed. In some cases it is
13987not practical to train all possible hot paths in the program. (For
13988example, program may contain functions specific for a given hardware and
13989trianing may not cover all hardware configurations program is run on.) With
13990@code{-fprofile-partial-training} profile feedback will be ignored for all
13991functions not executed during the train run leading them to be optimized as if
13992they were compiled without profile feedback. This leads to better performance
13993when train run is not representative but also leads to significantly bigger
13994code.
13995
13996@item -fprofile-use
13997@itemx -fprofile-use=@var{path}
13998@opindex fprofile-use
13999Enable profile feedback-directed optimizations,
14000and the following optimizations, many of which
14001are generally profitable only with profile feedback available:
14002
14003@gccoptlist{-fbranch-probabilities -fprofile-values @gol
14004-funroll-loops -fpeel-loops -ftracer -fvpt @gol
14005-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp @gol
14006-fpredictive-commoning -fsplit-loops -funswitch-loops @gol
14007-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize @gol
14008-fvect-cost-model=dynamic -ftree-loop-distribute-patterns @gol
14009-fprofile-reorder-functions}
14010
14011Before you can use this option, you must first generate profiling information.
14012@xref{Instrumentation Options}, for information about the
14013@option{-fprofile-generate} option.
14014
14015By default, GCC emits an error message if the feedback profiles do not
14016match the source code. This error can be turned into a warning by using
14017@option{-Wno-error=coverage-mismatch}. Note this may result in poorly
14018optimized code. Additionally, by default, GCC also emits a warning message if
14019the feedback profiles do not exist (see @option{-Wmissing-profile}).
14020
14021If @var{path} is specified, GCC looks at the @var{path} to find
14022the profile feedback data files. See @option{-fprofile-dir}.
14023
14024@item -fauto-profile
14025@itemx -fauto-profile=@var{path}
14026@opindex fauto-profile
14027Enable sampling-based feedback-directed optimizations,
14028and the following optimizations,
14029many of which are generally profitable only with profile feedback available:
14030
14031@gccoptlist{-fbranch-probabilities -fprofile-values @gol
14032-funroll-loops -fpeel-loops -ftracer -fvpt @gol
14033-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp @gol
14034-fpredictive-commoning -fsplit-loops -funswitch-loops @gol
14035-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize @gol
14036-fvect-cost-model=dynamic -ftree-loop-distribute-patterns @gol
14037-fprofile-correction}
14038
14039@var{path} is the name of a file containing AutoFDO profile information.
14040If omitted, it defaults to @file{fbdata.afdo} in the current directory.
14041
14042Producing an AutoFDO profile data file requires running your program
14043with the @command{perf} utility on a supported GNU/Linux target system.
14044For more information, see @uref{https://perf.wiki.kernel.org/}.
14045
14046E.g.
14047@smallexample
14048perf record -e br_inst_retired:near_taken -b -o perf.data \
14049 -- your_program
14050@end smallexample
14051
14052Then use the @command{create_gcov} tool to convert the raw profile data
14053to a format that can be used by GCC.@ You must also supply the
14054unstripped binary for your program to this tool.
14055See @uref{https://github.com/google/autofdo}.
14056
14057E.g.
14058@smallexample
14059create_gcov --binary=your_program.unstripped --profile=perf.data \
14060 --gcov=profile.afdo
14061@end smallexample
14062@end table
14063
14064The following options control compiler behavior regarding floating-point
14065arithmetic. These options trade off between speed and
14066correctness. All must be specifically enabled.
14067
14068@table @gcctabopt
14069@item -ffloat-store
14070@opindex ffloat-store
14071Do not store floating-point variables in registers, and inhibit other
14072options that might change whether a floating-point value is taken from a
14073register or memory.
14074
14075@cindex floating-point precision
14076This option prevents undesirable excess precision on machines such as
14077the 68000 where the floating registers (of the 68881) keep more
14078precision than a @code{double} is supposed to have. Similarly for the
14079x86 architecture. For most programs, the excess precision does only
14080good, but a few programs rely on the precise definition of IEEE floating
14081point. Use @option{-ffloat-store} for such programs, after modifying
14082them to store all pertinent intermediate computations into variables.
14083
14084@item -fexcess-precision=@var{style}
14085@opindex fexcess-precision
14086This option allows further control over excess precision on machines
14087where floating-point operations occur in a format with more precision or
14088range than the IEEE standard and interchange floating-point types. By
14089default, @option{-fexcess-precision=fast} is in effect; this means that
14090operations may be carried out in a wider precision than the types specified
14091in the source if that would result in faster code, and it is unpredictable
14092when rounding to the types specified in the source code takes place.
14093When compiling C or C++, if @option{-fexcess-precision=standard} is specified
14094then excess precision follows the rules specified in ISO C99 or C++; in particular,
14095both casts and assignments cause values to be rounded to their
14096semantic types (whereas @option{-ffloat-store} only affects
14097assignments). This option is enabled by default for C or C++ if a strict
14098conformance option such as @option{-std=c99} or @option{-std=c++17} is used.
14099@option{-ffast-math} enables @option{-fexcess-precision=fast} by default
14100regardless of whether a strict conformance option is used.
14101
14102@opindex mfpmath
14103@option{-fexcess-precision=standard} is not implemented for languages
14104other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse}
14105or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
14106semantics apply without excess precision, and in the latter, rounding
14107is unpredictable.
14108
14109@item -ffast-math
14110@opindex ffast-math
14111Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
14112@option{-ffinite-math-only}, @option{-fno-rounding-math},
14113@option{-fno-signaling-nans}, @option{-fcx-limited-range} and
14114@option{-fexcess-precision=fast}.
14115
14116This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
14117
14118This option is not turned on by any @option{-O} option besides
14119@option{-Ofast} since it can result in incorrect output for programs
14120that depend on an exact implementation of IEEE or ISO rules/specifications
14121for math functions. It may, however, yield faster code for programs
14122that do not require the guarantees of these specifications.
14123
14124@item -fno-math-errno
14125@opindex fno-math-errno
14126@opindex fmath-errno
14127Do not set @code{errno} after calling math functions that are executed
14128with a single instruction, e.g., @code{sqrt}. A program that relies on
14129IEEE exceptions for math error handling may want to use this flag
14130for speed while maintaining IEEE arithmetic compatibility.
14131
14132This option is not turned on by any @option{-O} option since
14133it can result in incorrect output for programs that depend on
14134an exact implementation of IEEE or ISO rules/specifications for
14135math functions. It may, however, yield faster code for programs
14136that do not require the guarantees of these specifications.
14137
14138The default is @option{-fmath-errno}.
14139
14140On Darwin systems, the math library never sets @code{errno}. There is
14141therefore no reason for the compiler to consider the possibility that
14142it might, and @option{-fno-math-errno} is the default.
14143
14144@item -funsafe-math-optimizations
14145@opindex funsafe-math-optimizations
14146
14147Allow optimizations for floating-point arithmetic that (a) assume
14148that arguments and results are valid and (b) may violate IEEE or
14149ANSI standards. When used at link time, it may include libraries
14150or startup files that change the default FPU control word or other
14151similar optimizations.
14152
14153This option is not turned on by any @option{-O} option since
14154it can result in incorrect output for programs that depend on
14155an exact implementation of IEEE or ISO rules/specifications for
14156math functions. It may, however, yield faster code for programs
14157that do not require the guarantees of these specifications.
14158Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
14159@option{-fassociative-math} and @option{-freciprocal-math}.
14160
14161The default is @option{-fno-unsafe-math-optimizations}.
14162
14163@item -fassociative-math
14164@opindex fassociative-math
14165
14166Allow re-association of operands in series of floating-point operations.
14167This violates the ISO C and C++ language standard by possibly changing
14168computation result. NOTE: re-ordering may change the sign of zero as
14169well as ignore NaNs and inhibit or create underflow or overflow (and
14170thus cannot be used on code that relies on rounding behavior like
14171@code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
14172and thus may not be used when ordered comparisons are required.
14173This option requires that both @option{-fno-signed-zeros} and
14174@option{-fno-trapping-math} be in effect. Moreover, it doesn't make
14175much sense with @option{-frounding-math}. For Fortran the option
14176is automatically enabled when both @option{-fno-signed-zeros} and
14177@option{-fno-trapping-math} are in effect.
14178
14179The default is @option{-fno-associative-math}.
14180
14181@item -freciprocal-math
14182@opindex freciprocal-math
14183
14184Allow the reciprocal of a value to be used instead of dividing by
14185the value if this enables optimizations. For example @code{x / y}
14186can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
14187is subject to common subexpression elimination. Note that this loses
14188precision and increases the number of flops operating on the value.
14189
14190The default is @option{-fno-reciprocal-math}.
14191
14192@item -ffinite-math-only
14193@opindex ffinite-math-only
14194Allow optimizations for floating-point arithmetic that assume
14195that arguments and results are not NaNs or +-Infs.
14196
14197This option is not turned on by any @option{-O} option since
14198it can result in incorrect output for programs that depend on
14199an exact implementation of IEEE or ISO rules/specifications for
14200math functions. It may, however, yield faster code for programs
14201that do not require the guarantees of these specifications.
14202
14203The default is @option{-fno-finite-math-only}.
14204
14205@item -fno-signed-zeros
14206@opindex fno-signed-zeros
14207@opindex fsigned-zeros
14208Allow optimizations for floating-point arithmetic that ignore the
14209signedness of zero. IEEE arithmetic specifies the behavior of
14210distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
14211of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
14212This option implies that the sign of a zero result isn't significant.
14213
14214The default is @option{-fsigned-zeros}.
14215
14216@item -fno-trapping-math
14217@opindex fno-trapping-math
14218@opindex ftrapping-math
14219Compile code assuming that floating-point operations cannot generate
14220user-visible traps. These traps include division by zero, overflow,
14221underflow, inexact result and invalid operation. This option requires
14222that @option{-fno-signaling-nans} be in effect. Setting this option may
14223allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
14224
14225This option should never be turned on by any @option{-O} option since
14226it can result in incorrect output for programs that depend on
14227an exact implementation of IEEE or ISO rules/specifications for
14228math functions.
14229
14230The default is @option{-ftrapping-math}.
14231
14232Future versions of GCC may provide finer control of this setting
14233using C99's @code{FENV_ACCESS} pragma. This command-line option
14234will be used along with @option{-frounding-math} to specify the
14235default state for @code{FENV_ACCESS}.
14236
14237@item -frounding-math
14238@opindex frounding-math
14239Disable transformations and optimizations that assume default floating-point
14240rounding behavior. This is round-to-zero for all floating point
14241to integer conversions, and round-to-nearest for all other arithmetic
14242truncations. This option should be specified for programs that change
14243the FP rounding mode dynamically, or that may be executed with a
14244non-default rounding mode. This option disables constant folding of
14245floating-point expressions at compile time (which may be affected by
14246rounding mode) and arithmetic transformations that are unsafe in the
14247presence of sign-dependent rounding modes.
14248
14249The default is @option{-fno-rounding-math}.
14250
14251This option is experimental and does not currently guarantee to
14252disable all GCC optimizations that are affected by rounding mode.
14253Future versions of GCC may provide finer control of this setting
14254using C99's @code{FENV_ACCESS} pragma. This command-line option
14255will be used along with @option{-ftrapping-math} to specify the
14256default state for @code{FENV_ACCESS}.
14257
14258@item -fsignaling-nans
14259@opindex fsignaling-nans
14260Compile code assuming that IEEE signaling NaNs may generate user-visible
14261traps during floating-point operations. Setting this option disables
14262optimizations that may change the number of exceptions visible with
14263signaling NaNs. This option implies @option{-ftrapping-math}.
14264
14265This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
14266be defined.
14267
14268The default is @option{-fno-signaling-nans}.
14269
14270This option is experimental and does not currently guarantee to
14271disable all GCC optimizations that affect signaling NaN behavior.
14272
14273@item -fno-fp-int-builtin-inexact
14274@opindex fno-fp-int-builtin-inexact
14275@opindex ffp-int-builtin-inexact
14276Do not allow the built-in functions @code{ceil}, @code{floor},
14277@code{round} and @code{trunc}, and their @code{float} and @code{long
14278double} variants, to generate code that raises the ``inexact''
14279floating-point exception for noninteger arguments. ISO C99 and C11
14280allow these functions to raise the ``inexact'' exception, but ISO/IEC
14281TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
14282ISO C2X, does not allow these functions to do so.
14283
14284The default is @option{-ffp-int-builtin-inexact}, allowing the
14285exception to be raised, unless C2X or a later C standard is selected.
14286This option does nothing unless @option{-ftrapping-math} is in effect.
14287
14288Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
14289generate a call to a library function then the ``inexact'' exception
14290may be raised if the library implementation does not follow TS 18661.
14291
14292@item -fsingle-precision-constant
14293@opindex fsingle-precision-constant
14294Treat floating-point constants as single precision instead of
14295implicitly converting them to double-precision constants.
14296
14297@item -fcx-limited-range
14298@opindex fcx-limited-range
14299When enabled, this option states that a range reduction step is not
14300needed when performing complex division. Also, there is no checking
14301whether the result of a complex multiplication or division is @code{NaN
14302+ I*NaN}, with an attempt to rescue the situation in that case. The
14303default is @option{-fno-cx-limited-range}, but is enabled by
14304@option{-ffast-math}.
14305
14306This option controls the default setting of the ISO C99
14307@code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
14308all languages.
14309
14310@item -fcx-fortran-rules
14311@opindex fcx-fortran-rules
14312Complex multiplication and division follow Fortran rules. Range
14313reduction is done as part of complex division, but there is no checking
14314whether the result of a complex multiplication or division is @code{NaN
14315+ I*NaN}, with an attempt to rescue the situation in that case.
14316
14317The default is @option{-fno-cx-fortran-rules}.
14318
14319@end table
14320
14321The following options control optimizations that may improve
14322performance, but are not enabled by any @option{-O} options. This
14323section includes experimental options that may produce broken code.
14324
14325@table @gcctabopt
14326@item -fbranch-probabilities
14327@opindex fbranch-probabilities
14328After running a program compiled with @option{-fprofile-arcs}
14329(@pxref{Instrumentation Options}),
14330you can compile it a second time using
14331@option{-fbranch-probabilities}, to improve optimizations based on
14332the number of times each branch was taken. When a program
14333compiled with @option{-fprofile-arcs} exits, it saves arc execution
14334counts to a file called @file{@var{sourcename}.gcda} for each source
14335file. The information in this data file is very dependent on the
14336structure of the generated code, so you must use the same source code
14337and the same optimization options for both compilations.
14338See details about the file naming in @option{-fprofile-arcs}.
14339
14340With @option{-fbranch-probabilities}, GCC puts a
14341@samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
14342These can be used to improve optimization. Currently, they are only
14343used in one place: in @file{reorg.cc}, instead of guessing which path a
14344branch is most likely to take, the @samp{REG_BR_PROB} values are used to
14345exactly determine which path is taken more often.
14346
14347Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14348
14349@item -fprofile-values
14350@opindex fprofile-values
14351If combined with @option{-fprofile-arcs}, it adds code so that some
14352data about values of expressions in the program is gathered.
14353
14354With @option{-fbranch-probabilities}, it reads back the data gathered
14355from profiling values of expressions for usage in optimizations.
14356
14357Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
14358@option{-fauto-profile}.
14359
14360@item -fprofile-reorder-functions
14361@opindex fprofile-reorder-functions
14362Function reordering based on profile instrumentation collects
14363first time of execution of a function and orders these functions
14364in ascending order.
14365
14366Enabled with @option{-fprofile-use}.
14367
14368@item -fvpt
14369@opindex fvpt
14370If combined with @option{-fprofile-arcs}, this option instructs the compiler
14371to add code to gather information about values of expressions.
14372
14373With @option{-fbranch-probabilities}, it reads back the data gathered
14374and actually performs the optimizations based on them.
14375Currently the optimizations include specialization of division operations
14376using the knowledge about the value of the denominator.
14377
14378Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
14379
14380@item -frename-registers
14381@opindex frename-registers
14382Attempt to avoid false dependencies in scheduled code by making use
14383of registers left over after register allocation. This optimization
14384most benefits processors with lots of registers. Depending on the
14385debug information format adopted by the target, however, it can
14386make debugging impossible, since variables no longer stay in
14387a ``home register''.
14388
14389Enabled by default with @option{-funroll-loops}.
14390
14391@item -fschedule-fusion
14392@opindex fschedule-fusion
14393Performs a target dependent pass over the instruction stream to schedule
14394instructions of same type together because target machine can execute them
14395more efficiently if they are adjacent to each other in the instruction flow.
14396
14397Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14398
14399@item -ftracer
14400@opindex ftracer
14401Perform tail duplication to enlarge superblock size. This transformation
14402simplifies the control flow of the function allowing other optimizations to do
14403a better job.
14404
14405Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14406
14407@item -funroll-loops
14408@opindex funroll-loops
14409Unroll loops whose number of iterations can be determined at compile time or
14410upon entry to the loop. @option{-funroll-loops} implies
14411@option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
14412It also turns on complete loop peeling (i.e.@: complete removal of loops with
14413a small constant number of iterations). This option makes code larger, and may
14414or may not make it run faster.
14415
14416Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14417
14418@item -funroll-all-loops
14419@opindex funroll-all-loops
14420Unroll all loops, even if their number of iterations is uncertain when
14421the loop is entered. This usually makes programs run more slowly.
14422@option{-funroll-all-loops} implies the same options as
14423@option{-funroll-loops}.
14424
14425@item -fpeel-loops
14426@opindex fpeel-loops
14427Peels loops for which there is enough information that they do not
14428roll much (from profile feedback or static analysis). It also turns on
14429complete loop peeling (i.e.@: complete removal of loops with small constant
14430number of iterations).
14431
14432Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
14433
14434@item -fmove-loop-invariants
14435@opindex fmove-loop-invariants
14436Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
14437at level @option{-O1} and higher, except for @option{-Og}.
14438
14439@item -fmove-loop-stores
14440@opindex fmove-loop-stores
14441Enables the loop store motion pass in the GIMPLE loop optimizer. This
14442moves invariant stores to after the end of the loop in exchange for
14443carrying the stored value in a register across the iteration.
14444Note for this option to have an effect @option{-ftree-loop-im} has to
14445be enabled as well. Enabled at level @option{-O1} and higher, except
14446for @option{-Og}.
14447
14448@item -fsplit-loops
14449@opindex fsplit-loops
14450Split a loop into two if it contains a condition that's always true
14451for one side of the iteration space and false for the other.
14452
14453Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14454
14455@item -funswitch-loops
14456@opindex funswitch-loops
14457Move branches with loop invariant conditions out of the loop, with duplicates
14458of the loop on both branches (modified according to result of the condition).
14459
14460Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14461
14462@item -fversion-loops-for-strides
14463@opindex fversion-loops-for-strides
14464If a loop iterates over an array with a variable stride, create another
14465version of the loop that assumes the stride is always one. For example:
14466
14467@smallexample
14468for (int i = 0; i < n; ++i)
14469 x[i * stride] = @dots{};
14470@end smallexample
14471
14472becomes:
14473
14474@smallexample
14475if (stride == 1)
14476 for (int i = 0; i < n; ++i)
14477 x[i] = @dots{};
14478else
14479 for (int i = 0; i < n; ++i)
14480 x[i * stride] = @dots{};
14481@end smallexample
14482
14483This is particularly useful for assumed-shape arrays in Fortran where
14484(for example) it allows better vectorization assuming contiguous accesses.
14485This flag is enabled by default at @option{-O3}.
14486It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14487
14488@item -ffunction-sections
14489@itemx -fdata-sections
14490@opindex ffunction-sections
14491@opindex fdata-sections
14492Place each function or data item into its own section in the output
14493file if the target supports arbitrary sections. The name of the
14494function or the name of the data item determines the section's name
14495in the output file.
14496
14497Use these options on systems where the linker can perform optimizations to
14498improve locality of reference in the instruction space. Most systems using the
14499ELF object format have linkers with such optimizations. On AIX, the linker
14500rearranges sections (CSECTs) based on the call graph. The performance impact
14501varies.
14502
14503Together with a linker garbage collection (linker @option{--gc-sections}
14504option) these options may lead to smaller statically-linked executables (after
14505stripping).
14506
14507On ELF/DWARF systems these options do not degenerate the quality of the debug
14508information. There could be issues with other object files/debug info formats.
14509
14510Only use these options when there are significant benefits from doing so. When
14511you specify these options, the assembler and linker create larger object and
14512executable files and are also slower. These options affect code generation.
14513They prevent optimizations by the compiler and assembler using relative
14514locations inside a translation unit since the locations are unknown until
14515link time. An example of such an optimization is relaxing calls to short call
14516instructions.
14517
14518@item -fstdarg-opt
14519@opindex fstdarg-opt
14520Optimize the prologue of variadic argument functions with respect to usage of
14521those arguments.
14522
14523@item -fsection-anchors
14524@opindex fsection-anchors
14525Try to reduce the number of symbolic address calculations by using
14526shared ``anchor'' symbols to address nearby objects. This transformation
14527can help to reduce the number of GOT entries and GOT accesses on some
14528targets.
14529
14530For example, the implementation of the following function @code{foo}:
14531
14532@smallexample
14533static int a, b, c;
14534int foo (void) @{ return a + b + c; @}
14535@end smallexample
14536
14537@noindent
14538usually calculates the addresses of all three variables, but if you
14539compile it with @option{-fsection-anchors}, it accesses the variables
14540from a common anchor point instead. The effect is similar to the
14541following pseudocode (which isn't valid C):
14542
14543@smallexample
14544int foo (void)
14545@{
14546 register int *xr = &x;
14547 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
14548@}
14549@end smallexample
14550
14551Not all targets support this option.
14552
14553@item -fzero-call-used-regs=@var{choice}
14554@opindex fzero-call-used-regs
14555Zero call-used registers at function return to increase program
14556security by either mitigating Return-Oriented Programming (ROP)
14557attacks or preventing information leakage through registers.
14558
14559The possible values of @var{choice} are the same as for the
14560@code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
14561The default is @samp{skip}.
14562
14563You can control this behavior for a specific function by using the function
14564attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
14565
14566@item --param @var{name}=@var{value}
14567@opindex param
14568In some places, GCC uses various constants to control the amount of
14569optimization that is done. For example, GCC does not inline functions
14570that contain more than a certain number of instructions. You can
14571control some of these constants on the command line using the
14572@option{--param} option.
14573
14574The names of specific parameters, and the meaning of the values, are
14575tied to the internals of the compiler, and are subject to change
14576without notice in future releases.
14577
14578In order to get minimal, maximal and default value of a parameter,
14579one can use @option{--help=param -Q} options.
14580
14581In each case, the @var{value} is an integer. The following choices
14582of @var{name} are recognized for all targets:
14583
14584@table @gcctabopt
14585@item predictable-branch-outcome
14586When branch is predicted to be taken with probability lower than this threshold
14587(in percent), then it is considered well predictable.
14588
14589@item max-rtl-if-conversion-insns
14590RTL if-conversion tries to remove conditional branches around a block and
14591replace them with conditionally executed instructions. This parameter
14592gives the maximum number of instructions in a block which should be
14593considered for if-conversion. The compiler will
14594also use other heuristics to decide whether if-conversion is likely to be
14595profitable.
14596
14597@item max-rtl-if-conversion-predictable-cost
14598RTL if-conversion will try to remove conditional branches around a block
14599and replace them with conditionally executed instructions. These parameters
14600give the maximum permissible cost for the sequence that would be generated
14601by if-conversion depending on whether the branch is statically determined
14602to be predictable or not. The units for this parameter are the same as
14603those for the GCC internal seq_cost metric. The compiler will try to
14604provide a reasonable default for this parameter using the BRANCH_COST
14605target macro.
14606
14607@item max-crossjump-edges
14608The maximum number of incoming edges to consider for cross-jumping.
14609The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
14610the number of edges incoming to each block. Increasing values mean
14611more aggressive optimization, making the compilation time increase with
14612probably small improvement in executable size.
14613
14614@item min-crossjump-insns
14615The minimum number of instructions that must be matched at the end
14616of two blocks before cross-jumping is performed on them. This
14617value is ignored in the case where all instructions in the block being
14618cross-jumped from are matched.
14619
14620@item max-grow-copy-bb-insns
14621The maximum code size expansion factor when copying basic blocks
14622instead of jumping. The expansion is relative to a jump instruction.
14623
14624@item max-goto-duplication-insns
14625The maximum number of instructions to duplicate to a block that jumps
14626to a computed goto. To avoid @math{O(N^2)} behavior in a number of
14627passes, GCC factors computed gotos early in the compilation process,
14628and unfactors them as late as possible. Only computed jumps at the
14629end of a basic blocks with no more than max-goto-duplication-insns are
14630unfactored.
14631
14632@item max-delay-slot-insn-search
14633The maximum number of instructions to consider when looking for an
14634instruction to fill a delay slot. If more than this arbitrary number of
14635instructions are searched, the time savings from filling the delay slot
14636are minimal, so stop searching. Increasing values mean more
14637aggressive optimization, making the compilation time increase with probably
14638small improvement in execution time.
14639
14640@item max-delay-slot-live-search
14641When trying to fill delay slots, the maximum number of instructions to
14642consider when searching for a block with valid live register
14643information. Increasing this arbitrarily chosen value means more
14644aggressive optimization, increasing the compilation time. This parameter
14645should be removed when the delay slot code is rewritten to maintain the
14646control-flow graph.
14647
14648@item max-gcse-memory
14649The approximate maximum amount of memory in @code{kB} that can be allocated in
14650order to perform the global common subexpression elimination
14651optimization. If more memory than specified is required, the
14652optimization is not done.
14653
14654@item max-gcse-insertion-ratio
14655If the ratio of expression insertions to deletions is larger than this value
14656for any expression, then RTL PRE inserts or removes the expression and thus
14657leaves partially redundant computations in the instruction stream.
14658
14659@item max-pending-list-length
14660The maximum number of pending dependencies scheduling allows
14661before flushing the current state and starting over. Large functions
14662with few branches or calls can create excessively large lists which
14663needlessly consume memory and resources.
14664
14665@item max-modulo-backtrack-attempts
14666The maximum number of backtrack attempts the scheduler should make
14667when modulo scheduling a loop. Larger values can exponentially increase
14668compilation time.
14669
14670@item max-inline-functions-called-once-loop-depth
14671Maximal loop depth of a call considered by inline heuristics that tries to
14672inline all functions called once.
14673
14674@item max-inline-functions-called-once-insns
14675Maximal estimated size of functions produced while inlining functions called
14676once.
14677
14678@item max-inline-insns-single
14679Several parameters control the tree inliner used in GCC@. This number sets the
14680maximum number of instructions (counted in GCC's internal representation) in a
14681single function that the tree inliner considers for inlining. This only
14682affects functions declared inline and methods implemented in a class
14683declaration (C++).
14684
14685
14686@item max-inline-insns-auto
14687When you use @option{-finline-functions} (included in @option{-O3}),
14688a lot of functions that would otherwise not be considered for inlining
14689by the compiler are investigated. To those functions, a different
14690(more restrictive) limit compared to functions declared inline can
14691be applied (@option{--param max-inline-insns-auto}).
14692
14693@item max-inline-insns-small
14694This is bound applied to calls which are considered relevant with
14695@option{-finline-small-functions}.
14696
14697@item max-inline-insns-size
14698This is bound applied to calls which are optimized for size. Small growth
14699may be desirable to anticipate optimization oppurtunities exposed by inlining.
14700
14701@item uninlined-function-insns
14702Number of instructions accounted by inliner for function overhead such as
14703function prologue and epilogue.
14704
14705@item uninlined-function-time
14706Extra time accounted by inliner for function overhead such as time needed to
14707execute function prologue and epilogue.
14708
14709@item inline-heuristics-hint-percent
14710The scale (in percents) applied to @option{inline-insns-single},
14711@option{inline-insns-single-O2}, @option{inline-insns-auto}
14712when inline heuristics hints that inlining is
14713very profitable (will enable later optimizations).
14714
14715@item uninlined-thunk-insns
14716@item uninlined-thunk-time
14717Same as @option{--param uninlined-function-insns} and
14718@option{--param uninlined-function-time} but applied to function thunks.
14719
14720@item inline-min-speedup
14721When estimated performance improvement of caller + callee runtime exceeds this
14722threshold (in percent), the function can be inlined regardless of the limit on
14723@option{--param max-inline-insns-single} and @option{--param
14724max-inline-insns-auto}.
14725
14726@item large-function-insns
14727The limit specifying really large functions. For functions larger than this
14728limit after inlining, inlining is constrained by
14729@option{--param large-function-growth}. This parameter is useful primarily
14730to avoid extreme compilation time caused by non-linear algorithms used by the
14731back end.
14732
14733@item large-function-growth
14734Specifies maximal growth of large function caused by inlining in percents.
14735For example, parameter value 100 limits large function growth to 2.0 times
14736the original size.
14737
14738@item large-unit-insns
14739The limit specifying large translation unit. Growth caused by inlining of
14740units larger than this limit is limited by @option{--param inline-unit-growth}.
14741For small units this might be too tight.
14742For example, consider a unit consisting of function A
14743that is inline and B that just calls A three times. If B is small relative to
14744A, the growth of unit is 300\% and yet such inlining is very sane. For very
14745large units consisting of small inlineable functions, however, the overall unit
14746growth limit is needed to avoid exponential explosion of code size. Thus for
14747smaller units, the size is increased to @option{--param large-unit-insns}
14748before applying @option{--param inline-unit-growth}.
14749
14750@item lazy-modules
14751Maximum number of concurrently open C++ module files when lazy loading.
14752
14753@item inline-unit-growth
14754Specifies maximal overall growth of the compilation unit caused by inlining.
14755For example, parameter value 20 limits unit growth to 1.2 times the original
14756size. Cold functions (either marked cold via an attribute or by profile
14757feedback) are not accounted into the unit size.
14758
14759@item ipa-cp-unit-growth
14760Specifies maximal overall growth of the compilation unit caused by
14761interprocedural constant propagation. For example, parameter value 10 limits
14762unit growth to 1.1 times the original size.
14763
14764@item ipa-cp-large-unit-insns
14765The size of translation unit that IPA-CP pass considers large.
14766
14767@item large-stack-frame
14768The limit specifying large stack frames. While inlining the algorithm is trying
14769to not grow past this limit too much.
14770
14771@item large-stack-frame-growth
14772Specifies maximal growth of large stack frames caused by inlining in percents.
14773For example, parameter value 1000 limits large stack frame growth to 11 times
14774the original size.
14775
14776@item max-inline-insns-recursive
14777@itemx max-inline-insns-recursive-auto
14778Specifies the maximum number of instructions an out-of-line copy of a
14779self-recursive inline
14780function can grow into by performing recursive inlining.
14781
14782@option{--param max-inline-insns-recursive} applies to functions
14783declared inline.
14784For functions not declared inline, recursive inlining
14785happens only when @option{-finline-functions} (included in @option{-O3}) is
14786enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
14787
14788@item max-inline-recursive-depth
14789@itemx max-inline-recursive-depth-auto
14790Specifies the maximum recursion depth used for recursive inlining.
14791
14792@option{--param max-inline-recursive-depth} applies to functions
14793declared inline. For functions not declared inline, recursive inlining
14794happens only when @option{-finline-functions} (included in @option{-O3}) is
14795enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
14796
14797@item min-inline-recursive-probability
14798Recursive inlining is profitable only for function having deep recursion
14799in average and can hurt for function having little recursion depth by
14800increasing the prologue size or complexity of function body to other
14801optimizers.
14802
14803When profile feedback is available (see @option{-fprofile-generate}) the actual
14804recursion depth can be guessed from the probability that function recurses
14805via a given call expression. This parameter limits inlining only to call
14806expressions whose probability exceeds the given threshold (in percents).
14807
14808@item early-inlining-insns
14809Specify growth that the early inliner can make. In effect it increases
14810the amount of inlining for code having a large abstraction penalty.
14811
14812@item max-early-inliner-iterations
14813Limit of iterations of the early inliner. This basically bounds
14814the number of nested indirect calls the early inliner can resolve.
14815Deeper chains are still handled by late inlining.
14816
14817@item comdat-sharing-probability
14818Probability (in percent) that C++ inline function with comdat visibility
14819are shared across multiple compilation units.
14820
14821@item modref-max-bases
14822@item modref-max-refs
14823@item modref-max-accesses
14824Specifies the maximal number of base pointers, references and accesses stored
14825for a single function by mod/ref analysis.
14826
14827@item modref-max-tests
14828Specifies the maxmal number of tests alias oracle can perform to disambiguate
14829memory locations using the mod/ref information. This parameter ought to be
14830bigger than @option{--param modref-max-bases} and @option{--param
14831modref-max-refs}.
14832
14833@item modref-max-depth
14834Specifies the maximum depth of DFS walk used by modref escape analysis.
14835Setting to 0 disables the analysis completely.
14836
14837@item modref-max-escape-points
14838Specifies the maximum number of escape points tracked by modref per SSA-name.
14839
14840@item modref-max-adjustments
14841Specifies the maximum number the access range is enlarged during modref dataflow
14842analysis.
14843
14844@item profile-func-internal-id
14845A parameter to control whether to use function internal id in profile
14846database lookup. If the value is 0, the compiler uses an id that
14847is based on function assembler name and filename, which makes old profile
14848data more tolerant to source changes such as function reordering etc.
14849
14850@item min-vect-loop-bound
14851The minimum number of iterations under which loops are not vectorized
14852when @option{-ftree-vectorize} is used. The number of iterations after
14853vectorization needs to be greater than the value specified by this option
14854to allow vectorization.
14855
14856@item gcse-cost-distance-ratio
14857Scaling factor in calculation of maximum distance an expression
14858can be moved by GCSE optimizations. This is currently supported only in the
14859code hoisting pass. The bigger the ratio, the more aggressive code hoisting
14860is with simple expressions, i.e., the expressions that have cost
14861less than @option{gcse-unrestricted-cost}. Specifying 0 disables
14862hoisting of simple expressions.
14863
14864@item gcse-unrestricted-cost
14865Cost, roughly measured as the cost of a single typical machine
14866instruction, at which GCSE optimizations do not constrain
14867the distance an expression can travel. This is currently
14868supported only in the code hoisting pass. The lesser the cost,
14869the more aggressive code hoisting is. Specifying 0
14870allows all expressions to travel unrestricted distances.
14871
14872@item max-hoist-depth
14873The depth of search in the dominator tree for expressions to hoist.
14874This is used to avoid quadratic behavior in hoisting algorithm.
14875The value of 0 does not limit on the search, but may slow down compilation
14876of huge functions.
14877
14878@item max-tail-merge-comparisons
14879The maximum amount of similar bbs to compare a bb with. This is used to
14880avoid quadratic behavior in tree tail merging.
14881
14882@item max-tail-merge-iterations
14883The maximum amount of iterations of the pass over the function. This is used to
14884limit compilation time in tree tail merging.
14885
14886@item store-merging-allow-unaligned
14887Allow the store merging pass to introduce unaligned stores if it is legal to
14888do so.
14889
14890@item max-stores-to-merge
14891The maximum number of stores to attempt to merge into wider stores in the store
14892merging pass.
14893
14894@item max-store-chains-to-track
14895The maximum number of store chains to track at the same time in the attempt
14896to merge them into wider stores in the store merging pass.
14897
14898@item max-stores-to-track
14899The maximum number of stores to track at the same time in the attemt to
14900to merge them into wider stores in the store merging pass.
14901
14902@item max-unrolled-insns
14903The maximum number of instructions that a loop may have to be unrolled.
14904If a loop is unrolled, this parameter also determines how many times
14905the loop code is unrolled.
14906
14907@item max-average-unrolled-insns
14908The maximum number of instructions biased by probabilities of their execution
14909that a loop may have to be unrolled. If a loop is unrolled,
14910this parameter also determines how many times the loop code is unrolled.
14911
14912@item max-unroll-times
14913The maximum number of unrollings of a single loop.
14914
14915@item max-peeled-insns
14916The maximum number of instructions that a loop may have to be peeled.
14917If a loop is peeled, this parameter also determines how many times
14918the loop code is peeled.
14919
14920@item max-peel-times
14921The maximum number of peelings of a single loop.
14922
14923@item max-peel-branches
14924The maximum number of branches on the hot path through the peeled sequence.
14925
14926@item max-completely-peeled-insns
14927The maximum number of insns of a completely peeled loop.
14928
14929@item max-completely-peel-times
14930The maximum number of iterations of a loop to be suitable for complete peeling.
14931
14932@item max-completely-peel-loop-nest-depth
14933The maximum depth of a loop nest suitable for complete peeling.
14934
14935@item max-unswitch-insns
14936The maximum number of insns of an unswitched loop.
14937
14938@item lim-expensive
14939The minimum cost of an expensive expression in the loop invariant motion.
14940
14941@item min-loop-cond-split-prob
14942When FDO profile information is available, @option{min-loop-cond-split-prob}
14943specifies minimum threshold for probability of semi-invariant condition
14944statement to trigger loop split.
14945
14946@item iv-consider-all-candidates-bound
14947Bound on number of candidates for induction variables, below which
14948all candidates are considered for each use in induction variable
14949optimizations. If there are more candidates than this,
14950only the most relevant ones are considered to avoid quadratic time complexity.
14951
14952@item iv-max-considered-uses
14953The induction variable optimizations give up on loops that contain more
14954induction variable uses.
14955
14956@item iv-always-prune-cand-set-bound
14957If the number of candidates in the set is smaller than this value,
14958always try to remove unnecessary ivs from the set
14959when adding a new one.
14960
14961@item avg-loop-niter
14962Average number of iterations of a loop.
14963
14964@item dse-max-object-size
14965Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
14966Larger values may result in larger compilation times.
14967
14968@item dse-max-alias-queries-per-store
14969Maximum number of queries into the alias oracle per store.
14970Larger values result in larger compilation times and may result in more
14971removed dead stores.
14972
14973@item scev-max-expr-size
14974Bound on size of expressions used in the scalar evolutions analyzer.
14975Large expressions slow the analyzer.
14976
14977@item scev-max-expr-complexity
14978Bound on the complexity of the expressions in the scalar evolutions analyzer.
14979Complex expressions slow the analyzer.
14980
14981@item max-tree-if-conversion-phi-args
14982Maximum number of arguments in a PHI supported by TREE if conversion
14983unless the loop is marked with simd pragma.
14984
14985@item vect-max-layout-candidates
14986The maximum number of possible vector layouts (such as permutations)
14987to consider when optimizing to-be-vectorized code.
14988
14989@item vect-max-version-for-alignment-checks
14990The maximum number of run-time checks that can be performed when
14991doing loop versioning for alignment in the vectorizer.
14992
14993@item vect-max-version-for-alias-checks
14994The maximum number of run-time checks that can be performed when
14995doing loop versioning for alias in the vectorizer.
14996
14997@item vect-max-peeling-for-alignment
14998The maximum number of loop peels to enhance access alignment
14999for vectorizer. Value -1 means no limit.
15000
15001@item max-iterations-to-track
15002The maximum number of iterations of a loop the brute-force algorithm
15003for analysis of the number of iterations of the loop tries to evaluate.
15004
15005@item hot-bb-count-fraction
15006The denominator n of fraction 1/n of the maximal execution count of a
15007basic block in the entire program that a basic block needs to at least
15008have in order to be considered hot. The default is 10000, which means
15009that a basic block is considered hot if its execution count is greater
15010than 1/10000 of the maximal execution count. 0 means that it is never
15011considered hot. Used in non-LTO mode.
15012
15013@item hot-bb-count-ws-permille
15014The number of most executed permilles, ranging from 0 to 1000, of the
15015profiled execution of the entire program to which the execution count
15016of a basic block must be part of in order to be considered hot. The
15017default is 990, which means that a basic block is considered hot if
15018its execution count contributes to the upper 990 permilles, or 99.0%,
15019of the profiled execution of the entire program. 0 means that it is
15020never considered hot. Used in LTO mode.
15021
15022@item hot-bb-frequency-fraction
15023The denominator n of fraction 1/n of the execution frequency of the
15024entry block of a function that a basic block of this function needs
15025to at least have in order to be considered hot. The default is 1000,
15026which means that a basic block is considered hot in a function if it
15027is executed more frequently than 1/1000 of the frequency of the entry
15028block of the function. 0 means that it is never considered hot.
15029
15030@item unlikely-bb-count-fraction
15031The denominator n of fraction 1/n of the number of profiled runs of
15032the entire program below which the execution count of a basic block
15033must be in order for the basic block to be considered unlikely executed.
15034The default is 20, which means that a basic block is considered unlikely
15035executed if it is executed in fewer than 1/20, or 5%, of the runs of
15036the program. 0 means that it is always considered unlikely executed.
15037
15038@item max-predicted-iterations
15039The maximum number of loop iterations we predict statically. This is useful
15040in cases where a function contains a single loop with known bound and
15041another loop with unknown bound.
15042The known number of iterations is predicted correctly, while
15043the unknown number of iterations average to roughly 10. This means that the
15044loop without bounds appears artificially cold relative to the other one.
15045
15046@item builtin-expect-probability
15047Control the probability of the expression having the specified value. This
15048parameter takes a percentage (i.e.@: 0 ... 100) as input.
15049
15050@item builtin-string-cmp-inline-length
15051The maximum length of a constant string for a builtin string cmp call
15052eligible for inlining.
15053
15054@item align-threshold
15055
15056Select fraction of the maximal frequency of executions of a basic block in
15057a function to align the basic block.
15058
15059@item align-loop-iterations
15060
15061A loop expected to iterate at least the selected number of iterations is
15062aligned.
15063
15064@item tracer-dynamic-coverage
15065@itemx tracer-dynamic-coverage-feedback
15066
15067This value is used to limit superblock formation once the given percentage of
15068executed instructions is covered. This limits unnecessary code size
15069expansion.
15070
15071The @option{tracer-dynamic-coverage-feedback} parameter
15072is used only when profile
15073feedback is available. The real profiles (as opposed to statically estimated
15074ones) are much less balanced allowing the threshold to be larger value.
15075
15076@item tracer-max-code-growth
15077Stop tail duplication once code growth has reached given percentage. This is
15078a rather artificial limit, as most of the duplicates are eliminated later in
15079cross jumping, so it may be set to much higher values than is the desired code
15080growth.
15081
15082@item tracer-min-branch-ratio
15083
15084Stop reverse growth when the reverse probability of best edge is less than this
15085threshold (in percent).
15086
15087@item tracer-min-branch-probability
15088@itemx tracer-min-branch-probability-feedback
15089
15090Stop forward growth if the best edge has probability lower than this
15091threshold.
15092
15093Similarly to @option{tracer-dynamic-coverage} two parameters are
15094provided. @option{tracer-min-branch-probability-feedback} is used for
15095compilation with profile feedback and @option{tracer-min-branch-probability}
15096compilation without. The value for compilation with profile feedback
15097needs to be more conservative (higher) in order to make tracer
15098effective.
15099
15100@item stack-clash-protection-guard-size
15101Specify the size of the operating system provided stack guard as
151022 raised to @var{num} bytes. Higher values may reduce the
15103number of explicit probes, but a value larger than the operating system
15104provided guard will leave code vulnerable to stack clash style attacks.
15105
15106@item stack-clash-protection-probe-interval
15107Stack clash protection involves probing stack space as it is allocated. This
15108param controls the maximum distance between probes into the stack as 2 raised
15109to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
15110larger than the operating system provided guard will leave code vulnerable to
15111stack clash style attacks.
15112
15113@item max-cse-path-length
15114
15115The maximum number of basic blocks on path that CSE considers.
15116
15117@item max-cse-insns
15118The maximum number of instructions CSE processes before flushing.
15119
15120@item ggc-min-expand
15121
15122GCC uses a garbage collector to manage its own memory allocation. This
15123parameter specifies the minimum percentage by which the garbage
15124collector's heap should be allowed to expand between collections.
15125Tuning this may improve compilation speed; it has no effect on code
15126generation.
15127
15128The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
15129RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
15130the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
15131GCC is not able to calculate RAM on a particular platform, the lower
15132bound of 30% is used. Setting this parameter and
15133@option{ggc-min-heapsize} to zero causes a full collection to occur at
15134every opportunity. This is extremely slow, but can be useful for
15135debugging.
15136
15137@item ggc-min-heapsize
15138
15139Minimum size of the garbage collector's heap before it begins bothering
15140to collect garbage. The first collection occurs after the heap expands
15141by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
15142tuning this may improve compilation speed, and has no effect on code
15143generation.
15144
15145The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
15146tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
15147with a lower bound of 4096 (four megabytes) and an upper bound of
15148131072 (128 megabytes). If GCC is not able to calculate RAM on a
15149particular platform, the lower bound is used. Setting this parameter
15150very large effectively disables garbage collection. Setting this
15151parameter and @option{ggc-min-expand} to zero causes a full collection
15152to occur at every opportunity.
15153
15154@item max-reload-search-insns
15155The maximum number of instruction reload should look backward for equivalent
15156register. Increasing values mean more aggressive optimization, making the
15157compilation time increase with probably slightly better performance.
15158
15159@item max-cselib-memory-locations
15160The maximum number of memory locations cselib should take into account.
15161Increasing values mean more aggressive optimization, making the compilation time
15162increase with probably slightly better performance.
15163
15164@item max-sched-ready-insns
15165The maximum number of instructions ready to be issued the scheduler should
15166consider at any given time during the first scheduling pass. Increasing
15167values mean more thorough searches, making the compilation time increase
15168with probably little benefit.
15169
15170@item max-sched-region-blocks
15171The maximum number of blocks in a region to be considered for
15172interblock scheduling.
15173
15174@item max-pipeline-region-blocks
15175The maximum number of blocks in a region to be considered for
15176pipelining in the selective scheduler.
15177
15178@item max-sched-region-insns
15179The maximum number of insns in a region to be considered for
15180interblock scheduling.
15181
15182@item max-pipeline-region-insns
15183The maximum number of insns in a region to be considered for
15184pipelining in the selective scheduler.
15185
15186@item min-spec-prob
15187The minimum probability (in percents) of reaching a source block
15188for interblock speculative scheduling.
15189
15190@item max-sched-extend-regions-iters
15191The maximum number of iterations through CFG to extend regions.
15192A value of 0 disables region extensions.
15193
15194@item max-sched-insn-conflict-delay
15195The maximum conflict delay for an insn to be considered for speculative motion.
15196
15197@item sched-spec-prob-cutoff
15198The minimal probability of speculation success (in percents), so that
15199speculative insns are scheduled.
15200
15201@item sched-state-edge-prob-cutoff
15202The minimum probability an edge must have for the scheduler to save its
15203state across it.
15204
15205@item sched-mem-true-dep-cost
15206Minimal distance (in CPU cycles) between store and load targeting same
15207memory locations.
15208
15209@item selsched-max-lookahead
15210The maximum size of the lookahead window of selective scheduling. It is a
15211depth of search for available instructions.
15212
15213@item selsched-max-sched-times
15214The maximum number of times that an instruction is scheduled during
15215selective scheduling. This is the limit on the number of iterations
15216through which the instruction may be pipelined.
15217
15218@item selsched-insns-to-rename
15219The maximum number of best instructions in the ready list that are considered
15220for renaming in the selective scheduler.
15221
15222@item sms-min-sc
15223The minimum value of stage count that swing modulo scheduler
15224generates.
15225
15226@item max-last-value-rtl
15227The maximum size measured as number of RTLs that can be recorded in an expression
15228in combiner for a pseudo register as last known value of that register.
15229
15230@item max-combine-insns
15231The maximum number of instructions the RTL combiner tries to combine.
15232
15233@item integer-share-limit
15234Small integer constants can use a shared data structure, reducing the
15235compiler's memory usage and increasing its speed. This sets the maximum
15236value of a shared integer constant.
15237
15238@item ssp-buffer-size
15239The minimum size of buffers (i.e.@: arrays) that receive stack smashing
15240protection when @option{-fstack-protector} is used.
15241
15242@item min-size-for-stack-sharing
15243The minimum size of variables taking part in stack slot sharing when not
15244optimizing.
15245
15246@item max-jump-thread-duplication-stmts
15247Maximum number of statements allowed in a block that needs to be
15248duplicated when threading jumps.
15249
15250@item max-jump-thread-paths
15251The maximum number of paths to consider when searching for jump threading
15252opportunities. When arriving at a block, incoming edges are only considered
15253if the number of paths to be searched so far multiplied by the number of
15254incoming edges does not exhaust the specified maximum number of paths to
15255consider.
15256
15257@item max-fields-for-field-sensitive
15258Maximum number of fields in a structure treated in
15259a field sensitive manner during pointer analysis.
15260
15261@item prefetch-latency
15262Estimate on average number of instructions that are executed before
15263prefetch finishes. The distance prefetched ahead is proportional
15264to this constant. Increasing this number may also lead to less
15265streams being prefetched (see @option{simultaneous-prefetches}).
15266
15267@item simultaneous-prefetches
15268Maximum number of prefetches that can run at the same time.
15269
15270@item l1-cache-line-size
15271The size of cache line in L1 data cache, in bytes.
15272
15273@item l1-cache-size
15274The size of L1 data cache, in kilobytes.
15275
15276@item l2-cache-size
15277The size of L2 data cache, in kilobytes.
15278
15279@item prefetch-dynamic-strides
15280Whether the loop array prefetch pass should issue software prefetch hints
15281for strides that are non-constant. In some cases this may be
15282beneficial, though the fact the stride is non-constant may make it
15283hard to predict when there is clear benefit to issuing these hints.
15284
15285Set to 1 if the prefetch hints should be issued for non-constant
15286strides. Set to 0 if prefetch hints should be issued only for strides that
15287are known to be constant and below @option{prefetch-minimum-stride}.
15288
15289@item prefetch-minimum-stride
15290Minimum constant stride, in bytes, to start using prefetch hints for. If
15291the stride is less than this threshold, prefetch hints will not be issued.
15292
15293This setting is useful for processors that have hardware prefetchers, in
15294which case there may be conflicts between the hardware prefetchers and
15295the software prefetchers. If the hardware prefetchers have a maximum
15296stride they can handle, it should be used here to improve the use of
15297software prefetchers.
15298
15299A value of -1 means we don't have a threshold and therefore
15300prefetch hints can be issued for any constant stride.
15301
15302This setting is only useful for strides that are known and constant.
15303
15304@item destructive-interference-size
15305@item constructive-interference-size
15306The values for the C++17 variables
15307@code{std::hardware_destructive_interference_size} and
15308@code{std::hardware_constructive_interference_size}. The destructive
15309interference size is the minimum recommended offset between two
15310independent concurrently-accessed objects; the constructive
15311interference size is the maximum recommended size of contiguous memory
15312accessed together. Typically both will be the size of an L1 cache
15313line for the target, in bytes. For a generic target covering a range of L1
15314cache line sizes, typically the constructive interference size will be
15315the small end of the range and the destructive size will be the large
15316end.
15317
15318The destructive interference size is intended to be used for layout,
15319and thus has ABI impact. The default value is not expected to be
15320stable, and on some targets varies with @option{-mtune}, so use of
15321this variable in a context where ABI stability is important, such as
15322the public interface of a library, is strongly discouraged; if it is
15323used in that context, users can stabilize the value using this
15324option.
15325
15326The constructive interference size is less sensitive, as it is
15327typically only used in a @samp{static_assert} to make sure that a type
15328fits within a cache line.
15329
15330See also @option{-Winterference-size}.
15331
15332@item loop-interchange-max-num-stmts
15333The maximum number of stmts in a loop to be interchanged.
15334
15335@item loop-interchange-stride-ratio
15336The minimum ratio between stride of two loops for interchange to be profitable.
15337
15338@item min-insn-to-prefetch-ratio
15339The minimum ratio between the number of instructions and the
15340number of prefetches to enable prefetching in a loop.
15341
15342@item prefetch-min-insn-to-mem-ratio
15343The minimum ratio between the number of instructions and the
15344number of memory references to enable prefetching in a loop.
15345
15346@item use-canonical-types
15347Whether the compiler should use the ``canonical'' type system.
15348Should always be 1, which uses a more efficient internal
15349mechanism for comparing types in C++ and Objective-C++. However, if
15350bugs in the canonical type system are causing compilation failures,
15351set this value to 0 to disable canonical types.
15352
15353@item switch-conversion-max-branch-ratio
15354Switch initialization conversion refuses to create arrays that are
15355bigger than @option{switch-conversion-max-branch-ratio} times the number of
15356branches in the switch.
15357
15358@item max-partial-antic-length
15359Maximum length of the partial antic set computed during the tree
15360partial redundancy elimination optimization (@option{-ftree-pre}) when
15361optimizing at @option{-O3} and above. For some sorts of source code
15362the enhanced partial redundancy elimination optimization can run away,
15363consuming all of the memory available on the host machine. This
15364parameter sets a limit on the length of the sets that are computed,
15365which prevents the runaway behavior. Setting a value of 0 for
15366this parameter allows an unlimited set length.
15367
15368@item rpo-vn-max-loop-depth
15369Maximum loop depth that is value-numbered optimistically.
15370When the limit hits the innermost
15371@var{rpo-vn-max-loop-depth} loops and the outermost loop in the
15372loop nest are value-numbered optimistically and the remaining ones not.
15373
15374@item sccvn-max-alias-queries-per-access
15375Maximum number of alias-oracle queries we perform when looking for
15376redundancies for loads and stores. If this limit is hit the search
15377is aborted and the load or store is not considered redundant. The
15378number of queries is algorithmically limited to the number of
15379stores on all paths from the load to the function entry.
15380
15381@item ira-max-loops-num
15382IRA uses regional register allocation by default. If a function
15383contains more loops than the number given by this parameter, only at most
15384the given number of the most frequently-executed loops form regions
15385for regional register allocation.
15386
15387@item ira-max-conflict-table-size
15388Although IRA uses a sophisticated algorithm to compress the conflict
15389table, the table can still require excessive amounts of memory for
15390huge functions. If the conflict table for a function could be more
15391than the size in MB given by this parameter, the register allocator
15392instead uses a faster, simpler, and lower-quality
15393algorithm that does not require building a pseudo-register conflict table.
15394
15395@item ira-loop-reserved-regs
15396IRA can be used to evaluate more accurate register pressure in loops
15397for decisions to move loop invariants (see @option{-O3}). The number
15398of available registers reserved for some other purposes is given
15399by this parameter. Default of the parameter
15400is the best found from numerous experiments.
15401
15402@item ira-consider-dup-in-all-alts
15403Make IRA to consider matching constraint (duplicated operand number)
15404heavily in all available alternatives for preferred register class.
15405If it is set as zero, it means IRA only respects the matching
15406constraint when it's in the only available alternative with an
15407appropriate register class. Otherwise, it means IRA will check all
15408available alternatives for preferred register class even if it has
15409found some choice with an appropriate register class and respect the
15410found qualified matching constraint.
15411
15412@item lra-inheritance-ebb-probability-cutoff
15413LRA tries to reuse values reloaded in registers in subsequent insns.
15414This optimization is called inheritance. EBB is used as a region to
15415do this optimization. The parameter defines a minimal fall-through
15416edge probability in percentage used to add BB to inheritance EBB in
15417LRA. The default value was chosen
15418from numerous runs of SPEC2000 on x86-64.
15419
15420@item loop-invariant-max-bbs-in-loop
15421Loop invariant motion can be very expensive, both in compilation time and
15422in amount of needed compile-time memory, with very large loops. Loops
15423with more basic blocks than this parameter won't have loop invariant
15424motion optimization performed on them.
15425
15426@item loop-max-datarefs-for-datadeps
15427Building data dependencies is expensive for very large loops. This
15428parameter limits the number of data references in loops that are
15429considered for data dependence analysis. These large loops are no
15430handled by the optimizations using loop data dependencies.
15431
15432@item max-vartrack-size
15433Sets a maximum number of hash table slots to use during variable
15434tracking dataflow analysis of any function. If this limit is exceeded
15435with variable tracking at assignments enabled, analysis for that
15436function is retried without it, after removing all debug insns from
15437the function. If the limit is exceeded even without debug insns, var
15438tracking analysis is completely disabled for the function. Setting
15439the parameter to zero makes it unlimited.
15440
15441@item max-vartrack-expr-depth
15442Sets a maximum number of recursion levels when attempting to map
15443variable names or debug temporaries to value expressions. This trades
15444compilation time for more complete debug information. If this is set too
15445low, value expressions that are available and could be represented in
15446debug information may end up not being used; setting this higher may
15447enable the compiler to find more complex debug expressions, but compile
15448time and memory use may grow.
15449
15450@item max-debug-marker-count
15451Sets a threshold on the number of debug markers (e.g.@: begin stmt
15452markers) to avoid complexity explosion at inlining or expanding to RTL.
15453If a function has more such gimple stmts than the set limit, such stmts
15454will be dropped from the inlined copy of a function, and from its RTL
15455expansion.
15456
15457@item min-nondebug-insn-uid
15458Use uids starting at this parameter for nondebug insns. The range below
15459the parameter is reserved exclusively for debug insns created by
15460@option{-fvar-tracking-assignments}, but debug insns may get
15461(non-overlapping) uids above it if the reserved range is exhausted.
15462
15463@item ipa-sra-ptr-growth-factor
15464IPA-SRA replaces a pointer to an aggregate with one or more new
15465parameters only when their cumulative size is less or equal to
15466@option{ipa-sra-ptr-growth-factor} times the size of the original
15467pointer parameter.
15468
15469@item ipa-sra-max-replacements
15470Maximum pieces of an aggregate that IPA-SRA tracks. As a
15471consequence, it is also the maximum number of replacements of a formal
15472parameter.
15473
15474@item sra-max-scalarization-size-Ospeed
15475@itemx sra-max-scalarization-size-Osize
15476The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
15477replace scalar parts of aggregates with uses of independent scalar
15478variables. These parameters control the maximum size, in storage units,
15479of aggregate which is considered for replacement when compiling for
15480speed
15481(@option{sra-max-scalarization-size-Ospeed}) or size
15482(@option{sra-max-scalarization-size-Osize}) respectively.
15483
15484@item sra-max-propagations
15485The maximum number of artificial accesses that Scalar Replacement of
15486Aggregates (SRA) will track, per one local variable, in order to
15487facilitate copy propagation.
15488
15489@item tm-max-aggregate-size
15490When making copies of thread-local variables in a transaction, this
15491parameter specifies the size in bytes after which variables are
15492saved with the logging functions as opposed to save/restore code
15493sequence pairs. This option only applies when using
15494@option{-fgnu-tm}.
15495
15496@item graphite-max-nb-scop-params
15497To avoid exponential effects in the Graphite loop transforms, the
15498number of parameters in a Static Control Part (SCoP) is bounded.
15499A value of zero can be used to lift
15500the bound. A variable whose value is unknown at compilation time and
15501defined outside a SCoP is a parameter of the SCoP.
15502
15503@item loop-block-tile-size
15504Loop blocking or strip mining transforms, enabled with
15505@option{-floop-block} or @option{-floop-strip-mine}, strip mine each
15506loop in the loop nest by a given number of iterations. The strip
15507length can be changed using the @option{loop-block-tile-size}
15508parameter.
15509
15510@item ipa-jump-function-lookups
15511Specifies number of statements visited during jump function offset discovery.
15512
15513@item ipa-cp-value-list-size
15514IPA-CP attempts to track all possible values and types passed to a function's
15515parameter in order to propagate them and perform devirtualization.
15516@option{ipa-cp-value-list-size} is the maximum number of values and types it
15517stores per one formal parameter of a function.
15518
15519@item ipa-cp-eval-threshold
15520IPA-CP calculates its own score of cloning profitability heuristics
15521and performs those cloning opportunities with scores that exceed
15522@option{ipa-cp-eval-threshold}.
15523
15524@item ipa-cp-max-recursive-depth
15525Maximum depth of recursive cloning for self-recursive function.
15526
15527@item ipa-cp-min-recursive-probability
15528Recursive cloning only when the probability of call being executed exceeds
15529the parameter.
15530
15531@item ipa-cp-profile-count-base
15532When using @option{-fprofile-use} option, IPA-CP will consider the measured
15533execution count of a call graph edge at this percentage position in their
15534histogram as the basis for its heuristics calculation.
15535
15536@item ipa-cp-recursive-freq-factor
15537The number of times interprocedural copy propagation expects recursive
15538functions to call themselves.
15539
15540@item ipa-cp-recursion-penalty
15541Percentage penalty the recursive functions will receive when they
15542are evaluated for cloning.
15543
15544@item ipa-cp-single-call-penalty
15545Percentage penalty functions containing a single call to another
15546function will receive when they are evaluated for cloning.
15547
15548@item ipa-max-agg-items
15549IPA-CP is also capable to propagate a number of scalar values passed
15550in an aggregate. @option{ipa-max-agg-items} controls the maximum
15551number of such values per one parameter.
15552
15553@item ipa-cp-loop-hint-bonus
15554When IPA-CP determines that a cloning candidate would make the number
15555of iterations of a loop known, it adds a bonus of
15556@option{ipa-cp-loop-hint-bonus} to the profitability score of
15557the candidate.
15558
15559@item ipa-max-loop-predicates
15560The maximum number of different predicates IPA will use to describe when
15561loops in a function have known properties.
15562
15563@item ipa-max-aa-steps
15564During its analysis of function bodies, IPA-CP employs alias analysis
15565in order to track values pointed to by function parameters. In order
15566not spend too much time analyzing huge functions, it gives up and
15567consider all memory clobbered after examining
15568@option{ipa-max-aa-steps} statements modifying memory.
15569
15570@item ipa-max-switch-predicate-bounds
15571Maximal number of boundary endpoints of case ranges of switch statement.
15572For switch exceeding this limit, IPA-CP will not construct cloning cost
15573predicate, which is used to estimate cloning benefit, for default case
15574of the switch statement.
15575
15576@item ipa-max-param-expr-ops
15577IPA-CP will analyze conditional statement that references some function
15578parameter to estimate benefit for cloning upon certain constant value.
15579But if number of operations in a parameter expression exceeds
15580@option{ipa-max-param-expr-ops}, the expression is treated as complicated
15581one, and is not handled by IPA analysis.
15582
15583@item lto-partitions
15584Specify desired number of partitions produced during WHOPR compilation.
15585The number of partitions should exceed the number of CPUs used for compilation.
15586
15587@item lto-min-partition
15588Size of minimal partition for WHOPR (in estimated instructions).
15589This prevents expenses of splitting very small programs into too many
15590partitions.
15591
15592@item lto-max-partition
15593Size of max partition for WHOPR (in estimated instructions).
15594to provide an upper bound for individual size of partition.
15595Meant to be used only with balanced partitioning.
15596
15597@item lto-max-streaming-parallelism
15598Maximal number of parallel processes used for LTO streaming.
15599
15600@item cxx-max-namespaces-for-diagnostic-help
15601The maximum number of namespaces to consult for suggestions when C++
15602name lookup fails for an identifier.
15603
15604@item sink-frequency-threshold
15605The maximum relative execution frequency (in percents) of the target block
15606relative to a statement's original block to allow statement sinking of a
15607statement. Larger numbers result in more aggressive statement sinking.
15608A small positive adjustment is applied for
15609statements with memory operands as those are even more profitable so sink.
15610
15611@item max-stores-to-sink
15612The maximum number of conditional store pairs that can be sunk. Set to 0
15613if either vectorization (@option{-ftree-vectorize}) or if-conversion
15614(@option{-ftree-loop-if-convert}) is disabled.
15615
15616@item case-values-threshold
15617The smallest number of different values for which it is best to use a
15618jump-table instead of a tree of conditional branches. If the value is
156190, use the default for the machine.
15620
15621@item jump-table-max-growth-ratio-for-size
15622The maximum code size growth ratio when expanding
15623into a jump table (in percent). The parameter is used when
15624optimizing for size.
15625
15626@item jump-table-max-growth-ratio-for-speed
15627The maximum code size growth ratio when expanding
15628into a jump table (in percent). The parameter is used when
15629optimizing for speed.
15630
15631@item tree-reassoc-width
15632Set the maximum number of instructions executed in parallel in
15633reassociated tree. This parameter overrides target dependent
15634heuristics used by default if has non zero value.
15635
15636@item sched-pressure-algorithm
15637Choose between the two available implementations of
15638@option{-fsched-pressure}. Algorithm 1 is the original implementation
15639and is the more likely to prevent instructions from being reordered.
15640Algorithm 2 was designed to be a compromise between the relatively
15641conservative approach taken by algorithm 1 and the rather aggressive
15642approach taken by the default scheduler. It relies more heavily on
15643having a regular register file and accurate register pressure classes.
15644See @file{haifa-sched.cc} in the GCC sources for more details.
15645
15646The default choice depends on the target.
15647
15648@item max-slsr-cand-scan
15649Set the maximum number of existing candidates that are considered when
15650seeking a basis for a new straight-line strength reduction candidate.
15651
15652@item asan-globals
15653Enable buffer overflow detection for global objects. This kind
15654of protection is enabled by default if you are using
15655@option{-fsanitize=address} option.
15656To disable global objects protection use @option{--param asan-globals=0}.
15657
15658@item asan-stack
15659Enable buffer overflow detection for stack objects. This kind of
15660protection is enabled by default when using @option{-fsanitize=address}.
15661To disable stack protection use @option{--param asan-stack=0} option.
15662
15663@item asan-instrument-reads
15664Enable buffer overflow detection for memory reads. This kind of
15665protection is enabled by default when using @option{-fsanitize=address}.
15666To disable memory reads protection use
15667@option{--param asan-instrument-reads=0}.
15668
15669@item asan-instrument-writes
15670Enable buffer overflow detection for memory writes. This kind of
15671protection is enabled by default when using @option{-fsanitize=address}.
15672To disable memory writes protection use
15673@option{--param asan-instrument-writes=0} option.
15674
15675@item asan-memintrin
15676Enable detection for built-in functions. This kind of protection
15677is enabled by default when using @option{-fsanitize=address}.
15678To disable built-in functions protection use
15679@option{--param asan-memintrin=0}.
15680
15681@item asan-use-after-return
15682Enable detection of use-after-return. This kind of protection
15683is enabled by default when using the @option{-fsanitize=address} option.
15684To disable it use @option{--param asan-use-after-return=0}.
15685
15686Note: By default the check is disabled at run time. To enable it,
15687add @code{detect_stack_use_after_return=1} to the environment variable
15688@env{ASAN_OPTIONS}.
15689
15690@item asan-instrumentation-with-call-threshold
15691If number of memory accesses in function being instrumented
15692is greater or equal to this number, use callbacks instead of inline checks.
15693E.g. to disable inline code use
15694@option{--param asan-instrumentation-with-call-threshold=0}.
15695
15696@item hwasan-instrument-stack
15697Enable hwasan instrumentation of statically sized stack-allocated variables.
15698This kind of instrumentation is enabled by default when using
15699@option{-fsanitize=hwaddress} and disabled by default when using
15700@option{-fsanitize=kernel-hwaddress}.
15701To disable stack instrumentation use
15702@option{--param hwasan-instrument-stack=0}, and to enable it use
15703@option{--param hwasan-instrument-stack=1}.
15704
15705@item hwasan-random-frame-tag
15706When using stack instrumentation, decide tags for stack variables using a
15707deterministic sequence beginning at a random tag for each frame. With this
15708parameter unset tags are chosen using the same sequence but beginning from 1.
15709This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
15710for @option{-fsanitize=kernel-hwaddress}.
15711To disable it use @option{--param hwasan-random-frame-tag=0}.
15712
15713@item hwasan-instrument-allocas
15714Enable hwasan instrumentation of dynamically sized stack-allocated variables.
15715This kind of instrumentation is enabled by default when using
15716@option{-fsanitize=hwaddress} and disabled by default when using
15717@option{-fsanitize=kernel-hwaddress}.
15718To disable instrumentation of such variables use
15719@option{--param hwasan-instrument-allocas=0}, and to enable it use
15720@option{--param hwasan-instrument-allocas=1}.
15721
15722@item hwasan-instrument-reads
15723Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
15724default for both @option{-fsanitize=hwaddress} and
15725@option{-fsanitize=kernel-hwaddress}.
15726To disable checking memory reads use
15727@option{--param hwasan-instrument-reads=0}.
15728
15729@item hwasan-instrument-writes
15730Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
15731default for both @option{-fsanitize=hwaddress} and
15732@option{-fsanitize=kernel-hwaddress}.
15733To disable checking memory writes use
15734@option{--param hwasan-instrument-writes=0}.
15735
15736@item hwasan-instrument-mem-intrinsics
15737Enable hwasan instrumentation of builtin functions. Instrumentation of these
15738builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
15739and @option{-fsanitize=kernel-hwaddress}.
15740To disable instrumentation of builtin functions use
15741@option{--param hwasan-instrument-mem-intrinsics=0}.
15742
15743@item use-after-scope-direct-emission-threshold
15744If the size of a local variable in bytes is smaller or equal to this
15745number, directly poison (or unpoison) shadow memory instead of using
15746run-time callbacks.
15747
15748@item tsan-distinguish-volatile
15749Emit special instrumentation for accesses to volatiles.
15750
15751@item tsan-instrument-func-entry-exit
15752Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
15753
15754@item max-fsm-thread-path-insns
15755Maximum number of instructions to copy when duplicating blocks on a
15756finite state automaton jump thread path.
15757
15758@item threader-debug
15759threader-debug=[none|all] Enables verbose dumping of the threader solver.
15760
15761@item parloops-chunk-size
15762Chunk size of omp schedule for loops parallelized by parloops.
15763
15764@item parloops-schedule
15765Schedule type of omp schedule for loops parallelized by parloops (static,
15766dynamic, guided, auto, runtime).
15767
15768@item parloops-min-per-thread
15769The minimum number of iterations per thread of an innermost parallelized
15770loop for which the parallelized variant is preferred over the single threaded
15771one. Note that for a parallelized loop nest the
15772minimum number of iterations of the outermost loop per thread is two.
15773
15774@item max-ssa-name-query-depth
15775Maximum depth of recursion when querying properties of SSA names in things
15776like fold routines. One level of recursion corresponds to following a
15777use-def chain.
15778
15779@item max-speculative-devirt-maydefs
15780The maximum number of may-defs we analyze when looking for a must-def
15781specifying the dynamic type of an object that invokes a virtual call
15782we may be able to devirtualize speculatively.
15783
15784@item max-vrp-switch-assertions
15785The maximum number of assertions to add along the default edge of a switch
15786statement during VRP.
15787
15788@item evrp-sparse-threshold
15789Maximum number of basic blocks before EVRP uses a sparse cache.
15790
15791@item vrp1-mode
15792Specifies the mode VRP pass 1 should operate in.
15793
15794@item vrp2-mode
15795Specifies the mode VRP pass 2 should operate in.
15796
15797@item ranger-debug
15798Specifies the type of debug output to be issued for ranges.
15799
15800@item evrp-switch-limit
15801Specifies the maximum number of switch cases before EVRP ignores a switch.
15802
15803@item unroll-jam-min-percent
15804The minimum percentage of memory references that must be optimized
15805away for the unroll-and-jam transformation to be considered profitable.
15806
15807@item unroll-jam-max-unroll
15808The maximum number of times the outer loop should be unrolled by
15809the unroll-and-jam transformation.
15810
15811@item max-rtl-if-conversion-unpredictable-cost
15812Maximum permissible cost for the sequence that would be generated
15813by the RTL if-conversion pass for a branch that is considered unpredictable.
15814
15815@item max-variable-expansions-in-unroller
15816If @option{-fvariable-expansion-in-unroller} is used, the maximum number
15817of times that an individual variable will be expanded during loop unrolling.
15818
15819@item partial-inlining-entry-probability
15820Maximum probability of the entry BB of split region
15821(in percent relative to entry BB of the function)
15822to make partial inlining happen.
15823
15824@item max-tracked-strlens
15825Maximum number of strings for which strlen optimization pass will
15826track string lengths.
15827
15828@item gcse-after-reload-partial-fraction
15829The threshold ratio for performing partial redundancy
15830elimination after reload.
15831
15832@item gcse-after-reload-critical-fraction
15833The threshold ratio of critical edges execution count that
15834permit performing redundancy elimination after reload.
15835
15836@item max-loop-header-insns
15837The maximum number of insns in loop header duplicated
15838by the copy loop headers pass.
15839
15840@item vect-epilogues-nomask
15841Enable loop epilogue vectorization using smaller vector size.
15842
15843@item vect-partial-vector-usage
15844Controls when the loop vectorizer considers using partial vector loads
15845and stores as an alternative to falling back to scalar code. 0 stops
15846the vectorizer from ever using partial vector loads and stores. 1 allows
15847partial vector loads and stores if vectorization removes the need for the
15848code to iterate. 2 allows partial vector loads and stores in all loops.
15849The parameter only has an effect on targets that support partial
15850vector loads and stores.
15851
15852@item vect-inner-loop-cost-factor
15853The maximum factor which the loop vectorizer applies to the cost of statements
15854in an inner loop relative to the loop being vectorized. The factor applied
15855is the maximum of the estimated number of iterations of the inner loop and
15856this parameter. The default value of this parameter is 50.
15857
15858@item vect-induction-float
15859Enable loop vectorization of floating point inductions.
15860
15861@item avoid-fma-max-bits
15862Maximum number of bits for which we avoid creating FMAs.
15863
15864@item sms-loop-average-count-threshold
15865A threshold on the average loop count considered by the swing modulo scheduler.
15866
15867@item sms-dfa-history
15868The number of cycles the swing modulo scheduler considers when checking
15869conflicts using DFA.
15870
15871@item graphite-allow-codegen-errors
15872Whether codegen errors should be ICEs when @option{-fchecking}.
15873
15874@item sms-max-ii-factor
15875A factor for tuning the upper bound that swing modulo scheduler
15876uses for scheduling a loop.
15877
15878@item lra-max-considered-reload-pseudos
15879The max number of reload pseudos which are considered during
15880spilling a non-reload pseudo.
15881
15882@item max-pow-sqrt-depth
15883Maximum depth of sqrt chains to use when synthesizing exponentiation
15884by a real constant.
15885
15886@item max-dse-active-local-stores
15887Maximum number of active local stores in RTL dead store elimination.
15888
15889@item asan-instrument-allocas
15890Enable asan allocas/VLAs protection.
15891
15892@item max-iterations-computation-cost
15893Bound on the cost of an expression to compute the number of iterations.
15894
15895@item max-isl-operations
15896Maximum number of isl operations, 0 means unlimited.
15897
15898@item graphite-max-arrays-per-scop
15899Maximum number of arrays per scop.
15900
15901@item max-vartrack-reverse-op-size
15902Max. size of loc list for which reverse ops should be added.
15903
15904@item fsm-scale-path-stmts
15905Scale factor to apply to the number of statements in a threading path
15906when comparing to the number of (scaled) blocks.
15907
15908@item uninit-control-dep-attempts
15909Maximum number of nested calls to search for control dependencies
15910during uninitialized variable analysis.
15911
15912@item fsm-scale-path-blocks
15913Scale factor to apply to the number of blocks in a threading path
15914when comparing to the number of (scaled) statements.
15915
15916@item sched-autopref-queue-depth
15917Hardware autoprefetcher scheduler model control flag.
15918Number of lookahead cycles the model looks into; at '
15919' only enable instruction sorting heuristic.
15920
15921@item loop-versioning-max-inner-insns
15922The maximum number of instructions that an inner loop can have
15923before the loop versioning pass considers it too big to copy.
15924
15925@item loop-versioning-max-outer-insns
15926The maximum number of instructions that an outer loop can have
15927before the loop versioning pass considers it too big to copy,
15928discounting any instructions in inner loops that directly benefit
15929from versioning.
15930
15931@item ssa-name-def-chain-limit
15932The maximum number of SSA_NAME assignments to follow in determining
15933a property of a variable such as its value. This limits the number
15934of iterations or recursive calls GCC performs when optimizing certain
15935statements or when determining their validity prior to issuing
15936diagnostics.
15937
15938@item store-merging-max-size
15939Maximum size of a single store merging region in bytes.
15940
15941@item hash-table-verification-limit
15942The number of elements for which hash table verification is done
15943for each searched element.
15944
15945@item max-find-base-term-values
15946Maximum number of VALUEs handled during a single find_base_term call.
15947
15948@item analyzer-max-enodes-per-program-point
15949The maximum number of exploded nodes per program point within
15950the analyzer, before terminating analysis of that point.
15951
15952@item analyzer-max-constraints
15953The maximum number of constraints per state.
15954
15955@item analyzer-min-snodes-for-call-summary
15956The minimum number of supernodes within a function for the
15957analyzer to consider summarizing its effects at call sites.
15958
15959@item analyzer-max-enodes-for-full-dump
15960The maximum depth of exploded nodes that should appear in a dot dump
15961before switching to a less verbose format.
15962
15963@item analyzer-max-recursion-depth
15964The maximum number of times a callsite can appear in a call stack
15965within the analyzer, before terminating analysis of a call that would
15966recurse deeper.
15967
15968@item analyzer-max-svalue-depth
15969The maximum depth of a symbolic value, before approximating
15970the value as unknown.
15971
15972@item analyzer-max-infeasible-edges
15973The maximum number of infeasible edges to reject before declaring
15974a diagnostic as infeasible.
15975
15976@item gimple-fe-computed-hot-bb-threshold
15977The number of executions of a basic block which is considered hot.
15978The parameter is used only in GIMPLE FE.
15979
15980@item analyzer-bb-explosion-factor
15981The maximum number of 'after supernode' exploded nodes within the analyzer
15982per supernode, before terminating analysis.
15983
15984@item ranger-logical-depth
15985Maximum depth of logical expression evaluation ranger will look through
15986when evaluating outgoing edge ranges.
15987
15988@item relation-block-limit
15989Maximum number of relations the oracle will register in a basic block.
15990
15991@item min-pagesize
15992Minimum page size for warning purposes.
15993
15994@item openacc-kernels
15995Specify mode of OpenACC `kernels' constructs handling.
15996With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
15997constructs are decomposed into parts, a sequence of compute
15998constructs, each then handled individually.
15999This is work in progress.
16000With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
16001constructs are handled by the @samp{parloops} pass, en bloc.
16002This is the current default.
16003
16004@item openacc-privatization
16005Specify mode of OpenACC privatization diagnostics for
16006@option{-fopt-info-omp-note} and applicable
16007@option{-fdump-tree-*-details}.
16008With @option{--param=openacc-privatization=quiet}, don't diagnose.
16009This is the current default.
16010With @option{--param=openacc-privatization=noisy}, do diagnose.
16011
16012@end table
16013
16014The following choices of @var{name} are available on AArch64 targets:
16015
16016@table @gcctabopt
16017@item aarch64-sve-compare-costs
16018When vectorizing for SVE, consider using ``unpacked'' vectors for
16019smaller elements and use the cost model to pick the cheapest approach.
16020Also use the cost model to choose between SVE and Advanced SIMD vectorization.
16021
16022Using unpacked vectors includes storing smaller elements in larger
16023containers and accessing elements with extending loads and truncating
16024stores.
16025
16026@item aarch64-float-recp-precision
16027The number of Newton iterations for calculating the reciprocal for float type.
16028The precision of division is proportional to this param when division
16029approximation is enabled. The default value is 1.
16030
16031@item aarch64-double-recp-precision
16032The number of Newton iterations for calculating the reciprocal for double type.
16033The precision of division is propotional to this param when division
16034approximation is enabled. The default value is 2.
16035
16036@item aarch64-autovec-preference
16037Force an ISA selection strategy for auto-vectorization. Accepts values from
160380 to 4, inclusive.
16039@table @samp
16040@item 0
16041Use the default heuristics.
16042@item 1
16043Use only Advanced SIMD for auto-vectorization.
16044@item 2
16045Use only SVE for auto-vectorization.
16046@item 3
16047Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
16048deemed equal.
16049@item 4
16050Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
16051@end table
16052The default value is 0.
16053
16054@item aarch64-loop-vect-issue-rate-niters
16055The tuning for some AArch64 CPUs tries to take both latencies and issue
16056rates into account when deciding whether a loop should be vectorized
16057using SVE, vectorized using Advanced SIMD, or not vectorized at all.
16058If this parameter is set to @var{n}, GCC will not use this heuristic
16059for loops that are known to execute in fewer than @var{n} Advanced
16060SIMD iterations.
16061
16062@item aarch64-vect-unroll-limit
16063The vectorizer will use available tuning information to determine whether it
16064would be beneficial to unroll the main vectorized loop and by how much. This
16065parameter set's the upper bound of how much the vectorizer will unroll the main
16066loop. The default value is four.
16067
16068@end table
16069
16070The following choices of @var{name} are available on i386 and x86_64 targets:
16071
16072@table @gcctabopt
16073@item x86-stlf-window-ninsns
16074Instructions number above which STFL stall penalty can be compensated.
16075
16076@end table
16077
16078@end table
16079
16080@node Instrumentation Options
16081@section Program Instrumentation Options
16082@cindex instrumentation options
16083@cindex program instrumentation options
16084@cindex run-time error checking options
16085@cindex profiling options
16086@cindex options, program instrumentation
16087@cindex options, run-time error checking
16088@cindex options, profiling
16089
16090GCC supports a number of command-line options that control adding
16091run-time instrumentation to the code it normally generates.
16092For example, one purpose of instrumentation is collect profiling
16093statistics for use in finding program hot spots, code coverage
16094analysis, or profile-guided optimizations.
16095Another class of program instrumentation is adding run-time checking
16096to detect programming errors like invalid pointer
16097dereferences or out-of-bounds array accesses, as well as deliberately
16098hostile attacks such as stack smashing or C++ vtable hijacking.
16099There is also a general hook which can be used to implement other
16100forms of tracing or function-level instrumentation for debug or
16101program analysis purposes.
16102
16103@table @gcctabopt
16104@cindex @command{prof}
16105@cindex @command{gprof}
16106@item -p
16107@itemx -pg
16108@opindex p
16109@opindex pg
16110Generate extra code to write profile information suitable for the
16111analysis program @command{prof} (for @option{-p}) or @command{gprof}
16112(for @option{-pg}). You must use this option when compiling
16113the source files you want data about, and you must also use it when
16114linking.
16115
16116You can use the function attribute @code{no_instrument_function} to
16117suppress profiling of individual functions when compiling with these options.
16118@xref{Common Function Attributes}.
16119
16120@item -fprofile-arcs
16121@opindex fprofile-arcs
16122Add code so that program flow @dfn{arcs} are instrumented. During
16123execution the program records how many times each branch and call is
16124executed and how many times it is taken or returns. On targets that support
16125constructors with priority support, profiling properly handles constructors,
16126destructors and C++ constructors (and destructors) of classes which are used
16127as a type of a global variable.
16128
16129When the compiled
16130program exits it saves this data to a file called
16131@file{@var{auxname}.gcda} for each source file. The data may be used for
16132profile-directed optimizations (@option{-fbranch-probabilities}), or for
16133test coverage analysis (@option{-ftest-coverage}). Each object file's
16134@var{auxname} is generated from the name of the output file, if
16135explicitly specified and it is not the final executable, otherwise it is
16136the basename of the source file. In both cases any suffix is removed
16137(e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
16138@file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
16139
16140Note that if a command line directly links source files, the corresponding
16141@var{.gcda} files will be prefixed with the unsuffixed name of the output file.
16142E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and
16143@file{binary-b.gcda} files.
16144
16145@xref{Cross-profiling}.
16146
16147@cindex @command{gcov}
16148@item --coverage
16149@opindex coverage
16150
16151This option is used to compile and link code instrumented for coverage
16152analysis. The option is a synonym for @option{-fprofile-arcs}
16153@option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
16154linking). See the documentation for those options for more details.
16155
16156@itemize
16157
16158@item
16159Compile the source files with @option{-fprofile-arcs} plus optimization
16160and code generation options. For test coverage analysis, use the
16161additional @option{-ftest-coverage} option. You do not need to profile
16162every source file in a program.
16163
16164@item
16165Compile the source files additionally with @option{-fprofile-abs-path}
16166to create absolute path names in the @file{.gcno} files. This allows
16167@command{gcov} to find the correct sources in projects where compilations
16168occur with different working directories.
16169
16170@item
16171Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
16172(the latter implies the former).
16173
16174@item
16175Run the program on a representative workload to generate the arc profile
16176information. This may be repeated any number of times. You can run
16177concurrent instances of your program, and provided that the file system
16178supports locking, the data files will be correctly updated. Unless
16179a strict ISO C dialect option is in effect, @code{fork} calls are
16180detected and correctly handled without double counting.
16181
16182Moreover, an object file can be recompiled multiple times
16183and the corresponding @file{.gcda} file merges as long as
16184the source file and the compiler options are unchanged.
16185
16186@item
16187For profile-directed optimizations, compile the source files again with
16188the same optimization and code generation options plus
16189@option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
16190Control Optimization}).
16191
16192@item
16193For test coverage analysis, use @command{gcov} to produce human readable
16194information from the @file{.gcno} and @file{.gcda} files. Refer to the
16195@command{gcov} documentation for further information.
16196
16197@end itemize
16198
16199With @option{-fprofile-arcs}, for each function of your program GCC
16200creates a program flow graph, then finds a spanning tree for the graph.
16201Only arcs that are not on the spanning tree have to be instrumented: the
16202compiler adds code to count the number of times that these arcs are
16203executed. When an arc is the only exit or only entrance to a block, the
16204instrumentation code can be added to the block; otherwise, a new basic
16205block must be created to hold the instrumentation code.
16206
16207@need 2000
16208@item -ftest-coverage
16209@opindex ftest-coverage
16210Produce a notes file that the @command{gcov} code-coverage utility
16211(@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
16212show program coverage. Each source file's note file is called
16213@file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
16214above for a description of @var{auxname} and instructions on how to
16215generate test coverage data. Coverage data matches the source files
16216more closely if you do not optimize.
16217
16218@item -fprofile-abs-path
16219@opindex fprofile-abs-path
16220Automatically convert relative source file names to absolute path names
16221in the @file{.gcno} files. This allows @command{gcov} to find the correct
16222sources in projects where compilations occur with different working
16223directories.
16224
16225@item -fprofile-dir=@var{path}
16226@opindex fprofile-dir
16227
16228Set the directory to search for the profile data files in to @var{path}.
16229This option affects only the profile data generated by
16230@option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
16231and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
16232and its related options. Both absolute and relative paths can be used.
16233By default, GCC uses the current directory as @var{path}, thus the
16234profile data file appears in the same directory as the object file.
16235In order to prevent the file name clashing, if the object file name is
16236not an absolute path, we mangle the absolute path of the
16237@file{@var{sourcename}.gcda} file and use it as the file name of a
16238@file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}.
16239See similar option @option{-fprofile-note}.
16240
16241When an executable is run in a massive parallel environment, it is recommended
16242to save profile to different folders. That can be done with variables
16243in @var{path} that are exported during run-time:
16244
16245@table @gcctabopt
16246
16247@item %p
16248process ID.
16249
16250@item %q@{VAR@}
16251value of environment variable @var{VAR}
16252
16253@end table
16254
16255@item -fprofile-generate
16256@itemx -fprofile-generate=@var{path}
16257@opindex fprofile-generate
16258
16259Enable options usually used for instrumenting application to produce
16260profile useful for later recompilation with profile feedback based
16261optimization. You must use @option{-fprofile-generate} both when
16262compiling and when linking your program.
16263
16264The following options are enabled:
16265@option{-fprofile-arcs}, @option{-fprofile-values},
16266@option{-finline-functions}, and @option{-fipa-bit-cp}.
16267
16268If @var{path} is specified, GCC looks at the @var{path} to find
16269the profile feedback data files. See @option{-fprofile-dir}.
16270
16271To optimize the program based on the collected profile information, use
16272@option{-fprofile-use}. @xref{Optimize Options}, for more information.
16273
16274@item -fprofile-info-section
16275@itemx -fprofile-info-section=@var{name}
16276@opindex fprofile-info-section
16277
16278Register the profile information in the specified section instead of using a
16279constructor/destructor. The section name is @var{name} if it is specified,
16280otherwise the section name defaults to @code{.gcov_info}. A pointer to the
16281profile information generated by @option{-fprofile-arcs} is placed in the
16282specified section for each translation unit. This option disables the profile
16283information registration through a constructor and it disables the profile
16284information processing through a destructor. This option is not intended to be
16285used in hosted environments such as GNU/Linux. It targets freestanding
16286environments (for example embedded systems) with limited resources which do not
16287support constructors/destructors or the C library file I/O.
16288
16289The linker could collect the input sections in a continuous memory block and
16290define start and end symbols. A GNU linker script example which defines a
16291linker output section follows:
16292
16293@smallexample
16294 .gcov_info :
16295 @{
16296 PROVIDE (__gcov_info_start = .);
16297 KEEP (*(.gcov_info))
16298 PROVIDE (__gcov_info_end = .);
16299 @}
16300@end smallexample
16301
16302The program could dump the profiling information registered in this linker set
16303for example like this:
16304
16305@smallexample
16306#include <gcov.h>
16307#include <stdio.h>
16308#include <stdlib.h>
16309
16310extern const struct gcov_info *const __gcov_info_start[];
16311extern const struct gcov_info *const __gcov_info_end[];
16312
16313static void
16314dump (const void *d, unsigned n, void *arg)
16315@{
16316 const unsigned char *c = d;
16317
16318 for (unsigned i = 0; i < n; ++i)
16319 printf ("%02x", c[i]);
16320@}
16321
16322static void
16323filename (const char *f, void *arg)
16324@{
16325 __gcov_filename_to_gcfn (f, dump, arg );
16326@}
16327
16328static void *
16329allocate (unsigned length, void *arg)
16330@{
16331 return malloc (length);
16332@}
16333
16334static void
16335dump_gcov_info (void)
16336@{
16337 const struct gcov_info *const *info = __gcov_info_start;
16338 const struct gcov_info *const *end = __gcov_info_end;
16339
16340 /* Obfuscate variable to prevent compiler optimizations. */
16341 __asm__ ("" : "+r" (info));
16342
16343 while (info != end)
16344 @{
16345 void *arg = NULL;
16346 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
16347 putchar ('\n');
16348 ++info;
16349 @}
16350@}
16351
16352int
16353main (void)
16354@{
16355 dump_gcov_info ();
16356 return 0;
16357@}
16358@end smallexample
16359
16360The @command{merge-stream} subcommand of @command{gcov-tool} may be used to
16361deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and
16362@code{__gcov_info_to_gcda} functions and merge the profile information into
16363@file{.gcda} files on the host filesystem.
16364
16365@item -fprofile-note=@var{path}
16366@opindex fprofile-note
16367
16368If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
16369location. If you combine the option with multiple source files,
16370the @file{.gcno} file will be overwritten.
16371
16372@item -fprofile-prefix-path=@var{path}
16373@opindex fprofile-prefix-path
16374
16375This option can be used in combination with
16376@option{profile-generate=}@var{profile_dir} and
16377@option{profile-use=}@var{profile_dir} to inform GCC where is the base
16378directory of built source tree. By default @var{profile_dir} will contain
16379files with mangled absolute paths of all object files in the built project.
16380This is not desirable when directory used to build the instrumented binary
16381differs from the directory used to build the binary optimized with profile
16382feedback because the profile data will not be found during the optimized build.
16383In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
16384pointing to the base directory of the build can be used to strip the irrelevant
16385part of the path and keep all file names relative to the main build directory.
16386
16387@item -fprofile-prefix-map=@var{old}=@var{new}
16388@opindex fprofile-prefix-map
16389When compiling files residing in directory @file{@var{old}}, record
16390profiling information (with @option{--coverage})
16391describing them as if the files resided in
16392directory @file{@var{new}} instead.
16393See also @option{-ffile-prefix-map}.
16394
16395@item -fprofile-update=@var{method}
16396@opindex fprofile-update
16397
16398Alter the update method for an application instrumented for profile
16399feedback based optimization. The @var{method} argument should be one of
16400@samp{single}, @samp{atomic} or @samp{prefer-atomic}.
16401The first one is useful for single-threaded applications,
16402while the second one prevents profile corruption by emitting thread-safe code.
16403
16404@strong{Warning:} When an application does not properly join all threads
16405(or creates an detached thread), a profile file can be still corrupted.
16406
16407Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
16408when supported by a target, or to @samp{single} otherwise. The GCC driver
16409automatically selects @samp{prefer-atomic} when @option{-pthread}
16410is present in the command line.
16411
16412@item -fprofile-filter-files=@var{regex}
16413@opindex fprofile-filter-files
16414
16415Instrument only functions from files whose name matches
16416any of the regular expressions (separated by semi-colons).
16417
16418For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
16419only @file{main.c} and all C files starting with 'module'.
16420
16421@item -fprofile-exclude-files=@var{regex}
16422@opindex fprofile-exclude-files
16423
16424Instrument only functions from files whose name does not match
16425any of the regular expressions (separated by semi-colons).
16426
16427For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
16428of all files that are located in the @file{/usr/} folder.
16429
16430@item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
16431@opindex fprofile-reproducible
16432Control level of reproducibility of profile gathered by
16433@code{-fprofile-generate}. This makes it possible to rebuild program
16434with same outcome which is useful, for example, for distribution
16435packages.
16436
16437With @option{-fprofile-reproducible=serial} the profile gathered by
16438@option{-fprofile-generate} is reproducible provided the trained program
16439behaves the same at each invocation of the train run, it is not
16440multi-threaded and profile data streaming is always done in the same
16441order. Note that profile streaming happens at the end of program run but
16442also before @code{fork} function is invoked.
16443
16444Note that it is quite common that execution counts of some part of
16445programs depends, for example, on length of temporary file names or
16446memory space randomization (that may affect hash-table collision rate).
16447Such non-reproducible part of programs may be annotated by
16448@code{no_instrument_function} function attribute. @command{gcov-dump} with
16449@option{-l} can be used to dump gathered data and verify that they are
16450indeed reproducible.
16451
16452With @option{-fprofile-reproducible=parallel-runs} collected profile
16453stays reproducible regardless the order of streaming of the data into
16454gcda files. This setting makes it possible to run multiple instances of
16455instrumented program in parallel (such as with @code{make -j}). This
16456reduces quality of gathered data, in particular of indirect call
16457profiling.
16458
16459@item -fsanitize=address
16460@opindex fsanitize=address
16461Enable AddressSanitizer, a fast memory error detector.
16462Memory access instructions are instrumented to detect
16463out-of-bounds and use-after-free bugs.
16464The option enables @option{-fsanitize-address-use-after-scope}.
16465See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
16466more details. The run-time behavior can be influenced using the
16467@env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
16468the available options are shown at startup of the instrumented program. See
16469@url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
16470for a list of supported options.
16471The option cannot be combined with @option{-fsanitize=thread} or
16472@option{-fsanitize=hwaddress}. Note that the only target
16473@option{-fsanitize=hwaddress} is currently supported on is AArch64.
16474
16475@item -fsanitize=kernel-address
16476@opindex fsanitize=kernel-address
16477Enable AddressSanitizer for Linux kernel.
16478See @uref{https://github.com/google/kasan} for more details.
16479
16480@item -fsanitize=hwaddress
16481@opindex fsanitize=hwaddress
16482Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
16483ignore the top byte of a pointer to allow the detection of memory errors with
16484a low memory overhead.
16485Memory access instructions are instrumented to detect out-of-bounds and
16486use-after-free bugs.
16487The option enables @option{-fsanitize-address-use-after-scope}.
16488See
16489@uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
16490for more details. The run-time behavior can be influenced using the
16491@env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
16492the available options are shown at startup of the instrumented program.
16493The option cannot be combined with @option{-fsanitize=thread} or
16494@option{-fsanitize=address}, and is currently only available on AArch64.
16495
16496@item -fsanitize=kernel-hwaddress
16497@opindex fsanitize=kernel-hwaddress
16498Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
16499Similar to @option{-fsanitize=kernel-address} but using an alternate
16500instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
16501instrumentation differences necessary for compiling the Linux kernel.
16502These differences are to avoid hwasan library initialization calls and to
16503account for the stack pointer having a different value in its top byte.
16504
16505@emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
16506Instrumenting the stack and alloca calls are not on by default but are still
16507possible by specifying the command-line options
16508@option{--param hwasan-instrument-stack=1} and
16509@option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
16510tag is not implemented for kernel instrumentation.
16511
16512@item -fsanitize=pointer-compare
16513@opindex fsanitize=pointer-compare
16514Instrument comparison operation (<, <=, >, >=) with pointer operands.
16515The option must be combined with either @option{-fsanitize=kernel-address} or
16516@option{-fsanitize=address}
16517The option cannot be combined with @option{-fsanitize=thread}.
16518Note: By default the check is disabled at run time. To enable it,
16519add @code{detect_invalid_pointer_pairs=2} to the environment variable
16520@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16521invalid operation only when both pointers are non-null.
16522
16523@item -fsanitize=pointer-subtract
16524@opindex fsanitize=pointer-subtract
16525Instrument subtraction with pointer operands.
16526The option must be combined with either @option{-fsanitize=kernel-address} or
16527@option{-fsanitize=address}
16528The option cannot be combined with @option{-fsanitize=thread}.
16529Note: By default the check is disabled at run time. To enable it,
16530add @code{detect_invalid_pointer_pairs=2} to the environment variable
16531@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16532invalid operation only when both pointers are non-null.
16533
16534@item -fsanitize=shadow-call-stack
16535@opindex fsanitize=shadow-call-stack
16536Enable ShadowCallStack, a security enhancement mechanism used to protect
16537programs against return address overwrites (e.g. stack buffer overflows.)
16538It works by saving a function's return address to a separately allocated
16539shadow call stack in the function prologue and restoring the return address
16540from the shadow call stack in the function epilogue. Instrumentation only
16541occurs in functions that need to save the return address to the stack.
16542
16543Currently it only supports the aarch64 platform. It is specifically
16544designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option.
16545For the user space programs, runtime support is not currently provided
16546in libc and libgcc. Users who want to use this feature in user space need
16547to provide their own support for the runtime. It should be noted that
16548this may cause the ABI rules to be broken.
16549
16550On aarch64, the instrumentation makes use of the platform register @code{x18}.
16551This generally means that any code that may run on the same thread as code
16552compiled with ShadowCallStack must be compiled with the flag
16553@option{-ffixed-x18}, otherwise functions compiled without
16554@option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow
16555stack pointer.
16556
16557Also, because there is no userspace runtime support, code compiled with
16558ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions}
16559to turn off exceptions.
16560
16561See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more
16562details.
16563
16564@item -fsanitize=thread
16565@opindex fsanitize=thread
16566Enable ThreadSanitizer, a fast data race detector.
16567Memory access instructions are instrumented to detect
16568data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
16569details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
16570environment variable; see
16571@url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
16572supported options.
16573The option cannot be combined with @option{-fsanitize=address},
16574@option{-fsanitize=leak}.
16575
16576Note that sanitized atomic builtins cannot throw exceptions when
16577operating on invalid memory addresses with non-call exceptions
16578(@option{-fnon-call-exceptions}).
16579
16580@item -fsanitize=leak
16581@opindex fsanitize=leak
16582Enable LeakSanitizer, a memory leak detector.
16583This option only matters for linking of executables and
16584the executable is linked against a library that overrides @code{malloc}
16585and other allocator functions. See
16586@uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
16587details. The run-time behavior can be influenced using the
16588@env{LSAN_OPTIONS} environment variable.
16589The option cannot be combined with @option{-fsanitize=thread}.
16590
16591@item -fsanitize=undefined
16592@opindex fsanitize=undefined
16593Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
16594Various computations are instrumented to detect undefined behavior
16595at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
16596@env{UBSAN_OPTIONS} environment variable. Current suboptions are:
16597
16598@table @gcctabopt
16599
16600@item -fsanitize=shift
16601@opindex fsanitize=shift
16602This option enables checking that the result of a shift operation is
16603not undefined. Note that what exactly is considered undefined differs
16604slightly between C and C++, as well as between ISO C90 and C99, etc.
16605This option has two suboptions, @option{-fsanitize=shift-base} and
16606@option{-fsanitize=shift-exponent}.
16607
16608@item -fsanitize=shift-exponent
16609@opindex fsanitize=shift-exponent
16610This option enables checking that the second argument of a shift operation
16611is not negative and is smaller than the precision of the promoted first
16612argument.
16613
16614@item -fsanitize=shift-base
16615@opindex fsanitize=shift-base
16616If the second argument of a shift operation is within range, check that the
16617result of a shift operation is not undefined. Note that what exactly is
16618considered undefined differs slightly between C and C++, as well as between
16619ISO C90 and C99, etc.
16620
16621@item -fsanitize=integer-divide-by-zero
16622@opindex fsanitize=integer-divide-by-zero
16623Detect integer division by zero.
16624
16625@item -fsanitize=unreachable
16626@opindex fsanitize=unreachable
16627With this option, the compiler turns the @code{__builtin_unreachable}
16628call into a diagnostics message call instead. When reaching the
16629@code{__builtin_unreachable} call, the behavior is undefined.
16630
16631@item -fsanitize=vla-bound
16632@opindex fsanitize=vla-bound
16633This option instructs the compiler to check that the size of a variable
16634length array is positive.
16635
16636@item -fsanitize=null
16637@opindex fsanitize=null
16638This option enables pointer checking. Particularly, the application
16639built with this option turned on will issue an error message when it
16640tries to dereference a NULL pointer, or if a reference (possibly an
16641rvalue reference) is bound to a NULL pointer, or if a method is invoked
16642on an object pointed by a NULL pointer.
16643
16644@item -fsanitize=return
16645@opindex fsanitize=return
16646This option enables return statement checking. Programs
16647built with this option turned on will issue an error message
16648when the end of a non-void function is reached without actually
16649returning a value. This option works in C++ only.
16650
16651@item -fsanitize=signed-integer-overflow
16652@opindex fsanitize=signed-integer-overflow
16653This option enables signed integer overflow checking. We check that
16654the result of @code{+}, @code{*}, and both unary and binary @code{-}
16655does not overflow in the signed arithmetics. This also detects
16656@code{INT_MIN / -1} signed division. Note, integer promotion
16657rules must be taken into account. That is, the following is not an
16658overflow:
16659@smallexample
16660signed char a = SCHAR_MAX;
16661a++;
16662@end smallexample
16663
16664@item -fsanitize=bounds
16665@opindex fsanitize=bounds
16666This option enables instrumentation of array bounds. Various out of bounds
16667accesses are detected. Flexible array members, flexible array member-like
16668arrays, and initializers of variables with static storage are not instrumented.
16669
16670@item -fsanitize=bounds-strict
16671@opindex fsanitize=bounds-strict
16672This option enables strict instrumentation of array bounds. Most out of bounds
16673accesses are detected, including flexible array members and flexible array
16674member-like arrays. Initializers of variables with static storage are not
16675instrumented.
16676
16677@item -fsanitize=alignment
16678@opindex fsanitize=alignment
16679
16680This option enables checking of alignment of pointers when they are
16681dereferenced, or when a reference is bound to insufficiently aligned target,
16682or when a method or constructor is invoked on insufficiently aligned object.
16683
16684@item -fsanitize=object-size
16685@opindex fsanitize=object-size
16686This option enables instrumentation of memory references using the
16687@code{__builtin_object_size} function. Various out of bounds pointer
16688accesses are detected.
16689
16690@item -fsanitize=float-divide-by-zero
16691@opindex fsanitize=float-divide-by-zero
16692Detect floating-point division by zero. Unlike other similar options,
16693@option{-fsanitize=float-divide-by-zero} is not enabled by
16694@option{-fsanitize=undefined}, since floating-point division by zero can
16695be a legitimate way of obtaining infinities and NaNs.
16696
16697@item -fsanitize=float-cast-overflow
16698@opindex fsanitize=float-cast-overflow
16699This option enables floating-point type to integer conversion checking.
16700We check that the result of the conversion does not overflow.
16701Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
16702not enabled by @option{-fsanitize=undefined}.
16703This option does not work well with @code{FE_INVALID} exceptions enabled.
16704
16705@item -fsanitize=nonnull-attribute
16706@opindex fsanitize=nonnull-attribute
16707
16708This option enables instrumentation of calls, checking whether null values
16709are not passed to arguments marked as requiring a non-null value by the
16710@code{nonnull} function attribute.
16711
16712@item -fsanitize=returns-nonnull-attribute
16713@opindex fsanitize=returns-nonnull-attribute
16714
16715This option enables instrumentation of return statements in functions
16716marked with @code{returns_nonnull} function attribute, to detect returning
16717of null values from such functions.
16718
16719@item -fsanitize=bool
16720@opindex fsanitize=bool
16721
16722This option enables instrumentation of loads from bool. If a value other
16723than 0/1 is loaded, a run-time error is issued.
16724
16725@item -fsanitize=enum
16726@opindex fsanitize=enum
16727
16728This option enables instrumentation of loads from an enum type. If
16729a value outside the range of values for the enum type is loaded,
16730a run-time error is issued.
16731
16732@item -fsanitize=vptr
16733@opindex fsanitize=vptr
16734
16735This option enables instrumentation of C++ member function calls, member
16736accesses and some conversions between pointers to base and derived classes,
16737to verify the referenced object has the correct dynamic type.
16738
16739@item -fsanitize=pointer-overflow
16740@opindex fsanitize=pointer-overflow
16741
16742This option enables instrumentation of pointer arithmetics. If the pointer
16743arithmetics overflows, a run-time error is issued.
16744
16745@item -fsanitize=builtin
16746@opindex fsanitize=builtin
16747
16748This option enables instrumentation of arguments to selected builtin
16749functions. If an invalid value is passed to such arguments, a run-time
16750error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
16751or @code{__builtin_clz} invokes undefined behavior and is diagnosed
16752by this option.
16753
16754@end table
16755
16756Note that sanitizers tend to increase the rate of false positive
16757warnings, most notably those around @option{-Wmaybe-uninitialized}.
16758We recommend against combining @option{-Werror} and [the use of]
16759sanitizers.
16760
16761While @option{-ftrapv} causes traps for signed overflows to be emitted,
16762@option{-fsanitize=undefined} gives a diagnostic message.
16763This currently works only for the C family of languages.
16764
16765@item -fno-sanitize=all
16766@opindex fno-sanitize=all
16767
16768This option disables all previously enabled sanitizers.
16769@option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
16770together.
16771
16772@item -fasan-shadow-offset=@var{number}
16773@opindex fasan-shadow-offset
16774This option forces GCC to use custom shadow offset in AddressSanitizer checks.
16775It is useful for experimenting with different shadow memory layouts in
16776Kernel AddressSanitizer.
16777
16778@item -fsanitize-sections=@var{s1},@var{s2},...
16779@opindex fsanitize-sections
16780Sanitize global variables in selected user-defined sections. @var{si} may
16781contain wildcards.
16782
16783@item -fsanitize-recover@r{[}=@var{opts}@r{]}
16784@opindex fsanitize-recover
16785@opindex fno-sanitize-recover
16786@option{-fsanitize-recover=} controls error recovery mode for sanitizers
16787mentioned in comma-separated list of @var{opts}. Enabling this option
16788for a sanitizer component causes it to attempt to continue
16789running the program as if no error happened. This means multiple
16790runtime errors can be reported in a single program run, and the exit
16791code of the program may indicate success even when errors
16792have been reported. The @option{-fno-sanitize-recover=} option
16793can be used to alter
16794this behavior: only the first detected error is reported
16795and program then exits with a non-zero exit code.
16796
16797Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
16798except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
16799@option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
16800@option{-fsanitize=bounds-strict},
16801@option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
16802For these sanitizers error recovery is turned on by default,
16803except @option{-fsanitize=address}, for which this feature is experimental.
16804@option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
16805accepted, the former enables recovery for all sanitizers that support it,
16806the latter disables recovery for all sanitizers that support it.
16807
16808Even if a recovery mode is turned on the compiler side, it needs to be also
16809enabled on the runtime library side, otherwise the failures are still fatal.
16810The runtime library defaults to @code{halt_on_error=0} for
16811ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
16812AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
16813setting the @code{halt_on_error} flag in the corresponding environment variable.
16814
16815Syntax without an explicit @var{opts} parameter is deprecated. It is
16816equivalent to specifying an @var{opts} list of:
16817
16818@smallexample
16819undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
16820@end smallexample
16821
16822@item -fsanitize-address-use-after-scope
16823@opindex fsanitize-address-use-after-scope
16824Enable sanitization of local variables to detect use-after-scope bugs.
16825The option sets @option{-fstack-reuse} to @samp{none}.
16826
16827@item -fsanitize-trap@r{[}=@var{opts}@r{]}
16828@opindex fsanitize-trap
16829@opindex fno-sanitize-trap
16830The @option{-fsanitize-trap=} option instructs the compiler to
16831report for sanitizers mentioned in comma-separated list of @var{opts}
16832undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
16833library routine. If this option is enabled for certain sanitizer,
16834it takes precedence over the @option{-fsanitizer-recover=} for that
16835sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
16836of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
16837
16838The advantage of this is that the @code{libubsan} library is not needed
16839and is not linked in, so this is usable even in freestanding environments.
16840
16841Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
16842except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
16843@option{-fsanitize=float-divide-by-zero} and
16844@option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
16845specified, which enables it for @code{undefined} suboptions,
16846@option{-fsanitize=float-cast-overflow},
16847@option{-fsanitize=float-divide-by-zero} and
16848@option{-fsanitize=bounds-strict}.
16849If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
16850and @code{-fsanitize=vptr} is enabled on the command line, the
16851instrumentation is silently ignored as the instrumentation always needs
16852@code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
16853
16854@item -fsanitize-undefined-trap-on-error
16855@opindex fsanitize-undefined-trap-on-error
16856The @option{-fsanitize-undefined-trap-on-error} option is deprecated
16857equivalent of @option{-fsanitize-trap=all}.
16858
16859@item -fsanitize-coverage=trace-pc
16860@opindex fsanitize-coverage=trace-pc
16861Enable coverage-guided fuzzing code instrumentation.
16862Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
16863
16864@item -fsanitize-coverage=trace-cmp
16865@opindex fsanitize-coverage=trace-cmp
16866Enable dataflow guided fuzzing code instrumentation.
16867Inserts a call to @code{__sanitizer_cov_trace_cmp1},
16868@code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
16869@code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
16870variable or @code{__sanitizer_cov_trace_const_cmp1},
16871@code{__sanitizer_cov_trace_const_cmp2},
16872@code{__sanitizer_cov_trace_const_cmp4} or
16873@code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
16874operand constant, @code{__sanitizer_cov_trace_cmpf} or
16875@code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
16876@code{__sanitizer_cov_trace_switch} for switch statements.
16877
16878@item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
16879@opindex fcf-protection
16880Enable code instrumentation of control-flow transfers to increase
16881program security by checking that target addresses of control-flow
16882transfer instructions (such as indirect function call, function return,
16883indirect jump) are valid. This prevents diverting the flow of control
16884to an unexpected target. This is intended to protect against such
16885threats as Return-oriented Programming (ROP), and similarly
16886call/jmp-oriented programming (COP/JOP).
16887
16888The value @code{branch} tells the compiler to implement checking of
16889validity of control-flow transfer at the point of indirect branch
16890instructions, i.e.@: call/jmp instructions. The value @code{return}
16891implements checking of validity at the point of returning from a
16892function. The value @code{full} is an alias for specifying both
16893@code{branch} and @code{return}. The value @code{none} turns off
16894instrumentation.
16895
16896The value @code{check} is used for the final link with link-time
16897optimization (LTO). An error is issued if LTO object files are
16898compiled with different @option{-fcf-protection} values. The
16899value @code{check} is ignored at the compile time.
16900
16901The macro @code{__CET__} is defined when @option{-fcf-protection} is
16902used. The first bit of @code{__CET__} is set to 1 for the value
16903@code{branch} and the second bit of @code{__CET__} is set to 1 for
16904the @code{return}.
16905
16906You can also use the @code{nocf_check} attribute to identify
16907which functions and calls should be skipped from instrumentation
16908(@pxref{Function Attributes}).
16909
16910Currently the x86 GNU/Linux target provides an implementation based
16911on Intel Control-flow Enforcement Technology (CET) which works for
16912i686 processor or newer.
16913
16914@item -fharden-compares
16915@opindex fharden-compares
16916For every logical test that survives gimple optimizations and is
16917@emph{not} the condition in a conditional branch (for example,
16918conditions tested for conditional moves, or to store in boolean
16919variables), emit extra code to compute and verify the reversed
16920condition, and to call @code{__builtin_trap} if the results do not
16921match. Use with @samp{-fharden-conditional-branches} to cover all
16922conditionals.
16923
16924@item -fharden-conditional-branches
16925@opindex fharden-conditional-branches
16926For every non-vectorized conditional branch that survives gimple
16927optimizations, emit extra code to compute and verify the reversed
16928condition, and to call @code{__builtin_trap} if the result is
16929unexpected. Use with @samp{-fharden-compares} to cover all
16930conditionals.
16931
16932@item -fstack-protector
16933@opindex fstack-protector
16934Emit extra code to check for buffer overflows, such as stack smashing
16935attacks. This is done by adding a guard variable to functions with
16936vulnerable objects. This includes functions that call @code{alloca}, and
16937functions with buffers larger than or equal to 8 bytes. The guards are
16938initialized when a function is entered and then checked when the function
16939exits. If a guard check fails, an error message is printed and the program
16940exits. Only variables that are actually allocated on the stack are
16941considered, optimized away variables or variables allocated in registers
16942don't count.
16943
16944@item -fstack-protector-all
16945@opindex fstack-protector-all
16946Like @option{-fstack-protector} except that all functions are protected.
16947
16948@item -fstack-protector-strong
16949@opindex fstack-protector-strong
16950Like @option{-fstack-protector} but includes additional functions to
16951be protected --- those that have local array definitions, or have
16952references to local frame addresses. Only variables that are actually
16953allocated on the stack are considered, optimized away variables or variables
16954allocated in registers don't count.
16955
16956@item -fstack-protector-explicit
16957@opindex fstack-protector-explicit
16958Like @option{-fstack-protector} but only protects those functions which
16959have the @code{stack_protect} attribute.
16960
16961@item -fstack-check
16962@opindex fstack-check
16963Generate code to verify that you do not go beyond the boundary of the
16964stack. You should specify this flag if you are running in an
16965environment with multiple threads, but you only rarely need to specify it in
16966a single-threaded environment since stack overflow is automatically
16967detected on nearly all systems if there is only one stack.
16968
16969Note that this switch does not actually cause checking to be done; the
16970operating system or the language runtime must do that. The switch causes
16971generation of code to ensure that they see the stack being extended.
16972
16973You can additionally specify a string parameter: @samp{no} means no
16974checking, @samp{generic} means force the use of old-style checking,
16975@samp{specific} means use the best checking method and is equivalent
16976to bare @option{-fstack-check}.
16977
16978Old-style checking is a generic mechanism that requires no specific
16979target support in the compiler but comes with the following drawbacks:
16980
16981@enumerate
16982@item
16983Modified allocation strategy for large objects: they are always
16984allocated dynamically if their size exceeds a fixed threshold. Note this
16985may change the semantics of some code.
16986
16987@item
16988Fixed limit on the size of the static frame of functions: when it is
16989topped by a particular function, stack checking is not reliable and
16990a warning is issued by the compiler.
16991
16992@item
16993Inefficiency: because of both the modified allocation strategy and the
16994generic implementation, code performance is hampered.
16995@end enumerate
16996
16997Note that old-style stack checking is also the fallback method for
16998@samp{specific} if no target support has been added in the compiler.
16999
17000@samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
17001and stack overflows. @samp{specific} is an excellent choice when compiling
17002Ada code. It is not generally sufficient to protect against stack-clash
17003attacks. To protect against those you want @samp{-fstack-clash-protection}.
17004
17005@item -fstack-clash-protection
17006@opindex fstack-clash-protection
17007Generate code to prevent stack clash style attacks. When this option is
17008enabled, the compiler will only allocate one page of stack space at a time
17009and each page is accessed immediately after allocation. Thus, it prevents
17010allocations from jumping over any stack guard page provided by the
17011operating system.
17012
17013Most targets do not fully support stack clash protection. However, on
17014those targets @option{-fstack-clash-protection} will protect dynamic stack
17015allocations. @option{-fstack-clash-protection} may also provide limited
17016protection for static stack allocations if the target supports
17017@option{-fstack-check=specific}.
17018
17019@item -fstack-limit-register=@var{reg}
17020@itemx -fstack-limit-symbol=@var{sym}
17021@itemx -fno-stack-limit
17022@opindex fstack-limit-register
17023@opindex fstack-limit-symbol
17024@opindex fno-stack-limit
17025Generate code to ensure that the stack does not grow beyond a certain value,
17026either the value of a register or the address of a symbol. If a larger
17027stack is required, a signal is raised at run time. For most targets,
17028the signal is raised before the stack overruns the boundary, so
17029it is possible to catch the signal without taking special precautions.
17030
17031For instance, if the stack starts at absolute address @samp{0x80000000}
17032and grows downwards, you can use the flags
17033@option{-fstack-limit-symbol=__stack_limit} and
17034@option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
17035of 128KB@. Note that this may only work with the GNU linker.
17036
17037You can locally override stack limit checking by using the
17038@code{no_stack_limit} function attribute (@pxref{Function Attributes}).
17039
17040@item -fsplit-stack
17041@opindex fsplit-stack
17042Generate code to automatically split the stack before it overflows.
17043The resulting program has a discontiguous stack which can only
17044overflow if the program is unable to allocate any more memory. This
17045is most useful when running threaded programs, as it is no longer
17046necessary to calculate a good stack size to use for each thread. This
17047is currently only implemented for the x86 targets running
17048GNU/Linux.
17049
17050When code compiled with @option{-fsplit-stack} calls code compiled
17051without @option{-fsplit-stack}, there may not be much stack space
17052available for the latter code to run. If compiling all code,
17053including library code, with @option{-fsplit-stack} is not an option,
17054then the linker can fix up these calls so that the code compiled
17055without @option{-fsplit-stack} always has a large stack. Support for
17056this is implemented in the gold linker in GNU binutils release 2.21
17057and later.
17058
17059@item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
17060@opindex fvtable-verify
17061This option is only available when compiling C++ code.
17062It turns on (or off, if using @option{-fvtable-verify=none}) the security
17063feature that verifies at run time, for every virtual call, that
17064the vtable pointer through which the call is made is valid for the type of
17065the object, and has not been corrupted or overwritten. If an invalid vtable
17066pointer is detected at run time, an error is reported and execution of the
17067program is immediately halted.
17068
17069This option causes run-time data structures to be built at program startup,
17070which are used for verifying the vtable pointers.
17071The options @samp{std} and @samp{preinit}
17072control the timing of when these data structures are built. In both cases the
17073data structures are built before execution reaches @code{main}. Using
17074@option{-fvtable-verify=std} causes the data structures to be built after
17075shared libraries have been loaded and initialized.
17076@option{-fvtable-verify=preinit} causes them to be built before shared
17077libraries have been loaded and initialized.
17078
17079If this option appears multiple times in the command line with different
17080values specified, @samp{none} takes highest priority over both @samp{std} and
17081@samp{preinit}; @samp{preinit} takes priority over @samp{std}.
17082
17083@item -fvtv-debug
17084@opindex fvtv-debug
17085When used in conjunction with @option{-fvtable-verify=std} or
17086@option{-fvtable-verify=preinit}, causes debug versions of the
17087runtime functions for the vtable verification feature to be called.
17088This flag also causes the compiler to log information about which
17089vtable pointers it finds for each class.
17090This information is written to a file named @file{vtv_set_ptr_data.log}
17091in the directory named by the environment variable @env{VTV_LOGS_DIR}
17092if that is defined or the current working directory otherwise.
17093
17094Note: This feature @emph{appends} data to the log file. If you want a fresh log
17095file, be sure to delete any existing one.
17096
17097@item -fvtv-counts
17098@opindex fvtv-counts
17099This is a debugging flag. When used in conjunction with
17100@option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
17101causes the compiler to keep track of the total number of virtual calls
17102it encounters and the number of verifications it inserts. It also
17103counts the number of calls to certain run-time library functions
17104that it inserts and logs this information for each compilation unit.
17105The compiler writes this information to a file named
17106@file{vtv_count_data.log} in the directory named by the environment
17107variable @env{VTV_LOGS_DIR} if that is defined or the current working
17108directory otherwise. It also counts the size of the vtable pointer sets
17109for each class, and writes this information to @file{vtv_class_set_sizes.log}
17110in the same directory.
17111
17112Note: This feature @emph{appends} data to the log files. To get fresh log
17113files, be sure to delete any existing ones.
17114
17115@item -finstrument-functions
17116@opindex finstrument-functions
17117Generate instrumentation calls for entry and exit to functions. Just
17118after function entry and just before function exit, the following
17119profiling functions are called with the address of the current
17120function and its call site. (On some platforms,
17121@code{__builtin_return_address} does not work beyond the current
17122function, so the call site information may not be available to the
17123profiling functions otherwise.)
17124
17125@smallexample
17126void __cyg_profile_func_enter (void *this_fn,
17127 void *call_site);
17128void __cyg_profile_func_exit (void *this_fn,
17129 void *call_site);
17130@end smallexample
17131
17132The first argument is the address of the start of the current function,
17133which may be looked up exactly in the symbol table.
17134
17135This instrumentation is also done for functions expanded inline in other
17136functions. The profiling calls indicate where, conceptually, the
17137inline function is entered and exited. This means that addressable
17138versions of such functions must be available. If all your uses of a
17139function are expanded inline, this may mean an additional expansion of
17140code size. If you use @code{extern inline} in your C code, an
17141addressable version of such functions must be provided. (This is
17142normally the case anyway, but if you get lucky and the optimizer always
17143expands the functions inline, you might have gotten away without
17144providing static copies.)
17145
17146A function may be given the attribute @code{no_instrument_function}, in
17147which case this instrumentation is not done. This can be used, for
17148example, for the profiling functions listed above, high-priority
17149interrupt routines, and any functions from which the profiling functions
17150cannot safely be called (perhaps signal handlers, if the profiling
17151routines generate output or allocate memory).
17152@xref{Common Function Attributes}.
17153
17154@item -finstrument-functions-once
9c19597c 17155@opindex finstrument-functions-once
d77de738
ML
17156This is similar to @option{-finstrument-functions}, but the profiling
17157functions are called only once per instrumented function, i.e. the first
17158profiling function is called after the first entry into the instrumented
17159function and the second profiling function is called before the exit
17160corresponding to this first entry.
17161
17162The definition of @code{once} for the purpose of this option is a little
17163vague because the implementation is not protected against data races.
17164As a result, the implementation only guarantees that the profiling
17165functions are called at @emph{least} once per process and at @emph{most}
17166once per thread, but the calls are always paired, that is to say, if a
17167thread calls the first function, then it will call the second function,
17168unless it never reaches the exit of the instrumented function.
17169
17170@item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
17171@opindex finstrument-functions-exclude-file-list
17172
17173Set the list of functions that are excluded from instrumentation (see
17174the description of @option{-finstrument-functions}). If the file that
17175contains a function definition matches with one of @var{file}, then
17176that function is not instrumented. The match is done on substrings:
17177if the @var{file} parameter is a substring of the file name, it is
17178considered to be a match.
17179
17180For example:
17181
17182@smallexample
17183-finstrument-functions-exclude-file-list=/bits/stl,include/sys
17184@end smallexample
17185
17186@noindent
17187excludes any inline function defined in files whose pathnames
17188contain @file{/bits/stl} or @file{include/sys}.
17189
17190If, for some reason, you want to include letter @samp{,} in one of
17191@var{sym}, write @samp{\,}. For example,
17192@option{-finstrument-functions-exclude-file-list='\,\,tmp'}
17193(note the single quote surrounding the option).
17194
17195@item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
17196@opindex finstrument-functions-exclude-function-list
17197
17198This is similar to @option{-finstrument-functions-exclude-file-list},
17199but this option sets the list of function names to be excluded from
17200instrumentation. The function name to be matched is its user-visible
17201name, such as @code{vector<int> blah(const vector<int> &)}, not the
17202internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
17203match is done on substrings: if the @var{sym} parameter is a substring
17204of the function name, it is considered to be a match. For C99 and C++
17205extended identifiers, the function name must be given in UTF-8, not
17206using universal character names.
17207
17208@item -fpatchable-function-entry=@var{N}[,@var{M}]
17209@opindex fpatchable-function-entry
17210Generate @var{N} NOPs right at the beginning
17211of each function, with the function entry point before the @var{M}th NOP.
17212If @var{M} is omitted, it defaults to @code{0} so the
17213function entry points to the address just at the first NOP.
17214The NOP instructions reserve extra space which can be used to patch in
17215any desired instrumentation at run time, provided that the code segment
17216is writable. The amount of space is controllable indirectly via
17217the number of NOPs; the NOP instruction used corresponds to the instruction
17218emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
17219is target-specific and may also depend on the architecture variant and/or
17220other compilation options.
17221
17222For run-time identification, the starting addresses of these areas,
17223which correspond to their respective function entries minus @var{M},
17224are additionally collected in the @code{__patchable_function_entries}
17225section of the resulting binary.
17226
17227Note that the value of @code{__attribute__ ((patchable_function_entry
17228(N,M)))} takes precedence over command-line option
17229@option{-fpatchable-function-entry=N,M}. This can be used to increase
17230the area size or to remove it completely on a single function.
17231If @code{N=0}, no pad location is recorded.
17232
17233The NOP instructions are inserted at---and maybe before, depending on
17234@var{M}---the function entry address, even before the prologue. On
17235PowerPC with the ELFv2 ABI, for a function with dual entry points,
17236the local entry point is this function entry address.
17237
17238The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the
17239ELFv2 ABI, for a function with dual entry points, the supported values
17240for @var{M} are 0, 2, 6 and 14.
17241@end table
17242
17243
17244@node Preprocessor Options
17245@section Options Controlling the Preprocessor
17246@cindex preprocessor options
17247@cindex options, preprocessor
17248
17249These options control the C preprocessor, which is run on each C source
17250file before actual compilation.
17251
17252If you use the @option{-E} option, nothing is done except preprocessing.
17253Some of these options make sense only together with @option{-E} because
17254they cause the preprocessor output to be unsuitable for actual
17255compilation.
17256
17257In addition to the options listed here, there are a number of options
17258to control search paths for include files documented in
17259@ref{Directory Options}.
17260Options to control preprocessor diagnostics are listed in
17261@ref{Warning Options}.
17262
17263@table @gcctabopt
17264@include cppopts.texi
17265
17266@item -Wp,@var{option}
17267@opindex Wp
17268You can use @option{-Wp,@var{option}} to bypass the compiler driver
17269and pass @var{option} directly through to the preprocessor. If
17270@var{option} contains commas, it is split into multiple options at the
17271commas. However, many options are modified, translated or interpreted
17272by the compiler driver before being passed to the preprocessor, and
17273@option{-Wp} forcibly bypasses this phase. The preprocessor's direct
17274interface is undocumented and subject to change, so whenever possible
17275you should avoid using @option{-Wp} and let the driver handle the
17276options instead.
17277
17278@item -Xpreprocessor @var{option}
17279@opindex Xpreprocessor
17280Pass @var{option} as an option to the preprocessor. You can use this to
17281supply system-specific preprocessor options that GCC does not
17282recognize.
17283
17284If you want to pass an option that takes an argument, you must use
17285@option{-Xpreprocessor} twice, once for the option and once for the argument.
17286
17287@item -no-integrated-cpp
17288@opindex no-integrated-cpp
17289Perform preprocessing as a separate pass before compilation.
17290By default, GCC performs preprocessing as an integrated part of
17291input tokenization and parsing.
17292If this option is provided, the appropriate language front end
17293(@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
17294and Objective-C, respectively) is instead invoked twice,
17295once for preprocessing only and once for actual compilation
17296of the preprocessed input.
17297This option may be useful in conjunction with the @option{-B} or
17298@option{-wrapper} options to specify an alternate preprocessor or
17299perform additional processing of the program source between
17300normal preprocessing and compilation.
17301
17302@item -flarge-source-files
17303@opindex flarge-source-files
17304Adjust GCC to expect large source files, at the expense of slower
17305compilation and higher memory usage.
17306
17307Specifically, GCC normally tracks both column numbers and line numbers
17308within source files and it normally prints both of these numbers in
17309diagnostics. However, once it has processed a certain number of source
17310lines, it stops tracking column numbers and only tracks line numbers.
17311This means that diagnostics for later lines do not include column numbers.
17312It also means that options like @option{-Wmisleading-indentation} cease to work
17313at that point, although the compiler prints a note if this happens.
17314Passing @option{-flarge-source-files} significantly increases the number
17315of source lines that GCC can process before it stops tracking columns.
17316
17317@end table
17318
17319@node Assembler Options
17320@section Passing Options to the Assembler
17321
17322@c prevent bad page break with this line
17323You can pass options to the assembler.
17324
17325@table @gcctabopt
17326@item -Wa,@var{option}
17327@opindex Wa
17328Pass @var{option} as an option to the assembler. If @var{option}
17329contains commas, it is split into multiple options at the commas.
17330
17331@item -Xassembler @var{option}
17332@opindex Xassembler
17333Pass @var{option} as an option to the assembler. You can use this to
17334supply system-specific assembler options that GCC does not
17335recognize.
17336
17337If you want to pass an option that takes an argument, you must use
17338@option{-Xassembler} twice, once for the option and once for the argument.
17339
17340@end table
17341
17342@node Link Options
17343@section Options for Linking
17344@cindex link options
17345@cindex options, linking
17346
17347These options come into play when the compiler links object files into
17348an executable output file. They are meaningless if the compiler is
17349not doing a link step.
17350
17351@table @gcctabopt
17352@cindex file names
17353@item @var{object-file-name}
17354A file name that does not end in a special recognized suffix is
17355considered to name an object file or library. (Object files are
17356distinguished from libraries by the linker according to the file
17357contents.) If linking is done, these object files are used as input
17358to the linker.
17359
17360@item -c
17361@itemx -S
17362@itemx -E
17363@opindex c
17364@opindex S
17365@opindex E
17366If any of these options is used, then the linker is not run, and
17367object file names should not be used as arguments. @xref{Overall
17368Options}.
17369
17370@item -flinker-output=@var{type}
17371@opindex flinker-output
17372This option controls code generation of the link-time optimizer. By
17373default the linker output is automatically determined by the linker
17374plugin. For debugging the compiler and if incremental linking with a
17375non-LTO object file is desired, it may be useful to control the type
17376manually.
17377
17378If @var{type} is @samp{exec}, code generation produces a static
17379binary. In this case @option{-fpic} and @option{-fpie} are both
17380disabled.
17381
17382If @var{type} is @samp{dyn}, code generation produces a shared
17383library. In this case @option{-fpic} or @option{-fPIC} is preserved,
17384but not enabled automatically. This allows to build shared libraries
17385without position-independent code on architectures where this is
17386possible, i.e.@: on x86.
17387
17388If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
17389executable. This results in similar optimizations as @samp{exec}
17390except that @option{-fpie} is not disabled if specified at compilation
17391time.
17392
17393If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
17394done. The sections containing intermediate code for link-time optimization are
17395merged, pre-optimized, and output to the resulting object file. In addition, if
17396@option{-ffat-lto-objects} is specified, binary code is produced for future
17397non-LTO linking. The object file produced by incremental linking is smaller
17398than a static library produced from the same object files. At link time the
17399result of incremental linking also loads faster than a static
17400library assuming that the majority of objects in the library are used.
17401
17402Finally @samp{nolto-rel} configures the compiler for incremental linking where
17403code generation is forced, a final binary is produced, and the intermediate
17404code for later link-time optimization is stripped. When multiple object files
17405are linked together the resulting code is better optimized than with
17406link-time optimizations disabled (for example, cross-module inlining
17407happens), but most of benefits of whole program optimizations are lost.
17408
17409During the incremental link (by @option{-r}) the linker plugin defaults to
17410@option{rel}. With current interfaces to GNU Binutils it is however not
17411possible to incrementally link LTO objects and non-LTO objects into a single
17412mixed object file. If any of object files in incremental link cannot
17413be used for link-time optimization, the linker plugin issues a warning and
17414uses @samp{nolto-rel}. To maintain whole program optimization, it is
17415recommended to link such objects into static library instead. Alternatively it
17416is possible to use H.J. Lu's binutils with support for mixed objects.
17417
17418@item -fuse-ld=bfd
17419@opindex fuse-ld=bfd
17420Use the @command{bfd} linker instead of the default linker.
17421
17422@item -fuse-ld=gold
17423@opindex fuse-ld=gold
17424Use the @command{gold} linker instead of the default linker.
17425
17426@item -fuse-ld=lld
17427@opindex fuse-ld=lld
17428Use the LLVM @command{lld} linker instead of the default linker.
17429
17430@item -fuse-ld=mold
17431@opindex fuse-ld=mold
17432Use the Modern Linker (@command{mold}) instead of the default linker.
17433
17434@cindex Libraries
17435@item -l@var{library}
17436@itemx -l @var{library}
17437@opindex l
17438Search the library named @var{library} when linking. (The second
17439alternative with the library as a separate argument is only for
17440POSIX compliance and is not recommended.)
17441
17442The @option{-l} option is passed directly to the linker by GCC. Refer
17443to your linker documentation for exact details. The general
17444description below applies to the GNU linker.
17445
17446The linker searches a standard list of directories for the library.
17447The directories searched include several standard system directories
17448plus any that you specify with @option{-L}.
17449
17450Static libraries are archives of object files, and have file names
17451like @file{lib@var{library}.a}. Some targets also support shared
17452libraries, which typically have names like @file{lib@var{library}.so}.
17453If both static and shared libraries are found, the linker gives
17454preference to linking with the shared library unless the
17455@option{-static} option is used.
17456
17457It makes a difference where in the command you write this option; the
17458linker searches and processes libraries and object files in the order they
17459are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
17460after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
17461to functions in @samp{z}, those functions may not be loaded.
17462
17463@item -lobjc
17464@opindex lobjc
17465You need this special case of the @option{-l} option in order to
17466link an Objective-C or Objective-C++ program.
17467
17468@item -nostartfiles
17469@opindex nostartfiles
17470Do not use the standard system startup files when linking.
17471The standard system libraries are used normally, unless @option{-nostdlib},
17472@option{-nolibc}, or @option{-nodefaultlibs} is used.
17473
17474@item -nodefaultlibs
17475@opindex nodefaultlibs
17476Do not use the standard system libraries when linking.
17477Only the libraries you specify are passed to the linker, and options
17478specifying linkage of the system libraries, such as @option{-static-libgcc}
17479or @option{-shared-libgcc}, are ignored.
17480The standard startup files are used normally, unless @option{-nostartfiles}
17481is used.
17482
17483The compiler may generate calls to @code{memcmp},
17484@code{memset}, @code{memcpy} and @code{memmove}.
17485These entries are usually resolved by entries in
17486libc. These entry points should be supplied through some other
17487mechanism when this option is specified.
17488
17489@item -nolibc
17490@opindex nolibc
17491Do not use the C library or system libraries tightly coupled with it when
17492linking. Still link with the startup files, @file{libgcc} or toolchain
17493provided language support libraries such as @file{libgnat}, @file{libgfortran}
17494or @file{libstdc++} unless options preventing their inclusion are used as
17495well. This typically removes @option{-lc} from the link command line, as well
17496as system libraries that normally go with it and become meaningless when
17497absence of a C library is assumed, for example @option{-lpthread} or
17498@option{-lm} in some configurations. This is intended for bare-board
17499targets when there is indeed no C library available.
17500
17501@item -nostdlib
17502@opindex nostdlib
17503Do not use the standard system startup files or libraries when linking.
17504No startup files and only the libraries you specify are passed to
17505the linker, and options specifying linkage of the system libraries, such as
17506@option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
17507
17508The compiler may generate calls to @code{memcmp}, @code{memset},
17509@code{memcpy} and @code{memmove}.
17510These entries are usually resolved by entries in
17511libc. These entry points should be supplied through some other
17512mechanism when this option is specified.
17513
17514@cindex @option{-lgcc}, use with @option{-nostdlib}
17515@cindex @option{-nostdlib} and unresolved references
17516@cindex unresolved references and @option{-nostdlib}
17517@cindex @option{-lgcc}, use with @option{-nodefaultlibs}
17518@cindex @option{-nodefaultlibs} and unresolved references
17519@cindex unresolved references and @option{-nodefaultlibs}
17520One of the standard libraries bypassed by @option{-nostdlib} and
17521@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
17522which GCC uses to overcome shortcomings of particular machines, or special
17523needs for some languages.
17524(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
17525Collection (GCC) Internals},
17526for more discussion of @file{libgcc.a}.)
17527In most cases, you need @file{libgcc.a} even when you want to avoid
17528other standard libraries. In other words, when you specify @option{-nostdlib}
17529or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
17530This ensures that you have no unresolved references to internal GCC
17531library subroutines.
17532(An example of such an internal subroutine is @code{__main}, used to ensure C++
17533constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
17534GNU Compiler Collection (GCC) Internals}.)
17535
17536@item -nostdlib++
17537@opindex nostdlib++
17538Do not implicitly link with standard C++ libraries.
17539
17540@item -e @var{entry}
17541@itemx --entry=@var{entry}
17542@opindex e
17543@opindex entry
17544
17545Specify that the program entry point is @var{entry}. The argument is
17546interpreted by the linker; the GNU linker accepts either a symbol name
17547or an address.
17548
17549@item -pie
17550@opindex pie
17551Produce a dynamically linked position independent executable on targets
17552that support it. For predictable results, you must also specify the same
17553set of options used for compilation (@option{-fpie}, @option{-fPIE},
17554or model suboptions) when you specify this linker option.
17555
17556@item -no-pie
17557@opindex no-pie
17558Don't produce a dynamically linked position independent executable.
17559
17560@item -static-pie
17561@opindex static-pie
17562Produce a static position independent executable on targets that support
17563it. A static position independent executable is similar to a static
17564executable, but can be loaded at any address without a dynamic linker.
17565For predictable results, you must also specify the same set of options
17566used for compilation (@option{-fpie}, @option{-fPIE}, or model
17567suboptions) when you specify this linker option.
17568
17569@item -pthread
17570@opindex pthread
17571Link with the POSIX threads library. This option is supported on
17572GNU/Linux targets, most other Unix derivatives, and also on
17573x86 Cygwin and MinGW targets. On some targets this option also sets
17574flags for the preprocessor, so it should be used consistently for both
17575compilation and linking.
17576
17577@item -r
17578@opindex r
17579Produce a relocatable object as output. This is also known as partial
17580linking.
17581
17582@item -rdynamic
17583@opindex rdynamic
17584Pass the flag @option{-export-dynamic} to the ELF linker, on targets
17585that support it. This instructs the linker to add all symbols, not
17586only used ones, to the dynamic symbol table. This option is needed
17587for some uses of @code{dlopen} or to allow obtaining backtraces
17588from within a program.
17589
17590@item -s
17591@opindex s
17592Remove all symbol table and relocation information from the executable.
17593
17594@item -static
17595@opindex static
17596On systems that support dynamic linking, this overrides @option{-pie}
17597and prevents linking with the shared libraries. On other systems, this
17598option has no effect.
17599
17600@item -shared
17601@opindex shared
17602Produce a shared object which can then be linked with other objects to
17603form an executable. Not all systems support this option. For predictable
17604results, you must also specify the same set of options used for compilation
17605(@option{-fpic}, @option{-fPIC}, or model suboptions) when
17606you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
17607needs to build supplementary stub code for constructors to work. On
17608multi-libbed systems, @samp{gcc -shared} must select the correct support
17609libraries to link against. Failing to supply the correct flags may lead
17610to subtle defects. Supplying them in cases where they are not necessary
17611is innocuous.}
17612
17613@item -shared-libgcc
17614@itemx -static-libgcc
17615@opindex shared-libgcc
17616@opindex static-libgcc
17617On systems that provide @file{libgcc} as a shared library, these options
17618force the use of either the shared or static version, respectively.
17619If no shared version of @file{libgcc} was built when the compiler was
17620configured, these options have no effect.
17621
17622There are several situations in which an application should use the
17623shared @file{libgcc} instead of the static version. The most common
17624of these is when the application wishes to throw and catch exceptions
17625across different shared libraries. In that case, each of the libraries
17626as well as the application itself should use the shared @file{libgcc}.
17627
17628Therefore, the G++ driver automatically adds @option{-shared-libgcc}
17629whenever you build a shared library or a main executable, because C++
17630programs typically use exceptions, so this is the right thing to do.
17631
17632If, instead, you use the GCC driver to create shared libraries, you may
17633find that they are not always linked with the shared @file{libgcc}.
17634If GCC finds, at its configuration time, that you have a non-GNU linker
17635or a GNU linker that does not support option @option{--eh-frame-hdr},
17636it links the shared version of @file{libgcc} into shared libraries
17637by default. Otherwise, it takes advantage of the linker and optimizes
17638away the linking with the shared version of @file{libgcc}, linking with
17639the static version of libgcc by default. This allows exceptions to
17640propagate through such shared libraries, without incurring relocation
17641costs at library load time.
17642
17643However, if a library or main executable is supposed to throw or catch
17644exceptions, you must link it using the G++ driver, or using the option
17645@option{-shared-libgcc}, such that it is linked with the shared
17646@file{libgcc}.
17647
17648@item -static-libasan
17649@opindex static-libasan
17650When the @option{-fsanitize=address} option is used to link a program,
17651the GCC driver automatically links against @option{libasan}. If
17652@file{libasan} is available as a shared library, and the @option{-static}
17653option is not used, then this links against the shared version of
17654@file{libasan}. The @option{-static-libasan} option directs the GCC
17655driver to link @file{libasan} statically, without necessarily linking
17656other libraries statically.
17657
17658@item -static-libtsan
17659@opindex static-libtsan
17660When the @option{-fsanitize=thread} option is used to link a program,
17661the GCC driver automatically links against @option{libtsan}. If
17662@file{libtsan} is available as a shared library, and the @option{-static}
17663option is not used, then this links against the shared version of
17664@file{libtsan}. The @option{-static-libtsan} option directs the GCC
17665driver to link @file{libtsan} statically, without necessarily linking
17666other libraries statically.
17667
17668@item -static-liblsan
17669@opindex static-liblsan
17670When the @option{-fsanitize=leak} option is used to link a program,
17671the GCC driver automatically links against @option{liblsan}. If
17672@file{liblsan} is available as a shared library, and the @option{-static}
17673option is not used, then this links against the shared version of
17674@file{liblsan}. The @option{-static-liblsan} option directs the GCC
17675driver to link @file{liblsan} statically, without necessarily linking
17676other libraries statically.
17677
17678@item -static-libubsan
17679@opindex static-libubsan
17680When the @option{-fsanitize=undefined} option is used to link a program,
17681the GCC driver automatically links against @option{libubsan}. If
17682@file{libubsan} is available as a shared library, and the @option{-static}
17683option is not used, then this links against the shared version of
17684@file{libubsan}. The @option{-static-libubsan} option directs the GCC
17685driver to link @file{libubsan} statically, without necessarily linking
17686other libraries statically.
17687
17688@item -static-libstdc++
17689@opindex static-libstdc++
17690When the @command{g++} program is used to link a C++ program, it
17691normally automatically links against @option{libstdc++}. If
17692@file{libstdc++} is available as a shared library, and the
17693@option{-static} option is not used, then this links against the
17694shared version of @file{libstdc++}. That is normally fine. However, it
17695is sometimes useful to freeze the version of @file{libstdc++} used by
17696the program without going all the way to a fully static link. The
17697@option{-static-libstdc++} option directs the @command{g++} driver to
17698link @file{libstdc++} statically, without necessarily linking other
17699libraries statically.
17700
17701@item -symbolic
17702@opindex symbolic
17703Bind references to global symbols when building a shared object. Warn
17704about any unresolved references (unless overridden by the link editor
17705option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
17706this option.
17707
17708@item -T @var{script}
17709@opindex T
17710@cindex linker script
17711Use @var{script} as the linker script. This option is supported by most
17712systems using the GNU linker. On some targets, such as bare-board
17713targets without an operating system, the @option{-T} option may be required
17714when linking to avoid references to undefined symbols.
17715
17716@item -Xlinker @var{option}
17717@opindex Xlinker
17718Pass @var{option} as an option to the linker. You can use this to
17719supply system-specific linker options that GCC does not recognize.
17720
17721If you want to pass an option that takes a separate argument, you must use
17722@option{-Xlinker} twice, once for the option and once for the argument.
17723For example, to pass @option{-assert definitions}, you must write
17724@option{-Xlinker -assert -Xlinker definitions}. It does not work to write
17725@option{-Xlinker "-assert definitions"}, because this passes the entire
17726string as a single argument, which is not what the linker expects.
17727
17728When using the GNU linker, it is usually more convenient to pass
17729arguments to linker options using the @option{@var{option}=@var{value}}
17730syntax than as separate arguments. For example, you can specify
17731@option{-Xlinker -Map=output.map} rather than
17732@option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
17733this syntax for command-line options.
17734
17735@item -Wl,@var{option}
17736@opindex Wl
17737Pass @var{option} as an option to the linker. If @var{option} contains
17738commas, it is split into multiple options at the commas. You can use this
17739syntax to pass an argument to the option.
17740For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
17741linker. When using the GNU linker, you can also get the same effect with
17742@option{-Wl,-Map=output.map}.
17743
17744@item -u @var{symbol}
17745@opindex u
17746Pretend the symbol @var{symbol} is undefined, to force linking of
17747library modules to define it. You can use @option{-u} multiple times with
17748different symbols to force loading of additional library modules.
17749
17750@item -z @var{keyword}
17751@opindex z
17752@option{-z} is passed directly on to the linker along with the keyword
17753@var{keyword}. See the section in the documentation of your linker for
17754permitted values and their meanings.
17755@end table
17756
17757@node Directory Options
17758@section Options for Directory Search
17759@cindex directory options
17760@cindex options, directory search
17761@cindex search path
17762
17763These options specify directories to search for header files, for
17764libraries and for parts of the compiler:
17765
17766@table @gcctabopt
17767@include cppdiropts.texi
17768
17769@item -iplugindir=@var{dir}
17770@opindex iplugindir=
17771Set the directory to search for plugins that are passed
17772by @option{-fplugin=@var{name}} instead of
17773@option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
17774to be used by the user, but only passed by the driver.
17775
17776@item -L@var{dir}
17777@opindex L
17778Add directory @var{dir} to the list of directories to be searched
17779for @option{-l}.
17780
17781@item -B@var{prefix}
17782@opindex B
17783This option specifies where to find the executables, libraries,
17784include files, and data files of the compiler itself.
17785
17786The compiler driver program runs one or more of the subprograms
17787@command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
17788@var{prefix} as a prefix for each program it tries to run, both with and
17789without @samp{@var{machine}/@var{version}/} for the corresponding target
17790machine and compiler version.
17791
17792For each subprogram to be run, the compiler driver first tries the
17793@option{-B} prefix, if any. If that name is not found, or if @option{-B}
17794is not specified, the driver tries two standard prefixes,
17795@file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
17796those results in a file name that is found, the unmodified program
17797name is searched for using the directories specified in your
17798@env{PATH} environment variable.
17799
17800The compiler checks to see if the path provided by @option{-B}
17801refers to a directory, and if necessary it adds a directory
17802separator character at the end of the path.
17803
17804@option{-B} prefixes that effectively specify directory names also apply
17805to libraries in the linker, because the compiler translates these
17806options into @option{-L} options for the linker. They also apply to
17807include files in the preprocessor, because the compiler translates these
17808options into @option{-isystem} options for the preprocessor. In this case,
17809the compiler appends @samp{include} to the prefix.
17810
17811The runtime support file @file{libgcc.a} can also be searched for using
17812the @option{-B} prefix, if needed. If it is not found there, the two
17813standard prefixes above are tried, and that is all. The file is left
17814out of the link if it is not found by those means.
17815
17816Another way to specify a prefix much like the @option{-B} prefix is to use
17817the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
17818Variables}.
17819
17820As a special kludge, if the path provided by @option{-B} is
17821@file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
178229, then it is replaced by @file{[dir/]include}. This is to help
17823with boot-strapping the compiler.
17824
17825@item -no-canonical-prefixes
17826@opindex no-canonical-prefixes
17827Do not expand any symbolic links, resolve references to @samp{/../}
17828or @samp{/./}, or make the path absolute when generating a relative
17829prefix.
17830
17831@item --sysroot=@var{dir}
17832@opindex sysroot
17833Use @var{dir} as the logical root directory for headers and libraries.
17834For example, if the compiler normally searches for headers in
17835@file{/usr/include} and libraries in @file{/usr/lib}, it instead
17836searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
17837
17838If you use both this option and the @option{-isysroot} option, then
17839the @option{--sysroot} option applies to libraries, but the
17840@option{-isysroot} option applies to header files.
17841
17842The GNU linker (beginning with version 2.16) has the necessary support
17843for this option. If your linker does not support this option, the
17844header file aspect of @option{--sysroot} still works, but the
17845library aspect does not.
17846
17847@item --no-sysroot-suffix
17848@opindex no-sysroot-suffix
17849For some targets, a suffix is added to the root directory specified
17850with @option{--sysroot}, depending on the other options used, so that
17851headers may for example be found in
17852@file{@var{dir}/@var{suffix}/usr/include} instead of
17853@file{@var{dir}/usr/include}. This option disables the addition of
17854such a suffix.
17855
17856@end table
17857
17858@node Code Gen Options
17859@section Options for Code Generation Conventions
17860@cindex code generation conventions
17861@cindex options, code generation
17862@cindex run-time options
17863
17864These machine-independent options control the interface conventions
17865used in code generation.
17866
17867Most of them have both positive and negative forms; the negative form
17868of @option{-ffoo} is @option{-fno-foo}. In the table below, only
17869one of the forms is listed---the one that is not the default. You
17870can figure out the other form by either removing @samp{no-} or adding
17871it.
17872
17873@table @gcctabopt
17874@item -fstack-reuse=@var{reuse-level}
17875@opindex fstack_reuse
17876This option controls stack space reuse for user declared local/auto variables
17877and compiler generated temporaries. @var{reuse_level} can be @samp{all},
17878@samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
17879local variables and temporaries, @samp{named_vars} enables the reuse only for
17880user defined local variables with names, and @samp{none} disables stack reuse
17881completely. The default value is @samp{all}. The option is needed when the
17882program extends the lifetime of a scoped local variable or a compiler generated
17883temporary beyond the end point defined by the language. When a lifetime of
17884a variable ends, and if the variable lives in memory, the optimizing compiler
17885has the freedom to reuse its stack space with other temporaries or scoped
17886local variables whose live range does not overlap with it. Legacy code extending
17887local lifetime is likely to break with the stack reuse optimization.
17888
17889For example,
17890
17891@smallexample
17892 int *p;
17893 @{
17894 int local1;
17895
17896 p = &local1;
17897 local1 = 10;
17898 ....
17899 @}
17900 @{
17901 int local2;
17902 local2 = 20;
17903 ...
17904 @}
17905
17906 if (*p == 10) // out of scope use of local1
17907 @{
17908
17909 @}
17910@end smallexample
17911
17912Another example:
17913@smallexample
17914
17915 struct A
17916 @{
17917 A(int k) : i(k), j(k) @{ @}
17918 int i;
17919 int j;
17920 @};
17921
17922 A *ap;
17923
17924 void foo(const A& ar)
17925 @{
17926 ap = &ar;
17927 @}
17928
17929 void bar()
17930 @{
17931 foo(A(10)); // temp object's lifetime ends when foo returns
17932
17933 @{
17934 A a(20);
17935 ....
17936 @}
17937 ap->i+= 10; // ap references out of scope temp whose space
17938 // is reused with a. What is the value of ap->i?
17939 @}
17940
17941@end smallexample
17942
17943The lifetime of a compiler generated temporary is well defined by the C++
17944standard. When a lifetime of a temporary ends, and if the temporary lives
17945in memory, the optimizing compiler has the freedom to reuse its stack
17946space with other temporaries or scoped local variables whose live range
17947does not overlap with it. However some of the legacy code relies on
17948the behavior of older compilers in which temporaries' stack space is
17949not reused, the aggressive stack reuse can lead to runtime errors. This
17950option is used to control the temporary stack reuse optimization.
17951
17952@item -ftrapv
17953@opindex ftrapv
17954This option generates traps for signed overflow on addition, subtraction,
17955multiplication operations.
17956The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
17957@option{-ftrapv} @option{-fwrapv} on the command-line results in
17958@option{-fwrapv} being effective. Note that only active options override, so
17959using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
17960results in @option{-ftrapv} being effective.
17961
17962@item -fwrapv
17963@opindex fwrapv
17964This option instructs the compiler to assume that signed arithmetic
17965overflow of addition, subtraction and multiplication wraps around
17966using twos-complement representation. This flag enables some optimizations
17967and disables others.
17968The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
17969@option{-ftrapv} @option{-fwrapv} on the command-line results in
17970@option{-fwrapv} being effective. Note that only active options override, so
17971using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
17972results in @option{-ftrapv} being effective.
17973
17974@item -fwrapv-pointer
17975@opindex fwrapv-pointer
17976This option instructs the compiler to assume that pointer arithmetic
17977overflow on addition and subtraction wraps around using twos-complement
17978representation. This flag disables some optimizations which assume
17979pointer overflow is invalid.
17980
17981@item -fstrict-overflow
17982@opindex fstrict-overflow
17983This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
17984negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
17985
17986@item -fexceptions
17987@opindex fexceptions
17988Enable exception handling. Generates extra code needed to propagate
17989exceptions. For some targets, this implies GCC generates frame
17990unwind information for all functions, which can produce significant data
17991size overhead, although it does not affect execution. If you do not
17992specify this option, GCC enables it by default for languages like
17993C++ that normally require exception handling, and disables it for
17994languages like C that do not normally require it. However, you may need
17995to enable this option when compiling C code that needs to interoperate
17996properly with exception handlers written in C++. You may also wish to
17997disable this option if you are compiling older C++ programs that don't
17998use exception handling.
17999
18000@item -fnon-call-exceptions
18001@opindex fnon-call-exceptions
18002Generate code that allows trapping instructions to throw exceptions.
18003Note that this requires platform-specific runtime support that does
18004not exist everywhere. Moreover, it only allows @emph{trapping}
18005instructions to throw exceptions, i.e.@: memory references or floating-point
18006instructions. It does not allow exceptions to be thrown from
18007arbitrary signal handlers such as @code{SIGALRM}. This enables
18008@option{-fexceptions}.
18009
18010@item -fdelete-dead-exceptions
18011@opindex fdelete-dead-exceptions
18012Consider that instructions that may throw exceptions but don't otherwise
18013contribute to the execution of the program can be optimized away.
18014This does not affect calls to functions except those with the
18015@code{pure} or @code{const} attributes.
18016This option is enabled by default for the Ada and C++ compilers, as permitted by
18017the language specifications.
18018Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
18019
18020@item -funwind-tables
18021@opindex funwind-tables
18022Similar to @option{-fexceptions}, except that it just generates any needed
18023static data, but does not affect the generated code in any other way.
18024You normally do not need to enable this option; instead, a language processor
18025that needs this handling enables it on your behalf.
18026
18027@item -fasynchronous-unwind-tables
18028@opindex fasynchronous-unwind-tables
18029Generate unwind table in DWARF format, if supported by target machine. The
18030table is exact at each instruction boundary, so it can be used for stack
18031unwinding from asynchronous events (such as debugger or garbage collector).
18032
18033@item -fno-gnu-unique
18034@opindex fno-gnu-unique
18035@opindex fgnu-unique
18036On systems with recent GNU assembler and C library, the C++ compiler
18037uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
18038of template static data members and static local variables in inline
18039functions are unique even in the presence of @code{RTLD_LOCAL}; this
18040is necessary to avoid problems with a library used by two different
18041@code{RTLD_LOCAL} plugins depending on a definition in one of them and
18042therefore disagreeing with the other one about the binding of the
18043symbol. But this causes @code{dlclose} to be ignored for affected
18044DSOs; if your program relies on reinitialization of a DSO via
18045@code{dlclose} and @code{dlopen}, you can use
18046@option{-fno-gnu-unique}.
18047
18048@item -fpcc-struct-return
18049@opindex fpcc-struct-return
18050Return ``short'' @code{struct} and @code{union} values in memory like
18051longer ones, rather than in registers. This convention is less
18052efficient, but it has the advantage of allowing intercallability between
18053GCC-compiled files and files compiled with other compilers, particularly
18054the Portable C Compiler (pcc).
18055
18056The precise convention for returning structures in memory depends
18057on the target configuration macros.
18058
18059Short structures and unions are those whose size and alignment match
18060that of some integer type.
18061
18062@strong{Warning:} code compiled with the @option{-fpcc-struct-return}
18063switch is not binary compatible with code compiled with the
18064@option{-freg-struct-return} switch.
18065Use it to conform to a non-default application binary interface.
18066
18067@item -freg-struct-return
18068@opindex freg-struct-return
18069Return @code{struct} and @code{union} values in registers when possible.
18070This is more efficient for small structures than
18071@option{-fpcc-struct-return}.
18072
18073If you specify neither @option{-fpcc-struct-return} nor
18074@option{-freg-struct-return}, GCC defaults to whichever convention is
18075standard for the target. If there is no standard convention, GCC
18076defaults to @option{-fpcc-struct-return}, except on targets where GCC is
18077the principal compiler. In those cases, we can choose the standard, and
18078we chose the more efficient register return alternative.
18079
18080@strong{Warning:} code compiled with the @option{-freg-struct-return}
18081switch is not binary compatible with code compiled with the
18082@option{-fpcc-struct-return} switch.
18083Use it to conform to a non-default application binary interface.
18084
18085@item -fshort-enums
18086@opindex fshort-enums
18087Allocate to an @code{enum} type only as many bytes as it needs for the
18088declared range of possible values. Specifically, the @code{enum} type
18089is equivalent to the smallest integer type that has enough room.
18090
18091@strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
18092code that is not binary compatible with code generated without that switch.
18093Use it to conform to a non-default application binary interface.
18094
18095@item -fshort-wchar
18096@opindex fshort-wchar
18097Override the underlying type for @code{wchar_t} to be @code{short
18098unsigned int} instead of the default for the target. This option is
18099useful for building programs to run under WINE@.
18100
18101@strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
18102code that is not binary compatible with code generated without that switch.
18103Use it to conform to a non-default application binary interface.
18104
18105@item -fcommon
18106@opindex fcommon
18107@opindex fno-common
18108@cindex tentative definitions
18109In C code, this option controls the placement of global variables
18110defined without an initializer, known as @dfn{tentative definitions}
18111in the C standard. Tentative definitions are distinct from declarations
18112of a variable with the @code{extern} keyword, which do not allocate storage.
18113
18114The default is @option{-fno-common}, which specifies that the compiler places
18115uninitialized global variables in the BSS section of the object file.
18116This inhibits the merging of tentative definitions by the linker so you get a
18117multiple-definition error if the same variable is accidentally defined in more
18118than one compilation unit.
18119
18120The @option{-fcommon} places uninitialized global variables in a common block.
18121This allows the linker to resolve all tentative definitions of the same variable
18122in different compilation units to the same object, or to a non-tentative
18123definition. This behavior is inconsistent with C++, and on many targets implies
18124a speed and code size penalty on global variable references. It is mainly
18125useful to enable legacy code to link without errors.
18126
18127@item -fno-ident
18128@opindex fno-ident
18129@opindex fident
18130Ignore the @code{#ident} directive.
18131
18132@item -finhibit-size-directive
18133@opindex finhibit-size-directive
18134Don't output a @code{.size} assembler directive, or anything else that
18135would cause trouble if the function is split in the middle, and the
18136two halves are placed at locations far apart in memory. This option is
18137used when compiling @file{crtstuff.c}; you should not need to use it
18138for anything else.
18139
18140@item -fverbose-asm
18141@opindex fverbose-asm
18142Put extra commentary information in the generated assembly code to
18143make it more readable. This option is generally only of use to those
18144who actually need to read the generated assembly code (perhaps while
18145debugging the compiler itself).
18146
18147@option{-fno-verbose-asm}, the default, causes the
18148extra information to be omitted and is useful when comparing two assembler
18149files.
18150
18151The added comments include:
18152
18153@itemize @bullet
18154
18155@item
18156information on the compiler version and command-line options,
18157
18158@item
18159the source code lines associated with the assembly instructions,
18160in the form FILENAME:LINENUMBER:CONTENT OF LINE,
18161
18162@item
18163hints on which high-level expressions correspond to
18164the various assembly instruction operands.
18165
18166@end itemize
18167
18168For example, given this C source file:
18169
18170@smallexample
18171int test (int n)
18172@{
18173 int i;
18174 int total = 0;
18175
18176 for (i = 0; i < n; i++)
18177 total += i * i;
18178
18179 return total;
18180@}
18181@end smallexample
18182
18183compiling to (x86_64) assembly via @option{-S} and emitting the result
18184direct to stdout via @option{-o} @option{-}
18185
18186@smallexample
18187gcc -S test.c -fverbose-asm -Os -o -
18188@end smallexample
18189
18190gives output similar to this:
18191
18192@smallexample
18193 .file "test.c"
18194# GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
18195 [...snip...]
18196# options passed:
18197 [...snip...]
18198
18199 .text
18200 .globl test
18201 .type test, @@function
18202test:
18203.LFB0:
18204 .cfi_startproc
18205# test.c:4: int total = 0;
18206 xorl %eax, %eax # <retval>
18207# test.c:6: for (i = 0; i < n; i++)
18208 xorl %edx, %edx # i
18209.L2:
18210# test.c:6: for (i = 0; i < n; i++)
18211 cmpl %edi, %edx # n, i
18212 jge .L5 #,
18213# test.c:7: total += i * i;
18214 movl %edx, %ecx # i, tmp92
18215 imull %edx, %ecx # i, tmp92
18216# test.c:6: for (i = 0; i < n; i++)
18217 incl %edx # i
18218# test.c:7: total += i * i;
18219 addl %ecx, %eax # tmp92, <retval>
18220 jmp .L2 #
18221.L5:
18222# test.c:10: @}
18223 ret
18224 .cfi_endproc
18225.LFE0:
18226 .size test, .-test
18227 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
18228 .section .note.GNU-stack,"",@@progbits
18229@end smallexample
18230
18231The comments are intended for humans rather than machines and hence the
18232precise format of the comments is subject to change.
18233
18234@item -frecord-gcc-switches
18235@opindex frecord-gcc-switches
18236This switch causes the command line used to invoke the
18237compiler to be recorded into the object file that is being created.
18238This switch is only implemented on some targets and the exact format
18239of the recording is target and binary file format dependent, but it
18240usually takes the form of a section containing ASCII text. This
18241switch is related to the @option{-fverbose-asm} switch, but that
18242switch only records information in the assembler output file as
18243comments, so it never reaches the object file.
18244See also @option{-grecord-gcc-switches} for another
18245way of storing compiler options into the object file.
18246
18247@item -fpic
18248@opindex fpic
18249@cindex global offset table
18250@cindex PIC
18251Generate position-independent code (PIC) suitable for use in a shared
18252library, if supported for the target machine. Such code accesses all
18253constant addresses through a global offset table (GOT)@. The dynamic
18254loader resolves the GOT entries when the program starts (the dynamic
18255loader is not part of GCC; it is part of the operating system). If
18256the GOT size for the linked executable exceeds a machine-specific
18257maximum size, you get an error message from the linker indicating that
18258@option{-fpic} does not work; in that case, recompile with @option{-fPIC}
18259instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
18260on the m68k and RS/6000. The x86 has no such limit.)
18261
18262Position-independent code requires special support, and therefore works
18263only on certain machines. For the x86, GCC supports PIC for System V
18264but not for the Sun 386i. Code generated for the IBM RS/6000 is always
18265position-independent.
18266
18267When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18268are defined to 1.
18269
18270@item -fPIC
18271@opindex fPIC
18272If supported for the target machine, emit position-independent code,
18273suitable for dynamic linking and avoiding any limit on the size of the
18274global offset table. This option makes a difference on AArch64, m68k,
18275PowerPC and SPARC@.
18276
18277Position-independent code requires special support, and therefore works
18278only on certain machines.
18279
18280When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18281are defined to 2.
18282
18283@item -fpie
18284@itemx -fPIE
18285@opindex fpie
18286@opindex fPIE
18287These options are similar to @option{-fpic} and @option{-fPIC}, but the
18288generated position-independent code can be only linked into executables.
18289Usually these options are used to compile code that will be linked using
18290the @option{-pie} GCC option.
18291
18292@option{-fpie} and @option{-fPIE} both define the macros
18293@code{__pie__} and @code{__PIE__}. The macros have the value 1
18294for @option{-fpie} and 2 for @option{-fPIE}.
18295
18296@item -fno-plt
18297@opindex fno-plt
18298@opindex fplt
18299Do not use the PLT for external function calls in position-independent code.
18300Instead, load the callee address at call sites from the GOT and branch to it.
18301This leads to more efficient code by eliminating PLT stubs and exposing
18302GOT loads to optimizations. On architectures such as 32-bit x86 where
18303PLT stubs expect the GOT pointer in a specific register, this gives more
18304register allocation freedom to the compiler.
18305Lazy binding requires use of the PLT;
18306with @option{-fno-plt} all external symbols are resolved at load time.
18307
18308Alternatively, the function attribute @code{noplt} can be used to avoid calls
18309through the PLT for specific external functions.
18310
18311In position-dependent code, a few targets also convert calls to
18312functions that are marked to not use the PLT to use the GOT instead.
18313
18314@item -fno-jump-tables
18315@opindex fno-jump-tables
18316@opindex fjump-tables
18317Do not use jump tables for switch statements even where it would be
18318more efficient than other code generation strategies. This option is
18319of use in conjunction with @option{-fpic} or @option{-fPIC} for
18320building code that forms part of a dynamic linker and cannot
18321reference the address of a jump table. On some targets, jump tables
18322do not require a GOT and this option is not needed.
18323
18324@item -fno-bit-tests
18325@opindex fno-bit-tests
18326@opindex fbit-tests
18327Do not use bit tests for switch statements even where it would be
18328more efficient than other code generation strategies.
18329
18330@item -ffixed-@var{reg}
18331@opindex ffixed
18332Treat the register named @var{reg} as a fixed register; generated code
18333should never refer to it (except perhaps as a stack pointer, frame
18334pointer or in some other fixed role).
18335
18336@var{reg} must be the name of a register. The register names accepted
18337are machine-specific and are defined in the @code{REGISTER_NAMES}
18338macro in the machine description macro file.
18339
18340This flag does not have a negative form, because it specifies a
18341three-way choice.
18342
18343@item -fcall-used-@var{reg}
18344@opindex fcall-used
18345Treat the register named @var{reg} as an allocable register that is
18346clobbered by function calls. It may be allocated for temporaries or
18347variables that do not live across a call. Functions compiled this way
18348do not save and restore the register @var{reg}.
18349
18350It is an error to use this flag with the frame pointer or stack pointer.
18351Use of this flag for other registers that have fixed pervasive roles in
18352the machine's execution model produces disastrous results.
18353
18354This flag does not have a negative form, because it specifies a
18355three-way choice.
18356
18357@item -fcall-saved-@var{reg}
18358@opindex fcall-saved
18359Treat the register named @var{reg} as an allocable register saved by
18360functions. It may be allocated even for temporaries or variables that
18361live across a call. Functions compiled this way save and restore
18362the register @var{reg} if they use it.
18363
18364It is an error to use this flag with the frame pointer or stack pointer.
18365Use of this flag for other registers that have fixed pervasive roles in
18366the machine's execution model produces disastrous results.
18367
18368A different sort of disaster results from the use of this flag for
18369a register in which function values may be returned.
18370
18371This flag does not have a negative form, because it specifies a
18372three-way choice.
18373
18374@item -fpack-struct[=@var{n}]
18375@opindex fpack-struct
18376Without a value specified, pack all structure members together without
18377holes. When a value is specified (which must be a small power of two), pack
18378structure members according to this value, representing the maximum
18379alignment (that is, objects with default alignment requirements larger than
18380this are output potentially unaligned at the next fitting location.
18381
18382@strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
18383code that is not binary compatible with code generated without that switch.
18384Additionally, it makes the code suboptimal.
18385Use it to conform to a non-default application binary interface.
18386
18387@item -fleading-underscore
18388@opindex fleading-underscore
18389This option and its counterpart, @option{-fno-leading-underscore}, forcibly
18390change the way C symbols are represented in the object file. One use
18391is to help link with legacy assembly code.
18392
18393@strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
18394generate code that is not binary compatible with code generated without that
18395switch. Use it to conform to a non-default application binary interface.
18396Not all targets provide complete support for this switch.
18397
18398@item -ftls-model=@var{model}
18399@opindex ftls-model
18400Alter the thread-local storage model to be used (@pxref{Thread-Local}).
18401The @var{model} argument should be one of @samp{global-dynamic},
18402@samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
18403Note that the choice is subject to optimization: the compiler may use
18404a more efficient model for symbols not visible outside of the translation
18405unit, or if @option{-fpic} is not given on the command line.
18406
18407The default without @option{-fpic} is @samp{initial-exec}; with
18408@option{-fpic} the default is @samp{global-dynamic}.
18409
18410@item -ftrampolines
18411@opindex ftrampolines
18412For targets that normally need trampolines for nested functions, always
18413generate them instead of using descriptors. Otherwise, for targets that
18414do not need them, like for example HP-PA or IA-64, do nothing.
18415
18416A trampoline is a small piece of code that is created at run time on the
18417stack when the address of a nested function is taken, and is used to call
18418the nested function indirectly. Therefore, it requires the stack to be
18419made executable in order for the program to work properly.
18420
18421@option{-fno-trampolines} is enabled by default on a language by language
18422basis to let the compiler avoid generating them, if it computes that this
18423is safe, and replace them with descriptors. Descriptors are made up of data
18424only, but the generated code must be prepared to deal with them. As of this
18425writing, @option{-fno-trampolines} is enabled by default only for Ada.
18426
18427Moreover, code compiled with @option{-ftrampolines} and code compiled with
18428@option{-fno-trampolines} are not binary compatible if nested functions are
18429present. This option must therefore be used on a program-wide basis and be
18430manipulated with extreme care.
18431
18432For languages other than Ada, the @code{-ftrampolines} and
18433@code{-fno-trampolines} options currently have no effect, and
18434trampolines are always generated on platforms that need them
18435for nested functions.
18436
18437@item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
18438@opindex fvisibility
18439Set the default ELF image symbol visibility to the specified option---all
18440symbols are marked with this unless overridden within the code.
18441Using this feature can very substantially improve linking and
18442load times of shared object libraries, produce more optimized
18443code, provide near-perfect API export and prevent symbol clashes.
18444It is @strong{strongly} recommended that you use this in any shared objects
18445you distribute.
18446
18447Despite the nomenclature, @samp{default} always means public; i.e.,
18448available to be linked against from outside the shared object.
18449@samp{protected} and @samp{internal} are pretty useless in real-world
18450usage so the only other commonly used option is @samp{hidden}.
18451The default if @option{-fvisibility} isn't specified is
18452@samp{default}, i.e., make every symbol public.
18453
18454A good explanation of the benefits offered by ensuring ELF
18455symbols have the correct visibility is given by ``How To Write
18456Shared Libraries'' by Ulrich Drepper (which can be found at
18457@w{@uref{https://www.akkadia.org/drepper/}})---however a superior
18458solution made possible by this option to marking things hidden when
18459the default is public is to make the default hidden and mark things
18460public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
18461and @code{__attribute__ ((visibility("default")))} instead of
18462@code{__declspec(dllexport)} you get almost identical semantics with
18463identical syntax. This is a great boon to those working with
18464cross-platform projects.
18465
18466For those adding visibility support to existing code, you may find
18467@code{#pragma GCC visibility} of use. This works by you enclosing
18468the declarations you wish to set visibility for with (for example)
18469@code{#pragma GCC visibility push(hidden)} and
18470@code{#pragma GCC visibility pop}.
18471Bear in mind that symbol visibility should be viewed @strong{as
18472part of the API interface contract} and thus all new code should
18473always specify visibility when it is not the default; i.e., declarations
18474only for use within the local DSO should @strong{always} be marked explicitly
18475as hidden as so to avoid PLT indirection overheads---making this
18476abundantly clear also aids readability and self-documentation of the code.
18477Note that due to ISO C++ specification requirements, @code{operator new} and
18478@code{operator delete} must always be of default visibility.
18479
18480Be aware that headers from outside your project, in particular system
18481headers and headers from any other library you use, may not be
18482expecting to be compiled with visibility other than the default. You
18483may need to explicitly say @code{#pragma GCC visibility push(default)}
18484before including any such headers.
18485
18486@code{extern} declarations are not affected by @option{-fvisibility}, so
18487a lot of code can be recompiled with @option{-fvisibility=hidden} with
18488no modifications. However, this means that calls to @code{extern}
18489functions with no explicit visibility use the PLT, so it is more
18490effective to use @code{__attribute ((visibility))} and/or
18491@code{#pragma GCC visibility} to tell the compiler which @code{extern}
18492declarations should be treated as hidden.
18493
18494Note that @option{-fvisibility} does affect C++ vague linkage
18495entities. This means that, for instance, an exception class that is
18496be thrown between DSOs must be explicitly marked with default
18497visibility so that the @samp{type_info} nodes are unified between
18498the DSOs.
18499
18500An overview of these techniques, their benefits and how to use them
18501is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
18502
18503@item -fstrict-volatile-bitfields
18504@opindex fstrict-volatile-bitfields
18505This option should be used if accesses to volatile bit-fields (or other
18506structure fields, although the compiler usually honors those types
18507anyway) should use a single access of the width of the
18508field's type, aligned to a natural alignment if possible. For
18509example, targets with memory-mapped peripheral registers might require
18510all such accesses to be 16 bits wide; with this flag you can
18511declare all peripheral bit-fields as @code{unsigned short} (assuming short
18512is 16 bits on these targets) to force GCC to use 16-bit accesses
18513instead of, perhaps, a more efficient 32-bit access.
18514
18515If this option is disabled, the compiler uses the most efficient
18516instruction. In the previous example, that might be a 32-bit load
18517instruction, even though that accesses bytes that do not contain
18518any portion of the bit-field, or memory-mapped registers unrelated to
18519the one being updated.
18520
18521In some cases, such as when the @code{packed} attribute is applied to a
18522structure field, it may not be possible to access the field with a single
18523read or write that is correctly aligned for the target machine. In this
18524case GCC falls back to generating multiple accesses rather than code that
18525will fault or truncate the result at run time.
18526
18527Note: Due to restrictions of the C/C++11 memory model, write accesses are
18528not allowed to touch non bit-field members. It is therefore recommended
18529to define all bits of the field's type as bit-field members.
18530
18531The default value of this option is determined by the application binary
18532interface for the target processor.
18533
18534@item -fsync-libcalls
18535@opindex fsync-libcalls
18536This option controls whether any out-of-line instance of the @code{__sync}
18537family of functions may be used to implement the C++11 @code{__atomic}
18538family of functions.
18539
18540The default value of this option is enabled, thus the only useful form
18541of the option is @option{-fno-sync-libcalls}. This option is used in
18542the implementation of the @file{libatomic} runtime library.
18543
18544@end table
18545
18546@node Developer Options
18547@section GCC Developer Options
18548@cindex developer options
18549@cindex debugging GCC
18550@cindex debug dump options
18551@cindex dump options
18552@cindex compilation statistics
18553
18554This section describes command-line options that are primarily of
18555interest to GCC developers, including options to support compiler
18556testing and investigation of compiler bugs and compile-time
18557performance problems. This includes options that produce debug dumps
18558at various points in the compilation; that print statistics such as
18559memory use and execution time; and that print information about GCC's
18560configuration, such as where it searches for libraries. You should
18561rarely need to use any of these options for ordinary compilation and
18562linking tasks.
18563
18564Many developer options that cause GCC to dump output to a file take an
18565optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
18566or @samp{-} to dump to standard output, and @samp{stderr} for standard
18567error.
18568
18569If @samp{=@var{filename}} is omitted, a default dump file name is
18570constructed by concatenating the base dump file name, a pass number,
18571phase letter, and pass name. The base dump file name is the name of
18572output file produced by the compiler if explicitly specified and not
18573an executable; otherwise it is the source file name.
18574The pass number is determined by the order passes are registered with
18575the compiler's pass manager.
18576This is generally the same as the order of execution, but passes
18577registered by plugins, target-specific passes, or passes that are
18578otherwise registered late are numbered higher than the pass named
18579@samp{final}, even if they are executed earlier. The phase letter is
18580one of @samp{i} (inter-procedural analysis), @samp{l}
18581(language-specific), @samp{r} (RTL), or @samp{t} (tree).
18582The files are created in the directory of the output file.
18583
18584@table @gcctabopt
18585
18586@item -fcallgraph-info
18587@itemx -fcallgraph-info=@var{MARKERS}
18588@opindex fcallgraph-info
18589Makes the compiler output callgraph information for the program, on a
18590per-object-file basis. The information is generated in the common VCG
18591format. It can be decorated with additional, per-node and/or per-edge
18592information, if a list of comma-separated markers is additionally
18593specified. When the @code{su} marker is specified, the callgraph is
18594decorated with stack usage information; it is equivalent to
18595@option{-fstack-usage}. When the @code{da} marker is specified, the
18596callgraph is decorated with information about dynamically allocated
18597objects.
18598
18599When compiling with @option{-flto}, no callgraph information is output
18600along with the object file. At LTO link time, @option{-fcallgraph-info}
18601may generate multiple callgraph information files next to intermediate
18602LTO output files.
18603
18604@item -d@var{letters}
18605@itemx -fdump-rtl-@var{pass}
18606@itemx -fdump-rtl-@var{pass}=@var{filename}
18607@opindex d
18608@opindex fdump-rtl-@var{pass}
18609Says to make debugging dumps during compilation at times specified by
18610@var{letters}. This is used for debugging the RTL-based passes of the
18611compiler.
18612
18613Some @option{-d@var{letters}} switches have different meaning when
18614@option{-E} is used for preprocessing. @xref{Preprocessor Options},
18615for information about preprocessor-specific dump options.
18616
18617Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
18618@option{-d} option @var{letters}. Here are the possible
18619letters for use in @var{pass} and @var{letters}, and their meanings:
18620
18621@table @gcctabopt
18622
18623@item -fdump-rtl-alignments
18624@opindex fdump-rtl-alignments
18625Dump after branch alignments have been computed.
18626
18627@item -fdump-rtl-asmcons
18628@opindex fdump-rtl-asmcons
18629Dump after fixing rtl statements that have unsatisfied in/out constraints.
18630
18631@item -fdump-rtl-auto_inc_dec
18632@opindex fdump-rtl-auto_inc_dec
18633Dump after auto-inc-dec discovery. This pass is only run on
18634architectures that have auto inc or auto dec instructions.
18635
18636@item -fdump-rtl-barriers
18637@opindex fdump-rtl-barriers
18638Dump after cleaning up the barrier instructions.
18639
18640@item -fdump-rtl-bbpart
18641@opindex fdump-rtl-bbpart
18642Dump after partitioning hot and cold basic blocks.
18643
18644@item -fdump-rtl-bbro
18645@opindex fdump-rtl-bbro
18646Dump after block reordering.
18647
18648@item -fdump-rtl-btl1
18649@itemx -fdump-rtl-btl2
18650@opindex fdump-rtl-btl2
18651@opindex fdump-rtl-btl2
18652@option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
18653after the two branch
18654target load optimization passes.
18655
18656@item -fdump-rtl-bypass
18657@opindex fdump-rtl-bypass
18658Dump after jump bypassing and control flow optimizations.
18659
18660@item -fdump-rtl-combine
18661@opindex fdump-rtl-combine
18662Dump after the RTL instruction combination pass.
18663
18664@item -fdump-rtl-compgotos
18665@opindex fdump-rtl-compgotos
18666Dump after duplicating the computed gotos.
18667
18668@item -fdump-rtl-ce1
18669@itemx -fdump-rtl-ce2
18670@itemx -fdump-rtl-ce3
18671@opindex fdump-rtl-ce1
18672@opindex fdump-rtl-ce2
18673@opindex fdump-rtl-ce3
18674@option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
18675@option{-fdump-rtl-ce3} enable dumping after the three
18676if conversion passes.
18677
18678@item -fdump-rtl-cprop_hardreg
18679@opindex fdump-rtl-cprop_hardreg
18680Dump after hard register copy propagation.
18681
18682@item -fdump-rtl-csa
18683@opindex fdump-rtl-csa
18684Dump after combining stack adjustments.
18685
18686@item -fdump-rtl-cse1
18687@itemx -fdump-rtl-cse2
18688@opindex fdump-rtl-cse1
18689@opindex fdump-rtl-cse2
18690@option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
18691the two common subexpression elimination passes.
18692
18693@item -fdump-rtl-dce
18694@opindex fdump-rtl-dce
18695Dump after the standalone dead code elimination passes.
18696
18697@item -fdump-rtl-dbr
18698@opindex fdump-rtl-dbr
18699Dump after delayed branch scheduling.
18700
18701@item -fdump-rtl-dce1
18702@itemx -fdump-rtl-dce2
18703@opindex fdump-rtl-dce1
18704@opindex fdump-rtl-dce2
18705@option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
18706the two dead store elimination passes.
18707
18708@item -fdump-rtl-eh
18709@opindex fdump-rtl-eh
18710Dump after finalization of EH handling code.
18711
18712@item -fdump-rtl-eh_ranges
18713@opindex fdump-rtl-eh_ranges
18714Dump after conversion of EH handling range regions.
18715
18716@item -fdump-rtl-expand
18717@opindex fdump-rtl-expand
18718Dump after RTL generation.
18719
18720@item -fdump-rtl-fwprop1
18721@itemx -fdump-rtl-fwprop2
18722@opindex fdump-rtl-fwprop1
18723@opindex fdump-rtl-fwprop2
18724@option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
18725dumping after the two forward propagation passes.
18726
18727@item -fdump-rtl-gcse1
18728@itemx -fdump-rtl-gcse2
18729@opindex fdump-rtl-gcse1
18730@opindex fdump-rtl-gcse2
18731@option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
18732after global common subexpression elimination.
18733
18734@item -fdump-rtl-init-regs
18735@opindex fdump-rtl-init-regs
18736Dump after the initialization of the registers.
18737
18738@item -fdump-rtl-initvals
18739@opindex fdump-rtl-initvals
18740Dump after the computation of the initial value sets.
18741
18742@item -fdump-rtl-into_cfglayout
18743@opindex fdump-rtl-into_cfglayout
18744Dump after converting to cfglayout mode.
18745
18746@item -fdump-rtl-ira
18747@opindex fdump-rtl-ira
18748Dump after iterated register allocation.
18749
18750@item -fdump-rtl-jump
18751@opindex fdump-rtl-jump
18752Dump after the second jump optimization.
18753
18754@item -fdump-rtl-loop2
18755@opindex fdump-rtl-loop2
18756@option{-fdump-rtl-loop2} enables dumping after the rtl
18757loop optimization passes.
18758
18759@item -fdump-rtl-mach
18760@opindex fdump-rtl-mach
18761Dump after performing the machine dependent reorganization pass, if that
18762pass exists.
18763
18764@item -fdump-rtl-mode_sw
18765@opindex fdump-rtl-mode_sw
18766Dump after removing redundant mode switches.
18767
18768@item -fdump-rtl-rnreg
18769@opindex fdump-rtl-rnreg
18770Dump after register renumbering.
18771
18772@item -fdump-rtl-outof_cfglayout
18773@opindex fdump-rtl-outof_cfglayout
18774Dump after converting from cfglayout mode.
18775
18776@item -fdump-rtl-peephole2
18777@opindex fdump-rtl-peephole2
18778Dump after the peephole pass.
18779
18780@item -fdump-rtl-postreload
18781@opindex fdump-rtl-postreload
18782Dump after post-reload optimizations.
18783
18784@item -fdump-rtl-pro_and_epilogue
18785@opindex fdump-rtl-pro_and_epilogue
18786Dump after generating the function prologues and epilogues.
18787
18788@item -fdump-rtl-sched1
18789@itemx -fdump-rtl-sched2
18790@opindex fdump-rtl-sched1
18791@opindex fdump-rtl-sched2
18792@option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
18793after the basic block scheduling passes.
18794
18795@item -fdump-rtl-ree
18796@opindex fdump-rtl-ree
18797Dump after sign/zero extension elimination.
18798
18799@item -fdump-rtl-seqabstr
18800@opindex fdump-rtl-seqabstr
18801Dump after common sequence discovery.
18802
18803@item -fdump-rtl-shorten
18804@opindex fdump-rtl-shorten
18805Dump after shortening branches.
18806
18807@item -fdump-rtl-sibling
18808@opindex fdump-rtl-sibling
18809Dump after sibling call optimizations.
18810
18811@item -fdump-rtl-split1
18812@itemx -fdump-rtl-split2
18813@itemx -fdump-rtl-split3
18814@itemx -fdump-rtl-split4
18815@itemx -fdump-rtl-split5
18816@opindex fdump-rtl-split1
18817@opindex fdump-rtl-split2
18818@opindex fdump-rtl-split3
18819@opindex fdump-rtl-split4
18820@opindex fdump-rtl-split5
18821These options enable dumping after five rounds of
18822instruction splitting.
18823
18824@item -fdump-rtl-sms
18825@opindex fdump-rtl-sms
18826Dump after modulo scheduling. This pass is only run on some
18827architectures.
18828
18829@item -fdump-rtl-stack
18830@opindex fdump-rtl-stack
18831Dump after conversion from GCC's ``flat register file'' registers to the
18832x87's stack-like registers. This pass is only run on x86 variants.
18833
18834@item -fdump-rtl-subreg1
18835@itemx -fdump-rtl-subreg2
18836@opindex fdump-rtl-subreg1
18837@opindex fdump-rtl-subreg2
18838@option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
18839the two subreg expansion passes.
18840
18841@item -fdump-rtl-unshare
18842@opindex fdump-rtl-unshare
18843Dump after all rtl has been unshared.
18844
18845@item -fdump-rtl-vartrack
18846@opindex fdump-rtl-vartrack
18847Dump after variable tracking.
18848
18849@item -fdump-rtl-vregs
18850@opindex fdump-rtl-vregs
18851Dump after converting virtual registers to hard registers.
18852
18853@item -fdump-rtl-web
18854@opindex fdump-rtl-web
18855Dump after live range splitting.
18856
18857@item -fdump-rtl-regclass
18858@itemx -fdump-rtl-subregs_of_mode_init
18859@itemx -fdump-rtl-subregs_of_mode_finish
18860@itemx -fdump-rtl-dfinit
18861@itemx -fdump-rtl-dfinish
18862@opindex fdump-rtl-regclass
18863@opindex fdump-rtl-subregs_of_mode_init
18864@opindex fdump-rtl-subregs_of_mode_finish
18865@opindex fdump-rtl-dfinit
18866@opindex fdump-rtl-dfinish
18867These dumps are defined but always produce empty files.
18868
18869@item -da
18870@itemx -fdump-rtl-all
18871@opindex da
18872@opindex fdump-rtl-all
18873Produce all the dumps listed above.
18874
18875@item -dA
18876@opindex dA
18877Annotate the assembler output with miscellaneous debugging information.
18878
18879@item -dD
18880@opindex dD
18881Dump all macro definitions, at the end of preprocessing, in addition to
18882normal output.
18883
18884@item -dH
18885@opindex dH
18886Produce a core dump whenever an error occurs.
18887
18888@item -dp
18889@opindex dp
18890Annotate the assembler output with a comment indicating which
18891pattern and alternative is used. The length and cost of each instruction are
18892also printed.
18893
18894@item -dP
18895@opindex dP
18896Dump the RTL in the assembler output as a comment before each instruction.
18897Also turns on @option{-dp} annotation.
18898
18899@item -dx
18900@opindex dx
18901Just generate RTL for a function instead of compiling it. Usually used
18902with @option{-fdump-rtl-expand}.
18903@end table
18904
18905@item -fdump-debug
18906@opindex fdump-debug
18907Dump debugging information generated during the debug
18908generation phase.
18909
18910@item -fdump-earlydebug
18911@opindex fdump-earlydebug
18912Dump debugging information generated during the early debug
18913generation phase.
18914
18915@item -fdump-noaddr
18916@opindex fdump-noaddr
18917When doing debugging dumps, suppress address output. This makes it more
18918feasible to use diff on debugging dumps for compiler invocations with
18919different compiler binaries and/or different
18920text / bss / data / heap / stack / dso start locations.
18921
18922@item -freport-bug
18923@opindex freport-bug
18924Collect and dump debug information into a temporary file if an
18925internal compiler error (ICE) occurs.
18926
18927@item -fdump-unnumbered
18928@opindex fdump-unnumbered
18929When doing debugging dumps, suppress instruction numbers and address output.
18930This makes it more feasible to use diff on debugging dumps for compiler
18931invocations with different options, in particular with and without
18932@option{-g}.
18933
18934@item -fdump-unnumbered-links
18935@opindex fdump-unnumbered-links
18936When doing debugging dumps (see @option{-d} option above), suppress
18937instruction numbers for the links to the previous and next instructions
18938in a sequence.
18939
18940@item -fdump-ipa-@var{switch}
18941@itemx -fdump-ipa-@var{switch}-@var{options}
18942@opindex fdump-ipa
18943Control the dumping at various stages of inter-procedural analysis
18944language tree to a file. The file name is generated by appending a
18945switch specific suffix to the source file name, and the file is created
18946in the same directory as the output file. The following dumps are
18947possible:
18948
18949@table @samp
18950@item all
18951Enables all inter-procedural analysis dumps.
18952
18953@item cgraph
18954Dumps information about call-graph optimization, unused function removal,
18955and inlining decisions.
18956
18957@item inline
18958Dump after function inlining.
18959
18960@end table
18961
18962Additionally, the options @option{-optimized}, @option{-missed},
18963@option{-note}, and @option{-all} can be provided, with the same meaning
18964as for @option{-fopt-info}, defaulting to @option{-optimized}.
18965
18966For example, @option{-fdump-ipa-inline-optimized-missed} will emit
18967information on callsites that were inlined, along with callsites
18968that were not inlined.
18969
18970By default, the dump will contain messages about successful
18971optimizations (equivalent to @option{-optimized}) together with
18972low-level details about the analysis.
18973
18974@item -fdump-lang
18975@opindex fdump-lang
18976Dump language-specific information. The file name is made by appending
18977@file{.lang} to the source file name.
18978
18979@item -fdump-lang-all
18980@itemx -fdump-lang-@var{switch}
18981@itemx -fdump-lang-@var{switch}-@var{options}
18982@itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
18983@opindex fdump-lang-all
18984@opindex fdump-lang
18985Control the dumping of language-specific information. The @var{options}
18986and @var{filename} portions behave as described in the
18987@option{-fdump-tree} option. The following @var{switch} values are
18988accepted:
18989
18990@table @samp
18991@item all
18992
18993Enable all language-specific dumps.
18994
18995@item class
18996Dump class hierarchy information. Virtual table information is emitted
18997unless '@option{slim}' is specified. This option is applicable to C++ only.
18998
18999@item module
19000Dump module information. Options @option{lineno} (locations),
19001@option{graph} (reachability), @option{blocks} (clusters),
19002@option{uid} (serialization), @option{alias} (mergeable),
19003@option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
19004(macros) may provide additional information. This option is
19005applicable to C++ only.
19006
19007@item raw
19008Dump the raw internal tree data. This option is applicable to C++ only.
19009
19010@end table
19011
19012@item -fdump-passes
19013@opindex fdump-passes
19014Print on @file{stderr} the list of optimization passes that are turned
19015on and off by the current command-line options.
19016
19017@item -fdump-statistics-@var{option}
19018@opindex fdump-statistics
19019Enable and control dumping of pass statistics in a separate file. The
19020file name is generated by appending a suffix ending in
19021@samp{.statistics} to the source file name, and the file is created in
19022the same directory as the output file. If the @samp{-@var{option}}
19023form is used, @samp{-stats} causes counters to be summed over the
19024whole compilation unit while @samp{-details} dumps every event as
19025the passes generate them. The default with no option is to sum
19026counters for each function compiled.
19027
19028@item -fdump-tree-all
19029@itemx -fdump-tree-@var{switch}
19030@itemx -fdump-tree-@var{switch}-@var{options}
19031@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
19032@opindex fdump-tree-all
19033@opindex fdump-tree
19034Control the dumping at various stages of processing the intermediate
19035language tree to a file. If the @samp{-@var{options}}
19036form is used, @var{options} is a list of @samp{-} separated options
19037which control the details of the dump. Not all options are applicable
19038to all dumps; those that are not meaningful are ignored. The
19039following options are available
19040
19041@table @samp
19042@item address
19043Print the address of each node. Usually this is not meaningful as it
19044changes according to the environment and source file. Its primary use
19045is for tying up a dump file with a debug environment.
19046@item asmname
19047If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
19048in the dump instead of @code{DECL_NAME}. Its primary use is ease of
19049use working backward from mangled names in the assembly file.
19050@item slim
19051When dumping front-end intermediate representations, inhibit dumping
19052of members of a scope or body of a function merely because that scope
19053has been reached. Only dump such items when they are directly reachable
19054by some other path.
19055
19056When dumping pretty-printed trees, this option inhibits dumping the
19057bodies of control structures.
19058
19059When dumping RTL, print the RTL in slim (condensed) form instead of
19060the default LISP-like representation.
19061@item raw
19062Print a raw representation of the tree. By default, trees are
19063pretty-printed into a C-like representation.
19064@item details
19065Enable more detailed dumps (not honored by every dump option). Also
19066include information from the optimization passes.
19067@item stats
19068Enable dumping various statistics about the pass (not honored by every dump
19069option).
19070@item blocks
19071Enable showing basic block boundaries (disabled in raw dumps).
19072@item graph
19073For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
19074dump a representation of the control flow graph suitable for viewing with
19075GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
19076the file is pretty-printed as a subgraph, so that GraphViz can render them
19077all in a single plot.
19078
19079This option currently only works for RTL dumps, and the RTL is always
19080dumped in slim form.
19081@item vops
19082Enable showing virtual operands for every statement.
19083@item lineno
19084Enable showing line numbers for statements.
19085@item uid
19086Enable showing the unique ID (@code{DECL_UID}) for each variable.
19087@item verbose
19088Enable showing the tree dump for each statement.
19089@item eh
19090Enable showing the EH region number holding each statement.
19091@item scev
19092Enable showing scalar evolution analysis details.
19093@item optimized
19094Enable showing optimization information (only available in certain
19095passes).
19096@item missed
19097Enable showing missed optimization information (only available in certain
19098passes).
19099@item note
19100Enable other detailed optimization information (only available in
19101certain passes).
19102@item all
19103Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
19104and @option{lineno}.
19105@item optall
19106Turn on all optimization options, i.e., @option{optimized},
19107@option{missed}, and @option{note}.
19108@end table
19109
19110To determine what tree dumps are available or find the dump for a pass
19111of interest follow the steps below.
19112
19113@enumerate
19114@item
19115Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
19116look for a code that corresponds to the pass you are interested in.
19117For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
19118@code{tree-vrp2} correspond to the three Value Range Propagation passes.
19119The number at the end distinguishes distinct invocations of the same pass.
19120@item
19121To enable the creation of the dump file, append the pass code to
19122the @option{-fdump-} option prefix and invoke GCC with it. For example,
19123to enable the dump from the Early Value Range Propagation pass, invoke
19124GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
19125specify the name of the dump file. If you don't specify one, GCC
19126creates as described below.
19127@item
19128Find the pass dump in a file whose name is composed of three components
19129separated by a period: the name of the source file GCC was invoked to
19130compile, a numeric suffix indicating the pass number followed by the
19131letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
19132and finally the pass code. For example, the Early VRP pass dump might
19133be in a file named @file{myfile.c.038t.evrp} in the current working
19134directory. Note that the numeric codes are not stable and may change
19135from one version of GCC to another.
19136@end enumerate
19137
19138@item -fopt-info
19139@itemx -fopt-info-@var{options}
19140@itemx -fopt-info-@var{options}=@var{filename}
19141@opindex fopt-info
19142Controls optimization dumps from various optimization passes. If the
19143@samp{-@var{options}} form is used, @var{options} is a list of
19144@samp{-} separated option keywords to select the dump details and
19145optimizations.
19146
19147The @var{options} can be divided into three groups:
19148@enumerate
19149@item
19150options describing what kinds of messages should be emitted,
19151@item
19152options describing the verbosity of the dump, and
19153@item
19154options describing which optimizations should be included.
19155@end enumerate
19156The options from each group can be freely mixed as they are
19157non-overlapping. However, in case of any conflicts,
19158the later options override the earlier options on the command
19159line.
19160
19161The following options control which kinds of messages should be emitted:
19162
19163@table @samp
19164@item optimized
19165Print information when an optimization is successfully applied. It is
19166up to a pass to decide which information is relevant. For example, the
19167vectorizer passes print the source location of loops which are
19168successfully vectorized.
19169@item missed
19170Print information about missed optimizations. Individual passes
19171control which information to include in the output.
19172@item note
19173Print verbose information about optimizations, such as certain
19174transformations, more detailed messages about decisions etc.
19175@item all
19176Print detailed optimization information. This includes
19177@samp{optimized}, @samp{missed}, and @samp{note}.
19178@end table
19179
19180The following option controls the dump verbosity:
19181
19182@table @samp
19183@item internals
19184By default, only ``high-level'' messages are emitted. This option enables
19185additional, more detailed, messages, which are likely to only be of interest
19186to GCC developers.
19187@end table
19188
19189One or more of the following option keywords can be used to describe a
19190group of optimizations:
19191
19192@table @samp
19193@item ipa
19194Enable dumps from all interprocedural optimizations.
19195@item loop
19196Enable dumps from all loop optimizations.
19197@item inline
19198Enable dumps from all inlining optimizations.
19199@item omp
19200Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
19201@item vec
19202Enable dumps from all vectorization optimizations.
19203@item optall
19204Enable dumps from all optimizations. This is a superset of
19205the optimization groups listed above.
19206@end table
19207
19208If @var{options} is
19209omitted, it defaults to @samp{optimized-optall}, which means to dump messages
19210about successful optimizations from all the passes, omitting messages
19211that are treated as ``internals''.
19212
19213If the @var{filename} is provided, then the dumps from all the
19214applicable optimizations are concatenated into the @var{filename}.
19215Otherwise the dump is output onto @file{stderr}. Though multiple
19216@option{-fopt-info} options are accepted, only one of them can include
19217a @var{filename}. If other filenames are provided then all but the
19218first such option are ignored.
19219
19220Note that the output @var{filename} is overwritten
19221in case of multiple translation units. If a combined output from
19222multiple translation units is desired, @file{stderr} should be used
19223instead.
19224
19225In the following example, the optimization info is output to
19226@file{stderr}:
19227
19228@smallexample
19229gcc -O3 -fopt-info
19230@end smallexample
19231
19232This example:
19233@smallexample
19234gcc -O3 -fopt-info-missed=missed.all
19235@end smallexample
19236
19237@noindent
19238outputs missed optimization report from all the passes into
19239@file{missed.all}, and this one:
19240
19241@smallexample
19242gcc -O2 -ftree-vectorize -fopt-info-vec-missed
19243@end smallexample
19244
19245@noindent
19246prints information about missed optimization opportunities from
19247vectorization passes on @file{stderr}.
19248Note that @option{-fopt-info-vec-missed} is equivalent to
19249@option{-fopt-info-missed-vec}. The order of the optimization group
19250names and message types listed after @option{-fopt-info} does not matter.
19251
19252As another example,
19253@smallexample
19254gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
19255@end smallexample
19256
19257@noindent
19258outputs information about missed optimizations as well as
19259optimized locations from all the inlining passes into
19260@file{inline.txt}.
19261
19262Finally, consider:
19263
19264@smallexample
19265gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
19266@end smallexample
19267
19268@noindent
19269Here the two output filenames @file{vec.miss} and @file{loop.opt} are
19270in conflict since only one output file is allowed. In this case, only
19271the first option takes effect and the subsequent options are
19272ignored. Thus only @file{vec.miss} is produced which contains
19273dumps from the vectorizer about missed opportunities.
19274
19275@item -fsave-optimization-record
19276@opindex fsave-optimization-record
19277Write a SRCFILE.opt-record.json.gz file detailing what optimizations
19278were performed, for those optimizations that support @option{-fopt-info}.
19279
19280This option is experimental and the format of the data within the
19281compressed JSON file is subject to change.
19282
19283It is roughly equivalent to a machine-readable version of
19284@option{-fopt-info-all}, as a collection of messages with source file,
19285line number and column number, with the following additional data for
19286each message:
19287
19288@itemize @bullet
19289
19290@item
19291the execution count of the code being optimized, along with metadata about
19292whether this was from actual profile data, or just an estimate, allowing
19293consumers to prioritize messages by code hotness,
19294
19295@item
19296the function name of the code being optimized, where applicable,
19297
19298@item
19299the ``inlining chain'' for the code being optimized, so that when
19300a function is inlined into several different places (which might
19301themselves be inlined), the reader can distinguish between the copies,
19302
19303@item
19304objects identifying those parts of the message that refer to expressions,
19305statements or symbol-table nodes, which of these categories they are, and,
19306when available, their source code location,
19307
19308@item
19309the GCC pass that emitted the message, and
19310
19311@item
19312the location in GCC's own code from which the message was emitted
19313
19314@end itemize
19315
19316Additionally, some messages are logically nested within other
19317messages, reflecting implementation details of the optimization
19318passes.
19319
19320@item -fsched-verbose=@var{n}
19321@opindex fsched-verbose
19322On targets that use instruction scheduling, this option controls the
19323amount of debugging output the scheduler prints to the dump files.
19324
19325For @var{n} greater than zero, @option{-fsched-verbose} outputs the
19326same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
19327For @var{n} greater than one, it also output basic block probabilities,
19328detailed ready list information and unit/insn info. For @var{n} greater
19329than two, it includes RTL at abort point, control-flow and regions info.
19330And for @var{n} over four, @option{-fsched-verbose} also includes
19331dependence info.
19332
19333
19334
19335@item -fenable-@var{kind}-@var{pass}
19336@itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
19337@opindex fdisable-
19338@opindex fenable-
19339
19340This is a set of options that are used to explicitly disable/enable
19341optimization passes. These options are intended for use for debugging GCC.
19342Compiler users should use regular options for enabling/disabling
19343passes instead.
19344
19345@table @gcctabopt
19346
19347@item -fdisable-ipa-@var{pass}
19348Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19349statically invoked in the compiler multiple times, the pass name should be
19350appended with a sequential number starting from 1.
19351
19352@item -fdisable-rtl-@var{pass}
19353@itemx -fdisable-rtl-@var{pass}=@var{range-list}
19354Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
19355statically invoked in the compiler multiple times, the pass name should be
19356appended with a sequential number starting from 1. @var{range-list} is a
19357comma-separated list of function ranges or assembler names. Each range is a number
19358pair separated by a colon. The range is inclusive in both ends. If the range
19359is trivial, the number pair can be simplified as a single number. If the
19360function's call graph node's @var{uid} falls within one of the specified ranges,
19361the @var{pass} is disabled for that function. The @var{uid} is shown in the
19362function header of a dump file, and the pass names can be dumped by using
19363option @option{-fdump-passes}.
19364
19365@item -fdisable-tree-@var{pass}
19366@itemx -fdisable-tree-@var{pass}=@var{range-list}
19367Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
19368option arguments.
19369
19370@item -fenable-ipa-@var{pass}
19371Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19372statically invoked in the compiler multiple times, the pass name should be
19373appended with a sequential number starting from 1.
19374
19375@item -fenable-rtl-@var{pass}
19376@itemx -fenable-rtl-@var{pass}=@var{range-list}
19377Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
19378description and examples.
19379
19380@item -fenable-tree-@var{pass}
19381@itemx -fenable-tree-@var{pass}=@var{range-list}
19382Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
19383of option arguments.
19384
19385@end table
19386
19387Here are some examples showing uses of these options.
19388
19389@smallexample
19390
19391# disable ccp1 for all functions
19392 -fdisable-tree-ccp1
19393# disable complete unroll for function whose cgraph node uid is 1
19394 -fenable-tree-cunroll=1
19395# disable gcse2 for functions at the following ranges [1,1],
19396# [300,400], and [400,1000]
19397# disable gcse2 for functions foo and foo2
19398 -fdisable-rtl-gcse2=foo,foo2
19399# disable early inlining
19400 -fdisable-tree-einline
19401# disable ipa inlining
19402 -fdisable-ipa-inline
19403# enable tree full unroll
19404 -fenable-tree-unroll
19405
19406@end smallexample
19407
19408@item -fchecking
19409@itemx -fchecking=@var{n}
19410@opindex fchecking
19411@opindex fno-checking
19412Enable internal consistency checking. The default depends on
19413the compiler configuration. @option{-fchecking=2} enables further
19414internal consistency checking that might affect code generation.
19415
19416@item -frandom-seed=@var{string}
19417@opindex frandom-seed
19418This option provides a seed that GCC uses in place of
19419random numbers in generating certain symbol names
19420that have to be different in every compiled file. It is also used to
19421place unique stamps in coverage data files and the object files that
19422produce them. You can use the @option{-frandom-seed} option to produce
19423reproducibly identical object files.
19424
19425The @var{string} can either be a number (decimal, octal or hex) or an
19426arbitrary string (in which case it's converted to a number by
19427computing CRC32).
19428
19429The @var{string} should be different for every file you compile.
19430
19431@item -save-temps
19432@opindex save-temps
19433Store the usual ``temporary'' intermediate files permanently; name them
19434as auxiliary output files, as specified described under
19435@option{-dumpbase} and @option{-dumpdir}.
19436
19437When used in combination with the @option{-x} command-line option,
19438@option{-save-temps} is sensible enough to avoid overwriting an
19439input source file with the same extension as an intermediate file.
19440The corresponding intermediate file may be obtained by renaming the
19441source file before using @option{-save-temps}.
19442
19443@item -save-temps=cwd
19444@opindex save-temps=cwd
19445Equivalent to @option{-save-temps -dumpdir ./}.
19446
19447@item -save-temps=obj
19448@opindex save-temps=obj
19449Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
19450@file{outdir/} is the directory of the output file specified after the
19451@option{-o} option, including any directory separators. If the
19452@option{-o} option is not used, the @option{-save-temps=obj} switch
19453behaves like @option{-save-temps=cwd}.
19454
19455@item -time@r{[}=@var{file}@r{]}
19456@opindex time
19457Report the CPU time taken by each subprocess in the compilation
19458sequence. For C source files, this is the compiler proper and assembler
19459(plus the linker if linking is done).
19460
19461Without the specification of an output file, the output looks like this:
19462
19463@smallexample
19464# cc1 0.12 0.01
19465# as 0.00 0.01
19466@end smallexample
19467
19468The first number on each line is the ``user time'', that is time spent
19469executing the program itself. The second number is ``system time'',
19470time spent executing operating system routines on behalf of the program.
19471Both numbers are in seconds.
19472
19473With the specification of an output file, the output is appended to the
19474named file, and it looks like this:
19475
19476@smallexample
194770.12 0.01 cc1 @var{options}
194780.00 0.01 as @var{options}
19479@end smallexample
19480
19481The ``user time'' and the ``system time'' are moved before the program
19482name, and the options passed to the program are displayed, so that one
19483can later tell what file was being compiled, and with which options.
19484
19485@item -fdump-final-insns@r{[}=@var{file}@r{]}
19486@opindex fdump-final-insns
19487Dump the final internal representation (RTL) to @var{file}. If the
19488optional argument is omitted (or if @var{file} is @code{.}), the name
19489of the dump file is determined by appending @code{.gkd} to the
19490dump base name, see @option{-dumpbase}.
19491
19492@item -fcompare-debug@r{[}=@var{opts}@r{]}
19493@opindex fcompare-debug
19494@opindex fno-compare-debug
19495If no error occurs during compilation, run the compiler a second time,
19496adding @var{opts} and @option{-fcompare-debug-second} to the arguments
19497passed to the second compilation. Dump the final internal
19498representation in both compilations, and print an error if they differ.
19499
19500If the equal sign is omitted, the default @option{-gtoggle} is used.
19501
19502The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
19503and nonzero, implicitly enables @option{-fcompare-debug}. If
19504@env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
19505then it is used for @var{opts}, otherwise the default @option{-gtoggle}
19506is used.
19507
19508@option{-fcompare-debug=}, with the equal sign but without @var{opts},
19509is equivalent to @option{-fno-compare-debug}, which disables the dumping
19510of the final representation and the second compilation, preventing even
19511@env{GCC_COMPARE_DEBUG} from taking effect.
19512
19513To verify full coverage during @option{-fcompare-debug} testing, set
19514@env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
19515which GCC rejects as an invalid option in any actual compilation
19516(rather than preprocessing, assembly or linking). To get just a
19517warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
19518not overridden} will do.
19519
19520@item -fcompare-debug-second
19521@opindex fcompare-debug-second
19522This option is implicitly passed to the compiler for the second
19523compilation requested by @option{-fcompare-debug}, along with options to
19524silence warnings, and omitting other options that would cause the compiler
19525to produce output to files or to standard output as a side effect. Dump
19526files and preserved temporary files are renamed so as to contain the
19527@code{.gk} additional extension during the second compilation, to avoid
19528overwriting those generated by the first.
19529
19530When this option is passed to the compiler driver, it causes the
19531@emph{first} compilation to be skipped, which makes it useful for little
19532other than debugging the compiler proper.
19533
19534@item -gtoggle
19535@opindex gtoggle
19536Turn off generation of debug info, if leaving out this option
19537generates it, or turn it on at level 2 otherwise. The position of this
19538argument in the command line does not matter; it takes effect after all
19539other options are processed, and it does so only once, no matter how
19540many times it is given. This is mainly intended to be used with
19541@option{-fcompare-debug}.
19542
19543@item -fvar-tracking-assignments-toggle
19544@opindex fvar-tracking-assignments-toggle
19545@opindex fno-var-tracking-assignments-toggle
19546Toggle @option{-fvar-tracking-assignments}, in the same way that
19547@option{-gtoggle} toggles @option{-g}.
19548
19549@item -Q
19550@opindex Q
19551Makes the compiler print out each function name as it is compiled, and
19552print some statistics about each pass when it finishes.
19553
19554@item -ftime-report
19555@opindex ftime-report
19556Makes the compiler print some statistics about the time consumed by each
19557pass when it finishes.
19558
19559@item -ftime-report-details
19560@opindex ftime-report-details
19561Record the time consumed by infrastructure parts separately for each pass.
19562
19563@item -fira-verbose=@var{n}
19564@opindex fira-verbose
19565Control the verbosity of the dump file for the integrated register allocator.
19566The default value is 5. If the value @var{n} is greater or equal to 10,
19567the dump output is sent to stderr using the same format as @var{n} minus 10.
19568
19569@item -flto-report
19570@opindex flto-report
19571Prints a report with internal details on the workings of the link-time
19572optimizer. The contents of this report vary from version to version.
19573It is meant to be useful to GCC developers when processing object
19574files in LTO mode (via @option{-flto}).
19575
19576Disabled by default.
19577
19578@item -flto-report-wpa
19579@opindex flto-report-wpa
19580Like @option{-flto-report}, but only print for the WPA phase of link-time
19581optimization.
19582
19583@item -fmem-report
19584@opindex fmem-report
19585Makes the compiler print some statistics about permanent memory
19586allocation when it finishes.
19587
19588@item -fmem-report-wpa
19589@opindex fmem-report-wpa
19590Makes the compiler print some statistics about permanent memory
19591allocation for the WPA phase only.
19592
19593@item -fpre-ipa-mem-report
19594@opindex fpre-ipa-mem-report
19595@item -fpost-ipa-mem-report
19596@opindex fpost-ipa-mem-report
19597Makes the compiler print some statistics about permanent memory
19598allocation before or after interprocedural optimization.
19599
19600@item -fmultiflags
19601@opindex fmultiflags
19602This option enables multilib-aware @code{TFLAGS} to be used to build
19603target libraries with options different from those the compiler is
19604configured to use by default, through the use of specs (@xref{Spec
19605Files}) set up by compiler internals, by the target, or by builders at
19606configure time.
19607
19608Like @code{TFLAGS}, this allows the target libraries to be built for
19609portable baseline environments, while the compiler defaults to more
19610demanding ones. That's useful because users can easily override the
19611defaults the compiler is configured to use to build their own programs,
19612if the defaults are not ideal for their target environment, whereas
19613rebuilding the runtime libraries is usually not as easy or desirable.
19614
19615Unlike @code{TFLAGS}, the use of specs enables different flags to be
19616selected for different multilibs. The way to accomplish that is to
19617build with @samp{make TFLAGS=-fmultiflags}, after configuring
19618@samp{--with-specs=%@{fmultiflags:...@}}.
19619
19620This option is discarded by the driver once it's done processing driver
19621self spec.
19622
19623It is also useful to check that @code{TFLAGS} are being used to build
19624all target libraries, by configuring a non-bootstrap compiler
19625@samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building
19626the compiler and target libraries.
19627
19628@item -fprofile-report
19629@opindex fprofile-report
19630Makes the compiler print some statistics about consistency of the
19631(estimated) profile and effect of individual passes.
19632
19633@item -fstack-usage
19634@opindex fstack-usage
19635Makes the compiler output stack usage information for the program, on a
19636per-function basis. The filename for the dump is made by appending
19637@file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
19638the output file, if explicitly specified and it is not an executable,
19639otherwise it is the basename of the source file. An entry is made up
19640of three fields:
19641
19642@itemize
19643@item
19644The name of the function.
19645@item
19646A number of bytes.
19647@item
19648One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
19649@end itemize
19650
19651The qualifier @code{static} means that the function manipulates the stack
19652statically: a fixed number of bytes are allocated for the frame on function
19653entry and released on function exit; no stack adjustments are otherwise made
19654in the function. The second field is this fixed number of bytes.
19655
19656The qualifier @code{dynamic} means that the function manipulates the stack
19657dynamically: in addition to the static allocation described above, stack
19658adjustments are made in the body of the function, for example to push/pop
19659arguments around function calls. If the qualifier @code{bounded} is also
19660present, the amount of these adjustments is bounded at compile time and
19661the second field is an upper bound of the total amount of stack used by
19662the function. If it is not present, the amount of these adjustments is
19663not bounded at compile time and the second field only represents the
19664bounded part.
19665
19666@item -fstats
19667@opindex fstats
19668Emit statistics about front-end processing at the end of the compilation.
19669This option is supported only by the C++ front end, and
19670the information is generally only useful to the G++ development team.
19671
19672@item -fdbg-cnt-list
19673@opindex fdbg-cnt-list
19674Print the name and the counter upper bound for all debug counters.
19675
19676
19677@item -fdbg-cnt=@var{counter-value-list}
19678@opindex fdbg-cnt
19679Set the internal debug counter lower and upper bound. @var{counter-value-list}
19680is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
19681[:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
19682the name of the counter and list of closed intervals.
19683The @var{lower_bound} is optional and is zero
19684initialized if not set.
19685For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
19686@code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
19687eleventh invocation.
19688For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
19689
19690@item -print-file-name=@var{library}
19691@opindex print-file-name
19692Print the full absolute name of the library file @var{library} that
19693would be used when linking---and don't do anything else. With this
19694option, GCC does not compile or link anything; it just prints the
19695file name.
19696
19697@item -print-multi-directory
19698@opindex print-multi-directory
19699Print the directory name corresponding to the multilib selected by any
19700other switches present in the command line. This directory is supposed
19701to exist in @env{GCC_EXEC_PREFIX}.
19702
19703@item -print-multi-lib
19704@opindex print-multi-lib
19705Print the mapping from multilib directory names to compiler switches
19706that enable them. The directory name is separated from the switches by
19707@samp{;}, and each switch starts with an @samp{@@} instead of the
19708@samp{-}, without spaces between multiple switches. This is supposed to
19709ease shell processing.
19710
19711@item -print-multi-os-directory
19712@opindex print-multi-os-directory
19713Print the path to OS libraries for the selected
19714multilib, relative to some @file{lib} subdirectory. If OS libraries are
19715present in the @file{lib} subdirectory and no multilibs are used, this is
19716usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
19717sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
19718@file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
19719subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
19720
19721@item -print-multiarch
19722@opindex print-multiarch
19723Print the path to OS libraries for the selected multiarch,
19724relative to some @file{lib} subdirectory.
19725
19726@item -print-prog-name=@var{program}
19727@opindex print-prog-name
19728Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
19729
19730@item -print-libgcc-file-name
19731@opindex print-libgcc-file-name
19732Same as @option{-print-file-name=libgcc.a}.
19733
19734This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
19735but you do want to link with @file{libgcc.a}. You can do:
19736
19737@smallexample
19738gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
19739@end smallexample
19740
19741@item -print-search-dirs
19742@opindex print-search-dirs
19743Print the name of the configured installation directory and a list of
19744program and library directories @command{gcc} searches---and don't do anything else.
19745
19746This is useful when @command{gcc} prints the error message
19747@samp{installation problem, cannot exec cpp0: No such file or directory}.
19748To resolve this you either need to put @file{cpp0} and the other compiler
19749components where @command{gcc} expects to find them, or you can set the environment
19750variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
19751Don't forget the trailing @samp{/}.
19752@xref{Environment Variables}.
19753
19754@item -print-sysroot
19755@opindex print-sysroot
19756Print the target sysroot directory that is used during
19757compilation. This is the target sysroot specified either at configure
19758time or using the @option{--sysroot} option, possibly with an extra
19759suffix that depends on compilation options. If no target sysroot is
19760specified, the option prints nothing.
19761
19762@item -print-sysroot-headers-suffix
19763@opindex print-sysroot-headers-suffix
19764Print the suffix added to the target sysroot when searching for
19765headers, or give an error if the compiler is not configured with such
19766a suffix---and don't do anything else.
19767
19768@item -dumpmachine
19769@opindex dumpmachine
19770Print the compiler's target machine (for example,
19771@samp{i686-pc-linux-gnu})---and don't do anything else.
19772
19773@item -dumpversion
19774@opindex dumpversion
19775Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
19776anything else. This is the compiler version used in filesystem paths and
19777specs. Depending on how the compiler has been configured it can be just
19778a single number (major version), two numbers separated by a dot (major and
19779minor version) or three numbers separated by dots (major, minor and patchlevel
19780version).
19781
19782@item -dumpfullversion
19783@opindex dumpfullversion
19784Print the full compiler version---and don't do anything else. The output is
19785always three numbers separated by dots, major, minor and patchlevel version.
19786
19787@item -dumpspecs
19788@opindex dumpspecs
19789Print the compiler's built-in specs---and don't do anything else. (This
19790is used when GCC itself is being built.) @xref{Spec Files}.
19791@end table
19792
19793@node Submodel Options
19794@section Machine-Dependent Options
19795@cindex submodel options
19796@cindex specifying hardware config
19797@cindex hardware models and configurations, specifying
19798@cindex target-dependent options
19799@cindex machine-dependent options
19800
19801Each target machine supported by GCC can have its own options---for
19802example, to allow you to compile for a particular processor variant or
19803ABI, or to control optimizations specific to that machine. By
19804convention, the names of machine-specific options start with
19805@samp{-m}.
19806
19807Some configurations of the compiler also support additional target-specific
19808options, usually for compatibility with other compilers on the same
19809platform.
19810
19811@c This list is ordered alphanumerically by subsection name.
19812@c It should be the same order and spelling as these options are listed
19813@c in Machine Dependent Options
19814
19815@menu
19816* AArch64 Options::
19817* Adapteva Epiphany Options::
19818* AMD GCN Options::
19819* ARC Options::
19820* ARM Options::
19821* AVR Options::
19822* Blackfin Options::
19823* C6X Options::
19824* CRIS Options::
19825* C-SKY Options::
19826* Darwin Options::
19827* DEC Alpha Options::
19828* eBPF Options::
19829* FR30 Options::
19830* FT32 Options::
19831* FRV Options::
19832* GNU/Linux Options::
19833* H8/300 Options::
19834* HPPA Options::
19835* IA-64 Options::
19836* LM32 Options::
19837* LoongArch Options::
19838* M32C Options::
19839* M32R/D Options::
19840* M680x0 Options::
19841* MCore Options::
d77de738
ML
19842* MicroBlaze Options::
19843* MIPS Options::
19844* MMIX Options::
19845* MN10300 Options::
19846* Moxie Options::
19847* MSP430 Options::
19848* NDS32 Options::
19849* Nios II Options::
19850* Nvidia PTX Options::
19851* OpenRISC Options::
19852* PDP-11 Options::
d77de738
ML
19853* PowerPC Options::
19854* PRU Options::
19855* RISC-V Options::
19856* RL78 Options::
19857* RS/6000 and PowerPC Options::
19858* RX Options::
19859* S/390 and zSeries Options::
d77de738
ML
19860* SH Options::
19861* Solaris 2 Options::
19862* SPARC Options::
19863* System V Options::
19864* V850 Options::
19865* VAX Options::
19866* Visium Options::
19867* VMS Options::
19868* VxWorks Options::
19869* x86 Options::
19870* x86 Windows Options::
19871* Xstormy16 Options::
19872* Xtensa Options::
19873* zSeries Options::
19874@end menu
19875
19876@node AArch64 Options
19877@subsection AArch64 Options
19878@cindex AArch64 Options
19879
19880These options are defined for AArch64 implementations:
19881
19882@table @gcctabopt
19883
19884@item -mabi=@var{name}
19885@opindex mabi
19886Generate code for the specified data model. Permissible values
19887are @samp{ilp32} for SysV-like data model where int, long int and pointers
19888are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
19889but long int and pointers are 64 bits.
19890
19891The default depends on the specific target configuration. Note that
19892the LP64 and ILP32 ABIs are not link-compatible; you must compile your
19893entire program with the same ABI, and link with a compatible set of libraries.
19894
19895@item -mbig-endian
19896@opindex mbig-endian
19897Generate big-endian code. This is the default when GCC is configured for an
19898@samp{aarch64_be-*-*} target.
19899
19900@item -mgeneral-regs-only
19901@opindex mgeneral-regs-only
19902Generate code which uses only the general-purpose registers. This will prevent
19903the compiler from using floating-point and Advanced SIMD registers but will not
19904impose any restrictions on the assembler.
19905
19906@item -mlittle-endian
19907@opindex mlittle-endian
19908Generate little-endian code. This is the default when GCC is configured for an
19909@samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
19910
19911@item -mcmodel=tiny
19912@opindex mcmodel=tiny
19913Generate code for the tiny code model. The program and its statically defined
19914symbols must be within 1MB of each other. Programs can be statically or
19915dynamically linked.
19916
19917@item -mcmodel=small
19918@opindex mcmodel=small
19919Generate code for the small code model. The program and its statically defined
19920symbols must be within 4GB of each other. Programs can be statically or
19921dynamically linked. This is the default code model.
19922
19923@item -mcmodel=large
19924@opindex mcmodel=large
19925Generate code for the large code model. This makes no assumptions about
19926addresses and sizes of sections. Programs can be statically linked only. The
19927@option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
19928@option{-fpic} and @option{-fPIC}.
19929
19930@item -mstrict-align
19931@itemx -mno-strict-align
19932@opindex mstrict-align
19933@opindex mno-strict-align
19934Avoid or allow generating memory accesses that may not be aligned on a natural
19935object boundary as described in the architecture specification.
19936
19937@item -momit-leaf-frame-pointer
19938@itemx -mno-omit-leaf-frame-pointer
19939@opindex momit-leaf-frame-pointer
19940@opindex mno-omit-leaf-frame-pointer
19941Omit or keep the frame pointer in leaf functions. The former behavior is the
19942default.
19943
19944@item -mstack-protector-guard=@var{guard}
19945@itemx -mstack-protector-guard-reg=@var{reg}
19946@itemx -mstack-protector-guard-offset=@var{offset}
19947@opindex mstack-protector-guard
19948@opindex mstack-protector-guard-reg
19949@opindex mstack-protector-guard-offset
19950Generate stack protection code using canary at @var{guard}. Supported
19951locations are @samp{global} for a global canary or @samp{sysreg} for a
19952canary in an appropriate system register.
19953
19954With the latter choice the options
19955@option{-mstack-protector-guard-reg=@var{reg}} and
19956@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
19957which system register to use as base register for reading the canary,
19958and from what offset from that base register. There is no default
19959register or offset as this is entirely for use within the Linux
19960kernel.
19961
19962@item -mtls-dialect=desc
19963@opindex mtls-dialect=desc
19964Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
19965of TLS variables. This is the default.
19966
19967@item -mtls-dialect=traditional
19968@opindex mtls-dialect=traditional
19969Use traditional TLS as the thread-local storage mechanism for dynamic accesses
19970of TLS variables.
19971
19972@item -mtls-size=@var{size}
19973@opindex mtls-size
19974Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
19975This option requires binutils 2.26 or newer.
19976
19977@item -mfix-cortex-a53-835769
19978@itemx -mno-fix-cortex-a53-835769
19979@opindex mfix-cortex-a53-835769
19980@opindex mno-fix-cortex-a53-835769
19981Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
19982This involves inserting a NOP instruction between memory instructions and
1998364-bit integer multiply-accumulate instructions.
19984
19985@item -mfix-cortex-a53-843419
19986@itemx -mno-fix-cortex-a53-843419
19987@opindex mfix-cortex-a53-843419
19988@opindex mno-fix-cortex-a53-843419
19989Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
19990This erratum workaround is made at link time and this will only pass the
19991corresponding flag to the linker.
19992
19993@item -mlow-precision-recip-sqrt
19994@itemx -mno-low-precision-recip-sqrt
19995@opindex mlow-precision-recip-sqrt
19996@opindex mno-low-precision-recip-sqrt
19997Enable or disable the reciprocal square root approximation.
19998This option only has an effect if @option{-ffast-math} or
19999@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20000precision of reciprocal square root results to about 16 bits for
20001single precision and to 32 bits for double precision.
20002
20003@item -mlow-precision-sqrt
20004@itemx -mno-low-precision-sqrt
20005@opindex mlow-precision-sqrt
20006@opindex mno-low-precision-sqrt
20007Enable or disable the square root approximation.
20008This option only has an effect if @option{-ffast-math} or
20009@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20010precision of square root results to about 16 bits for
20011single precision and to 32 bits for double precision.
20012If enabled, it implies @option{-mlow-precision-recip-sqrt}.
20013
20014@item -mlow-precision-div
20015@itemx -mno-low-precision-div
20016@opindex mlow-precision-div
20017@opindex mno-low-precision-div
20018Enable or disable the division approximation.
20019This option only has an effect if @option{-ffast-math} or
20020@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20021precision of division results to about 16 bits for
20022single precision and to 32 bits for double precision.
20023
20024@item -mtrack-speculation
20025@itemx -mno-track-speculation
20026Enable or disable generation of additional code to track speculative
20027execution through conditional branches. The tracking state can then
20028be used by the compiler when expanding calls to
20029@code{__builtin_speculation_safe_copy} to permit a more efficient code
20030sequence to be generated.
20031
20032@item -moutline-atomics
20033@itemx -mno-outline-atomics
20034Enable or disable calls to out-of-line helpers to implement atomic operations.
20035These helpers will, at runtime, determine if the LSE instructions from
20036ARMv8.1-A can be used; if not, they will use the load/store-exclusive
20037instructions that are present in the base ARMv8.0 ISA.
20038
20039This option is only applicable when compiling for the base ARMv8.0
20040instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
20041or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
20042used directly. The same applies when using @option{-mcpu=} when the
20043selected cpu supports the @samp{lse} feature.
20044This option is on by default.
20045
20046@item -march=@var{name}
20047@opindex march
20048Specify the name of the target architecture and, optionally, one or
20049more feature modifiers. This option has the form
20050@option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
20051
20052The table below summarizes the permissible values for @var{arch}
20053and the features that they enable by default:
20054
20055@multitable @columnfractions 0.20 0.20 0.60
20056@headitem @var{arch} value @tab Architecture @tab Includes by default
20057@item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
20058@item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
20059@item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
20060@item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}
20061@item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}
20062@item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}
20063@item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
20064@item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64}
20065@item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
20066@item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
20067@item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
20068@item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64}
20069@item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
20070@item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
20071@end multitable
20072
20073The value @samp{native} is available on native AArch64 GNU/Linux and
20074causes the compiler to pick the architecture of the host system. This
20075option has no effect if the compiler is unable to recognize the
20076architecture of the host system,
20077
20078The permissible values for @var{feature} are listed in the sub-section
20079on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20080Feature Modifiers}. Where conflicting feature modifiers are
20081specified, the right-most feature is used.
20082
20083GCC uses @var{name} to determine what kind of instructions it can emit
20084when generating assembly code. If @option{-march} is specified
20085without either of @option{-mtune} or @option{-mcpu} also being
20086specified, the code is tuned to perform well across a range of target
20087processors implementing the target architecture.
20088
20089@item -mtune=@var{name}
20090@opindex mtune
20091Specify the name of the target processor for which GCC should tune the
20092performance of the code. Permissible values for this option are:
20093@samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
20094@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
20095@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
20096@samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
20097@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
20098@samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
20099@samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
20100@samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx},
20101@samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
20102@samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
20103@samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
20104@samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
20105@samp{octeontx2f95mm},
20106@samp{a64fx},
20107@samp{thunderx}, @samp{thunderxt88},
20108@samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
20109@samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
20110@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20111@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20112@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
ce51e843 20113@samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2},
e07556a8
SP
20114@samp{cortex-x3}, @samp{cortex-a510}, @samp{cortex-a710}, @samp{cortex-a715},
20115@samp{ampere1}, @samp{ampere1a}, and @samp{native}.
d77de738
ML
20116
20117The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20118@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20119@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC
20120should tune for a big.LITTLE system.
20121
20122The value @samp{neoverse-512tvb} specifies that GCC should tune
20123for Neoverse cores that (a) implement SVE and (b) have a total vector
20124bandwidth of 512 bits per cycle. In other words, the option tells GCC to
20125tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
20126instructions a cycle and that can execute an equivalent number of SVE
20127arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
20128This is more general than tuning for a specific core like Neoverse V1
20129but is more specific than the default tuning described below.
20130
20131Additionally on native AArch64 GNU/Linux systems the value
20132@samp{native} tunes performance to the host system. This option has no effect
20133if the compiler is unable to recognize the processor of the host system.
20134
20135Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
20136are specified, the code is tuned to perform well across a range
20137of target processors.
20138
20139This option cannot be suffixed by feature modifiers.
20140
20141@item -mcpu=@var{name}
20142@opindex mcpu
20143Specify the name of the target processor, optionally suffixed by one
20144or more feature modifiers. This option has the form
20145@option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
20146the permissible values for @var{cpu} are the same as those available
20147for @option{-mtune}. The permissible values for @var{feature} are
20148documented in the sub-section on
20149@ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20150Feature Modifiers}. Where conflicting feature modifiers are
20151specified, the right-most feature is used.
20152
20153GCC uses @var{name} to determine what kind of instructions it can emit when
20154generating assembly code (as if by @option{-march}) and to determine
20155the target processor for which to tune for performance (as if
20156by @option{-mtune}). Where this option is used in conjunction
20157with @option{-march} or @option{-mtune}, those options take precedence
20158over the appropriate part of this option.
20159
20160@option{-mcpu=neoverse-512tvb} is special in that it does not refer
20161to a specific core, but instead refers to all Neoverse cores that
20162(a) implement SVE and (b) have a total vector bandwidth of 512 bits
20163a cycle. Unless overridden by @option{-march},
20164@option{-mcpu=neoverse-512tvb} generates code that can run on a
20165Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
20166these properties. Unless overridden by @option{-mtune},
20167@option{-mcpu=neoverse-512tvb} tunes code in the same way as for
20168@option{-mtune=neoverse-512tvb}.
20169
20170@item -moverride=@var{string}
20171@opindex moverride
20172Override tuning decisions made by the back-end in response to a
20173@option{-mtune=} switch. The syntax, semantics, and accepted values
20174for @var{string} in this option are not guaranteed to be consistent
20175across releases.
20176
20177This option is only intended to be useful when developing GCC.
20178
20179@item -mverbose-cost-dump
20180@opindex mverbose-cost-dump
20181Enable verbose cost model dumping in the debug dump files. This option is
20182provided for use in debugging the compiler.
20183
20184@item -mpc-relative-literal-loads
20185@itemx -mno-pc-relative-literal-loads
20186@opindex mpc-relative-literal-loads
20187@opindex mno-pc-relative-literal-loads
20188Enable or disable PC-relative literal loads. With this option literal pools are
20189accessed using a single instruction and emitted after each function. This
20190limits the maximum size of functions to 1MB. This is enabled by default for
20191@option{-mcmodel=tiny}.
20192
20193@item -msign-return-address=@var{scope}
20194@opindex msign-return-address
20195Select the function scope on which return address signing will be applied.
20196Permissible values are @samp{none}, which disables return address signing,
20197@samp{non-leaf}, which enables pointer signing for functions which are not leaf
20198functions, and @samp{all}, which enables pointer signing for all functions. The
20199default value is @samp{none}. This option has been deprecated by
20200-mbranch-protection.
20201
20202@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}
20203@opindex mbranch-protection
20204Select the branch protection features to use.
20205@samp{none} is the default and turns off all types of branch protection.
20206@samp{standard} turns on all types of branch protection features. If a feature
20207has additional tuning options, then @samp{standard} sets it to its standard
20208level.
20209@samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
20210level: signing functions that save the return address to memory (non-leaf
20211functions will practically always do this) using the a-key. The optional
20212argument @samp{leaf} can be used to extend the signing to include leaf
20213functions. The optional argument @samp{b-key} can be used to sign the functions
20214with the B-key instead of the A-key.
20215@samp{bti} turns on branch target identification mechanism.
20216
20217@item -mharden-sls=@var{opts}
20218@opindex mharden-sls
20219Enable compiler hardening against straight line speculation (SLS).
20220@var{opts} is a comma-separated list of the following options:
20221@table @samp
20222@item retbr
20223@item blr
20224@end table
20225In addition, @samp{-mharden-sls=all} enables all SLS hardening while
20226@samp{-mharden-sls=none} disables all SLS hardening.
20227
20228@item -msve-vector-bits=@var{bits}
20229@opindex msve-vector-bits
20230Specify the number of bits in an SVE vector register. This option only has
20231an effect when SVE is enabled.
20232
20233GCC supports two forms of SVE code generation: ``vector-length
20234agnostic'' output that works with any size of vector register and
20235``vector-length specific'' output that allows GCC to make assumptions
20236about the vector length when it is useful for optimization reasons.
20237The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
20238@samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
20239Specifying @samp{scalable} selects vector-length agnostic
20240output. At present @samp{-msve-vector-bits=128} also generates vector-length
20241agnostic output for big-endian targets. All other values generate
20242vector-length specific code. The behavior of these values may change
20243in future releases and no value except @samp{scalable} should be
20244relied on for producing code that is portable across different
20245hardware SVE vector lengths.
20246
20247The default is @samp{-msve-vector-bits=scalable}, which produces
20248vector-length agnostic code.
20249@end table
20250
20251@subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
20252@anchor{aarch64-feature-modifiers}
20253@cindex @option{-march} feature modifiers
20254@cindex @option{-mcpu} feature modifiers
20255Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
20256the following and their inverses @option{no@var{feature}}:
20257
20258@table @samp
20259@item crc
20260Enable CRC extension. This is on by default for
20261@option{-march=armv8.1-a}.
20262@item crypto
20263Enable Crypto extension. This also enables Advanced SIMD and floating-point
20264instructions.
20265@item fp
20266Enable floating-point instructions. This is on by default for all possible
20267values for options @option{-march} and @option{-mcpu}.
20268@item simd
20269Enable Advanced SIMD instructions. This also enables floating-point
20270instructions. This is on by default for all possible values for options
20271@option{-march} and @option{-mcpu}.
20272@item sve
20273Enable Scalable Vector Extension instructions. This also enables Advanced
20274SIMD and floating-point instructions.
20275@item lse
20276Enable Large System Extension instructions. This is on by default for
20277@option{-march=armv8.1-a}.
20278@item rdma
20279Enable Round Double Multiply Accumulate instructions. This is on by default
20280for @option{-march=armv8.1-a}.
20281@item fp16
20282Enable FP16 extension. This also enables floating-point instructions.
20283@item fp16fml
20284Enable FP16 fmla extension. This also enables FP16 extensions and
20285floating-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.
20286
20287@item rcpc
0431e8ae
AV
20288Enable the RCpc extension. This enables the use of the LDAPR instructions for
20289load-acquire atomic semantics, and passes it on to the assembler, enabling
20290inline asm statements to use instructions from the RCpc extension.
d77de738
ML
20291@item dotprod
20292Enable the Dot Product extension. This also enables Advanced SIMD instructions.
20293@item aes
20294Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
20295SIMD instructions.
20296@item sha2
20297Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
20298@item sha3
20299Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
20300instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
20301@item sm4
20302Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
20303Use of this option with architectures prior to Armv8.2-A is not supported.
20304@item profile
20305Enable the Statistical Profiling extension. This option is only to enable the
20306extension at the assembler level and does not affect code generation.
20307@item rng
20308Enable the Armv8.5-a Random Number instructions. This option is only to
20309enable the extension at the assembler level and does not affect code
20310generation.
20311@item memtag
20312Enable the Armv8.5-a Memory Tagging Extensions.
20313Use of this option with architectures prior to Armv8.5-A is not supported.
20314@item sb
20315Enable the Armv8-a Speculation Barrier instruction. This option is only to
20316enable the extension at the assembler level and does not affect code
20317generation. This option is enabled by default for @option{-march=armv8.5-a}.
20318@item ssbs
20319Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
20320is only to enable the extension at the assembler level and does not affect code
20321generation. This option is enabled by default for @option{-march=armv8.5-a}.
20322@item predres
20323Enable the Armv8-a Execution and Data Prediction Restriction instructions.
20324This option is only to enable the extension at the assembler level and does
20325not affect code generation. This option is enabled by default for
20326@option{-march=armv8.5-a}.
20327@item sve2
20328Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
20329instructions.
20330@item sve2-bitperm
20331Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
20332@item sve2-sm4
20333Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
20334@item sve2-aes
20335Enable SVE2 aes instructions. This also enables SVE2 instructions.
20336@item sve2-sha3
20337Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
20338@item tme
20339Enable the Transactional Memory Extension.
20340@item i8mm
20341Enable 8-bit Integer Matrix Multiply instructions. This also enables
20342Advanced SIMD and floating-point instructions. This option is enabled by
20343default for @option{-march=armv8.6-a}. Use of this option with architectures
20344prior to Armv8.2-A is not supported.
20345@item f32mm
20346Enable 32-bit Floating point Matrix Multiply instructions. This also enables
20347SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20348not supported.
20349@item f64mm
20350Enable 64-bit Floating point Matrix Multiply instructions. This also enables
20351SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20352not supported.
20353@item bf16
20354Enable brain half-precision floating-point instructions. This also enables
20355Advanced SIMD and floating-point instructions. This option is enabled by
20356default for @option{-march=armv8.6-a}. Use of this option with architectures
20357prior to Armv8.2-A is not supported.
20358@item ls64
20359Enable the 64-byte atomic load and store instructions for accelerators.
20360This option is enabled by default for @option{-march=armv8.7-a}.
20361@item mops
20362Enable the instructions to accelerate memory operations like @code{memcpy},
20363@code{memmove}, @code{memset}. This option is enabled by default for
20364@option{-march=armv8.8-a}
20365@item flagm
20366Enable the Flag Manipulation instructions Extension.
20367@item pauth
20368Enable the Pointer Authentication Extension.
d758d190
KT
20369@item cssc
20370Enable the Common Short Sequence Compression instructions.
d77de738
ML
20371
20372@end table
20373
20374Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
20375which implies @option{fp}.
20376Conversely, @option{nofp} implies @option{nosimd}, which implies
20377@option{nocrypto}, @option{noaes} and @option{nosha2}.
20378
20379@node Adapteva Epiphany Options
20380@subsection Adapteva Epiphany Options
20381
20382These @samp{-m} options are defined for Adapteva Epiphany:
20383
20384@table @gcctabopt
20385@item -mhalf-reg-file
20386@opindex mhalf-reg-file
20387Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
20388That allows code to run on hardware variants that lack these registers.
20389
20390@item -mprefer-short-insn-regs
20391@opindex mprefer-short-insn-regs
20392Preferentially allocate registers that allow short instruction generation.
20393This can result in increased instruction count, so this may either reduce or
20394increase overall code size.
20395
20396@item -mbranch-cost=@var{num}
20397@opindex mbranch-cost
20398Set the cost of branches to roughly @var{num} ``simple'' instructions.
20399This cost is only a heuristic and is not guaranteed to produce
20400consistent results across releases.
20401
20402@item -mcmove
20403@opindex mcmove
20404Enable the generation of conditional moves.
20405
20406@item -mnops=@var{num}
20407@opindex mnops
20408Emit @var{num} NOPs before every other generated instruction.
20409
20410@item -mno-soft-cmpsf
20411@opindex mno-soft-cmpsf
20412@opindex msoft-cmpsf
20413For single-precision floating-point comparisons, emit an @code{fsub} instruction
20414and test the flags. This is faster than a software comparison, but can
20415get incorrect results in the presence of NaNs, or when two different small
20416numbers are compared such that their difference is calculated as zero.
20417The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
20418software comparisons.
20419
20420@item -mstack-offset=@var{num}
20421@opindex mstack-offset
20422Set the offset between the top of the stack and the stack pointer.
20423E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
20424can be used by leaf functions without stack allocation.
20425Values other than @samp{8} or @samp{16} are untested and unlikely to work.
20426Note also that this option changes the ABI; compiling a program with a
20427different stack offset than the libraries have been compiled with
20428generally does not work.
20429This option can be useful if you want to evaluate if a different stack
20430offset would give you better code, but to actually use a different stack
20431offset to build working programs, it is recommended to configure the
20432toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
20433
20434@item -mno-round-nearest
20435@opindex mno-round-nearest
20436@opindex mround-nearest
20437Make the scheduler assume that the rounding mode has been set to
20438truncating. The default is @option{-mround-nearest}.
20439
20440@item -mlong-calls
20441@opindex mlong-calls
20442If not otherwise specified by an attribute, assume all calls might be beyond
20443the offset range of the @code{b} / @code{bl} instructions, and therefore load the
20444function address into a register before performing a (otherwise direct) call.
20445This is the default.
20446
20447@item -mshort-calls
20448@opindex short-calls
20449If not otherwise specified by an attribute, assume all direct calls are
20450in the range of the @code{b} / @code{bl} instructions, so use these instructions
20451for direct calls. The default is @option{-mlong-calls}.
20452
20453@item -msmall16
20454@opindex msmall16
20455Assume addresses can be loaded as 16-bit unsigned values. This does not
20456apply to function addresses for which @option{-mlong-calls} semantics
20457are in effect.
20458
20459@item -mfp-mode=@var{mode}
20460@opindex mfp-mode
20461Set the prevailing mode of the floating-point unit.
20462This determines the floating-point mode that is provided and expected
20463at function call and return time. Making this mode match the mode you
20464predominantly need at function start can make your programs smaller and
20465faster by avoiding unnecessary mode switches.
20466
20467@var{mode} can be set to one the following values:
20468
20469@table @samp
20470@item caller
20471Any mode at function entry is valid, and retained or restored when
20472the function returns, and when it calls other functions.
20473This mode is useful for compiling libraries or other compilation units
20474you might want to incorporate into different programs with different
20475prevailing FPU modes, and the convenience of being able to use a single
20476object file outweighs the size and speed overhead for any extra
20477mode switching that might be needed, compared with what would be needed
20478with a more specific choice of prevailing FPU mode.
20479
20480@item truncate
20481This is the mode used for floating-point calculations with
20482truncating (i.e.@: round towards zero) rounding mode. That includes
20483conversion from floating point to integer.
20484
20485@item round-nearest
20486This is the mode used for floating-point calculations with
20487round-to-nearest-or-even rounding mode.
20488
20489@item int
20490This is the mode used to perform integer calculations in the FPU, e.g.@:
20491integer multiply, or integer multiply-and-accumulate.
20492@end table
20493
20494The default is @option{-mfp-mode=caller}
20495
20496@item -mno-split-lohi
20497@itemx -mno-postinc
20498@itemx -mno-postmodify
20499@opindex mno-split-lohi
20500@opindex msplit-lohi
20501@opindex mno-postinc
20502@opindex mpostinc
20503@opindex mno-postmodify
20504@opindex mpostmodify
20505Code generation tweaks that disable, respectively, splitting of 32-bit
20506loads, generation of post-increment addresses, and generation of
20507post-modify addresses. The defaults are @option{msplit-lohi},
20508@option{-mpost-inc}, and @option{-mpost-modify}.
20509
20510@item -mnovect-double
20511@opindex mno-vect-double
20512@opindex mvect-double
20513Change the preferred SIMD mode to SImode. The default is
20514@option{-mvect-double}, which uses DImode as preferred SIMD mode.
20515
20516@item -max-vect-align=@var{num}
20517@opindex max-vect-align
20518The maximum alignment for SIMD vector mode types.
20519@var{num} may be 4 or 8. The default is 8.
20520Note that this is an ABI change, even though many library function
20521interfaces are unaffected if they don't use SIMD vector modes
20522in places that affect size and/or alignment of relevant types.
20523
20524@item -msplit-vecmove-early
20525@opindex msplit-vecmove-early
20526Split vector moves into single word moves before reload. In theory this
20527can give better register allocation, but so far the reverse seems to be
20528generally the case.
20529
20530@item -m1reg-@var{reg}
20531@opindex m1reg-
20532Specify a register to hold the constant @minus{}1, which makes loading small negative
20533constants and certain bitmasks faster.
20534Allowable values for @var{reg} are @samp{r43} and @samp{r63},
20535which specify use of that register as a fixed register,
20536and @samp{none}, which means that no register is used for this
20537purpose. The default is @option{-m1reg-none}.
20538
20539@end table
20540
20541@node AMD GCN Options
20542@subsection AMD GCN Options
20543@cindex AMD GCN Options
20544
20545These options are defined specifically for the AMD GCN port.
20546
20547@table @gcctabopt
20548
20549@item -march=@var{gpu}
20550@opindex march
20551@itemx -mtune=@var{gpu}
20552@opindex mtune
20553Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
20554are
20555
20556@table @samp
20557@item fiji
20558Compile for GCN3 Fiji devices (gfx803).
20559
20560@item gfx900
20561Compile for GCN5 Vega 10 devices (gfx900).
20562
20563@item gfx906
20564Compile for GCN5 Vega 20 devices (gfx906).
20565
20566@item gfx908
20567Compile for CDNA1 Instinct MI100 series devices (gfx908).
20568
20569@item gfx90a
20570Compile for CDNA2 Instinct MI200 series devices (gfx90a).
20571
20572@end table
20573
20574@item -msram-ecc=on
20575@itemx -msram-ecc=off
20576@itemx -msram-ecc=any
20577@opindex msram-ecc
20578Compile binaries suitable for devices with the SRAM-ECC feature enabled,
20579disabled, or either mode. This feature can be enabled per-process on some
20580devices. The compiled code must match the device mode. The default is
20581@samp{any}, for devices that support it.
20582
20583@item -mstack-size=@var{bytes}
20584@opindex mstack-size
20585Specify how many @var{bytes} of stack space will be requested for each GPU
20586thread (wave-front). Beware that there may be many threads and limited memory
20587available. The size of the stack allocation may also have an impact on
20588run-time performance. The default is 32KB when using OpenACC or OpenMP, and
205891MB otherwise.
20590
20591@item -mxnack
20592@opindex mxnack
20593Compile binaries suitable for devices with the XNACK feature enabled. Some
20594devices always require XNACK and some allow the user to configure XNACK. The
20595compiled code must match the device mode. The default is @samp{-mno-xnack}.
20596At present this option is a placeholder for support that is not yet
20597implemented.
20598
20599@end table
20600
20601@node ARC Options
20602@subsection ARC Options
20603@cindex ARC options
20604
20605The following options control the architecture variant for which code
20606is being compiled:
20607
20608@c architecture variants
20609@table @gcctabopt
20610
20611@item -mbarrel-shifter
20612@opindex mbarrel-shifter
20613Generate instructions supported by barrel shifter. This is the default
20614unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
20615
20616@item -mjli-always
20617@opindex mjli-always
20618Force to call a function using jli_s instruction. This option is
20619valid only for ARCv2 architecture.
20620
20621@item -mcpu=@var{cpu}
20622@opindex mcpu
20623Set architecture type, register usage, and instruction scheduling
20624parameters for @var{cpu}. There are also shortcut alias options
20625available for backward compatibility and convenience. Supported
20626values for @var{cpu} are
20627
20628@table @samp
20629@opindex mA6
20630@opindex mARC600
20631@item arc600
20632Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
20633
20634@item arc601
20635@opindex mARC601
20636Compile for ARC601. Alias: @option{-mARC601}.
20637
20638@item arc700
20639@opindex mA7
20640@opindex mARC700
20641Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
20642This is the default when configured with @option{--with-cpu=arc700}@.
20643
20644@item arcem
20645Compile for ARC EM.
20646
20647@item archs
20648Compile for ARC HS.
20649
20650@item em
20651Compile for ARC EM CPU with no hardware extensions.
20652
20653@item em4
20654Compile for ARC EM4 CPU.
20655
20656@item em4_dmips
20657Compile for ARC EM4 DMIPS CPU.
20658
20659@item em4_fpus
20660Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
20661extension.
20662
20663@item em4_fpuda
20664Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
20665double assist instructions.
20666
20667@item hs
20668Compile for ARC HS CPU with no hardware extensions except the atomic
20669instructions.
20670
20671@item hs34
20672Compile for ARC HS34 CPU.
20673
20674@item hs38
20675Compile for ARC HS38 CPU.
20676
20677@item hs38_linux
20678Compile for ARC HS38 CPU with all hardware extensions on.
20679
20680@item hs4x
20681Compile for ARC HS4x CPU.
20682
20683@item hs4xd
20684Compile for ARC HS4xD CPU.
20685
20686@item hs4x_rel31
20687Compile for ARC HS4x CPU release 3.10a.
20688
20689@item arc600_norm
20690Compile for ARC 600 CPU with @code{norm} instructions enabled.
20691
20692@item arc600_mul32x16
20693Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
20694instructions enabled.
20695
20696@item arc600_mul64
20697Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
20698instructions enabled.
20699
20700@item arc601_norm
20701Compile for ARC 601 CPU with @code{norm} instructions enabled.
20702
20703@item arc601_mul32x16
20704Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
20705instructions enabled.
20706
20707@item arc601_mul64
20708Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
20709instructions enabled.
20710
20711@item nps400
20712Compile for ARC 700 on NPS400 chip.
20713
20714@item em_mini
20715Compile for ARC EM minimalist configuration featuring reduced register
20716set.
20717
20718@end table
20719
20720@item -mdpfp
20721@opindex mdpfp
20722@itemx -mdpfp-compact
20723@opindex mdpfp-compact
20724Generate double-precision FPX instructions, tuned for the compact
20725implementation.
20726
20727@item -mdpfp-fast
20728@opindex mdpfp-fast
20729Generate double-precision FPX instructions, tuned for the fast
20730implementation.
20731
20732@item -mno-dpfp-lrsr
20733@opindex mno-dpfp-lrsr
20734Disable @code{lr} and @code{sr} instructions from using FPX extension
20735aux registers.
20736
20737@item -mea
20738@opindex mea
20739Generate extended arithmetic instructions. Currently only
20740@code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
20741supported. Only valid for @option{-mcpu=ARC700}.
20742
20743@item -mno-mpy
20744@opindex mno-mpy
20745@opindex mmpy
20746Do not generate @code{mpy}-family instructions for ARC700. This option is
20747deprecated.
20748
20749@item -mmul32x16
20750@opindex mmul32x16
20751Generate 32x16-bit multiply and multiply-accumulate instructions.
20752
20753@item -mmul64
20754@opindex mmul64
20755Generate @code{mul64} and @code{mulu64} instructions.
20756Only valid for @option{-mcpu=ARC600}.
20757
20758@item -mnorm
20759@opindex mnorm
20760Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
20761is in effect.
20762
20763@item -mspfp
20764@opindex mspfp
20765@itemx -mspfp-compact
20766@opindex mspfp-compact
20767Generate single-precision FPX instructions, tuned for the compact
20768implementation.
20769
20770@item -mspfp-fast
20771@opindex mspfp-fast
20772Generate single-precision FPX instructions, tuned for the fast
20773implementation.
20774
20775@item -msimd
20776@opindex msimd
20777Enable generation of ARC SIMD instructions via target-specific
20778builtins. Only valid for @option{-mcpu=ARC700}.
20779
20780@item -msoft-float
20781@opindex msoft-float
20782This option ignored; it is provided for compatibility purposes only.
20783Software floating-point code is emitted by default, and this default
20784can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
20785@option{-mspfp-fast} for single precision, and @option{-mdpfp},
20786@option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
20787
20788@item -mswap
20789@opindex mswap
20790Generate @code{swap} instructions.
20791
20792@item -matomic
20793@opindex matomic
20794This enables use of the locked load/store conditional extension to implement
20795atomic memory built-in functions. Not available for ARC 6xx or ARC
20796EM cores.
20797
20798@item -mdiv-rem
20799@opindex mdiv-rem
20800Enable @code{div} and @code{rem} instructions for ARCv2 cores.
20801
20802@item -mcode-density
20803@opindex mcode-density
20804Enable code density instructions for ARC EM.
20805This option is on by default for ARC HS.
20806
20807@item -mll64
20808@opindex mll64
20809Enable double load/store operations for ARC HS cores.
20810
20811@item -mtp-regno=@var{regno}
20812@opindex mtp-regno
20813Specify thread pointer register number.
20814
20815@item -mmpy-option=@var{multo}
20816@opindex mmpy-option
20817Compile ARCv2 code with a multiplier design option. You can specify
20818the option using either a string or numeric value for @var{multo}.
20819@samp{wlh1} is the default value. The recognized values are:
20820
20821@table @samp
20822@item 0
20823@itemx none
20824No multiplier available.
20825
20826@item 1
20827@itemx w
2082816x16 multiplier, fully pipelined.
20829The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
20830
20831@item 2
20832@itemx wlh1
2083332x32 multiplier, fully
20834pipelined (1 stage). The following instructions are additionally
20835enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20836
20837@item 3
20838@itemx wlh2
2083932x32 multiplier, fully pipelined
20840(2 stages). The following instructions are additionally enabled: @code{mpy},
20841@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20842
20843@item 4
20844@itemx wlh3
20845Two 16x16 multipliers, blocking,
20846sequential. The following instructions are additionally enabled: @code{mpy},
20847@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20848
20849@item 5
20850@itemx wlh4
20851One 16x16 multiplier, blocking,
20852sequential. The following instructions are additionally enabled: @code{mpy},
20853@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20854
20855@item 6
20856@itemx wlh5
20857One 32x4 multiplier, blocking,
20858sequential. The following instructions are additionally enabled: @code{mpy},
20859@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20860
20861@item 7
20862@itemx plus_dmpy
20863ARC HS SIMD support.
20864
20865@item 8
20866@itemx plus_macd
20867ARC HS SIMD support.
20868
20869@item 9
20870@itemx plus_qmacw
20871ARC HS SIMD support.
20872
20873@end table
20874
20875This option is only available for ARCv2 cores@.
20876
20877@item -mfpu=@var{fpu}
20878@opindex mfpu
20879Enables support for specific floating-point hardware extensions for ARCv2
20880cores. Supported values for @var{fpu} are:
20881
20882@table @samp
20883
20884@item fpus
20885Enables support for single-precision floating-point hardware
20886extensions@.
20887
20888@item fpud
20889Enables support for double-precision floating-point hardware
20890extensions. The single-precision floating-point extension is also
20891enabled. Not available for ARC EM@.
20892
20893@item fpuda
20894Enables support for double-precision floating-point hardware
20895extensions using double-precision assist instructions. The single-precision
20896floating-point extension is also enabled. This option is
20897only available for ARC EM@.
20898
20899@item fpuda_div
20900Enables support for double-precision floating-point hardware
20901extensions using double-precision assist instructions.
20902The single-precision floating-point, square-root, and divide
20903extensions are also enabled. This option is
20904only available for ARC EM@.
20905
20906@item fpuda_fma
20907Enables support for double-precision floating-point hardware
20908extensions using double-precision assist instructions.
20909The single-precision floating-point and fused multiply and add
20910hardware extensions are also enabled. This option is
20911only available for ARC EM@.
20912
20913@item fpuda_all
20914Enables support for double-precision floating-point hardware
20915extensions using double-precision assist instructions.
20916All single-precision floating-point hardware extensions are also
20917enabled. This option is only available for ARC EM@.
20918
20919@item fpus_div
20920Enables support for single-precision floating-point, square-root and divide
20921hardware extensions@.
20922
20923@item fpud_div
20924Enables support for double-precision floating-point, square-root and divide
20925hardware extensions. This option
20926includes option @samp{fpus_div}. Not available for ARC EM@.
20927
20928@item fpus_fma
20929Enables support for single-precision floating-point and
20930fused multiply and add hardware extensions@.
20931
20932@item fpud_fma
20933Enables support for double-precision floating-point and
20934fused multiply and add hardware extensions. This option
20935includes option @samp{fpus_fma}. Not available for ARC EM@.
20936
20937@item fpus_all
20938Enables support for all single-precision floating-point hardware
20939extensions@.
20940
20941@item fpud_all
20942Enables support for all single- and double-precision floating-point
20943hardware extensions. Not available for ARC EM@.
20944
20945@end table
20946
20947@item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
20948@opindex mirq-ctrl-saved
20949Specifies general-purposes registers that the processor automatically
20950saves/restores on interrupt entry and exit. @var{register-range} is
20951specified as two registers separated by a dash. The register range
20952always starts with @code{r0}, the upper limit is @code{fp} register.
20953@var{blink} and @var{lp_count} are optional. This option is only
20954valid for ARC EM and ARC HS cores.
20955
20956@item -mrgf-banked-regs=@var{number}
20957@opindex mrgf-banked-regs
20958Specifies the number of registers replicated in second register bank
20959on entry to fast interrupt. Fast interrupts are interrupts with the
20960highest priority level P0. These interrupts save only PC and STATUS32
20961registers to avoid memory transactions during interrupt entry and exit
20962sequences. Use this option when you are using fast interrupts in an
20963ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
20964
20965@item -mlpc-width=@var{width}
20966@opindex mlpc-width
20967Specify the width of the @code{lp_count} register. Valid values for
20968@var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
20969fixed to 32 bits. If the width is less than 32, the compiler does not
20970attempt to transform loops in your program to use the zero-delay loop
20971mechanism unless it is known that the @code{lp_count} register can
20972hold the required loop-counter value. Depending on the width
20973specified, the compiler and run-time library might continue to use the
20974loop mechanism for various needs. This option defines macro
20975@code{__ARC_LPC_WIDTH__} with the value of @var{width}.
20976
20977@item -mrf16
20978@opindex mrf16
20979This option instructs the compiler to generate code for a 16-entry
20980register file. This option defines the @code{__ARC_RF16__}
20981preprocessor macro.
20982
20983@item -mbranch-index
20984@opindex mbranch-index
20985Enable use of @code{bi} or @code{bih} instructions to implement jump
20986tables.
20987
20988@end table
20989
20990The following options are passed through to the assembler, and also
20991define preprocessor macro symbols.
20992
20993@c Flags used by the assembler, but for which we define preprocessor
20994@c macro symbols as well.
20995@table @gcctabopt
20996@item -mdsp-packa
20997@opindex mdsp-packa
20998Passed down to the assembler to enable the DSP Pack A extensions.
20999Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
21000deprecated.
21001
21002@item -mdvbf
21003@opindex mdvbf
21004Passed down to the assembler to enable the dual Viterbi butterfly
21005extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
21006option is deprecated.
21007
21008@c ARC700 4.10 extension instruction
21009@item -mlock
21010@opindex mlock
21011Passed down to the assembler to enable the locked load/store
21012conditional extension. Also sets the preprocessor symbol
21013@code{__Xlock}.
21014
21015@item -mmac-d16
21016@opindex mmac-d16
21017Passed down to the assembler. Also sets the preprocessor symbol
21018@code{__Xxmac_d16}. This option is deprecated.
21019
21020@item -mmac-24
21021@opindex mmac-24
21022Passed down to the assembler. Also sets the preprocessor symbol
21023@code{__Xxmac_24}. This option is deprecated.
21024
21025@c ARC700 4.10 extension instruction
21026@item -mrtsc
21027@opindex mrtsc
21028Passed down to the assembler to enable the 64-bit time-stamp counter
21029extension instruction. Also sets the preprocessor symbol
21030@code{__Xrtsc}. This option is deprecated.
21031
21032@c ARC700 4.10 extension instruction
21033@item -mswape
21034@opindex mswape
21035Passed down to the assembler to enable the swap byte ordering
21036extension instruction. Also sets the preprocessor symbol
21037@code{__Xswape}.
21038
21039@item -mtelephony
21040@opindex mtelephony
21041Passed down to the assembler to enable dual- and single-operand
21042instructions for telephony. Also sets the preprocessor symbol
21043@code{__Xtelephony}. This option is deprecated.
21044
21045@item -mxy
21046@opindex mxy
21047Passed down to the assembler to enable the XY memory extension. Also
21048sets the preprocessor symbol @code{__Xxy}.
21049
21050@end table
21051
21052The following options control how the assembly code is annotated:
21053
21054@c Assembly annotation options
21055@table @gcctabopt
21056@item -misize
21057@opindex misize
21058Annotate assembler instructions with estimated addresses.
21059
21060@item -mannotate-align
21061@opindex mannotate-align
21062Explain what alignment considerations lead to the decision to make an
21063instruction short or long.
21064
21065@end table
21066
21067The following options are passed through to the linker:
21068
21069@c options passed through to the linker
21070@table @gcctabopt
21071@item -marclinux
21072@opindex marclinux
21073Passed through to the linker, to specify use of the @code{arclinux} emulation.
21074This option is enabled by default in tool chains built for
21075@w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
21076when profiling is not requested.
21077
21078@item -marclinux_prof
21079@opindex marclinux_prof
21080Passed through to the linker, to specify use of the
21081@code{arclinux_prof} emulation. This option is enabled by default in
21082tool chains built for @w{@code{arc-linux-uclibc}} and
21083@w{@code{arceb-linux-uclibc}} targets when profiling is requested.
21084
21085@end table
21086
21087The following options control the semantics of generated code:
21088
21089@c semantically relevant code generation options
21090@table @gcctabopt
21091@item -mlong-calls
21092@opindex mlong-calls
21093Generate calls as register indirect calls, thus providing access
21094to the full 32-bit address range.
21095
21096@item -mmedium-calls
21097@opindex mmedium-calls
21098Don't use less than 25-bit addressing range for calls, which is the
21099offset available for an unconditional branch-and-link
21100instruction. Conditional execution of function calls is suppressed, to
21101allow use of the 25-bit range, rather than the 21-bit range with
21102conditional branch-and-link. This is the default for tool chains built
21103for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
21104
21105@item -G @var{num}
21106@opindex G
21107Put definitions of externally-visible data in a small data section if
21108that data is no bigger than @var{num} bytes. The default value of
21109@var{num} is 4 for any ARC configuration, or 8 when we have double
21110load/store operations.
21111
21112@item -mno-sdata
21113@opindex mno-sdata
21114@opindex msdata
21115Do not generate sdata references. This is the default for tool chains
21116built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
21117targets.
21118
21119@item -mvolatile-cache
21120@opindex mvolatile-cache
21121Use ordinarily cached memory accesses for volatile references. This is the
21122default.
21123
21124@item -mno-volatile-cache
21125@opindex mno-volatile-cache
21126@opindex mvolatile-cache
21127Enable cache bypass for volatile references.
21128
21129@end table
21130
21131The following options fine tune code generation:
21132@c code generation tuning options
21133@table @gcctabopt
21134@item -malign-call
21135@opindex malign-call
21136Does nothing. Preserved for backward compatibility.
21137
21138@item -mauto-modify-reg
21139@opindex mauto-modify-reg
21140Enable the use of pre/post modify with register displacement.
21141
21142@item -mbbit-peephole
21143@opindex mbbit-peephole
21144Enable bbit peephole2.
21145
21146@item -mno-brcc
21147@opindex mno-brcc
21148This option disables a target-specific pass in @file{arc_reorg} to
21149generate compare-and-branch (@code{br@var{cc}}) instructions.
21150It has no effect on
21151generation of these instructions driven by the combiner pass.
21152
21153@item -mcase-vector-pcrel
21154@opindex mcase-vector-pcrel
21155Use PC-relative switch case tables to enable case table shortening.
21156This is the default for @option{-Os}.
21157
21158@item -mcompact-casesi
21159@opindex mcompact-casesi
21160Enable compact @code{casesi} pattern. This is the default for @option{-Os},
21161and only available for ARCv1 cores. This option is deprecated.
21162
21163@item -mno-cond-exec
21164@opindex mno-cond-exec
21165Disable the ARCompact-specific pass to generate conditional
21166execution instructions.
21167
21168Due to delay slot scheduling and interactions between operand numbers,
21169literal sizes, instruction lengths, and the support for conditional execution,
21170the target-independent pass to generate conditional execution is often lacking,
21171so the ARC port has kept a special pass around that tries to find more
21172conditional execution generation opportunities after register allocation,
21173branch shortening, and delay slot scheduling have been done. This pass
21174generally, but not always, improves performance and code size, at the cost of
21175extra compilation time, which is why there is an option to switch it off.
21176If you have a problem with call instructions exceeding their allowable
21177offset range because they are conditionalized, you should consider using
21178@option{-mmedium-calls} instead.
21179
21180@item -mearly-cbranchsi
21181@opindex mearly-cbranchsi
21182Enable pre-reload use of the @code{cbranchsi} pattern.
21183
21184@item -mexpand-adddi
21185@opindex mexpand-adddi
21186Expand @code{adddi3} and @code{subdi3} at RTL generation time into
21187@code{add.f}, @code{adc} etc. This option is deprecated.
21188
21189@item -mindexed-loads
21190@opindex mindexed-loads
21191Enable the use of indexed loads. This can be problematic because some
21192optimizers then assume that indexed stores exist, which is not
21193the case.
21194
21195@item -mlra
21196@opindex mlra
21197Enable Local Register Allocation. This is still experimental for ARC,
21198so by default the compiler uses standard reload
21199(i.e.@: @option{-mno-lra}).
21200
21201@item -mlra-priority-none
21202@opindex mlra-priority-none
21203Don't indicate any priority for target registers.
21204
21205@item -mlra-priority-compact
21206@opindex mlra-priority-compact
21207Indicate target register priority for r0..r3 / r12..r15.
21208
21209@item -mlra-priority-noncompact
21210@opindex mlra-priority-noncompact
21211Reduce target register priority for r0..r3 / r12..r15.
21212
21213@item -mmillicode
21214@opindex mmillicode
21215When optimizing for size (using @option{-Os}), prologues and epilogues
21216that have to save or restore a large number of registers are often
21217shortened by using call to a special function in libgcc; this is
21218referred to as a @emph{millicode} call. As these calls can pose
21219performance issues, and/or cause linking issues when linking in a
21220nonstandard way, this option is provided to turn on or off millicode
21221call generation.
21222
21223@item -mcode-density-frame
21224@opindex mcode-density-frame
21225This option enable the compiler to emit @code{enter} and @code{leave}
21226instructions. These instructions are only valid for CPUs with
21227code-density feature.
21228
21229@item -mmixed-code
21230@opindex mmixed-code
21231Does nothing. Preserved for backward compatibility.
21232
21233@item -mq-class
21234@opindex mq-class
21235Ths option is deprecated. Enable @samp{q} instruction alternatives.
21236This is the default for @option{-Os}.
21237
21238@item -mRcq
21239@opindex mRcq
21240Does nothing. Preserved for backward compatibility.
21241
21242@item -mRcw
21243@opindex mRcw
21244Does nothing. Preserved for backward compatibility.
21245
21246@item -msize-level=@var{level}
21247@opindex msize-level
21248Fine-tune size optimization with regards to instruction lengths and alignment.
21249The recognized values for @var{level} are:
21250@table @samp
21251@item 0
21252No size optimization. This level is deprecated and treated like @samp{1}.
21253
21254@item 1
21255Short instructions are used opportunistically.
21256
21257@item 2
21258In addition, alignment of loops and of code after barriers are dropped.
21259
21260@item 3
21261In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
21262
21263@end table
21264
21265This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
21266the behavior when this is not set is equivalent to level @samp{1}.
21267
21268@item -mtune=@var{cpu}
21269@opindex mtune
21270Set instruction scheduling parameters for @var{cpu}, overriding any implied
21271by @option{-mcpu=}.
21272
21273Supported values for @var{cpu} are
21274
21275@table @samp
21276@item ARC600
21277Tune for ARC600 CPU.
21278
21279@item ARC601
21280Tune for ARC601 CPU.
21281
21282@item ARC700
21283Tune for ARC700 CPU with standard multiplier block.
21284
21285@item ARC700-xmac
21286Tune for ARC700 CPU with XMAC block.
21287
21288@item ARC725D
21289Tune for ARC725D CPU.
21290
21291@item ARC750D
21292Tune for ARC750D CPU.
21293
21294@item core3
21295Tune for ARCv2 core3 type CPU. This option enable usage of
21296@code{dbnz} instruction.
21297
21298@item release31a
21299Tune for ARC4x release 3.10a.
21300
21301@end table
21302
21303@item -mmultcost=@var{num}
21304@opindex mmultcost
21305Cost to assume for a multiply instruction, with @samp{4} being equal to a
21306normal instruction.
21307
21308@item -munalign-prob-threshold=@var{probability}
21309@opindex munalign-prob-threshold
21310Does nothing. Preserved for backward compatibility.
21311
21312@end table
21313
21314The following options are maintained for backward compatibility, but
21315are now deprecated and will be removed in a future release:
21316
21317@c Deprecated options
21318@table @gcctabopt
21319
21320@item -margonaut
21321@opindex margonaut
21322Obsolete FPX.
21323
21324@item -mbig-endian
21325@opindex mbig-endian
21326@itemx -EB
21327@opindex EB
21328Compile code for big-endian targets. Use of these options is now
21329deprecated. Big-endian code is supported by configuring GCC to build
21330@w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
21331for which big endian is the default.
21332
21333@item -mlittle-endian
21334@opindex mlittle-endian
21335@itemx -EL
21336@opindex EL
21337Compile code for little-endian targets. Use of these options is now
21338deprecated. Little-endian code is supported by configuring GCC to build
21339@w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
21340for which little endian is the default.
21341
21342@item -mbarrel_shifter
21343@opindex mbarrel_shifter
21344Replaced by @option{-mbarrel-shifter}.
21345
21346@item -mdpfp_compact
21347@opindex mdpfp_compact
21348Replaced by @option{-mdpfp-compact}.
21349
21350@item -mdpfp_fast
21351@opindex mdpfp_fast
21352Replaced by @option{-mdpfp-fast}.
21353
21354@item -mdsp_packa
21355@opindex mdsp_packa
21356Replaced by @option{-mdsp-packa}.
21357
21358@item -mEA
21359@opindex mEA
21360Replaced by @option{-mea}.
21361
21362@item -mmac_24
21363@opindex mmac_24
21364Replaced by @option{-mmac-24}.
21365
21366@item -mmac_d16
21367@opindex mmac_d16
21368Replaced by @option{-mmac-d16}.
21369
21370@item -mspfp_compact
21371@opindex mspfp_compact
21372Replaced by @option{-mspfp-compact}.
21373
21374@item -mspfp_fast
21375@opindex mspfp_fast
21376Replaced by @option{-mspfp-fast}.
21377
21378@item -mtune=@var{cpu}
21379@opindex mtune
21380Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
21381@samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
21382@samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
21383
21384@item -multcost=@var{num}
21385@opindex multcost
21386Replaced by @option{-mmultcost}.
21387
21388@end table
21389
21390@node ARM Options
21391@subsection ARM Options
21392@cindex ARM options
21393
21394These @samp{-m} options are defined for the ARM port:
21395
21396@table @gcctabopt
21397@item -mabi=@var{name}
21398@opindex mabi
21399Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
21400@samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}.
21401
21402@item -mapcs-frame
21403@opindex mapcs-frame
21404Generate a stack frame that is compliant with the ARM Procedure Call
21405Standard for all functions, even if this is not strictly necessary for
21406correct execution of the code. Specifying @option{-fomit-frame-pointer}
21407with this option causes the stack frames not to be generated for
21408leaf functions. The default is @option{-mno-apcs-frame}.
21409This option is deprecated.
21410
21411@item -mapcs
21412@opindex mapcs
21413This is a synonym for @option{-mapcs-frame} and is deprecated.
21414
21415@ignore
21416@c not currently implemented
21417@item -mapcs-stack-check
21418@opindex mapcs-stack-check
21419Generate code to check the amount of stack space available upon entry to
21420every function (that actually uses some stack space). If there is
21421insufficient space available then either the function
21422@code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
21423called, depending upon the amount of stack space required. The runtime
21424system is required to provide these functions. The default is
21425@option{-mno-apcs-stack-check}, since this produces smaller code.
21426
21427@c not currently implemented
21428@item -mapcs-reentrant
21429@opindex mapcs-reentrant
21430Generate reentrant, position-independent code. The default is
21431@option{-mno-apcs-reentrant}.
21432@end ignore
21433
21434@item -mthumb-interwork
21435@opindex mthumb-interwork
21436Generate code that supports calling between the ARM and Thumb
21437instruction sets. Without this option, on pre-v5 architectures, the
21438two instruction sets cannot be reliably used inside one program. The
21439default is @option{-mno-thumb-interwork}, since slightly larger code
21440is generated when @option{-mthumb-interwork} is specified. In AAPCS
21441configurations this option is meaningless.
21442
21443@item -mno-sched-prolog
21444@opindex mno-sched-prolog
21445@opindex msched-prolog
21446Prevent the reordering of instructions in the function prologue, or the
21447merging of those instruction with the instructions in the function's
21448body. This means that all functions start with a recognizable set
21449of instructions (or in fact one of a choice from a small set of
21450different function prologues), and this information can be used to
21451locate the start of functions inside an executable piece of code. The
21452default is @option{-msched-prolog}.
21453
21454@item -mfloat-abi=@var{name}
21455@opindex mfloat-abi
21456Specifies which floating-point ABI to use. Permissible values
21457are: @samp{soft}, @samp{softfp} and @samp{hard}.
21458
21459Specifying @samp{soft} causes GCC to generate output containing
21460library calls for floating-point operations.
21461@samp{softfp} allows the generation of code using hardware floating-point
21462instructions, but still uses the soft-float calling conventions.
21463@samp{hard} allows generation of floating-point instructions
21464and uses FPU-specific calling conventions.
21465
21466The default depends on the specific target configuration. Note that
21467the hard-float and soft-float ABIs are not link-compatible; you must
21468compile your entire program with the same ABI, and link with a
21469compatible set of libraries.
21470
21471@item -mgeneral-regs-only
21472@opindex mgeneral-regs-only
21473Generate code which uses only the general-purpose registers. This will prevent
21474the compiler from using floating-point and Advanced SIMD registers but will not
21475impose any restrictions on the assembler.
21476
21477@item -mlittle-endian
21478@opindex mlittle-endian
21479Generate code for a processor running in little-endian mode. This is
21480the default for all standard configurations.
21481
21482@item -mbig-endian
21483@opindex mbig-endian
21484Generate code for a processor running in big-endian mode; the default is
21485to compile code for a little-endian processor.
21486
21487@item -mbe8
21488@itemx -mbe32
21489@opindex mbe8
21490When linking a big-endian image select between BE8 and BE32 formats.
21491The option has no effect for little-endian images and is ignored. The
21492default is dependent on the selected target architecture. For ARMv6
21493and later architectures the default is BE8, for older architectures
21494the default is BE32. BE32 format has been deprecated by ARM.
21495
21496@item -march=@var{name}@r{[}+extension@dots{}@r{]}
21497@opindex march
21498This specifies the name of the target ARM architecture. GCC uses this
21499name to determine what kind of instructions it can emit when generating
21500assembly code. This option can be used in conjunction with or instead
21501of the @option{-mcpu=} option.
21502
21503Permissible names are:
21504@samp{armv4t},
21505@samp{armv5t}, @samp{armv5te},
21506@samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
21507@samp{armv6z}, @samp{armv6zk},
21508@samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
21509@samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
21510@samp{armv8.4-a},
21511@samp{armv8.5-a},
21512@samp{armv8.6-a},
21513@samp{armv9-a},
21514@samp{armv7-r},
21515@samp{armv8-r},
21516@samp{armv6-m}, @samp{armv6s-m},
21517@samp{armv7-m}, @samp{armv7e-m},
21518@samp{armv8-m.base}, @samp{armv8-m.main},
21519@samp{armv8.1-m.main},
21520@samp{armv9-a},
21521@samp{iwmmxt} and @samp{iwmmxt2}.
21522
21523Additionally, the following architectures, which lack support for the
21524Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
21525
21526Many of the architectures support extensions. These can be added by
21527appending @samp{+@var{extension}} to the architecture name. Extension
21528options are processed in order and capabilities accumulate. An extension
21529will also enable any necessary base extensions
21530upon which it depends. For example, the @samp{+crypto} extension
21531will always enable the @samp{+simd} extension. The exception to the
21532additive construction is for extensions that are prefixed with
21533@samp{+no@dots{}}: these extensions disable the specified option and
21534any other extensions that may depend on the presence of that
21535extension.
21536
21537For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
21538writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
21539entirely disabled by the @samp{+nofp} option that follows it.
21540
21541Most extension names are generically named, but have an effect that is
21542dependent upon the architecture to which it is applied. For example,
21543the @samp{+simd} option can be applied to both @samp{armv7-a} and
21544@samp{armv8-a} architectures, but will enable the original ARMv7-A
21545Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
21546variant for @samp{armv8-a}.
21547
21548The table below lists the supported extensions for each architecture.
21549Architectures not mentioned do not support any extensions.
21550
21551@table @samp
21552@item armv5te
21553@itemx armv6
21554@itemx armv6j
21555@itemx armv6k
21556@itemx armv6kz
21557@itemx armv6t2
21558@itemx armv6z
21559@itemx armv6zk
21560@table @samp
21561@item +fp
21562The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
21563used as an alias for this extension.
21564
21565@item +nofp
21566Disable the floating-point instructions.
21567@end table
21568
21569@item armv7
21570The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
21571@table @samp
21572@item +fp
21573The VFPv3 floating-point instructions, with 16 double-precision
21574registers. The extension @samp{+vfpv3-d16} can be used as an alias
21575for this extension. Note that floating-point is not supported by the
21576base ARMv7-M architecture, but is compatible with both the ARMv7-A and
21577ARMv7-R architectures.
21578
21579@item +nofp
21580Disable the floating-point instructions.
21581@end table
21582
21583@item armv7-a
21584@table @samp
21585@item +mp
21586The multiprocessing extension.
21587
21588@item +sec
21589The security extension.
21590
21591@item +fp
21592The VFPv3 floating-point instructions, with 16 double-precision
21593registers. The extension @samp{+vfpv3-d16} can be used as an alias
21594for this extension.
21595
21596@item +simd
21597The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21598The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
21599for this extension.
21600
21601@item +vfpv3
21602The VFPv3 floating-point instructions, with 32 double-precision
21603registers.
21604
21605@item +vfpv3-d16-fp16
21606The VFPv3 floating-point instructions, with 16 double-precision
21607registers and the half-precision floating-point conversion operations.
21608
21609@item +vfpv3-fp16
21610The VFPv3 floating-point instructions, with 32 double-precision
21611registers and the half-precision floating-point conversion operations.
21612
21613@item +vfpv4-d16
21614The VFPv4 floating-point instructions, with 16 double-precision
21615registers.
21616
21617@item +vfpv4
21618The VFPv4 floating-point instructions, with 32 double-precision
21619registers.
21620
21621@item +neon-fp16
21622The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21623the half-precision floating-point conversion operations.
21624
21625@item +neon-vfpv4
21626The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
21627
21628@item +nosimd
21629Disable the Advanced SIMD instructions (does not disable floating point).
21630
21631@item +nofp
21632Disable the floating-point and Advanced SIMD instructions.
21633@end table
21634
21635@item armv7ve
21636The extended version of the ARMv7-A architecture with support for
21637virtualization.
21638@table @samp
21639@item +fp
21640The VFPv4 floating-point instructions, with 16 double-precision registers.
21641The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
21642
21643@item +simd
21644The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
21645extension @samp{+neon-vfpv4} can be used as an alias for this extension.
21646
21647@item +vfpv3-d16
21648The VFPv3 floating-point instructions, with 16 double-precision
21649registers.
21650
21651@item +vfpv3
21652The VFPv3 floating-point instructions, with 32 double-precision
21653registers.
21654
21655@item +vfpv3-d16-fp16
21656The VFPv3 floating-point instructions, with 16 double-precision
21657registers and the half-precision floating-point conversion operations.
21658
21659@item +vfpv3-fp16
21660The VFPv3 floating-point instructions, with 32 double-precision
21661registers and the half-precision floating-point conversion operations.
21662
21663@item +vfpv4-d16
21664The VFPv4 floating-point instructions, with 16 double-precision
21665registers.
21666
21667@item +vfpv4
21668The VFPv4 floating-point instructions, with 32 double-precision
21669registers.
21670
21671@item +neon
21672The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21673The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
21674
21675@item +neon-fp16
21676The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21677the half-precision floating-point conversion operations.
21678
21679@item +nosimd
21680Disable the Advanced SIMD instructions (does not disable floating point).
21681
21682@item +nofp
21683Disable the floating-point and Advanced SIMD instructions.
21684@end table
21685
21686@item armv8-a
21687@table @samp
21688@item +crc
21689The Cyclic Redundancy Check (CRC) instructions.
21690@item +simd
21691The ARMv8-A Advanced SIMD and floating-point instructions.
21692@item +crypto
21693The cryptographic instructions.
21694@item +nocrypto
21695Disable the cryptographic instructions.
21696@item +nofp
21697Disable the floating-point, Advanced SIMD and cryptographic instructions.
21698@item +sb
21699Speculation Barrier Instruction.
21700@item +predres
21701Execution and Data Prediction Restriction Instructions.
21702@end table
21703
21704@item armv8.1-a
21705@table @samp
21706@item +simd
21707The ARMv8.1-A Advanced SIMD and floating-point instructions.
21708
21709@item +crypto
21710The cryptographic instructions. This also enables the Advanced SIMD and
21711floating-point instructions.
21712
21713@item +nocrypto
21714Disable the cryptographic instructions.
21715
21716@item +nofp
21717Disable the floating-point, Advanced SIMD and cryptographic instructions.
21718
21719@item +sb
21720Speculation Barrier Instruction.
21721
21722@item +predres
21723Execution and Data Prediction Restriction Instructions.
21724@end table
21725
21726@item armv8.2-a
21727@itemx armv8.3-a
21728@table @samp
21729@item +fp16
21730The half-precision floating-point data processing instructions.
21731This also enables the Advanced SIMD and floating-point instructions.
21732
21733@item +fp16fml
21734The half-precision floating-point fmla extension. This also enables
21735the half-precision floating-point extension and Advanced SIMD and
21736floating-point instructions.
21737
21738@item +simd
21739The ARMv8.1-A Advanced SIMD and floating-point instructions.
21740
21741@item +crypto
21742The cryptographic instructions. This also enables the Advanced SIMD and
21743floating-point instructions.
21744
21745@item +dotprod
21746Enable the Dot Product extension. This also enables Advanced SIMD instructions.
21747
21748@item +nocrypto
21749Disable the cryptographic extension.
21750
21751@item +nofp
21752Disable the floating-point, Advanced SIMD and cryptographic instructions.
21753
21754@item +sb
21755Speculation Barrier Instruction.
21756
21757@item +predres
21758Execution and Data Prediction Restriction Instructions.
21759
21760@item +i8mm
217618-bit Integer Matrix Multiply instructions.
21762This also enables Advanced SIMD and floating-point instructions.
21763
21764@item +bf16
21765Brain half-precision floating-point instructions.
21766This also enables Advanced SIMD and floating-point instructions.
21767@end table
21768
21769@item armv8.4-a
21770@table @samp
21771@item +fp16
21772The half-precision floating-point data processing instructions.
21773This also enables the Advanced SIMD and floating-point instructions as well
21774as the Dot Product extension and the half-precision floating-point fmla
21775extension.
21776
21777@item +simd
21778The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21779Dot Product extension.
21780
21781@item +crypto
21782The cryptographic instructions. This also enables the Advanced SIMD and
21783floating-point instructions as well as the Dot Product extension.
21784
21785@item +nocrypto
21786Disable the cryptographic extension.
21787
21788@item +nofp
21789Disable the floating-point, Advanced SIMD and cryptographic instructions.
21790
21791@item +sb
21792Speculation Barrier Instruction.
21793
21794@item +predres
21795Execution and Data Prediction Restriction Instructions.
21796
21797@item +i8mm
217988-bit Integer Matrix Multiply instructions.
21799This also enables Advanced SIMD and floating-point instructions.
21800
21801@item +bf16
21802Brain half-precision floating-point instructions.
21803This also enables Advanced SIMD and floating-point instructions.
21804@end table
21805
21806@item armv8.5-a
21807@table @samp
21808@item +fp16
21809The half-precision floating-point data processing instructions.
21810This also enables the Advanced SIMD and floating-point instructions as well
21811as the Dot Product extension and the half-precision floating-point fmla
21812extension.
21813
21814@item +simd
21815The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21816Dot Product extension.
21817
21818@item +crypto
21819The cryptographic instructions. This also enables the Advanced SIMD and
21820floating-point instructions as well as the Dot Product extension.
21821
21822@item +nocrypto
21823Disable the cryptographic extension.
21824
21825@item +nofp
21826Disable the floating-point, Advanced SIMD and cryptographic instructions.
21827
21828@item +i8mm
218298-bit Integer Matrix Multiply instructions.
21830This also enables Advanced SIMD and floating-point instructions.
21831
21832@item +bf16
21833Brain half-precision floating-point instructions.
21834This also enables Advanced SIMD and floating-point instructions.
21835@end table
21836
21837@item armv8.6-a
21838@table @samp
21839@item +fp16
21840The half-precision floating-point data processing instructions.
21841This also enables the Advanced SIMD and floating-point instructions as well
21842as the Dot Product extension and the half-precision floating-point fmla
21843extension.
21844
21845@item +simd
21846The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21847Dot Product extension.
21848
21849@item +crypto
21850The cryptographic instructions. This also enables the Advanced SIMD and
21851floating-point instructions as well as the Dot Product extension.
21852
21853@item +nocrypto
21854Disable the cryptographic extension.
21855
21856@item +nofp
21857Disable the floating-point, Advanced SIMD and cryptographic instructions.
21858
21859@item +i8mm
218608-bit Integer Matrix Multiply instructions.
21861This also enables Advanced SIMD and floating-point instructions.
21862
21863@item +bf16
21864Brain half-precision floating-point instructions.
21865This also enables Advanced SIMD and floating-point instructions.
21866@end table
21867
21868@item armv7-r
21869@table @samp
21870@item +fp.sp
21871The single-precision VFPv3 floating-point instructions. The extension
21872@samp{+vfpv3xd} can be used as an alias for this extension.
21873
21874@item +fp
21875The VFPv3 floating-point instructions with 16 double-precision registers.
21876The extension +vfpv3-d16 can be used as an alias for this extension.
21877
21878@item +vfpv3xd-d16-fp16
21879The single-precision VFPv3 floating-point instructions with 16 double-precision
21880registers and the half-precision floating-point conversion operations.
21881
21882@item +vfpv3-d16-fp16
21883The VFPv3 floating-point instructions with 16 double-precision
21884registers and the half-precision floating-point conversion operations.
21885
21886@item +nofp
21887Disable the floating-point extension.
21888
21889@item +idiv
21890The ARM-state integer division instructions.
21891
21892@item +noidiv
21893Disable the ARM-state integer division extension.
21894@end table
21895
21896@item armv7e-m
21897@table @samp
21898@item +fp
21899The single-precision VFPv4 floating-point instructions.
21900
21901@item +fpv5
21902The single-precision FPv5 floating-point instructions.
21903
21904@item +fp.dp
21905The single- and double-precision FPv5 floating-point instructions.
21906
21907@item +nofp
21908Disable the floating-point extensions.
21909@end table
21910
21911@item armv8.1-m.main
21912@table @samp
21913
21914@item +dsp
21915The DSP instructions.
21916
21917@item +mve
21918The M-Profile Vector Extension (MVE) integer instructions.
21919
21920@item +mve.fp
21921The M-Profile Vector Extension (MVE) integer and single precision
21922floating-point instructions.
21923
21924@item +fp
21925The single-precision floating-point instructions.
21926
21927@item +fp.dp
21928The single- and double-precision floating-point instructions.
21929
21930@item +nofp
21931Disable the floating-point extension.
21932
21933@item +cdecp0, +cdecp1, ... , +cdecp7
21934Enable the Custom Datapath Extension (CDE) on selected coprocessors according
21935to the numbers given in the options in the range 0 to 7.
21936@end table
21937
21938@item armv8-m.main
21939@table @samp
21940@item +dsp
21941The DSP instructions.
21942
21943@item +nodsp
21944Disable the DSP extension.
21945
21946@item +fp
21947The single-precision floating-point instructions.
21948
21949@item +fp.dp
21950The single- and double-precision floating-point instructions.
21951
21952@item +nofp
21953Disable the floating-point extension.
21954
21955@item +cdecp0, +cdecp1, ... , +cdecp7
21956Enable the Custom Datapath Extension (CDE) on selected coprocessors according
21957to the numbers given in the options in the range 0 to 7.
21958@end table
21959
21960@item armv8-r
21961@table @samp
21962@item +crc
21963The Cyclic Redundancy Check (CRC) instructions.
21964@item +fp.sp
21965The single-precision FPv5 floating-point instructions.
21966@item +simd
21967The ARMv8-A Advanced SIMD and floating-point instructions.
21968@item +crypto
21969The cryptographic instructions.
21970@item +nocrypto
21971Disable the cryptographic instructions.
21972@item +nofp
21973Disable the floating-point, Advanced SIMD and cryptographic instructions.
21974@end table
21975
21976@end table
21977
21978@option{-march=native} causes the compiler to auto-detect the architecture
21979of the build computer. At present, this feature is only supported on
21980GNU/Linux, and not all architectures are recognized. If the auto-detect
21981is unsuccessful the option has no effect.
21982
21983@item -mtune=@var{name}
21984@opindex mtune
21985This option specifies the name of the target ARM processor for
21986which GCC should tune the performance of the code.
21987For some ARM implementations better performance can be obtained by using
21988this option.
21989Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
21990@samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
21991@samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
21992@samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
21993@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
21994@samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
21995@samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
21996@samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
21997@samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
21998@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
21999@samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
22000@samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
22001@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
22002@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
22003@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
22004@samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
22005@samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
22006@samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
22007@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
23a121d4 22008@samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-x1}, @samp{cortex-x1c},
d77de738
ML
22009@samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
22010@samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
22011@samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
22012@samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
22013@samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1},
22014@samp{xgene1}.
22015
22016Additionally, this option can specify that GCC should tune the performance
22017of the code for a big.LITTLE system. Permissible names are:
22018@samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
22019@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22020@samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
22021@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
22022
22023@option{-mtune=generic-@var{arch}} specifies that GCC should tune the
22024performance for a blend of processors within architecture @var{arch}.
22025The aim is to generate code that run well on the current most popular
22026processors, balancing between optimizations that benefit some CPUs in the
22027range, and avoiding performance pitfalls of other CPUs. The effects of
22028this option may change in future GCC versions as CPU models come and go.
22029
22030@option{-mtune} permits the same extension options as @option{-mcpu}, but
22031the extension options do not affect the tuning of the generated code.
22032
22033@option{-mtune=native} causes the compiler to auto-detect the CPU
22034of the build computer. At present, this feature is only supported on
22035GNU/Linux, and not all architectures are recognized. If the auto-detect is
22036unsuccessful the option has no effect.
22037
22038@item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
22039@opindex mcpu
22040This specifies the name of the target ARM processor. GCC uses this name
22041to derive the name of the target ARM architecture (as if specified
22042by @option{-march}) and the ARM processor type for which to tune for
22043performance (as if specified by @option{-mtune}). Where this option
22044is used in conjunction with @option{-march} or @option{-mtune},
22045those options take precedence over the appropriate part of this option.
22046
22047Many of the supported CPUs implement optional architectural
22048extensions. Where this is so the architectural extensions are
22049normally enabled by default. If implementations that lack the
22050extension exist, then the extension syntax can be used to disable
22051those extensions that have been omitted. For floating-point and
22052Advanced SIMD (Neon) instructions, the settings of the options
22053@option{-mfloat-abi} and @option{-mfpu} must also be considered:
22054floating-point and Advanced SIMD instructions will only be used if
22055@option{-mfloat-abi} is not set to @samp{soft}; and any setting of
22056@option{-mfpu} other than @samp{auto} will override the available
22057floating-point and SIMD extension instructions.
22058
22059For example, @samp{cortex-a9} can be found in three major
22060configurations: integer only, with just a floating-point unit or with
22061floating-point and Advanced SIMD. The default is to enable all the
22062instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
22063be used to disable just the SIMD or both the SIMD and floating-point
22064instructions respectively.
22065
22066Permissible names for this option are the same as those for
22067@option{-mtune}.
22068
22069The following extension options are common to the listed CPUs:
22070
22071@table @samp
22072@item +nodsp
22073Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p}
22074and @samp{cortex-m55}. Also disable the M-Profile Vector Extension (MVE)
22075integer and single precision floating-point instructions on @samp{cortex-m55}.
22076
22077@item +nomve
22078Disable the M-Profile Vector Extension (MVE) integer and single precision
22079floating-point instructions on @samp{cortex-m55}.
22080
22081@item +nomve.fp
22082Disable the M-Profile Vector Extension (MVE) single precision floating-point
22083instructions on @samp{cortex-m55}.
22084
22085@item +nofp
22086Disables the floating-point instructions on @samp{arm9e},
22087@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
22088@samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
22089@samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
22090@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}
22091and @samp{cortex-m55}.
22092Disables the floating-point and SIMD instructions on
22093@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
22094@samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
22095@samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
22096@samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
22097@samp{cortex-a53} and @samp{cortex-a55}.
22098
22099@item +nofp.dp
22100Disables the double-precision component of the floating-point instructions
22101on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
22102@samp{cortex-r52plus} and @samp{cortex-m7}.
22103
22104@item +nosimd
22105Disables the SIMD (but not floating-point) instructions on
22106@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
22107and @samp{cortex-a9}.
22108
22109@item +crypto
22110Enables the cryptographic instructions on @samp{cortex-a32},
22111@samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
22112@samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
22113@samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22114@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
22115@samp{cortex-a75.cortex-a55}.
22116@end table
22117
22118Additionally the @samp{generic-armv7-a} pseudo target defaults to
22119VFPv3 with 16 double-precision registers. It supports the following
22120extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
22121@samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
22122@samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
22123@samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
22124the extensions to @option{-march=armv7-a}.
22125
22126@option{-mcpu=generic-@var{arch}} is also permissible, and is
22127equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
22128See @option{-mtune} for more information.
22129
22130@option{-mcpu=native} causes the compiler to auto-detect the CPU
22131of the build computer. At present, this feature is only supported on
22132GNU/Linux, and not all architectures are recognized. If the auto-detect
22133is unsuccessful the option has no effect.
22134
22135@item -mfpu=@var{name}
22136@opindex mfpu
22137This specifies what floating-point hardware (or hardware emulation) is
22138available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
22139@samp{vfpv3},
22140@samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
22141@samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
22142@samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
22143@samp{fpv5-d16}, @samp{fpv5-sp-d16},
22144@samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
22145Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
22146is an alias for @samp{vfpv2}.
22147
22148The setting @samp{auto} is the default and is special. It causes the
22149compiler to select the floating-point and Advanced SIMD instructions
22150based on the settings of @option{-mcpu} and @option{-march}.
22151
22152If the selected floating-point hardware includes the NEON extension
22153(e.g.@: @option{-mfpu=neon}), note that floating-point
22154operations are not generated by GCC's auto-vectorization pass unless
22155@option{-funsafe-math-optimizations} is also specified. This is
22156because NEON hardware does not fully implement the IEEE 754 standard for
22157floating-point arithmetic (in particular denormal values are treated as
22158zero), so the use of NEON instructions may lead to a loss of precision.
22159
22160You 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}).
22161
22162@item -mfp16-format=@var{name}
22163@opindex mfp16-format
22164Specify the format of the @code{__fp16} half-precision floating-point type.
22165Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
22166the default is @samp{none}, in which case the @code{__fp16} type is not
22167defined. @xref{Half-Precision}, for more information.
22168
22169@item -mstructure-size-boundary=@var{n}
22170@opindex mstructure-size-boundary
22171The sizes of all structures and unions are rounded up to a multiple
22172of the number of bits set by this option. Permissible values are 8, 32
22173and 64. The default value varies for different toolchains. For the COFF
22174targeted toolchain the default value is 8. A value of 64 is only allowed
22175if the underlying ABI supports it.
22176
22177Specifying a larger number can produce faster, more efficient code, but
22178can also increase the size of the program. Different values are potentially
22179incompatible. Code compiled with one value cannot necessarily expect to
22180work with code or libraries compiled with another value, if they exchange
22181information using structures or unions.
22182
22183This option is deprecated.
22184
22185@item -mabort-on-noreturn
22186@opindex mabort-on-noreturn
22187Generate a call to the function @code{abort} at the end of a
22188@code{noreturn} function. It is executed if the function tries to
22189return.
22190
22191@item -mlong-calls
22192@itemx -mno-long-calls
22193@opindex mlong-calls
22194@opindex mno-long-calls
22195Tells the compiler to perform function calls by first loading the
22196address of the function into a register and then performing a subroutine
22197call on this register. This switch is needed if the target function
22198lies outside of the 64-megabyte addressing range of the offset-based
22199version of subroutine call instruction.
22200
22201Even if this switch is enabled, not all function calls are turned
22202into long calls. The heuristic is that static functions, functions
22203that have the @code{short_call} attribute, functions that are inside
22204the scope of a @code{#pragma no_long_calls} directive, and functions whose
22205definitions have already been compiled within the current compilation
22206unit are not turned into long calls. The exceptions to this rule are
22207that weak function definitions, functions with the @code{long_call}
22208attribute or the @code{section} attribute, and functions that are within
22209the scope of a @code{#pragma long_calls} directive are always
22210turned into long calls.
22211
22212This feature is not enabled by default. Specifying
22213@option{-mno-long-calls} restores the default behavior, as does
22214placing the function calls within the scope of a @code{#pragma
22215long_calls_off} directive. Note these switches have no effect on how
22216the compiler generates code to handle function calls via function
22217pointers.
22218
22219@item -msingle-pic-base
22220@opindex msingle-pic-base
22221Treat the register used for PIC addressing as read-only, rather than
22222loading it in the prologue for each function. The runtime system is
22223responsible for initializing this register with an appropriate value
22224before execution begins.
22225
22226@item -mpic-register=@var{reg}
22227@opindex mpic-register
22228Specify the register to be used for PIC addressing.
22229For standard PIC base case, the default is any suitable register
22230determined by compiler. For single PIC base case, the default is
22231@samp{R9} if target is EABI based or stack-checking is enabled,
22232otherwise the default is @samp{R10}.
22233
22234@item -mpic-data-is-text-relative
22235@opindex mpic-data-is-text-relative
22236Assume that the displacement between the text and data segments is fixed
22237at static link time. This permits using PC-relative addressing
22238operations to access data known to be in the data segment. For
22239non-VxWorks RTP targets, this option is enabled by default. When
22240disabled on such targets, it will enable @option{-msingle-pic-base} by
22241default.
22242
22243@item -mpoke-function-name
22244@opindex mpoke-function-name
22245Write the name of each function into the text section, directly
22246preceding the function prologue. The generated code is similar to this:
22247
22248@smallexample
22249 t0
22250 .ascii "arm_poke_function_name", 0
22251 .align
22252 t1
22253 .word 0xff000000 + (t1 - t0)
22254 arm_poke_function_name
22255 mov ip, sp
22256 stmfd sp!, @{fp, ip, lr, pc@}
22257 sub fp, ip, #4
22258@end smallexample
22259
22260When performing a stack backtrace, code can inspect the value of
22261@code{pc} stored at @code{fp + 0}. If the trace function then looks at
22262location @code{pc - 12} and the top 8 bits are set, then we know that
22263there is a function name embedded immediately preceding this location
22264and has length @code{((pc[-3]) & 0xff000000)}.
22265
22266@item -mthumb
22267@itemx -marm
22268@opindex marm
22269@opindex mthumb
22270
22271Select between generating code that executes in ARM and Thumb
22272states. The default for most configurations is to generate code
22273that executes in ARM state, but the default can be changed by
22274configuring GCC with the @option{--with-mode=}@var{state}
22275configure option.
22276
22277You can also override the ARM and Thumb mode for each function
22278by using the @code{target("thumb")} and @code{target("arm")} function attributes
22279(@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
22280
22281@item -mflip-thumb
22282@opindex mflip-thumb
22283Switch ARM/Thumb modes on alternating functions.
22284This option is provided for regression testing of mixed Thumb/ARM code
22285generation, and is not intended for ordinary use in compiling code.
22286
22287@item -mtpcs-frame
22288@opindex mtpcs-frame
22289Generate a stack frame that is compliant with the Thumb Procedure Call
22290Standard for all non-leaf functions. (A leaf function is one that does
22291not call any other functions.) The default is @option{-mno-tpcs-frame}.
22292
22293@item -mtpcs-leaf-frame
22294@opindex mtpcs-leaf-frame
22295Generate a stack frame that is compliant with the Thumb Procedure Call
22296Standard for all leaf functions. (A leaf function is one that does
22297not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
22298
22299@item -mcallee-super-interworking
22300@opindex mcallee-super-interworking
22301Gives all externally visible functions in the file being compiled an ARM
22302instruction set header which switches to Thumb mode before executing the
22303rest of the function. This allows these functions to be called from
22304non-interworking code. This option is not valid in AAPCS configurations
22305because interworking is enabled by default.
22306
22307@item -mcaller-super-interworking
22308@opindex mcaller-super-interworking
22309Allows calls via function pointers (including virtual functions) to
22310execute correctly regardless of whether the target code has been
22311compiled for interworking or not. There is a small overhead in the cost
22312of executing a function pointer if this option is enabled. This option
22313is not valid in AAPCS configurations because interworking is enabled
22314by default.
22315
22316@item -mtp=@var{name}
22317@opindex mtp
22318Specify the access model for the thread local storage pointer. The valid
22319models are @samp{soft}, which generates calls to @code{__aeabi_read_tp},
22320@samp{cp15}, which fetches the thread pointer from @code{cp15} directly
22321(supported in the arm6k architecture), and @samp{auto}, which uses the
22322best available method for the selected processor. The default setting is
22323@samp{auto}.
22324
22325@item -mtls-dialect=@var{dialect}
22326@opindex mtls-dialect
22327Specify the dialect to use for accessing thread local storage. Two
22328@var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
22329@samp{gnu} dialect selects the original GNU scheme for supporting
22330local and global dynamic TLS models. The @samp{gnu2} dialect
22331selects the GNU descriptor scheme, which provides better performance
22332for shared libraries. The GNU descriptor scheme is compatible with
22333the original scheme, but does require new assembler, linker and
22334library support. Initial and local exec TLS models are unaffected by
22335this option and always use the original scheme.
22336
22337@item -mword-relocations
22338@opindex mword-relocations
22339Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
22340This is enabled by default on targets (uClinux, SymbianOS) where the runtime
22341loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
22342is specified. This option conflicts with @option{-mslow-flash-data}.
22343
22344@item -mfix-cortex-m3-ldrd
22345@opindex mfix-cortex-m3-ldrd
22346Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
22347with overlapping destination and base registers are used. This option avoids
22348generating these instructions. This option is enabled by default when
22349@option{-mcpu=cortex-m3} is specified.
22350
22351@item -mfix-cortex-a57-aes-1742098
22352@itemx -mno-fix-cortex-a57-aes-1742098
22353@itemx -mfix-cortex-a72-aes-1655431
22354@itemx -mno-fix-cortex-a72-aes-1655431
22355Enable (disable) mitigation for an erratum on Cortex-A57 and
22356Cortex-A72 that affects the AES cryptographic instructions. This
22357option is enabled by default when either @option{-mcpu=cortex-a57} or
22358@option{-mcpu=cortex-a72} is specified.
22359
22360@item -munaligned-access
22361@itemx -mno-unaligned-access
22362@opindex munaligned-access
22363@opindex mno-unaligned-access
22364Enables (or disables) reading and writing of 16- and 32- bit values
22365from addresses that are not 16- or 32- bit aligned. By default
22366unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
22367ARMv8-M Baseline architectures, and enabled for all other
22368architectures. If unaligned access is not enabled then words in packed
22369data structures are accessed a byte at a time.
22370
22371The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
22372generated object file to either true or false, depending upon the
22373setting of this option. If unaligned access is enabled then the
22374preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
22375defined.
22376
22377@item -mneon-for-64bits
22378@opindex mneon-for-64bits
22379This option is deprecated and has no effect.
22380
22381@item -mslow-flash-data
22382@opindex mslow-flash-data
22383Assume loading data from flash is slower than fetching instruction.
22384Therefore literal load is minimized for better performance.
22385This option is only supported when compiling for ARMv7 M-profile and
22386off by default. It conflicts with @option{-mword-relocations}.
22387
22388@item -masm-syntax-unified
22389@opindex masm-syntax-unified
22390Assume inline assembler is using unified asm syntax. The default is
22391currently off which implies divided syntax. This option has no impact
22392on Thumb2. However, this may change in future releases of GCC.
22393Divided syntax should be considered deprecated.
22394
22395@item -mrestrict-it
22396@opindex mrestrict-it
22397Restricts generation of IT blocks to conform to the rules of ARMv8-A.
22398IT blocks can only contain a single 16-bit instruction from a select
22399set of instructions. This option is on by default for ARMv8-A Thumb mode.
22400
22401@item -mprint-tune-info
22402@opindex mprint-tune-info
22403Print CPU tuning information as comment in assembler file. This is
22404an option used only for regression testing of the compiler and not
22405intended for ordinary use in compiling code. This option is disabled
22406by default.
22407
22408@item -mverbose-cost-dump
22409@opindex mverbose-cost-dump
22410Enable verbose cost model dumping in the debug dump files. This option is
22411provided for use in debugging the compiler.
22412
22413@item -mpure-code
22414@opindex mpure-code
22415Do not allow constant data to be placed in code sections.
22416Additionally, when compiling for ELF object format give all text sections the
22417ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
22418is only available when generating non-pic code for M-profile targets.
22419
22420@item -mcmse
22421@opindex mcmse
22422Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
22423Development Tools Engineering Specification", which can be found on
22424@url{https://developer.arm.com/documentation/ecm0359818/latest/}.
22425
22426@item -mfix-cmse-cve-2021-35465
22427@opindex mfix-cmse-cve-2021-35465
22428Mitigate against a potential security issue with the @code{VLLDM} instruction
22429in some M-profile devices when using CMSE (CVE-2021-365465). This option is
22430enabled by default when the option @option{-mcpu=} is used with
22431@code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55} or @code{star-mc1}.
22432The option @option{-mno-fix-cmse-cve-2021-35465} can be used to disable
22433the mitigation.
22434
22435@item -mstack-protector-guard=@var{guard}
22436@itemx -mstack-protector-guard-offset=@var{offset}
22437@opindex mstack-protector-guard
22438@opindex mstack-protector-guard-offset
22439Generate stack protection code using canary at @var{guard}. Supported
22440locations are @samp{global} for a global canary or @samp{tls} for a
22441canary accessible via the TLS register. The option
22442@option{-mstack-protector-guard-offset=} is for use with
22443@option{-fstack-protector-guard=tls} and not for use in user-land code.
22444
22445@item -mfdpic
22446@itemx -mno-fdpic
22447@opindex mfdpic
22448@opindex mno-fdpic
22449Select the FDPIC ABI, which uses 64-bit function descriptors to
22450represent pointers to functions. When the compiler is configured for
22451@code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
22452and implies @option{-fPIE} if none of the PIC/PIE-related options is
22453provided. On other targets, it only enables the FDPIC-specific code
22454generation features, and the user should explicitly provide the
22455PIC/PIE-related options as needed.
22456
22457Note that static linking is not supported because it would still
22458involve the dynamic linker when the program self-relocates. If such
22459behavior is acceptable, use -static and -Wl,-dynamic-linker options.
22460
22461The opposite @option{-mno-fdpic} option is useful (and required) to
22462build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
22463toolchain as the one used to build the userland programs.
22464
22465@end table
22466
22467@node AVR Options
22468@subsection AVR Options
22469@cindex AVR Options
22470
22471These options are defined for AVR implementations:
22472
22473@table @gcctabopt
22474@item -mmcu=@var{mcu}
22475@opindex mmcu
22476Specify Atmel AVR instruction set architectures (ISA) or MCU type.
22477
22478The default for this option is@tie{}@samp{avr2}.
22479
22480GCC supports the following AVR devices and ISAs:
22481
22482@include avr-mmcu.texi
22483
22484@item -mabsdata
22485@opindex mabsdata
22486
22487Assume that all data in static storage can be accessed by LDS / STS
22488instructions. This option has only an effect on reduced Tiny devices like
22489ATtiny40. See also the @code{absdata}
22490@ref{AVR Variable Attributes,variable attribute}.
22491
22492@item -maccumulate-args
22493@opindex maccumulate-args
22494Accumulate outgoing function arguments and acquire/release the needed
22495stack space for outgoing function arguments once in function
22496prologue/epilogue. Without this option, outgoing arguments are pushed
22497before calling a function and popped afterwards.
22498
22499Popping the arguments after the function call can be expensive on
22500AVR so that accumulating the stack space might lead to smaller
22501executables because arguments need not be removed from the
22502stack after such a function call.
22503
22504This option can lead to reduced code size for functions that perform
22505several calls to functions that get their arguments on the stack like
22506calls to printf-like functions.
22507
22508@item -mbranch-cost=@var{cost}
22509@opindex mbranch-cost
22510Set the branch costs for conditional branch instructions to
22511@var{cost}. Reasonable values for @var{cost} are small, non-negative
22512integers. The default branch cost is 0.
22513
22514@item -mcall-prologues
22515@opindex mcall-prologues
22516Functions prologues/epilogues are expanded as calls to appropriate
22517subroutines. Code size is smaller.
22518
22519@item -mdouble=@var{bits}
22520@itemx -mlong-double=@var{bits}
22521@opindex mdouble
22522@opindex mlong-double
22523Set the size (in bits) of the @code{double} or @code{long double} type,
22524respectively. Possible values for @var{bits} are 32 and 64.
22525Whether or not a specific value for @var{bits} is allowed depends on
22526the @code{--with-double=} and @code{--with-long-double=}
22527@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
22528and the same applies for the default values of the options.
22529
22530@item -mgas-isr-prologues
22531@opindex mgas-isr-prologues
22532Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
22533instruction supported by GNU Binutils.
22534If this option is on, the feature can still be disabled for individual
22535ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
22536function attribute. This feature is activated per default
22537if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
22538and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
22539
22540@item -mint8
22541@opindex mint8
22542Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
22543@code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
22544and @code{long long} is 4 bytes. Please note that this option does not
22545conform to the C standards, but it results in smaller code
22546size.
22547
22548@item -mmain-is-OS_task
22549@opindex mmain-is-OS_task
22550Do not save registers in @code{main}. The effect is the same like
22551attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
22552to @code{main}. It is activated per default if optimization is on.
22553
22554@item -mn-flash=@var{num}
22555@opindex mn-flash
22556Assume that the flash memory has a size of
22557@var{num} times 64@tie{}KiB.
22558
22559@item -mno-interrupts
22560@opindex mno-interrupts
22561Generated code is not compatible with hardware interrupts.
22562Code size is smaller.
22563
22564@item -mrelax
22565@opindex mrelax
22566Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
22567@code{RCALL} resp.@: @code{RJMP} instruction if applicable.
22568Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
22569the assembler's command line and the @option{--relax} option to the
22570linker's command line.
22571
22572Jump relaxing is performed by the linker because jump offsets are not
22573known before code is located. Therefore, the assembler code generated by the
22574compiler is the same, but the instructions in the executable may
22575differ from instructions in the assembler code.
22576
22577Relaxing must be turned on if linker stubs are needed, see the
22578section on @code{EIND} and linker stubs below.
22579
22580@item -mrmw
22581@opindex mrmw
22582Assume that the device supports the Read-Modify-Write
22583instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
22584
22585@item -mshort-calls
22586@opindex mshort-calls
22587
22588Assume that @code{RJMP} and @code{RCALL} can target the whole
22589program memory.
22590
22591This option is used internally for multilib selection. It is
22592not an optimization option, and you don't need to set it by hand.
22593
22594@item -msp8
22595@opindex msp8
22596Treat the stack pointer register as an 8-bit register,
22597i.e.@: assume the high byte of the stack pointer is zero.
22598In general, you don't need to set this option by hand.
22599
22600This option is used internally by the compiler to select and
22601build multilibs for architectures @code{avr2} and @code{avr25}.
22602These architectures mix devices with and without @code{SPH}.
22603For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25}
22604the compiler driver adds or removes this option from the compiler
22605proper's command line, because the compiler then knows if the device
22606or architecture has an 8-bit stack pointer and thus no @code{SPH}
22607register or not.
22608
22609@item -mstrict-X
22610@opindex mstrict-X
22611Use address register @code{X} in a way proposed by the hardware. This means
22612that @code{X} is only used in indirect, post-increment or
22613pre-decrement addressing.
22614
22615Without this option, the @code{X} register may be used in the same way
22616as @code{Y} or @code{Z} which then is emulated by additional
22617instructions.
22618For example, loading a value with @code{X+const} addressing with a
22619small non-negative @code{const < 64} to a register @var{Rn} is
22620performed as
22621
22622@example
22623adiw r26, const ; X += const
22624ld @var{Rn}, X ; @var{Rn} = *X
22625sbiw r26, const ; X -= const
22626@end example
22627
22628@item -mtiny-stack
22629@opindex mtiny-stack
22630Only change the lower 8@tie{}bits of the stack pointer.
22631
22632@item -mfract-convert-truncate
22633@opindex mfract-convert-truncate
22634Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
22635
22636@item -nodevicelib
22637@opindex nodevicelib
22638Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}.
22639
22640@item -nodevicespecs
22641@opindex nodevicespecs
22642Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
22643command line. The user takes responsibility for supplying the sub-processes
22644like compiler proper, assembler and linker with appropriate command line
22645options. This means that the user has to supply her private device specs
22646file by means of @option{-specs=@var{path-to-specs-file}}. There is no
22647more need for option @option{-mmcu=@var{mcu}}.
22648
22649This option can also serve as a replacement for the older way of
22650specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
22651which contains a folder named @code{device-specs} which contains a specs file named
22652@code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
22653
22654@item -Waddr-space-convert
22655@opindex Waddr-space-convert
22656@opindex Wno-addr-space-convert
22657Warn about conversions between address spaces in the case where the
22658resulting address space is not contained in the incoming address space.
22659
22660@item -Wmisspelled-isr
22661@opindex Wmisspelled-isr
22662@opindex Wno-misspelled-isr
22663Warn if the ISR is misspelled, i.e.@: without __vector prefix.
22664Enabled by default.
22665@end table
22666
22667@subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
22668@cindex @code{EIND}
22669Pointers in the implementation are 16@tie{}bits wide.
22670The address of a function or label is represented as word address so
22671that indirect jumps and calls can target any code address in the
22672range of 64@tie{}Ki words.
22673
22674In order to facilitate indirect jump on devices with more than 128@tie{}Ki
22675bytes of program memory space, there is a special function register called
22676@code{EIND} that serves as most significant part of the target address
22677when @code{EICALL} or @code{EIJMP} instructions are used.
22678
22679Indirect jumps and calls on these devices are handled as follows by
22680the compiler and are subject to some limitations:
22681
22682@itemize @bullet
22683
22684@item
22685The compiler never sets @code{EIND}.
22686
22687@item
22688The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
22689instructions or might read @code{EIND} directly in order to emulate an
22690indirect call/jump by means of a @code{RET} instruction.
22691
22692@item
22693The compiler assumes that @code{EIND} never changes during the startup
22694code or during the application. In particular, @code{EIND} is not
22695saved/restored in function or interrupt service routine
22696prologue/epilogue.
22697
22698@item
22699For indirect calls to functions and computed goto, the linker
22700generates @emph{stubs}. Stubs are jump pads sometimes also called
22701@emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
22702The stub contains a direct jump to the desired address.
22703
22704@item
22705Linker relaxation must be turned on so that the linker generates
22706the stubs correctly in all situations. See the compiler option
22707@option{-mrelax} and the linker option @option{--relax}.
22708There are corner cases where the linker is supposed to generate stubs
22709but aborts without relaxation and without a helpful error message.
22710
22711@item
22712The default linker script is arranged for code with @code{EIND = 0}.
22713If code is supposed to work for a setup with @code{EIND != 0}, a custom
22714linker script has to be used in order to place the sections whose
22715name start with @code{.trampolines} into the segment where @code{EIND}
22716points to.
22717
22718@item
22719The startup code from libgcc never sets @code{EIND}.
22720Notice that startup code is a blend of code from libgcc and AVR-LibC.
22721For the impact of AVR-LibC on @code{EIND}, see the
22722@w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}.
22723
22724@item
22725It is legitimate for user-specific startup code to set up @code{EIND}
22726early, for example by means of initialization code located in
22727section @code{.init3}. Such code runs prior to general startup code
22728that initializes RAM and calls constructors, but after the bit
22729of startup code from AVR-LibC that sets @code{EIND} to the segment
22730where the vector table is located.
22731@example
22732#include <avr/io.h>
22733
22734static void
22735__attribute__((section(".init3"),naked,used,no_instrument_function))
22736init3_set_eind (void)
22737@{
22738 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
22739 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
22740@}
22741@end example
22742
22743@noindent
22744The @code{__trampolines_start} symbol is defined in the linker script.
22745
22746@item
22747Stubs are generated automatically by the linker if
22748the following two conditions are met:
22749@itemize @minus
22750
22751@item The address of a label is taken by means of the @code{gs} modifier
22752(short for @emph{generate stubs}) like so:
22753@example
22754LDI r24, lo8(gs(@var{func}))
22755LDI r25, hi8(gs(@var{func}))
22756@end example
22757@item The final location of that label is in a code segment
22758@emph{outside} the segment where the stubs are located.
22759@end itemize
22760
22761@item
22762The compiler emits such @code{gs} modifiers for code labels in the
22763following situations:
22764@itemize @minus
22765@item Taking address of a function or code label.
22766@item Computed goto.
22767@item If prologue-save function is used, see @option{-mcall-prologues}
22768command-line option.
22769@item Switch/case dispatch tables. If you do not want such dispatch
22770tables you can specify the @option{-fno-jump-tables} command-line option.
22771@item C and C++ constructors/destructors called during startup/shutdown.
22772@item If the tools hit a @code{gs()} modifier explained above.
22773@end itemize
22774
22775@item
22776Jumping to non-symbolic addresses like so is @emph{not} supported:
22777
22778@example
22779int main (void)
22780@{
22781 /* Call function at word address 0x2 */
22782 return ((int(*)(void)) 0x2)();
22783@}
22784@end example
22785
22786Instead, a stub has to be set up, i.e.@: the function has to be called
22787through a symbol (@code{func_4} in the example):
22788
22789@example
22790int main (void)
22791@{
22792 extern int func_4 (void);
22793
22794 /* Call function at byte address 0x4 */
22795 return func_4();
22796@}
22797@end example
22798
22799and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
22800Alternatively, @code{func_4} can be defined in the linker script.
22801@end itemize
22802
22803@subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
22804@cindex @code{RAMPD}
22805@cindex @code{RAMPX}
22806@cindex @code{RAMPY}
22807@cindex @code{RAMPZ}
22808Some AVR devices support memories larger than the 64@tie{}KiB range
22809that can be accessed with 16-bit pointers. To access memory locations
22810outside this 64@tie{}KiB range, the content of a @code{RAMP}
22811register is used as high part of the address:
22812The @code{X}, @code{Y}, @code{Z} address register is concatenated
22813with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
22814register, respectively, to get a wide address. Similarly,
22815@code{RAMPD} is used together with direct addressing.
22816
22817@itemize
22818@item
22819The startup code initializes the @code{RAMP} special function
22820registers with zero.
22821
22822@item
22823If a @ref{AVR Named Address Spaces,named address space} other than
22824generic or @code{__flash} is used, then @code{RAMPZ} is set
22825as needed before the operation.
22826
22827@item
22828If the device supports RAM larger than 64@tie{}KiB and the compiler
22829needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
22830is reset to zero after the operation.
22831
22832@item
22833If the device comes with a specific @code{RAMP} register, the ISR
22834prologue/epilogue saves/restores that SFR and initializes it with
22835zero in case the ISR code might (implicitly) use it.
22836
22837@item
22838RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
22839If you use inline assembler to read from locations outside the
2284016-bit address range and change one of the @code{RAMP} registers,
22841you must reset it to zero after the access.
22842
22843@end itemize
22844
22845@subsubsection AVR Built-in Macros
22846
22847GCC defines several built-in macros so that the user code can test
22848for the presence or absence of features. Almost any of the following
22849built-in macros are deduced from device capabilities and thus
22850triggered by the @option{-mmcu=} command-line option.
22851
22852For even more AVR-specific built-in macros see
22853@ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
22854
22855@table @code
22856
22857@item __AVR_ARCH__
22858Build-in macro that resolves to a decimal number that identifies the
22859architecture and depends on the @option{-mmcu=@var{mcu}} option.
22860Possible values are:
22861
22862@code{2}, @code{25}, @code{3}, @code{31}, @code{35},
22863@code{4}, @code{5}, @code{51}, @code{6}
22864
22865for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
22866@code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
22867
22868respectively and
22869
22870@code{100},
22871@code{102}, @code{103}, @code{104},
22872@code{105}, @code{106}, @code{107}
22873
22874for @var{mcu}=@code{avrtiny},
22875@code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
22876@code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
22877If @var{mcu} specifies a device, this built-in macro is set
22878accordingly. For example, with @option{-mmcu=atmega8} the macro is
22879defined to @code{4}.
22880
22881@item __AVR_@var{Device}__
22882Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
22883the device's name. For example, @option{-mmcu=atmega8} defines the
22884built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
22885@code{__AVR_ATtiny261A__}, etc.
22886
22887The built-in macros' names follow
22888the scheme @code{__AVR_@var{Device}__} where @var{Device} is
22889the device name as from the AVR user manual. The difference between
22890@var{Device} in the built-in macro and @var{device} in
22891@option{-mmcu=@var{device}} is that the latter is always lowercase.
22892
22893If @var{device} is not a device but only a core architecture like
22894@samp{avr51}, this macro is not defined.
22895
22896@item __AVR_DEVICE_NAME__
22897Setting @option{-mmcu=@var{device}} defines this built-in macro to
22898the device's name. For example, with @option{-mmcu=atmega8} the macro
22899is defined to @code{atmega8}.
22900
22901If @var{device} is not a device but only a core architecture like
22902@samp{avr51}, this macro is not defined.
22903
22904@item __AVR_XMEGA__
22905The device / architecture belongs to the XMEGA family of devices.
22906
22907@item __AVR_HAVE_ELPM__
22908The device has the @code{ELPM} instruction.
22909
22910@item __AVR_HAVE_ELPMX__
22911The device has the @code{ELPM R@var{n},Z} and @code{ELPM
22912R@var{n},Z+} instructions.
22913
22914@item __AVR_HAVE_MOVW__
22915The device has the @code{MOVW} instruction to perform 16-bit
22916register-register moves.
22917
22918@item __AVR_HAVE_LPMX__
22919The device has the @code{LPM R@var{n},Z} and
22920@code{LPM R@var{n},Z+} instructions.
22921
22922@item __AVR_HAVE_MUL__
22923The device has a hardware multiplier.
22924
22925@item __AVR_HAVE_JMP_CALL__
22926The device has the @code{JMP} and @code{CALL} instructions.
22927This is the case for devices with more than 8@tie{}KiB of program
22928memory.
22929
22930@item __AVR_HAVE_EIJMP_EICALL__
22931@itemx __AVR_3_BYTE_PC__
22932The device has the @code{EIJMP} and @code{EICALL} instructions.
22933This is the case for devices with more than 128@tie{}KiB of program memory.
22934This also means that the program counter
22935(PC) is 3@tie{}bytes wide.
22936
22937@item __AVR_2_BYTE_PC__
22938The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
22939with up to 128@tie{}KiB of program memory.
22940
22941@item __AVR_HAVE_8BIT_SP__
22942@itemx __AVR_HAVE_16BIT_SP__
22943The stack pointer (SP) register is treated as 8-bit respectively
2294416-bit register by the compiler.
22945The definition of these macros is affected by @option{-mtiny-stack}.
22946
22947@item __AVR_HAVE_SPH__
22948@itemx __AVR_SP8__
22949The device has the SPH (high part of stack pointer) special function
22950register or has an 8-bit stack pointer, respectively.
22951The definition of these macros is affected by @option{-mmcu=} and
22952in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
22953by @option{-msp8}.
22954
22955@item __AVR_HAVE_RAMPD__
22956@itemx __AVR_HAVE_RAMPX__
22957@itemx __AVR_HAVE_RAMPY__
22958@itemx __AVR_HAVE_RAMPZ__
22959The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
22960@code{RAMPZ} special function register, respectively.
22961
22962@item __NO_INTERRUPTS__
22963This macro reflects the @option{-mno-interrupts} command-line option.
22964
22965@item __AVR_ERRATA_SKIP__
22966@itemx __AVR_ERRATA_SKIP_JMP_CALL__
22967Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
22968instructions because of a hardware erratum. Skip instructions are
22969@code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
22970The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
22971set.
22972
22973@item __AVR_ISA_RMW__
22974The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
22975
22976@item __AVR_SFR_OFFSET__=@var{offset}
22977Instructions that can address I/O special function registers directly
22978like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
22979address as if addressed by an instruction to access RAM like @code{LD}
22980or @code{STS}. This offset depends on the device architecture and has
22981to be subtracted from the RAM address in order to get the
22982respective I/O@tie{}address.
22983
22984@item __AVR_SHORT_CALLS__
22985The @option{-mshort-calls} command line option is set.
22986
22987@item __AVR_PM_BASE_ADDRESS__=@var{addr}
22988Some devices support reading from flash memory by means of @code{LD*}
22989instructions. The flash memory is seen in the data address space
22990at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
22991is not defined, this feature is not available. If defined,
22992the address space is linear and there is no need to put
22993@code{.rodata} into RAM. This is handled by the default linker
22994description file, and is currently available for
22995@code{avrtiny} and @code{avrxmega3}. Even more convenient,
22996there is no need to use address spaces like @code{__flash} or
22997features like attribute @code{progmem} and @code{pgm_read_*}.
22998
22999@item __WITH_AVRLIBC__
23000The compiler is configured to be used together with AVR-Libc.
23001See the @option{--with-avrlibc} configure option.
23002
23003@item __HAVE_DOUBLE_MULTILIB__
23004Defined if @option{-mdouble=} acts as a multilib option.
23005
23006@item __HAVE_DOUBLE32__
23007@itemx __HAVE_DOUBLE64__
23008Defined if the compiler supports 32-bit double resp. 64-bit double.
23009The actual layout is specified by option @option{-mdouble=}.
23010
23011@item __DEFAULT_DOUBLE__
23012The size in bits of @code{double} if @option{-mdouble=} is not set.
23013To test the layout of @code{double} in a program, use the built-in
23014macro @code{__SIZEOF_DOUBLE__}.
23015
23016@item __HAVE_LONG_DOUBLE32__
23017@itemx __HAVE_LONG_DOUBLE64__
23018@itemx __HAVE_LONG_DOUBLE_MULTILIB__
23019@itemx __DEFAULT_LONG_DOUBLE__
23020Same as above, but for @code{long double} instead of @code{double}.
23021
23022@item __WITH_DOUBLE_COMPARISON__
23023Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
23024@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
23025and is defined to @code{2} or @code{3}.
23026
23027@item __WITH_LIBF7_LIBGCC__
23028@itemx __WITH_LIBF7_MATH__
23029@itemx __WITH_LIBF7_MATH_SYMBOLS__
23030Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
23031@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
23032
23033@end table
23034
23035@node Blackfin Options
23036@subsection Blackfin Options
23037@cindex Blackfin Options
23038
23039@table @gcctabopt
23040@item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
23041@opindex mcpu=
23042Specifies the name of the target Blackfin processor. Currently, @var{cpu}
23043can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
23044@samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
23045@samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
23046@samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
23047@samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
23048@samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
23049@samp{bf561}, @samp{bf592}.
23050
23051The optional @var{sirevision} specifies the silicon revision of the target
23052Blackfin processor. Any workarounds available for the targeted silicon revision
23053are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
23054If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
23055are enabled. The @code{__SILICON_REVISION__} macro is defined to two
23056hexadecimal digits representing the major and minor numbers in the silicon
23057revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
23058is not defined. If @var{sirevision} is @samp{any}, the
23059@code{__SILICON_REVISION__} is defined to be @code{0xffff}.
23060If this optional @var{sirevision} is not used, GCC assumes the latest known
23061silicon revision of the targeted Blackfin processor.
23062
23063GCC defines a preprocessor macro for the specified @var{cpu}.
23064For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
23065provided by libgloss to be linked in if @option{-msim} is not given.
23066
23067Without this option, @samp{bf532} is used as the processor by default.
23068
23069Note that support for @samp{bf561} is incomplete. For @samp{bf561},
23070only the preprocessor macro is defined.
23071
23072@item -msim
23073@opindex msim
23074Specifies that the program will be run on the simulator. This causes
23075the simulator BSP provided by libgloss to be linked in. This option
23076has effect only for @samp{bfin-elf} toolchain.
23077Certain other options, such as @option{-mid-shared-library} and
23078@option{-mfdpic}, imply @option{-msim}.
23079
23080@item -momit-leaf-frame-pointer
23081@opindex momit-leaf-frame-pointer
23082Don't keep the frame pointer in a register for leaf functions. This
23083avoids the instructions to save, set up and restore frame pointers and
23084makes an extra register available in leaf functions.
23085
23086@item -mspecld-anomaly
23087@opindex mspecld-anomaly
23088When enabled, the compiler ensures that the generated code does not
23089contain speculative loads after jump instructions. If this option is used,
23090@code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
23091
23092@item -mno-specld-anomaly
23093@opindex mno-specld-anomaly
23094@opindex mspecld-anomaly
23095Don't generate extra code to prevent speculative loads from occurring.
23096
23097@item -mcsync-anomaly
23098@opindex mcsync-anomaly
23099When enabled, the compiler ensures that the generated code does not
23100contain CSYNC or SSYNC instructions too soon after conditional branches.
23101If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
23102
23103@item -mno-csync-anomaly
23104@opindex mno-csync-anomaly
23105@opindex mcsync-anomaly
23106Don't generate extra code to prevent CSYNC or SSYNC instructions from
23107occurring too soon after a conditional branch.
23108
23109@item -mlow64k
23110@opindex mlow64k
23111When enabled, the compiler is free to take advantage of the knowledge that
23112the entire program fits into the low 64k of memory.
23113
23114@item -mno-low64k
23115@opindex mno-low64k
23116Assume that the program is arbitrarily large. This is the default.
23117
23118@item -mstack-check-l1
23119@opindex mstack-check-l1
23120Do stack checking using information placed into L1 scratchpad memory by the
23121uClinux kernel.
23122
23123@item -mid-shared-library
23124@opindex mid-shared-library
23125Generate code that supports shared libraries via the library ID method.
23126This allows for execute in place and shared libraries in an environment
23127without virtual memory management. This option implies @option{-fPIC}.
23128With a @samp{bfin-elf} target, this option implies @option{-msim}.
23129
23130@item -mno-id-shared-library
23131@opindex mno-id-shared-library
23132@opindex mid-shared-library
23133Generate code that doesn't assume ID-based shared libraries are being used.
23134This is the default.
23135
23136@item -mleaf-id-shared-library
23137@opindex mleaf-id-shared-library
23138Generate code that supports shared libraries via the library ID method,
23139but assumes that this library or executable won't link against any other
23140ID shared libraries. That allows the compiler to use faster code for jumps
23141and calls.
23142
23143@item -mno-leaf-id-shared-library
23144@opindex mno-leaf-id-shared-library
23145@opindex mleaf-id-shared-library
23146Do not assume that the code being compiled won't link against any ID shared
23147libraries. Slower code is generated for jump and call insns.
23148
23149@item -mshared-library-id=n
23150@opindex mshared-library-id
23151Specifies the identification number of the ID-based shared library being
23152compiled. Specifying a value of 0 generates more compact code; specifying
23153other values forces the allocation of that number to the current
23154library but is no more space- or time-efficient than omitting this option.
23155
23156@item -msep-data
23157@opindex msep-data
23158Generate code that allows the data segment to be located in a different
23159area of memory from the text segment. This allows for execute in place in
23160an environment without virtual memory management by eliminating relocations
23161against the text section.
23162
23163@item -mno-sep-data
23164@opindex mno-sep-data
23165@opindex msep-data
23166Generate code that assumes that the data segment follows the text segment.
23167This is the default.
23168
23169@item -mlong-calls
23170@itemx -mno-long-calls
23171@opindex mlong-calls
23172@opindex mno-long-calls
23173Tells the compiler to perform function calls by first loading the
23174address of the function into a register and then performing a subroutine
23175call on this register. This switch is needed if the target function
23176lies outside of the 24-bit addressing range of the offset-based
23177version of subroutine call instruction.
23178
23179This feature is not enabled by default. Specifying
23180@option{-mno-long-calls} restores the default behavior. Note these
23181switches have no effect on how the compiler generates code to handle
23182function calls via function pointers.
23183
23184@item -mfast-fp
23185@opindex mfast-fp
23186Link with the fast floating-point library. This library relaxes some of
23187the IEEE floating-point standard's rules for checking inputs against
23188Not-a-Number (NAN), in the interest of performance.
23189
23190@item -minline-plt
23191@opindex minline-plt
23192Enable inlining of PLT entries in function calls to functions that are
23193not known to bind locally. It has no effect without @option{-mfdpic}.
23194
23195@item -mmulticore
23196@opindex mmulticore
23197Build a standalone application for multicore Blackfin processors.
23198This option causes proper start files and link scripts supporting
23199multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
23200It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
23201
23202This option can be used with @option{-mcorea} or @option{-mcoreb}, which
23203selects the one-application-per-core programming model. Without
23204@option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
23205programming model is used. In this model, the main function of Core B
23206should be named as @code{coreb_main}.
23207
23208If this option is not used, the single-core application programming
23209model is used.
23210
23211@item -mcorea
23212@opindex mcorea
23213Build a standalone application for Core A of BF561 when using
23214the one-application-per-core programming model. Proper start files
23215and link scripts are used to support Core A, and the macro
23216@code{__BFIN_COREA} is defined.
23217This option can only be used in conjunction with @option{-mmulticore}.
23218
23219@item -mcoreb
23220@opindex mcoreb
23221Build a standalone application for Core B of BF561 when using
23222the one-application-per-core programming model. Proper start files
23223and link scripts are used to support Core B, and the macro
23224@code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
23225should be used instead of @code{main}.
23226This option can only be used in conjunction with @option{-mmulticore}.
23227
23228@item -msdram
23229@opindex msdram
23230Build a standalone application for SDRAM. Proper start files and
23231link scripts are used to put the application into SDRAM, and the macro
23232@code{__BFIN_SDRAM} is defined.
23233The loader should initialize SDRAM before loading the application.
23234
23235@item -micplb
23236@opindex micplb
23237Assume that ICPLBs are enabled at run time. This has an effect on certain
23238anomaly workarounds. For Linux targets, the default is to assume ICPLBs
23239are enabled; for standalone applications the default is off.
23240@end table
23241
23242@node C6X Options
23243@subsection C6X Options
23244@cindex C6X Options
23245
23246@table @gcctabopt
23247@item -march=@var{name}
23248@opindex march
23249This specifies the name of the target architecture. GCC uses this
23250name to determine what kind of instructions it can emit when generating
23251assembly code. Permissible names are: @samp{c62x},
23252@samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
23253
23254@item -mbig-endian
23255@opindex mbig-endian
23256Generate code for a big-endian target.
23257
23258@item -mlittle-endian
23259@opindex mlittle-endian
23260Generate code for a little-endian target. This is the default.
23261
23262@item -msim
23263@opindex msim
23264Choose startup files and linker script suitable for the simulator.
23265
23266@item -msdata=default
23267@opindex msdata=default
23268Put small global and static data in the @code{.neardata} section,
23269which is pointed to by register @code{B14}. Put small uninitialized
23270global and static data in the @code{.bss} section, which is adjacent
23271to the @code{.neardata} section. Put small read-only data into the
23272@code{.rodata} section. The corresponding sections used for large
23273pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
23274
23275@item -msdata=all
23276@opindex msdata=all
23277Put all data, not just small objects, into the sections reserved for
23278small data, and use addressing relative to the @code{B14} register to
23279access them.
23280
23281@item -msdata=none
23282@opindex msdata=none
23283Make no use of the sections reserved for small data, and use absolute
23284addresses to access all data. Put all initialized global and static
23285data in the @code{.fardata} section, and all uninitialized data in the
23286@code{.far} section. Put all constant data into the @code{.const}
23287section.
23288@end table
23289
23290@node CRIS Options
23291@subsection CRIS Options
23292@cindex CRIS Options
23293
23294These options are defined specifically for the CRIS ports.
23295
23296@table @gcctabopt
23297@item -march=@var{architecture-type}
23298@itemx -mcpu=@var{architecture-type}
23299@opindex march
23300@opindex mcpu
23301Generate code for the specified architecture. The choices for
23302@var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
23303respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
23304Default is @samp{v0}.
23305
23306@item -mtune=@var{architecture-type}
23307@opindex mtune
23308Tune to @var{architecture-type} everything applicable about the generated
23309code, except for the ABI and the set of available instructions. The
23310choices for @var{architecture-type} are the same as for
23311@option{-march=@var{architecture-type}}.
23312
23313@item -mmax-stack-frame=@var{n}
23314@opindex mmax-stack-frame
23315Warn when the stack frame of a function exceeds @var{n} bytes.
23316
23317@item -metrax4
23318@itemx -metrax100
23319@opindex metrax4
23320@opindex metrax100
23321The options @option{-metrax4} and @option{-metrax100} are synonyms for
23322@option{-march=v3} and @option{-march=v8} respectively.
23323
23324@item -mmul-bug-workaround
23325@itemx -mno-mul-bug-workaround
23326@opindex mmul-bug-workaround
23327@opindex mno-mul-bug-workaround
23328Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
23329models where it applies. This option is disabled by default.
23330
23331@item -mpdebug
23332@opindex mpdebug
23333Enable CRIS-specific verbose debug-related information in the assembly
23334code. This option also has the effect of turning off the @samp{#NO_APP}
23335formatted-code indicator to the assembler at the beginning of the
23336assembly file.
23337
23338@item -mcc-init
23339@opindex mcc-init
23340Do not use condition-code results from previous instruction; always emit
23341compare and test instructions before use of condition codes.
23342
23343@item -mno-side-effects
23344@opindex mno-side-effects
23345@opindex mside-effects
23346Do not emit instructions with side effects in addressing modes other than
23347post-increment.
23348
23349@item -mstack-align
23350@itemx -mno-stack-align
23351@itemx -mdata-align
23352@itemx -mno-data-align
23353@itemx -mconst-align
23354@itemx -mno-const-align
23355@opindex mstack-align
23356@opindex mno-stack-align
23357@opindex mdata-align
23358@opindex mno-data-align
23359@opindex mconst-align
23360@opindex mno-const-align
23361These options (@samp{no-} options) arrange (eliminate arrangements) for the
23362stack frame, individual data and constants to be aligned for the maximum
23363single data access size for the chosen CPU model. The default is to
23364arrange for 32-bit alignment. ABI details such as structure layout are
23365not affected by these options.
23366
23367@item -m32-bit
23368@itemx -m16-bit
23369@itemx -m8-bit
23370@opindex m32-bit
23371@opindex m16-bit
23372@opindex m8-bit
23373Similar to the stack- data- and const-align options above, these options
23374arrange for stack frame, writable data and constants to all be 32-bit,
2337516-bit or 8-bit aligned. The default is 32-bit alignment.
23376
23377@item -mno-prologue-epilogue
23378@itemx -mprologue-epilogue
23379@opindex mno-prologue-epilogue
23380@opindex mprologue-epilogue
23381With @option{-mno-prologue-epilogue}, the normal function prologue and
23382epilogue which set up the stack frame are omitted and no return
23383instructions or return sequences are generated in the code. Use this
23384option only together with visual inspection of the compiled code: no
23385warnings or errors are generated when call-saved registers must be saved,
23386or storage for local variables needs to be allocated.
23387
23388@item -melf
23389@opindex melf
23390Legacy no-op option.
23391
23392@item -sim
23393@opindex sim
23394This option arranges
23395to link with input-output functions from a simulator library. Code,
23396initialized data and zero-initialized data are allocated consecutively.
23397
23398@item -sim2
23399@opindex sim2
23400Like @option{-sim}, but pass linker options to locate initialized data at
234010x40000000 and zero-initialized data at 0x80000000.
23402@end table
23403
23404@node C-SKY Options
23405@subsection C-SKY Options
23406@cindex C-SKY Options
23407
23408GCC supports these options when compiling for C-SKY V2 processors.
23409
23410@table @gcctabopt
23411
23412@item -march=@var{arch}
23413@opindex march=
23414Specify the C-SKY target architecture. Valid values for @var{arch} are:
23415@samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
23416The default is @samp{ck810}.
23417
23418@item -mcpu=@var{cpu}
23419@opindex mcpu=
23420Specify the C-SKY target processor. Valid values for @var{cpu} are:
23421@samp{ck801}, @samp{ck801t},
23422@samp{ck802}, @samp{ck802t}, @samp{ck802j},
23423@samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
23424@samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
23425@samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
23426@samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
23427@samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
23428@samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
23429@samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
23430@samp{ck803eftr1}, @samp{ck803efhtr1},
23431@samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
23432@samp{ck803sef}, @samp{ck803seft},
23433@samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
23434@samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
23435@samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
23436@samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
23437
23438@item -mbig-endian
23439@opindex mbig-endian
23440@itemx -EB
23441@opindex EB
23442@itemx -mlittle-endian
23443@opindex mlittle-endian
23444@itemx -EL
23445@opindex EL
23446
23447Select big- or little-endian code. The default is little-endian.
23448
23449@item -mfloat-abi=@var{name}
23450@opindex mfloat-abi
23451Specifies which floating-point ABI to use. Permissible values
23452are: @samp{soft}, @samp{softfp} and @samp{hard}.
23453
23454Specifying @samp{soft} causes GCC to generate output containing
23455library calls for floating-point operations.
23456@samp{softfp} allows the generation of code using hardware floating-point
23457instructions, but still uses the soft-float calling conventions.
23458@samp{hard} allows generation of floating-point instructions
23459and uses FPU-specific calling conventions.
23460
23461The default depends on the specific target configuration. Note that
23462the hard-float and soft-float ABIs are not link-compatible; you must
23463compile your entire program with the same ABI, and link with a
23464compatible set of libraries.
23465
23466@item -mhard-float
23467@opindex mhard-float
23468@itemx -msoft-float
23469@opindex msoft-float
23470
23471Select hardware or software floating-point implementations.
23472The default is soft float.
23473
23474@item -mdouble-float
23475@itemx -mno-double-float
23476@opindex mdouble-float
23477When @option{-mhard-float} is in effect, enable generation of
23478double-precision float instructions. This is the default except
23479when compiling for CK803.
23480
23481@item -mfdivdu
23482@itemx -mno-fdivdu
23483@opindex mfdivdu
23484When @option{-mhard-float} is in effect, enable generation of
23485@code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
23486This is the default except when compiling for CK803.
23487
23488@item -mfpu=@var{fpu}
23489@opindex mfpu=
23490Select the floating-point processor. This option can only be used with
23491@option{-mhard-float}.
23492Values for @var{fpu} are
23493@samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
23494@samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
23495@samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
23496
23497@item -melrw
23498@itemx -mno-elrw
23499@opindex melrw
23500Enable the extended @code{lrw} instruction. This option defaults to on
23501for CK801 and off otherwise.
23502
23503@item -mistack
23504@itemx -mno-istack
23505@opindex mistack
23506Enable interrupt stack instructions; the default is off.
23507
23508The @option{-mistack} option is required to handle the
23509@code{interrupt} and @code{isr} function attributes
23510(@pxref{C-SKY Function Attributes}).
23511
23512@item -mmp
23513@opindex mmp
23514Enable multiprocessor instructions; the default is off.
23515
23516@item -mcp
23517@opindex mcp
23518Enable coprocessor instructions; the default is off.
23519
23520@item -mcache
23521@opindex mcache
23522Enable coprocessor instructions; the default is off.
23523
23524@item -msecurity
23525@opindex msecurity
23526Enable C-SKY security instructions; the default is off.
23527
23528@item -mtrust
23529@opindex mtrust
23530Enable C-SKY trust instructions; the default is off.
23531
23532@item -mdsp
23533@opindex mdsp
23534@itemx -medsp
23535@opindex medsp
23536@itemx -mvdsp
23537@opindex mvdsp
23538Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
23539All of these options default to off.
23540
23541@item -mdiv
23542@itemx -mno-div
23543@opindex mdiv
23544Generate divide instructions. Default is off.
23545
23546@item -msmart
23547@itemx -mno-smart
23548@opindex msmart
23549Generate code for Smart Mode, using only registers numbered 0-7 to allow
23550use of 16-bit instructions. This option is ignored for CK801 where this
23551is the required behavior, and it defaults to on for CK802.
23552For other targets, the default is off.
23553
23554@item -mhigh-registers
23555@itemx -mno-high-registers
23556@opindex mhigh-registers
23557Generate code using the high registers numbered 16-31. This option
23558is not supported on CK801, CK802, or CK803, and is enabled by default
23559for other processors.
23560
23561@item -manchor
23562@itemx -mno-anchor
23563@opindex manchor
23564Generate code using global anchor symbol addresses.
23565
23566@item -mpushpop
23567@itemx -mno-pushpop
23568@opindex mpushpop
23569Generate code using @code{push} and @code{pop} instructions. This option
23570defaults to on.
23571
23572@item -mmultiple-stld
23573@itemx -mstm
23574@itemx -mno-multiple-stld
23575@itemx -mno-stm
23576@opindex mmultiple-stld
23577Generate code using @code{stm} and @code{ldm} instructions. This option
23578isn't supported on CK801 but is enabled by default on other processors.
23579
23580@item -mconstpool
23581@itemx -mno-constpool
23582@opindex mconstpool
23583Create constant pools in the compiler instead of deferring it to the
23584assembler. This option is the default and required for correct code
23585generation on CK801 and CK802, and is optional on other processors.
23586
23587@item -mstack-size
23588@item -mno-stack-size
23589@opindex mstack-size
23590Emit @code{.stack_size} directives for each function in the assembly
23591output. This option defaults to off.
23592
23593@item -mccrt
23594@itemx -mno-ccrt
23595@opindex mccrt
23596Generate code for the C-SKY compiler runtime instead of libgcc. This
23597option defaults to off.
23598
23599@item -mbranch-cost=@var{n}
23600@opindex mbranch-cost=
23601Set the branch costs to roughly @code{n} instructions. The default is 1.
23602
23603@item -msched-prolog
23604@itemx -mno-sched-prolog
23605@opindex msched-prolog
23606Permit scheduling of function prologue and epilogue sequences. Using
23607this option can result in code that is not compliant with the C-SKY V2 ABI
23608prologue requirements and that cannot be debugged or backtraced.
23609It is disabled by default.
23610
23611@item -msim
23612@opindex msim
23613Links the library libsemi.a which is in compatible with simulator. Applicable
23614to ELF compiler only.
23615
23616@end table
23617
23618@node Darwin Options
23619@subsection Darwin Options
23620@cindex Darwin options
23621
23622These options are defined for all architectures running the Darwin operating
23623system.
23624
23625FSF GCC on Darwin does not create ``fat'' object files; it creates
23626an object file for the single architecture that GCC was built to
23627target. Apple's GCC on Darwin does create ``fat'' files if multiple
23628@option{-arch} options are used; it does so by running the compiler or
23629linker multiple times and joining the results together with
23630@file{lipo}.
23631
23632The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
23633@samp{i686}) is determined by the flags that specify the ISA
23634that GCC is targeting, like @option{-mcpu} or @option{-march}. The
23635@option{-force_cpusubtype_ALL} option can be used to override this.
23636
23637The Darwin tools vary in their behavior when presented with an ISA
23638mismatch. The assembler, @file{as}, only permits instructions to
23639be used that are valid for the subtype of the file it is generating,
23640so you cannot put 64-bit instructions in a @samp{ppc750} object file.
23641The linker for shared libraries, @file{/usr/bin/libtool}, fails
23642and prints an error if asked to create a shared library with a less
23643restrictive subtype than its input files (for instance, trying to put
23644a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
23645for executables, @command{ld}, quietly gives the executable the most
23646restrictive subtype of any of its input files.
23647
23648@table @gcctabopt
23649@item -F@var{dir}
23650@opindex F
23651Add the framework directory @var{dir} to the head of the list of
23652directories to be searched for header files. These directories are
23653interleaved with those specified by @option{-I} options and are
23654scanned in a left-to-right order.
23655
23656A framework directory is a directory with frameworks in it. A
23657framework is a directory with a @file{Headers} and/or
23658@file{PrivateHeaders} directory contained directly in it that ends
23659in @file{.framework}. The name of a framework is the name of this
23660directory excluding the @file{.framework}. Headers associated with
23661the framework are found in one of those two directories, with
23662@file{Headers} being searched first. A subframework is a framework
23663directory that is in a framework's @file{Frameworks} directory.
23664Includes of subframework headers can only appear in a header of a
23665framework that contains the subframework, or in a sibling subframework
23666header. Two subframeworks are siblings if they occur in the same
23667framework. A subframework should not have the same name as a
23668framework; a warning is issued if this is violated. Currently a
23669subframework cannot have subframeworks; in the future, the mechanism
23670may be extended to support this. The standard frameworks can be found
23671in @file{/System/Library/Frameworks} and
23672@file{/Library/Frameworks}. An example include looks like
23673@code{#include <Framework/header.h>}, where @file{Framework} denotes
23674the name of the framework and @file{header.h} is found in the
23675@file{PrivateHeaders} or @file{Headers} directory.
23676
23677@item -iframework@var{dir}
23678@opindex iframework
23679Like @option{-F} except the directory is a treated as a system
23680directory. The main difference between this @option{-iframework} and
23681@option{-F} is that with @option{-iframework} the compiler does not
23682warn about constructs contained within header files found via
23683@var{dir}. This option is valid only for the C family of languages.
23684
23685@item -gused
23686@opindex gused
23687Emit debugging information for symbols that are used. For stabs
23688debugging format, this enables @option{-feliminate-unused-debug-symbols}.
23689This is by default ON@.
23690
23691@item -gfull
23692@opindex gfull
23693Emit debugging information for all symbols and types.
23694
23695@item -mmacosx-version-min=@var{version}
23696The earliest version of MacOS X that this executable will run on
23697is @var{version}. Typical values of @var{version} include @code{10.1},
23698@code{10.2}, and @code{10.3.9}.
23699
23700If the compiler was built to use the system's headers by default,
23701then the default for this option is the system version on which the
23702compiler is running, otherwise the default is to make choices that
23703are compatible with as many systems and code bases as possible.
23704
23705@item -mkernel
23706@opindex mkernel
23707Enable kernel development mode. The @option{-mkernel} option sets
23708@option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
23709@option{-fno-exceptions}, @option{-fno-non-call-exceptions},
23710@option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
23711applicable. This mode also sets @option{-mno-altivec},
23712@option{-msoft-float}, @option{-fno-builtin} and
23713@option{-mlong-branch} for PowerPC targets.
23714
23715@item -mone-byte-bool
23716@opindex mone-byte-bool
23717Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
23718By default @code{sizeof(bool)} is @code{4} when compiling for
23719Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
23720option has no effect on x86.
23721
23722@strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
23723to generate code that is not binary compatible with code generated
23724without that switch. Using this switch may require recompiling all
23725other modules in a program, including system libraries. Use this
23726switch to conform to a non-default data model.
23727
23728@item -mfix-and-continue
23729@itemx -ffix-and-continue
23730@itemx -findirect-data
23731@opindex mfix-and-continue
23732@opindex ffix-and-continue
23733@opindex findirect-data
23734Generate code suitable for fast turnaround development, such as to
23735allow GDB to dynamically load @file{.o} files into already-running
23736programs. @option{-findirect-data} and @option{-ffix-and-continue}
23737are provided for backwards compatibility.
23738
23739@item -all_load
23740@opindex all_load
23741Loads all members of static archive libraries.
23742See man ld(1) for more information.
23743
23744@item -arch_errors_fatal
23745@opindex arch_errors_fatal
23746Cause the errors having to do with files that have the wrong architecture
23747to be fatal.
23748
23749@item -bind_at_load
23750@opindex bind_at_load
23751Causes the output file to be marked such that the dynamic linker will
23752bind all undefined references when the file is loaded or launched.
23753
23754@item -bundle
23755@opindex bundle
23756Produce a Mach-o bundle format file.
23757See man ld(1) for more information.
23758
23759@item -bundle_loader @var{executable}
23760@opindex bundle_loader
23761This option specifies the @var{executable} that will load the build
23762output file being linked. See man ld(1) for more information.
23763
23764@item -dynamiclib
23765@opindex dynamiclib
23766When passed this option, GCC produces a dynamic library instead of
23767an executable when linking, using the Darwin @file{libtool} command.
23768
23769@item -force_cpusubtype_ALL
23770@opindex force_cpusubtype_ALL
23771This causes GCC's output file to have the @samp{ALL} subtype, instead of
23772one controlled by the @option{-mcpu} or @option{-march} option.
23773
23774@item -allowable_client @var{client_name}
23775@itemx -client_name
23776@itemx -compatibility_version
23777@itemx -current_version
23778@itemx -dead_strip
23779@itemx -dependency-file
23780@itemx -dylib_file
23781@itemx -dylinker_install_name
23782@itemx -dynamic
23783@itemx -exported_symbols_list
23784@itemx -filelist
23785@need 800
23786@itemx -flat_namespace
23787@itemx -force_flat_namespace
23788@itemx -headerpad_max_install_names
23789@itemx -image_base
23790@itemx -init
23791@itemx -install_name
23792@itemx -keep_private_externs
23793@itemx -multi_module
23794@itemx -multiply_defined
23795@itemx -multiply_defined_unused
23796@need 800
23797@itemx -noall_load
23798@itemx -no_dead_strip_inits_and_terms
23799@itemx -nofixprebinding
23800@itemx -nomultidefs
23801@itemx -noprebind
23802@itemx -noseglinkedit
23803@itemx -pagezero_size
23804@itemx -prebind
23805@itemx -prebind_all_twolevel_modules
23806@itemx -private_bundle
23807@need 800
23808@itemx -read_only_relocs
23809@itemx -sectalign
23810@itemx -sectobjectsymbols
23811@itemx -whyload
23812@itemx -seg1addr
23813@itemx -sectcreate
23814@itemx -sectobjectsymbols
23815@itemx -sectorder
23816@itemx -segaddr
23817@itemx -segs_read_only_addr
23818@need 800
23819@itemx -segs_read_write_addr
23820@itemx -seg_addr_table
23821@itemx -seg_addr_table_filename
23822@itemx -seglinkedit
23823@itemx -segprot
23824@itemx -segs_read_only_addr
23825@itemx -segs_read_write_addr
23826@itemx -single_module
23827@itemx -static
23828@itemx -sub_library
23829@need 800
23830@itemx -sub_umbrella
23831@itemx -twolevel_namespace
23832@itemx -umbrella
23833@itemx -undefined
23834@itemx -unexported_symbols_list
23835@itemx -weak_reference_mismatches
23836@itemx -whatsloaded
23837@opindex allowable_client
23838@opindex client_name
23839@opindex compatibility_version
23840@opindex current_version
23841@opindex dead_strip
23842@opindex dependency-file
23843@opindex dylib_file
23844@opindex dylinker_install_name
23845@opindex dynamic
23846@opindex exported_symbols_list
23847@opindex filelist
23848@opindex flat_namespace
23849@opindex force_flat_namespace
23850@opindex headerpad_max_install_names
23851@opindex image_base
23852@opindex init
23853@opindex install_name
23854@opindex keep_private_externs
23855@opindex multi_module
23856@opindex multiply_defined
23857@opindex multiply_defined_unused
23858@opindex noall_load
23859@opindex no_dead_strip_inits_and_terms
23860@opindex nofixprebinding
23861@opindex nomultidefs
23862@opindex noprebind
23863@opindex noseglinkedit
23864@opindex pagezero_size
23865@opindex prebind
23866@opindex prebind_all_twolevel_modules
23867@opindex private_bundle
23868@opindex read_only_relocs
23869@opindex sectalign
23870@opindex sectobjectsymbols
23871@opindex whyload
23872@opindex seg1addr
23873@opindex sectcreate
23874@opindex sectobjectsymbols
23875@opindex sectorder
23876@opindex segaddr
23877@opindex segs_read_only_addr
23878@opindex segs_read_write_addr
23879@opindex seg_addr_table
23880@opindex seg_addr_table_filename
23881@opindex seglinkedit
23882@opindex segprot
23883@opindex segs_read_only_addr
23884@opindex segs_read_write_addr
23885@opindex single_module
23886@opindex static
23887@opindex sub_library
23888@opindex sub_umbrella
23889@opindex twolevel_namespace
23890@opindex umbrella
23891@opindex undefined
23892@opindex unexported_symbols_list
23893@opindex weak_reference_mismatches
23894@opindex whatsloaded
23895These options are passed to the Darwin linker. The Darwin linker man page
23896describes them in detail.
23897@end table
23898
23899@node DEC Alpha Options
23900@subsection DEC Alpha Options
23901
23902These @samp{-m} options are defined for the DEC Alpha implementations:
23903
23904@table @gcctabopt
23905@item -mno-soft-float
23906@itemx -msoft-float
23907@opindex mno-soft-float
23908@opindex msoft-float
23909Use (do not use) the hardware floating-point instructions for
23910floating-point operations. When @option{-msoft-float} is specified,
23911functions in @file{libgcc.a} are used to perform floating-point
23912operations. Unless they are replaced by routines that emulate the
23913floating-point operations, or compiled in such a way as to call such
23914emulations routines, these routines issue floating-point
23915operations. If you are compiling for an Alpha without floating-point
23916operations, you must ensure that the library is built so as not to call
23917them.
23918
23919Note that Alpha implementations without floating-point operations are
23920required to have floating-point registers.
23921
23922@item -mfp-reg
23923@itemx -mno-fp-regs
23924@opindex mfp-reg
23925@opindex mno-fp-regs
23926Generate code that uses (does not use) the floating-point register set.
23927@option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
23928register set is not used, floating-point operands are passed in integer
23929registers as if they were integers and floating-point results are passed
23930in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
23931so any function with a floating-point argument or return value called by code
23932compiled with @option{-mno-fp-regs} must also be compiled with that
23933option.
23934
23935A typical use of this option is building a kernel that does not use,
23936and hence need not save and restore, any floating-point registers.
23937
23938@item -mieee
23939@opindex mieee
23940The Alpha architecture implements floating-point hardware optimized for
23941maximum performance. It is mostly compliant with the IEEE floating-point
23942standard. However, for full compliance, software assistance is
23943required. This option generates code fully IEEE-compliant code
23944@emph{except} that the @var{inexact-flag} is not maintained (see below).
23945If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
23946defined during compilation. The resulting code is less efficient but is
23947able to correctly support denormalized numbers and exceptional IEEE
23948values such as not-a-number and plus/minus infinity. Other Alpha
23949compilers call this option @option{-ieee_with_no_inexact}.
23950
23951@item -mieee-with-inexact
23952@opindex mieee-with-inexact
23953This is like @option{-mieee} except the generated code also maintains
23954the IEEE @var{inexact-flag}. Turning on this option causes the
23955generated code to implement fully-compliant IEEE math. In addition to
23956@code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
23957macro. On some Alpha implementations the resulting code may execute
23958significantly slower than the code generated by default. Since there is
23959very little code that depends on the @var{inexact-flag}, you should
23960normally not specify this option. Other Alpha compilers call this
23961option @option{-ieee_with_inexact}.
23962
23963@item -mfp-trap-mode=@var{trap-mode}
23964@opindex mfp-trap-mode
23965This option controls what floating-point related traps are enabled.
23966Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
23967The trap mode can be set to one of four values:
23968
23969@table @samp
23970@item n
23971This is the default (normal) setting. The only traps that are enabled
23972are the ones that cannot be disabled in software (e.g., division by zero
23973trap).
23974
23975@item u
23976In addition to the traps enabled by @samp{n}, underflow traps are enabled
23977as well.
23978
23979@item su
23980Like @samp{u}, but the instructions are marked to be safe for software
23981completion (see Alpha architecture manual for details).
23982
23983@item sui
23984Like @samp{su}, but inexact traps are enabled as well.
23985@end table
23986
23987@item -mfp-rounding-mode=@var{rounding-mode}
23988@opindex mfp-rounding-mode
23989Selects the IEEE rounding mode. Other Alpha compilers call this option
23990@option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
23991of:
23992
23993@table @samp
23994@item n
23995Normal IEEE rounding mode. Floating-point numbers are rounded towards
23996the nearest machine number or towards the even machine number in case
23997of a tie.
23998
23999@item m
24000Round towards minus infinity.
24001
24002@item c
24003Chopped rounding mode. Floating-point numbers are rounded towards zero.
24004
24005@item d
24006Dynamic rounding mode. A field in the floating-point control register
24007(@var{fpcr}, see Alpha architecture reference manual) controls the
24008rounding mode in effect. The C library initializes this register for
24009rounding towards plus infinity. Thus, unless your program modifies the
24010@var{fpcr}, @samp{d} corresponds to round towards plus infinity.
24011@end table
24012
24013@item -mtrap-precision=@var{trap-precision}
24014@opindex mtrap-precision
24015In the Alpha architecture, floating-point traps are imprecise. This
24016means without software assistance it is impossible to recover from a
24017floating trap and program execution normally needs to be terminated.
24018GCC can generate code that can assist operating system trap handlers
24019in determining the exact location that caused a floating-point trap.
24020Depending on the requirements of an application, different levels of
24021precisions can be selected:
24022
24023@table @samp
24024@item p
24025Program precision. This option is the default and means a trap handler
24026can only identify which program caused a floating-point exception.
24027
24028@item f
24029Function precision. The trap handler can determine the function that
24030caused a floating-point exception.
24031
24032@item i
24033Instruction precision. The trap handler can determine the exact
24034instruction that caused a floating-point exception.
24035@end table
24036
24037Other Alpha compilers provide the equivalent options called
24038@option{-scope_safe} and @option{-resumption_safe}.
24039
24040@item -mieee-conformant
24041@opindex mieee-conformant
24042This option marks the generated code as IEEE conformant. You must not
24043use this option unless you also specify @option{-mtrap-precision=i} and either
24044@option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
24045is to emit the line @samp{.eflag 48} in the function prologue of the
24046generated assembly file.
24047
24048@item -mbuild-constants
24049@opindex mbuild-constants
24050Normally GCC examines a 32- or 64-bit integer constant to
24051see if it can construct it from smaller constants in two or three
24052instructions. If it cannot, it outputs the constant as a literal and
24053generates code to load it from the data segment at run time.
24054
24055Use this option to require GCC to construct @emph{all} integer constants
24056using code, even if it takes more instructions (the maximum is six).
24057
24058You typically use this option to build a shared library dynamic
24059loader. Itself a shared library, it must relocate itself in memory
24060before it can find the variables and constants in its own data segment.
24061
24062@item -mbwx
24063@itemx -mno-bwx
24064@itemx -mcix
24065@itemx -mno-cix
24066@itemx -mfix
24067@itemx -mno-fix
24068@itemx -mmax
24069@itemx -mno-max
24070@opindex mbwx
24071@opindex mno-bwx
24072@opindex mcix
24073@opindex mno-cix
24074@opindex mfix
24075@opindex mno-fix
24076@opindex mmax
24077@opindex mno-max
24078Indicate whether GCC should generate code to use the optional BWX,
24079CIX, FIX and MAX instruction sets. The default is to use the instruction
24080sets supported by the CPU type specified via @option{-mcpu=} option or that
24081of the CPU on which GCC was built if none is specified.
24082
24083@item -mfloat-vax
24084@itemx -mfloat-ieee
24085@opindex mfloat-vax
24086@opindex mfloat-ieee
24087Generate code that uses (does not use) VAX F and G floating-point
24088arithmetic instead of IEEE single and double precision.
24089
24090@item -mexplicit-relocs
24091@itemx -mno-explicit-relocs
24092@opindex mexplicit-relocs
24093@opindex mno-explicit-relocs
24094Older Alpha assemblers provided no way to generate symbol relocations
24095except via assembler macros. Use of these macros does not allow
24096optimal instruction scheduling. GNU binutils as of version 2.12
24097supports a new syntax that allows the compiler to explicitly mark
24098which relocations should apply to which instructions. This option
24099is mostly useful for debugging, as GCC detects the capabilities of
24100the assembler when it is built and sets the default accordingly.
24101
24102@item -msmall-data
24103@itemx -mlarge-data
24104@opindex msmall-data
24105@opindex mlarge-data
24106When @option{-mexplicit-relocs} is in effect, static data is
24107accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
24108is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
24109(the @code{.sdata} and @code{.sbss} sections) and are accessed via
2411016-bit relocations off of the @code{$gp} register. This limits the
24111size of the small data area to 64KB, but allows the variables to be
24112directly accessed via a single instruction.
24113
24114The default is @option{-mlarge-data}. With this option the data area
24115is limited to just below 2GB@. Programs that require more than 2GB of
24116data must use @code{malloc} or @code{mmap} to allocate the data in the
24117heap instead of in the program's data segment.
24118
24119When generating code for shared libraries, @option{-fpic} implies
24120@option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
24121
24122@item -msmall-text
24123@itemx -mlarge-text
24124@opindex msmall-text
24125@opindex mlarge-text
24126When @option{-msmall-text} is used, the compiler assumes that the
24127code of the entire program (or shared library) fits in 4MB, and is
24128thus reachable with a branch instruction. When @option{-msmall-data}
24129is used, the compiler can assume that all local symbols share the
24130same @code{$gp} value, and thus reduce the number of instructions
24131required for a function call from 4 to 1.
24132
24133The default is @option{-mlarge-text}.
24134
24135@item -mcpu=@var{cpu_type}
24136@opindex mcpu
24137Set the instruction set and instruction scheduling parameters for
24138machine type @var{cpu_type}. You can specify either the @samp{EV}
24139style name or the corresponding chip number. GCC supports scheduling
24140parameters for the EV4, EV5 and EV6 family of processors and
24141chooses the default values for the instruction set from the processor
24142you specify. If you do not specify a processor type, GCC defaults
24143to the processor on which the compiler was built.
24144
24145Supported values for @var{cpu_type} are
24146
24147@table @samp
24148@item ev4
24149@itemx ev45
24150@itemx 21064
24151Schedules as an EV4 and has no instruction set extensions.
24152
24153@item ev5
24154@itemx 21164
24155Schedules as an EV5 and has no instruction set extensions.
24156
24157@item ev56
24158@itemx 21164a
24159Schedules as an EV5 and supports the BWX extension.
24160
24161@item pca56
24162@itemx 21164pc
24163@itemx 21164PC
24164Schedules as an EV5 and supports the BWX and MAX extensions.
24165
24166@item ev6
24167@itemx 21264
24168Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
24169
24170@item ev67
24171@itemx 21264a
24172Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
24173@end table
24174
24175Native toolchains also support the value @samp{native},
24176which selects the best architecture option for the host processor.
24177@option{-mcpu=native} has no effect if GCC does not recognize
24178the processor.
24179
24180@item -mtune=@var{cpu_type}
24181@opindex mtune
24182Set only the instruction scheduling parameters for machine type
24183@var{cpu_type}. The instruction set is not changed.
24184
24185Native toolchains also support the value @samp{native},
24186which selects the best architecture option for the host processor.
24187@option{-mtune=native} has no effect if GCC does not recognize
24188the processor.
24189
24190@item -mmemory-latency=@var{time}
24191@opindex mmemory-latency
24192Sets the latency the scheduler should assume for typical memory
24193references as seen by the application. This number is highly
24194dependent on the memory access patterns used by the application
24195and the size of the external cache on the machine.
24196
24197Valid options for @var{time} are
24198
24199@table @samp
24200@item @var{number}
24201A decimal number representing clock cycles.
24202
24203@item L1
24204@itemx L2
24205@itemx L3
24206@itemx main
24207The compiler contains estimates of the number of clock cycles for
24208``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
24209(also called Dcache, Scache, and Bcache), as well as to main memory.
24210Note that L3 is only valid for EV5.
24211
24212@end table
24213@end table
24214
24215@node eBPF Options
24216@subsection eBPF Options
24217@cindex eBPF Options
24218
24219@table @gcctabopt
24220@item -mframe-limit=@var{bytes}
24221This specifies the hard limit for frame sizes, in bytes. Currently,
24222the value that can be specified should be less than or equal to
24223@samp{32767}. Defaults to whatever limit is imposed by the version of
24224the Linux kernel targeted.
24225
24226@item -mkernel=@var{version}
24227@opindex mkernel
24228This specifies the minimum version of the kernel that will run the
24229compiled program. GCC uses this version to determine which
24230instructions to use, what kernel helpers to allow, etc. Currently,
24231@var{version} can be one of @samp{4.0}, @samp{4.1}, @samp{4.2},
24232@samp{4.3}, @samp{4.4}, @samp{4.5}, @samp{4.6}, @samp{4.7},
24233@samp{4.8}, @samp{4.9}, @samp{4.10}, @samp{4.11}, @samp{4.12},
24234@samp{4.13}, @samp{4.14}, @samp{4.15}, @samp{4.16}, @samp{4.17},
24235@samp{4.18}, @samp{4.19}, @samp{4.20}, @samp{5.0}, @samp{5.1},
24236@samp{5.2}, @samp{latest} and @samp{native}.
24237
24238@item -mbig-endian
24239@opindex mbig-endian
24240Generate code for a big-endian target.
24241
24242@item -mlittle-endian
24243@opindex mlittle-endian
24244Generate code for a little-endian target. This is the default.
24245
24246@item -mjmpext
24247@opindex mjmpext
24248Enable generation of extra conditional-branch instructions.
24249Enabled for CPU v2 and above.
24250
24251@item -mjmp32
24252@opindex mjmp32
24253Enable 32-bit jump instructions. Enabled for CPU v3 and above.
24254
24255@item -malu32
24256@opindex malu32
24257Enable 32-bit ALU instructions. Enabled for CPU v3 and above.
24258
24259@item -mcpu=@var{version}
24260@opindex mcpu
24261This specifies which version of the eBPF ISA to target. Newer versions
24262may not be supported by all kernels. The default is @samp{v3}.
24263
24264Supported values for @var{version} are:
24265
24266@table @samp
24267@item v1
24268The first stable eBPF ISA with no special features or extensions.
24269
24270@item v2
24271Supports the jump extensions, as in @option{-mjmpext}.
24272
24273@item v3
24274All features of v2, plus:
24275@itemize @minus
24276@item 32-bit jump operations, as in @option{-mjmp32}
24277@item 32-bit ALU operations, as in @option{-malu32}
24278@end itemize
24279
24280@end table
24281
24282@item -mco-re
24283@opindex mco-re
24284Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
24285is implied by @option{-gbtf}.
24286
24287@item -mno-co-re
24288@opindex mno-co-re
24289Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
24290support is enabled by default when generating BTF debug information for
24291the BPF target.
24292
24293@item -mxbpf
24294Generate code for an expanded version of BPF, which relaxes some of
24295the restrictions imposed by the BPF architecture:
24296@itemize @minus
24297@item Save and restore callee-saved registers at function entry and
24298exit, respectively.
24299@end itemize
24300@end table
24301
24302@node FR30 Options
24303@subsection FR30 Options
24304@cindex FR30 Options
24305
24306These options are defined specifically for the FR30 port.
24307
24308@table @gcctabopt
24309
24310@item -msmall-model
24311@opindex msmall-model
24312Use the small address space model. This can produce smaller code, but
24313it does assume that all symbolic values and addresses fit into a
2431420-bit range.
24315
24316@item -mno-lsim
24317@opindex mno-lsim
24318Assume that runtime support has been provided and so there is no need
24319to include the simulator library (@file{libsim.a}) on the linker
24320command line.
24321
24322@end table
24323
24324@node FT32 Options
24325@subsection FT32 Options
24326@cindex FT32 Options
24327
24328These options are defined specifically for the FT32 port.
24329
24330@table @gcctabopt
24331
24332@item -msim
24333@opindex msim
24334Specifies that the program will be run on the simulator. This causes
24335an alternate runtime startup and library to be linked.
24336You must not use this option when generating programs that will run on
24337real hardware; you must provide your own runtime library for whatever
24338I/O functions are needed.
24339
24340@item -mlra
24341@opindex mlra
24342Enable Local Register Allocation. This is still experimental for FT32,
24343so by default the compiler uses standard reload.
24344
24345@item -mnodiv
24346@opindex mnodiv
24347Do not use div and mod instructions.
24348
24349@item -mft32b
24350@opindex mft32b
24351Enable use of the extended instructions of the FT32B processor.
24352
24353@item -mcompress
24354@opindex mcompress
24355Compress all code using the Ft32B code compression scheme.
24356
24357@item -mnopm
24358@opindex mnopm
24359Do not generate code that reads program memory.
24360
24361@end table
24362
24363@node FRV Options
24364@subsection FRV Options
24365@cindex FRV Options
24366
24367@table @gcctabopt
24368@item -mgpr-32
24369@opindex mgpr-32
24370
24371Only use the first 32 general-purpose registers.
24372
24373@item -mgpr-64
24374@opindex mgpr-64
24375
24376Use all 64 general-purpose registers.
24377
24378@item -mfpr-32
24379@opindex mfpr-32
24380
24381Use only the first 32 floating-point registers.
24382
24383@item -mfpr-64
24384@opindex mfpr-64
24385
24386Use all 64 floating-point registers.
24387
24388@item -mhard-float
24389@opindex mhard-float
24390
24391Use hardware instructions for floating-point operations.
24392
24393@item -msoft-float
24394@opindex msoft-float
24395
24396Use library routines for floating-point operations.
24397
24398@item -malloc-cc
24399@opindex malloc-cc
24400
24401Dynamically allocate condition code registers.
24402
24403@item -mfixed-cc
24404@opindex mfixed-cc
24405
24406Do not try to dynamically allocate condition code registers, only
24407use @code{icc0} and @code{fcc0}.
24408
24409@item -mdword
24410@opindex mdword
24411
24412Change ABI to use double word insns.
24413
24414@item -mno-dword
24415@opindex mno-dword
24416@opindex mdword
24417
24418Do not use double word instructions.
24419
24420@item -mdouble
24421@opindex mdouble
24422
24423Use floating-point double instructions.
24424
24425@item -mno-double
24426@opindex mno-double
24427
24428Do not use floating-point double instructions.
24429
24430@item -mmedia
24431@opindex mmedia
24432
24433Use media instructions.
24434
24435@item -mno-media
24436@opindex mno-media
24437
24438Do not use media instructions.
24439
24440@item -mmuladd
24441@opindex mmuladd
24442
24443Use multiply and add/subtract instructions.
24444
24445@item -mno-muladd
24446@opindex mno-muladd
24447
24448Do not use multiply and add/subtract instructions.
24449
24450@item -mfdpic
24451@opindex mfdpic
24452
24453Select the FDPIC ABI, which uses function descriptors to represent
24454pointers to functions. Without any PIC/PIE-related options, it
24455implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
24456assumes GOT entries and small data are within a 12-bit range from the
24457GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
24458are computed with 32 bits.
24459With a @samp{bfin-elf} target, this option implies @option{-msim}.
24460
24461@item -minline-plt
24462@opindex minline-plt
24463
24464Enable inlining of PLT entries in function calls to functions that are
24465not known to bind locally. It has no effect without @option{-mfdpic}.
24466It's enabled by default if optimizing for speed and compiling for
24467shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
24468optimization option such as @option{-O3} or above is present in the
24469command line.
24470
24471@item -mTLS
24472@opindex mTLS
24473
24474Assume a large TLS segment when generating thread-local code.
24475
24476@item -mtls
24477@opindex mtls
24478
24479Do not assume a large TLS segment when generating thread-local code.
24480
24481@item -mgprel-ro
24482@opindex mgprel-ro
24483
24484Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
24485that is known to be in read-only sections. It's enabled by default,
24486except for @option{-fpic} or @option{-fpie}: even though it may help
24487make the global offset table smaller, it trades 1 instruction for 4.
24488With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
24489one of which may be shared by multiple symbols, and it avoids the need
24490for a GOT entry for the referenced symbol, so it's more likely to be a
24491win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
24492
24493@item -multilib-library-pic
24494@opindex multilib-library-pic
24495
24496Link with the (library, not FD) pic libraries. It's implied by
24497@option{-mlibrary-pic}, as well as by @option{-fPIC} and
24498@option{-fpic} without @option{-mfdpic}. You should never have to use
24499it explicitly.
24500
24501@item -mlinked-fp
24502@opindex mlinked-fp
24503
24504Follow the EABI requirement of always creating a frame pointer whenever
24505a stack frame is allocated. This option is enabled by default and can
24506be disabled with @option{-mno-linked-fp}.
24507
24508@item -mlong-calls
24509@opindex mlong-calls
24510
24511Use indirect addressing to call functions outside the current
24512compilation unit. This allows the functions to be placed anywhere
24513within the 32-bit address space.
24514
24515@item -malign-labels
24516@opindex malign-labels
24517
24518Try to align labels to an 8-byte boundary by inserting NOPs into the
24519previous packet. This option only has an effect when VLIW packing
24520is enabled. It doesn't create new packets; it merely adds NOPs to
24521existing ones.
24522
24523@item -mlibrary-pic
24524@opindex mlibrary-pic
24525
24526Generate position-independent EABI code.
24527
24528@item -macc-4
24529@opindex macc-4
24530
24531Use only the first four media accumulator registers.
24532
24533@item -macc-8
24534@opindex macc-8
24535
24536Use all eight media accumulator registers.
24537
24538@item -mpack
24539@opindex mpack
24540
24541Pack VLIW instructions.
24542
24543@item -mno-pack
24544@opindex mno-pack
24545
24546Do not pack VLIW instructions.
24547
24548@item -mno-eflags
24549@opindex mno-eflags
24550
24551Do not mark ABI switches in e_flags.
24552
24553@item -mcond-move
24554@opindex mcond-move
24555
24556Enable the use of conditional-move instructions (default).
24557
24558This switch is mainly for debugging the compiler and will likely be removed
24559in a future version.
24560
24561@item -mno-cond-move
24562@opindex mno-cond-move
24563
24564Disable the use of conditional-move instructions.
24565
24566This switch is mainly for debugging the compiler and will likely be removed
24567in a future version.
24568
24569@item -mscc
24570@opindex mscc
24571
24572Enable the use of conditional set instructions (default).
24573
24574This switch is mainly for debugging the compiler and will likely be removed
24575in a future version.
24576
24577@item -mno-scc
24578@opindex mno-scc
24579
24580Disable the use of conditional set instructions.
24581
24582This switch is mainly for debugging the compiler and will likely be removed
24583in a future version.
24584
24585@item -mcond-exec
24586@opindex mcond-exec
24587
24588Enable the use of conditional execution (default).
24589
24590This switch is mainly for debugging the compiler and will likely be removed
24591in a future version.
24592
24593@item -mno-cond-exec
24594@opindex mno-cond-exec
24595
24596Disable the use of conditional execution.
24597
24598This switch is mainly for debugging the compiler and will likely be removed
24599in a future version.
24600
24601@item -mvliw-branch
24602@opindex mvliw-branch
24603
24604Run a pass to pack branches into VLIW instructions (default).
24605
24606This switch is mainly for debugging the compiler and will likely be removed
24607in a future version.
24608
24609@item -mno-vliw-branch
24610@opindex mno-vliw-branch
24611
24612Do not run a pass to pack branches into VLIW instructions.
24613
24614This switch is mainly for debugging the compiler and will likely be removed
24615in a future version.
24616
24617@item -mmulti-cond-exec
24618@opindex mmulti-cond-exec
24619
24620Enable optimization of @code{&&} and @code{||} in conditional execution
24621(default).
24622
24623This switch is mainly for debugging the compiler and will likely be removed
24624in a future version.
24625
24626@item -mno-multi-cond-exec
24627@opindex mno-multi-cond-exec
24628
24629Disable optimization of @code{&&} and @code{||} in conditional execution.
24630
24631This switch is mainly for debugging the compiler and will likely be removed
24632in a future version.
24633
24634@item -mnested-cond-exec
24635@opindex mnested-cond-exec
24636
24637Enable nested conditional execution optimizations (default).
24638
24639This switch is mainly for debugging the compiler and will likely be removed
24640in a future version.
24641
24642@item -mno-nested-cond-exec
24643@opindex mno-nested-cond-exec
24644
24645Disable nested conditional execution optimizations.
24646
24647This switch is mainly for debugging the compiler and will likely be removed
24648in a future version.
24649
24650@item -moptimize-membar
24651@opindex moptimize-membar
24652
24653This switch removes redundant @code{membar} instructions from the
24654compiler-generated code. It is enabled by default.
24655
24656@item -mno-optimize-membar
24657@opindex mno-optimize-membar
24658@opindex moptimize-membar
24659
24660This switch disables the automatic removal of redundant @code{membar}
24661instructions from the generated code.
24662
24663@item -mtomcat-stats
24664@opindex mtomcat-stats
24665
24666Cause gas to print out tomcat statistics.
24667
24668@item -mcpu=@var{cpu}
24669@opindex mcpu
24670
24671Select the processor type for which to generate code. Possible values are
24672@samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
24673@samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
24674
24675@end table
24676
24677@node GNU/Linux Options
24678@subsection GNU/Linux Options
24679
24680These @samp{-m} options are defined for GNU/Linux targets:
24681
24682@table @gcctabopt
24683@item -mglibc
24684@opindex mglibc
24685Use the GNU C library. This is the default except
24686on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
24687@samp{*-*-linux-*android*} targets.
24688
24689@item -muclibc
24690@opindex muclibc
24691Use uClibc C library. This is the default on
24692@samp{*-*-linux-*uclibc*} targets.
24693
24694@item -mmusl
24695@opindex mmusl
24696Use the musl C library. This is the default on
24697@samp{*-*-linux-*musl*} targets.
24698
24699@item -mbionic
24700@opindex mbionic
24701Use Bionic C library. This is the default on
24702@samp{*-*-linux-*android*} targets.
24703
24704@item -mandroid
24705@opindex mandroid
24706Compile code compatible with Android platform. This is the default on
24707@samp{*-*-linux-*android*} targets.
24708
24709When compiling, this option enables @option{-mbionic}, @option{-fPIC},
24710@option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
24711this option makes the GCC driver pass Android-specific options to the linker.
24712Finally, this option causes the preprocessor macro @code{__ANDROID__}
24713to be defined.
24714
24715@item -tno-android-cc
24716@opindex tno-android-cc
24717Disable compilation effects of @option{-mandroid}, i.e., do not enable
24718@option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
24719@option{-fno-rtti} by default.
24720
24721@item -tno-android-ld
24722@opindex tno-android-ld
24723Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
24724linking options to the linker.
24725
24726@end table
24727
24728@node H8/300 Options
24729@subsection H8/300 Options
24730
24731These @samp{-m} options are defined for the H8/300 implementations:
24732
24733@table @gcctabopt
24734@item -mrelax
24735@opindex mrelax
24736Shorten some address references at link time, when possible; uses the
24737linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
24738ld, Using ld}, for a fuller description.
24739
24740@item -mh
24741@opindex mh
24742Generate code for the H8/300H@.
24743
24744@item -ms
24745@opindex ms
24746Generate code for the H8S@.
24747
24748@item -mn
24749@opindex mn
24750Generate code for the H8S and H8/300H in the normal mode. This switch
24751must be used either with @option{-mh} or @option{-ms}.
24752
24753@item -ms2600
24754@opindex ms2600
24755Generate code for the H8S/2600. This switch must be used with @option{-ms}.
24756
24757@item -mexr
24758@opindex mexr
24759Extended registers are stored on stack before execution of function
24760with monitor attribute. Default option is @option{-mexr}.
24761This option is valid only for H8S targets.
24762
24763@item -mno-exr
24764@opindex mno-exr
24765@opindex mexr
24766Extended registers are not stored on stack before execution of function
24767with monitor attribute. Default option is @option{-mno-exr}.
24768This option is valid only for H8S targets.
24769
24770@item -mint32
24771@opindex mint32
24772Make @code{int} data 32 bits by default.
24773
24774@item -malign-300
24775@opindex malign-300
24776On the H8/300H and H8S, use the same alignment rules as for the H8/300.
24777The default for the H8/300H and H8S is to align longs and floats on
247784-byte boundaries.
24779@option{-malign-300} causes them to be aligned on 2-byte boundaries.
24780This option has no effect on the H8/300.
24781@end table
24782
24783@node HPPA Options
24784@subsection HPPA Options
24785@cindex HPPA Options
24786
24787These @samp{-m} options are defined for the HPPA family of computers:
24788
24789@table @gcctabopt
24790@item -march=@var{architecture-type}
24791@opindex march
24792Generate code for the specified architecture. The choices for
24793@var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
247941.1, and @samp{2.0} for PA 2.0 processors. Refer to
24795@file{/usr/lib/sched.models} on an HP-UX system to determine the proper
24796architecture option for your machine. Code compiled for lower numbered
24797architectures runs on higher numbered architectures, but not the
24798other way around.
24799
24800@item -mpa-risc-1-0
24801@itemx -mpa-risc-1-1
24802@itemx -mpa-risc-2-0
24803@opindex mpa-risc-1-0
24804@opindex mpa-risc-1-1
24805@opindex mpa-risc-2-0
24806Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
24807
24808@item -mcaller-copies
24809@opindex mcaller-copies
24810The caller copies function arguments passed by hidden reference. This
24811option should be used with care as it is not compatible with the default
2481232-bit runtime. However, only aggregates larger than eight bytes are
24813passed by hidden reference and the option provides better compatibility
24814with OpenMP.
24815
24816@item -mjump-in-delay
24817@opindex mjump-in-delay
24818This option is ignored and provided for compatibility purposes only.
24819
24820@item -mdisable-fpregs
24821@opindex mdisable-fpregs
24822Prevent floating-point registers from being used in any manner. This is
24823necessary for compiling kernels that perform lazy context switching of
24824floating-point registers. If you use this option and attempt to perform
24825floating-point operations, the compiler aborts.
24826
24827@item -mdisable-indexing
24828@opindex mdisable-indexing
24829Prevent the compiler from using indexing address modes. This avoids some
24830rather obscure problems when compiling MIG generated code under MACH@.
24831
24832@item -mno-space-regs
24833@opindex mno-space-regs
24834@opindex mspace-regs
24835Generate code that assumes the target has no space registers. This allows
24836GCC to generate faster indirect calls and use unscaled index address modes.
24837
24838Such code is suitable for level 0 PA systems and kernels.
24839
24840@item -mfast-indirect-calls
24841@opindex mfast-indirect-calls
24842Generate code that assumes calls never cross space boundaries. This
24843allows GCC to emit code that performs faster indirect calls.
24844
24845This option does not work in the presence of shared libraries or nested
24846functions.
24847
24848@item -mfixed-range=@var{register-range}
24849@opindex mfixed-range
24850Generate code treating the given register range as fixed registers.
24851A fixed register is one that the register allocator cannot use. This is
24852useful when compiling kernel code. A register range is specified as
24853two registers separated by a dash. Multiple register ranges can be
24854specified separated by a comma.
24855
24856@item -mlong-load-store
24857@opindex mlong-load-store
24858Generate 3-instruction load and store sequences as sometimes required by
24859the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
24860the HP compilers.
24861
24862@item -mportable-runtime
24863@opindex mportable-runtime
24864Use the portable calling conventions proposed by HP for ELF systems.
24865
24866@item -mgas
24867@opindex mgas
24868Enable the use of assembler directives only GAS understands.
24869
24870@item -mschedule=@var{cpu-type}
24871@opindex mschedule
24872Schedule code according to the constraints for the machine type
24873@var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
24874@samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
24875to @file{/usr/lib/sched.models} on an HP-UX system to determine the
24876proper scheduling option for your machine. The default scheduling is
24877@samp{8000}.
24878
24879@item -mlinker-opt
24880@opindex mlinker-opt
24881Enable the optimization pass in the HP-UX linker. Note this makes symbolic
24882debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
24883linkers in which they give bogus error messages when linking some programs.
24884
24885@item -msoft-float
24886@opindex msoft-float
24887Generate output containing library calls for floating point.
24888@strong{Warning:} the requisite libraries are not available for all HPPA
24889targets. Normally the facilities of the machine's usual C compiler are
24890used, but this cannot be done directly in cross-compilation. You must make
24891your own arrangements to provide suitable library functions for
24892cross-compilation.
24893
24894@option{-msoft-float} changes the calling convention in the output file;
24895therefore, it is only useful if you compile @emph{all} of a program with
24896this option. In particular, you need to compile @file{libgcc.a}, the
24897library that comes with GCC, with @option{-msoft-float} in order for
24898this to work.
24899
24900@item -msio
24901@opindex msio
24902Generate the predefine, @code{_SIO}, for server IO@. The default is
24903@option{-mwsio}. This generates the predefines, @code{__hp9000s700},
24904@code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
24905options are available under HP-UX and HI-UX@.
24906
24907@item -mgnu-ld
24908@opindex mgnu-ld
24909Use options specific to GNU @command{ld}.
24910This passes @option{-shared} to @command{ld} when
24911building a shared library. It is the default when GCC is configured,
24912explicitly or implicitly, with the GNU linker. This option does not
24913affect which @command{ld} is called; it only changes what parameters
24914are passed to that @command{ld}.
24915The @command{ld} that is called is determined by the
24916@option{--with-ld} configure option, GCC's program search path, and
24917finally by the user's @env{PATH}. The linker used by GCC can be printed
24918using @samp{which `gcc -print-prog-name=ld`}. This option is only available
24919on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
24920
24921@item -mhp-ld
24922@opindex mhp-ld
24923Use options specific to HP @command{ld}.
24924This passes @option{-b} to @command{ld} when building
24925a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
24926links. It is the default when GCC is configured, explicitly or
24927implicitly, with the HP linker. This option does not affect
24928which @command{ld} is called; it only changes what parameters are passed to that
24929@command{ld}.
24930The @command{ld} that is called is determined by the @option{--with-ld}
24931configure option, GCC's program search path, and finally by the user's
24932@env{PATH}. The linker used by GCC can be printed using @samp{which
24933`gcc -print-prog-name=ld`}. This option is only available on the 64-bit
24934HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
24935
24936@item -mlong-calls
24937@opindex mno-long-calls
24938@opindex mlong-calls
24939Generate code that uses long call sequences. This ensures that a call
24940is always able to reach linker generated stubs. The default is to generate
24941long calls only when the distance from the call site to the beginning
24942of the function or translation unit, as the case may be, exceeds a
24943predefined limit set by the branch type being used. The limits for
24944normal calls are 7,600,000 and 240,000 bytes, respectively for the
24945PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
24946240,000 bytes.
24947
24948Distances are measured from the beginning of functions when using the
24949@option{-ffunction-sections} option, or when using the @option{-mgas}
24950and @option{-mno-portable-runtime} options together under HP-UX with
24951the SOM linker.
24952
24953It is normally not desirable to use this option as it degrades
24954performance. However, it may be useful in large applications,
24955particularly when partial linking is used to build the application.
24956
24957The types of long calls used depends on the capabilities of the
24958assembler and linker, and the type of code being generated. The
24959impact on systems that support long absolute calls, and long pic
24960symbol-difference or pc-relative calls should be relatively small.
24961However, an indirect call is used on 32-bit ELF systems in pic code
24962and it is quite long.
24963
24964@item -munix=@var{unix-std}
24965@opindex march
24966Generate compiler predefines and select a startfile for the specified
24967UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
24968and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
24969is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
2497011.11 and later. The default values are @samp{93} for HP-UX 10.00,
24971@samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
24972and later.
24973
24974@option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
24975@option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
24976and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
24977@option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
24978@code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
24979@code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
24980
24981It is @emph{important} to note that this option changes the interfaces
24982for various library routines. It also affects the operational behavior
24983of the C library. Thus, @emph{extreme} care is needed in using this
24984option.
24985
24986Library code that is intended to operate with more than one UNIX
24987standard must test, set and restore the variable @code{__xpg4_extended_mask}
24988as appropriate. Most GNU software doesn't provide this capability.
24989
24990@item -nolibdld
24991@opindex nolibdld
24992Suppress the generation of link options to search libdld.sl when the
24993@option{-static} option is specified on HP-UX 10 and later.
24994
24995@item -static
24996@opindex static
24997The HP-UX implementation of setlocale in libc has a dependency on
24998libdld.sl. There isn't an archive version of libdld.sl. Thus,
24999when the @option{-static} option is specified, special link options
25000are needed to resolve this dependency.
25001
25002On HP-UX 10 and later, the GCC driver adds the necessary options to
25003link with libdld.sl when the @option{-static} option is specified.
25004This causes the resulting binary to be dynamic. On the 64-bit port,
25005the linkers generate dynamic binaries by default in any case. The
25006@option{-nolibdld} option can be used to prevent the GCC driver from
25007adding these link options.
25008
25009@item -threads
25010@opindex threads
25011Add support for multithreading with the @dfn{dce thread} library
25012under HP-UX@. This option sets flags for both the preprocessor and
25013linker.
25014@end table
25015
25016@node IA-64 Options
25017@subsection IA-64 Options
25018@cindex IA-64 Options
25019
25020These are the @samp{-m} options defined for the Intel IA-64 architecture.
25021
25022@table @gcctabopt
25023@item -mbig-endian
25024@opindex mbig-endian
25025Generate code for a big-endian target. This is the default for HP-UX@.
25026
25027@item -mlittle-endian
25028@opindex mlittle-endian
25029Generate code for a little-endian target. This is the default for AIX5
25030and GNU/Linux.
25031
25032@item -mgnu-as
25033@itemx -mno-gnu-as
25034@opindex mgnu-as
25035@opindex mno-gnu-as
25036Generate (or don't) code for the GNU assembler. This is the default.
25037@c Also, this is the default if the configure option @option{--with-gnu-as}
25038@c is used.
25039
25040@item -mgnu-ld
25041@itemx -mno-gnu-ld
25042@opindex mgnu-ld
25043@opindex mno-gnu-ld
25044Generate (or don't) code for the GNU linker. This is the default.
25045@c Also, this is the default if the configure option @option{--with-gnu-ld}
25046@c is used.
25047
25048@item -mno-pic
25049@opindex mno-pic
25050Generate code that does not use a global pointer register. The result
25051is not position independent code, and violates the IA-64 ABI@.
25052
25053@item -mvolatile-asm-stop
25054@itemx -mno-volatile-asm-stop
25055@opindex mvolatile-asm-stop
25056@opindex mno-volatile-asm-stop
25057Generate (or don't) a stop bit immediately before and after volatile asm
25058statements.
25059
25060@item -mregister-names
25061@itemx -mno-register-names
25062@opindex mregister-names
25063@opindex mno-register-names
25064Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
25065the stacked registers. This may make assembler output more readable.
25066
25067@item -mno-sdata
25068@itemx -msdata
25069@opindex mno-sdata
25070@opindex msdata
25071Disable (or enable) optimizations that use the small data section. This may
25072be useful for working around optimizer bugs.
25073
25074@item -mconstant-gp
25075@opindex mconstant-gp
25076Generate code that uses a single constant global pointer value. This is
25077useful when compiling kernel code.
25078
25079@item -mauto-pic
25080@opindex mauto-pic
25081Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
25082This is useful when compiling firmware code.
25083
25084@item -minline-float-divide-min-latency
25085@opindex minline-float-divide-min-latency
25086Generate code for inline divides of floating-point values
25087using the minimum latency algorithm.
25088
25089@item -minline-float-divide-max-throughput
25090@opindex minline-float-divide-max-throughput
25091Generate code for inline divides of floating-point values
25092using the maximum throughput algorithm.
25093
25094@item -mno-inline-float-divide
25095@opindex mno-inline-float-divide
25096Do not generate inline code for divides of floating-point values.
25097
25098@item -minline-int-divide-min-latency
25099@opindex minline-int-divide-min-latency
25100Generate code for inline divides of integer values
25101using the minimum latency algorithm.
25102
25103@item -minline-int-divide-max-throughput
25104@opindex minline-int-divide-max-throughput
25105Generate code for inline divides of integer values
25106using the maximum throughput algorithm.
25107
25108@item -mno-inline-int-divide
25109@opindex mno-inline-int-divide
25110@opindex minline-int-divide
25111Do not generate inline code for divides of integer values.
25112
25113@item -minline-sqrt-min-latency
25114@opindex minline-sqrt-min-latency
25115Generate code for inline square roots
25116using the minimum latency algorithm.
25117
25118@item -minline-sqrt-max-throughput
25119@opindex minline-sqrt-max-throughput
25120Generate code for inline square roots
25121using the maximum throughput algorithm.
25122
25123@item -mno-inline-sqrt
25124@opindex mno-inline-sqrt
25125Do not generate inline code for @code{sqrt}.
25126
25127@item -mfused-madd
25128@itemx -mno-fused-madd
25129@opindex mfused-madd
25130@opindex mno-fused-madd
25131Do (don't) generate code that uses the fused multiply/add or multiply/subtract
25132instructions. The default is to use these instructions.
25133
25134@item -mno-dwarf2-asm
25135@itemx -mdwarf2-asm
25136@opindex mno-dwarf2-asm
25137@opindex mdwarf2-asm
25138Don't (or do) generate assembler code for the DWARF line number debugging
25139info. This may be useful when not using the GNU assembler.
25140
25141@item -mearly-stop-bits
25142@itemx -mno-early-stop-bits
25143@opindex mearly-stop-bits
25144@opindex mno-early-stop-bits
25145Allow stop bits to be placed earlier than immediately preceding the
25146instruction that triggered the stop bit. This can improve instruction
25147scheduling, but does not always do so.
25148
25149@item -mfixed-range=@var{register-range}
25150@opindex mfixed-range
25151Generate code treating the given register range as fixed registers.
25152A fixed register is one that the register allocator cannot use. This is
25153useful when compiling kernel code. A register range is specified as
25154two registers separated by a dash. Multiple register ranges can be
25155specified separated by a comma.
25156
25157@item -mtls-size=@var{tls-size}
25158@opindex mtls-size
25159Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
2516064.
25161
25162@item -mtune=@var{cpu-type}
25163@opindex mtune
25164Tune the instruction scheduling for a particular CPU, Valid values are
25165@samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
25166and @samp{mckinley}.
25167
25168@item -milp32
25169@itemx -mlp64
25170@opindex milp32
25171@opindex mlp64
25172Generate code for a 32-bit or 64-bit environment.
25173The 32-bit environment sets int, long and pointer to 32 bits.
25174The 64-bit environment sets int to 32 bits and long and pointer
25175to 64 bits. These are HP-UX specific flags.
25176
25177@item -mno-sched-br-data-spec
25178@itemx -msched-br-data-spec
25179@opindex mno-sched-br-data-spec
25180@opindex msched-br-data-spec
25181(Dis/En)able data speculative scheduling before reload.
25182This results in generation of @code{ld.a} instructions and
25183the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25184The default setting is disabled.
25185
25186@item -msched-ar-data-spec
25187@itemx -mno-sched-ar-data-spec
25188@opindex msched-ar-data-spec
25189@opindex mno-sched-ar-data-spec
25190(En/Dis)able data speculative scheduling after reload.
25191This results in generation of @code{ld.a} instructions and
25192the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25193The default setting is enabled.
25194
25195@item -mno-sched-control-spec
25196@itemx -msched-control-spec
25197@opindex mno-sched-control-spec
25198@opindex msched-control-spec
25199(Dis/En)able control speculative scheduling. This feature is
25200available only during region scheduling (i.e.@: before reload).
25201This results in generation of the @code{ld.s} instructions and
25202the corresponding check instructions @code{chk.s}.
25203The default setting is disabled.
25204
25205@item -msched-br-in-data-spec
25206@itemx -mno-sched-br-in-data-spec
25207@opindex msched-br-in-data-spec
25208@opindex mno-sched-br-in-data-spec
25209(En/Dis)able speculative scheduling of the instructions that
25210are dependent on the data speculative loads before reload.
25211This is effective only with @option{-msched-br-data-spec} enabled.
25212The default setting is enabled.
25213
25214@item -msched-ar-in-data-spec
25215@itemx -mno-sched-ar-in-data-spec
25216@opindex msched-ar-in-data-spec
25217@opindex mno-sched-ar-in-data-spec
25218(En/Dis)able speculative scheduling of the instructions that
25219are dependent on the data speculative loads after reload.
25220This is effective only with @option{-msched-ar-data-spec} enabled.
25221The default setting is enabled.
25222
25223@item -msched-in-control-spec
25224@itemx -mno-sched-in-control-spec
25225@opindex msched-in-control-spec
25226@opindex mno-sched-in-control-spec
25227(En/Dis)able speculative scheduling of the instructions that
25228are dependent on the control speculative loads.
25229This is effective only with @option{-msched-control-spec} enabled.
25230The default setting is enabled.
25231
25232@item -mno-sched-prefer-non-data-spec-insns
25233@itemx -msched-prefer-non-data-spec-insns
25234@opindex mno-sched-prefer-non-data-spec-insns
25235@opindex msched-prefer-non-data-spec-insns
25236If enabled, data-speculative instructions are chosen for schedule
25237only if there are no other choices at the moment. This makes
25238the use of the data speculation much more conservative.
25239The default setting is disabled.
25240
25241@item -mno-sched-prefer-non-control-spec-insns
25242@itemx -msched-prefer-non-control-spec-insns
25243@opindex mno-sched-prefer-non-control-spec-insns
25244@opindex msched-prefer-non-control-spec-insns
25245If enabled, control-speculative instructions are chosen for schedule
25246only if there are no other choices at the moment. This makes
25247the use of the control speculation much more conservative.
25248The default setting is disabled.
25249
25250@item -mno-sched-count-spec-in-critical-path
25251@itemx -msched-count-spec-in-critical-path
25252@opindex mno-sched-count-spec-in-critical-path
25253@opindex msched-count-spec-in-critical-path
25254If enabled, speculative dependencies are considered during
25255computation of the instructions priorities. This makes the use of the
25256speculation a bit more conservative.
25257The default setting is disabled.
25258
25259@item -msched-spec-ldc
25260@opindex msched-spec-ldc
25261Use a simple data speculation check. This option is on by default.
25262
25263@item -msched-control-spec-ldc
25264@opindex msched-spec-ldc
25265Use a simple check for control speculation. This option is on by default.
25266
25267@item -msched-stop-bits-after-every-cycle
25268@opindex msched-stop-bits-after-every-cycle
25269Place a stop bit after every cycle when scheduling. This option is on
25270by default.
25271
25272@item -msched-fp-mem-deps-zero-cost
25273@opindex msched-fp-mem-deps-zero-cost
25274Assume that floating-point stores and loads are not likely to cause a conflict
25275when placed into the same instruction group. This option is disabled by
25276default.
25277
25278@item -msel-sched-dont-check-control-spec
25279@opindex msel-sched-dont-check-control-spec
25280Generate checks for control speculation in selective scheduling.
25281This flag is disabled by default.
25282
25283@item -msched-max-memory-insns=@var{max-insns}
25284@opindex msched-max-memory-insns
25285Limit on the number of memory insns per instruction group, giving lower
25286priority to subsequent memory insns attempting to schedule in the same
25287instruction group. Frequently useful to prevent cache bank conflicts.
25288The default value is 1.
25289
25290@item -msched-max-memory-insns-hard-limit
25291@opindex msched-max-memory-insns-hard-limit
25292Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
25293disallowing more than that number in an instruction group.
25294Otherwise, the limit is ``soft'', meaning that non-memory operations
25295are preferred when the limit is reached, but memory operations may still
25296be scheduled.
25297
25298@end table
25299
25300@node LM32 Options
25301@subsection LM32 Options
25302@cindex LM32 options
25303
25304These @option{-m} options are defined for the LatticeMico32 architecture:
25305
25306@table @gcctabopt
25307@item -mbarrel-shift-enabled
25308@opindex mbarrel-shift-enabled
25309Enable barrel-shift instructions.
25310
25311@item -mdivide-enabled
25312@opindex mdivide-enabled
25313Enable divide and modulus instructions.
25314
25315@item -mmultiply-enabled
25316@opindex multiply-enabled
25317Enable multiply instructions.
25318
25319@item -msign-extend-enabled
25320@opindex msign-extend-enabled
25321Enable sign extend instructions.
25322
25323@item -muser-enabled
25324@opindex muser-enabled
25325Enable user-defined instructions.
25326
25327@end table
25328
25329@node LoongArch Options
25330@subsection LoongArch Options
25331@cindex LoongArch Options
25332
25333These command-line options are defined for LoongArch targets:
25334
25335@table @gcctabopt
25336@item -march=@var{cpu-type}
9c19597c 25337@opindex march
d77de738
ML
25338Generate instructions for the machine type @var{cpu-type}. In contrast to
25339@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
25340for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
25341to generate code that may not run at all on processors other than the one
25342indicated. Specifying @option{-march=@var{cpu-type}} implies
25343@option{-mtune=@var{cpu-type}}, except where noted otherwise.
25344
25345The choices for @var{cpu-type} are:
25346
25347@table @samp
25348@item native
25349This selects the CPU to generate code for at compilation time by determining
25350the processor type of the compiling machine. Using @option{-march=native}
25351enables all instruction subsets supported by the local machine (hence
25352the result might not run on different machines). Using @option{-mtune=native}
25353produces code optimized for the local machine under the constraints
25354of the selected instruction set.
25355@item loongarch64
25356A generic CPU with 64-bit extensions.
25357@item la464
25358LoongArch LA464 CPU with LBT, LSX, LASX, LVZ.
25359@end table
25360
25361@item -mtune=@var{cpu-type}
25362@opindex mtune
25363Optimize the output for the given processor, specified by microarchitecture
25364name.
25365
25366@item -mabi=@var{base-abi-type}
25367@opindex mabi
25368Generate code for the specified calling convention.
25369@var{base-abi-type} can be one of:
25370@table @samp
25371@item lp64d
25372Uses 64-bit general purpose registers and 32/64-bit floating-point
25373registers for parameter passing. Data model is LP64, where @samp{int}
25374is 32 bits, while @samp{long int} and pointers are 64 bits.
25375@item lp64f
25376Uses 64-bit general purpose registers and 32-bit floating-point
25377registers for parameter passing. Data model is LP64, where @samp{int}
25378is 32 bits, while @samp{long int} and pointers are 64 bits.
25379@item lp64s
25380Uses 64-bit general purpose registers and no floating-point
25381registers for parameter passing. Data model is LP64, where @samp{int}
25382is 32 bits, while @samp{long int} and pointers are 64 bits.
25383@end table
25384
25385@item -mfpu=@var{fpu-type}
25386@opindex mfpu
25387Generate code for the specified FPU type, which can be one of:
25388@table @samp
25389@item 64
25390Allow the use of hardware floating-point instructions for 32-bit
25391and 64-bit operations.
25392@item 32
25393Allow the use of hardware floating-point instructions for 32-bit
25394operations.
25395@item none
25396@item 0
25397Prevent the use of hardware floating-point instructions.
25398@end table
25399
25400@item -msoft-float
25401@opindex msoft-float
25402Force @option{-mfpu=none} and prevents the use of floating-point
25403registers for parameter passing. This option may change the target
25404ABI.
25405
25406@item -msingle-float
9c19597c 25407@opindex msingle-float
d77de738
ML
25408Force @option{-mfpu=32} and allow the use of 32-bit floating-point
25409registers for parameter passing. This option may change the target
25410ABI.
25411
25412@item -mdouble-float
9c19597c 25413@opindex mdouble-float
d77de738
ML
25414Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point
25415registers for parameter passing. This option may change the target
25416ABI.
25417
25418@item -mbranch-cost=@var{n}
9c19597c 25419@opindex mbranch-cost
d77de738
ML
25420Set the cost of branches to roughly @var{n} instructions.
25421
25422@item -mcheck-zero-division
25423@itemx -mno-check-zero-divison
9c19597c 25424@opindex mcheck-zero-division
d77de738
ML
25425Trap (do not trap) on integer division by zero. The default is
25426@option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and
25427@option{-mno-check-zero-division} for other optimization levels.
25428
25429@item -mcond-move-int
25430@itemx -mno-cond-move-int
9c19597c 25431@opindex mcond-move-int
d77de738
ML
25432Conditional moves for integral data in general-purpose registers
25433are enabled (disabled). The default is @option{-mcond-move-int}.
25434
25435@item -mcond-move-float
25436@itemx -mno-cond-move-float
9c19597c 25437@opindex mcond-move-float
d77de738
ML
25438Conditional moves for floating-point registers are enabled (disabled).
25439The default is @option{-mcond-move-float}.
25440
25441@item -mmemcpy
25442@itemx -mno-memcpy
9c19597c 25443@opindex mmemcpy
d77de738
ML
25444Force (do not force) the use of @code{memcpy} for non-trivial block moves.
25445The default is @option{-mno-memcpy}, which allows GCC to inline most
25446constant-sized copies. Setting optimization level to @option{-Os} also
25447forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this
25448behavior if explicitly specified, regardless of the order these options on
25449the command line.
25450
25451@item -mstrict-align
25452@itemx -mno-strict-align
9c19597c 25453@opindex mstrict-align
d77de738
ML
25454Avoid or allow generating memory accesses that may not be aligned on a natural
25455object boundary as described in the architecture specification. The default is
25456@option{-mno-strict-align}.
25457
25458@item -msmall-data-limit=@var{number}
9c19597c 25459@opindex msmall-data-limit
d77de738
ML
25460Put global and static data smaller than @var{number} bytes into a special
25461section (on some targets). The default value is 0.
25462
25463@item -mmax-inline-memcpy-size=@var{n}
9c19597c 25464@opindex mmax-inline-memcpy-size
d77de738
ML
25465Inline all block moves (such as calls to @code{memcpy} or structure copies)
25466less than or equal to @var{n} bytes. The default value of @var{n} is 1024.
25467
25468@item -mcmodel=@var{code-model}
25469Set the code model to one of:
25470@table @samp
25471@item tiny-static (Not implemented yet)
25472@item tiny (Not implemented yet)
25473
25474@item normal
25475The text segment must be within 128MB addressing space. The data segment must
25476be within 2GB addressing space.
25477
25478@item medium
25479The text segment and data segment must be within 2GB addressing space.
25480
25481@item large (Not implemented yet)
25482
25483@item extreme
25484This mode does not limit the size of the code segment and data segment.
25485The @option{-mcmodel=extreme} option is incompatible with @option{-fplt} and
25486@option{-mno-explicit-relocs}.
25487@end table
25488The default code model is @code{normal}.
25489
25490@item -mexplicit-relocs
25491@itemx -mno-explicit-relocs
25492@opindex mexplicit-relocs
25493@opindex mno-explicit-relocs
25494Use or do not use assembler relocation operators when dealing with symbolic
25495addresses. The alternative is to use assembler macros instead, which may
25496limit optimization. The default value for the option is determined during
25497GCC build-time by detecting corresponding assembler support:
25498@code{-mexplicit-relocs} if said support is present,
25499@code{-mno-explicit-relocs} otherwise. This option is mostly useful for
25500debugging, or interoperation with assemblers different from the build-time
25501one.
25502
25503@item -mdirect-extern-access
25504@itemx -mno-direct-extern-access
25505@opindex mdirect-extern-access
25506Do not use or use GOT to access external symbols. The default is
25507@option{-mno-direct-extern-access}: GOT is used for external symbols with
25508default visibility, but not used for other external symbols.
25509
25510With @option{-mdirect-extern-access}, GOT is not used and all external
25511symbols are PC-relatively addressed. It is @strong{only} suitable for
25512environments where no dynamic link is performed, like firmwares, OS
25513kernels, executables linked with @option{-static} or @option{-static-pie}.
25514@option{-mdirect-extern-access} is not compatible with @option{-fPIC} or
25515@option{-fpic}.
25516@end table
25517
25518@node M32C Options
25519@subsection M32C Options
25520@cindex M32C options
25521
25522@table @gcctabopt
25523@item -mcpu=@var{name}
25524@opindex mcpu=
25525Select the CPU for which code is generated. @var{name} may be one of
25526@samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
25527/60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
25528the M32C/80 series.
25529
25530@item -msim
25531@opindex msim
25532Specifies that the program will be run on the simulator. This causes
25533an alternate runtime library to be linked in which supports, for
25534example, file I/O@. You must not use this option when generating
25535programs that will run on real hardware; you must provide your own
25536runtime library for whatever I/O functions are needed.
25537
25538@item -memregs=@var{number}
25539@opindex memregs=
25540Specifies the number of memory-based pseudo-registers GCC uses
25541during code generation. These pseudo-registers are used like real
25542registers, so there is a tradeoff between GCC's ability to fit the
25543code into available registers, and the performance penalty of using
25544memory instead of registers. Note that all modules in a program must
25545be compiled with the same value for this option. Because of that, you
25546must not use this option with GCC's default runtime libraries.
25547
25548@end table
25549
25550@node M32R/D Options
25551@subsection M32R/D Options
25552@cindex M32R/D options
25553
25554These @option{-m} options are defined for Renesas M32R/D architectures:
25555
25556@table @gcctabopt
25557@item -m32r2
25558@opindex m32r2
25559Generate code for the M32R/2@.
25560
25561@item -m32rx
25562@opindex m32rx
25563Generate code for the M32R/X@.
25564
25565@item -m32r
25566@opindex m32r
25567Generate code for the M32R@. This is the default.
25568
25569@item -mmodel=small
25570@opindex mmodel=small
25571Assume all objects live in the lower 16MB of memory (so that their addresses
25572can be loaded with the @code{ld24} instruction), and assume all subroutines
25573are reachable with the @code{bl} instruction.
25574This is the default.
25575
25576The addressability of a particular object can be set with the
25577@code{model} attribute.
25578
25579@item -mmodel=medium
25580@opindex mmodel=medium
25581Assume objects may be anywhere in the 32-bit address space (the compiler
25582generates @code{seth/add3} instructions to load their addresses), and
25583assume all subroutines are reachable with the @code{bl} instruction.
25584
25585@item -mmodel=large
25586@opindex mmodel=large
25587Assume objects may be anywhere in the 32-bit address space (the compiler
25588generates @code{seth/add3} instructions to load their addresses), and
25589assume subroutines may not be reachable with the @code{bl} instruction
25590(the compiler generates the much slower @code{seth/add3/jl}
25591instruction sequence).
25592
25593@item -msdata=none
25594@opindex msdata=none
25595Disable use of the small data area. Variables are put into
25596one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
25597@code{section} attribute has been specified).
25598This is the default.
25599
25600The small data area consists of sections @code{.sdata} and @code{.sbss}.
25601Objects may be explicitly put in the small data area with the
25602@code{section} attribute using one of these sections.
25603
25604@item -msdata=sdata
25605@opindex msdata=sdata
25606Put small global and static data in the small data area, but do not
25607generate special code to reference them.
25608
25609@item -msdata=use
25610@opindex msdata=use
25611Put small global and static data in the small data area, and generate
25612special instructions to reference them.
25613
25614@item -G @var{num}
25615@opindex G
25616@cindex smaller data references
25617Put global and static objects less than or equal to @var{num} bytes
25618into the small data or BSS sections instead of the normal data or BSS
25619sections. The default value of @var{num} is 8.
25620The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
25621for this option to have any effect.
25622
25623All modules should be compiled with the same @option{-G @var{num}} value.
25624Compiling with different values of @var{num} may or may not work; if it
25625doesn't the linker gives an error message---incorrect code is not
25626generated.
25627
25628@item -mdebug
25629@opindex mdebug
25630Makes the M32R-specific code in the compiler display some statistics
25631that might help in debugging programs.
25632
25633@item -malign-loops
25634@opindex malign-loops
25635Align all loops to a 32-byte boundary.
25636
25637@item -mno-align-loops
25638@opindex mno-align-loops
25639Do not enforce a 32-byte alignment for loops. This is the default.
25640
25641@item -missue-rate=@var{number}
25642@opindex missue-rate=@var{number}
25643Issue @var{number} instructions per cycle. @var{number} can only be 1
25644or 2.
25645
25646@item -mbranch-cost=@var{number}
25647@opindex mbranch-cost=@var{number}
25648@var{number} can only be 1 or 2. If it is 1 then branches are
25649preferred over conditional code, if it is 2, then the opposite applies.
25650
25651@item -mflush-trap=@var{number}
25652@opindex mflush-trap=@var{number}
25653Specifies the trap number to use to flush the cache. The default is
2565412. Valid numbers are between 0 and 15 inclusive.
25655
25656@item -mno-flush-trap
25657@opindex mno-flush-trap
25658Specifies that the cache cannot be flushed by using a trap.
25659
25660@item -mflush-func=@var{name}
25661@opindex mflush-func=@var{name}
25662Specifies the name of the operating system function to call to flush
25663the cache. The default is @samp{_flush_cache}, but a function call
25664is only used if a trap is not available.
25665
25666@item -mno-flush-func
25667@opindex mno-flush-func
25668Indicates that there is no OS function for flushing the cache.
25669
25670@end table
25671
25672@node M680x0 Options
25673@subsection M680x0 Options
25674@cindex M680x0 options
25675
25676These are the @samp{-m} options defined for M680x0 and ColdFire processors.
25677The default settings depend on which architecture was selected when
25678the compiler was configured; the defaults for the most common choices
25679are given below.
25680
25681@table @gcctabopt
25682@item -march=@var{arch}
25683@opindex march
25684Generate code for a specific M680x0 or ColdFire instruction set
25685architecture. Permissible values of @var{arch} for M680x0
25686architectures are: @samp{68000}, @samp{68010}, @samp{68020},
25687@samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
25688architectures are selected according to Freescale's ISA classification
25689and the permissible values are: @samp{isaa}, @samp{isaaplus},
25690@samp{isab} and @samp{isac}.
25691
25692GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
25693code for a ColdFire target. The @var{arch} in this macro is one of the
25694@option{-march} arguments given above.
25695
25696When used together, @option{-march} and @option{-mtune} select code
25697that runs on a family of similar processors but that is optimized
25698for a particular microarchitecture.
25699
25700@item -mcpu=@var{cpu}
25701@opindex mcpu
25702Generate code for a specific M680x0 or ColdFire processor.
25703The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
25704@samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
25705and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
25706below, which also classifies the CPUs into families:
25707
25708@multitable @columnfractions 0.20 0.80
25709@headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
25710@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}
25711@item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
25712@item @samp{5206e} @tab @samp{5206e}
25713@item @samp{5208} @tab @samp{5207} @samp{5208}
25714@item @samp{5211a} @tab @samp{5210a} @samp{5211a}
25715@item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
25716@item @samp{5216} @tab @samp{5214} @samp{5216}
25717@item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
25718@item @samp{5225} @tab @samp{5224} @samp{5225}
25719@item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
25720@item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
25721@item @samp{5249} @tab @samp{5249}
25722@item @samp{5250} @tab @samp{5250}
25723@item @samp{5271} @tab @samp{5270} @samp{5271}
25724@item @samp{5272} @tab @samp{5272}
25725@item @samp{5275} @tab @samp{5274} @samp{5275}
25726@item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
25727@item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
25728@item @samp{5307} @tab @samp{5307}
25729@item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
25730@item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
25731@item @samp{5407} @tab @samp{5407}
25732@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}
25733@end multitable
25734
25735@option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
25736@var{arch} is compatible with @var{cpu}. Other combinations of
25737@option{-mcpu} and @option{-march} are rejected.
25738
25739GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
25740@var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
25741where the value of @var{family} is given by the table above.
25742
25743@item -mtune=@var{tune}
25744@opindex mtune
25745Tune the code for a particular microarchitecture within the
25746constraints set by @option{-march} and @option{-mcpu}.
25747The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
25748@samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
25749and @samp{cpu32}. The ColdFire microarchitectures
25750are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
25751
25752You can also use @option{-mtune=68020-40} for code that needs
25753to run relatively well on 68020, 68030 and 68040 targets.
25754@option{-mtune=68020-60} is similar but includes 68060 targets
25755as well. These two options select the same tuning decisions as
25756@option{-m68020-40} and @option{-m68020-60} respectively.
25757
25758GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
25759when tuning for 680x0 architecture @var{arch}. It also defines
25760@code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
25761option is used. If GCC is tuning for a range of architectures,
25762as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
25763it defines the macros for every architecture in the range.
25764
25765GCC also defines the macro @code{__m@var{uarch}__} when tuning for
25766ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
25767of the arguments given above.
25768
25769@item -m68000
25770@itemx -mc68000
25771@opindex m68000
25772@opindex mc68000
25773Generate output for a 68000. This is the default
25774when the compiler is configured for 68000-based systems.
25775It is equivalent to @option{-march=68000}.
25776
25777Use this option for microcontrollers with a 68000 or EC000 core,
25778including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
25779
25780@item -m68010
25781@opindex m68010
25782Generate output for a 68010. This is the default
25783when the compiler is configured for 68010-based systems.
25784It is equivalent to @option{-march=68010}.
25785
25786@item -m68020
25787@itemx -mc68020
25788@opindex m68020
25789@opindex mc68020
25790Generate output for a 68020. This is the default
25791when the compiler is configured for 68020-based systems.
25792It is equivalent to @option{-march=68020}.
25793
25794@item -m68030
25795@opindex m68030
25796Generate output for a 68030. This is the default when the compiler is
25797configured for 68030-based systems. It is equivalent to
25798@option{-march=68030}.
25799
25800@item -m68040
25801@opindex m68040
25802Generate output for a 68040. This is the default when the compiler is
25803configured for 68040-based systems. It is equivalent to
25804@option{-march=68040}.
25805
25806This option inhibits the use of 68881/68882 instructions that have to be
25807emulated by software on the 68040. Use this option if your 68040 does not
25808have code to emulate those instructions.
25809
25810@item -m68060
25811@opindex m68060
25812Generate output for a 68060. This is the default when the compiler is
25813configured for 68060-based systems. It is equivalent to
25814@option{-march=68060}.
25815
25816This option inhibits the use of 68020 and 68881/68882 instructions that
25817have to be emulated by software on the 68060. Use this option if your 68060
25818does not have code to emulate those instructions.
25819
25820@item -mcpu32
25821@opindex mcpu32
25822Generate output for a CPU32. This is the default
25823when the compiler is configured for CPU32-based systems.
25824It is equivalent to @option{-march=cpu32}.
25825
25826Use this option for microcontrollers with a
25827CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
2582868336, 68340, 68341, 68349 and 68360.
25829
25830@item -m5200
25831@opindex m5200
25832Generate output for a 520X ColdFire CPU@. This is the default
25833when the compiler is configured for 520X-based systems.
25834It is equivalent to @option{-mcpu=5206}, and is now deprecated
25835in favor of that option.
25836
25837Use this option for microcontroller with a 5200 core, including
25838the MCF5202, MCF5203, MCF5204 and MCF5206.
25839
25840@item -m5206e
25841@opindex m5206e
25842Generate output for a 5206e ColdFire CPU@. The option is now
25843deprecated in favor of the equivalent @option{-mcpu=5206e}.
25844
25845@item -m528x
25846@opindex m528x
25847Generate output for a member of the ColdFire 528X family.
25848The option is now deprecated in favor of the equivalent
25849@option{-mcpu=528x}.
25850
25851@item -m5307
25852@opindex m5307
25853Generate output for a ColdFire 5307 CPU@. The option is now deprecated
25854in favor of the equivalent @option{-mcpu=5307}.
25855
25856@item -m5407
25857@opindex m5407
25858Generate output for a ColdFire 5407 CPU@. The option is now deprecated
25859in favor of the equivalent @option{-mcpu=5407}.
25860
25861@item -mcfv4e
25862@opindex mcfv4e
25863Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
25864This includes use of hardware floating-point instructions.
25865The option is equivalent to @option{-mcpu=547x}, and is now
25866deprecated in favor of that option.
25867
25868@item -m68020-40
25869@opindex m68020-40
25870Generate output for a 68040, without using any of the new instructions.
25871This results in code that can run relatively efficiently on either a
2587268020/68881 or a 68030 or a 68040. The generated code does use the
2587368881 instructions that are emulated on the 68040.
25874
25875The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
25876
25877@item -m68020-60
25878@opindex m68020-60
25879Generate output for a 68060, without using any of the new instructions.
25880This results in code that can run relatively efficiently on either a
2588168020/68881 or a 68030 or a 68040. The generated code does use the
2588268881 instructions that are emulated on the 68060.
25883
25884The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
25885
25886@item -mhard-float
25887@itemx -m68881
25888@opindex mhard-float
25889@opindex m68881
25890Generate floating-point instructions. This is the default for 68020
25891and above, and for ColdFire devices that have an FPU@. It defines the
25892macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
25893on ColdFire targets.
25894
25895@item -msoft-float
25896@opindex msoft-float
25897Do not generate floating-point instructions; use library calls instead.
25898This is the default for 68000, 68010, and 68832 targets. It is also
25899the default for ColdFire devices that have no FPU.
25900
25901@item -mdiv
25902@itemx -mno-div
25903@opindex mdiv
25904@opindex mno-div
25905Generate (do not generate) ColdFire hardware divide and remainder
25906instructions. If @option{-march} is used without @option{-mcpu},
25907the default is ``on'' for ColdFire architectures and ``off'' for M680x0
25908architectures. Otherwise, the default is taken from the target CPU
25909(either the default CPU, or the one specified by @option{-mcpu}). For
25910example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
25911@option{-mcpu=5206e}.
25912
25913GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
25914
25915@item -mshort
25916@opindex mshort
25917Consider type @code{int} to be 16 bits wide, like @code{short int}.
25918Additionally, parameters passed on the stack are also aligned to a
2591916-bit boundary even on targets whose API mandates promotion to 32-bit.
25920
25921@item -mno-short
25922@opindex mno-short
25923Do not consider type @code{int} to be 16 bits wide. This is the default.
25924
25925@item -mnobitfield
25926@itemx -mno-bitfield
25927@opindex mnobitfield
25928@opindex mno-bitfield
25929Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
25930and @option{-m5200} options imply @w{@option{-mnobitfield}}.
25931
25932@item -mbitfield
25933@opindex mbitfield
25934Do use the bit-field instructions. The @option{-m68020} option implies
25935@option{-mbitfield}. This is the default if you use a configuration
25936designed for a 68020.
25937
25938@item -mrtd
25939@opindex mrtd
25940Use a different function-calling convention, in which functions
25941that take a fixed number of arguments return with the @code{rtd}
25942instruction, which pops their arguments while returning. This
25943saves one instruction in the caller since there is no need to pop
25944the arguments there.
25945
25946This calling convention is incompatible with the one normally
25947used on Unix, so you cannot use it if you need to call libraries
25948compiled with the Unix compiler.
25949
25950Also, you must provide function prototypes for all functions that
25951take variable numbers of arguments (including @code{printf});
25952otherwise incorrect code is generated for calls to those
25953functions.
25954
25955In addition, seriously incorrect code results if you call a
25956function with too many arguments. (Normally, extra arguments are
25957harmlessly ignored.)
25958
25959The @code{rtd} instruction is supported by the 68010, 68020, 68030,
2596068040, 68060 and CPU32 processors, but not by the 68000 or 5200.
25961
25962The default is @option{-mno-rtd}.
25963
25964@item -malign-int
25965@itemx -mno-align-int
25966@opindex malign-int
25967@opindex mno-align-int
25968Control whether GCC aligns @code{int}, @code{long}, @code{long long},
25969@code{float}, @code{double}, and @code{long double} variables on a 32-bit
25970boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
25971Aligning variables on 32-bit boundaries produces code that runs somewhat
25972faster on processors with 32-bit busses at the expense of more memory.
25973
25974@strong{Warning:} if you use the @option{-malign-int} switch, GCC
25975aligns structures containing the above types differently than
25976most published application binary interface specifications for the m68k.
25977
25978@opindex mpcrel
25979Use the pc-relative addressing mode of the 68000 directly, instead of
25980using a global offset table. At present, this option implies @option{-fpic},
25981allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
25982not presently supported with @option{-mpcrel}, though this could be supported for
2598368020 and higher processors.
25984
25985@item -mno-strict-align
25986@itemx -mstrict-align
25987@opindex mno-strict-align
25988@opindex mstrict-align
25989Do not (do) assume that unaligned memory references are handled by
25990the system.
25991
25992@item -msep-data
25993Generate code that allows the data segment to be located in a different
25994area of memory from the text segment. This allows for execute-in-place in
25995an environment without virtual memory management. This option implies
25996@option{-fPIC}.
25997
25998@item -mno-sep-data
25999Generate code that assumes that the data segment follows the text segment.
26000This is the default.
26001
26002@item -mid-shared-library
26003Generate code that supports shared libraries via the library ID method.
26004This allows for execute-in-place and shared libraries in an environment
26005without virtual memory management. This option implies @option{-fPIC}.
26006
26007@item -mno-id-shared-library
26008Generate code that doesn't assume ID-based shared libraries are being used.
26009This is the default.
26010
26011@item -mshared-library-id=n
26012Specifies the identification number of the ID-based shared library being
26013compiled. Specifying a value of 0 generates more compact code; specifying
26014other values forces the allocation of that number to the current
26015library, but is no more space- or time-efficient than omitting this option.
26016
26017@item -mxgot
26018@itemx -mno-xgot
26019@opindex mxgot
26020@opindex mno-xgot
26021When generating position-independent code for ColdFire, generate code
26022that works if the GOT has more than 8192 entries. This code is
26023larger and slower than code generated without this option. On M680x0
26024processors, this option is not needed; @option{-fPIC} suffices.
26025
26026GCC normally uses a single instruction to load values from the GOT@.
26027While this is relatively efficient, it only works if the GOT
26028is smaller than about 64k. Anything larger causes the linker
26029to report an error such as:
26030
26031@cindex relocation truncated to fit (ColdFire)
26032@smallexample
26033relocation truncated to fit: R_68K_GOT16O foobar
26034@end smallexample
26035
26036If this happens, you should recompile your code with @option{-mxgot}.
26037It should then work with very large GOTs. However, code generated with
26038@option{-mxgot} is less efficient, since it takes 4 instructions to fetch
26039the value of a global symbol.
26040
26041Note that some linkers, including newer versions of the GNU linker,
26042can create multiple GOTs and sort GOT entries. If you have such a linker,
26043you should only need to use @option{-mxgot} when compiling a single
26044object file that accesses more than 8192 GOT entries. Very few do.
26045
26046These options have no effect unless GCC is generating
26047position-independent code.
26048
26049@item -mlong-jump-table-offsets
26050@opindex mlong-jump-table-offsets
26051Use 32-bit offsets in @code{switch} tables. The default is to use
2605216-bit offsets.
26053
26054@end table
26055
26056@node MCore Options
26057@subsection MCore Options
26058@cindex MCore options
26059
26060These are the @samp{-m} options defined for the Motorola M*Core
26061processors.
26062
26063@table @gcctabopt
26064
26065@item -mhardlit
26066@itemx -mno-hardlit
26067@opindex mhardlit
26068@opindex mno-hardlit
26069Inline constants into the code stream if it can be done in two
26070instructions or less.
26071
26072@item -mdiv
26073@itemx -mno-div
26074@opindex mdiv
26075@opindex mno-div
26076Use the divide instruction. (Enabled by default).
26077
26078@item -mrelax-immediate
26079@itemx -mno-relax-immediate
26080@opindex mrelax-immediate
26081@opindex mno-relax-immediate
26082Allow arbitrary-sized immediates in bit operations.
26083
26084@item -mwide-bitfields
26085@itemx -mno-wide-bitfields
26086@opindex mwide-bitfields
26087@opindex mno-wide-bitfields
26088Always treat bit-fields as @code{int}-sized.
26089
26090@item -m4byte-functions
26091@itemx -mno-4byte-functions
26092@opindex m4byte-functions
26093@opindex mno-4byte-functions
26094Force all functions to be aligned to a 4-byte boundary.
26095
26096@item -mcallgraph-data
26097@itemx -mno-callgraph-data
26098@opindex mcallgraph-data
26099@opindex mno-callgraph-data
26100Emit callgraph information.
26101
26102@item -mslow-bytes
26103@itemx -mno-slow-bytes
26104@opindex mslow-bytes
26105@opindex mno-slow-bytes
26106Prefer word access when reading byte quantities.
26107
26108@item -mlittle-endian
26109@itemx -mbig-endian
26110@opindex mlittle-endian
26111@opindex mbig-endian
26112Generate code for a little-endian target.
26113
26114@item -m210
26115@itemx -m340
26116@opindex m210
26117@opindex m340
26118Generate code for the 210 processor.
26119
26120@item -mno-lsim
26121@opindex mno-lsim
26122Assume that runtime support has been provided and so omit the
26123simulator library (@file{libsim.a)} from the linker command line.
26124
26125@item -mstack-increment=@var{size}
26126@opindex mstack-increment
26127Set the maximum amount for a single stack increment operation. Large
26128values can increase the speed of programs that contain functions
26129that need a large amount of stack space, but they can also trigger a
26130segmentation fault if the stack is extended too much. The default
26131value is 0x1000.
26132
26133@end table
26134
d77de738
ML
26135@node MicroBlaze Options
26136@subsection MicroBlaze Options
26137@cindex MicroBlaze Options
26138
26139@table @gcctabopt
26140
26141@item -msoft-float
26142@opindex msoft-float
26143Use software emulation for floating point (default).
26144
26145@item -mhard-float
26146@opindex mhard-float
26147Use hardware floating-point instructions.
26148
26149@item -mmemcpy
26150@opindex mmemcpy
26151Do not optimize block moves, use @code{memcpy}.
26152
26153@item -mno-clearbss
26154@opindex mno-clearbss
26155This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
26156
26157@item -mcpu=@var{cpu-type}
26158@opindex mcpu=
26159Use features of, and schedule code for, the given CPU.
26160Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
26161where @var{X} is a major version, @var{YY} is the minor version, and
26162@var{Z} is compatibility code. Example values are @samp{v3.00.a},
26163@samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
26164
26165@item -mxl-soft-mul
26166@opindex mxl-soft-mul
26167Use software multiply emulation (default).
26168
26169@item -mxl-soft-div
26170@opindex mxl-soft-div
26171Use software emulation for divides (default).
26172
26173@item -mxl-barrel-shift
26174@opindex mxl-barrel-shift
26175Use the hardware barrel shifter.
26176
26177@item -mxl-pattern-compare
26178@opindex mxl-pattern-compare
26179Use pattern compare instructions.
26180
26181@item -msmall-divides
26182@opindex msmall-divides
26183Use table lookup optimization for small signed integer divisions.
26184
26185@item -mxl-stack-check
26186@opindex mxl-stack-check
26187This option is deprecated. Use @option{-fstack-check} instead.
26188
26189@item -mxl-gp-opt
26190@opindex mxl-gp-opt
26191Use GP-relative @code{.sdata}/@code{.sbss} sections.
26192
26193@item -mxl-multiply-high
26194@opindex mxl-multiply-high
26195Use multiply high instructions for high part of 32x32 multiply.
26196
26197@item -mxl-float-convert
26198@opindex mxl-float-convert
26199Use hardware floating-point conversion instructions.
26200
26201@item -mxl-float-sqrt
26202@opindex mxl-float-sqrt
26203Use hardware floating-point square root instruction.
26204
26205@item -mbig-endian
26206@opindex mbig-endian
26207Generate code for a big-endian target.
26208
26209@item -mlittle-endian
26210@opindex mlittle-endian
26211Generate code for a little-endian target.
26212
26213@item -mxl-reorder
26214@opindex mxl-reorder
26215Use reorder instructions (swap and byte reversed load/store).
26216
26217@item -mxl-mode-@var{app-model}
26218Select application model @var{app-model}. Valid models are
26219@table @samp
26220@item executable
26221normal executable (default), uses startup code @file{crt0.o}.
26222
26223@item xmdstub
26224for use with Xilinx Microprocessor Debugger (XMD) based
26225software intrusive debug agent called xmdstub. This uses startup file
26226@file{crt1.o} and sets the start address of the program to 0x800.
26227
26228@item bootstrap
26229for applications that are loaded using a bootloader.
26230This model uses startup file @file{crt2.o} which does not contain a processor
26231reset vector handler. This is suitable for transferring control on a
26232processor reset to the bootloader rather than the application.
26233
26234@item novectors
26235for applications that do not require any of the
26236MicroBlaze vectors. This option may be useful for applications running
26237within a monitoring application. This model uses @file{crt3.o} as a startup file.
26238@end table
26239
26240Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
26241@option{-mxl-mode-@var{app-model}}.
26242
26243@item -mpic-data-is-text-relative
26244@opindex mpic-data-is-text-relative
26245Assume that the displacement between the text and data segments is fixed
26246at static link time. This allows data to be referenced by offset from start of
26247text address instead of GOT since PC-relative addressing is not supported.
26248
26249@end table
26250
26251@node MIPS Options
26252@subsection MIPS Options
26253@cindex MIPS options
26254
26255@table @gcctabopt
26256
26257@item -EB
26258@opindex EB
26259Generate big-endian code.
26260
26261@item -EL
26262@opindex EL
26263Generate little-endian code. This is the default for @samp{mips*el-*-*}
26264configurations.
26265
26266@item -march=@var{arch}
26267@opindex march
26268Generate code that runs on @var{arch}, which can be the name of a
26269generic MIPS ISA, or the name of a particular processor.
26270The ISA names are:
26271@samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
26272@samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
26273@samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
26274@samp{mips64r5} and @samp{mips64r6}.
26275The processor names are:
26276@samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
26277@samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
26278@samp{5kc}, @samp{5kf},
26279@samp{20kc},
26280@samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
26281@samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
26282@samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
26283@samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
26284@samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
26285@samp{i6400}, @samp{i6500},
26286@samp{interaptiv},
26287@samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
26288@samp{gs464e}, @samp{gs264e},
26289@samp{m4k},
26290@samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
26291@samp{m5100}, @samp{m5101},
26292@samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
26293@samp{orion},
26294@samp{p5600}, @samp{p6600},
26295@samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
26296@samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
26297@samp{r6000}, @samp{r8000},
26298@samp{rm7000}, @samp{rm9000},
26299@samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
26300@samp{sb1},
26301@samp{sr71000},
26302@samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
26303@samp{vr5000}, @samp{vr5400}, @samp{vr5500},
26304@samp{xlr} and @samp{xlp}.
26305The special value @samp{from-abi} selects the
26306most compatible architecture for the selected ABI (that is,
26307@samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
26308
26309The native Linux/GNU toolchain also supports the value @samp{native},
26310which selects the best architecture option for the host processor.
26311@option{-march=native} has no effect if GCC does not recognize
26312the processor.
26313
26314In processor names, a final @samp{000} can be abbreviated as @samp{k}
26315(for example, @option{-march=r2k}). Prefixes are optional, and
26316@samp{vr} may be written @samp{r}.
26317
26318Names of the form @samp{@var{n}f2_1} refer to processors with
26319FPUs clocked at half the rate of the core, names of the form
26320@samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
26321rate as the core, and names of the form @samp{@var{n}f3_2} refer to
26322processors with FPUs clocked a ratio of 3:2 with respect to the core.
26323For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
26324for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
26325accepted as synonyms for @samp{@var{n}f1_1}.
26326
26327GCC defines two macros based on the value of this option. The first
26328is @code{_MIPS_ARCH}, which gives the name of target architecture, as
26329a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
26330where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
26331For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
26332to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
26333
26334Note that the @code{_MIPS_ARCH} macro uses the processor names given
26335above. In other words, it has the full prefix and does not
26336abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
26337the macro names the resolved architecture (either @code{"mips1"} or
26338@code{"mips3"}). It names the default architecture when no
26339@option{-march} option is given.
26340
26341@item -mtune=@var{arch}
26342@opindex mtune
26343Optimize for @var{arch}. Among other things, this option controls
26344the way instructions are scheduled, and the perceived cost of arithmetic
26345operations. The list of @var{arch} values is the same as for
26346@option{-march}.
26347
26348When this option is not used, GCC optimizes for the processor
26349specified by @option{-march}. By using @option{-march} and
26350@option{-mtune} together, it is possible to generate code that
26351runs on a family of processors, but optimize the code for one
26352particular member of that family.
26353
26354@option{-mtune} defines the macros @code{_MIPS_TUNE} and
26355@code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
26356@option{-march} ones described above.
26357
26358@item -mips1
26359@opindex mips1
26360Equivalent to @option{-march=mips1}.
26361
26362@item -mips2
26363@opindex mips2
26364Equivalent to @option{-march=mips2}.
26365
26366@item -mips3
26367@opindex mips3
26368Equivalent to @option{-march=mips3}.
26369
26370@item -mips4
26371@opindex mips4
26372Equivalent to @option{-march=mips4}.
26373
26374@item -mips32
26375@opindex mips32
26376Equivalent to @option{-march=mips32}.
26377
26378@item -mips32r3
26379@opindex mips32r3
26380Equivalent to @option{-march=mips32r3}.
26381
26382@item -mips32r5
26383@opindex mips32r5
26384Equivalent to @option{-march=mips32r5}.
26385
26386@item -mips32r6
26387@opindex mips32r6
26388Equivalent to @option{-march=mips32r6}.
26389
26390@item -mips64
26391@opindex mips64
26392Equivalent to @option{-march=mips64}.
26393
26394@item -mips64r2
26395@opindex mips64r2
26396Equivalent to @option{-march=mips64r2}.
26397
26398@item -mips64r3
26399@opindex mips64r3
26400Equivalent to @option{-march=mips64r3}.
26401
26402@item -mips64r5
26403@opindex mips64r5
26404Equivalent to @option{-march=mips64r5}.
26405
26406@item -mips64r6
26407@opindex mips64r6
26408Equivalent to @option{-march=mips64r6}.
26409
26410@item -mips16
26411@itemx -mno-mips16
26412@opindex mips16
26413@opindex mno-mips16
26414Generate (do not generate) MIPS16 code. If GCC is targeting a
26415MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
26416
26417MIPS16 code generation can also be controlled on a per-function basis
26418by means of @code{mips16} and @code{nomips16} attributes.
26419@xref{Function Attributes}, for more information.
26420
26421@item -mflip-mips16
26422@opindex mflip-mips16
26423Generate MIPS16 code on alternating functions. This option is provided
26424for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
26425not intended for ordinary use in compiling user code.
26426
26427@item -minterlink-compressed
26428@itemx -mno-interlink-compressed
26429@opindex minterlink-compressed
26430@opindex mno-interlink-compressed
26431Require (do not require) that code using the standard (uncompressed) MIPS ISA
26432be link-compatible with MIPS16 and microMIPS code, and vice versa.
26433
26434For example, code using the standard ISA encoding cannot jump directly
26435to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
26436@option{-minterlink-compressed} therefore disables direct jumps unless GCC
26437knows that the target of the jump is not compressed.
26438
26439@item -minterlink-mips16
26440@itemx -mno-interlink-mips16
26441@opindex minterlink-mips16
26442@opindex mno-interlink-mips16
26443Aliases of @option{-minterlink-compressed} and
26444@option{-mno-interlink-compressed}. These options predate the microMIPS ASE
26445and are retained for backwards compatibility.
26446
26447@item -mabi=32
26448@itemx -mabi=o64
26449@itemx -mabi=n32
26450@itemx -mabi=64
26451@itemx -mabi=eabi
26452@opindex mabi=32
26453@opindex mabi=o64
26454@opindex mabi=n32
26455@opindex mabi=64
26456@opindex mabi=eabi
26457Generate code for the given ABI@.
26458
26459Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
26460generates 64-bit code when you select a 64-bit architecture, but you
26461can use @option{-mgp32} to get 32-bit code instead.
26462
26463For information about the O64 ABI, see
26464@uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
26465
26466GCC supports a variant of the o32 ABI in which floating-point registers
26467are 64 rather than 32 bits wide. You can select this combination with
26468@option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
26469and @code{mfhc1} instructions and is therefore only supported for
26470MIPS32R2, MIPS32R3 and MIPS32R5 processors.
26471
26472The register assignments for arguments and return values remain the
26473same, but each scalar value is passed in a single 64-bit register
26474rather than a pair of 32-bit registers. For example, scalar
26475floating-point values are returned in @samp{$f0} only, not a
26476@samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
26477remains the same in that the even-numbered double-precision registers
26478are saved.
26479
26480Two additional variants of the o32 ABI are supported to enable
26481a transition from 32-bit to 64-bit registers. These are FPXX
26482(@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
26483The FPXX extension mandates that all code must execute correctly
26484when run using 32-bit or 64-bit registers. The code can be interlinked
26485with either FP32 or FP64, but not both.
26486The FP64A extension is similar to the FP64 extension but forbids the
26487use of odd-numbered single-precision registers. This can be used
26488in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
26489processors and allows both FP32 and FP64A code to interlink and
26490run in the same process without changing FPU modes.
26491
26492@item -mabicalls
26493@itemx -mno-abicalls
26494@opindex mabicalls
26495@opindex mno-abicalls
26496Generate (do not generate) code that is suitable for SVR4-style
26497dynamic objects. @option{-mabicalls} is the default for SVR4-based
26498systems.
26499
26500@item -mshared
26501@itemx -mno-shared
26502Generate (do not generate) code that is fully position-independent,
26503and that can therefore be linked into shared libraries. This option
26504only affects @option{-mabicalls}.
26505
26506All @option{-mabicalls} code has traditionally been position-independent,
26507regardless of options like @option{-fPIC} and @option{-fpic}. However,
26508as an extension, the GNU toolchain allows executables to use absolute
26509accesses for locally-binding symbols. It can also use shorter GP
26510initialization sequences and generate direct calls to locally-defined
26511functions. This mode is selected by @option{-mno-shared}.
26512
26513@option{-mno-shared} depends on binutils 2.16 or higher and generates
26514objects that can only be linked by the GNU linker. However, the option
26515does not affect the ABI of the final executable; it only affects the ABI
26516of relocatable objects. Using @option{-mno-shared} generally makes
26517executables both smaller and quicker.
26518
26519@option{-mshared} is the default.
26520
26521@item -mplt
26522@itemx -mno-plt
26523@opindex mplt
26524@opindex mno-plt
26525Assume (do not assume) that the static and dynamic linkers
26526support PLTs and copy relocations. This option only affects
26527@option{-mno-shared -mabicalls}. For the n64 ABI, this option
26528has no effect without @option{-msym32}.
26529
26530You can make @option{-mplt} the default by configuring
26531GCC with @option{--with-mips-plt}. The default is
26532@option{-mno-plt} otherwise.
26533
26534@item -mxgot
26535@itemx -mno-xgot
26536@opindex mxgot
26537@opindex mno-xgot
26538Lift (do not lift) the usual restrictions on the size of the global
26539offset table.
26540
26541GCC normally uses a single instruction to load values from the GOT@.
26542While this is relatively efficient, it only works if the GOT
26543is smaller than about 64k. Anything larger causes the linker
26544to report an error such as:
26545
26546@cindex relocation truncated to fit (MIPS)
26547@smallexample
26548relocation truncated to fit: R_MIPS_GOT16 foobar
26549@end smallexample
26550
26551If this happens, you should recompile your code with @option{-mxgot}.
26552This works with very large GOTs, although the code is also
26553less efficient, since it takes three instructions to fetch the
26554value of a global symbol.
26555
26556Note that some linkers can create multiple GOTs. If you have such a
26557linker, you should only need to use @option{-mxgot} when a single object
26558file accesses more than 64k's worth of GOT entries. Very few do.
26559
26560These options have no effect unless GCC is generating position
26561independent code.
26562
26563@item -mgp32
26564@opindex mgp32
26565Assume that general-purpose registers are 32 bits wide.
26566
26567@item -mgp64
26568@opindex mgp64
26569Assume that general-purpose registers are 64 bits wide.
26570
26571@item -mfp32
26572@opindex mfp32
26573Assume that floating-point registers are 32 bits wide.
26574
26575@item -mfp64
26576@opindex mfp64
26577Assume that floating-point registers are 64 bits wide.
26578
26579@item -mfpxx
26580@opindex mfpxx
26581Do not assume the width of floating-point registers.
26582
26583@item -mhard-float
26584@opindex mhard-float
26585Use floating-point coprocessor instructions.
26586
26587@item -msoft-float
26588@opindex msoft-float
26589Do not use floating-point coprocessor instructions. Implement
26590floating-point calculations using library calls instead.
26591
26592@item -mno-float
26593@opindex mno-float
26594Equivalent to @option{-msoft-float}, but additionally asserts that the
26595program being compiled does not perform any floating-point operations.
26596This option is presently supported only by some bare-metal MIPS
26597configurations, where it may select a special set of libraries
26598that lack all floating-point support (including, for example, the
26599floating-point @code{printf} formats).
26600If code compiled with @option{-mno-float} accidentally contains
26601floating-point operations, it is likely to suffer a link-time
26602or run-time failure.
26603
26604@item -msingle-float
26605@opindex msingle-float
26606Assume that the floating-point coprocessor only supports single-precision
26607operations.
26608
26609@item -mdouble-float
26610@opindex mdouble-float
26611Assume that the floating-point coprocessor supports double-precision
26612operations. This is the default.
26613
26614@item -modd-spreg
26615@itemx -mno-odd-spreg
26616@opindex modd-spreg
26617@opindex mno-odd-spreg
26618Enable the use of odd-numbered single-precision floating-point registers
26619for the o32 ABI. This is the default for processors that are known to
26620support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
26621is set by default.
26622
26623@item -mabs=2008
26624@itemx -mabs=legacy
26625@opindex mabs=2008
26626@opindex mabs=legacy
26627These options control the treatment of the special not-a-number (NaN)
26628IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
26629@code{neg.@i{fmt}} machine instructions.
26630
26631By default or when @option{-mabs=legacy} is used the legacy
26632treatment is selected. In this case these instructions are considered
26633arithmetic and avoided where correct operation is required and the
26634input operand might be a NaN. A longer sequence of instructions that
26635manipulate the sign bit of floating-point datum manually is used
26636instead unless the @option{-ffinite-math-only} option has also been
26637specified.
26638
26639The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
26640this case these instructions are considered non-arithmetic and therefore
26641operating correctly in all cases, including in particular where the
26642input operand is a NaN. These instructions are therefore always used
26643for the respective operations.
26644
26645@item -mnan=2008
26646@itemx -mnan=legacy
26647@opindex mnan=2008
26648@opindex mnan=legacy
26649These options control the encoding of the special not-a-number (NaN)
26650IEEE 754 floating-point data.
26651
26652The @option{-mnan=legacy} option selects the legacy encoding. In this
26653case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
26654significand field being 0, whereas signaling NaNs (sNaNs) are denoted
26655by the first bit of their trailing significand field being 1.
26656
26657The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
26658this case qNaNs are denoted by the first bit of their trailing
26659significand field being 1, whereas sNaNs are denoted by the first bit of
26660their trailing significand field being 0.
26661
26662The default is @option{-mnan=legacy} unless GCC has been configured with
26663@option{--with-nan=2008}.
26664
26665@item -mllsc
26666@itemx -mno-llsc
26667@opindex mllsc
26668@opindex mno-llsc
26669Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
26670implement atomic memory built-in functions. When neither option is
26671specified, GCC uses the instructions if the target architecture
26672supports them.
26673
26674@option{-mllsc} is useful if the runtime environment can emulate the
26675instructions and @option{-mno-llsc} can be useful when compiling for
26676nonstandard ISAs. You can make either option the default by
26677configuring GCC with @option{--with-llsc} and @option{--without-llsc}
26678respectively. @option{--with-llsc} is the default for some
26679configurations; see the installation documentation for details.
26680
26681@item -mdsp
26682@itemx -mno-dsp
26683@opindex mdsp
26684@opindex mno-dsp
26685Use (do not use) revision 1 of the MIPS DSP ASE@.
26686@xref{MIPS DSP Built-in Functions}. This option defines the
26687preprocessor macro @code{__mips_dsp}. It also defines
26688@code{__mips_dsp_rev} to 1.
26689
26690@item -mdspr2
26691@itemx -mno-dspr2
26692@opindex mdspr2
26693@opindex mno-dspr2
26694Use (do not use) revision 2 of the MIPS DSP ASE@.
26695@xref{MIPS DSP Built-in Functions}. This option defines the
26696preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
26697It also defines @code{__mips_dsp_rev} to 2.
26698
26699@item -msmartmips
26700@itemx -mno-smartmips
26701@opindex msmartmips
26702@opindex mno-smartmips
26703Use (do not use) the MIPS SmartMIPS ASE.
26704
26705@item -mpaired-single
26706@itemx -mno-paired-single
26707@opindex mpaired-single
26708@opindex mno-paired-single
26709Use (do not use) paired-single floating-point instructions.
26710@xref{MIPS Paired-Single Support}. This option requires
26711hardware floating-point support to be enabled.
26712
26713@item -mdmx
26714@itemx -mno-mdmx
26715@opindex mdmx
26716@opindex mno-mdmx
26717Use (do not use) MIPS Digital Media Extension instructions.
26718This option can only be used when generating 64-bit code and requires
26719hardware floating-point support to be enabled.
26720
26721@item -mips3d
26722@itemx -mno-mips3d
26723@opindex mips3d
26724@opindex mno-mips3d
26725Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
26726The option @option{-mips3d} implies @option{-mpaired-single}.
26727
26728@item -mmicromips
26729@itemx -mno-micromips
26730@opindex mmicromips
26731@opindex mno-mmicromips
26732Generate (do not generate) microMIPS code.
26733
26734MicroMIPS code generation can also be controlled on a per-function basis
26735by means of @code{micromips} and @code{nomicromips} attributes.
26736@xref{Function Attributes}, for more information.
26737
26738@item -mmt
26739@itemx -mno-mt
26740@opindex mmt
26741@opindex mno-mt
26742Use (do not use) MT Multithreading instructions.
26743
26744@item -mmcu
26745@itemx -mno-mcu
26746@opindex mmcu
26747@opindex mno-mcu
26748Use (do not use) the MIPS MCU ASE instructions.
26749
26750@item -meva
26751@itemx -mno-eva
26752@opindex meva
26753@opindex mno-eva
26754Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
26755
26756@item -mvirt
26757@itemx -mno-virt
26758@opindex mvirt
26759@opindex mno-virt
26760Use (do not use) the MIPS Virtualization (VZ) instructions.
26761
26762@item -mxpa
26763@itemx -mno-xpa
26764@opindex mxpa
26765@opindex mno-xpa
26766Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
26767
26768@item -mcrc
26769@itemx -mno-crc
26770@opindex mcrc
26771@opindex mno-crc
26772Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
26773
26774@item -mginv
26775@itemx -mno-ginv
26776@opindex mginv
26777@opindex mno-ginv
26778Use (do not use) the MIPS Global INValidate (GINV) instructions.
26779
26780@item -mloongson-mmi
26781@itemx -mno-loongson-mmi
26782@opindex mloongson-mmi
26783@opindex mno-loongson-mmi
26784Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
26785
26786@item -mloongson-ext
26787@itemx -mno-loongson-ext
26788@opindex mloongson-ext
26789@opindex mno-loongson-ext
26790Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
26791
26792@item -mloongson-ext2
26793@itemx -mno-loongson-ext2
26794@opindex mloongson-ext2
26795@opindex mno-loongson-ext2
26796Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
26797
26798@item -mlong64
26799@opindex mlong64
26800Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
26801an explanation of the default and the way that the pointer size is
26802determined.
26803
26804@item -mlong32
26805@opindex mlong32
26806Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
26807
26808The default size of @code{int}s, @code{long}s and pointers depends on
26809the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
26810uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
2681132-bit @code{long}s. Pointers are the same size as @code{long}s,
26812or the same size as integer registers, whichever is smaller.
26813
26814@item -msym32
26815@itemx -mno-sym32
26816@opindex msym32
26817@opindex mno-sym32
26818Assume (do not assume) that all symbols have 32-bit values, regardless
26819of the selected ABI@. This option is useful in combination with
26820@option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
26821to generate shorter and faster references to symbolic addresses.
26822
26823@item -G @var{num}
26824@opindex G
26825Put definitions of externally-visible data in a small data section
26826if that data is no bigger than @var{num} bytes. GCC can then generate
26827more efficient accesses to the data; see @option{-mgpopt} for details.
26828
26829The default @option{-G} option depends on the configuration.
26830
26831@item -mlocal-sdata
26832@itemx -mno-local-sdata
26833@opindex mlocal-sdata
26834@opindex mno-local-sdata
26835Extend (do not extend) the @option{-G} behavior to local data too,
26836such as to static variables in C@. @option{-mlocal-sdata} is the
26837default for all configurations.
26838
26839If the linker complains that an application is using too much small data,
26840you might want to try rebuilding the less performance-critical parts with
26841@option{-mno-local-sdata}. You might also want to build large
26842libraries with @option{-mno-local-sdata}, so that the libraries leave
26843more room for the main program.
26844
26845@item -mextern-sdata
26846@itemx -mno-extern-sdata
26847@opindex mextern-sdata
26848@opindex mno-extern-sdata
26849Assume (do not assume) that externally-defined data is in
26850a small data section if the size of that data is within the @option{-G} limit.
26851@option{-mextern-sdata} is the default for all configurations.
26852
26853If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
26854@var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
26855that is no bigger than @var{num} bytes, you must make sure that @var{Var}
26856is placed in a small data section. If @var{Var} is defined by another
26857module, you must either compile that module with a high-enough
26858@option{-G} setting or attach a @code{section} attribute to @var{Var}'s
26859definition. If @var{Var} is common, you must link the application
26860with a high-enough @option{-G} setting.
26861
26862The easiest way of satisfying these restrictions is to compile
26863and link every module with the same @option{-G} option. However,
26864you may wish to build a library that supports several different
26865small data limits. You can do this by compiling the library with
26866the highest supported @option{-G} setting and additionally using
26867@option{-mno-extern-sdata} to stop the library from making assumptions
26868about externally-defined data.
26869
26870@item -mgpopt
26871@itemx -mno-gpopt
26872@opindex mgpopt
26873@opindex mno-gpopt
26874Use (do not use) GP-relative accesses for symbols that are known to be
26875in a small data section; see @option{-G}, @option{-mlocal-sdata} and
26876@option{-mextern-sdata}. @option{-mgpopt} is the default for all
26877configurations.
26878
26879@option{-mno-gpopt} is useful for cases where the @code{$gp} register
26880might not hold the value of @code{_gp}. For example, if the code is
26881part of a library that might be used in a boot monitor, programs that
26882call boot monitor routines pass an unknown value in @code{$gp}.
26883(In such situations, the boot monitor itself is usually compiled
26884with @option{-G0}.)
26885
26886@option{-mno-gpopt} implies @option{-mno-local-sdata} and
26887@option{-mno-extern-sdata}.
26888
26889@item -membedded-data
26890@itemx -mno-embedded-data
26891@opindex membedded-data
26892@opindex mno-embedded-data
26893Allocate variables to the read-only data section first if possible, then
26894next in the small data section if possible, otherwise in data. This gives
26895slightly slower code than the default, but reduces the amount of RAM required
26896when executing, and thus may be preferred for some embedded systems.
26897
26898@item -muninit-const-in-rodata
26899@itemx -mno-uninit-const-in-rodata
26900@opindex muninit-const-in-rodata
26901@opindex mno-uninit-const-in-rodata
26902Put uninitialized @code{const} variables in the read-only data section.
26903This option is only meaningful in conjunction with @option{-membedded-data}.
26904
26905@item -mcode-readable=@var{setting}
26906@opindex mcode-readable
26907Specify whether GCC may generate code that reads from executable sections.
26908There are three possible settings:
26909
26910@table @gcctabopt
26911@item -mcode-readable=yes
26912Instructions may freely access executable sections. This is the
26913default setting.
26914
26915@item -mcode-readable=pcrel
26916MIPS16 PC-relative load instructions can access executable sections,
26917but other instructions must not do so. This option is useful on 4KSc
26918and 4KSd processors when the code TLBs have the Read Inhibit bit set.
26919It is also useful on processors that can be configured to have a dual
26920instruction/data SRAM interface and that, like the M4K, automatically
26921redirect PC-relative loads to the instruction RAM.
26922
26923@item -mcode-readable=no
26924Instructions must not access executable sections. This option can be
26925useful on targets that are configured to have a dual instruction/data
26926SRAM interface but that (unlike the M4K) do not automatically redirect
26927PC-relative loads to the instruction RAM.
26928@end table
26929
26930@item -msplit-addresses
26931@itemx -mno-split-addresses
26932@opindex msplit-addresses
26933@opindex mno-split-addresses
26934Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
26935relocation operators. This option has been superseded by
26936@option{-mexplicit-relocs} but is retained for backwards compatibility.
26937
26938@item -mexplicit-relocs
26939@itemx -mno-explicit-relocs
26940@opindex mexplicit-relocs
26941@opindex mno-explicit-relocs
26942Use (do not use) assembler relocation operators when dealing with symbolic
26943addresses. The alternative, selected by @option{-mno-explicit-relocs},
26944is to use assembler macros instead.
26945
26946@option{-mexplicit-relocs} is the default if GCC was configured
26947to use an assembler that supports relocation operators.
26948
26949@item -mcheck-zero-division
26950@itemx -mno-check-zero-division
26951@opindex mcheck-zero-division
26952@opindex mno-check-zero-division
26953Trap (do not trap) on integer division by zero.
26954
26955The default is @option{-mcheck-zero-division}.
26956
26957@item -mdivide-traps
26958@itemx -mdivide-breaks
26959@opindex mdivide-traps
26960@opindex mdivide-breaks
26961MIPS systems check for division by zero by generating either a
26962conditional trap or a break instruction. Using traps results in
26963smaller code, but is only supported on MIPS II and later. Also, some
26964versions of the Linux kernel have a bug that prevents trap from
26965generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
26966allow conditional traps on architectures that support them and
26967@option{-mdivide-breaks} to force the use of breaks.
26968
26969The default is usually @option{-mdivide-traps}, but this can be
26970overridden at configure time using @option{--with-divide=breaks}.
26971Divide-by-zero checks can be completely disabled using
26972@option{-mno-check-zero-division}.
26973
26974@item -mload-store-pairs
26975@itemx -mno-load-store-pairs
26976@opindex mload-store-pairs
26977@opindex mno-load-store-pairs
26978Enable (disable) an optimization that pairs consecutive load or store
26979instructions to enable load/store bonding. This option is enabled by
26980default but only takes effect when the selected architecture is known
26981to support bonding.
26982
26983@item -munaligned-access
26984@itemx -mno-unaligned-access
26985@opindex munaligned-access
26986@opindex mno-unaligned-access
26987Enable (disable) direct unaligned access for MIPS Release 6.
26988MIPSr6 requires load/store unaligned-access support,
26989by hardware or trap&emulate.
26990So @option{-mno-unaligned-access} may be needed by kernel.
26991
26992@item -mmemcpy
26993@itemx -mno-memcpy
26994@opindex mmemcpy
26995@opindex mno-memcpy
26996Force (do not force) the use of @code{memcpy} for non-trivial block
26997moves. The default is @option{-mno-memcpy}, which allows GCC to inline
26998most constant-sized copies.
26999
27000@item -mlong-calls
27001@itemx -mno-long-calls
27002@opindex mlong-calls
27003@opindex mno-long-calls
27004Disable (do not disable) use of the @code{jal} instruction. Calling
27005functions using @code{jal} is more efficient but requires the caller
27006and callee to be in the same 256 megabyte segment.
27007
27008This option has no effect on abicalls code. The default is
27009@option{-mno-long-calls}.
27010
27011@item -mmad
27012@itemx -mno-mad
27013@opindex mmad
27014@opindex mno-mad
27015Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
27016instructions, as provided by the R4650 ISA@.
27017
27018@item -mimadd
27019@itemx -mno-imadd
27020@opindex mimadd
27021@opindex mno-imadd
27022Enable (disable) use of the @code{madd} and @code{msub} integer
27023instructions. The default is @option{-mimadd} on architectures
27024that support @code{madd} and @code{msub} except for the 74k
27025architecture where it was found to generate slower code.
27026
27027@item -mfused-madd
27028@itemx -mno-fused-madd
27029@opindex mfused-madd
27030@opindex mno-fused-madd
27031Enable (disable) use of the floating-point multiply-accumulate
27032instructions, when they are available. The default is
27033@option{-mfused-madd}.
27034
27035On the R8000 CPU when multiply-accumulate instructions are used,
27036the intermediate product is calculated to infinite precision
27037and is not subject to the FCSR Flush to Zero bit. This may be
27038undesirable in some circumstances. On other processors the result
27039is numerically identical to the equivalent computation using
27040separate multiply, add, subtract and negate instructions.
27041
27042@item -nocpp
27043@opindex nocpp
27044Tell the MIPS assembler to not run its preprocessor over user
27045assembler files (with a @samp{.s} suffix) when assembling them.
27046
27047@item -mfix-24k
27048@itemx -mno-fix-24k
27049@opindex mfix-24k
27050@opindex mno-fix-24k
27051Work around the 24K E48 (lost data on stores during refill) errata.
27052The workarounds are implemented by the assembler rather than by GCC@.
27053
27054@item -mfix-r4000
27055@itemx -mno-fix-r4000
27056@opindex mfix-r4000
27057@opindex mno-fix-r4000
27058Work around certain R4000 CPU errata:
27059@itemize @minus
27060@item
27061A double-word or a variable shift may give an incorrect result if executed
27062immediately after starting an integer division.
27063@item
27064A double-word or a variable shift may give an incorrect result if executed
27065while an integer multiplication is in progress.
27066@item
27067An integer division may give an incorrect result if started in a delay slot
27068of a taken branch or a jump.
27069@end itemize
27070
27071@item -mfix-r4400
27072@itemx -mno-fix-r4400
27073@opindex mfix-r4400
27074@opindex mno-fix-r4400
27075Work around certain R4400 CPU errata:
27076@itemize @minus
27077@item
27078A double-word or a variable shift may give an incorrect result if executed
27079immediately after starting an integer division.
27080@end itemize
27081
27082@item -mfix-r10000
27083@itemx -mno-fix-r10000
27084@opindex mfix-r10000
27085@opindex mno-fix-r10000
27086Work around certain R10000 errata:
27087@itemize @minus
27088@item
27089@code{ll}/@code{sc} sequences may not behave atomically on revisions
27090prior to 3.0. They may deadlock on revisions 2.6 and earlier.
27091@end itemize
27092
27093This option can only be used if the target architecture supports
27094branch-likely instructions. @option{-mfix-r10000} is the default when
27095@option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
27096otherwise.
27097
27098@item -mfix-r5900
27099@itemx -mno-fix-r5900
27100@opindex mfix-r5900
27101Do not attempt to schedule the preceding instruction into the delay slot
27102of a branch instruction placed at the end of a short loop of six
27103instructions or fewer and always schedule a @code{nop} instruction there
27104instead. The short loop bug under certain conditions causes loops to
27105execute only once or twice, due to a hardware bug in the R5900 chip. The
27106workaround is implemented by the assembler rather than by GCC@.
27107
27108@item -mfix-rm7000
27109@itemx -mno-fix-rm7000
27110@opindex mfix-rm7000
27111Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
27112workarounds are implemented by the assembler rather than by GCC@.
27113
27114@item -mfix-vr4120
27115@itemx -mno-fix-vr4120
27116@opindex mfix-vr4120
27117Work around certain VR4120 errata:
27118@itemize @minus
27119@item
27120@code{dmultu} does not always produce the correct result.
27121@item
27122@code{div} and @code{ddiv} do not always produce the correct result if one
27123of the operands is negative.
27124@end itemize
27125The workarounds for the division errata rely on special functions in
27126@file{libgcc.a}. At present, these functions are only provided by
27127the @code{mips64vr*-elf} configurations.
27128
27129Other VR4120 errata require a NOP to be inserted between certain pairs of
27130instructions. These errata are handled by the assembler, not by GCC itself.
27131
27132@item -mfix-vr4130
27133@opindex mfix-vr4130
27134Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
27135workarounds are implemented by the assembler rather than by GCC,
27136although GCC avoids using @code{mflo} and @code{mfhi} if the
27137VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
27138instructions are available instead.
27139
27140@item -mfix-sb1
27141@itemx -mno-fix-sb1
27142@opindex mfix-sb1
27143Work around certain SB-1 CPU core errata.
27144(This flag currently works around the SB-1 revision 2
27145``F1'' and ``F2'' floating-point errata.)
27146
27147@item -mr10k-cache-barrier=@var{setting}
27148@opindex mr10k-cache-barrier
27149Specify whether GCC should insert cache barriers to avoid the
27150side effects of speculation on R10K processors.
27151
27152In common with many processors, the R10K tries to predict the outcome
27153of a conditional branch and speculatively executes instructions from
27154the ``taken'' branch. It later aborts these instructions if the
27155predicted outcome is wrong. However, on the R10K, even aborted
27156instructions can have side effects.
27157
27158This problem only affects kernel stores and, depending on the system,
27159kernel loads. As an example, a speculatively-executed store may load
27160the target memory into cache and mark the cache line as dirty, even if
27161the store itself is later aborted. If a DMA operation writes to the
27162same area of memory before the ``dirty'' line is flushed, the cached
27163data overwrites the DMA-ed data. See the R10K processor manual
27164for a full description, including other potential problems.
27165
27166One workaround is to insert cache barrier instructions before every memory
27167access that might be speculatively executed and that might have side
27168effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
27169controls GCC's implementation of this workaround. It assumes that
27170aborted accesses to any byte in the following regions does not have
27171side effects:
27172
27173@enumerate
27174@item
27175the memory occupied by the current function's stack frame;
27176
27177@item
27178the memory occupied by an incoming stack argument;
27179
27180@item
27181the memory occupied by an object with a link-time-constant address.
27182@end enumerate
27183
27184It is the kernel's responsibility to ensure that speculative
27185accesses to these regions are indeed safe.
27186
27187If the input program contains a function declaration such as:
27188
27189@smallexample
27190void foo (void);
27191@end smallexample
27192
27193then the implementation of @code{foo} must allow @code{j foo} and
27194@code{jal foo} to be executed speculatively. GCC honors this
27195restriction for functions it compiles itself. It expects non-GCC
27196functions (such as hand-written assembly code) to do the same.
27197
27198The option has three forms:
27199
27200@table @gcctabopt
27201@item -mr10k-cache-barrier=load-store
27202Insert a cache barrier before a load or store that might be
27203speculatively executed and that might have side effects even
27204if aborted.
27205
27206@item -mr10k-cache-barrier=store
27207Insert a cache barrier before a store that might be speculatively
27208executed and that might have side effects even if aborted.
27209
27210@item -mr10k-cache-barrier=none
27211Disable the insertion of cache barriers. This is the default setting.
27212@end table
27213
27214@item -mflush-func=@var{func}
27215@itemx -mno-flush-func
27216@opindex mflush-func
27217Specifies the function to call to flush the I and D caches, or to not
27218call any such function. If called, the function must take the same
27219arguments as the common @code{_flush_func}, that is, the address of the
27220memory range for which the cache is being flushed, the size of the
27221memory range, and the number 3 (to flush both caches). The default
27222depends on the target GCC was configured for, but commonly is either
27223@code{_flush_func} or @code{__cpu_flush}.
27224
27225@item mbranch-cost=@var{num}
27226@opindex mbranch-cost
27227Set the cost of branches to roughly @var{num} ``simple'' instructions.
27228This cost is only a heuristic and is not guaranteed to produce
27229consistent results across releases. A zero cost redundantly selects
27230the default, which is based on the @option{-mtune} setting.
27231
27232@item -mbranch-likely
27233@itemx -mno-branch-likely
27234@opindex mbranch-likely
27235@opindex mno-branch-likely
27236Enable or disable use of Branch Likely instructions, regardless of the
27237default for the selected architecture. By default, Branch Likely
27238instructions may be generated if they are supported by the selected
27239architecture. An exception is for the MIPS32 and MIPS64 architectures
27240and processors that implement those architectures; for those, Branch
27241Likely instructions are not be generated by default because the MIPS32
27242and MIPS64 architectures specifically deprecate their use.
27243
27244@item -mcompact-branches=never
27245@itemx -mcompact-branches=optimal
27246@itemx -mcompact-branches=always
27247@opindex mcompact-branches=never
27248@opindex mcompact-branches=optimal
27249@opindex mcompact-branches=always
27250These options control which form of branches will be generated. The
27251default is @option{-mcompact-branches=optimal}.
27252
27253The @option{-mcompact-branches=never} option ensures that compact branch
27254instructions will never be generated.
27255
27256The @option{-mcompact-branches=always} option ensures that a compact
27257branch instruction will be generated if available for MIPS Release 6 onwards.
27258If a compact branch instruction is not available (or pre-R6),
27259a delay slot form of the branch will be used instead.
27260
27261If it is used for MIPS16/microMIPS targets, it will be just ignored now.
27262The behaviour for MIPS16/microMIPS may change in future,
27263since they do have some compact branch instructions.
27264
27265The @option{-mcompact-branches=optimal} option will cause a delay slot
27266branch to be used if one is available in the current ISA and the delay
27267slot is successfully filled. If the delay slot is not filled, a compact
27268branch will be chosen if one is available.
27269
27270@item -mfp-exceptions
27271@itemx -mno-fp-exceptions
27272@opindex mfp-exceptions
27273Specifies whether FP exceptions are enabled. This affects how
27274FP instructions are scheduled for some processors.
27275The default is that FP exceptions are
27276enabled.
27277
27278For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
2727964-bit code, then we can use both FP pipes. Otherwise, we can only use one
27280FP pipe.
27281
27282@item -mvr4130-align
27283@itemx -mno-vr4130-align
27284@opindex mvr4130-align
27285The VR4130 pipeline is two-way superscalar, but can only issue two
27286instructions together if the first one is 8-byte aligned. When this
27287option is enabled, GCC aligns pairs of instructions that it
27288thinks should execute in parallel.
27289
27290This option only has an effect when optimizing for the VR4130.
27291It normally makes code faster, but at the expense of making it bigger.
27292It is enabled by default at optimization level @option{-O3}.
27293
27294@item -msynci
27295@itemx -mno-synci
27296@opindex msynci
27297Enable (disable) generation of @code{synci} instructions on
27298architectures that support it. The @code{synci} instructions (if
27299enabled) are generated when @code{__builtin___clear_cache} is
27300compiled.
27301
27302This option defaults to @option{-mno-synci}, but the default can be
27303overridden by configuring GCC with @option{--with-synci}.
27304
27305When compiling code for single processor systems, it is generally safe
27306to use @code{synci}. However, on many multi-core (SMP) systems, it
27307does not invalidate the instruction caches on all cores and may lead
27308to undefined behavior.
27309
27310@item -mrelax-pic-calls
27311@itemx -mno-relax-pic-calls
27312@opindex mrelax-pic-calls
27313Try to turn PIC calls that are normally dispatched via register
27314@code{$25} into direct calls. This is only possible if the linker can
27315resolve the destination at link time and if the destination is within
27316range for a direct call.
27317
27318@option{-mrelax-pic-calls} is the default if GCC was configured to use
27319an assembler and a linker that support the @code{.reloc} assembly
27320directive and @option{-mexplicit-relocs} is in effect. With
27321@option{-mno-explicit-relocs}, this optimization can be performed by the
27322assembler and the linker alone without help from the compiler.
27323
27324@item -mmcount-ra-address
27325@itemx -mno-mcount-ra-address
27326@opindex mmcount-ra-address
27327@opindex mno-mcount-ra-address
27328Emit (do not emit) code that allows @code{_mcount} to modify the
27329calling function's return address. When enabled, this option extends
27330the usual @code{_mcount} interface with a new @var{ra-address}
27331parameter, which has type @code{intptr_t *} and is passed in register
27332@code{$12}. @code{_mcount} can then modify the return address by
27333doing both of the following:
27334@itemize
27335@item
27336Returning the new address in register @code{$31}.
27337@item
27338Storing the new address in @code{*@var{ra-address}},
27339if @var{ra-address} is nonnull.
27340@end itemize
27341
27342The default is @option{-mno-mcount-ra-address}.
27343
27344@item -mframe-header-opt
27345@itemx -mno-frame-header-opt
27346@opindex mframe-header-opt
27347Enable (disable) frame header optimization in the o32 ABI. When using the
27348o32 ABI, calling functions will allocate 16 bytes on the stack for the called
27349function to write out register arguments. When enabled, this optimization
27350will suppress the allocation of the frame header if it can be determined that
27351it is unused.
27352
27353This optimization is off by default at all optimization levels.
27354
27355@item -mlxc1-sxc1
27356@itemx -mno-lxc1-sxc1
27357@opindex mlxc1-sxc1
27358When applicable, enable (disable) the generation of @code{lwxc1},
27359@code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
27360
27361@item -mmadd4
27362@itemx -mno-madd4
27363@opindex mmadd4
27364When applicable, enable (disable) the generation of 4-operand @code{madd.s},
27365@code{madd.d} and related instructions. Enabled by default.
27366
27367@end table
27368
27369@node MMIX Options
27370@subsection MMIX Options
27371@cindex MMIX Options
27372
27373These options are defined for the MMIX:
27374
27375@table @gcctabopt
27376@item -mlibfuncs
27377@itemx -mno-libfuncs
27378@opindex mlibfuncs
27379@opindex mno-libfuncs
27380Specify that intrinsic library functions are being compiled, passing all
27381values in registers, no matter the size.
27382
27383@item -mepsilon
27384@itemx -mno-epsilon
27385@opindex mepsilon
27386@opindex mno-epsilon
27387Generate floating-point comparison instructions that compare with respect
27388to the @code{rE} epsilon register.
27389
27390@item -mabi=mmixware
27391@itemx -mabi=gnu
27392@opindex mabi=mmixware
27393@opindex mabi=gnu
27394Generate code that passes function parameters and return values that (in
27395the called function) are seen as registers @code{$0} and up, as opposed to
27396the GNU ABI which uses global registers @code{$231} and up.
27397
27398@item -mzero-extend
27399@itemx -mno-zero-extend
27400@opindex mzero-extend
27401@opindex mno-zero-extend
27402When reading data from memory in sizes shorter than 64 bits, use (do not
27403use) zero-extending load instructions by default, rather than
27404sign-extending ones.
27405
27406@item -mknuthdiv
27407@itemx -mno-knuthdiv
27408@opindex mknuthdiv
27409@opindex mno-knuthdiv
27410Make the result of a division yielding a remainder have the same sign as
27411the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
27412remainder follows the sign of the dividend. Both methods are
27413arithmetically valid, the latter being almost exclusively used.
27414
27415@item -mtoplevel-symbols
27416@itemx -mno-toplevel-symbols
27417@opindex mtoplevel-symbols
27418@opindex mno-toplevel-symbols
27419Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
27420code can be used with the @code{PREFIX} assembly directive.
27421
27422@item -melf
27423@opindex melf
27424Generate an executable in the ELF format, rather than the default
27425@samp{mmo} format used by the @command{mmix} simulator.
27426
27427@item -mbranch-predict
27428@itemx -mno-branch-predict
27429@opindex mbranch-predict
27430@opindex mno-branch-predict
27431Use (do not use) the probable-branch instructions, when static branch
27432prediction indicates a probable branch.
27433
27434@item -mbase-addresses
27435@itemx -mno-base-addresses
27436@opindex mbase-addresses
27437@opindex mno-base-addresses
27438Generate (do not generate) code that uses @emph{base addresses}. Using a
27439base address automatically generates a request (handled by the assembler
27440and the linker) for a constant to be set up in a global register. The
27441register is used for one or more base address requests within the range 0
27442to 255 from the value held in the register. The generally leads to short
27443and fast code, but the number of different data items that can be
27444addressed is limited. This means that a program that uses lots of static
27445data may require @option{-mno-base-addresses}.
27446
27447@item -msingle-exit
27448@itemx -mno-single-exit
27449@opindex msingle-exit
27450@opindex mno-single-exit
27451Force (do not force) generated code to have a single exit point in each
27452function.
27453@end table
27454
27455@node MN10300 Options
27456@subsection MN10300 Options
27457@cindex MN10300 options
27458
27459These @option{-m} options are defined for Matsushita MN10300 architectures:
27460
27461@table @gcctabopt
27462@item -mmult-bug
27463@opindex mmult-bug
27464Generate code to avoid bugs in the multiply instructions for the MN10300
27465processors. This is the default.
27466
27467@item -mno-mult-bug
27468@opindex mno-mult-bug
27469Do not generate code to avoid bugs in the multiply instructions for the
27470MN10300 processors.
27471
27472@item -mam33
27473@opindex mam33
27474Generate code using features specific to the AM33 processor.
27475
27476@item -mno-am33
27477@opindex mno-am33
27478Do not generate code using features specific to the AM33 processor. This
27479is the default.
27480
27481@item -mam33-2
27482@opindex mam33-2
27483Generate code using features specific to the AM33/2.0 processor.
27484
27485@item -mam34
27486@opindex mam34
27487Generate code using features specific to the AM34 processor.
27488
27489@item -mtune=@var{cpu-type}
27490@opindex mtune
27491Use the timing characteristics of the indicated CPU type when
27492scheduling instructions. This does not change the targeted processor
27493type. The CPU type must be one of @samp{mn10300}, @samp{am33},
27494@samp{am33-2} or @samp{am34}.
27495
27496@item -mreturn-pointer-on-d0
27497@opindex mreturn-pointer-on-d0
27498When generating a function that returns a pointer, return the pointer
27499in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
27500only in @code{a0}, and attempts to call such functions without a prototype
27501result in errors. Note that this option is on by default; use
27502@option{-mno-return-pointer-on-d0} to disable it.
27503
27504@item -mno-crt0
27505@opindex mno-crt0
27506Do not link in the C run-time initialization object file.
27507
27508@item -mrelax
27509@opindex mrelax
27510Indicate to the linker that it should perform a relaxation optimization pass
27511to shorten branches, calls and absolute memory addresses. This option only
27512has an effect when used on the command line for the final link step.
27513
27514This option makes symbolic debugging impossible.
27515
27516@item -mliw
27517@opindex mliw
27518Allow the compiler to generate @emph{Long Instruction Word}
27519instructions if the target is the @samp{AM33} or later. This is the
27520default. This option defines the preprocessor macro @code{__LIW__}.
27521
27522@item -mno-liw
27523@opindex mno-liw
27524Do not allow the compiler to generate @emph{Long Instruction Word}
27525instructions. This option defines the preprocessor macro
27526@code{__NO_LIW__}.
27527
27528@item -msetlb
27529@opindex msetlb
27530Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
27531instructions if the target is the @samp{AM33} or later. This is the
27532default. This option defines the preprocessor macro @code{__SETLB__}.
27533
27534@item -mno-setlb
27535@opindex mno-setlb
27536Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
27537instructions. This option defines the preprocessor macro
27538@code{__NO_SETLB__}.
27539
27540@end table
27541
27542@node Moxie Options
27543@subsection Moxie Options
27544@cindex Moxie Options
27545
27546@table @gcctabopt
27547
27548@item -meb
27549@opindex meb
27550Generate big-endian code. This is the default for @samp{moxie-*-*}
27551configurations.
27552
27553@item -mel
27554@opindex mel
27555Generate little-endian code.
27556
27557@item -mmul.x
27558@opindex mmul.x
27559Generate mul.x and umul.x instructions. This is the default for
27560@samp{moxiebox-*-*} configurations.
27561
27562@item -mno-crt0
27563@opindex mno-crt0
27564Do not link in the C run-time initialization object file.
27565
27566@end table
27567
27568@node MSP430 Options
27569@subsection MSP430 Options
27570@cindex MSP430 Options
27571
27572These options are defined for the MSP430:
27573
27574@table @gcctabopt
27575
27576@item -masm-hex
27577@opindex masm-hex
27578Force assembly output to always use hex constants. Normally such
27579constants are signed decimals, but this option is available for
27580testsuite and/or aesthetic purposes.
27581
27582@item -mmcu=
27583@opindex mmcu=
27584Select the MCU to target. This is used to create a C preprocessor
27585symbol based upon the MCU name, converted to upper case and pre- and
27586post-fixed with @samp{__}. This in turn is used by the
27587@file{msp430.h} header file to select an MCU-specific supplementary
27588header file.
27589
27590The option also sets the ISA to use. If the MCU name is one that is
27591known to only support the 430 ISA then that is selected, otherwise the
27592430X ISA is selected. A generic MCU name of @samp{msp430} can also be
27593used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
27594name selects the 430X ISA.
27595
27596In addition an MCU-specific linker script is added to the linker
27597command line. The script's name is the name of the MCU with
27598@file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
27599command line defines the C preprocessor symbol @code{__XXX__} and
27600cause the linker to search for a script called @file{xxx.ld}.
27601
27602The ISA and hardware multiply supported for the different MCUs is hard-coded
27603into GCC. However, an external @samp{devices.csv} file can be used to
27604extend device support beyond those that have been hard-coded.
27605
27606GCC searches for the @samp{devices.csv} file using the following methods in the
27607given precedence order, where the first method takes precendence over the
27608second which takes precedence over the third.
27609
27610@table @asis
27611@item Include path specified with @code{-I} and @code{-L}
27612@samp{devices.csv} will be searched for in each of the directories specified by
27613include paths and linker library search paths.
27614@item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
27615Define the value of the global environment variable
27616@samp{MSP430_GCC_INCLUDE_DIR}
27617to the full path to the directory containing devices.csv, and GCC will search
27618this directory for devices.csv. If devices.csv is found, this directory will
27619also be registered as an include path, and linker library path. Header files
27620and linker scripts in this directory can therefore be used without manually
27621specifying @code{-I} and @code{-L} on the command line.
27622@item The @samp{msp430-elf@{,bare@}/include/devices} directory
27623Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the
27624toolchain root directory. This directory does not exist in a default
27625installation, but if the user has created it and copied @samp{devices.csv}
27626there, then the MCU data will be read. As above, this directory will
27627also be registered as an include path, and linker library path.
27628
27629@end table
27630If none of the above search methods find @samp{devices.csv}, then the
27631hard-coded MCU data is used.
27632
27633
27634@item -mwarn-mcu
27635@itemx -mno-warn-mcu
27636@opindex mwarn-mcu
27637@opindex mno-warn-mcu
27638This option enables or disables warnings about conflicts between the
27639MCU name specified by the @option{-mmcu} option and the ISA set by the
27640@option{-mcpu} option and/or the hardware multiply support set by the
27641@option{-mhwmult} option. It also toggles warnings about unrecognized
27642MCU names. This option is on by default.
27643
27644@item -mcpu=
27645@opindex mcpu=
27646Specifies the ISA to use. Accepted values are @samp{msp430},
27647@samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
27648@option{-mmcu=} option should be used to select the ISA.
27649
27650@item -msim
27651@opindex msim
27652Link to the simulator runtime libraries and linker script. Overrides
27653any scripts that would be selected by the @option{-mmcu=} option.
27654
27655@item -mlarge
27656@opindex mlarge
27657Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
27658
27659@item -msmall
27660@opindex msmall
27661Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
27662
27663@item -mrelax
27664@opindex mrelax
27665This option is passed to the assembler and linker, and allows the
27666linker to perform certain optimizations that cannot be done until
27667the final link.
27668
27669@item mhwmult=
27670@opindex mhwmult=
27671Describes the type of hardware multiply supported by the target.
27672Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
27673for the original 16-bit-only multiply supported by early MCUs.
27674@samp{32bit} for the 16/32-bit multiply supported by later MCUs and
27675@samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
27676A value of @samp{auto} can also be given. This tells GCC to deduce
27677the hardware multiply support based upon the MCU name provided by the
27678@option{-mmcu} option. If no @option{-mmcu} option is specified or if
27679the MCU name is not recognized then no hardware multiply support is
27680assumed. @code{auto} is the default setting.
27681
27682Hardware multiplies are normally performed by calling a library
27683routine. This saves space in the generated code. When compiling at
27684@option{-O3} or higher however the hardware multiplier is invoked
27685inline. This makes for bigger, but faster code.
27686
27687The hardware multiply routines disable interrupts whilst running and
27688restore the previous interrupt state when they finish. This makes
27689them safe to use inside interrupt handlers as well as in normal code.
27690
27691@item -minrt
27692@opindex minrt
27693Enable the use of a minimum runtime environment - no static
27694initializers or constructors. This is intended for memory-constrained
27695devices. The compiler includes special symbols in some objects
27696that tell the linker and runtime which code fragments are required.
27697
27698@item -mtiny-printf
27699@opindex mtiny-printf
27700Enable reduced code size @code{printf} and @code{puts} library functions.
27701The @samp{tiny} implementations of these functions are not reentrant, so
27702must be used with caution in multi-threaded applications.
27703
27704Support for streams has been removed and the string to be printed will
27705always be sent to stdout via the @code{write} syscall. The string is not
27706buffered before it is sent to write.
27707
27708This option requires Newlib Nano IO, so GCC must be configured with
27709@samp{--enable-newlib-nano-formatted-io}.
27710
27711@item -mmax-inline-shift=
27712@opindex mmax-inline-shift=
27713This option takes an integer between 0 and 64 inclusive, and sets
27714the maximum number of inline shift instructions which should be emitted to
27715perform a shift operation by a constant amount. When this value needs to be
27716exceeded, an mspabi helper function is used instead. The default value is 4.
27717
27718This only affects cases where a shift by multiple positions cannot be
27719completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
27720
27721Shifts of a 32-bit value are at least twice as costly, so the value passed for
27722this option is divided by 2 and the resulting value used instead.
27723
27724@item -mcode-region=
27725@itemx -mdata-region=
27726@opindex mcode-region
27727@opindex mdata-region
27728These options tell the compiler where to place functions and data that
27729do not have one of the @code{lower}, @code{upper}, @code{either} or
27730@code{section} attributes. Possible values are @code{lower},
27731@code{upper}, @code{either} or @code{any}. The first three behave
27732like the corresponding attribute. The fourth possible value -
27733@code{any} - is the default. It leaves placement entirely up to the
27734linker script and how it assigns the standard sections
27735(@code{.text}, @code{.data}, etc) to the memory regions.
27736
27737@item -msilicon-errata=
27738@opindex msilicon-errata
27739This option passes on a request to assembler to enable the fixes for
27740the named silicon errata.
27741
27742@item -msilicon-errata-warn=
27743@opindex msilicon-errata-warn
27744This option passes on a request to the assembler to enable warning
27745messages when a silicon errata might need to be applied.
27746
27747@item -mwarn-devices-csv
27748@itemx -mno-warn-devices-csv
27749@opindex mwarn-devices-csv
27750@opindex mno-warn-devices-csv
27751Warn if @samp{devices.csv} is not found or there are problem parsing it
27752(default: on).
27753
27754@end table
27755
27756@node NDS32 Options
27757@subsection NDS32 Options
27758@cindex NDS32 Options
27759
27760These options are defined for NDS32 implementations:
27761
27762@table @gcctabopt
27763
27764@item -mbig-endian
27765@opindex mbig-endian
27766Generate code in big-endian mode.
27767
27768@item -mlittle-endian
27769@opindex mlittle-endian
27770Generate code in little-endian mode.
27771
27772@item -mreduced-regs
27773@opindex mreduced-regs
27774Use reduced-set registers for register allocation.
27775
27776@item -mfull-regs
27777@opindex mfull-regs
27778Use full-set registers for register allocation.
27779
27780@item -mcmov
27781@opindex mcmov
27782Generate conditional move instructions.
27783
27784@item -mno-cmov
27785@opindex mno-cmov
27786Do not generate conditional move instructions.
27787
27788@item -mext-perf
27789@opindex mext-perf
27790Generate performance extension instructions.
27791
27792@item -mno-ext-perf
27793@opindex mno-ext-perf
27794Do not generate performance extension instructions.
27795
27796@item -mext-perf2
27797@opindex mext-perf2
27798Generate performance extension 2 instructions.
27799
27800@item -mno-ext-perf2
27801@opindex mno-ext-perf2
27802Do not generate performance extension 2 instructions.
27803
27804@item -mext-string
27805@opindex mext-string
27806Generate string extension instructions.
27807
27808@item -mno-ext-string
27809@opindex mno-ext-string
27810Do not generate string extension instructions.
27811
27812@item -mv3push
27813@opindex mv3push
27814Generate v3 push25/pop25 instructions.
27815
27816@item -mno-v3push
27817@opindex mno-v3push
27818Do not generate v3 push25/pop25 instructions.
27819
27820@item -m16-bit
27821@opindex m16-bit
27822Generate 16-bit instructions.
27823
27824@item -mno-16-bit
27825@opindex mno-16-bit
27826Do not generate 16-bit instructions.
27827
27828@item -misr-vector-size=@var{num}
27829@opindex misr-vector-size
27830Specify the size of each interrupt vector, which must be 4 or 16.
27831
27832@item -mcache-block-size=@var{num}
27833@opindex mcache-block-size
27834Specify the size of each cache block,
27835which must be a power of 2 between 4 and 512.
27836
27837@item -march=@var{arch}
27838@opindex march
27839Specify the name of the target architecture.
27840
27841@item -mcmodel=@var{code-model}
27842@opindex mcmodel
27843Set the code model to one of
27844@table @asis
27845@item @samp{small}
27846All the data and read-only data segments must be within 512KB addressing space.
27847The text segment must be within 16MB addressing space.
27848@item @samp{medium}
27849The data segment must be within 512KB while the read-only data segment can be
27850within 4GB addressing space. The text segment should be still within 16MB
27851addressing space.
27852@item @samp{large}
27853All the text and data segments can be within 4GB addressing space.
27854@end table
27855
27856@item -mctor-dtor
27857@opindex mctor-dtor
27858Enable constructor/destructor feature.
27859
27860@item -mrelax
27861@opindex mrelax
27862Guide linker to relax instructions.
27863
27864@end table
27865
27866@node Nios II Options
27867@subsection Nios II Options
27868@cindex Nios II options
27869@cindex Altera Nios II options
27870
27871These are the options defined for the Altera Nios II processor.
27872
27873@table @gcctabopt
27874
27875@item -G @var{num}
27876@opindex G
27877@cindex smaller data references
27878Put global and static objects less than or equal to @var{num} bytes
27879into the small data or BSS sections instead of the normal data or BSS
27880sections. The default value of @var{num} is 8.
27881
27882@item -mgpopt=@var{option}
27883@itemx -mgpopt
27884@itemx -mno-gpopt
27885@opindex mgpopt
27886@opindex mno-gpopt
27887Generate (do not generate) GP-relative accesses. The following
27888@var{option} names are recognized:
27889
27890@table @samp
27891
27892@item none
27893Do not generate GP-relative accesses.
27894
27895@item local
27896Generate GP-relative accesses for small data objects that are not
27897external, weak, or uninitialized common symbols.
27898Also use GP-relative addressing for objects that
27899have been explicitly placed in a small data section via a @code{section}
27900attribute.
27901
27902@item global
27903As for @samp{local}, but also generate GP-relative accesses for
27904small data objects that are external, weak, or common. If you use this option,
27905you must ensure that all parts of your program (including libraries) are
27906compiled with the same @option{-G} setting.
27907
27908@item data
27909Generate GP-relative accesses for all data objects in the program. If you
27910use this option, the entire data and BSS segments
27911of your program must fit in 64K of memory and you must use an appropriate
27912linker script to allocate them within the addressable range of the
27913global pointer.
27914
27915@item all
27916Generate GP-relative addresses for function pointers as well as data
27917pointers. If you use this option, the entire text, data, and BSS segments
27918of your program must fit in 64K of memory and you must use an appropriate
27919linker script to allocate them within the addressable range of the
27920global pointer.
27921
27922@end table
27923
27924@option{-mgpopt} is equivalent to @option{-mgpopt=local}, and
27925@option{-mno-gpopt} is equivalent to @option{-mgpopt=none}.
27926
27927The default is @option{-mgpopt} except when @option{-fpic} or
27928@option{-fPIC} is specified to generate position-independent code.
27929Note that the Nios II ABI does not permit GP-relative accesses from
27930shared libraries.
27931
27932You may need to specify @option{-mno-gpopt} explicitly when building
27933programs that include large amounts of small data, including large
27934GOT data sections. In this case, the 16-bit offset for GP-relative
27935addressing may not be large enough to allow access to the entire
27936small data section.
27937
27938@item -mgprel-sec=@var{regexp}
27939@opindex mgprel-sec
27940This option specifies additional section names that can be accessed via
27941GP-relative addressing. It is most useful in conjunction with
27942@code{section} attributes on variable declarations
27943(@pxref{Common Variable Attributes}) and a custom linker script.
27944The @var{regexp} is a POSIX Extended Regular Expression.
27945
27946This option does not affect the behavior of the @option{-G} option, and
27947the specified sections are in addition to the standard @code{.sdata}
27948and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}.
27949
27950@item -mr0rel-sec=@var{regexp}
27951@opindex mr0rel-sec
27952This option specifies names of sections that can be accessed via a
2795316-bit offset from @code{r0}; that is, in the low 32K or high 32K
27954of the 32-bit address space. It is most useful in conjunction with
27955@code{section} attributes on variable declarations
27956(@pxref{Common Variable Attributes}) and a custom linker script.
27957The @var{regexp} is a POSIX Extended Regular Expression.
27958
27959In contrast to the use of GP-relative addressing for small data,
27960zero-based addressing is never generated by default and there are no
27961conventional section names used in standard linker scripts for sections
27962in the low or high areas of memory.
27963
27964@item -mel
27965@itemx -meb
27966@opindex mel
27967@opindex meb
27968Generate little-endian (default) or big-endian (experimental) code,
27969respectively.
27970
27971@item -march=@var{arch}
27972@opindex march
27973This specifies the name of the target Nios II architecture. GCC uses this
27974name to determine what kind of instructions it can emit when generating
27975assembly code. Permissible names are: @samp{r1}, @samp{r2}.
27976
27977The preprocessor macro @code{__nios2_arch__} is available to programs,
27978with value 1 or 2, indicating the targeted ISA level.
27979
27980@item -mbypass-cache
27981@itemx -mno-bypass-cache
27982@opindex mno-bypass-cache
27983@opindex mbypass-cache
27984Force all load and store instructions to always bypass cache by
27985using I/O variants of the instructions. The default is not to
27986bypass the cache.
27987
27988@item -mno-cache-volatile
27989@itemx -mcache-volatile
27990@opindex mcache-volatile
27991@opindex mno-cache-volatile
27992Volatile memory access bypass the cache using the I/O variants of
27993the load and store instructions. The default is not to bypass the cache.
27994
27995@item -mno-fast-sw-div
27996@itemx -mfast-sw-div
27997@opindex mno-fast-sw-div
27998@opindex mfast-sw-div
27999Do not use table-based fast divide for small numbers. The default
28000is to use the fast divide at @option{-O3} and above.
28001
28002@item -mno-hw-mul
28003@itemx -mhw-mul
28004@itemx -mno-hw-mulx
28005@itemx -mhw-mulx
28006@itemx -mno-hw-div
28007@itemx -mhw-div
28008@opindex mno-hw-mul
28009@opindex mhw-mul
28010@opindex mno-hw-mulx
28011@opindex mhw-mulx
28012@opindex mno-hw-div
28013@opindex mhw-div
28014Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
28015instructions by the compiler. The default is to emit @code{mul}
28016and not emit @code{div} and @code{mulx}.
28017
28018@item -mbmx
28019@itemx -mno-bmx
28020@itemx -mcdx
28021@itemx -mno-cdx
28022Enable or disable generation of Nios II R2 BMX (bit manipulation) and
28023CDX (code density) instructions. Enabling these instructions also
28024requires @option{-march=r2}. Since these instructions are optional
28025extensions to the R2 architecture, the default is not to emit them.
28026
28027@item -mcustom-@var{insn}=@var{N}
28028@itemx -mno-custom-@var{insn}
28029@opindex mcustom-@var{insn}
28030@opindex mno-custom-@var{insn}
28031Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a
28032custom instruction with encoding @var{N} when generating code that uses
28033@var{insn}. For example, @option{-mcustom-fadds=253} generates custom
28034instruction 253 for single-precision floating-point add operations instead
28035of the default behavior of using a library call.
28036
28037The following values of @var{insn} are supported. Except as otherwise
28038noted, floating-point operations are expected to be implemented with
28039normal IEEE 754 semantics and correspond directly to the C operators or the
28040equivalent GCC built-in functions (@pxref{Other Builtins}).
28041
28042Single-precision floating point:
28043@table @asis
28044
28045@item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls}
28046Binary arithmetic operations.
28047
28048@item @samp{fnegs}
28049Unary negation.
28050
28051@item @samp{fabss}
28052Unary absolute value.
28053
28054@item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes}
28055Comparison operations.
28056
28057@item @samp{fmins}, @samp{fmaxs}
28058Floating-point minimum and maximum. These instructions are only
28059generated if @option{-ffinite-math-only} is specified.
28060
28061@item @samp{fsqrts}
28062Unary square root operation.
28063
28064@item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs}
28065Floating-point trigonometric and exponential functions. These instructions
28066are only generated if @option{-funsafe-math-optimizations} is also specified.
28067
28068@end table
28069
28070Double-precision floating point:
28071@table @asis
28072
28073@item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld}
28074Binary arithmetic operations.
28075
28076@item @samp{fnegd}
28077Unary negation.
28078
28079@item @samp{fabsd}
28080Unary absolute value.
28081
28082@item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned}
28083Comparison operations.
28084
28085@item @samp{fmind}, @samp{fmaxd}
28086Double-precision minimum and maximum. These instructions are only
28087generated if @option{-ffinite-math-only} is specified.
28088
28089@item @samp{fsqrtd}
28090Unary square root operation.
28091
28092@item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd}
28093Double-precision trigonometric and exponential functions. These instructions
28094are only generated if @option{-funsafe-math-optimizations} is also specified.
28095
28096@end table
28097
28098Conversions:
28099@table @asis
28100@item @samp{fextsd}
28101Conversion from single precision to double precision.
28102
28103@item @samp{ftruncds}
28104Conversion from double precision to single precision.
28105
28106@item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu}
28107Conversion from floating point to signed or unsigned integer types, with
28108truncation towards zero.
28109
28110@item @samp{round}
28111Conversion from single-precision floating point to signed integer,
28112rounding to the nearest integer and ties away from zero.
28113This corresponds to the @code{__builtin_lroundf} function when
28114@option{-fno-math-errno} is used.
28115
28116@item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud}
28117Conversion from signed or unsigned integer types to floating-point types.
28118
28119@end table
28120
28121In addition, all of the following transfer instructions for internal
28122registers X and Y must be provided to use any of the double-precision
28123floating-point instructions. Custom instructions taking two
28124double-precision source operands expect the first operand in the
2812564-bit register X. The other operand (or only operand of a unary
28126operation) is given to the custom arithmetic instruction with the
28127least significant half in source register @var{src1} and the most
28128significant half in @var{src2}. A custom instruction that returns a
28129double-precision result returns the most significant 32 bits in the
28130destination register and the other half in 32-bit register Y.
28131GCC automatically generates the necessary code sequences to write
28132register X and/or read register Y when double-precision floating-point
28133instructions are used.
28134
28135@table @asis
28136
28137@item @samp{fwrx}
28138Write @var{src1} into the least significant half of X and @var{src2} into
28139the most significant half of X.
28140
28141@item @samp{fwry}
28142Write @var{src1} into Y.
28143
28144@item @samp{frdxhi}, @samp{frdxlo}
28145Read the most or least (respectively) significant half of X and store it in
28146@var{dest}.
28147
28148@item @samp{frdy}
28149Read the value of Y and store it into @var{dest}.
28150@end table
28151
28152Note that you can gain more local control over generation of Nios II custom
28153instructions by using the @code{target("custom-@var{insn}=@var{N}")}
28154and @code{target("no-custom-@var{insn}")} function attributes
28155(@pxref{Function Attributes})
28156or pragmas (@pxref{Function Specific Option Pragmas}).
28157
28158@item -mcustom-fpu-cfg=@var{name}
28159@opindex mcustom-fpu-cfg
28160
28161This option enables a predefined, named set of custom instruction encodings
28162(see @option{-mcustom-@var{insn}} above).
28163Currently, the following sets are defined:
28164
28165@option{-mcustom-fpu-cfg=60-1} is equivalent to:
28166@gccoptlist{-mcustom-fmuls=252 @gol
28167-mcustom-fadds=253 @gol
28168-mcustom-fsubs=254 @gol
28169-fsingle-precision-constant}
28170
28171@option{-mcustom-fpu-cfg=60-2} is equivalent to:
28172@gccoptlist{-mcustom-fmuls=252 @gol
28173-mcustom-fadds=253 @gol
28174-mcustom-fsubs=254 @gol
28175-mcustom-fdivs=255 @gol
28176-fsingle-precision-constant}
28177
28178@option{-mcustom-fpu-cfg=72-3} is equivalent to:
28179@gccoptlist{-mcustom-floatus=243 @gol
28180-mcustom-fixsi=244 @gol
28181-mcustom-floatis=245 @gol
28182-mcustom-fcmpgts=246 @gol
28183-mcustom-fcmples=249 @gol
28184-mcustom-fcmpeqs=250 @gol
28185-mcustom-fcmpnes=251 @gol
28186-mcustom-fmuls=252 @gol
28187-mcustom-fadds=253 @gol
28188-mcustom-fsubs=254 @gol
28189-mcustom-fdivs=255 @gol
28190-fsingle-precision-constant}
28191
28192@option{-mcustom-fpu-cfg=fph2} is equivalent to:
28193@gccoptlist{-mcustom-fabss=224 @gol
28194-mcustom-fnegs=225 @gol
28195-mcustom-fcmpnes=226 @gol
28196-mcustom-fcmpeqs=227 @gol
28197-mcustom-fcmpges=228 @gol
28198-mcustom-fcmpgts=229 @gol
28199-mcustom-fcmples=230 @gol
28200-mcustom-fcmplts=231 @gol
28201-mcustom-fmaxs=232 @gol
28202-mcustom-fmins=233 @gol
28203-mcustom-round=248 @gol
28204-mcustom-fixsi=249 @gol
28205-mcustom-floatis=250 @gol
28206-mcustom-fsqrts=251 @gol
28207-mcustom-fmuls=252 @gol
28208-mcustom-fadds=253 @gol
28209-mcustom-fsubs=254 @gol
28210-mcustom-fdivs=255 @gol}
28211
28212Custom instruction assignments given by individual
28213@option{-mcustom-@var{insn}=} options override those given by
28214@option{-mcustom-fpu-cfg=}, regardless of the
28215order of the options on the command line.
28216
28217Note that you can gain more local control over selection of a FPU
28218configuration by using the @code{target("custom-fpu-cfg=@var{name}")}
28219function attribute (@pxref{Function Attributes})
28220or pragma (@pxref{Function Specific Option Pragmas}).
28221
28222The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point
28223Hardware 2 Component}. Please note that the custom instructions enabled by
28224@option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated
28225if @option{-ffinite-math-only} is specified. The custom instruction enabled by
28226@option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is
28227specified. In contrast to the other configurations,
28228@option{-fsingle-precision-constant} is not set.
28229
28230@end table
28231
28232These additional @samp{-m} options are available for the Altera Nios II
28233ELF (bare-metal) target:
28234
28235@table @gcctabopt
28236
28237@item -mhal
28238@opindex mhal
28239Link with HAL BSP. This suppresses linking with the GCC-provided C runtime
28240startup and termination code, and is typically used in conjunction with
28241@option{-msys-crt0=} to specify the location of the alternate startup code
28242provided by the HAL BSP.
28243
28244@item -msmallc
28245@opindex msmallc
28246Link with a limited version of the C library, @option{-lsmallc}, rather than
28247Newlib.
28248
28249@item -msys-crt0=@var{startfile}
28250@opindex msys-crt0
28251@var{startfile} is the file name of the startfile (crt0) to use
28252when linking. This option is only useful in conjunction with @option{-mhal}.
28253
28254@item -msys-lib=@var{systemlib}
28255@opindex msys-lib
28256@var{systemlib} is the library name of the library that provides
28257low-level system calls required by the C library,
28258e.g.@: @code{read} and @code{write}.
28259This option is typically used to link with a library provided by a HAL BSP.
28260
28261@end table
28262
28263@node Nvidia PTX Options
28264@subsection Nvidia PTX Options
28265@cindex Nvidia PTX options
28266@cindex nvptx options
28267
28268These options are defined for Nvidia PTX:
28269
28270@table @gcctabopt
28271
28272@item -m64
28273@opindex m64
28274Ignored, but preserved for backward compatibility. Only 64-bit ABI is
28275supported.
28276
28277@item -march=@var{architecture-string}
28278@opindex march
28279Generate code for the specified PTX ISA target architecture
28280(e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30},
28281@samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and
28282@samp{sm_80}.
28283The default depends on how the compiler has been configured, see
28284@option{--with-arch}.
28285
28286This option sets the value of the preprocessor macro
28287@code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value
28288@samp{350}.
28289
28290@item -misa=@var{architecture-string}
28291@opindex misa
28292Alias of @option{-march=}.
28293
28294@item -march-map=@var{architecture-string}
28295@opindex march
28296Select the closest available @option{-march=} value that is not more
28297capable. For instance, for @option{-march-map=sm_50} select
28298@option{-march=sm_35}, and for @option{-march-map=sm_53} select
28299@option{-march=sm_53}.
28300
28301@item -mptx=@var{version-string}
28302@opindex mptx
28303Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}).
28304Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and
28305@samp{7.0}. The default PTX ISA version is 6.0, unless a higher
28306version is required for specified PTX ISA target architecture via
28307option @option{-march=}.
28308
28309This option sets the values of the preprocessor macros
28310@code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__};
28311for instance, for @samp{3.1} the macros have the values @samp{3} and
28312@samp{1}, respectively.
28313
28314@item -mmainkernel
28315@opindex mmainkernel
28316Link in code for a __main kernel. This is for stand-alone instead of
28317offloading execution.
28318
28319@item -moptimize
28320@opindex moptimize
28321Apply partitioned execution optimizations. This is the default when any
28322level of optimization is selected.
28323
28324@item -msoft-stack
28325@opindex msoft-stack
28326Generate code that does not use @code{.local} memory
28327directly for stack storage. Instead, a per-warp stack pointer is
28328maintained explicitly. This enables variable-length stack allocation (with
28329variable-length arrays or @code{alloca}), and when global memory is used for
28330underlying storage, makes it possible to access automatic variables from other
28331threads, or with atomic instructions. This code generation variant is used
28332for OpenMP offloading, but the option is exposed on its own for the purpose
28333of testing the compiler; to generate code suitable for linking into programs
28334using OpenMP offloading, use option @option{-mgomp}.
28335
28336@item -muniform-simt
28337@opindex muniform-simt
28338Switch to code generation variant that allows to execute all threads in each
28339warp, while maintaining memory state and side effects as if only one thread
28340in each warp was active outside of OpenMP SIMD regions. All atomic operations
28341and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
28342current lane index equals the master lane index), and the register being
28343assigned is copied via a shuffle instruction from the master lane. Outside of
28344SIMD regions lane 0 is the master; inside, each thread sees itself as the
28345master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
28346all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
28347regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
28348with current lane index to compute the master lane index.
28349
28350@item -mgomp
28351@opindex mgomp
28352Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
28353@option{-muniform-simt} options, and selects corresponding multilib variant.
28354
28355@end table
28356
28357@node OpenRISC Options
28358@subsection OpenRISC Options
28359@cindex OpenRISC Options
28360
28361These options are defined for OpenRISC:
28362
28363@table @gcctabopt
28364
28365@item -mboard=@var{name}
28366@opindex mboard
28367Configure a board specific runtime. This will be passed to the linker for
28368newlib board library linking. The default is @code{or1ksim}.
28369
28370@item -mnewlib
28371@opindex mnewlib
28372This option is ignored; it is for compatibility purposes only. This used to
28373select linker and preprocessor options for use with newlib.
28374
28375@item -msoft-div
28376@itemx -mhard-div
28377@opindex msoft-div
28378@opindex mhard-div
28379Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
28380This default is hardware divide.
28381
28382@item -msoft-mul
28383@itemx -mhard-mul
28384@opindex msoft-mul
28385@opindex mhard-mul
28386Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
28387This default is hardware multiply.
28388
28389@item -msoft-float
28390@itemx -mhard-float
28391@opindex msoft-float
28392@opindex mhard-float
28393Select software or hardware for floating point operations.
28394The default is software.
28395
28396@item -mdouble-float
28397@opindex mdouble-float
28398When @option{-mhard-float} is selected, enables generation of double-precision
28399floating point instructions. By default functions from @file{libgcc} are used
28400to perform double-precision floating point operations.
28401
28402@item -munordered-float
28403@opindex munordered-float
28404When @option{-mhard-float} is selected, enables generation of unordered
28405floating point compare and set flag (@code{lf.sfun*}) instructions. By default
28406functions from @file{libgcc} are used to perform unordered floating point
28407compare and set flag operations.
28408
28409@item -mcmov
28410@opindex mcmov
28411Enable generation of conditional move (@code{l.cmov}) instructions. By
28412default the equivalent will be generated using set and branch.
28413
28414@item -mror
28415@opindex mror
28416Enable generation of rotate right (@code{l.ror}) instructions. By default
28417functions from @file{libgcc} are used to perform rotate right operations.
28418
28419@item -mrori
28420@opindex mrori
28421Enable generation of rotate right with immediate (@code{l.rori}) instructions.
28422By default functions from @file{libgcc} are used to perform rotate right with
28423immediate operations.
28424
28425@item -msext
28426@opindex msext
28427Enable generation of sign extension (@code{l.ext*}) instructions. By default
28428memory loads are used to perform sign extension.
28429
28430@item -msfimm
28431@opindex msfimm
28432Enable generation of compare and set flag with immediate (@code{l.sf*i})
28433instructions. By default extra instructions will be generated to store the
28434immediate to a register first.
28435
28436@item -mshftimm
28437@opindex mshftimm
28438Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
28439@code{l.slli}) instructions. By default extra instructions will be generated
28440to store the immediate to a register first.
28441
28442@item -mcmodel=small
28443@opindex mcmodel=small
28444Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
28445the default model.
28446
28447@item -mcmodel=large
28448@opindex mcmodel=large
28449Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
28450
28451
28452@end table
28453
28454@node PDP-11 Options
28455@subsection PDP-11 Options
28456@cindex PDP-11 Options
28457
28458These options are defined for the PDP-11:
28459
28460@table @gcctabopt
28461@item -mfpu
28462@opindex mfpu
28463Use hardware FPP floating point. This is the default. (FIS floating
28464point on the PDP-11/40 is not supported.) Implies -m45.
28465
28466@item -msoft-float
28467@opindex msoft-float
28468Do not use hardware floating point.
28469
28470@item -mac0
28471@opindex mac0
28472Return floating-point results in ac0 (fr0 in Unix assembler syntax).
28473
28474@item -mno-ac0
28475@opindex mno-ac0
28476Return floating-point results in memory. This is the default.
28477
28478@item -m40
28479@opindex m40
28480Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
28481
28482@item -m45
28483@opindex m45
28484Generate code for a PDP-11/45. This is the default.
28485
28486@item -m10
28487@opindex m10
28488Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
28489
28490@item -mint16
28491@itemx -mno-int32
28492@opindex mint16
28493@opindex mno-int32
28494Use 16-bit @code{int}. This is the default.
28495
28496@item -mint32
28497@itemx -mno-int16
28498@opindex mint32
28499@opindex mno-int16
28500Use 32-bit @code{int}.
28501
28502@item -msplit
28503@opindex msplit
28504Target has split instruction and data space. Implies -m45.
28505
28506@item -munix-asm
28507@opindex munix-asm
28508Use Unix assembler syntax.
28509
28510@item -mdec-asm
28511@opindex mdec-asm
28512Use DEC assembler syntax.
28513
28514@item -mgnu-asm
28515@opindex mgnu-asm
28516Use GNU assembler syntax. This is the default.
28517
28518@item -mlra
28519@opindex mlra
28520Use the new LRA register allocator. By default, the old ``reload''
28521allocator is used.
28522@end table
28523
d77de738
ML
28524@node PowerPC Options
28525@subsection PowerPC Options
28526@cindex PowerPC options
28527
28528These are listed under @xref{RS/6000 and PowerPC Options}.
28529
28530@node PRU Options
28531@subsection PRU Options
28532@cindex PRU Options
28533
28534These command-line options are defined for PRU target:
28535
28536@table @gcctabopt
28537@item -minrt
28538@opindex minrt
28539Link with a minimum runtime environment, with no support for static
28540initializers and constructors. Using this option can significantly reduce
28541the size of the final ELF binary. Beware that the compiler could still
28542generate code with static initializers and constructors. It is up to the
28543programmer to ensure that the source program will not use those features.
28544
28545@item -mmcu=@var{mcu}
28546@opindex mmcu
28547Specify the PRU MCU variant to use. Check Newlib for the exact list of
28548supported MCUs.
28549
28550@item -mno-relax
28551@opindex mno-relax
28552Make GCC pass the @option{--no-relax} command-line option to the linker
28553instead of the @option{--relax} option.
28554
28555@item -mloop
28556@opindex mloop
28557Allow (or do not allow) GCC to use the LOOP instruction.
28558
28559@item -mabi=@var{variant}
28560@opindex mabi
28561Specify the ABI variant to output code for. @option{-mabi=ti} selects the
28562unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
28563more naturally with certain GCC assumptions. These are the differences:
28564
28565@table @samp
28566@item Function Pointer Size
28567TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
28568supports only 32-bit data and code pointers.
28569
28570@item Optional Return Value Pointer
28571Function return values larger than 64 bits are passed by using a hidden
28572pointer as the first argument of the function. TI ABI, though, mandates that
28573the pointer can be NULL in case the caller is not using the returned value.
28574GNU always passes and expects a valid return value pointer.
28575
28576@end table
28577
28578The current @option{-mabi=ti} implementation simply raises a compile error
28579when any of the above code constructs is detected. As a consequence
28580the standard C library cannot be built and it is omitted when linking with
28581@option{-mabi=ti}.
28582
28583Relaxation is a GNU feature and for safety reasons is disabled when using
28584@option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
28585instructions, so the GNU linker cannot adjust them when shortening adjacent
28586LDI32 pseudo instructions.
28587
28588@end table
28589
28590@node RISC-V Options
28591@subsection RISC-V Options
28592@cindex RISC-V Options
28593
28594These command-line options are defined for RISC-V targets:
28595
28596@table @gcctabopt
28597@item -mbranch-cost=@var{n}
28598@opindex mbranch-cost
28599Set the cost of branches to roughly @var{n} instructions.
28600
28601@item -mplt
28602@itemx -mno-plt
28603@opindex plt
28604When generating PIC code, do or don't allow the use of PLTs. Ignored for
28605non-PIC. The default is @option{-mplt}.
28606
28607@item -mabi=@var{ABI-string}
28608@opindex mabi
28609Specify integer and floating-point calling convention. @var{ABI-string}
28610contains two parts: the size of integer types and the registers used for
28611floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
28612@samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
2861332-bit), and that floating-point values up to 64 bits wide are passed in F
28614registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
28615allows the compiler to generate code that uses the F and D extensions but only
28616allows floating-point values up to 32 bits long to be passed in registers; or
28617@samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
28618passed in registers.
28619
28620The default for this argument is system dependent, users who want a specific
28621calling convention should specify one explicitly. The valid calling
28622conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
28623@samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
28624implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
28625invalid because the ABI requires 64-bit values be passed in F registers, but F
28626registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can
28627only be used with the @samp{rv32e} architecture. This ABI is not well
28628specified at present, and is subject to change.
28629
28630@item -mfdiv
28631@itemx -mno-fdiv
28632@opindex mfdiv
28633Do or don't use hardware floating-point divide and square root instructions.
28634This requires the F or D extensions for floating-point registers. The default
28635is to use them if the specified architecture has these instructions.
28636
28637@item -mdiv
28638@itemx -mno-div
28639@opindex mdiv
28640Do or don't use hardware instructions for integer division. This requires the
28641M extension. The default is to use them if the specified architecture has
28642these instructions.
28643
28644@item -misa-spec=@var{ISA-spec-string}
28645@opindex misa-spec
28646Specify the version of the RISC-V Unprivileged (formerly User-Level)
28647ISA specification to produce code conforming to. The possibilities
28648for @var{ISA-spec-string} are:
28649@table @code
28650@item 2.2
28651Produce code conforming to version 2.2.
28652@item 20190608
28653Produce code conforming to version 20190608.
28654@item 20191213
28655Produce code conforming to version 20191213.
28656@end table
28657The default is @option{-misa-spec=20191213} unless GCC has been configured
28658with @option{--with-isa-spec=} specifying a different default version.
28659
28660@item -march=@var{ISA-string}
28661@opindex march
28662Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be
28663lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and
28664@samp{rv32imaf}.
28665
28666When @option{-march=} is not specified, use the setting from @option{-mcpu}.
28667
28668If both @option{-march} and @option{-mcpu=} are not specified, the default for
28669this argument is system dependent, users who want a specific architecture
28670extensions should specify one explicitly.
28671
28672@item -mcpu=@var{processor-string}
28673@opindex mcpu
28674Use architecture of and optimize the output for the given processor, specified
28675by particular CPU name.
28676Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21},
28677@samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76},
28678@samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76},
aa37a91c 28679@samp{sifive-u54}, and @samp{sifive-u74}.
d77de738
ML
28680
28681@item -mtune=@var{processor-string}
28682@opindex mtune
28683Optimize the output for the given processor, specified by microarchitecture or
28684particular CPU name. Permissible values for this option are: @samp{rocket},
28685@samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series},
aa37a91c 28686@samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}.
d77de738
ML
28687
28688When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
28689the default is @samp{rocket} if both are not specified.
28690
28691The @samp{size} choice is not intended for use by end-users. This is used
28692when @option{-Os} is specified. It overrides the instruction cost info
28693provided by @option{-mtune=}, but does not override the pipeline info. This
28694helps reduce code size while still giving good performance.
28695
28696@item -mpreferred-stack-boundary=@var{num}
28697@opindex mpreferred-stack-boundary
28698Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
28699byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
28700the default is 4 (16 bytes or 128-bits).
28701
28702@strong{Warning:} If you use this switch, then you must build all modules with
28703the same value, including any libraries. This includes the system libraries
28704and startup modules.
28705
28706@item -msmall-data-limit=@var{n}
28707@opindex msmall-data-limit
28708Put global and static data smaller than @var{n} bytes into a special section
28709(on some targets).
28710
28711@item -msave-restore
28712@itemx -mno-save-restore
28713@opindex msave-restore
28714Do or don't use smaller but slower prologue and epilogue code that uses
28715library function calls. The default is to use fast inline prologues and
28716epilogues.
28717
28718@item -mshorten-memrefs
28719@itemx -mno-shorten-memrefs
28720@opindex mshorten-memrefs
28721Do or do not attempt to make more use of compressed load/store instructions by
28722replacing a load/store of 'base register + large offset' with a new load/store
28723of 'new base + small offset'. If the new base gets stored in a compressed
28724register, then the new load/store can be compressed. Currently targets 32-bit
28725integer load/stores only.
28726
28727@item -mstrict-align
28728@itemx -mno-strict-align
28729@opindex mstrict-align
28730Do not or do generate unaligned memory accesses. The default is set depending
28731on whether the processor we are optimizing for supports fast unaligned access
28732or not.
28733
28734@item -mcmodel=medlow
28735@opindex mcmodel=medlow
28736Generate code for the medium-low code model. The program and its statically
28737defined symbols must lie within a single 2 GiB address range and must lie
28738between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be
28739statically or dynamically linked. This is the default code model.
28740
28741@item -mcmodel=medany
28742@opindex mcmodel=medany
28743Generate code for the medium-any code model. The program and its statically
28744defined symbols must be within any single 2 GiB address range. Programs can be
28745statically or dynamically linked.
28746
28747The code generated by the medium-any code model is position-independent, but is
28748not guaranteed to function correctly when linked into position-independent
28749executables or libraries.
28750
28751@item -mexplicit-relocs
28752@itemx -mno-exlicit-relocs
28753Use or do not use assembler relocation operators when dealing with symbolic
28754addresses. The alternative is to use assembler macros instead, which may
28755limit optimization.
28756
28757@item -mrelax
28758@itemx -mno-relax
28759@opindex mrelax
28760Take advantage of linker relaxations to reduce the number of instructions
28761required to materialize symbol addresses. The default is to take advantage of
28762linker relaxations.
28763
28764@item -mriscv-attribute
28765@itemx -mno-riscv-attribute
28766@opindex mriscv-attribute
28767Emit (do not emit) RISC-V attribute to record extra information into ELF
28768objects. This feature requires at least binutils 2.32.
28769
28770@item -mcsr-check
28771@itemx -mno-csr-check
28772@opindex mcsr-check
28773Enables or disables the CSR checking.
28774
28775@item -malign-data=@var{type}
28776@opindex malign-data
28777Control how GCC aligns variables and constants of array, structure, or union
28778types. Supported values for @var{type} are @samp{xlen} which uses x register
28779width as the alignment value, and @samp{natural} which uses natural alignment.
28780@samp{xlen} is the default.
28781
28782@item -mbig-endian
28783@opindex mbig-endian
28784Generate big-endian code. This is the default when GCC is configured for a
28785@samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
28786
28787@item -mlittle-endian
28788@opindex mlittle-endian
28789Generate little-endian code. This is the default when GCC is configured for a
28790@samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
28791@samp{riscv32be-*-*} target.
28792
28793@item -mstack-protector-guard=@var{guard}
28794@itemx -mstack-protector-guard-reg=@var{reg}
28795@itemx -mstack-protector-guard-offset=@var{offset}
28796@opindex mstack-protector-guard
28797@opindex mstack-protector-guard-reg
28798@opindex mstack-protector-guard-offset
28799Generate stack protection code using canary at @var{guard}. Supported
28800locations are @samp{global} for a global canary or @samp{tls} for per-thread
28801canary in the TLS block.
28802
28803With the latter choice the options
28804@option{-mstack-protector-guard-reg=@var{reg}} and
28805@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
28806which register to use as base register for reading the canary,
28807and from what offset from that base register. There is no default
28808register or offset as this is entirely for use within the Linux
28809kernel.
28810@end table
28811
28812@node RL78 Options
28813@subsection RL78 Options
28814@cindex RL78 Options
28815
28816@table @gcctabopt
28817
28818@item -msim
28819@opindex msim
28820Links in additional target libraries to support operation within a
28821simulator.
28822
28823@item -mmul=none
28824@itemx -mmul=g10
28825@itemx -mmul=g13
28826@itemx -mmul=g14
28827@itemx -mmul=rl78
28828@opindex mmul
28829Specifies the type of hardware multiplication and division support to
28830be used. The simplest is @code{none}, which uses software for both
28831multiplication and division. This is the default. The @code{g13}
28832value is for the hardware multiply/divide peripheral found on the
28833RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
28834the multiplication and division instructions supported by the RL78/G14
28835(S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
28836the value @code{mg10} is an alias for @code{none}.
28837
28838In addition a C preprocessor macro is defined, based upon the setting
28839of this option. Possible values are: @code{__RL78_MUL_NONE__},
28840@code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
28841
28842@item -mcpu=g10
28843@itemx -mcpu=g13
28844@itemx -mcpu=g14
28845@itemx -mcpu=rl78
28846@opindex mcpu
28847Specifies the RL78 core to target. The default is the G14 core, also
28848known as an S3 core or just RL78. The G13 or S2 core does not have
28849multiply or divide instructions, instead it uses a hardware peripheral
28850for these operations. The G10 or S1 core does not have register
28851banks, so it uses a different calling convention.
28852
28853If this option is set it also selects the type of hardware multiply
28854support to use, unless this is overridden by an explicit
28855@option{-mmul=none} option on the command line. Thus specifying
28856@option{-mcpu=g13} enables the use of the G13 hardware multiply
28857peripheral and specifying @option{-mcpu=g10} disables the use of
28858hardware multiplications altogether.
28859
28860Note, although the RL78/G14 core is the default target, specifying
28861@option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
28862change the behavior of the toolchain since it also enables G14
28863hardware multiply support. If these options are not specified on the
28864command line then software multiplication routines will be used even
28865though the code targets the RL78 core. This is for backwards
28866compatibility with older toolchains which did not have hardware
28867multiply and divide support.
28868
28869In addition a C preprocessor macro is defined, based upon the setting
28870of this option. Possible values are: @code{__RL78_G10__},
28871@code{__RL78_G13__} or @code{__RL78_G14__}.
28872
28873@item -mg10
28874@itemx -mg13
28875@itemx -mg14
28876@itemx -mrl78
28877@opindex mg10
28878@opindex mg13
28879@opindex mg14
28880@opindex mrl78
28881These are aliases for the corresponding @option{-mcpu=} option. They
28882are provided for backwards compatibility.
28883
28884@item -mallregs
28885@opindex mallregs
28886Allow the compiler to use all of the available registers. By default
28887registers @code{r24..r31} are reserved for use in interrupt handlers.
28888With this option enabled these registers can be used in ordinary
28889functions as well.
28890
28891@item -m64bit-doubles
28892@itemx -m32bit-doubles
28893@opindex m64bit-doubles
28894@opindex m32bit-doubles
28895Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
28896or 32 bits (@option{-m32bit-doubles}) in size. The default is
28897@option{-m32bit-doubles}.
28898
28899@item -msave-mduc-in-interrupts
28900@itemx -mno-save-mduc-in-interrupts
28901@opindex msave-mduc-in-interrupts
28902@opindex mno-save-mduc-in-interrupts
28903Specifies that interrupt handler functions should preserve the
28904MDUC registers. This is only necessary if normal code might use
28905the MDUC registers, for example because it performs multiplication
28906and division operations. The default is to ignore the MDUC registers
28907as this makes the interrupt handlers faster. The target option -mg13
28908needs to be passed for this to work as this feature is only available
28909on the G13 target (S2 core). The MDUC registers will only be saved
28910if the interrupt handler performs a multiplication or division
28911operation or it calls another function.
28912
28913@end table
28914
28915@node RS/6000 and PowerPC Options
28916@subsection IBM RS/6000 and PowerPC Options
28917@cindex RS/6000 and PowerPC Options
28918@cindex IBM RS/6000 and PowerPC Options
28919
28920These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
28921@table @gcctabopt
28922@item -mpowerpc-gpopt
28923@itemx -mno-powerpc-gpopt
28924@itemx -mpowerpc-gfxopt
28925@itemx -mno-powerpc-gfxopt
28926@need 800
28927@itemx -mpowerpc64
28928@itemx -mno-powerpc64
28929@itemx -mmfcrf
28930@itemx -mno-mfcrf
28931@itemx -mpopcntb
28932@itemx -mno-popcntb
28933@itemx -mpopcntd
28934@itemx -mno-popcntd
28935@itemx -mfprnd
28936@itemx -mno-fprnd
28937@need 800
28938@itemx -mcmpb
28939@itemx -mno-cmpb
28940@itemx -mhard-dfp
28941@itemx -mno-hard-dfp
28942@opindex mpowerpc-gpopt
28943@opindex mno-powerpc-gpopt
28944@opindex mpowerpc-gfxopt
28945@opindex mno-powerpc-gfxopt
28946@opindex mpowerpc64
28947@opindex mno-powerpc64
28948@opindex mmfcrf
28949@opindex mno-mfcrf
28950@opindex mpopcntb
28951@opindex mno-popcntb
28952@opindex mpopcntd
28953@opindex mno-popcntd
28954@opindex mfprnd
28955@opindex mno-fprnd
28956@opindex mcmpb
28957@opindex mno-cmpb
28958@opindex mhard-dfp
28959@opindex mno-hard-dfp
28960You use these options to specify which instructions are available on the
28961processor you are using. The default value of these options is
28962determined when configuring GCC@. Specifying the
28963@option{-mcpu=@var{cpu_type}} overrides the specification of these
28964options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
28965rather than the options listed above.
28966
28967Specifying @option{-mpowerpc-gpopt} allows
28968GCC to use the optional PowerPC architecture instructions in the
28969General Purpose group, including floating-point square root. Specifying
28970@option{-mpowerpc-gfxopt} allows GCC to
28971use the optional PowerPC architecture instructions in the Graphics
28972group, including floating-point select.
28973
28974The @option{-mmfcrf} option allows GCC to generate the move from
28975condition register field instruction implemented on the POWER4
28976processor and other processors that support the PowerPC V2.01
28977architecture.
28978The @option{-mpopcntb} option allows GCC to generate the popcount and
28979double-precision FP reciprocal estimate instruction implemented on the
28980POWER5 processor and other processors that support the PowerPC V2.02
28981architecture.
28982The @option{-mpopcntd} option allows GCC to generate the popcount
28983instruction implemented on the POWER7 processor and other processors
28984that support the PowerPC V2.06 architecture.
28985The @option{-mfprnd} option allows GCC to generate the FP round to
28986integer instructions implemented on the POWER5+ processor and other
28987processors that support the PowerPC V2.03 architecture.
28988The @option{-mcmpb} option allows GCC to generate the compare bytes
28989instruction implemented on the POWER6 processor and other processors
28990that support the PowerPC V2.05 architecture.
28991The @option{-mhard-dfp} option allows GCC to generate the decimal
28992floating-point instructions implemented on some POWER processors.
28993
28994The @option{-mpowerpc64} option allows GCC to generate the additional
2899564-bit instructions that are found in the full PowerPC64 architecture
28996and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
28997@option{-mno-powerpc64}.
28998
28999@item -mcpu=@var{cpu_type}
29000@opindex mcpu
29001Set architecture type, register usage, and
29002instruction scheduling parameters for machine type @var{cpu_type}.
29003Supported values for @var{cpu_type} are @samp{401}, @samp{403},
29004@samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
29005@samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
29006@samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
29007@samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
29008@samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
29009@samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
29010@samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
29011@samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
29012@samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
29013@samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64},
29014@samp{powerpc64le}, @samp{rs64}, and @samp{native}.
29015
29016@option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
29017@option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
29018endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
29019architecture machine types, with an appropriate, generic processor
29020model assumed for scheduling purposes.
29021
29022Specifying @samp{native} as cpu type detects and selects the
29023architecture option that corresponds to the host processor of the
29024system performing the compilation.
29025@option{-mcpu=native} has no effect if GCC does not recognize the
29026processor.
29027
29028The other options specify a specific processor. Code generated under
29029those options runs best on that processor, and may not run at all on
29030others.
29031
29032The @option{-mcpu} options automatically enable or disable the
29033following options:
29034
29035@gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple @gol
29036-mpopcntb -mpopcntd -mpowerpc64 @gol
29037-mpowerpc-gpopt -mpowerpc-gfxopt @gol
29038-mmulhw -mdlmzb -mmfpgpr -mvsx @gol
29039-mcrypto -mhtm -mpower8-fusion -mpower8-vector @gol
29040-mquad-memory -mquad-memory-atomic -mfloat128 @gol
29041-mfloat128-hardware -mprefixed -mpcrel -mmma @gol
29042-mrop-protect}
29043
29044The particular options set for any particular CPU varies between
29045compiler versions, depending on what setting seems to produce optimal
29046code for that CPU; it doesn't necessarily reflect the actual hardware's
29047capabilities. If you wish to set an individual option to a particular
29048value, you may specify it after the @option{-mcpu} option, like
29049@option{-mcpu=970 -mno-altivec}.
29050
29051On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
29052not enabled or disabled by the @option{-mcpu} option at present because
29053AIX does not have full support for these options. You may still
29054enable or disable them individually if you're sure it'll work in your
29055environment.
29056
29057@item -mtune=@var{cpu_type}
29058@opindex mtune
29059Set the instruction scheduling parameters for machine type
29060@var{cpu_type}, but do not set the architecture type or register usage,
29061as @option{-mcpu=@var{cpu_type}} does. The same
29062values for @var{cpu_type} are used for @option{-mtune} as for
29063@option{-mcpu}. If both are specified, the code generated uses the
29064architecture and registers set by @option{-mcpu}, but the
29065scheduling parameters set by @option{-mtune}.
29066
29067@item -mcmodel=small
29068@opindex mcmodel=small
29069Generate PowerPC64 code for the small model: The TOC is limited to
2907064k.
29071
29072@item -mcmodel=medium
29073@opindex mcmodel=medium
29074Generate PowerPC64 code for the medium model: The TOC and other static
29075data may be up to a total of 4G in size. This is the default for 64-bit
29076Linux.
29077
29078@item -mcmodel=large
29079@opindex mcmodel=large
29080Generate PowerPC64 code for the large model: The TOC may be up to 4G
29081in size. Other data and code is only limited by the 64-bit address
29082space.
29083
29084@item -maltivec
29085@itemx -mno-altivec
29086@opindex maltivec
29087@opindex mno-altivec
29088Generate code that uses (does not use) AltiVec instructions, and also
29089enable the use of built-in functions that allow more direct access to
29090the AltiVec instruction set. You may also need to set
29091@option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
29092enhancements.
29093
29094When @option{-maltivec} is used, the element order for AltiVec intrinsics
29095such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
29096match array element order corresponding to the endianness of the
29097target. That is, element zero identifies the leftmost element in a
29098vector register when targeting a big-endian platform, and identifies
29099the rightmost element in a vector register when targeting a
29100little-endian platform.
29101
29102@item -mvrsave
29103@itemx -mno-vrsave
29104@opindex mvrsave
29105@opindex mno-vrsave
29106Generate VRSAVE instructions when generating AltiVec code.
29107
29108@item -msecure-plt
29109@opindex msecure-plt
29110Generate code that allows @command{ld} and @command{ld.so}
29111to build executables and shared
29112libraries with non-executable @code{.plt} and @code{.got} sections.
29113This is a PowerPC
2911432-bit SYSV ABI option.
29115
29116@item -mbss-plt
29117@opindex mbss-plt
29118Generate code that uses a BSS @code{.plt} section that @command{ld.so}
29119fills in, and
29120requires @code{.plt} and @code{.got}
29121sections that are both writable and executable.
29122This is a PowerPC 32-bit SYSV ABI option.
29123
29124@item -misel
29125@itemx -mno-isel
29126@opindex misel
29127@opindex mno-isel
29128This switch enables or disables the generation of ISEL instructions.
29129
29130@item -mvsx
29131@itemx -mno-vsx
29132@opindex mvsx
29133@opindex mno-vsx
29134Generate code that uses (does not use) vector/scalar (VSX)
29135instructions, and also enable the use of built-in functions that allow
29136more direct access to the VSX instruction set.
29137
29138@item -mcrypto
29139@itemx -mno-crypto
29140@opindex mcrypto
29141@opindex mno-crypto
29142Enable the use (disable) of the built-in functions that allow direct
29143access to the cryptographic instructions that were added in version
291442.07 of the PowerPC ISA.
29145
29146@item -mhtm
29147@itemx -mno-htm
29148@opindex mhtm
29149@opindex mno-htm
29150Enable (disable) the use of the built-in functions that allow direct
29151access to the Hardware Transactional Memory (HTM) instructions that
29152were added in version 2.07 of the PowerPC ISA.
29153
29154@item -mpower8-fusion
29155@itemx -mno-power8-fusion
29156@opindex mpower8-fusion
29157@opindex mno-power8-fusion
29158Generate code that keeps (does not keeps) some integer operations
29159adjacent so that the instructions can be fused together on power8 and
29160later processors.
29161
29162@item -mpower8-vector
29163@itemx -mno-power8-vector
29164@opindex mpower8-vector
29165@opindex mno-power8-vector
29166Generate code that uses (does not use) the vector and scalar
29167instructions that were added in version 2.07 of the PowerPC ISA. Also
29168enable the use of built-in functions that allow more direct access to
29169the vector instructions.
29170
29171@item -mquad-memory
29172@itemx -mno-quad-memory
29173@opindex mquad-memory
29174@opindex mno-quad-memory
29175Generate code that uses (does not use) the non-atomic quad word memory
29176instructions. The @option{-mquad-memory} option requires use of
2917764-bit mode.
29178
29179@item -mquad-memory-atomic
29180@itemx -mno-quad-memory-atomic
29181@opindex mquad-memory-atomic
29182@opindex mno-quad-memory-atomic
29183Generate code that uses (does not use) the atomic quad word memory
29184instructions. The @option{-mquad-memory-atomic} option requires use of
2918564-bit mode.
29186
29187@item -mfloat128
29188@itemx -mno-float128
29189@opindex mfloat128
29190@opindex mno-float128
29191Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
29192and use either software emulation for IEEE 128-bit floating point or
29193hardware instructions.
29194
29195The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
29196128-bit floating point support. The IEEE 128-bit floating point is only
29197supported on Linux.
29198
29199The default for @option{-mfloat128} is enabled on PowerPC Linux
29200systems using the VSX instruction set, and disabled on other systems.
29201
29202If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or
29203@option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating
29204point support will also enable the generation of ISA 3.0 IEEE 128-bit
29205floating point instructions. Otherwise, if you do not specify to
29206generate ISA 3.0 instructions or you are targeting a 32-bit big endian
29207system, IEEE 128-bit floating point will be done with software
29208emulation.
29209
29210@item -mfloat128-hardware
29211@itemx -mno-float128-hardware
29212@opindex mfloat128-hardware
29213@opindex mno-float128-hardware
29214Enable/disable using ISA 3.0 hardware instructions to support the
29215@var{__float128} data type.
29216
29217The default for @option{-mfloat128-hardware} is enabled on PowerPC
29218Linux systems using the ISA 3.0 instruction set, and disabled on other
29219systems.
29220
29221@item -m32
29222@itemx -m64
29223@opindex m32
29224@opindex m64
29225Generate code for 32-bit or 64-bit environments of Darwin and SVR4
29226targets (including GNU/Linux). The 32-bit environment sets int, long
29227and pointer to 32 bits and generates code that runs on any PowerPC
29228variant. The 64-bit environment sets int to 32 bits and long and
29229pointer to 64 bits, and generates code for PowerPC64, as for
29230@option{-mpowerpc64}.
29231
29232@item -mfull-toc
29233@itemx -mno-fp-in-toc
29234@itemx -mno-sum-in-toc
29235@itemx -mminimal-toc
29236@opindex mfull-toc
29237@opindex mno-fp-in-toc
29238@opindex mno-sum-in-toc
29239@opindex mminimal-toc
29240Modify generation of the TOC (Table Of Contents), which is created for
29241every executable file. The @option{-mfull-toc} option is selected by
29242default. In that case, GCC allocates at least one TOC entry for
29243each unique non-automatic variable reference in your program. GCC
29244also places floating-point constants in the TOC@. However, only
2924516,384 entries are available in the TOC@.
29246
29247If you receive a linker error message that saying you have overflowed
29248the available TOC space, you can reduce the amount of TOC space used
29249with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
29250@option{-mno-fp-in-toc} prevents GCC from putting floating-point
29251constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
29252generate code to calculate the sum of an address and a constant at
29253run time instead of putting that sum into the TOC@. You may specify one
29254or both of these options. Each causes GCC to produce very slightly
29255slower and larger code at the expense of conserving TOC space.
29256
29257If you still run out of space in the TOC even when you specify both of
29258these options, specify @option{-mminimal-toc} instead. This option causes
29259GCC to make only one TOC entry for every file. When you specify this
29260option, GCC produces code that is slower and larger but which
29261uses extremely little TOC space. You may wish to use this option
29262only on files that contain less frequently-executed code.
29263
29264@item -maix64
29265@itemx -maix32
29266@opindex maix64
29267@opindex maix32
29268Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
29269@code{long} type, and the infrastructure needed to support them.
29270Specifying @option{-maix64} implies @option{-mpowerpc64},
29271while @option{-maix32} disables the 64-bit ABI and
29272implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
29273
29274@item -mxl-compat
29275@itemx -mno-xl-compat
29276@opindex mxl-compat
29277@opindex mno-xl-compat
29278Produce code that conforms more closely to IBM XL compiler semantics
29279when using AIX-compatible ABI@. Pass floating-point arguments to
29280prototyped functions beyond the register save area (RSA) on the stack
29281in addition to argument FPRs. Do not assume that most significant
29282double in 128-bit long double value is properly rounded when comparing
29283values and converting to double. Use XL symbol names for long double
29284support routines.
29285
29286The AIX calling convention was extended but not initially documented to
29287handle an obscure K&R C case of calling a function that takes the
29288address of its arguments with fewer arguments than declared. IBM XL
29289compilers access floating-point arguments that do not fit in the
29290RSA from the stack when a subroutine is compiled without
29291optimization. Because always storing floating-point arguments on the
29292stack is inefficient and rarely needed, this option is not enabled by
29293default and only is necessary when calling subroutines compiled by IBM
29294XL compilers without optimization.
29295
29296@item -mpe
29297@opindex mpe
29298Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
29299application written to use message passing with special startup code to
29300enable the application to run. The system must have PE installed in the
29301standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
29302must be overridden with the @option{-specs=} option to specify the
29303appropriate directory location. The Parallel Environment does not
29304support threads, so the @option{-mpe} option and the @option{-pthread}
29305option are incompatible.
29306
29307@item -malign-natural
29308@itemx -malign-power
29309@opindex malign-natural
29310@opindex malign-power
29311On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
29312@option{-malign-natural} overrides the ABI-defined alignment of larger
29313types, such as floating-point doubles, on their natural size-based boundary.
29314The option @option{-malign-power} instructs GCC to follow the ABI-specified
29315alignment rules. GCC defaults to the standard alignment defined in the ABI@.
29316
29317On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
29318is not supported.
29319
29320@item -msoft-float
29321@itemx -mhard-float
29322@opindex msoft-float
29323@opindex mhard-float
29324Generate code that does not use (uses) the floating-point register set.
29325Software floating-point emulation is provided if you use the
29326@option{-msoft-float} option, and pass the option to GCC when linking.
29327
29328@item -mmultiple
29329@itemx -mno-multiple
29330@opindex mmultiple
29331@opindex mno-multiple
29332Generate code that uses (does not use) the load multiple word
29333instructions and the store multiple word instructions. These
29334instructions are generated by default on POWER systems, and not
29335generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
29336PowerPC systems, since those instructions do not work when the
29337processor is in little-endian mode. The exceptions are PPC740 and
29338PPC750 which permit these instructions in little-endian mode.
29339
29340@item -mupdate
29341@itemx -mno-update
29342@opindex mupdate
29343@opindex mno-update
29344Generate code that uses (does not use) the load or store instructions
29345that update the base register to the address of the calculated memory
29346location. These instructions are generated by default. If you use
29347@option{-mno-update}, there is a small window between the time that the
29348stack pointer is updated and the address of the previous frame is
29349stored, which means code that walks the stack frame across interrupts or
29350signals may get corrupted data.
29351
29352@item -mavoid-indexed-addresses
29353@itemx -mno-avoid-indexed-addresses
29354@opindex mavoid-indexed-addresses
29355@opindex mno-avoid-indexed-addresses
29356Generate code that tries to avoid (not avoid) the use of indexed load
29357or store instructions. These instructions can incur a performance
29358penalty on Power6 processors in certain situations, such as when
29359stepping through large arrays that cross a 16M boundary. This option
29360is enabled by default when targeting Power6 and disabled otherwise.
29361
29362@item -mfused-madd
29363@itemx -mno-fused-madd
29364@opindex mfused-madd
29365@opindex mno-fused-madd
29366Generate code that uses (does not use) the floating-point multiply and
29367accumulate instructions. These instructions are generated by default
29368if hardware floating point is used. The machine-dependent
29369@option{-mfused-madd} option is now mapped to the machine-independent
29370@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
29371mapped to @option{-ffp-contract=off}.
29372
29373@item -mmulhw
29374@itemx -mno-mulhw
29375@opindex mmulhw
29376@opindex mno-mulhw
29377Generate code that uses (does not use) the half-word multiply and
29378multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
29379These instructions are generated by default when targeting those
29380processors.
29381
29382@item -mdlmzb
29383@itemx -mno-dlmzb
29384@opindex mdlmzb
29385@opindex mno-dlmzb
29386Generate code that uses (does not use) the string-search @samp{dlmzb}
29387instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
29388generated by default when targeting those processors.
29389
29390@item -mno-bit-align
29391@itemx -mbit-align
29392@opindex mno-bit-align
29393@opindex mbit-align
29394On System V.4 and embedded PowerPC systems do not (do) force structures
29395and unions that contain bit-fields to be aligned to the base type of the
29396bit-field.
29397
29398For example, by default a structure containing nothing but 8
29399@code{unsigned} bit-fields of length 1 is aligned to a 4-byte
29400boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
29401the structure is aligned to a 1-byte boundary and is 1 byte in
29402size.
29403
29404@item -mno-strict-align
29405@itemx -mstrict-align
29406@opindex mno-strict-align
29407@opindex mstrict-align
29408On System V.4 and embedded PowerPC systems do not (do) assume that
29409unaligned memory references are handled by the system.
29410
29411@item -mrelocatable
29412@itemx -mno-relocatable
29413@opindex mrelocatable
29414@opindex mno-relocatable
29415Generate code that allows (does not allow) a static executable to be
29416relocated to a different address at run time. A simple embedded
29417PowerPC system loader should relocate the entire contents of
29418@code{.got2} and 4-byte locations listed in the @code{.fixup} section,
29419a table of 32-bit addresses generated by this option. For this to
29420work, all objects linked together must be compiled with
29421@option{-mrelocatable} or @option{-mrelocatable-lib}.
29422@option{-mrelocatable} code aligns the stack to an 8-byte boundary.
29423
29424@item -mrelocatable-lib
29425@itemx -mno-relocatable-lib
29426@opindex mrelocatable-lib
29427@opindex mno-relocatable-lib
29428Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
29429@code{.fixup} section to allow static executables to be relocated at
29430run time, but @option{-mrelocatable-lib} does not use the smaller stack
29431alignment of @option{-mrelocatable}. Objects compiled with
29432@option{-mrelocatable-lib} may be linked with objects compiled with
29433any combination of the @option{-mrelocatable} options.
29434
29435@item -mno-toc
29436@itemx -mtoc
29437@opindex mno-toc
29438@opindex mtoc
29439On System V.4 and embedded PowerPC systems do not (do) assume that
29440register 2 contains a pointer to a global area pointing to the addresses
29441used in the program.
29442
29443@item -mlittle
29444@itemx -mlittle-endian
29445@opindex mlittle
29446@opindex mlittle-endian
29447On System V.4 and embedded PowerPC systems compile code for the
29448processor in little-endian mode. The @option{-mlittle-endian} option is
29449the same as @option{-mlittle}.
29450
29451@item -mbig
29452@itemx -mbig-endian
29453@opindex mbig
29454@opindex mbig-endian
29455On System V.4 and embedded PowerPC systems compile code for the
29456processor in big-endian mode. The @option{-mbig-endian} option is
29457the same as @option{-mbig}.
29458
29459@item -mdynamic-no-pic
29460@opindex mdynamic-no-pic
29461On Darwin and Mac OS X systems, compile code so that it is not
29462relocatable, but that its external references are relocatable. The
29463resulting code is suitable for applications, but not shared
29464libraries.
29465
29466@item -msingle-pic-base
29467@opindex msingle-pic-base
29468Treat the register used for PIC addressing as read-only, rather than
29469loading it in the prologue for each function. The runtime system is
29470responsible for initializing this register with an appropriate value
29471before execution begins.
29472
29473@item -mprioritize-restricted-insns=@var{priority}
29474@opindex mprioritize-restricted-insns
29475This option controls the priority that is assigned to
29476dispatch-slot restricted instructions during the second scheduling
29477pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
29478or @samp{2} to assign no, highest, or second-highest (respectively)
29479priority to dispatch-slot restricted
29480instructions.
29481
29482@item -msched-costly-dep=@var{dependence_type}
29483@opindex msched-costly-dep
29484This option controls which dependences are considered costly
29485by the target during instruction scheduling. The argument
29486@var{dependence_type} takes one of the following values:
29487
29488@table @asis
29489@item @samp{no}
29490No dependence is costly.
29491
29492@item @samp{all}
29493All dependences are costly.
29494
29495@item @samp{true_store_to_load}
29496A true dependence from store to load is costly.
29497
29498@item @samp{store_to_load}
29499Any dependence from store to load is costly.
29500
29501@item @var{number}
29502Any dependence for which the latency is greater than or equal to
29503@var{number} is costly.
29504@end table
29505
29506@item -minsert-sched-nops=@var{scheme}
29507@opindex minsert-sched-nops
29508This option controls which NOP insertion scheme is used during
29509the second scheduling pass. The argument @var{scheme} takes one of the
29510following values:
29511
29512@table @asis
29513@item @samp{no}
29514Don't insert NOPs.
29515
29516@item @samp{pad}
29517Pad with NOPs any dispatch group that has vacant issue slots,
29518according to the scheduler's grouping.
29519
29520@item @samp{regroup_exact}
29521Insert NOPs to force costly dependent insns into
29522separate groups. Insert exactly as many NOPs as needed to force an insn
29523to a new group, according to the estimated processor grouping.
29524
29525@item @var{number}
29526Insert NOPs to force costly dependent insns into
29527separate groups. Insert @var{number} NOPs to force an insn to a new group.
29528@end table
29529
29530@item -mcall-sysv
29531@opindex mcall-sysv
29532On System V.4 and embedded PowerPC systems compile code using calling
29533conventions that adhere to the March 1995 draft of the System V
29534Application Binary Interface, PowerPC processor supplement. This is the
29535default unless you configured GCC using @samp{powerpc-*-eabiaix}.
29536
29537@item -mcall-sysv-eabi
29538@itemx -mcall-eabi
29539@opindex mcall-sysv-eabi
29540@opindex mcall-eabi
29541Specify both @option{-mcall-sysv} and @option{-meabi} options.
29542
29543@item -mcall-sysv-noeabi
29544@opindex mcall-sysv-noeabi
29545Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
29546
29547@item -mcall-aixdesc
d7971cf7 29548@opindex mcall-aixdesc
d77de738
ML
29549On System V.4 and embedded PowerPC systems compile code for the AIX
29550operating system.
29551
29552@item -mcall-linux
29553@opindex mcall-linux
29554On System V.4 and embedded PowerPC systems compile code for the
29555Linux-based GNU system.
29556
29557@item -mcall-freebsd
29558@opindex mcall-freebsd
29559On System V.4 and embedded PowerPC systems compile code for the
29560FreeBSD operating system.
29561
29562@item -mcall-netbsd
29563@opindex mcall-netbsd
29564On System V.4 and embedded PowerPC systems compile code for the
29565NetBSD operating system.
29566
29567@item -mcall-openbsd
d7971cf7 29568@opindex mcall-openbsd
d77de738
ML
29569On System V.4 and embedded PowerPC systems compile code for the
29570OpenBSD operating system.
29571
29572@item -mtraceback=@var{traceback_type}
29573@opindex mtraceback
29574Select the type of traceback table. Valid values for @var{traceback_type}
29575are @samp{full}, @samp{part}, and @samp{no}.
29576
29577@item -maix-struct-return
29578@opindex maix-struct-return
29579Return all structures in memory (as specified by the AIX ABI)@.
29580
29581@item -msvr4-struct-return
29582@opindex msvr4-struct-return
29583Return structures smaller than 8 bytes in registers (as specified by the
29584SVR4 ABI)@.
29585
29586@item -mabi=@var{abi-type}
29587@opindex mabi
29588Extend the current ABI with a particular extension, or remove such extension.
29589Valid values are: @samp{altivec}, @samp{no-altivec},
29590@samp{ibmlongdouble}, @samp{ieeelongdouble},
29591@samp{elfv1}, @samp{elfv2},
29592and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
29593
29594@item -mabi=ibmlongdouble
29595@opindex mabi=ibmlongdouble
29596Change the current ABI to use IBM extended-precision long double.
29597This is not likely to work if your system defaults to using IEEE
29598extended-precision long double. If you change the long double type
29599from IEEE extended-precision, the compiler will issue a warning unless
29600you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
29601to be enabled.
29602
29603@item -mabi=ieeelongdouble
29604@opindex mabi=ieeelongdouble
29605Change the current ABI to use IEEE extended-precision long double.
29606This is not likely to work if your system defaults to using IBM
29607extended-precision long double. If you change the long double type
29608from IBM extended-precision, the compiler will issue a warning unless
29609you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
29610to be enabled.
29611
29612@item -mabi=elfv1
29613@opindex mabi=elfv1
29614Change the current ABI to use the ELFv1 ABI.
29615This is the default ABI for big-endian PowerPC 64-bit Linux.
29616Overriding the default ABI requires special system support and is
29617likely to fail in spectacular ways.
29618
29619@item -mabi=elfv2
29620@opindex mabi=elfv2
29621Change the current ABI to use the ELFv2 ABI.
29622This is the default ABI for little-endian PowerPC 64-bit Linux.
29623Overriding the default ABI requires special system support and is
29624likely to fail in spectacular ways.
29625
29626@item -mgnu-attribute
29627@itemx -mno-gnu-attribute
29628@opindex mgnu-attribute
29629@opindex mno-gnu-attribute
29630Emit .gnu_attribute assembly directives to set tag/value pairs in a
29631.gnu.attributes section that specify ABI variations in function
29632parameters or return values.
29633
29634@item -mprototype
29635@itemx -mno-prototype
29636@opindex mprototype
29637@opindex mno-prototype
29638On System V.4 and embedded PowerPC systems assume that all calls to
29639variable argument functions are properly prototyped. Otherwise, the
29640compiler must insert an instruction before every non-prototyped call to
29641set or clear bit 6 of the condition code register (@code{CR}) to
29642indicate whether floating-point values are passed in the floating-point
29643registers in case the function takes variable arguments. With
29644@option{-mprototype}, only calls to prototyped variable argument functions
29645set or clear the bit.
29646
29647@item -msim
29648@opindex msim
29649On embedded PowerPC systems, assume that the startup module is called
29650@file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
29651@file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
29652configurations.
29653
29654@item -mmvme
29655@opindex mmvme
29656On embedded PowerPC systems, assume that the startup module is called
29657@file{crt0.o} and the standard C libraries are @file{libmvme.a} and
29658@file{libc.a}.
29659
29660@item -mads
29661@opindex mads
29662On embedded PowerPC systems, assume that the startup module is called
29663@file{crt0.o} and the standard C libraries are @file{libads.a} and
29664@file{libc.a}.
29665
29666@item -myellowknife
29667@opindex myellowknife
29668On embedded PowerPC systems, assume that the startup module is called
29669@file{crt0.o} and the standard C libraries are @file{libyk.a} and
29670@file{libc.a}.
29671
29672@item -mvxworks
29673@opindex mvxworks
29674On System V.4 and embedded PowerPC systems, specify that you are
29675compiling for a VxWorks system.
29676
29677@item -memb
29678@opindex memb
29679On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
29680header to indicate that @samp{eabi} extended relocations are used.
29681
29682@item -meabi
29683@itemx -mno-eabi
29684@opindex meabi
29685@opindex mno-eabi
29686On System V.4 and embedded PowerPC systems do (do not) adhere to the
29687Embedded Applications Binary Interface (EABI), which is a set of
29688modifications to the System V.4 specifications. Selecting @option{-meabi}
29689means that the stack is aligned to an 8-byte boundary, a function
29690@code{__eabi} is called from @code{main} to set up the EABI
29691environment, and the @option{-msdata} option can use both @code{r2} and
29692@code{r13} to point to two separate small data areas. Selecting
29693@option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
29694no EABI initialization function is called from @code{main}, and the
29695@option{-msdata} option only uses @code{r13} to point to a single
29696small data area. The @option{-meabi} option is on by default if you
29697configured GCC using one of the @samp{powerpc*-*-eabi*} options.
29698
29699@item -msdata=eabi
29700@opindex msdata=eabi
29701On System V.4 and embedded PowerPC systems, put small initialized
29702@code{const} global and static data in the @code{.sdata2} section, which
29703is pointed to by register @code{r2}. Put small initialized
29704non-@code{const} global and static data in the @code{.sdata} section,
29705which is pointed to by register @code{r13}. Put small uninitialized
29706global and static data in the @code{.sbss} section, which is adjacent to
29707the @code{.sdata} section. The @option{-msdata=eabi} option is
29708incompatible with the @option{-mrelocatable} option. The
29709@option{-msdata=eabi} option also sets the @option{-memb} option.
29710
29711@item -msdata=sysv
29712@opindex msdata=sysv
29713On System V.4 and embedded PowerPC systems, put small global and static
29714data in the @code{.sdata} section, which is pointed to by register
29715@code{r13}. Put small uninitialized global and static data in the
29716@code{.sbss} section, which is adjacent to the @code{.sdata} section.
29717The @option{-msdata=sysv} option is incompatible with the
29718@option{-mrelocatable} option.
29719
29720@item -msdata=default
29721@itemx -msdata
29722@opindex msdata=default
29723@opindex msdata
29724On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
29725compile code the same as @option{-msdata=eabi}, otherwise compile code the
29726same as @option{-msdata=sysv}.
29727
29728@item -msdata=data
29729@opindex msdata=data
29730On System V.4 and embedded PowerPC systems, put small global
29731data in the @code{.sdata} section. Put small uninitialized global
29732data in the @code{.sbss} section. Do not use register @code{r13}
29733to address small data however. This is the default behavior unless
29734other @option{-msdata} options are used.
29735
29736@item -msdata=none
29737@itemx -mno-sdata
29738@opindex msdata=none
29739@opindex mno-sdata
29740On embedded PowerPC systems, put all initialized global and static data
29741in the @code{.data} section, and all uninitialized data in the
29742@code{.bss} section.
29743
29744@item -mreadonly-in-sdata
29745@opindex mreadonly-in-sdata
29746@opindex mno-readonly-in-sdata
29747Put read-only objects in the @code{.sdata} section as well. This is the
29748default.
29749
29750@item -mblock-move-inline-limit=@var{num}
29751@opindex mblock-move-inline-limit
29752Inline all block moves (such as calls to @code{memcpy} or structure
29753copies) less than or equal to @var{num} bytes. The minimum value for
29754@var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
29755targets. The default value is target-specific.
29756
29757@item -mblock-compare-inline-limit=@var{num}
29758@opindex mblock-compare-inline-limit
29759Generate non-looping inline code for all block compares (such as calls
29760to @code{memcmp} or structure compares) less than or equal to @var{num}
29761bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
29762block compare is disabled. The default value is target-specific.
29763
29764@item -mblock-compare-inline-loop-limit=@var{num}
29765@opindex mblock-compare-inline-loop-limit
29766Generate an inline expansion using loop code for all block compares that
29767are less than or equal to @var{num} bytes, but greater than the limit
29768for non-loop inline block compare expansion. If the block length is not
29769constant, at most @var{num} bytes will be compared before @code{memcmp}
29770is called to compare the remainder of the block. The default value is
29771target-specific.
29772
29773@item -mstring-compare-inline-limit=@var{num}
29774@opindex mstring-compare-inline-limit
29775Compare at most @var{num} string bytes with inline code.
29776If the difference or end of string is not found at the
29777end of the inline compare a call to @code{strcmp} or @code{strncmp} will
29778take care of the rest of the comparison. The default is 64 bytes.
29779
29780@item -G @var{num}
29781@opindex G
29782@cindex smaller data references (PowerPC)
29783@cindex .sdata/.sdata2 references (PowerPC)
29784On embedded PowerPC systems, put global and static items less than or
29785equal to @var{num} bytes into the small data or BSS sections instead of
29786the normal data or BSS section. By default, @var{num} is 8. The
29787@option{-G @var{num}} switch is also passed to the linker.
29788All modules should be compiled with the same @option{-G @var{num}} value.
29789
29790@item -mregnames
29791@itemx -mno-regnames
29792@opindex mregnames
29793@opindex mno-regnames
29794On System V.4 and embedded PowerPC systems do (do not) emit register
29795names in the assembly language output using symbolic forms.
29796
29797@item -mlongcall
29798@itemx -mno-longcall
29799@opindex mlongcall
29800@opindex mno-longcall
29801By default assume that all calls are far away so that a longer and more
29802expensive calling sequence is required. This is required for calls
29803farther than 32 megabytes (33,554,432 bytes) from the current location.
29804A short call is generated if the compiler knows
29805the call cannot be that far away. This setting can be overridden by
29806the @code{shortcall} function attribute, or by @code{#pragma
29807longcall(0)}.
29808
29809Some linkers are capable of detecting out-of-range calls and generating
29810glue code on the fly. On these systems, long calls are unnecessary and
29811generate slower code. As of this writing, the AIX linker can do this,
29812as can the GNU linker for PowerPC/64. It is planned to add this feature
29813to the GNU linker for 32-bit PowerPC systems as well.
29814
29815On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
29816GCC can generate long calls using an inline PLT call sequence (see
29817@option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
29818ELFv1 (big-endian) do not support inline PLT calls.
29819
29820On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
29821callee, L42}, plus a @dfn{branch island} (glue code). The two target
29822addresses represent the callee and the branch island. The
29823Darwin/PPC linker prefers the first address and generates a @code{bl
29824callee} if the PPC @code{bl} instruction reaches the callee directly;
29825otherwise, the linker generates @code{bl L42} to call the branch
29826island. The branch island is appended to the body of the
29827calling function; it computes the full 32-bit address of the callee
29828and jumps to it.
29829
29830On Mach-O (Darwin) systems, this option directs the compiler emit to
29831the glue for every direct call, and the Darwin linker decides whether
29832to use or discard it.
29833
29834In the future, GCC may ignore all longcall specifications
29835when the linker is known to generate glue.
29836
29837@item -mpltseq
29838@itemx -mno-pltseq
29839@opindex mpltseq
29840@opindex mno-pltseq
29841Implement (do not implement) -fno-plt and long calls using an inline
29842PLT call sequence that supports lazy linking and long calls to
29843functions in dlopen'd shared libraries. Inline PLT calls are only
29844supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
29845linkers, and are enabled by default if the support is detected when
29846configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
29847configured with @option{--enable-secureplt}. @option{-mpltseq} code
29848and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
29849linked together.
29850
29851@item -mtls-markers
29852@itemx -mno-tls-markers
29853@opindex mtls-markers
29854@opindex mno-tls-markers
29855Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
29856specifying the function argument. The relocation allows the linker to
29857reliably associate function call with argument setup instructions for
29858TLS optimization, which in turn allows GCC to better schedule the
29859sequence.
29860
29861@item -mrecip
29862@itemx -mno-recip
29863@opindex mrecip
29864This option enables use of the reciprocal estimate and
29865reciprocal square root estimate instructions with additional
29866Newton-Raphson steps to increase precision instead of doing a divide or
29867square root and divide for floating-point arguments. You should use
29868the @option{-ffast-math} option when using @option{-mrecip} (or at
29869least @option{-funsafe-math-optimizations},
29870@option{-ffinite-math-only}, @option{-freciprocal-math} and
29871@option{-fno-trapping-math}). Note that while the throughput of the
29872sequence is generally higher than the throughput of the non-reciprocal
29873instruction, the precision of the sequence can be decreased by up to 2
29874ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
29875roots.
29876
29877@item -mrecip=@var{opt}
29878@opindex mrecip=opt
29879This option controls which reciprocal estimate instructions
29880may be used. @var{opt} is a comma-separated list of options, which may
29881be preceded by a @code{!} to invert the option:
29882
29883@table @samp
29884
29885@item all
29886Enable all estimate instructions.
29887
29888@item default
29889Enable the default instructions, equivalent to @option{-mrecip}.
29890
29891@item none
29892Disable all estimate instructions, equivalent to @option{-mno-recip}.
29893
29894@item div
29895Enable the reciprocal approximation instructions for both
29896single and double precision.
29897
29898@item divf
29899Enable the single-precision reciprocal approximation instructions.
29900
29901@item divd
29902Enable the double-precision reciprocal approximation instructions.
29903
29904@item rsqrt
29905Enable the reciprocal square root approximation instructions for both
29906single and double precision.
29907
29908@item rsqrtf
29909Enable the single-precision reciprocal square root approximation instructions.
29910
29911@item rsqrtd
29912Enable the double-precision reciprocal square root approximation instructions.
29913
29914@end table
29915
29916So, for example, @option{-mrecip=all,!rsqrtd} enables
29917all of the reciprocal estimate instructions, except for the
29918@code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
29919which handle the double-precision reciprocal square root calculations.
29920
29921@item -mrecip-precision
29922@itemx -mno-recip-precision
29923@opindex mrecip-precision
29924Assume (do not assume) that the reciprocal estimate instructions
29925provide higher-precision estimates than is mandated by the PowerPC
29926ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
29927@option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
29928The double-precision square root estimate instructions are not generated by
29929default on low-precision machines, since they do not provide an
29930estimate that converges after three steps.
29931
29932@item -mveclibabi=@var{type}
29933@opindex mveclibabi
29934Specifies the ABI type to use for vectorizing intrinsics using an
29935external library. The only type supported at present is @samp{mass},
29936which specifies to use IBM's Mathematical Acceleration Subsystem
29937(MASS) libraries for vectorizing intrinsics using external libraries.
29938GCC currently emits calls to @code{acosd2}, @code{acosf4},
29939@code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
29940@code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
29941@code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
29942@code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
29943@code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
29944@code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
29945@code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
29946@code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
29947@code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
29948@code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
29949@code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
29950@code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
29951@code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
29952for power7. Both @option{-ftree-vectorize} and
29953@option{-funsafe-math-optimizations} must also be enabled. The MASS
29954libraries must be specified at link time.
29955
29956@item -mfriz
29957@itemx -mno-friz
29958@opindex mfriz
29959Generate (do not generate) the @code{friz} instruction when the
29960@option{-funsafe-math-optimizations} option is used to optimize
29961rounding of floating-point values to 64-bit integer and back to floating
29962point. The @code{friz} instruction does not return the same value if
29963the floating-point number is too large to fit in an integer.
29964
29965@item -mpointers-to-nested-functions
29966@itemx -mno-pointers-to-nested-functions
29967@opindex mpointers-to-nested-functions
29968Generate (do not generate) code to load up the static chain register
29969(@code{r11}) when calling through a pointer on AIX and 64-bit Linux
29970systems where a function pointer points to a 3-word descriptor giving
29971the function address, TOC value to be loaded in register @code{r2}, and
29972static chain value to be loaded in register @code{r11}. The
29973@option{-mpointers-to-nested-functions} is on by default. You cannot
29974call through pointers to nested functions or pointers
29975to functions compiled in other languages that use the static chain if
29976you use @option{-mno-pointers-to-nested-functions}.
29977
29978@item -msave-toc-indirect
29979@itemx -mno-save-toc-indirect
29980@opindex msave-toc-indirect
29981Generate (do not generate) code to save the TOC value in the reserved
29982stack location in the function prologue if the function calls through
29983a pointer on AIX and 64-bit Linux systems. If the TOC value is not
29984saved in the prologue, it is saved just before the call through the
29985pointer. The @option{-mno-save-toc-indirect} option is the default.
29986
29987@item -mcompat-align-parm
29988@itemx -mno-compat-align-parm
29989@opindex mcompat-align-parm
29990Generate (do not generate) code to pass structure parameters with a
29991maximum alignment of 64 bits, for compatibility with older versions
29992of GCC.
29993
29994Older versions of GCC (prior to 4.9.0) incorrectly did not align a
29995structure parameter on a 128-bit boundary when that structure contained
29996a member requiring 128-bit alignment. This is corrected in more
29997recent versions of GCC. This option may be used to generate code
29998that is compatible with functions compiled with older versions of
29999GCC.
30000
30001The @option{-mno-compat-align-parm} option is the default.
30002
30003@item -mstack-protector-guard=@var{guard}
30004@itemx -mstack-protector-guard-reg=@var{reg}
30005@itemx -mstack-protector-guard-offset=@var{offset}
30006@itemx -mstack-protector-guard-symbol=@var{symbol}
30007@opindex mstack-protector-guard
30008@opindex mstack-protector-guard-reg
30009@opindex mstack-protector-guard-offset
30010@opindex mstack-protector-guard-symbol
30011Generate stack protection code using canary at @var{guard}. Supported
30012locations are @samp{global} for global canary or @samp{tls} for per-thread
30013canary in the TLS block (the default with GNU libc version 2.4 or later).
30014
30015With the latter choice the options
30016@option{-mstack-protector-guard-reg=@var{reg}} and
30017@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
30018which register to use as base register for reading the canary, and from what
30019offset from that base register. The default for those is as specified in the
30020relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides
30021the offset with a symbol reference to a canary in the TLS block.
30022
30023@item -mpcrel
30024@itemx -mno-pcrel
30025@opindex mpcrel
30026@opindex mno-pcrel
30027Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
30028option requires that the medium code model (@option{-mcmodel=medium})
30029and prefixed addressing (@option{-mprefixed}) options are enabled.
30030
30031@item -mprefixed
30032@itemx -mno-prefixed
30033@opindex mprefixed
30034@opindex mno-prefixed
30035Generate (do not generate) addressing modes using prefixed load and
30036store instructions. The @option{-mprefixed} option requires that
30037the option @option{-mcpu=power10} (or later) is enabled.
30038
30039@item -mmma
30040@itemx -mno-mma
30041@opindex mmma
30042@opindex mno-mma
30043Generate (do not generate) the MMA instructions. The @option{-mma}
30044option requires that the option @option{-mcpu=power10} (or later)
30045is enabled.
30046
30047@item -mrop-protect
30048@itemx -mno-rop-protect
30049@opindex mrop-protect
30050@opindex mno-rop-protect
30051Generate (do not generate) ROP protection instructions when the target
30052processor supports them. Currently this option disables the shrink-wrap
30053optimization (@option{-fshrink-wrap}).
30054
30055@item -mprivileged
30056@itemx -mno-privileged
30057@opindex mprivileged
30058@opindex mno-privileged
30059Generate (do not generate) code that will run in privileged state.
30060
30061@item -mblock-ops-unaligned-vsx
30062@itemx -mno-block-ops-unaligned-vsx
30063@opindex block-ops-unaligned-vsx
30064@opindex no-block-ops-unaligned-vsx
30065Generate (do not generate) unaligned vsx loads and stores for
30066inline expansion of @code{memcpy} and @code{memmove}.
30067
30068@item --param rs6000-vect-unroll-limit=
30069The vectorizer will check with target information to determine whether it
30070would be beneficial to unroll the main vectorized loop and by how much. This
30071parameter sets the upper bound of how much the vectorizer will unroll the main
30072loop. The default value is four.
30073
30074@end table
30075
30076@node RX Options
30077@subsection RX Options
30078@cindex RX Options
30079
30080These command-line options are defined for RX targets:
30081
30082@table @gcctabopt
30083@item -m64bit-doubles
30084@itemx -m32bit-doubles
30085@opindex m64bit-doubles
30086@opindex m32bit-doubles
30087Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
30088or 32 bits (@option{-m32bit-doubles}) in size. The default is
30089@option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
30090works on 32-bit values, which is why the default is
30091@option{-m32bit-doubles}.
30092
30093@item -fpu
30094@itemx -nofpu
30095@opindex fpu
30096@opindex nofpu
30097Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
30098floating-point hardware. The default is enabled for the RX600
30099series and disabled for the RX200 series.
30100
30101Floating-point instructions are only generated for 32-bit floating-point
30102values, however, so the FPU hardware is not used for doubles if the
30103@option{-m64bit-doubles} option is used.
30104
30105@emph{Note} If the @option{-fpu} option is enabled then
30106@option{-funsafe-math-optimizations} is also enabled automatically.
30107This is because the RX FPU instructions are themselves unsafe.
30108
30109@item -mcpu=@var{name}
30110@opindex mcpu
30111Selects the type of RX CPU to be targeted. Currently three types are
30112supported, the generic @samp{RX600} and @samp{RX200} series hardware and
30113the specific @samp{RX610} CPU. The default is @samp{RX600}.
30114
30115The only difference between @samp{RX600} and @samp{RX610} is that the
30116@samp{RX610} does not support the @code{MVTIPL} instruction.
30117
30118The @samp{RX200} series does not have a hardware floating-point unit
30119and so @option{-nofpu} is enabled by default when this type is
30120selected.
30121
30122@item -mbig-endian-data
30123@itemx -mlittle-endian-data
30124@opindex mbig-endian-data
30125@opindex mlittle-endian-data
30126Store data (but not code) in the big-endian format. The default is
30127@option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
30128format.
30129
30130@item -msmall-data-limit=@var{N}
30131@opindex msmall-data-limit
30132Specifies the maximum size in bytes of global and static variables
30133which can be placed into the small data area. Using the small data
30134area can lead to smaller and faster code, but the size of area is
30135limited and it is up to the programmer to ensure that the area does
30136not overflow. Also when the small data area is used one of the RX's
30137registers (usually @code{r13}) is reserved for use pointing to this
30138area, so it is no longer available for use by the compiler. This
30139could result in slower and/or larger code if variables are pushed onto
30140the stack instead of being held in this register.
30141
30142Note, common variables (variables that have not been initialized) and
30143constants are not placed into the small data area as they are assigned
30144to other sections in the output executable.
30145
30146The default value is zero, which disables this feature. Note, this
30147feature is not enabled by default with higher optimization levels
30148(@option{-O2} etc) because of the potentially detrimental effects of
30149reserving a register. It is up to the programmer to experiment and
30150discover whether this feature is of benefit to their program. See the
30151description of the @option{-mpid} option for a description of how the
30152actual register to hold the small data area pointer is chosen.
30153
30154@item -msim
30155@itemx -mno-sim
30156@opindex msim
30157@opindex mno-sim
30158Use the simulator runtime. The default is to use the libgloss
30159board-specific runtime.
30160
30161@item -mas100-syntax
30162@itemx -mno-as100-syntax
30163@opindex mas100-syntax
30164@opindex mno-as100-syntax
30165When generating assembler output use a syntax that is compatible with
30166Renesas's AS100 assembler. This syntax can also be handled by the GAS
30167assembler, but it has some restrictions so it is not generated by default.
30168
30169@item -mmax-constant-size=@var{N}
30170@opindex mmax-constant-size
30171Specifies the maximum size, in bytes, of a constant that can be used as
30172an operand in a RX instruction. Although the RX instruction set does
30173allow constants of up to 4 bytes in length to be used in instructions,
30174a longer value equates to a longer instruction. Thus in some
30175circumstances it can be beneficial to restrict the size of constants
30176that are used in instructions. Constants that are too big are instead
30177placed into a constant pool and referenced via register indirection.
30178
30179The value @var{N} can be between 0 and 4. A value of 0 (the default)
30180or 4 means that constants of any size are allowed.
30181
30182@item -mrelax
30183@opindex mrelax
30184Enable linker relaxation. Linker relaxation is a process whereby the
30185linker attempts to reduce the size of a program by finding shorter
30186versions of various instructions. Disabled by default.
30187
30188@item -mint-register=@var{N}
30189@opindex mint-register
30190Specify the number of registers to reserve for fast interrupt handler
30191functions. The value @var{N} can be between 0 and 4. A value of 1
30192means that register @code{r13} is reserved for the exclusive use
30193of fast interrupt handlers. A value of 2 reserves @code{r13} and
30194@code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
30195@code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
30196A value of 0, the default, does not reserve any registers.
30197
30198@item -msave-acc-in-interrupts
30199@opindex msave-acc-in-interrupts
30200Specifies that interrupt handler functions should preserve the
30201accumulator register. This is only necessary if normal code might use
30202the accumulator register, for example because it performs 64-bit
30203multiplications. The default is to ignore the accumulator as this
30204makes the interrupt handlers faster.
30205
30206@item -mpid
30207@itemx -mno-pid
30208@opindex mpid
30209@opindex mno-pid
30210Enables the generation of position independent data. When enabled any
30211access to constant data is done via an offset from a base address
30212held in a register. This allows the location of constant data to be
30213determined at run time without requiring the executable to be
30214relocated, which is a benefit to embedded applications with tight
30215memory constraints. Data that can be modified is not affected by this
30216option.
30217
30218Note, using this feature reserves a register, usually @code{r13}, for
30219the constant data base address. This can result in slower and/or
30220larger code, especially in complicated functions.
30221
30222The actual register chosen to hold the constant data base address
30223depends upon whether the @option{-msmall-data-limit} and/or the
30224@option{-mint-register} command-line options are enabled. Starting
30225with register @code{r13} and proceeding downwards, registers are
30226allocated first to satisfy the requirements of @option{-mint-register},
30227then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
30228is possible for the small data area register to be @code{r8} if both
30229@option{-mint-register=4} and @option{-mpid} are specified on the
30230command line.
30231
30232By default this feature is not enabled. The default can be restored
30233via the @option{-mno-pid} command-line option.
30234
30235@item -mno-warn-multiple-fast-interrupts
30236@itemx -mwarn-multiple-fast-interrupts
30237@opindex mno-warn-multiple-fast-interrupts
30238@opindex mwarn-multiple-fast-interrupts
30239Prevents GCC from issuing a warning message if it finds more than one
30240fast interrupt handler when it is compiling a file. The default is to
30241issue a warning for each extra fast interrupt handler found, as the RX
30242only supports one such interrupt.
30243
30244@item -mallow-string-insns
30245@itemx -mno-allow-string-insns
30246@opindex mallow-string-insns
30247@opindex mno-allow-string-insns
30248Enables or disables the use of the string manipulation instructions
30249@code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
30250@code{SWHILE} and also the @code{RMPA} instruction. These
30251instructions may prefetch data, which is not safe to do if accessing
30252an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
30253for more information).
30254
30255The default is to allow these instructions, but it is not possible for
30256GCC to reliably detect all circumstances where a string instruction
30257might be used to access an I/O register, so their use cannot be
30258disabled automatically. Instead it is reliant upon the programmer to
30259use the @option{-mno-allow-string-insns} option if their program
30260accesses I/O space.
30261
30262When the instructions are enabled GCC defines the C preprocessor
30263symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
30264symbol @code{__RX_DISALLOW_STRING_INSNS__}.
30265
30266@item -mjsr
30267@itemx -mno-jsr
30268@opindex mjsr
30269@opindex mno-jsr
30270Use only (or not only) @code{JSR} instructions to access functions.
30271This option can be used when code size exceeds the range of @code{BSR}
30272instructions. Note that @option{-mno-jsr} does not mean to not use
30273@code{JSR} but instead means that any type of branch may be used.
30274@end table
30275
30276@emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
30277has special significance to the RX port when used with the
30278@code{interrupt} function attribute. This attribute indicates a
30279function intended to process fast interrupts. GCC ensures
30280that it only uses the registers @code{r10}, @code{r11}, @code{r12}
30281and/or @code{r13} and only provided that the normal use of the
30282corresponding registers have been restricted via the
30283@option{-ffixed-@var{reg}} or @option{-mint-register} command-line
30284options.
30285
30286@node S/390 and zSeries Options
30287@subsection S/390 and zSeries Options
30288@cindex S/390 and zSeries Options
30289
30290These are the @samp{-m} options defined for the S/390 and zSeries architecture.
30291
30292@table @gcctabopt
30293@item -mhard-float
30294@itemx -msoft-float
30295@opindex mhard-float
30296@opindex msoft-float
30297Use (do not use) the hardware floating-point instructions and registers
30298for floating-point operations. When @option{-msoft-float} is specified,
30299functions in @file{libgcc.a} are used to perform floating-point
30300operations. When @option{-mhard-float} is specified, the compiler
30301generates IEEE floating-point instructions. This is the default.
30302
30303@item -mhard-dfp
30304@itemx -mno-hard-dfp
30305@opindex mhard-dfp
30306@opindex mno-hard-dfp
30307Use (do not use) the hardware decimal-floating-point instructions for
30308decimal-floating-point operations. When @option{-mno-hard-dfp} is
30309specified, functions in @file{libgcc.a} are used to perform
30310decimal-floating-point operations. When @option{-mhard-dfp} is
30311specified, the compiler generates decimal-floating-point hardware
30312instructions. This is the default for @option{-march=z9-ec} or higher.
30313
30314@item -mlong-double-64
30315@itemx -mlong-double-128
30316@opindex mlong-double-64
30317@opindex mlong-double-128
30318These switches control the size of @code{long double} type. A size
30319of 64 bits makes the @code{long double} type equivalent to the @code{double}
30320type. This is the default.
30321
30322@item -mbackchain
30323@itemx -mno-backchain
30324@opindex mbackchain
30325@opindex mno-backchain
30326Store (do not store) the address of the caller's frame as backchain pointer
30327into the callee's stack frame.
30328A backchain may be needed to allow debugging using tools that do not understand
30329DWARF call frame information.
30330When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
30331at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
30332the backchain is placed into the topmost word of the 96/160 byte register
30333save area.
30334
30335In general, code compiled with @option{-mbackchain} is call-compatible with
30336code compiled with @option{-mno-backchain}; however, use of the backchain
30337for debugging purposes usually requires that the whole binary is built with
30338@option{-mbackchain}. Note that the combination of @option{-mbackchain},
30339@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30340to build a linux kernel use @option{-msoft-float}.
30341
30342The default is to not maintain the backchain.
30343
30344@item -mpacked-stack
30345@itemx -mno-packed-stack
30346@opindex mpacked-stack
30347@opindex mno-packed-stack
30348Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
30349specified, the compiler uses the all fields of the 96/160 byte register save
30350area only for their default purpose; unused fields still take up stack space.
30351When @option{-mpacked-stack} is specified, register save slots are densely
30352packed at the top of the register save area; unused space is reused for other
30353purposes, allowing for more efficient use of the available stack space.
30354However, when @option{-mbackchain} is also in effect, the topmost word of
30355the save area is always used to store the backchain, and the return address
30356register is always saved two words below the backchain.
30357
30358As long as the stack frame backchain is not used, code generated with
30359@option{-mpacked-stack} is call-compatible with code generated with
30360@option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
30361S/390 or zSeries generated code that uses the stack frame backchain at run
30362time, not just for debugging purposes. Such code is not call-compatible
30363with code compiled with @option{-mpacked-stack}. Also, note that the
30364combination of @option{-mbackchain},
30365@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30366to build a linux kernel use @option{-msoft-float}.
30367
30368The default is to not use the packed stack layout.
30369
30370@item -msmall-exec
30371@itemx -mno-small-exec
30372@opindex msmall-exec
30373@opindex mno-small-exec
30374Generate (or do not generate) code using the @code{bras} instruction
30375to do subroutine calls.
30376This only works reliably if the total executable size does not
30377exceed 64k. The default is to use the @code{basr} instruction instead,
30378which does not have this limitation.
30379
30380@item -m64
30381@itemx -m31
30382@opindex m64
30383@opindex m31
30384When @option{-m31} is specified, generate code compliant to the
30385GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
30386code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
30387particular to generate 64-bit instructions. For the @samp{s390}
30388targets, the default is @option{-m31}, while the @samp{s390x}
30389targets default to @option{-m64}.
30390
30391@item -mzarch
30392@itemx -mesa
30393@opindex mzarch
30394@opindex mesa
30395When @option{-mzarch} is specified, generate code using the
30396instructions available on z/Architecture.
30397When @option{-mesa} is specified, generate code using the
30398instructions available on ESA/390. Note that @option{-mesa} is
30399not possible with @option{-m64}.
30400When generating code compliant to the GNU/Linux for S/390 ABI,
30401the default is @option{-mesa}. When generating code compliant
30402to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
30403
30404@item -mhtm
30405@itemx -mno-htm
30406@opindex mhtm
30407@opindex mno-htm
30408The @option{-mhtm} option enables a set of builtins making use of
30409instructions available with the transactional execution facility
30410introduced with the IBM zEnterprise EC12 machine generation
30411@ref{S/390 System z Built-in Functions}.
30412@option{-mhtm} is enabled by default when using @option{-march=zEC12}.
30413
30414@item -mvx
30415@itemx -mno-vx
30416@opindex mvx
30417@opindex mno-vx
30418When @option{-mvx} is specified, generate code using the instructions
30419available with the vector extension facility introduced with the IBM
30420z13 machine generation.
30421This option changes the ABI for some vector type values with regard to
30422alignment and calling conventions. In case vector type values are
30423being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
30424command will be added to mark the resulting binary with the ABI used.
30425@option{-mvx} is enabled by default when using @option{-march=z13}.
30426
30427@item -mzvector
30428@itemx -mno-zvector
30429@opindex mzvector
30430@opindex mno-zvector
30431The @option{-mzvector} option enables vector language extensions and
30432builtins using instructions available with the vector extension
30433facility introduced with the IBM z13 machine generation.
30434This option adds support for @samp{vector} to be used as a keyword to
30435define vector type variables and arguments. @samp{vector} is only
30436available when GNU extensions are enabled. It will not be expanded
30437when requesting strict standard compliance e.g.@: with @option{-std=c99}.
30438In addition to the GCC low-level builtins @option{-mzvector} enables
30439a set of builtins added for compatibility with AltiVec-style
30440implementations like Power and Cell. In order to make use of these
30441builtins the header file @file{vecintrin.h} needs to be included.
30442@option{-mzvector} is disabled by default.
30443
30444@item -mmvcle
30445@itemx -mno-mvcle
30446@opindex mmvcle
30447@opindex mno-mvcle
30448Generate (or do not generate) code using the @code{mvcle} instruction
30449to perform block moves. When @option{-mno-mvcle} is specified,
30450use a @code{mvc} loop instead. This is the default unless optimizing for
30451size.
30452
30453@item -mdebug
30454@itemx -mno-debug
30455@opindex mdebug
30456@opindex mno-debug
30457Print (or do not print) additional debug information when compiling.
30458The default is to not print debug information.
30459
30460@item -march=@var{cpu-type}
30461@opindex march
30462Generate code that runs on @var{cpu-type}, which is the name of a
30463system representing a certain processor type. Possible values for
30464@var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
30465@samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
30466@samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
30467@samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13},
30468@samp{z16}/@samp{arch14}, and @samp{native}.
30469
30470The default is @option{-march=z900}.
30471
30472Specifying @samp{native} as cpu type can be used to select the best
30473architecture option for the host processor.
30474@option{-march=native} has no effect if GCC does not recognize the
30475processor.
30476
30477@item -mtune=@var{cpu-type}
30478@opindex mtune
30479Tune to @var{cpu-type} everything applicable about the generated code,
30480except for the ABI and the set of available instructions.
30481The list of @var{cpu-type} values is the same as for @option{-march}.
30482The default is the value used for @option{-march}.
30483
30484@item -mtpf-trace
30485@itemx -mno-tpf-trace
30486@opindex mtpf-trace
30487@opindex mno-tpf-trace
30488Generate code that adds (does not add) in TPF OS specific branches to trace
30489routines in the operating system. This option is off by default, even
30490when compiling for the TPF OS@.
30491
30492@item -mtpf-trace-skip
30493@itemx -mno-tpf-trace-skip
30494@opindex mtpf-trace-skip
30495@opindex mno-tpf-trace-skip
30496Generate code that changes (does not change) the default branch
30497targets enabled by @option{-mtpf-trace} to point to specialized trace
30498routines providing the ability of selectively skipping function trace
30499entries for the TPF OS. This option is off by default, even when
30500compiling for the TPF OS and specifying @option{-mtpf-trace}.
30501
30502@item -mfused-madd
30503@itemx -mno-fused-madd
30504@opindex mfused-madd
30505@opindex mno-fused-madd
30506Generate code that uses (does not use) the floating-point multiply and
30507accumulate instructions. These instructions are generated by default if
30508hardware floating point is used.
30509
30510@item -mwarn-framesize=@var{framesize}
30511@opindex mwarn-framesize
30512Emit a warning if the current function exceeds the given frame size. Because
30513this is a compile-time check it doesn't need to be a real problem when the program
30514runs. It is intended to identify functions that most probably cause
30515a stack overflow. It is useful to be used in an environment with limited stack
30516size e.g.@: the linux kernel.
30517
30518@item -mwarn-dynamicstack
30519@opindex mwarn-dynamicstack
30520Emit a warning if the function calls @code{alloca} or uses dynamically-sized
30521arrays. This is generally a bad idea with a limited stack size.
30522
30523@item -mstack-guard=@var{stack-guard}
30524@itemx -mstack-size=@var{stack-size}
30525@opindex mstack-guard
30526@opindex mstack-size
30527If these options are provided the S/390 back end emits additional instructions in
30528the function prologue that trigger a trap if the stack size is @var{stack-guard}
30529bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
30530If the @var{stack-guard} option is omitted the smallest power of 2 larger than
30531the frame size of the compiled function is chosen.
30532These options are intended to be used to help debugging stack overflow problems.
30533The additionally emitted code causes only little overhead and hence can also be
30534used in production-like systems without greater performance degradation. The given
30535values have to be exact powers of 2 and @var{stack-size} has to be greater than
30536@var{stack-guard} without exceeding 64k.
30537In order to be efficient the extra code makes the assumption that the stack starts
30538at an address aligned to the value given by @var{stack-size}.
30539The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
30540
30541@item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
30542@opindex mhotpatch
30543If the hotpatch option is enabled, a ``hot-patching'' function
30544prologue is generated for all functions in the compilation unit.
30545The funtion label is prepended with the given number of two-byte
30546NOP instructions (@var{pre-halfwords}, maximum 1000000). After
30547the label, 2 * @var{post-halfwords} bytes are appended, using the
30548largest NOP like instructions the architecture allows (maximum
305491000000).
30550
30551If both arguments are zero, hotpatching is disabled.
30552
30553This option can be overridden for individual functions with the
30554@code{hotpatch} attribute.
30555@end table
30556
d77de738
ML
30557@node SH Options
30558@subsection SH Options
30559
30560These @samp{-m} options are defined for the SH implementations:
30561
30562@table @gcctabopt
30563@item -m1
30564@opindex m1
30565Generate code for the SH1.
30566
30567@item -m2
30568@opindex m2
30569Generate code for the SH2.
30570
30571@item -m2e
30572Generate code for the SH2e.
30573
30574@item -m2a-nofpu
30575@opindex m2a-nofpu
30576Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
30577that the floating-point unit is not used.
30578
30579@item -m2a-single-only
30580@opindex m2a-single-only
30581Generate code for the SH2a-FPU, in such a way that no double-precision
30582floating-point operations are used.
30583
30584@item -m2a-single
30585@opindex m2a-single
30586Generate code for the SH2a-FPU assuming the floating-point unit is in
30587single-precision mode by default.
30588
30589@item -m2a
30590@opindex m2a
30591Generate code for the SH2a-FPU assuming the floating-point unit is in
30592double-precision mode by default.
30593
30594@item -m3
30595@opindex m3
30596Generate code for the SH3.
30597
30598@item -m3e
30599@opindex m3e
30600Generate code for the SH3e.
30601
30602@item -m4-nofpu
30603@opindex m4-nofpu
30604Generate code for the SH4 without a floating-point unit.
30605
30606@item -m4-single-only
30607@opindex m4-single-only
30608Generate code for the SH4 with a floating-point unit that only
30609supports single-precision arithmetic.
30610
30611@item -m4-single
30612@opindex m4-single
30613Generate code for the SH4 assuming the floating-point unit is in
30614single-precision mode by default.
30615
30616@item -m4
30617@opindex m4
30618Generate code for the SH4.
30619
30620@item -m4-100
30621@opindex m4-100
30622Generate code for SH4-100.
30623
30624@item -m4-100-nofpu
30625@opindex m4-100-nofpu
30626Generate code for SH4-100 in such a way that the
30627floating-point unit is not used.
30628
30629@item -m4-100-single
30630@opindex m4-100-single
30631Generate code for SH4-100 assuming the floating-point unit is in
30632single-precision mode by default.
30633
30634@item -m4-100-single-only
30635@opindex m4-100-single-only
30636Generate code for SH4-100 in such a way that no double-precision
30637floating-point operations are used.
30638
30639@item -m4-200
30640@opindex m4-200
30641Generate code for SH4-200.
30642
30643@item -m4-200-nofpu
30644@opindex m4-200-nofpu
30645Generate code for SH4-200 without in such a way that the
30646floating-point unit is not used.
30647
30648@item -m4-200-single
30649@opindex m4-200-single
30650Generate code for SH4-200 assuming the floating-point unit is in
30651single-precision mode by default.
30652
30653@item -m4-200-single-only
30654@opindex m4-200-single-only
30655Generate code for SH4-200 in such a way that no double-precision
30656floating-point operations are used.
30657
30658@item -m4-300
30659@opindex m4-300
30660Generate code for SH4-300.
30661
30662@item -m4-300-nofpu
30663@opindex m4-300-nofpu
30664Generate code for SH4-300 without in such a way that the
30665floating-point unit is not used.
30666
30667@item -m4-300-single
30668@opindex m4-300-single
30669Generate code for SH4-300 in such a way that no double-precision
30670floating-point operations are used.
30671
30672@item -m4-300-single-only
30673@opindex m4-300-single-only
30674Generate code for SH4-300 in such a way that no double-precision
30675floating-point operations are used.
30676
30677@item -m4-340
30678@opindex m4-340
30679Generate code for SH4-340 (no MMU, no FPU).
30680
30681@item -m4-500
30682@opindex m4-500
30683Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
30684assembler.
30685
30686@item -m4a-nofpu
30687@opindex m4a-nofpu
30688Generate code for the SH4al-dsp, or for a SH4a in such a way that the
30689floating-point unit is not used.
30690
30691@item -m4a-single-only
30692@opindex m4a-single-only
30693Generate code for the SH4a, in such a way that no double-precision
30694floating-point operations are used.
30695
30696@item -m4a-single
30697@opindex m4a-single
30698Generate code for the SH4a assuming the floating-point unit is in
30699single-precision mode by default.
30700
30701@item -m4a
30702@opindex m4a
30703Generate code for the SH4a.
30704
30705@item -m4al
30706@opindex m4al
30707Same as @option{-m4a-nofpu}, except that it implicitly passes
30708@option{-dsp} to the assembler. GCC doesn't generate any DSP
30709instructions at the moment.
30710
30711@item -mb
30712@opindex mb
30713Compile code for the processor in big-endian mode.
30714
30715@item -ml
30716@opindex ml
30717Compile code for the processor in little-endian mode.
30718
30719@item -mdalign
30720@opindex mdalign
30721Align doubles at 64-bit boundaries. Note that this changes the calling
30722conventions, and thus some functions from the standard C library do
30723not work unless you recompile it first with @option{-mdalign}.
30724
30725@item -mrelax
30726@opindex mrelax
30727Shorten some address references at link time, when possible; uses the
30728linker option @option{-relax}.
30729
30730@item -mbigtable
30731@opindex mbigtable
30732Use 32-bit offsets in @code{switch} tables. The default is to use
3073316-bit offsets.
30734
30735@item -mbitops
30736@opindex mbitops
30737Enable the use of bit manipulation instructions on SH2A.
30738
30739@item -mfmovd
30740@opindex mfmovd
30741Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
30742alignment constraints.
30743
30744@item -mrenesas
30745@opindex mrenesas
30746Comply with the calling conventions defined by Renesas.
30747
30748@item -mno-renesas
30749@opindex mno-renesas
30750Comply with the calling conventions defined for GCC before the Renesas
30751conventions were available. This option is the default for all
30752targets of the SH toolchain.
30753
30754@item -mnomacsave
30755@opindex mnomacsave
30756Mark the @code{MAC} register as call-clobbered, even if
30757@option{-mrenesas} is given.
30758
30759@item -mieee
30760@itemx -mno-ieee
30761@opindex mieee
30762@opindex mno-ieee
30763Control the IEEE compliance of floating-point comparisons, which affects the
30764handling of cases where the result of a comparison is unordered. By default
30765@option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
30766enabled @option{-mno-ieee} is implicitly set, which results in faster
30767floating-point greater-equal and less-equal comparisons. The implicit settings
30768can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
30769
30770@item -minline-ic_invalidate
30771@opindex minline-ic_invalidate
30772Inline code to invalidate instruction cache entries after setting up
30773nested function trampolines.
30774This option has no effect if @option{-musermode} is in effect and the selected
30775code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
30776instruction.
30777If the selected code generation option does not allow the use of the @code{icbi}
30778instruction, and @option{-musermode} is not in effect, the inlined code
30779manipulates the instruction cache address array directly with an associative
30780write. This not only requires privileged mode at run time, but it also
30781fails if the cache line had been mapped via the TLB and has become unmapped.
30782
30783@item -misize
30784@opindex misize
30785Dump instruction size and location in the assembly code.
30786
30787@item -mpadstruct
30788@opindex mpadstruct
30789This option is deprecated. It pads structures to multiple of 4 bytes,
30790which is incompatible with the SH ABI@.
30791
30792@item -matomic-model=@var{model}
30793@opindex matomic-model=@var{model}
30794Sets the model of atomic operations and additional parameters as a comma
30795separated list. For details on the atomic built-in functions see
30796@ref{__atomic Builtins}. The following models and parameters are supported:
30797
30798@table @samp
30799
30800@item none
30801Disable compiler generated atomic sequences and emit library calls for atomic
30802operations. This is the default if the target is not @code{sh*-*-linux*}.
30803
30804@item soft-gusa
30805Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
30806built-in functions. The generated atomic sequences require additional support
30807from the interrupt/exception handling code of the system and are only suitable
30808for SH3* and SH4* single-core systems. This option is enabled by default when
30809the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
30810this option also partially utilizes the hardware atomic instructions
30811@code{movli.l} and @code{movco.l} to create more efficient code, unless
30812@samp{strict} is specified.
30813
30814@item soft-tcb
30815Generate software atomic sequences that use a variable in the thread control
30816block. This is a variation of the gUSA sequences which can also be used on
30817SH1* and SH2* targets. The generated atomic sequences require additional
30818support from the interrupt/exception handling code of the system and are only
30819suitable for single-core systems. When using this model, the @samp{gbr-offset=}
30820parameter has to be specified as well.
30821
30822@item soft-imask
30823Generate software atomic sequences that temporarily disable interrupts by
30824setting @code{SR.IMASK = 1111}. This model works only when the program runs
30825in privileged mode and is only suitable for single-core systems. Additional
30826support from the interrupt/exception handling code of the system is not
30827required. This model is enabled by default when the target is
30828@code{sh*-*-linux*} and SH1* or SH2*.
30829
30830@item hard-llcs
30831Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
30832instructions only. This is only available on SH4A and is suitable for
30833multi-core systems. Since the hardware instructions support only 32 bit atomic
30834variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
30835Code compiled with this option is also compatible with other software
30836atomic model interrupt/exception handling systems if executed on an SH4A
30837system. Additional support from the interrupt/exception handling code of the
30838system is not required for this model.
30839
30840@item gbr-offset=
30841This parameter specifies the offset in bytes of the variable in the thread
30842control block structure that should be used by the generated atomic sequences
30843when the @samp{soft-tcb} model has been selected. For other models this
30844parameter is ignored. The specified value must be an integer multiple of four
30845and in the range 0-1020.
30846
30847@item strict
30848This parameter prevents mixed usage of multiple atomic models, even if they
30849are compatible, and makes the compiler generate atomic sequences of the
30850specified model only.
30851
30852@end table
30853
30854@item -mtas
30855@opindex mtas
30856Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
30857Notice that depending on the particular hardware and software configuration
30858this can degrade overall performance due to the operand cache line flushes
30859that are implied by the @code{tas.b} instruction. On multi-core SH4A
30860processors the @code{tas.b} instruction must be used with caution since it
30861can result in data corruption for certain cache configurations.
30862
30863@item -mprefergot
30864@opindex mprefergot
30865When generating position-independent code, emit function calls using
30866the Global Offset Table instead of the Procedure Linkage Table.
30867
30868@item -musermode
30869@itemx -mno-usermode
30870@opindex musermode
30871@opindex mno-usermode
30872Don't allow (allow) the compiler generating privileged mode code. Specifying
30873@option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
30874inlined code would not work in user mode. @option{-musermode} is the default
30875when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
30876@option{-musermode} has no effect, since there is no user mode.
30877
30878@item -multcost=@var{number}
30879@opindex multcost=@var{number}
30880Set the cost to assume for a multiply insn.
30881
30882@item -mdiv=@var{strategy}
30883@opindex mdiv=@var{strategy}
30884Set the division strategy to be used for integer division operations.
30885@var{strategy} can be one of:
30886
30887@table @samp
30888
30889@item call-div1
30890Calls a library function that uses the single-step division instruction
30891@code{div1} to perform the operation. Division by zero calculates an
30892unspecified result and does not trap. This is the default except for SH4,
30893SH2A and SHcompact.
30894
30895@item call-fp
30896Calls a library function that performs the operation in double precision
30897floating point. Division by zero causes a floating-point exception. This is
30898the default for SHcompact with FPU. Specifying this for targets that do not
30899have a double precision FPU defaults to @code{call-div1}.
30900
30901@item call-table
30902Calls a library function that uses a lookup table for small divisors and
30903the @code{div1} instruction with case distinction for larger divisors. Division
30904by zero calculates an unspecified result and does not trap. This is the default
30905for SH4. Specifying this for targets that do not have dynamic shift
30906instructions defaults to @code{call-div1}.
30907
30908@end table
30909
30910When a division strategy has not been specified the default strategy is
30911selected based on the current target. For SH2A the default strategy is to
30912use the @code{divs} and @code{divu} instructions instead of library function
30913calls.
30914
30915@item -maccumulate-outgoing-args
30916@opindex maccumulate-outgoing-args
30917Reserve space once for outgoing arguments in the function prologue rather
30918than around each call. Generally beneficial for performance and size. Also
30919needed for unwinding to avoid changing the stack frame around conditional code.
30920
30921@item -mdivsi3_libfunc=@var{name}
30922@opindex mdivsi3_libfunc=@var{name}
30923Set the name of the library function used for 32-bit signed division to
30924@var{name}.
30925This only affects the name used in the @samp{call} division strategies, and
30926the compiler still expects the same sets of input/output/clobbered registers as
30927if this option were not present.
30928
30929@item -mfixed-range=@var{register-range}
30930@opindex mfixed-range
30931Generate code treating the given register range as fixed registers.
30932A fixed register is one that the register allocator cannot use. This is
30933useful when compiling kernel code. A register range is specified as
30934two registers separated by a dash. Multiple register ranges can be
30935specified separated by a comma.
30936
30937@item -mbranch-cost=@var{num}
30938@opindex mbranch-cost=@var{num}
30939Assume @var{num} to be the cost for a branch instruction. Higher numbers
30940make the compiler try to generate more branch-free code if possible.
30941If not specified the value is selected depending on the processor type that
30942is being compiled for.
30943
30944@item -mzdcbranch
30945@itemx -mno-zdcbranch
30946@opindex mzdcbranch
30947@opindex mno-zdcbranch
30948Assume (do not assume) that zero displacement conditional branch instructions
30949@code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
30950compiler prefers zero displacement branch code sequences. This is
30951enabled by default when generating code for SH4 and SH4A. It can be explicitly
30952disabled by specifying @option{-mno-zdcbranch}.
30953
30954@item -mcbranch-force-delay-slot
30955@opindex mcbranch-force-delay-slot
30956Force the usage of delay slots for conditional branches, which stuffs the delay
30957slot with a @code{nop} if a suitable instruction cannot be found. By default
30958this option is disabled. It can be enabled to work around hardware bugs as
30959found in the original SH7055.
30960
30961@item -mfused-madd
30962@itemx -mno-fused-madd
30963@opindex mfused-madd
30964@opindex mno-fused-madd
30965Generate code that uses (does not use) the floating-point multiply and
30966accumulate instructions. These instructions are generated by default
30967if hardware floating point is used. The machine-dependent
30968@option{-mfused-madd} option is now mapped to the machine-independent
30969@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
30970mapped to @option{-ffp-contract=off}.
30971
30972@item -mfsca
30973@itemx -mno-fsca
30974@opindex mfsca
30975@opindex mno-fsca
30976Allow or disallow the compiler to emit the @code{fsca} instruction for sine
30977and cosine approximations. The option @option{-mfsca} must be used in
30978combination with @option{-funsafe-math-optimizations}. It is enabled by default
30979when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
30980approximations even if @option{-funsafe-math-optimizations} is in effect.
30981
30982@item -mfsrra
30983@itemx -mno-fsrra
30984@opindex mfsrra
30985@opindex mno-fsrra
30986Allow or disallow the compiler to emit the @code{fsrra} instruction for
30987reciprocal square root approximations. The option @option{-mfsrra} must be used
30988in combination with @option{-funsafe-math-optimizations} and
30989@option{-ffinite-math-only}. It is enabled by default when generating code for
30990SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
30991even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
30992in effect.
30993
30994@item -mpretend-cmove
30995@opindex mpretend-cmove
30996Prefer zero-displacement conditional branches for conditional move instruction
30997patterns. This can result in faster code on the SH4 processor.
30998
30999@item -mfdpic
31000@opindex fdpic
31001Generate code using the FDPIC ABI.
31002
31003@end table
31004
31005@node Solaris 2 Options
31006@subsection Solaris 2 Options
31007@cindex Solaris 2 options
31008
31009These @samp{-m} options are supported on Solaris 2:
31010
31011@table @gcctabopt
31012@item -mclear-hwcap
31013@opindex mclear-hwcap
31014@option{-mclear-hwcap} tells the compiler to remove the hardware
31015capabilities generated by the Solaris assembler. This is only necessary
31016when object files use ISA extensions not supported by the current
31017machine, but check at runtime whether or not to use them.
31018
31019@item -mimpure-text
31020@opindex mimpure-text
31021@option{-mimpure-text}, used in addition to @option{-shared}, tells
31022the compiler to not pass @option{-z text} to the linker when linking a
31023shared object. Using this option, you can link position-dependent
31024code into a shared object.
31025
31026@option{-mimpure-text} suppresses the ``relocations remain against
31027allocatable but non-writable sections'' linker error message.
31028However, the necessary relocations trigger copy-on-write, and the
31029shared object is not actually shared across processes. Instead of
31030using @option{-mimpure-text}, you should compile all source code with
31031@option{-fpic} or @option{-fPIC}.
31032
31033@end table
31034
31035These switches are supported in addition to the above on Solaris 2:
31036
31037@table @gcctabopt
31038@item -pthreads
31039@opindex pthreads
31040This is a synonym for @option{-pthread}.
31041@end table
31042
31043@node SPARC Options
31044@subsection SPARC Options
31045@cindex SPARC options
31046
31047These @samp{-m} options are supported on the SPARC:
31048
31049@table @gcctabopt
31050@item -mno-app-regs
31051@itemx -mapp-regs
31052@opindex mno-app-regs
31053@opindex mapp-regs
31054Specify @option{-mapp-regs} to generate output using the global registers
310552 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
31056global register 1, each global register 2 through 4 is then treated as an
31057allocable register that is clobbered by function calls. This is the default.
31058
31059To be fully SVR4 ABI-compliant at the cost of some performance loss,
31060specify @option{-mno-app-regs}. You should compile libraries and system
31061software with this option.
31062
31063@item -mflat
31064@itemx -mno-flat
31065@opindex mflat
31066@opindex mno-flat
31067With @option{-mflat}, the compiler does not generate save/restore instructions
31068and uses a ``flat'' or single register window model. This model is compatible
31069with the regular register window model. The local registers and the input
31070registers (0--5) are still treated as ``call-saved'' registers and are
31071saved on the stack as needed.
31072
31073With @option{-mno-flat} (the default), the compiler generates save/restore
31074instructions (except for leaf functions). This is the normal operating mode.
31075
31076@item -mfpu
31077@itemx -mhard-float
31078@opindex mfpu
31079@opindex mhard-float
31080Generate output containing floating-point instructions. This is the
31081default.
31082
31083@item -mno-fpu
31084@itemx -msoft-float
31085@opindex mno-fpu
31086@opindex msoft-float
31087Generate output containing library calls for floating point.
31088@strong{Warning:} the requisite libraries are not available for all SPARC
31089targets. Normally the facilities of the machine's usual C compiler are
31090used, but this cannot be done directly in cross-compilation. You must make
31091your own arrangements to provide suitable library functions for
31092cross-compilation. The embedded targets @samp{sparc-*-aout} and
31093@samp{sparclite-*-*} do provide software floating-point support.
31094
31095@option{-msoft-float} changes the calling convention in the output file;
31096therefore, it is only useful if you compile @emph{all} of a program with
31097this option. In particular, you need to compile @file{libgcc.a}, the
31098library that comes with GCC, with @option{-msoft-float} in order for
31099this to work.
31100
31101@item -mhard-quad-float
31102@opindex mhard-quad-float
31103Generate output containing quad-word (long double) floating-point
31104instructions.
31105
31106@item -msoft-quad-float
31107@opindex msoft-quad-float
31108Generate output containing library calls for quad-word (long double)
31109floating-point instructions. The functions called are those specified
31110in the SPARC ABI@. This is the default.
31111
31112As of this writing, there are no SPARC implementations that have hardware
31113support for the quad-word floating-point instructions. They all invoke
31114a trap handler for one of these instructions, and then the trap handler
31115emulates the effect of the instruction. Because of the trap handler overhead,
31116this is much slower than calling the ABI library routines. Thus the
31117@option{-msoft-quad-float} option is the default.
31118
31119@item -mno-unaligned-doubles
31120@itemx -munaligned-doubles
31121@opindex mno-unaligned-doubles
31122@opindex munaligned-doubles
31123Assume that doubles have 8-byte alignment. This is the default.
31124
31125With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
31126alignment only if they are contained in another type, or if they have an
31127absolute address. Otherwise, it assumes they have 4-byte alignment.
31128Specifying this option avoids some rare compatibility problems with code
31129generated by other compilers. It is not the default because it results
31130in a performance loss, especially for floating-point code.
31131
31132@item -muser-mode
31133@itemx -mno-user-mode
31134@opindex muser-mode
31135@opindex mno-user-mode
31136Do not generate code that can only run in supervisor mode. This is relevant
31137only for the @code{casa} instruction emitted for the LEON3 processor. This
31138is the default.
31139
31140@item -mfaster-structs
31141@itemx -mno-faster-structs
31142@opindex mfaster-structs
31143@opindex mno-faster-structs
31144With @option{-mfaster-structs}, the compiler assumes that structures
31145should have 8-byte alignment. This enables the use of pairs of
31146@code{ldd} and @code{std} instructions for copies in structure
31147assignment, in place of twice as many @code{ld} and @code{st} pairs.
31148However, the use of this changed alignment directly violates the SPARC
31149ABI@. Thus, it's intended only for use on targets where the developer
31150acknowledges that their resulting code is not directly in line with
31151the rules of the ABI@.
31152
31153@item -mstd-struct-return
31154@itemx -mno-std-struct-return
31155@opindex mstd-struct-return
31156@opindex mno-std-struct-return
31157With @option{-mstd-struct-return}, the compiler generates checking code
31158in functions returning structures or unions to detect size mismatches
31159between the two sides of function calls, as per the 32-bit ABI@.
31160
31161The default is @option{-mno-std-struct-return}. This option has no effect
31162in 64-bit mode.
31163
31164@item -mlra
31165@itemx -mno-lra
31166@opindex mlra
31167@opindex mno-lra
31168Enable Local Register Allocation. This is the default for SPARC since GCC 7
31169so @option{-mno-lra} needs to be passed to get old Reload.
31170
31171@item -mcpu=@var{cpu_type}
31172@opindex mcpu
31173Set the instruction set, register set, and instruction scheduling parameters
31174for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
31175@samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
31176@samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
31177@samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
31178@samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
31179@samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
31180@samp{m8}.
31181
31182Native Solaris and GNU/Linux toolchains also support the value @samp{native},
31183which selects the best architecture option for the host processor.
31184@option{-mcpu=native} has no effect if GCC does not recognize
31185the processor.
31186
31187Default instruction scheduling parameters are used for values that select
31188an architecture and not an implementation. These are @samp{v7}, @samp{v8},
31189@samp{sparclite}, @samp{sparclet}, @samp{v9}.
31190
31191Here is a list of each supported architecture and their supported
31192implementations.
31193
31194@table @asis
31195@item v7
31196cypress, leon3v7
31197
31198@item v8
31199supersparc, hypersparc, leon, leon3, leon5
31200
31201@item sparclite
31202f930, f934, sparclite86x
31203
31204@item sparclet
31205tsc701
31206
31207@item v9
31208ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
31209niagara7, m8
31210@end table
31211
31212By default (unless configured otherwise), GCC generates code for the V7
31213variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
31214additionally optimizes it for the Cypress CY7C602 chip, as used in the
31215SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
31216SPARCStation 1, 2, IPX etc.
31217
31218With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
31219architecture. The only difference from V7 code is that the compiler emits
31220the integer multiply and integer divide instructions which exist in SPARC-V8
31221but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
31222optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
312232000 series.
31224
31225With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
31226the SPARC architecture. This adds the integer multiply, integer divide step
31227and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
31228With @option{-mcpu=f930}, the compiler additionally optimizes it for the
31229Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
31230@option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
31231MB86934 chip, which is the more recent SPARClite with FPU@.
31232
31233With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
31234the SPARC architecture. This adds the integer multiply, multiply/accumulate,
31235integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
31236but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
31237optimizes it for the TEMIC SPARClet chip.
31238
31239With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
31240architecture. This adds 64-bit integer and floating-point move instructions,
312413 additional floating-point condition code registers and conditional move
31242instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
31243optimizes it for the Sun UltraSPARC I/II/IIi chips. With
31244@option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
31245Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
31246@option{-mcpu=niagara}, the compiler additionally optimizes it for
31247Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
31248additionally optimizes it for Sun UltraSPARC T2 chips. With
31249@option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
31250UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
31251additionally optimizes it for Sun UltraSPARC T4 chips. With
31252@option{-mcpu=niagara7}, the compiler additionally optimizes it for
31253Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
31254additionally optimizes it for Oracle M8 chips.
31255
31256@item -mtune=@var{cpu_type}
31257@opindex mtune
31258Set the instruction scheduling parameters for machine type
31259@var{cpu_type}, but do not set the instruction set or register set that the
31260option @option{-mcpu=@var{cpu_type}} does.
31261
31262The same values for @option{-mcpu=@var{cpu_type}} can be used for
31263@option{-mtune=@var{cpu_type}}, but the only useful values are those
31264that select a particular CPU implementation. Those are
31265@samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
31266@samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
31267@samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
31268@samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
31269@samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
31270and GNU/Linux toolchains, @samp{native} can also be used.
31271
31272@item -mv8plus
31273@itemx -mno-v8plus
31274@opindex mv8plus
31275@opindex mno-v8plus
31276With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
31277difference from the V8 ABI is that the global and out registers are
31278considered 64 bits wide. This is enabled by default on Solaris in 32-bit
31279mode for all SPARC-V9 processors.
31280
31281@item -mvis
31282@itemx -mno-vis
31283@opindex mvis
31284@opindex mno-vis
31285With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
31286Visual Instruction Set extensions. The default is @option{-mno-vis}.
31287
31288@item -mvis2
31289@itemx -mno-vis2
31290@opindex mvis2
31291@opindex mno-vis2
31292With @option{-mvis2}, GCC generates code that takes advantage of
31293version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
31294default is @option{-mvis2} when targeting a cpu that supports such
31295instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
31296also sets @option{-mvis}.
31297
31298@item -mvis3
31299@itemx -mno-vis3
31300@opindex mvis3
31301@opindex mno-vis3
31302With @option{-mvis3}, GCC generates code that takes advantage of
31303version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
31304default is @option{-mvis3} when targeting a cpu that supports such
31305instructions, such as niagara-3 and later. Setting @option{-mvis3}
31306also sets @option{-mvis2} and @option{-mvis}.
31307
31308@item -mvis4
31309@itemx -mno-vis4
31310@opindex mvis4
31311@opindex mno-vis4
31312With @option{-mvis4}, GCC generates code that takes advantage of
31313version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
31314default is @option{-mvis4} when targeting a cpu that supports such
31315instructions, such as niagara-7 and later. Setting @option{-mvis4}
31316also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}.
31317
31318@item -mvis4b
31319@itemx -mno-vis4b
31320@opindex mvis4b
31321@opindex mno-vis4b
31322With @option{-mvis4b}, GCC generates code that takes advantage of
31323version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
31324the additional VIS instructions introduced in the Oracle SPARC
31325Architecture 2017. The default is @option{-mvis4b} when targeting a
31326cpu that supports such instructions, such as m8 and later. Setting
31327@option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3},
31328@option{-mvis2} and @option{-mvis}.
31329
31330@item -mcbcond
31331@itemx -mno-cbcond
31332@opindex mcbcond
31333@opindex mno-cbcond
31334With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
31335Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
31336when targeting a CPU that supports such instructions, such as Niagara-4 and
31337later.
31338
31339@item -mfmaf
31340@itemx -mno-fmaf
31341@opindex mfmaf
31342@opindex mno-fmaf
31343With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
31344Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
31345when targeting a CPU that supports such instructions, such as Niagara-3 and
31346later.
31347
31348@item -mfsmuld
31349@itemx -mno-fsmuld
31350@opindex mfsmuld
31351@opindex mno-fsmuld
31352With @option{-mfsmuld}, GCC generates code that takes advantage of the
31353Floating-point Multiply Single to Double (FsMULd) instruction. The default is
31354@option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
31355or V9 with FPU except @option{-mcpu=leon}.
31356
31357@item -mpopc
31358@itemx -mno-popc
31359@opindex mpopc
31360@opindex mno-popc
31361With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
31362Population Count instruction. The default is @option{-mpopc}
31363when targeting a CPU that supports such an instruction, such as Niagara-2 and
31364later.
31365
31366@item -msubxc
31367@itemx -mno-subxc
31368@opindex msubxc
31369@opindex mno-subxc
31370With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
31371Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
31372when targeting a CPU that supports such an instruction, such as Niagara-7 and
31373later.
31374
31375@item -mfix-at697f
31376@opindex mfix-at697f
31377Enable the documented workaround for the single erratum of the Atmel AT697F
31378processor (which corresponds to erratum #13 of the AT697E processor).
31379
31380@item -mfix-ut699
31381@opindex mfix-ut699
31382Enable the documented workarounds for the floating-point errata and the data
31383cache nullify errata of the UT699 processor.
31384
31385@item -mfix-ut700
31386@opindex mfix-ut700
31387Enable the documented workaround for the back-to-back store errata of
31388the UT699E/UT700 processor.
31389
31390@item -mfix-gr712rc
31391@opindex mfix-gr712rc
31392Enable the documented workaround for the back-to-back store errata of
31393the GR712RC processor.
31394@end table
31395
31396These @samp{-m} options are supported in addition to the above
31397on SPARC-V9 processors in 64-bit environments:
31398
31399@table @gcctabopt
31400@item -m32
31401@itemx -m64
31402@opindex m32
31403@opindex m64
31404Generate code for a 32-bit or 64-bit environment.
31405The 32-bit environment sets int, long and pointer to 32 bits.
31406The 64-bit environment sets int to 32 bits and long and pointer
31407to 64 bits.
31408
31409@item -mcmodel=@var{which}
31410@opindex mcmodel
31411Set the code model to one of
31412
31413@table @samp
31414@item medlow
31415The Medium/Low code model: 64-bit addresses, programs
31416must be linked in the low 32 bits of memory. Programs can be statically
31417or dynamically linked.
31418
31419@item medmid
31420The Medium/Middle code model: 64-bit addresses, programs
31421must be linked in the low 44 bits of memory, the text and data segments must
31422be less than 2GB in size and the data segment must be located within 2GB of
31423the text segment.
31424
31425@item medany
31426The Medium/Anywhere code model: 64-bit addresses, programs
31427may be linked anywhere in memory, the text and data segments must be less
31428than 2GB in size and the data segment must be located within 2GB of the
31429text segment.
31430
31431@item embmedany
31432The Medium/Anywhere code model for embedded systems:
3143364-bit addresses, the text and data segments must be less than 2GB in
31434size, both starting anywhere in memory (determined at link time). The
31435global register %g4 points to the base of the data segment. Programs
31436are statically linked and PIC is not supported.
31437@end table
31438
31439@item -mmemory-model=@var{mem-model}
31440@opindex mmemory-model
31441Set the memory model in force on the processor to one of
31442
31443@table @samp
31444@item default
31445The default memory model for the processor and operating system.
31446
31447@item rmo
31448Relaxed Memory Order
31449
31450@item pso
31451Partial Store Order
31452
31453@item tso
31454Total Store Order
31455
31456@item sc
31457Sequential Consistency
31458@end table
31459
31460These memory models are formally defined in Appendix D of the SPARC-V9
31461architecture manual, as set in the processor's @code{PSTATE.MM} field.
31462
31463@item -mstack-bias
31464@itemx -mno-stack-bias
31465@opindex mstack-bias
31466@opindex mno-stack-bias
31467With @option{-mstack-bias}, GCC assumes that the stack pointer, and
31468frame pointer if present, are offset by @minus{}2047 which must be added back
31469when making stack frame references. This is the default in 64-bit mode.
31470Otherwise, assume no such offset is present.
31471@end table
31472
31473@node System V Options
31474@subsection Options for System V
31475
31476These additional options are available on System V Release 4 for
31477compatibility with other compilers on those systems:
31478
31479@table @gcctabopt
31480@item -G
31481@opindex G
31482Create a shared object.
31483It is recommended that @option{-symbolic} or @option{-shared} be used instead.
31484
31485@item -Qy
31486@opindex Qy
31487Identify the versions of each tool used by the compiler, in a
31488@code{.ident} assembler directive in the output.
31489
31490@item -Qn
31491@opindex Qn
31492Refrain from adding @code{.ident} directives to the output file (this is
31493the default).
31494
31495@item -YP,@var{dirs}
31496@opindex YP
31497Search the directories @var{dirs}, and no others, for libraries
31498specified with @option{-l}.
31499
31500@item -Ym,@var{dir}
31501@opindex Ym
31502Look in the directory @var{dir} to find the M4 preprocessor.
31503The assembler uses this option.
31504@c This is supposed to go with a -Yd for predefined M4 macro files, but
31505@c the generic assembler that comes with Solaris takes just -Ym.
31506@end table
31507
31508@node V850 Options
31509@subsection V850 Options
31510@cindex V850 Options
31511
31512These @samp{-m} options are defined for V850 implementations:
31513
31514@table @gcctabopt
31515@item -mlong-calls
31516@itemx -mno-long-calls
31517@opindex mlong-calls
31518@opindex mno-long-calls
31519Treat all calls as being far away (near). If calls are assumed to be
31520far away, the compiler always loads the function's address into a
31521register, and calls indirect through the pointer.
31522
31523@item -mno-ep
31524@itemx -mep
31525@opindex mno-ep
31526@opindex mep
31527Do not optimize (do optimize) basic blocks that use the same index
31528pointer 4 or more times to copy pointer into the @code{ep} register, and
31529use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
31530option is on by default if you optimize.
31531
31532@item -mno-prolog-function
31533@itemx -mprolog-function
31534@opindex mno-prolog-function
31535@opindex mprolog-function
31536Do not use (do use) external functions to save and restore registers
31537at the prologue and epilogue of a function. The external functions
31538are slower, but use less code space if more than one function saves
31539the same number of registers. The @option{-mprolog-function} option
31540is on by default if you optimize.
31541
31542@item -mspace
31543@opindex mspace
31544Try to make the code as small as possible. At present, this just turns
31545on the @option{-mep} and @option{-mprolog-function} options.
31546
31547@item -mtda=@var{n}
31548@opindex mtda
31549Put static or global variables whose size is @var{n} bytes or less into
31550the tiny data area that register @code{ep} points to. The tiny data
31551area can hold up to 256 bytes in total (128 bytes for byte references).
31552
31553@item -msda=@var{n}
31554@opindex msda
31555Put static or global variables whose size is @var{n} bytes or less into
31556the small data area that register @code{gp} points to. The small data
31557area can hold up to 64 kilobytes.
31558
31559@item -mzda=@var{n}
31560@opindex mzda
31561Put static or global variables whose size is @var{n} bytes or less into
31562the first 32 kilobytes of memory.
31563
31564@item -mv850
31565@opindex mv850
31566Specify that the target processor is the V850.
31567
31568@item -mv850e3v5
31569@opindex mv850e3v5
31570Specify that the target processor is the V850E3V5. The preprocessor
31571constant @code{__v850e3v5__} is defined if this option is used.
31572
31573@item -mv850e2v4
31574@opindex mv850e2v4
31575Specify that the target processor is the V850E3V5. This is an alias for
31576the @option{-mv850e3v5} option.
31577
31578@item -mv850e2v3
31579@opindex mv850e2v3
31580Specify that the target processor is the V850E2V3. The preprocessor
31581constant @code{__v850e2v3__} is defined if this option is used.
31582
31583@item -mv850e2
31584@opindex mv850e2
31585Specify that the target processor is the V850E2. The preprocessor
31586constant @code{__v850e2__} is defined if this option is used.
31587
31588@item -mv850e1
31589@opindex mv850e1
31590Specify that the target processor is the V850E1. The preprocessor
31591constants @code{__v850e1__} and @code{__v850e__} are defined if
31592this option is used.
31593
31594@item -mv850es
31595@opindex mv850es
31596Specify that the target processor is the V850ES. This is an alias for
31597the @option{-mv850e1} option.
31598
31599@item -mv850e
31600@opindex mv850e
31601Specify that the target processor is the V850E@. The preprocessor
31602constant @code{__v850e__} is defined if this option is used.
31603
31604If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
31605nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
31606are defined then a default target processor is chosen and the
31607relevant @samp{__v850*__} preprocessor constant is defined.
31608
31609The preprocessor constants @code{__v850} and @code{__v851__} are always
31610defined, regardless of which processor variant is the target.
31611
31612@item -mdisable-callt
31613@itemx -mno-disable-callt
31614@opindex mdisable-callt
31615@opindex mno-disable-callt
31616This option suppresses generation of the @code{CALLT} instruction for the
31617v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
31618architecture.
31619
31620This option is enabled by default when the RH850 ABI is
31621in use (see @option{-mrh850-abi}), and disabled by default when the
31622GCC ABI is in use. If @code{CALLT} instructions are being generated
31623then the C preprocessor symbol @code{__V850_CALLT__} is defined.
31624
31625@item -mrelax
31626@itemx -mno-relax
31627@opindex mrelax
31628@opindex mno-relax
31629Pass on (or do not pass on) the @option{-mrelax} command-line option
31630to the assembler.
31631
31632@item -mlong-jumps
31633@itemx -mno-long-jumps
31634@opindex mlong-jumps
31635@opindex mno-long-jumps
31636Disable (or re-enable) the generation of PC-relative jump instructions.
31637
31638@item -msoft-float
31639@itemx -mhard-float
31640@opindex msoft-float
31641@opindex mhard-float
31642Disable (or re-enable) the generation of hardware floating point
31643instructions. This option is only significant when the target
31644architecture is @samp{V850E2V3} or higher. If hardware floating point
31645instructions are being generated then the C preprocessor symbol
31646@code{__FPU_OK__} is defined, otherwise the symbol
31647@code{__NO_FPU__} is defined.
31648
31649@item -mloop
31650@opindex mloop
31651Enables the use of the e3v5 LOOP instruction. The use of this
31652instruction is not enabled by default when the e3v5 architecture is
31653selected because its use is still experimental.
31654
31655@item -mrh850-abi
31656@itemx -mghs
31657@opindex mrh850-abi
31658@opindex mghs
31659Enables support for the RH850 version of the V850 ABI. This is the
31660default. With this version of the ABI the following rules apply:
31661
31662@itemize
31663@item
31664Integer sized structures and unions are returned via a memory pointer
31665rather than a register.
31666
31667@item
31668Large structures and unions (more than 8 bytes in size) are passed by
31669value.
31670
31671@item
31672Functions are aligned to 16-bit boundaries.
31673
31674@item
31675The @option{-m8byte-align} command-line option is supported.
31676
31677@item
31678The @option{-mdisable-callt} command-line option is enabled by
31679default. The @option{-mno-disable-callt} command-line option is not
31680supported.
31681@end itemize
31682
31683When this version of the ABI is enabled the C preprocessor symbol
31684@code{__V850_RH850_ABI__} is defined.
31685
31686@item -mgcc-abi
31687@opindex mgcc-abi
31688Enables support for the old GCC version of the V850 ABI. With this
31689version of the ABI the following rules apply:
31690
31691@itemize
31692@item
31693Integer sized structures and unions are returned in register @code{r10}.
31694
31695@item
31696Large structures and unions (more than 8 bytes in size) are passed by
31697reference.
31698
31699@item
31700Functions are aligned to 32-bit boundaries, unless optimizing for
31701size.
31702
31703@item
31704The @option{-m8byte-align} command-line option is not supported.
31705
31706@item
31707The @option{-mdisable-callt} command-line option is supported but not
31708enabled by default.
31709@end itemize
31710
31711When this version of the ABI is enabled the C preprocessor symbol
31712@code{__V850_GCC_ABI__} is defined.
31713
31714@item -m8byte-align
31715@itemx -mno-8byte-align
31716@opindex m8byte-align
31717@opindex mno-8byte-align
31718Enables support for @code{double} and @code{long long} types to be
31719aligned on 8-byte boundaries. The default is to restrict the
31720alignment of all objects to at most 4-bytes. When
31721@option{-m8byte-align} is in effect the C preprocessor symbol
31722@code{__V850_8BYTE_ALIGN__} is defined.
31723
31724@item -mbig-switch
31725@opindex mbig-switch
31726Generate code suitable for big switch tables. Use this option only if
31727the assembler/linker complain about out of range branches within a switch
31728table.
31729
31730@item -mapp-regs
31731@opindex mapp-regs
31732This option causes r2 and r5 to be used in the code generated by
31733the compiler. This setting is the default.
31734
31735@item -mno-app-regs
31736@opindex mno-app-regs
31737This option causes r2 and r5 to be treated as fixed registers.
31738
31739@end table
31740
31741@node VAX Options
31742@subsection VAX Options
31743@cindex VAX options
31744
31745These @samp{-m} options are defined for the VAX:
31746
31747@table @gcctabopt
31748@item -munix
31749@opindex munix
31750Do not output certain jump instructions (@code{aobleq} and so on)
31751that the Unix assembler for the VAX cannot handle across long
31752ranges.
31753
31754@item -mgnu
31755@opindex mgnu
31756Do output those jump instructions, on the assumption that the
31757GNU assembler is being used.
31758
31759@item -mg
31760@opindex mg
31761Output code for G-format floating-point numbers instead of D-format.
31762
31763@item -mlra
31764@itemx -mno-lra
31765@opindex mlra
31766@opindex mno-lra
31767Enable Local Register Allocation. This is still experimental for the VAX,
31768so by default the compiler uses standard reload.
31769@end table
31770
31771@node Visium Options
31772@subsection Visium Options
31773@cindex Visium options
31774
31775@table @gcctabopt
31776
31777@item -mdebug
31778@opindex mdebug
31779A program which performs file I/O and is destined to run on an MCM target
31780should be linked with this option. It causes the libraries libc.a and
31781libdebug.a to be linked. The program should be run on the target under
31782the control of the GDB remote debugging stub.
31783
31784@item -msim
31785@opindex msim
31786A program which performs file I/O and is destined to run on the simulator
31787should be linked with option. This causes libraries libc.a and libsim.a to
31788be linked.
31789
31790@item -mfpu
31791@itemx -mhard-float
31792@opindex mfpu
31793@opindex mhard-float
31794Generate code containing floating-point instructions. This is the
31795default.
31796
31797@item -mno-fpu
31798@itemx -msoft-float
31799@opindex mno-fpu
31800@opindex msoft-float
31801Generate code containing library calls for floating-point.
31802
31803@option{-msoft-float} changes the calling convention in the output file;
31804therefore, it is only useful if you compile @emph{all} of a program with
31805this option. In particular, you need to compile @file{libgcc.a}, the
31806library that comes with GCC, with @option{-msoft-float} in order for
31807this to work.
31808
31809@item -mcpu=@var{cpu_type}
31810@opindex mcpu
31811Set the instruction set, register set, and instruction scheduling parameters
31812for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
31813@samp{mcm}, @samp{gr5} and @samp{gr6}.
31814
31815@samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
31816
31817By default (unless configured otherwise), GCC generates code for the GR5
31818variant of the Visium architecture.
31819
31820With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
31821architecture. The only difference from GR5 code is that the compiler will
31822generate block move instructions.
31823
31824@item -mtune=@var{cpu_type}
31825@opindex mtune
31826Set the instruction scheduling parameters for machine type @var{cpu_type},
31827but do not set the instruction set or register set that the option
31828@option{-mcpu=@var{cpu_type}} would.
31829
31830@item -msv-mode
31831@opindex msv-mode
31832Generate code for the supervisor mode, where there are no restrictions on
31833the access to general registers. This is the default.
31834
31835@item -muser-mode
31836@opindex muser-mode
31837Generate code for the user mode, where the access to some general registers
31838is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
31839mode; on the GR6, only registers r29 to r31 are affected.
31840@end table
31841
31842@node VMS Options
31843@subsection VMS Options
31844
31845These @samp{-m} options are defined for the VMS implementations:
31846
31847@table @gcctabopt
31848@item -mvms-return-codes
31849@opindex mvms-return-codes
31850Return VMS condition codes from @code{main}. The default is to return POSIX-style
31851condition (e.g.@: error) codes.
31852
31853@item -mdebug-main=@var{prefix}
31854@opindex mdebug-main=@var{prefix}
31855Flag the first routine whose name starts with @var{prefix} as the main
31856routine for the debugger.
31857
31858@item -mmalloc64
31859@opindex mmalloc64
31860Default to 64-bit memory allocation routines.
31861
31862@item -mpointer-size=@var{size}
31863@opindex mpointer-size=@var{size}
31864Set the default size of pointers. Possible options for @var{size} are
31865@samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
31866for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
31867The later option disables @code{pragma pointer_size}.
31868@end table
31869
31870@node VxWorks Options
31871@subsection VxWorks Options
31872@cindex VxWorks Options
31873
31874The options in this section are defined for all VxWorks targets.
31875Options specific to the target hardware are listed with the other
31876options for that target.
31877
31878@table @gcctabopt
31879@item -mrtp
31880@opindex mrtp
31881GCC can generate code for both VxWorks kernels and real time processes
31882(RTPs). This option switches from the former to the latter. It also
31883defines the preprocessor macro @code{__RTP__}.
31884
31885@item -non-static
31886@opindex non-static
31887Link an RTP executable against shared libraries rather than static
31888libraries. The options @option{-static} and @option{-shared} can
31889also be used for RTPs (@pxref{Link Options}); @option{-static}
31890is the default.
31891
31892@item -Bstatic
31893@itemx -Bdynamic
31894@opindex Bstatic
31895@opindex Bdynamic
31896These options are passed down to the linker. They are defined for
31897compatibility with Diab.
31898
31899@item -Xbind-lazy
31900@opindex Xbind-lazy
31901Enable lazy binding of function calls. This option is equivalent to
31902@option{-Wl,-z,now} and is defined for compatibility with Diab.
31903
31904@item -Xbind-now
31905@opindex Xbind-now
31906Disable lazy binding of function calls. This option is the default and
31907is defined for compatibility with Diab.
31908@end table
31909
31910@node x86 Options
31911@subsection x86 Options
31912@cindex x86 Options
31913
31914These @samp{-m} options are defined for the x86 family of computers.
31915
31916@table @gcctabopt
31917
31918@item -march=@var{cpu-type}
31919@opindex march
31920Generate instructions for the machine type @var{cpu-type}. In contrast to
31921@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
31922for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
31923to generate code that may not run at all on processors other than the one
31924indicated. Specifying @option{-march=@var{cpu-type}} implies
31925@option{-mtune=@var{cpu-type}}, except where noted otherwise.
31926
31927The choices for @var{cpu-type} are:
31928
31929@table @samp
31930@item native
31931This selects the CPU to generate code for at compilation time by determining
31932the processor type of the compiling machine. Using @option{-march=native}
31933enables all instruction subsets supported by the local machine (hence
31934the result might not run on different machines). Using @option{-mtune=native}
31935produces code optimized for the local machine under the constraints
31936of the selected instruction set.
31937
31938@item x86-64
31939A generic CPU with 64-bit extensions.
31940
31941@item x86-64-v2
31942@itemx x86-64-v3
31943@itemx x86-64-v4
31944These choices for @var{cpu-type} select the corresponding
31945micro-architecture level from the x86-64 psABI. On ABIs other than
31946the x86-64 psABI they select the same CPU features as the x86-64 psABI
31947documents for the particular micro-architecture level.
31948
31949Since these @var{cpu-type} values do not have a corresponding
31950@option{-mtune} setting, using @option{-march} with these values enables
31951generic tuning. Specific tuning can be enabled using the
31952@option{-mtune=@var{other-cpu-type}} option with an appropriate
31953@var{other-cpu-type} value.
31954
31955@item i386
31956Original Intel i386 CPU@.
31957
31958@item i486
31959Intel i486 CPU@. (No scheduling is implemented for this chip.)
31960
31961@item i586
31962@itemx pentium
31963Intel Pentium CPU with no MMX support.
31964
31965@item lakemont
31966Intel Lakemont MCU, based on Intel Pentium CPU.
31967
31968@item pentium-mmx
31969Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
31970
31971@item pentiumpro
31972Intel Pentium Pro CPU@.
31973
31974@item i686
31975When used with @option{-march}, the Pentium Pro
31976instruction set is used, so the code runs on all i686 family chips.
31977When used with @option{-mtune}, it has the same meaning as @samp{generic}.
31978
31979@item pentium2
31980Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction
31981set support.
31982
31983@item pentium3
31984@itemx pentium3m
31985Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE
31986instruction set support.
31987
31988@item pentium-m
31989Intel Pentium M; low-power version of Intel Pentium III CPU
31990with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino
31991notebooks.
31992
31993@item pentium4
31994@itemx pentium4m
31995Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support.
31996
31997@item prescott
31998Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR
31999instruction set support.
32000
32001@item nocona
32002Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
32003SSE2, SSE3 and FXSR instruction set support.
32004
32005@item core2
32006Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16,
32007SAHF and FXSR instruction set support.
32008
32009@item nehalem
32010Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32011SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support.
32012
32013@item westmere
32014Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32015SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support.
32016
32017@item sandybridge
32018Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32019SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set
32020support.
32021
32022@item ivybridge
32023Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32024SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND
32025and F16C instruction set support.
32026
32027@item haswell
32028Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32029SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32030F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
32031
32032@item broadwell
32033Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32034SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32035F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW
32036instruction set support.
32037
32038@item skylake
32039Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32040SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32041F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32042CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support.
32043
32044@item bonnell
32045Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
32046instruction set support.
32047
32048@item silvermont
32049Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32050SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND
32051instruction set support.
32052
32053@item goldmont
32054Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32055SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32056RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction
32057set support.
32058
32059@item goldmont-plus
32060Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32061SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES,
32062SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE,
32063RDPID and SGX instruction set support.
32064
32065@item tremont
32066Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32067SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32068RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID,
32069SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
32070support.
32071
32072@item sierraforest
32073Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32074SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32075XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32076MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32077PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32078AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support.
32079
32080@item grandridge
32081Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32082SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32083XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32084MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32085PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32086AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD and RAOINT instruction set
32087support.
32088
32089@item knl
32090Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32091SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32092RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32093AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support.
32094
32095@item knm
32096Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32097SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32098RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32099AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW,
32100AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support.
32101
32102@item skylake-avx512
32103Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32104SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32105RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32106AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW,
32107AVX512DQ and AVX512CD instruction set support.
32108
32109@item cannonlake
32110Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
32111SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
32112FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
32113PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
32114AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set
32115support.
32116
32117@item icelake-client
32118Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32119SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32120RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32121AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32122AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32123, VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32124
32125@item icelake-server
32126Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32127SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32128RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32129AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32130AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32131, VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB
32132instruction set support.
32133
32134@item cascadelake
32135Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32136SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32137F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32138CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32139AVX512CD and AVX512VNNI instruction set support.
32140
32141@item cooperlake
32142Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32143SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32144F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32145CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32146AVX512CD, AVX512VNNI and AVX512BF16 instruction set support.
32147
32148@item tigerlake
32149Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32150SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32151F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32152CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32153PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32154VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB,
32155AVX512VP2INTERSECT and KEYLOCKER instruction set support.
32156
32157@item sapphirerapids
32158Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32159SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32160RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32161AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32162AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32163VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32164MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
32165UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16 and AVX512BF16
32166instruction set support.
32167
32168@item alderlake
32169Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32170SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
32171XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B,
32172CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
32173VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set
32174support.
32175
32176@item rocketlake
32177Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3
32178, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32179F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32180CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32181PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32182VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32183
32184@item graniterapids
32185Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32186SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32187RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32188AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32189AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32190VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32191MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG,
32192SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16,
32193AVX512BF16, AMX-FP16 and PREFETCHI instruction set support.
32194
32195@item k6
32196AMD K6 CPU with MMX instruction set support.
32197
32198@item k6-2
32199@itemx k6-3
32200Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
32201
32202@item athlon
32203@itemx athlon-tbird
32204AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
32205support.
32206
32207@item athlon-4
32208@itemx athlon-xp
32209@itemx athlon-mp
32210Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
32211instruction set support.
32212
32213@item k8
32214@itemx opteron
32215@itemx athlon64
32216@itemx athlon-fx
32217Processors based on the AMD K8 core with x86-64 instruction set support,
32218including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
32219(This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
32220instruction set extensions.)
32221
32222@item k8-sse3
32223@itemx opteron-sse3
32224@itemx athlon64-sse3
32225Improved versions of AMD K8 cores with SSE3 instruction set support.
32226
32227@item amdfam10
32228@itemx barcelona
32229CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
32230supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
32231instruction set extensions.)
32232
32233@item bdver1
32234CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
32235supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
32236SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
32237
32238@item bdver2
32239AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32240supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
32241SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
32242extensions.)
32243
32244@item bdver3
32245AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32246supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
32247PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
3224864-bit instruction set extensions.)
32249
32250@item bdver4
32251AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32252supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
32253AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
32254SSE4.2, ABM and 64-bit instruction set extensions.)
32255
32256@item znver1
32257AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32258supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
32259SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
32260SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
32261instruction set extensions.)
32262
32263@item znver2
32264AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32265supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32266MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32267SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32268WBNOINVD, and 64-bit instruction set extensions.)
32269
32270@item znver3
32271AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32272supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32273MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32274SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32275WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
32276
32277@item znver4
32278AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32279supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32280MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32281SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32282WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
32283AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
32284AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)
32285
32286@item btver1
32287CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
32288supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
32289instruction set extensions.)
32290
32291@item btver2
32292CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
32293includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
32294SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
32295
32296@item winchip-c6
32297IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
32298set support.
32299
32300@item winchip2
32301IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
32302instruction set support.
32303
32304@item c3
32305VIA C3 CPU with MMX and 3DNow!@: instruction set support.
32306(No scheduling is implemented for this chip.)
32307
32308@item c3-2
32309VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
32310(No scheduling is implemented for this chip.)
32311
32312@item c7
32313VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32314(No scheduling is implemented for this chip.)
32315
32316@item samuel-2
32317VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
32318(No scheduling is implemented for this chip.)
32319
32320@item nehemiah
32321VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
32322(No scheduling is implemented for this chip.)
32323
32324@item esther
32325VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32326(No scheduling is implemented for this chip.)
32327
32328@item eden-x2
32329VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
32330(No scheduling is implemented for this chip.)
32331
32332@item eden-x4
32333VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
32334AVX and AVX2 instruction set support.
32335(No scheduling is implemented for this chip.)
32336
32337@item nano
32338Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32339instruction set support.
32340(No scheduling is implemented for this chip.)
32341
32342@item nano-1000
32343VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32344instruction set support.
32345(No scheduling is implemented for this chip.)
32346
32347@item nano-2000
32348VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32349instruction set support.
32350(No scheduling is implemented for this chip.)
32351
32352@item nano-3000
32353VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32354instruction set support.
32355(No scheduling is implemented for this chip.)
32356
32357@item nano-x2
32358VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32359instruction set support.
32360(No scheduling is implemented for this chip.)
32361
32362@item nano-x4
32363VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32364instruction set support.
32365(No scheduling is implemented for this chip.)
32366
32367@item lujiazui
32368ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
32369SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
32370ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support.
32371
32372@item geode
32373AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
32374@end table
32375
32376@item -mtune=@var{cpu-type}
32377@opindex mtune
32378Tune to @var{cpu-type} everything applicable about the generated code, except
32379for the ABI and the set of available instructions.
32380While picking a specific @var{cpu-type} schedules things appropriately
32381for that particular chip, the compiler does not generate any code that
32382cannot run on the default machine type unless you use a
32383@option{-march=@var{cpu-type}} option.
32384For example, if GCC is configured for i686-pc-linux-gnu
32385then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
32386but still runs on i686 machines.
32387
32388The choices for @var{cpu-type} are the same as for @option{-march}.
32389In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
32390
32391@table @samp
32392@item generic
32393Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
32394If you know the CPU on which your code will run, then you should use
32395the corresponding @option{-mtune} or @option{-march} option instead of
32396@option{-mtune=generic}. But, if you do not know exactly what CPU users
32397of your application will have, then you should use this option.
32398
32399As new processors are deployed in the marketplace, the behavior of this
32400option will change. Therefore, if you upgrade to a newer version of
32401GCC, code generation controlled by this option will change to reflect
32402the processors
32403that are most common at the time that version of GCC is released.
32404
32405There is no @option{-march=generic} option because @option{-march}
32406indicates the instruction set the compiler can use, and there is no
32407generic instruction set applicable to all processors. In contrast,
32408@option{-mtune} indicates the processor (or, in this case, collection of
32409processors) for which the code is optimized.
32410
32411@item intel
32412Produce code optimized for the most current Intel processors, which are
32413Haswell and Silvermont for this version of GCC. If you know the CPU
32414on which your code will run, then you should use the corresponding
32415@option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
32416But, if you want your application performs better on both Haswell and
32417Silvermont, then you should use this option.
32418
32419As new Intel processors are deployed in the marketplace, the behavior of
32420this option will change. Therefore, if you upgrade to a newer version of
32421GCC, code generation controlled by this option will change to reflect
32422the most current Intel processors at the time that version of GCC is
32423released.
32424
32425There is no @option{-march=intel} option because @option{-march} indicates
32426the instruction set the compiler can use, and there is no common
32427instruction set applicable to all processors. In contrast,
32428@option{-mtune} indicates the processor (or, in this case, collection of
32429processors) for which the code is optimized.
32430@end table
32431
32432@item -mcpu=@var{cpu-type}
32433@opindex mcpu
32434A deprecated synonym for @option{-mtune}.
32435
32436@item -mfpmath=@var{unit}
32437@opindex mfpmath
32438Generate floating-point arithmetic for selected unit @var{unit}. The choices
32439for @var{unit} are:
32440
32441@table @samp
32442@item 387
32443Use the standard 387 floating-point coprocessor present on the majority of chips and
32444emulated otherwise. Code compiled with this option runs almost everywhere.
32445The temporary results are computed in 80-bit precision instead of the precision
32446specified by the type, resulting in slightly different results compared to most
32447of other chips. See @option{-ffloat-store} for more detailed description.
32448
32449This is the default choice for non-Darwin x86-32 targets.
32450
32451@item sse
32452Use scalar floating-point instructions present in the SSE instruction set.
32453This instruction set is supported by Pentium III and newer chips,
32454and in the AMD line
32455by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
32456instruction set supports only single-precision arithmetic, thus the double and
32457extended-precision arithmetic are still done using 387. A later version, present
32458only in Pentium 4 and AMD x86-64 chips, supports double-precision
32459arithmetic too.
32460
32461For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
32462or @option{-msse2} switches to enable SSE extensions and make this option
32463effective. For the x86-64 compiler, these extensions are enabled by default.
32464
32465The resulting code should be considerably faster in the majority of cases and avoid
32466the numerical instability problems of 387 code, but may break some existing
32467code that expects temporaries to be 80 bits.
32468
32469This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
32470and the default choice for x86-32 targets with the SSE2 instruction set
32471when @option{-ffast-math} is enabled.
32472
32473@item sse,387
32474@itemx sse+387
32475@itemx both
32476Attempt to utilize both instruction sets at once. This effectively doubles the
32477amount of available registers, and on chips with separate execution units for
32478387 and SSE the execution resources too. Use this option with care, as it is
32479still experimental, because the GCC register allocator does not model separate
32480functional units well, resulting in unstable performance.
32481@end table
32482
32483@item -masm=@var{dialect}
32484@opindex masm=@var{dialect}
32485Output assembly instructions using selected @var{dialect}. Also affects
32486which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
32487extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
32488order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
32489not support @samp{intel}.
32490
32491@item -mieee-fp
32492@itemx -mno-ieee-fp
32493@opindex mieee-fp
32494@opindex mno-ieee-fp
32495Control whether or not the compiler uses IEEE floating-point
32496comparisons. These correctly handle the case where the result of a
32497comparison is unordered.
32498
32499@item -m80387
32500@itemx -mhard-float
30348d30 32501@opindex m80387
d77de738
ML
32502@opindex mhard-float
32503Generate output containing 80387 instructions for floating point.
32504
32505@item -mno-80387
32506@itemx -msoft-float
32507@opindex no-80387
32508@opindex msoft-float
32509Generate output containing library calls for floating point.
32510
32511@strong{Warning:} the requisite libraries are not part of GCC@.
32512Normally the facilities of the machine's usual C compiler are used, but
32513this cannot be done directly in cross-compilation. You must make your
32514own arrangements to provide suitable library functions for
32515cross-compilation.
32516
32517On machines where a function returns floating-point results in the 80387
32518register stack, some floating-point opcodes may be emitted even if
32519@option{-msoft-float} is used.
32520
32521@item -mno-fp-ret-in-387
32522@opindex mno-fp-ret-in-387
32523@opindex mfp-ret-in-387
32524Do not use the FPU registers for return values of functions.
32525
32526The usual calling convention has functions return values of types
32527@code{float} and @code{double} in an FPU register, even if there
32528is no FPU@. The idea is that the operating system should emulate
32529an FPU@.
32530
32531The option @option{-mno-fp-ret-in-387} causes such values to be returned
32532in ordinary CPU registers instead.
32533
32534@item -mno-fancy-math-387
32535@opindex mno-fancy-math-387
32536@opindex mfancy-math-387
32537Some 387 emulators do not support the @code{sin}, @code{cos} and
32538@code{sqrt} instructions for the 387. Specify this option to avoid
32539generating those instructions.
32540This option is overridden when @option{-march}
32541indicates that the target CPU always has an FPU and so the
32542instruction does not need emulation. These
32543instructions are not generated unless you also use the
32544@option{-funsafe-math-optimizations} switch.
32545
32546@item -malign-double
32547@itemx -mno-align-double
32548@opindex malign-double
32549@opindex mno-align-double
32550Control whether GCC aligns @code{double}, @code{long double}, and
32551@code{long long} variables on a two-word boundary or a one-word
32552boundary. Aligning @code{double} variables on a two-word boundary
32553produces code that runs somewhat faster on a Pentium at the
32554expense of more memory.
32555
32556On x86-64, @option{-malign-double} is enabled by default.
32557
32558@strong{Warning:} if you use the @option{-malign-double} switch,
32559structures containing the above types are aligned differently than
32560the published application binary interface specifications for the x86-32
32561and are not binary compatible with structures in code compiled
32562without that switch.
32563
32564@item -m96bit-long-double
32565@itemx -m128bit-long-double
32566@opindex m96bit-long-double
32567@opindex m128bit-long-double
32568These switches control the size of @code{long double} type. The x86-32
32569application binary interface specifies the size to be 96 bits,
32570so @option{-m96bit-long-double} is the default in 32-bit mode.
32571
32572Modern architectures (Pentium and newer) prefer @code{long double}
32573to be aligned to an 8- or 16-byte boundary. In arrays or structures
32574conforming to the ABI, this is not possible. So specifying
32575@option{-m128bit-long-double} aligns @code{long double}
32576to a 16-byte boundary by padding the @code{long double} with an additional
3257732-bit zero.
32578
32579In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
32580its ABI specifies that @code{long double} is aligned on 16-byte boundary.
32581
32582Notice that neither of these options enable any extra precision over the x87
32583standard of 80 bits for a @code{long double}.
32584
32585@strong{Warning:} if you override the default value for your target ABI, this
32586changes the size of
32587structures and arrays containing @code{long double} variables,
32588as well as modifying the function calling convention for functions taking
32589@code{long double}. Hence they are not binary-compatible
32590with code compiled without that switch.
32591
32592@item -mlong-double-64
32593@itemx -mlong-double-80
32594@itemx -mlong-double-128
32595@opindex mlong-double-64
32596@opindex mlong-double-80
32597@opindex mlong-double-128
32598These switches control the size of @code{long double} type. A size
32599of 64 bits makes the @code{long double} type equivalent to the @code{double}
32600type. This is the default for 32-bit Bionic C library. A size
32601of 128 bits makes the @code{long double} type equivalent to the
32602@code{__float128} type. This is the default for 64-bit Bionic C library.
32603
32604@strong{Warning:} if you override the default value for your target ABI, this
32605changes the size of
32606structures and arrays containing @code{long double} variables,
32607as well as modifying the function calling convention for functions taking
32608@code{long double}. Hence they are not binary-compatible
32609with code compiled without that switch.
32610
32611@item -malign-data=@var{type}
32612@opindex malign-data
32613Control how GCC aligns variables. Supported values for @var{type} are
32614@samp{compat} uses increased alignment value compatible uses GCC 4.8
32615and earlier, @samp{abi} uses alignment value as specified by the
32616psABI, and @samp{cacheline} uses increased alignment value to match
32617the cache line size. @samp{compat} is the default.
32618
32619@item -mlarge-data-threshold=@var{threshold}
32620@opindex mlarge-data-threshold
32621When @option{-mcmodel=medium} is specified, data objects larger than
32622@var{threshold} are placed in the large data section. This value must be the
32623same across all objects linked into the binary, and defaults to 65535.
32624
32625@item -mrtd
32626@opindex mrtd
32627Use a different function-calling convention, in which functions that
32628take a fixed number of arguments return with the @code{ret @var{num}}
32629instruction, which pops their arguments while returning. This saves one
32630instruction in the caller since there is no need to pop the arguments
32631there.
32632
32633You can specify that an individual function is called with this calling
32634sequence with the function attribute @code{stdcall}. You can also
32635override the @option{-mrtd} option by using the function attribute
32636@code{cdecl}. @xref{Function Attributes}.
32637
32638@strong{Warning:} this calling convention is incompatible with the one
32639normally used on Unix, so you cannot use it if you need to call
32640libraries compiled with the Unix compiler.
32641
32642Also, you must provide function prototypes for all functions that
32643take variable numbers of arguments (including @code{printf});
32644otherwise incorrect code is generated for calls to those
32645functions.
32646
32647In addition, seriously incorrect code results if you call a
32648function with too many arguments. (Normally, extra arguments are
32649harmlessly ignored.)
32650
32651@item -mregparm=@var{num}
32652@opindex mregparm
32653Control how many registers are used to pass integer arguments. By
32654default, no registers are used to pass arguments, and at most 3
32655registers can be used. You can control this behavior for a specific
32656function by using the function attribute @code{regparm}.
32657@xref{Function Attributes}.
32658
32659@strong{Warning:} if you use this switch, and
32660@var{num} is nonzero, then you must build all modules with the same
32661value, including any libraries. This includes the system libraries and
32662startup modules.
32663
32664@item -msseregparm
32665@opindex msseregparm
32666Use SSE register passing conventions for float and double arguments
32667and return values. You can control this behavior for a specific
32668function by using the function attribute @code{sseregparm}.
32669@xref{Function Attributes}.
32670
32671@strong{Warning:} if you use this switch then you must build all
32672modules with the same value, including any libraries. This includes
32673the system libraries and startup modules.
32674
32675@item -mvect8-ret-in-mem
32676@opindex mvect8-ret-in-mem
32677Return 8-byte vectors in memory instead of MMX registers. This is the
32678default on VxWorks to match the ABI of the Sun Studio compilers until
32679version 12. @emph{Only} use this option if you need to remain
32680compatible with existing code produced by those previous compiler
32681versions or older versions of GCC@.
32682
32683@item -mpc32
32684@itemx -mpc64
32685@itemx -mpc80
32686@opindex mpc32
32687@opindex mpc64
32688@opindex mpc80
32689
32690Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
32691is specified, the significands of results of floating-point operations are
32692rounded to 24 bits (single precision); @option{-mpc64} rounds the
32693significands of results of floating-point operations to 53 bits (double
32694precision) and @option{-mpc80} rounds the significands of results of
32695floating-point operations to 64 bits (extended double precision), which is
32696the default. When this option is used, floating-point operations in higher
32697precisions are not available to the programmer without setting the FPU
32698control word explicitly.
32699
32700Setting the rounding of floating-point operations to less than the default
3270180 bits can speed some programs by 2% or more. Note that some mathematical
32702libraries assume that extended-precision (80-bit) floating-point operations
32703are enabled by default; routines in such libraries could suffer significant
32704loss of accuracy, typically through so-called ``catastrophic cancellation'',
32705when this option is used to set the precision to less than extended precision.
32706
32707@item -mstackrealign
32708@opindex mstackrealign
32709Realign the stack at entry. On the x86, the @option{-mstackrealign}
32710option generates an alternate prologue and epilogue that realigns the
32711run-time stack if necessary. This supports mixing legacy codes that keep
327124-byte stack alignment with modern codes that keep 16-byte stack alignment for
32713SSE compatibility. See also the attribute @code{force_align_arg_pointer},
32714applicable to individual functions.
32715
32716@item -mpreferred-stack-boundary=@var{num}
32717@opindex mpreferred-stack-boundary
32718Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
32719byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
32720the default is 4 (16 bytes or 128 bits).
32721
32722@strong{Warning:} When generating code for the x86-64 architecture with
32723SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
32724used to keep the stack boundary aligned to 8 byte boundary. Since
32725x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
32726intended to be used in controlled environment where stack space is
32727important limitation. This option leads to wrong code when functions
32728compiled with 16 byte stack alignment (such as functions from a standard
32729library) are called with misaligned stack. In this case, SSE
32730instructions may lead to misaligned memory access traps. In addition,
32731variable arguments are handled incorrectly for 16 byte aligned
32732objects (including x87 long double and __int128), leading to wrong
32733results. You must build all modules with
32734@option{-mpreferred-stack-boundary=3}, including any libraries. This
32735includes the system libraries and startup modules.
32736
32737@item -mincoming-stack-boundary=@var{num}
32738@opindex mincoming-stack-boundary
32739Assume the incoming stack is aligned to a 2 raised to @var{num} byte
32740boundary. If @option{-mincoming-stack-boundary} is not specified,
32741the one specified by @option{-mpreferred-stack-boundary} is used.
32742
32743On Pentium and Pentium Pro, @code{double} and @code{long double} values
32744should be aligned to an 8-byte boundary (see @option{-malign-double}) or
32745suffer significant run time performance penalties. On Pentium III, the
32746Streaming SIMD Extension (SSE) data type @code{__m128} may not work
32747properly if it is not 16-byte aligned.
32748
32749To ensure proper alignment of this values on the stack, the stack boundary
32750must be as aligned as that required by any value stored on the stack.
32751Further, every function must be generated such that it keeps the stack
32752aligned. Thus calling a function compiled with a higher preferred
32753stack boundary from a function compiled with a lower preferred stack
32754boundary most likely misaligns the stack. It is recommended that
32755libraries that use callbacks always use the default setting.
32756
32757This extra alignment does consume extra stack space, and generally
32758increases code size. Code that is sensitive to stack space usage, such
32759as embedded systems and operating system kernels, may want to reduce the
32760preferred alignment to @option{-mpreferred-stack-boundary=2}.
32761
32762@need 200
32763@item -mmmx
32764@opindex mmmx
32765@need 200
32766@itemx -msse
32767@opindex msse
32768@need 200
32769@itemx -msse2
32770@opindex msse2
32771@need 200
32772@itemx -msse3
32773@opindex msse3
32774@need 200
32775@itemx -mssse3
32776@opindex mssse3
32777@need 200
32778@itemx -msse4
32779@opindex msse4
32780@need 200
32781@itemx -msse4a
32782@opindex msse4a
32783@need 200
32784@itemx -msse4.1
32785@opindex msse4.1
32786@need 200
32787@itemx -msse4.2
32788@opindex msse4.2
32789@need 200
32790@itemx -mavx
32791@opindex mavx
32792@need 200
32793@itemx -mavx2
32794@opindex mavx2
32795@need 200
32796@itemx -mavx512f
32797@opindex mavx512f
32798@need 200
32799@itemx -mavx512pf
32800@opindex mavx512pf
32801@need 200
32802@itemx -mavx512er
32803@opindex mavx512er
32804@need 200
32805@itemx -mavx512cd
32806@opindex mavx512cd
32807@need 200
32808@itemx -mavx512vl
32809@opindex mavx512vl
32810@need 200
32811@itemx -mavx512bw
32812@opindex mavx512bw
32813@need 200
32814@itemx -mavx512dq
32815@opindex mavx512dq
32816@need 200
32817@itemx -mavx512ifma
32818@opindex mavx512ifma
32819@need 200
32820@itemx -mavx512vbmi
32821@opindex mavx512vbmi
32822@need 200
32823@itemx -msha
32824@opindex msha
32825@need 200
32826@itemx -maes
32827@opindex maes
32828@need 200
32829@itemx -mpclmul
32830@opindex mpclmul
32831@need 200
32832@itemx -mclflushopt
32833@opindex mclflushopt
32834@need 200
32835@itemx -mclwb
32836@opindex mclwb
32837@need 200
32838@itemx -mfsgsbase
32839@opindex mfsgsbase
32840@need 200
32841@itemx -mptwrite
32842@opindex mptwrite
32843@need 200
32844@itemx -mrdrnd
32845@opindex mrdrnd
32846@need 200
32847@itemx -mf16c
32848@opindex mf16c
32849@need 200
32850@itemx -mfma
32851@opindex mfma
32852@need 200
32853@itemx -mpconfig
32854@opindex mpconfig
32855@need 200
32856@itemx -mwbnoinvd
32857@opindex mwbnoinvd
32858@need 200
32859@itemx -mfma4
32860@opindex mfma4
32861@need 200
32862@itemx -mprfchw
32863@opindex mprfchw
32864@need 200
32865@itemx -mrdpid
32866@opindex mrdpid
32867@need 200
32868@itemx -mprefetchwt1
32869@opindex mprefetchwt1
32870@need 200
32871@itemx -mrdseed
32872@opindex mrdseed
32873@need 200
32874@itemx -msgx
32875@opindex msgx
32876@need 200
32877@itemx -mxop
32878@opindex mxop
32879@need 200
32880@itemx -mlwp
32881@opindex mlwp
32882@need 200
32883@itemx -m3dnow
32884@opindex m3dnow
32885@need 200
32886@itemx -m3dnowa
32887@opindex m3dnowa
32888@need 200
32889@itemx -mpopcnt
32890@opindex mpopcnt
32891@need 200
32892@itemx -mabm
32893@opindex mabm
32894@need 200
32895@itemx -madx
32896@opindex madx
32897@need 200
32898@itemx -mbmi
32899@opindex mbmi
32900@need 200
32901@itemx -mbmi2
32902@opindex mbmi2
32903@need 200
32904@itemx -mlzcnt
32905@opindex mlzcnt
32906@need 200
32907@itemx -mfxsr
32908@opindex mfxsr
32909@need 200
32910@itemx -mxsave
32911@opindex mxsave
32912@need 200
32913@itemx -mxsaveopt
32914@opindex mxsaveopt
32915@need 200
32916@itemx -mxsavec
32917@opindex mxsavec
32918@need 200
32919@itemx -mxsaves
32920@opindex mxsaves
32921@need 200
32922@itemx -mrtm
32923@opindex mrtm
32924@need 200
32925@itemx -mhle
32926@opindex mhle
32927@need 200
32928@itemx -mtbm
32929@opindex mtbm
32930@need 200
32931@itemx -mmwaitx
32932@opindex mmwaitx
32933@need 200
32934@itemx -mclzero
32935@opindex mclzero
32936@need 200
32937@itemx -mpku
32938@opindex mpku
32939@need 200
32940@itemx -mavx512vbmi2
32941@opindex mavx512vbmi2
32942@need 200
32943@itemx -mavx512bf16
32944@opindex mavx512bf16
32945@need 200
32946@itemx -mavx512fp16
32947@opindex mavx512fp16
32948@need 200
32949@itemx -mgfni
32950@opindex mgfni
32951@need 200
32952@itemx -mvaes
32953@opindex mvaes
32954@need 200
32955@itemx -mwaitpkg
32956@opindex mwaitpkg
32957@need 200
32958@itemx -mvpclmulqdq
32959@opindex mvpclmulqdq
32960@need 200
32961@itemx -mavx512bitalg
32962@opindex mavx512bitalg
32963@need 200
32964@itemx -mmovdiri
32965@opindex mmovdiri
32966@need 200
32967@itemx -mmovdir64b
32968@opindex mmovdir64b
32969@need 200
32970@itemx -menqcmd
32971@opindex menqcmd
32972@itemx -muintr
32973@opindex muintr
32974@need 200
32975@itemx -mtsxldtrk
32976@opindex mtsxldtrk
32977@need 200
32978@itemx -mavx512vpopcntdq
32979@opindex mavx512vpopcntdq
32980@need 200
32981@itemx -mavx512vp2intersect
32982@opindex mavx512vp2intersect
32983@need 200
32984@itemx -mavx5124fmaps
32985@opindex mavx5124fmaps
32986@need 200
32987@itemx -mavx512vnni
32988@opindex mavx512vnni
32989@need 200
32990@itemx -mavxvnni
32991@opindex mavxvnni
32992@need 200
32993@itemx -mavx5124vnniw
32994@opindex mavx5124vnniw
32995@need 200
32996@itemx -mcldemote
32997@opindex mcldemote
32998@need 200
32999@itemx -mserialize
33000@opindex mserialize
33001@need 200
33002@itemx -mamx-tile
33003@opindex mamx-tile
33004@need 200
33005@itemx -mamx-int8
33006@opindex mamx-int8
33007@need 200
33008@itemx -mamx-bf16
33009@opindex mamx-bf16
33010@need 200
33011@itemx -mhreset
33012@opindex mhreset
33013@itemx -mkl
33014@opindex mkl
33015@need 200
33016@itemx -mwidekl
33017@opindex mwidekl
33018@need 200
33019@itemx -mavxifma
33020@opindex mavxifma
33021@need 200
33022@itemx -mavxvnniint8
33023@opindex mavxvnniint8
33024@need 200
33025@itemx -mavxneconvert
33026@opindex mavxneconvert
33027@need 200
33028@itemx -mcmpccxadd
33029@opindex mcmpccxadd
33030@need 200
33031@itemx -mamx-fp16
33032@opindex mamx-fp16
33033@need 200
33034@itemx -mprefetchi
33035@opindex mprefetchi
33036@need 200
33037@itemx -mraoint
33038@opindex mraoint
33039These switches enable the use of instructions in the MMX, SSE,
33040SSE2, SSE3, SSSE3, SSE4, SSE4A, SSE4.1, SSE4.2, AVX, AVX2, AVX512F, AVX512PF,
33041AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA,
33042AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
33043WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP,
330443DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE,
33045XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2,
33046GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16,
33047ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE,
33048UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512FP16,
33049AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT or
33050CLDEMOTE extended instruction sets. Each has a corresponding @option{-mno-}
33051option to disable use of these instructions.
33052
33053These extensions are also available as built-in functions: see
33054@ref{x86 Built-in Functions}, for details of the functions enabled and
33055disabled by these switches.
33056
33057To generate SSE/SSE2 instructions automatically from floating-point
33058code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
33059
33060GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
33061generates new AVX instructions or AVX equivalence for all SSEx instructions
33062when needed.
33063
33064These options enable GCC to use these extended instructions in
33065generated code, even without @option{-mfpmath=sse}. Applications that
33066perform run-time CPU detection must compile separate files for each
33067supported architecture, using the appropriate flags. In particular,
33068the file containing the CPU detection code should be compiled without
33069these options.
33070
33071@item -mdump-tune-features
33072@opindex mdump-tune-features
33073This option instructs GCC to dump the names of the x86 performance
33074tuning features and default settings. The names can be used in
33075@option{-mtune-ctrl=@var{feature-list}}.
33076
33077@item -mtune-ctrl=@var{feature-list}
33078@opindex mtune-ctrl=@var{feature-list}
33079This option is used to do fine grain control of x86 code generation features.
33080@var{feature-list} is a comma separated list of @var{feature} names. See also
33081@option{-mdump-tune-features}. When specified, the @var{feature} is turned
33082on if it is not preceded with @samp{^}, otherwise, it is turned off.
33083@option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
33084developers. Using it may lead to code paths not covered by testing and can
33085potentially result in compiler ICEs or runtime errors.
33086
33087@item -mno-default
33088@opindex mno-default
33089This option instructs GCC to turn off all tunable features. See also
33090@option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
33091
33092@item -mcld
33093@opindex mcld
33094This option instructs GCC to emit a @code{cld} instruction in the prologue
33095of functions that use string instructions. String instructions depend on
33096the DF flag to select between autoincrement or autodecrement mode. While the
33097ABI specifies the DF flag to be cleared on function entry, some operating
33098systems violate this specification by not clearing the DF flag in their
33099exception dispatchers. The exception handler can be invoked with the DF flag
33100set, which leads to wrong direction mode when string instructions are used.
33101This option can be enabled by default on 32-bit x86 targets by configuring
33102GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
33103instructions can be suppressed with the @option{-mno-cld} compiler option
33104in this case.
33105
33106@item -mvzeroupper
33107@opindex mvzeroupper
33108This option instructs GCC to emit a @code{vzeroupper} instruction
33109before a transfer of control flow out of the function to minimize
33110the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
33111intrinsics.
33112
33113@item -mprefer-avx128
33114@opindex mprefer-avx128
33115This option instructs GCC to use 128-bit AVX instructions instead of
33116256-bit AVX instructions in the auto-vectorizer.
33117
33118@item -mprefer-vector-width=@var{opt}
33119@opindex mprefer-vector-width
33120This option instructs GCC to use @var{opt}-bit vector width in instructions
33121instead of default on the selected platform.
33122
33123@item -mmove-max=@var{bits}
33124@opindex mmove-max
33125This option instructs GCC to set the maximum number of bits can be
33126moved from memory to memory efficiently to @var{bits}. The valid
33127@var{bits} are 128, 256 and 512.
33128
33129@item -mstore-max=@var{bits}
33130@opindex mstore-max
33131This option instructs GCC to set the maximum number of bits can be
33132stored to memory efficiently to @var{bits}. The valid @var{bits} are
33133128, 256 and 512.
33134
33135@table @samp
33136@item none
33137No extra limitations applied to GCC other than defined by the selected platform.
33138
33139@item 128
33140Prefer 128-bit vector width for instructions.
33141
33142@item 256
33143Prefer 256-bit vector width for instructions.
33144
33145@item 512
33146Prefer 512-bit vector width for instructions.
33147@end table
33148
33149@item -mcx16
33150@opindex mcx16
33151This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
33152code to implement compare-and-exchange operations on 16-byte aligned 128-bit
33153objects. This is useful for atomic updates of data structures exceeding one
33154machine word in size. The compiler uses this instruction to implement
33155@ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
33156128-bit integers, a library call is always used.
33157
33158@item -msahf
33159@opindex msahf
33160This option enables generation of @code{SAHF} instructions in 64-bit code.
33161Early Intel Pentium 4 CPUs with Intel 64 support,
33162prior to the introduction of Pentium 4 G1 step in December 2005,
33163lacked the @code{LAHF} and @code{SAHF} instructions
33164which are supported by AMD64.
33165These are load and store instructions, respectively, for certain status flags.
33166In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
33167@code{drem}, and @code{remainder} built-in functions;
33168see @ref{Other Builtins} for details.
33169
33170@item -mmovbe
33171@opindex mmovbe
33172This option enables use of the @code{movbe} instruction to implement
33173@code{__builtin_bswap32} and @code{__builtin_bswap64}.
33174
33175@item -mshstk
33176@opindex mshstk
33177The @option{-mshstk} option enables shadow stack built-in functions
33178from x86 Control-flow Enforcement Technology (CET).
33179
33180@item -mcrc32
33181@opindex mcrc32
33182This option enables built-in functions @code{__builtin_ia32_crc32qi},
33183@code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
33184@code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
33185
33186@item -mmwait
33187@opindex mmwait
33188This option enables built-in functions @code{__builtin_ia32_monitor},
33189and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
33190@code{mwait} machine instructions.
33191
33192@item -mrecip
33193@opindex mrecip
33194This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
33195(and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
33196with an additional Newton-Raphson step
33197to increase precision instead of @code{DIVSS} and @code{SQRTSS}
33198(and their vectorized
33199variants) for single-precision floating-point arguments. These instructions
33200are generated only when @option{-funsafe-math-optimizations} is enabled
33201together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
33202Note that while the throughput of the sequence is higher than the throughput
33203of the non-reciprocal instruction, the precision of the sequence can be
33204decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
33205
33206Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
33207(or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
33208combination), and doesn't need @option{-mrecip}.
33209
33210Also note that GCC emits the above sequence with additional Newton-Raphson step
33211for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
33212already with @option{-ffast-math} (or the above option combination), and
33213doesn't need @option{-mrecip}.
33214
33215@item -mrecip=@var{opt}
33216@opindex mrecip=opt
33217This option controls which reciprocal estimate instructions
33218may be used. @var{opt} is a comma-separated list of options, which may
33219be preceded by a @samp{!} to invert the option:
33220
33221@table @samp
33222@item all
33223Enable all estimate instructions.
33224
33225@item default
33226Enable the default instructions, equivalent to @option{-mrecip}.
33227
33228@item none
33229Disable all estimate instructions, equivalent to @option{-mno-recip}.
33230
33231@item div
33232Enable the approximation for scalar division.
33233
33234@item vec-div
33235Enable the approximation for vectorized division.
33236
33237@item sqrt
33238Enable the approximation for scalar square root.
33239
33240@item vec-sqrt
33241Enable the approximation for vectorized square root.
33242@end table
33243
33244So, for example, @option{-mrecip=all,!sqrt} enables
33245all of the reciprocal approximations, except for square root.
33246
33247@item -mveclibabi=@var{type}
33248@opindex mveclibabi
33249Specifies the ABI type to use for vectorizing intrinsics using an
33250external library. Supported values for @var{type} are @samp{svml}
33251for the Intel short
33252vector math library and @samp{acml} for the AMD math core library.
33253To use this option, both @option{-ftree-vectorize} and
33254@option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
33255ABI-compatible library must be specified at link time.
33256
33257GCC currently emits calls to @code{vmldExp2},
33258@code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2},
33259@code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2},
33260@code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2},
33261@code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2},
33262@code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4},
33263@code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4},
33264@code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4},
33265@code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4},
33266@code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding
33267function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin},
33268@code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
33269@code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
33270@code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
33271@code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
33272when @option{-mveclibabi=acml} is used.
33273
33274@item -mabi=@var{name}
33275@opindex mabi
33276Generate code for the specified calling convention. Permissible values
33277are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
33278@samp{ms} for the Microsoft ABI. The default is to use the Microsoft
33279ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
33280You can control this behavior for specific functions by
33281using the function attributes @code{ms_abi} and @code{sysv_abi}.
33282@xref{Function Attributes}.
33283
33284@item -mforce-indirect-call
33285@opindex mforce-indirect-call
33286Force all calls to functions to be indirect. This is useful
33287when using Intel Processor Trace where it generates more precise timing
33288information for function calls.
33289
33290@item -mmanual-endbr
33291@opindex mmanual-endbr
33292Insert ENDBR instruction at function entry only via the @code{cf_check}
33293function attribute. This is useful when used with the option
33294@option{-fcf-protection=branch} to control ENDBR insertion at the
33295function entry.
33296
33297@item -mcet-switch
33298@opindex mcet-switch
33299By default, CET instrumentation is turned off on switch statements that
33300use a jump table and indirect branch track is disabled. Since jump
33301tables are stored in read-only memory, this does not result in a direct
33302loss of hardening. But if the jump table index is attacker-controlled,
33303the indirect jump may not be constrained by CET. This option turns on
33304CET instrumentation to enable indirect branch track for switch statements
33305with jump tables which leads to the jump targets reachable via any indirect
33306jumps.
33307
33308@item -mcall-ms2sysv-xlogues
33309@opindex mcall-ms2sysv-xlogues
33310@opindex mno-call-ms2sysv-xlogues
33311Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
33312System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
33313default, the code for saving and restoring these registers is emitted inline,
33314resulting in fairly lengthy prologues and epilogues. Using
33315@option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
33316use stubs in the static portion of libgcc to perform these saves and restores,
33317thus reducing function size at the cost of a few extra instructions.
33318
33319@item -mtls-dialect=@var{type}
33320@opindex mtls-dialect
33321Generate code to access thread-local storage using the @samp{gnu} or
33322@samp{gnu2} conventions. @samp{gnu} is the conservative default;
33323@samp{gnu2} is more efficient, but it may add compile- and run-time
33324requirements that cannot be satisfied on all systems.
33325
33326@item -mpush-args
33327@itemx -mno-push-args
33328@opindex mpush-args
33329@opindex mno-push-args
33330Use PUSH operations to store outgoing parameters. This method is shorter
33331and usually equally fast as method using SUB/MOV operations and is enabled
33332by default. In some cases disabling it may improve performance because of
33333improved scheduling and reduced dependencies.
33334
33335@item -maccumulate-outgoing-args
33336@opindex maccumulate-outgoing-args
33337If enabled, the maximum amount of space required for outgoing arguments is
33338computed in the function prologue. This is faster on most modern CPUs
33339because of reduced dependencies, improved scheduling and reduced stack usage
33340when the preferred stack boundary is not equal to 2. The drawback is a notable
33341increase in code size. This switch implies @option{-mno-push-args}.
33342
33343@item -mthreads
33344@opindex mthreads
33345Support thread-safe exception handling on MinGW. Programs that rely
33346on thread-safe exception handling must compile and link all code with the
33347@option{-mthreads} option. When compiling, @option{-mthreads} defines
33348@option{-D_MT}; when linking, it links in a special thread helper library
33349@option{-lmingwthrd} which cleans up per-thread exception-handling data.
33350
33351@item -mms-bitfields
33352@itemx -mno-ms-bitfields
33353@opindex mms-bitfields
33354@opindex mno-ms-bitfields
33355
33356Enable/disable bit-field layout compatible with the native Microsoft
33357Windows compiler.
33358
33359If @code{packed} is used on a structure, or if bit-fields are used,
33360it may be that the Microsoft ABI lays out the structure differently
33361than the way GCC normally does. Particularly when moving packed
33362data between functions compiled with GCC and the native Microsoft compiler
33363(either via function call or as data in a file), it may be necessary to access
33364either format.
33365
33366This option is enabled by default for Microsoft Windows
33367targets. This behavior can also be controlled locally by use of variable
33368or type attributes. For more information, see @ref{x86 Variable Attributes}
33369and @ref{x86 Type Attributes}.
33370
33371The Microsoft structure layout algorithm is fairly simple with the exception
33372of the bit-field packing.
33373The padding and alignment of members of structures and whether a bit-field
33374can straddle a storage-unit boundary are determine by these rules:
33375
33376@enumerate
33377@item Structure members are stored sequentially in the order in which they are
33378declared: the first member has the lowest memory address and the last member
33379the highest.
33380
33381@item Every data object has an alignment requirement. The alignment requirement
33382for all data except structures, unions, and arrays is either the size of the
33383object or the current packing size (specified with either the
33384@code{aligned} attribute or the @code{pack} pragma),
33385whichever is less. For structures, unions, and arrays,
33386the alignment requirement is the largest alignment requirement of its members.
33387Every object is allocated an offset so that:
33388
33389@smallexample
33390offset % alignment_requirement == 0
33391@end smallexample
33392
33393@item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
33394unit if the integral types are the same size and if the next bit-field fits
33395into the current allocation unit without crossing the boundary imposed by the
33396common alignment requirements of the bit-fields.
33397@end enumerate
33398
33399MSVC interprets zero-length bit-fields in the following ways:
33400
33401@enumerate
33402@item If a zero-length bit-field is inserted between two bit-fields that
33403are normally coalesced, the bit-fields are not coalesced.
33404
33405For example:
33406
33407@smallexample
33408struct
33409 @{
33410 unsigned long bf_1 : 12;
33411 unsigned long : 0;
33412 unsigned long bf_2 : 12;
33413 @} t1;
33414@end smallexample
33415
33416@noindent
33417The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
33418zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
33419
33420@item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
33421alignment of the zero-length bit-field is greater than the member that follows it,
33422@code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
33423
33424For example:
33425
33426@smallexample
33427struct
33428 @{
33429 char foo : 4;
33430 short : 0;
33431 char bar;
33432 @} t2;
33433
33434struct
33435 @{
33436 char foo : 4;
33437 short : 0;
33438 double bar;
33439 @} t3;
33440@end smallexample
33441
33442@noindent
33443For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
33444Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
33445bit-field does not affect the alignment of @code{bar} or, as a result, the size
33446of the structure.
33447
33448Taking this into account, it is important to note the following:
33449
33450@enumerate
33451@item If a zero-length bit-field follows a normal bit-field, the type of the
33452zero-length bit-field may affect the alignment of the structure as whole. For
33453example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
33454normal bit-field, and is of type short.
33455
33456@item Even if a zero-length bit-field is not followed by a normal bit-field, it may
33457still affect the alignment of the structure:
33458
33459@smallexample
33460struct
33461 @{
33462 char foo : 6;
33463 long : 0;
33464 @} t4;
33465@end smallexample
33466
33467@noindent
33468Here, @code{t4} takes up 4 bytes.
33469@end enumerate
33470
33471@item Zero-length bit-fields following non-bit-field members are ignored:
33472
33473@smallexample
33474struct
33475 @{
33476 char foo;
33477 long : 0;
33478 char bar;
33479 @} t5;
33480@end smallexample
33481
33482@noindent
33483Here, @code{t5} takes up 2 bytes.
33484@end enumerate
33485
33486
33487@item -mno-align-stringops
33488@opindex mno-align-stringops
33489@opindex malign-stringops
33490Do not align the destination of inlined string operations. This switch reduces
33491code size and improves performance in case the destination is already aligned,
33492but GCC doesn't know about it.
33493
33494@item -minline-all-stringops
33495@opindex minline-all-stringops
33496By default GCC inlines string operations only when the destination is
33497known to be aligned to least a 4-byte boundary.
33498This enables more inlining and increases code
33499size, but may improve performance of code that depends on fast
33500@code{memcpy} and @code{memset} for short lengths.
33501The option enables inline expansion of @code{strlen} for all
33502pointer alignments.
33503
33504@item -minline-stringops-dynamically
33505@opindex minline-stringops-dynamically
33506For string operations of unknown size, use run-time checks with
33507inline code for small blocks and a library call for large blocks.
33508
33509@item -mstringop-strategy=@var{alg}
33510@opindex mstringop-strategy=@var{alg}
33511Override the internal decision heuristic for the particular algorithm to use
33512for inlining string operations. The allowed values for @var{alg} are:
33513
33514@table @samp
33515@item rep_byte
33516@itemx rep_4byte
33517@itemx rep_8byte
33518Expand using i386 @code{rep} prefix of the specified size.
33519
33520@item byte_loop
33521@itemx loop
33522@itemx unrolled_loop
33523Expand into an inline loop.
33524
33525@item libcall
33526Always use a library call.
33527@end table
33528
33529@item -mmemcpy-strategy=@var{strategy}
33530@opindex mmemcpy-strategy=@var{strategy}
33531Override the internal decision heuristic to decide if @code{__builtin_memcpy}
33532should be inlined and what inline algorithm to use when the expected size
33533of the copy operation is known. @var{strategy}
33534is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
33535@var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
33536the max byte size with which inline algorithm @var{alg} is allowed. For the last
33537triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
33538in the list must be specified in increasing order. The minimal byte size for
33539@var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
33540preceding range.
33541
33542@item -mmemset-strategy=@var{strategy}
33543@opindex mmemset-strategy=@var{strategy}
33544The option is similar to @option{-mmemcpy-strategy=} except that it is to control
33545@code{__builtin_memset} expansion.
33546
33547@item -momit-leaf-frame-pointer
33548@opindex momit-leaf-frame-pointer
33549Don't keep the frame pointer in a register for leaf functions. This
33550avoids the instructions to save, set up, and restore frame pointers and
33551makes an extra register available in leaf functions. The option
33552@option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
33553which might make debugging harder.
33554
33555@item -mtls-direct-seg-refs
33556@itemx -mno-tls-direct-seg-refs
33557@opindex mtls-direct-seg-refs
33558Controls whether TLS variables may be accessed with offsets from the
33559TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
33560or whether the thread base pointer must be added. Whether or not this
33561is valid depends on the operating system, and whether it maps the
33562segment to cover the entire TLS area.
33563
33564For systems that use the GNU C Library, the default is on.
33565
33566@item -msse2avx
33567@itemx -mno-sse2avx
33568@opindex msse2avx
33569Specify that the assembler should encode SSE instructions with VEX
33570prefix. The option @option{-mavx} turns this on by default.
33571
33572@item -mfentry
33573@itemx -mno-fentry
33574@opindex mfentry
33575If profiling is active (@option{-pg}), put the profiling
33576counter call before the prologue.
33577Note: On x86 architectures the attribute @code{ms_hook_prologue}
33578isn't possible at the moment for @option{-mfentry} and @option{-pg}.
33579
33580@item -mrecord-mcount
33581@itemx -mno-record-mcount
33582@opindex mrecord-mcount
33583If profiling is active (@option{-pg}), generate a __mcount_loc section
33584that contains pointers to each profiling call. This is useful for
33585automatically patching and out calls.
33586
33587@item -mnop-mcount
33588@itemx -mno-nop-mcount
33589@opindex mnop-mcount
33590If profiling is active (@option{-pg}), generate the calls to
33591the profiling functions as NOPs. This is useful when they
33592should be patched in later dynamically. This is likely only
33593useful together with @option{-mrecord-mcount}.
33594
33595@item -minstrument-return=@var{type}
33596@opindex minstrument-return
33597Instrument function exit in -pg -mfentry instrumented functions with
33598call to specified function. This only instruments true returns ending
33599with ret, but not sibling calls ending with jump. Valid types
33600are @var{none} to not instrument, @var{call} to generate a call to __return__,
33601or @var{nop5} to generate a 5 byte nop.
33602
33603@item -mrecord-return
33604@itemx -mno-record-return
33605@opindex mrecord-return
33606Generate a __return_loc section pointing to all return instrumentation code.
33607
33608@item -mfentry-name=@var{name}
33609@opindex mfentry-name
33610Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
33611
33612@item -mfentry-section=@var{name}
33613@opindex mfentry-section
33614Set name of section to record -mrecord-mcount calls (default __mcount_loc).
33615
33616@item -mskip-rax-setup
33617@itemx -mno-skip-rax-setup
33618@opindex mskip-rax-setup
33619When generating code for the x86-64 architecture with SSE extensions
33620disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
33621register when there are no variable arguments passed in vector registers.
33622
33623@strong{Warning:} Since RAX register is used to avoid unnecessarily
33624saving vector registers on stack when passing variable arguments, the
33625impacts of this option are callees may waste some stack space,
33626misbehave or jump to a random location. GCC 4.4 or newer don't have
33627those issues, regardless the RAX register value.
33628
33629@item -m8bit-idiv
33630@itemx -mno-8bit-idiv
33631@opindex m8bit-idiv
33632On some processors, like Intel Atom, 8-bit unsigned integer divide is
33633much faster than 32-bit/64-bit integer divide. This option generates a
33634run-time check. If both dividend and divisor are within range of 0
33635to 255, 8-bit unsigned integer divide is used instead of
3363632-bit/64-bit integer divide.
33637
33638@item -mavx256-split-unaligned-load
33639@itemx -mavx256-split-unaligned-store
33640@opindex mavx256-split-unaligned-load
33641@opindex mavx256-split-unaligned-store
33642Split 32-byte AVX unaligned load and store.
33643
33644@item -mstack-protector-guard=@var{guard}
33645@itemx -mstack-protector-guard-reg=@var{reg}
33646@itemx -mstack-protector-guard-offset=@var{offset}
33647@opindex mstack-protector-guard
33648@opindex mstack-protector-guard-reg
33649@opindex mstack-protector-guard-offset
33650Generate stack protection code using canary at @var{guard}. Supported
33651locations are @samp{global} for global canary or @samp{tls} for per-thread
33652canary in the TLS block (the default). This option has effect only when
33653@option{-fstack-protector} or @option{-fstack-protector-all} is specified.
33654
33655With the latter choice the options
33656@option{-mstack-protector-guard-reg=@var{reg}} and
33657@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
33658which segment register (@code{%fs} or @code{%gs}) to use as base register
33659for reading the canary, and from what offset from that base register.
33660The default for those is as specified in the relevant ABI.
33661
33662@item -mgeneral-regs-only
33663@opindex mgeneral-regs-only
33664Generate code that uses only the general-purpose registers. This
33665prevents the compiler from using floating-point, vector, mask and bound
33666registers.
33667
33668@item -mrelax-cmpxchg-loop
33669@opindex mrelax-cmpxchg-loop
85966f0d
AM
33670When emitting a compare-and-swap loop for @ref{__sync Builtins}
33671and @ref{__atomic Builtins} lacking a native instruction, optimize
33672for the highly contended case by issuing an atomic load before the
33673@code{CMPXCHG} instruction, and using the @code{PAUSE} instruction
33674to save CPU power when restarting the loop.
d77de738
ML
33675
33676@item -mindirect-branch=@var{choice}
33677@opindex mindirect-branch
33678Convert indirect call and jump with @var{choice}. The default is
33679@samp{keep}, which keeps indirect call and jump unmodified.
33680@samp{thunk} converts indirect call and jump to call and return thunk.
33681@samp{thunk-inline} converts indirect call and jump to inlined call
33682and return thunk. @samp{thunk-extern} converts indirect call and jump
33683to external call and return thunk provided in a separate object file.
33684You can control this behavior for a specific function by using the
33685function attribute @code{indirect_branch}. @xref{Function Attributes}.
33686
33687Note that @option{-mcmodel=large} is incompatible with
33688@option{-mindirect-branch=thunk} and
33689@option{-mindirect-branch=thunk-extern} since the thunk function may
33690not be reachable in the large code model.
33691
33692Note that @option{-mindirect-branch=thunk-extern} is compatible with
33693@option{-fcf-protection=branch} since the external thunk can be made
33694to enable control-flow check.
33695
33696@item -mfunction-return=@var{choice}
33697@opindex mfunction-return
33698Convert function return with @var{choice}. The default is @samp{keep},
33699which keeps function return unmodified. @samp{thunk} converts function
33700return to call and return thunk. @samp{thunk-inline} converts function
33701return to inlined call and return thunk. @samp{thunk-extern} converts
33702function return to external call and return thunk provided in a separate
33703object file. You can control this behavior for a specific function by
33704using the function attribute @code{function_return}.
33705@xref{Function Attributes}.
33706
33707Note that @option{-mindirect-return=thunk-extern} is compatible with
33708@option{-fcf-protection=branch} since the external thunk can be made
33709to enable control-flow check.
33710
33711Note that @option{-mcmodel=large} is incompatible with
33712@option{-mfunction-return=thunk} and
33713@option{-mfunction-return=thunk-extern} since the thunk function may
33714not be reachable in the large code model.
33715
33716
33717@item -mindirect-branch-register
33718@opindex mindirect-branch-register
33719Force indirect call and jump via register.
33720
33721@item -mharden-sls=@var{choice}
33722@opindex mharden-sls
33723Generate code to mitigate against straight line speculation (SLS) with
33724@var{choice}. The default is @samp{none} which disables all SLS
33725hardening. @samp{return} enables SLS hardening for function returns.
33726@samp{indirect-jmp} enables SLS hardening for indirect jumps.
33727@samp{all} enables all SLS hardening.
33728
33729@item -mindirect-branch-cs-prefix
33730@opindex mindirect-branch-cs-prefix
33731Add CS prefix to call and jmp to indirect thunk with branch target in
33732r8-r15 registers so that the call and jmp instruction length is 6 bytes
33733to allow them to be replaced with @samp{lfence; call *%r8-r15} or
33734@samp{lfence; jmp *%r8-r15} at run-time.
33735
33736@end table
33737
33738These @samp{-m} switches are supported in addition to the above
33739on x86-64 processors in 64-bit environments.
33740
33741@table @gcctabopt
33742@item -m32
33743@itemx -m64
33744@itemx -mx32
33745@itemx -m16
33746@itemx -miamcu
33747@opindex m32
33748@opindex m64
33749@opindex mx32
33750@opindex m16
33751@opindex miamcu
33752Generate code for a 16-bit, 32-bit or 64-bit environment.
33753The @option{-m32} option sets @code{int}, @code{long}, and pointer types
33754to 32 bits, and
33755generates code that runs on any i386 system.
33756
33757The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
33758types to 64 bits, and generates code for the x86-64 architecture.
33759For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
33760and @option{-mdynamic-no-pic} options.
33761
33762The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
33763to 32 bits, and
33764generates code for the x86-64 architecture.
33765
33766The @option{-m16} option is the same as @option{-m32}, except for that
33767it outputs the @code{.code16gcc} assembly directive at the beginning of
33768the assembly output so that the binary can run in 16-bit mode.
33769
33770The @option{-miamcu} option generates code which conforms to Intel MCU
33771psABI. It requires the @option{-m32} option to be turned on.
33772
33773@item -mno-red-zone
33774@opindex mno-red-zone
33775@opindex mred-zone
33776Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
33777by the x86-64 ABI; it is a 128-byte area beyond the location of the
33778stack pointer that is not modified by signal or interrupt handlers
33779and therefore can be used for temporary data without adjusting the stack
33780pointer. The flag @option{-mno-red-zone} disables this red zone.
33781
33782@item -mcmodel=small
33783@opindex mcmodel=small
33784Generate code for the small code model: the program and its symbols must
33785be linked in the lower 2 GB of the address space. Pointers are 64 bits.
33786Programs can be statically or dynamically linked. This is the default
33787code model.
33788
33789@item -mcmodel=kernel
33790@opindex mcmodel=kernel
33791Generate code for the kernel code model. The kernel runs in the
33792negative 2 GB of the address space.
33793This model has to be used for Linux kernel code.
33794
33795@item -mcmodel=medium
33796@opindex mcmodel=medium
33797Generate code for the medium model: the program is linked in the lower 2
33798GB of the address space. Small symbols are also placed there. Symbols
33799with sizes larger than @option{-mlarge-data-threshold} are put into
33800large data or BSS sections and can be located above 2GB. Programs can
33801be statically or dynamically linked.
33802
33803@item -mcmodel=large
33804@opindex mcmodel=large
33805Generate code for the large model. This model makes no assumptions
33806about addresses and sizes of sections.
33807
33808@item -maddress-mode=long
33809@opindex maddress-mode=long
33810Generate code for long address mode. This is only supported for 64-bit
33811and x32 environments. It is the default address mode for 64-bit
33812environments.
33813
33814@item -maddress-mode=short
33815@opindex maddress-mode=short
33816Generate code for short address mode. This is only supported for 32-bit
33817and x32 environments. It is the default address mode for 32-bit and
33818x32 environments.
33819
33820@item -mneeded
33821@itemx -mno-needed
33822@opindex mneeded
33823Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
33824indicate the micro-architecture ISA level required to execute the binary.
33825
33826@item -mno-direct-extern-access
33827@opindex mno-direct-extern-access
33828@opindex mdirect-extern-access
33829Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer
33830to access external symbols. With @option{-fpic} or @option{-fPIC},
33831treat access to protected symbols as local symbols. The default is
33832@option{-mdirect-extern-access}.
33833
33834@strong{Warning:} shared libraries compiled with
33835@option{-mno-direct-extern-access} and executable compiled with
33836@option{-mdirect-extern-access} may not be binary compatible if
33837protected symbols are used in shared libraries and executable.
ce51e843
ML
33838
33839@item -munroll-only-small-loops
33840@opindex munroll-only-small-loops
33841@opindex mno-unroll-only-small-loops
33842Controls conservative small loop unrolling. It is default enabled by
33843O2, and unrolls loop with less than 4 insns by 1 time. Explicit
33844-f[no-]unroll-[all-]loops would disable this flag to avoid any
33845unintended unrolling behavior that user does not want.
d77de738
ML
33846@end table
33847
33848@node x86 Windows Options
33849@subsection x86 Windows Options
33850@cindex x86 Windows Options
33851@cindex Windows Options for x86
33852
33853These additional options are available for Microsoft Windows targets:
33854
33855@table @gcctabopt
33856@item -mconsole
33857@opindex mconsole
33858This option
33859specifies that a console application is to be generated, by
33860instructing the linker to set the PE header subsystem type
33861required for console applications.
33862This option is available for Cygwin and MinGW targets and is
33863enabled by default on those targets.
33864
33865@item -mdll
33866@opindex mdll
33867This option is available for Cygwin and MinGW targets. It
33868specifies that a DLL---a dynamic link library---is to be
33869generated, enabling the selection of the required runtime
33870startup object and entry point.
33871
33872@item -mnop-fun-dllimport
33873@opindex mnop-fun-dllimport
33874This option is available for Cygwin and MinGW targets. It
33875specifies that the @code{dllimport} attribute should be ignored.
33876
33877@item -mthreads
33878@opindex mthreads
33879This option is available for MinGW targets. It specifies
33880that MinGW-specific thread support is to be used.
33881
33882@item -municode
33883@opindex municode
33884This option is available for MinGW-w64 targets. It causes
33885the @code{UNICODE} preprocessor macro to be predefined, and
33886chooses Unicode-capable runtime startup code.
33887
33888@item -mwin32
33889@opindex mwin32
33890This option is available for Cygwin and MinGW targets. It
33891specifies that the typical Microsoft Windows predefined macros are to
33892be set in the pre-processor, but does not influence the choice
33893of runtime library/startup code.
33894
33895@item -mwindows
33896@opindex mwindows
33897This option is available for Cygwin and MinGW targets. It
33898specifies that a GUI application is to be generated by
33899instructing the linker to set the PE header subsystem type
33900appropriately.
33901
33902@item -fno-set-stack-executable
33903@opindex fno-set-stack-executable
33904@opindex fset-stack-executable
33905This option is available for MinGW targets. It specifies that
33906the executable flag for the stack used by nested functions isn't
33907set. This is necessary for binaries running in kernel mode of
33908Microsoft Windows, as there the User32 API, which is used to set executable
33909privileges, isn't available.
33910
33911@item -fwritable-relocated-rdata
33912@opindex fno-writable-relocated-rdata
33913@opindex fwritable-relocated-rdata
33914This option is available for MinGW and Cygwin targets. It specifies
33915that relocated-data in read-only section is put into the @code{.data}
33916section. This is a necessary for older runtimes not supporting
33917modification of @code{.rdata} sections for pseudo-relocation.
33918
33919@item -mpe-aligned-commons
33920@opindex mpe-aligned-commons
33921This option is available for Cygwin and MinGW targets. It
33922specifies that the GNU extension to the PE file format that
33923permits the correct alignment of COMMON variables should be
33924used when generating code. It is enabled by default if
33925GCC detects that the target assembler found during configuration
33926supports the feature.
33927@end table
33928
33929See also under @ref{x86 Options} for standard options.
33930
33931@node Xstormy16 Options
33932@subsection Xstormy16 Options
33933@cindex Xstormy16 Options
33934
33935These options are defined for Xstormy16:
33936
33937@table @gcctabopt
33938@item -msim
33939@opindex msim
33940Choose startup files and linker script suitable for the simulator.
33941@end table
33942
33943@node Xtensa Options
33944@subsection Xtensa Options
33945@cindex Xtensa Options
33946
33947These options are supported for Xtensa targets:
33948
33949@table @gcctabopt
33950@item -mconst16
33951@itemx -mno-const16
33952@opindex mconst16
33953@opindex mno-const16
33954Enable or disable use of @code{CONST16} instructions for loading
33955constant values. The @code{CONST16} instruction is currently not a
33956standard option from Tensilica. When enabled, @code{CONST16}
33957instructions are always used in place of the standard @code{L32R}
33958instructions. The use of @code{CONST16} is enabled by default only if
33959the @code{L32R} instruction is not available.
33960
33961@item -mfused-madd
33962@itemx -mno-fused-madd
33963@opindex mfused-madd
33964@opindex mno-fused-madd
33965Enable or disable use of fused multiply/add and multiply/subtract
33966instructions in the floating-point option. This has no effect if the
33967floating-point option is not also enabled. Disabling fused multiply/add
33968and multiply/subtract instructions forces the compiler to use separate
33969instructions for the multiply and add/subtract operations. This may be
33970desirable in some cases where strict IEEE 754-compliant results are
33971required: the fused multiply add/subtract instructions do not round the
33972intermediate result, thereby producing results with @emph{more} bits of
33973precision than specified by the IEEE standard. Disabling fused multiply
33974add/subtract instructions also ensures that the program output is not
33975sensitive to the compiler's ability to combine multiply and add/subtract
33976operations.
33977
33978@item -mserialize-volatile
33979@itemx -mno-serialize-volatile
33980@opindex mserialize-volatile
33981@opindex mno-serialize-volatile
33982When this option is enabled, GCC inserts @code{MEMW} instructions before
33983@code{volatile} memory references to guarantee sequential consistency.
33984The default is @option{-mserialize-volatile}. Use
33985@option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
33986
33987@item -mforce-no-pic
33988@opindex mforce-no-pic
33989For targets, like GNU/Linux, where all user-mode Xtensa code must be
33990position-independent code (PIC), this option disables PIC for compiling
33991kernel code.
33992
33993@item -mtext-section-literals
33994@itemx -mno-text-section-literals
33995@opindex mtext-section-literals
33996@opindex mno-text-section-literals
33997These options control the treatment of literal pools. The default is
33998@option{-mno-text-section-literals}, which places literals in a separate
33999section in the output file. This allows the literal pool to be placed
34000in a data RAM/ROM, and it also allows the linker to combine literal
34001pools from separate object files to remove redundant literals and
34002improve code size. With @option{-mtext-section-literals}, the literals
34003are interspersed in the text section in order to keep them as close as
34004possible to their references. This may be necessary for large assembly
34005files. Literals for each function are placed right before that function.
34006
34007@item -mauto-litpools
34008@itemx -mno-auto-litpools
34009@opindex mauto-litpools
34010@opindex mno-auto-litpools
34011These options control the treatment of literal pools. The default is
34012@option{-mno-auto-litpools}, which places literals in a separate
34013section in the output file unless @option{-mtext-section-literals} is
34014used. With @option{-mauto-litpools} the literals are interspersed in
34015the text section by the assembler. Compiler does not produce explicit
34016@code{.literal} directives and loads literals into registers with
34017@code{MOVI} instructions instead of @code{L32R} to let the assembler
34018do relaxation and place literals as necessary. This option allows
34019assembler to create several literal pools per function and assemble
34020very big functions, which may not be possible with
34021@option{-mtext-section-literals}.
34022
34023@item -mtarget-align
34024@itemx -mno-target-align
34025@opindex mtarget-align
34026@opindex mno-target-align
34027When this option is enabled, GCC instructs the assembler to
34028automatically align instructions to reduce branch penalties at the
34029expense of some code density. The assembler attempts to widen density
34030instructions to align branch targets and the instructions following call
34031instructions. If there are not enough preceding safe density
34032instructions to align a target, no widening is performed. The
34033default is @option{-mtarget-align}. These options do not affect the
34034treatment of auto-aligned instructions like @code{LOOP}, which the
34035assembler always aligns, either by widening density instructions or
34036by inserting NOP instructions.
34037
34038@item -mlongcalls
34039@itemx -mno-longcalls
34040@opindex mlongcalls
34041@opindex mno-longcalls
34042When this option is enabled, GCC instructs the assembler to translate
34043direct calls to indirect calls unless it can determine that the target
34044of a direct call is in the range allowed by the call instruction. This
34045translation typically occurs for calls to functions in other source
34046files. Specifically, the assembler translates a direct @code{CALL}
34047instruction into an @code{L32R} followed by a @code{CALLX} instruction.
34048The default is @option{-mno-longcalls}. This option should be used in
34049programs where the call target can potentially be out of range. This
34050option is implemented in the assembler, not the compiler, so the
34051assembly code generated by GCC still shows direct call
34052instructions---look at the disassembled object code to see the actual
34053instructions. Note that the assembler uses an indirect call for
34054every cross-file call, not just those that really are out of range.
34055
34056@item -mabi=@var{name}
34057@opindex mabi
34058Generate code for the specified ABI@. Permissible values are: @samp{call0},
34059@samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
34060
34061@item -mabi=call0
34062@opindex mabi=call0
34063When this option is enabled function parameters are passed in registers
34064@code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
34065caller-saved, and register @code{a15} may be used as a frame pointer.
34066When this version of the ABI is enabled the C preprocessor symbol
34067@code{__XTENSA_CALL0_ABI__} is defined.
34068
34069@item -mabi=windowed
34070@opindex mabi=windowed
34071When this option is enabled function parameters are passed in registers
34072@code{a10} through @code{a15}, and called function rotates register window
34073by 8 registers on entry so that its arguments are found in registers
34074@code{a2} through @code{a7}. Register @code{a7} may be used as a frame
34075pointer. Register window is rotated 8 registers back upon return.
34076When this version of the ABI is enabled the C preprocessor symbol
34077@code{__XTENSA_WINDOWED_ABI__} is defined.
34078
34079@item -mextra-l32r-costs=@var{n}
34080@opindex mextra-l32r-costs
34081Specify an extra cost of instruction RAM/ROM access for @code{L32R}
34082instructions, in clock cycles. This affects, when optimizing for speed,
34083whether loading a constant from literal pool using @code{L32R} or
34084synthesizing the constant from a small one with a couple of arithmetic
34085instructions. The default value is 0.
34086@end table
34087
34088@node zSeries Options
34089@subsection zSeries Options
34090@cindex zSeries options
34091
34092These are listed under @xref{S/390 and zSeries Options}.
34093
34094
34095@c man end
34096
34097@node Spec Files
34098@section Specifying Subprocesses and the Switches to Pass to Them
34099@cindex Spec Files
34100
34101@command{gcc} is a driver program. It performs its job by invoking a
34102sequence of other programs to do the work of compiling, assembling and
34103linking. GCC interprets its command-line parameters and uses these to
34104deduce which programs it should invoke, and which command-line options
34105it ought to place on their command lines. This behavior is controlled
34106by @dfn{spec strings}. In most cases there is one spec string for each
34107program that GCC can invoke, but a few programs have multiple spec
34108strings to control their behavior. The spec strings built into GCC can
34109be overridden by using the @option{-specs=} command-line switch to specify
34110a spec file.
34111
34112@dfn{Spec files} are plain-text files that are used to construct spec
34113strings. They consist of a sequence of directives separated by blank
34114lines. The type of directive is determined by the first non-whitespace
34115character on the line, which can be one of the following:
34116
34117@table @code
34118@item %@var{command}
34119Issues a @var{command} to the spec file processor. The commands that can
34120appear here are:
34121
34122@table @code
34123@item %include <@var{file}>
34124@cindex @code{%include}
34125Search for @var{file} and insert its text at the current point in the
34126specs file.
34127
34128@item %include_noerr <@var{file}>
34129@cindex @code{%include_noerr}
34130Just like @samp{%include}, but do not generate an error message if the include
34131file cannot be found.
34132
34133@item %rename @var{old_name} @var{new_name}
34134@cindex @code{%rename}
34135Rename the spec string @var{old_name} to @var{new_name}.
34136
34137@end table
34138
34139@item *[@var{spec_name}]:
34140This tells the compiler to create, override or delete the named spec
34141string. All lines after this directive up to the next directive or
34142blank line are considered to be the text for the spec string. If this
34143results in an empty string then the spec is deleted. (Or, if the
34144spec did not exist, then nothing happens.) Otherwise, if the spec
34145does not currently exist a new spec is created. If the spec does
34146exist then its contents are overridden by the text of this
34147directive, unless the first character of that text is the @samp{+}
34148character, in which case the text is appended to the spec.
34149
34150@item [@var{suffix}]:
34151Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
34152and up to the next directive or blank line are considered to make up the
34153spec string for the indicated suffix. When the compiler encounters an
34154input file with the named suffix, it processes the spec string in
34155order to work out how to compile that file. For example:
34156
34157@smallexample
34158.ZZ:
34159z-compile -input %i
34160@end smallexample
34161
34162This says that any input file whose name ends in @samp{.ZZ} should be
34163passed to the program @samp{z-compile}, which should be invoked with the
34164command-line switch @option{-input} and with the result of performing the
34165@samp{%i} substitution. (See below.)
34166
34167As an alternative to providing a spec string, the text following a
34168suffix directive can be one of the following:
34169
34170@table @code
34171@item @@@var{language}
34172This says that the suffix is an alias for a known @var{language}. This is
34173similar to using the @option{-x} command-line switch to GCC to specify a
34174language explicitly. For example:
34175
34176@smallexample
34177.ZZ:
34178@@c++
34179@end smallexample
34180
34181Says that .ZZ files are, in fact, C++ source files.
34182
34183@item #@var{name}
34184This causes an error messages saying:
34185
34186@smallexample
34187@var{name} compiler not installed on this system.
34188@end smallexample
34189@end table
34190
34191GCC already has an extensive list of suffixes built into it.
34192This directive adds an entry to the end of the list of suffixes, but
34193since the list is searched from the end backwards, it is effectively
34194possible to override earlier entries using this technique.
34195
34196@end table
34197
34198GCC has the following spec strings built into it. Spec files can
34199override these strings or create their own. Note that individual
34200targets can also add their own spec strings to this list.
34201
34202@smallexample
34203asm Options to pass to the assembler
34204asm_final Options to pass to the assembler post-processor
34205cpp Options to pass to the C preprocessor
34206cc1 Options to pass to the C compiler
34207cc1plus Options to pass to the C++ compiler
34208endfile Object files to include at the end of the link
34209link Options to pass to the linker
34210lib Libraries to include on the command line to the linker
34211libgcc Decides which GCC support library to pass to the linker
34212linker Sets the name of the linker
34213predefines Defines to be passed to the C preprocessor
34214signed_char Defines to pass to CPP to say whether @code{char} is signed
34215 by default
34216startfile Object files to include at the start of the link
34217@end smallexample
34218
34219Here is a small example of a spec file:
34220
34221@smallexample
34222%rename lib old_lib
34223
34224*lib:
34225--start-group -lgcc -lc -leval1 --end-group %(old_lib)
34226@end smallexample
34227
34228This example renames the spec called @samp{lib} to @samp{old_lib} and
34229then overrides the previous definition of @samp{lib} with a new one.
34230The new definition adds in some extra command-line options before
34231including the text of the old definition.
34232
34233@dfn{Spec strings} are a list of command-line options to be passed to their
34234corresponding program. In addition, the spec strings can contain
34235@samp{%}-prefixed sequences to substitute variable text or to
34236conditionally insert text into the command line. Using these constructs
34237it is possible to generate quite complex command lines.
34238
34239Here is a table of all defined @samp{%}-sequences for spec
34240strings. Note that spaces are not generated automatically around the
34241results of expanding these sequences. Therefore you can concatenate them
34242together or combine them with constant text in a single argument.
34243
34244@table @code
34245@item %%
34246Substitute one @samp{%} into the program name or argument.
34247
34248@item %"
34249Substitute an empty argument.
34250
34251@item %i
34252Substitute the name of the input file being processed.
34253
34254@item %b
34255Substitute the basename for outputs related with the input file being
34256processed. This is often the substring up to (and not including) the
34257last period and not including the directory but, unless %w is active, it
34258expands to the basename for auxiliary outputs, which may be influenced
34259by an explicit output name, and by various other options that control
34260how auxiliary outputs are named.
34261
34262@item %B
34263This is the same as @samp{%b}, but include the file suffix (text after
34264the last period). Without %w, it expands to the basename for dump
34265outputs.
34266
34267@item %d
34268Marks the argument containing or following the @samp{%d} as a
34269temporary file name, so that that file is deleted if GCC exits
34270successfully. Unlike @samp{%g}, this contributes no text to the
34271argument.
34272
34273@item %g@var{suffix}
34274Substitute a file name that has suffix @var{suffix} and is chosen
34275once per compilation, and mark the argument in the same way as
34276@samp{%d}. To reduce exposure to denial-of-service attacks, the file
34277name is now chosen in a way that is hard to predict even when previously
34278chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
34279might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
34280the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
34281treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
34282was simply substituted with a file name chosen once per compilation,
34283without regard to any appended suffix (which was therefore treated
34284just like ordinary text), making such attacks more likely to succeed.
34285
34286@item %u@var{suffix}
34287Like @samp{%g}, but generates a new temporary file name
34288each time it appears instead of once per compilation.
34289
34290@item %U@var{suffix}
34291Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
34292new one if there is no such last file name. In the absence of any
34293@samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
34294the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
34295involves the generation of two distinct file names, one
34296for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
34297simply substituted with a file name chosen for the previous @samp{%u},
34298without regard to any appended suffix.
34299
34300@item %j@var{suffix}
34301Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
34302writable, and if @option{-save-temps} is not used;
34303otherwise, substitute the name
34304of a temporary file, just like @samp{%u}. This temporary file is not
34305meant for communication between processes, but rather as a junk
34306disposal mechanism.
34307
34308@item %|@var{suffix}
34309@itemx %m@var{suffix}
34310Like @samp{%g}, except if @option{-pipe} is in effect. In that case
34311@samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
34312all. These are the two most common ways to instruct a program that it
34313should read from standard input or write to standard output. If you
34314need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
34315construct: see for example @file{gcc/fortran/lang-specs.h}.
34316
34317@item %.@var{SUFFIX}
34318Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
34319when it is subsequently output with @samp{%*}. @var{SUFFIX} is
34320terminated by the next space or %.
34321
34322@item %w
34323Marks the argument containing or following the @samp{%w} as the
34324designated output file of this compilation. This puts the argument
34325into the sequence of arguments that @samp{%o} substitutes.
34326
34327@item %V
34328Indicates that this compilation produces no output file.
34329
34330@item %o
34331Substitutes the names of all the output files, with spaces
34332automatically placed around them. You should write spaces
34333around the @samp{%o} as well or the results are undefined.
34334@samp{%o} is for use in the specs for running the linker.
34335Input files whose names have no recognized suffix are not compiled
34336at all, but they are included among the output files, so they are
34337linked.
34338
34339@item %O
34340Substitutes the suffix for object files. Note that this is
34341handled specially when it immediately follows @samp{%g, %u, or %U},
34342because of the need for those to form complete file names. The
34343handling is such that @samp{%O} is treated exactly as if it had already
34344been substituted, except that @samp{%g, %u, and %U} do not currently
34345support additional @var{suffix} characters following @samp{%O} as they do
34346following, for example, @samp{.o}.
34347
34348@item %I
34349Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
34350@option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
34351@option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
34352and @option{-imultilib} as necessary.
34353
34354@item %s
34355Current argument is the name of a library or startup file of some sort.
34356Search for that file in a standard list of directories and substitute
34357the full name found. The current working directory is included in the
34358list of directories scanned.
34359
34360@item %T
34361Current argument is the name of a linker script. Search for that file
34362in the current list of directories to scan for libraries. If the file
34363is located insert a @option{--script} option into the command line
34364followed by the full path name found. If the file is not found then
34365generate an error message. Note: the current working directory is not
34366searched.
34367
34368@item %e@var{str}
34369Print @var{str} as an error message. @var{str} is terminated by a newline.
34370Use this when inconsistent options are detected.
34371
34372@item %n@var{str}
34373Print @var{str} as a notice. @var{str} is terminated by a newline.
34374
34375@item %(@var{name})
34376Substitute the contents of spec string @var{name} at this point.
34377
34378@item %x@{@var{option}@}
34379Accumulate an option for @samp{%X}.
34380
34381@item %X
34382Output the accumulated linker options specified by a @samp{%x} spec string.
34383
34384@item %Y
34385Output the accumulated assembler options specified by @option{-Wa}.
34386
34387@item %Z
34388Output the accumulated preprocessor options specified by @option{-Wp}.
34389
34390@item %M
34391Output @code{multilib_os_dir}.
34392
34393@item %R
34394Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
34395
34396@item %a
34397Process the @code{asm} spec. This is used to compute the
34398switches to be passed to the assembler.
34399
34400@item %A
34401Process the @code{asm_final} spec. This is a spec string for
34402passing switches to an assembler post-processor, if such a program is
34403needed.
34404
34405@item %l
34406Process the @code{link} spec. This is the spec for computing the
34407command line passed to the linker. Typically it makes use of the
34408@samp{%L %G %S %D and %E} sequences.
34409
34410@item %D
34411Dump out a @option{-L} option for each directory that GCC believes might
34412contain startup files. If the target supports multilibs then the
34413current multilib directory is prepended to each of these paths.
34414
34415@item %L
34416Process the @code{lib} spec. This is a spec string for deciding which
34417libraries are included on the command line to the linker.
34418
34419@item %G
34420Process the @code{libgcc} spec. This is a spec string for deciding
34421which GCC support library is included on the command line to the linker.
34422
34423@item %S
34424Process the @code{startfile} spec. This is a spec for deciding which
34425object files are the first ones passed to the linker. Typically
34426this might be a file named @file{crt0.o}.
34427
34428@item %E
34429Process the @code{endfile} spec. This is a spec string that specifies
34430the last object files that are passed to the linker.
34431
34432@item %C
34433Process the @code{cpp} spec. This is used to construct the arguments
34434to be passed to the C preprocessor.
34435
34436@item %1
34437Process the @code{cc1} spec. This is used to construct the options to be
34438passed to the actual C compiler (@command{cc1}).
34439
34440@item %2
34441Process the @code{cc1plus} spec. This is used to construct the options to be
34442passed to the actual C++ compiler (@command{cc1plus}).
34443
34444@item %*
34445Substitute the variable part of a matched option. See below.
34446Note that each comma in the substituted string is replaced by
34447a single space.
34448
34449@item %<S
34450Remove all occurrences of @code{-S} from the command line. Note---this
34451command is position dependent. @samp{%} commands in the spec string
34452before this one see @code{-S}, @samp{%} commands in the spec string
34453after this one do not.
34454
34455@item %<S*
34456Similar to @samp{%<S}, but match all switches beginning with @code{-S}.
34457
34458@item %>S
34459Similar to @samp{%<S}, but keep @code{-S} in the GCC command line.
34460
34461@item %:@var{function}(@var{args})
34462Call the named function @var{function}, passing it @var{args}.
34463@var{args} is first processed as a nested spec string, then split
34464into an argument vector in the usual fashion. The function returns
34465a string which is processed as if it had appeared literally as part
34466of the current spec.
34467
34468The following built-in spec functions are provided:
34469
34470@table @code
34471@item @code{getenv}
34472The @code{getenv} spec function takes two arguments: an environment
34473variable name and a string. If the environment variable is not
34474defined, a fatal error is issued. Otherwise, the return value is the
34475value of the environment variable concatenated with the string. For
34476example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
34477
34478@smallexample
34479%:getenv(TOPDIR /include)
34480@end smallexample
34481
34482expands to @file{/path/to/top/include}.
34483
34484@item @code{if-exists}
34485The @code{if-exists} spec function takes one argument, an absolute
34486pathname to a file. If the file exists, @code{if-exists} returns the
34487pathname. Here is a small example of its usage:
34488
34489@smallexample
34490*startfile:
34491crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
34492@end smallexample
34493
34494@item @code{if-exists-else}
34495The @code{if-exists-else} spec function is similar to the @code{if-exists}
34496spec function, except that it takes two arguments. The first argument is
34497an absolute pathname to a file. If the file exists, @code{if-exists-else}
34498returns the pathname. If it does not exist, it returns the second argument.
34499This way, @code{if-exists-else} can be used to select one file or another,
34500based on the existence of the first. Here is a small example of its usage:
34501
34502@smallexample
34503*startfile:
34504crt0%O%s %:if-exists(crti%O%s) \
34505%:if-exists-else(crtbeginT%O%s crtbegin%O%s)
34506@end smallexample
34507
34508@item @code{if-exists-then-else}
34509The @code{if-exists-then-else} spec function takes at least two arguments
34510and an optional third one. The first argument is an absolute pathname to a
34511file. If the file exists, the function returns the second argument.
34512If the file does not exist, the function returns the third argument if there
34513is one, or NULL otherwise. This can be used to expand one text, or optionally
34514another, based on the existence of a file. Here is a small example of its
34515usage:
34516
34517@smallexample
34518-l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
34519@end smallexample
34520
34521@item @code{sanitize}
34522The @code{sanitize} spec function takes no arguments. It returns non-NULL if
34523any address, thread or undefined behavior sanitizers are active.
34524
34525@smallexample
34526%@{%:sanitize(address):-funwind-tables@}
34527@end smallexample
34528
34529@item @code{replace-outfile}
34530The @code{replace-outfile} spec function takes two arguments. It looks for the
34531first argument in the outfiles array and replaces it with the second argument. Here
34532is a small example of its usage:
34533
34534@smallexample
34535%@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
34536@end smallexample
34537
34538@item @code{remove-outfile}
34539The @code{remove-outfile} spec function takes one argument. It looks for the
34540first argument in the outfiles array and removes it. Here is a small example
34541its usage:
34542
34543@smallexample
34544%:remove-outfile(-lm)
34545@end smallexample
34546
34547@item @code{version-compare}
34548The @code{version-compare} spec function takes four or five arguments of the following
34549form:
34550
34551@smallexample
34552<comparison-op> <arg1> [<arg2>] <switch> <result>
34553@end smallexample
34554
34555It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
34556The supported @code{comparison-op} values are:
34557
34558@table @code
34559@item >=
34560True if @code{switch} is a later (or same) version than @code{arg1}
34561
34562@item !>
34563Opposite of @code{>=}
34564
34565@item <
34566True if @code{switch} is an earlier version than @code{arg1}
34567
34568@item !<
34569Opposite of @code{<}
34570
34571@item ><
34572True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
34573
34574@item <>
34575True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
34576@end table
34577
34578If the @code{switch} is not present at all, the condition is false unless the first character
34579of the @code{comparison-op} is @code{!}.
34580
34581@smallexample
34582%:version-compare(>= 10.3 mmacosx-version-min= -lmx)
34583@end smallexample
34584
34585The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
34586passed.
34587
34588@item @code{include}
34589The @code{include} spec function behaves much like @code{%include}, with the advantage
34590that it can be nested inside a spec and thus be conditionalized. It takes one argument,
34591the filename, and looks for it in the startfile path. It always returns NULL.
34592
34593@smallexample
34594%@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
34595@end smallexample
34596
34597@item @code{pass-through-libs}
34598The @code{pass-through-libs} spec function takes any number of arguments. It
34599finds any @option{-l} options and any non-options ending in @file{.a} (which it
34600assumes are the names of linker input library archive files) and returns a
34601result containing all the found arguments each prepended by
34602@option{-plugin-opt=-pass-through=} and joined by spaces. This list is
34603intended to be passed to the LTO linker plugin.
34604
34605@smallexample
34606%:pass-through-libs(%G %L %G)
34607@end smallexample
34608
34609@item @code{print-asm-header}
34610The @code{print-asm-header} function takes no arguments and simply
34611prints a banner like:
34612
34613@smallexample
34614Assembler options
34615=================
34616
34617Use "-Wa,OPTION" to pass "OPTION" to the assembler.
34618@end smallexample
34619
34620It is used to separate compiler options from assembler options
34621in the @option{--target-help} output.
34622
34623@item @code{gt}
34624The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
34625empty string) if the second-to-last argument is greater than the last argument, and NULL
34626otherwise. The following example inserts the @code{link_gomp} spec if the last
34627@option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
34628
34629@smallexample
34630%@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
34631@end smallexample
34632
34633@item @code{debug-level-gt}
34634The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
34635empty string) if @code{debug_info_level} is greater than the specified number, and NULL
34636otherwise.
34637
34638@smallexample
34639%@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
34640@end smallexample
34641@end table
34642
34643@item %@{S@}
34644Substitutes the @code{-S} switch, if that switch is given to GCC@.
34645If that switch is not specified, this substitutes nothing. Note that
34646the leading dash is omitted when specifying this option, and it is
34647automatically inserted if the substitution is performed. Thus the spec
34648string @samp{%@{foo@}} matches the command-line option @option{-foo}
34649and outputs the command-line option @option{-foo}.
34650
34651@item %W@{S@}
34652Like %@{@code{S}@} but mark last argument supplied within as a file to be
34653deleted on failure.
34654
34655@item %@@@{S@}
34656Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes
34657@code{@@FILE} if an @code{@@file} argument has been supplied.
34658
34659@item %@{S*@}
34660Substitutes all the switches specified to GCC whose names start
34661with @code{-S}, but which also take an argument. This is used for
34662switches like @option{-o}, @option{-D}, @option{-I}, etc.
34663GCC considers @option{-o foo} as being
34664one switch whose name starts with @samp{o}. %@{o*@} substitutes this
34665text, including the space. Thus two arguments are generated.
34666
34667@item %@{S*&T*@}
34668Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
34669(the order of @code{S} and @code{T} in the spec is not significant).
34670There can be any number of ampersand-separated variables; for each the
34671wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
34672
34673@item %@{S:X@}
34674Substitutes @code{X}, if the @option{-S} switch is given to GCC@.
34675
34676@item %@{!S:X@}
34677Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@.
34678
34679@item %@{S*:X@}
34680Substitutes @code{X} if one or more switches whose names start with
34681@code{-S} are specified to GCC@. Normally @code{X} is substituted only
34682once, no matter how many such switches appeared. However, if @code{%*}
34683appears somewhere in @code{X}, then @code{X} is substituted once
34684for each matching switch, with the @code{%*} replaced by the part of
34685that switch matching the @code{*}.
34686
34687If @code{%*} appears as the last part of a spec sequence then a space
34688is added after the end of the last substitution. If there is more
34689text in the sequence, however, then a space is not generated. This
34690allows the @code{%*} substitution to be used as part of a larger
34691string. For example, a spec string like this:
34692
34693@smallexample
34694%@{mcu=*:--script=%*/memory.ld@}
34695@end smallexample
34696
34697@noindent
34698when matching an option like @option{-mcu=newchip} produces:
34699
34700@smallexample
34701--script=newchip/memory.ld
34702@end smallexample
34703
34704@item %@{.S:X@}
34705Substitutes @code{X}, if processing a file with suffix @code{S}.
34706
34707@item %@{!.S:X@}
34708Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
34709
34710@item %@{,S:X@}
34711Substitutes @code{X}, if processing a file for language @code{S}.
34712
34713@item %@{!,S:X@}
34714Substitutes @code{X}, if not processing a file for language @code{S}.
34715
34716@item %@{S|P:X@}
34717Substitutes @code{X} if either @code{-S} or @code{-P} is given to
34718GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
34719@code{*} sequences as well, although they have a stronger binding than
34720the @samp{|}. If @code{%*} appears in @code{X}, all of the
34721alternatives must be starred, and only the first matching alternative
34722is substituted.
34723
34724For example, a spec string like this:
34725
34726@smallexample
34727%@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
34728@end smallexample
34729
34730@noindent
34731outputs the following command-line options from the following input
34732command-line options:
34733
34734@smallexample
34735fred.c -foo -baz
34736jim.d -bar -boggle
34737-d fred.c -foo -baz -boggle
34738-d jim.d -bar -baz -boggle
34739@end smallexample
34740
34741@item %@{%:@var{function}(@var{args}):X@}
34742
34743Call function named @var{function} with args @var{args}. If the
34744function returns non-NULL, then @code{X} is substituted, if it returns
34745NULL, it isn't substituted.
34746
34747@item %@{S:X; T:Y; :D@}
34748
34749If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is
34750given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
34751be as many clauses as you need. This may be combined with @code{.},
34752@code{,}, @code{!}, @code{|}, and @code{*} as needed.
34753
34754
34755@end table
34756
34757The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}}
34758or similar construct can use a backslash to ignore the special meaning
34759of the character following it, thus allowing literal matching of a
34760character that is otherwise specially treated. For example,
34761@samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the
34762@option{-std=iso9899:1999} option is given.
34763
34764The conditional text @code{X} in a @samp{%@{S:X@}} or similar
34765construct may contain other nested @samp{%} constructs or spaces, or
34766even newlines. They are processed as usual, as described above.
34767Trailing white space in @code{X} is ignored. White space may also
34768appear anywhere on the left side of the colon in these constructs,
34769except between @code{.} or @code{*} and the corresponding word.
34770
34771The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
34772handled specifically in these constructs. If another value of
34773@option{-O} or the negated form of a @option{-f}, @option{-m}, or
34774@option{-W} switch is found later in the command line, the earlier
34775switch value is ignored, except with @{@code{S}*@} where @code{S} is
34776just one letter, which passes all matching options.
34777
34778The character @samp{|} at the beginning of the predicate text is used to
34779indicate that a command should be piped to the following command, but
34780only if @option{-pipe} is specified.
34781
34782It is built into GCC which switches take arguments and which do not.
34783(You might think it would be useful to generalize this to allow each
34784compiler's spec to say which switches take arguments. But this cannot
34785be done in a consistent fashion. GCC cannot even decide which input
34786files have been specified without knowing which switches take arguments,
34787and it must know which input files to compile in order to tell which
34788compilers to run).
34789
34790GCC also knows implicitly that arguments starting in @option{-l} are to be
34791treated as compiler output files, and passed to the linker in their
34792proper position among the other output files.
34793
34794@node Environment Variables
34795@section Environment Variables Affecting GCC
34796@cindex environment variables
34797
34798@c man begin ENVIRONMENT
34799This section describes several environment variables that affect how GCC
34800operates. Some of them work by specifying directories or prefixes to use
34801when searching for various kinds of files. Some are used to specify other
34802aspects of the compilation environment.
34803
34804Note that you can also specify places to search using options such as
34805@option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
34806take precedence over places specified using environment variables, which
34807in turn take precedence over those specified by the configuration of GCC@.
34808@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
34809GNU Compiler Collection (GCC) Internals}.
34810
34811@table @env
34812@item LANG
34813@itemx LC_CTYPE
34814@c @itemx LC_COLLATE
34815@itemx LC_MESSAGES
34816@c @itemx LC_MONETARY
34817@c @itemx LC_NUMERIC
34818@c @itemx LC_TIME
34819@itemx LC_ALL
34820@findex LANG
34821@findex LC_CTYPE
34822@c @findex LC_COLLATE
34823@findex LC_MESSAGES
34824@c @findex LC_MONETARY
34825@c @findex LC_NUMERIC
34826@c @findex LC_TIME
34827@findex LC_ALL
34828@cindex locale
34829These environment variables control the way that GCC uses
34830localization information which allows GCC to work with different
34831national conventions. GCC inspects the locale categories
34832@env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
34833so. These locale categories can be set to any value supported by your
34834installation. A typical value is @samp{en_GB.UTF-8} for English in the United
34835Kingdom encoded in UTF-8.
34836
34837The @env{LC_CTYPE} environment variable specifies character
34838classification. GCC uses it to determine the character boundaries in
34839a string; this is needed for some multibyte encodings that contain quote
34840and escape characters that are otherwise interpreted as a string
34841end or escape.
34842
34843The @env{LC_MESSAGES} environment variable specifies the language to
34844use in diagnostic messages.
34845
34846If the @env{LC_ALL} environment variable is set, it overrides the value
34847of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
34848and @env{LC_MESSAGES} default to the value of the @env{LANG}
34849environment variable. If none of these variables are set, GCC
34850defaults to traditional C English behavior.
34851
34852@item TMPDIR
34853@findex TMPDIR
34854If @env{TMPDIR} is set, it specifies the directory to use for temporary
34855files. GCC uses temporary files to hold the output of one stage of
34856compilation which is to be used as input to the next stage: for example,
34857the output of the preprocessor, which is the input to the compiler
34858proper.
34859
34860@item GCC_COMPARE_DEBUG
34861@findex GCC_COMPARE_DEBUG
34862Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
34863@option{-fcompare-debug} to the compiler driver. See the documentation
34864of this option for more details.
34865
34866@item GCC_EXEC_PREFIX
34867@findex GCC_EXEC_PREFIX
34868If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
34869names of the subprograms executed by the compiler. No slash is added
34870when this prefix is combined with the name of a subprogram, but you can
34871specify a prefix that ends with a slash if you wish.
34872
34873If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
34874an appropriate prefix to use based on the pathname it is invoked with.
34875
34876If GCC cannot find the subprogram using the specified prefix, it
34877tries looking in the usual places for the subprogram.
34878
34879The default value of @env{GCC_EXEC_PREFIX} is
34880@file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
34881the installed compiler. In many cases @var{prefix} is the value
34882of @code{prefix} when you ran the @file{configure} script.
34883
34884Other prefixes specified with @option{-B} take precedence over this prefix.
34885
34886This prefix is also used for finding files such as @file{crt0.o} that are
34887used for linking.
34888
34889In addition, the prefix is used in an unusual way in finding the
34890directories to search for header files. For each of the standard
34891directories whose name normally begins with @samp{/usr/local/lib/gcc}
34892(more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
34893replacing that beginning with the specified prefix to produce an
34894alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
34895@file{foo/bar} just before it searches the standard directory
34896@file{/usr/local/lib/bar}.
34897If a standard directory begins with the configured
34898@var{prefix} then the value of @var{prefix} is replaced by
34899@env{GCC_EXEC_PREFIX} when looking for header files.
34900
34901@item COMPILER_PATH
34902@findex COMPILER_PATH
34903The value of @env{COMPILER_PATH} is a colon-separated list of
34904directories, much like @env{PATH}. GCC tries the directories thus
34905specified when searching for subprograms, if it cannot find the
34906subprograms using @env{GCC_EXEC_PREFIX}.
34907
34908@item LIBRARY_PATH
34909@findex LIBRARY_PATH
34910The value of @env{LIBRARY_PATH} is a colon-separated list of
34911directories, much like @env{PATH}. When configured as a native compiler,
34912GCC tries the directories thus specified when searching for special
34913linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
34914using GCC also uses these directories when searching for ordinary
34915libraries for the @option{-l} option (but directories specified with
34916@option{-L} come first).
34917
34918@item LANG
34919@findex LANG
34920@cindex locale definition
34921This variable is used to pass locale information to the compiler. One way in
34922which this information is used is to determine the character set to be used
34923when character literals, string literals and comments are parsed in C and C++.
34924When the compiler is configured to allow multibyte characters,
34925the following values for @env{LANG} are recognized:
34926
34927@table @samp
34928@item C-JIS
34929Recognize JIS characters.
34930@item C-SJIS
34931Recognize SJIS characters.
34932@item C-EUCJP
34933Recognize EUCJP characters.
34934@end table
34935
34936If @env{LANG} is not defined, or if it has some other value, then the
34937compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
34938recognize and translate multibyte characters.
34939
34940@item GCC_EXTRA_DIAGNOSTIC_OUTPUT
34941@findex GCC_EXTRA_DIAGNOSTIC_OUTPUT
34942If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
34943then additional text will be emitted to stderr when fix-it hints are
34944emitted. @option{-fdiagnostics-parseable-fixits} and
34945@option{-fno-diagnostics-parseable-fixits} take precedence over this
34946environment variable.
34947
34948@table @samp
34949@item fixits-v1
34950Emit parseable fix-it hints, equivalent to
34951@option{-fdiagnostics-parseable-fixits}. In particular, columns are
34952expressed as a count of bytes, starting at byte 1 for the initial column.
34953
34954@item fixits-v2
34955As @code{fixits-v1}, but columns are expressed as display columns,
34956as per @option{-fdiagnostics-column-unit=display}.
34957@end table
34958
34959@end table
34960
34961@noindent
34962Some additional environment variables affect the behavior of the
34963preprocessor.
34964
34965@include cppenv.texi
34966
34967@c man end
34968
34969@node Precompiled Headers
34970@section Using Precompiled Headers
34971@cindex precompiled headers
34972@cindex speed of compilation
34973
34974Often large projects have many header files that are included in every
34975source file. The time the compiler takes to process these header files
34976over and over again can account for nearly all of the time required to
34977build the project. To make builds faster, GCC allows you to
34978@dfn{precompile} a header file.
34979
34980To create a precompiled header file, simply compile it as you would any
34981other file, if necessary using the @option{-x} option to make the driver
34982treat it as a C or C++ header file. You may want to use a
34983tool like @command{make} to keep the precompiled header up-to-date when
34984the headers it contains change.
34985
34986A precompiled header file is searched for when @code{#include} is
34987seen in the compilation. As it searches for the included file
34988(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
34989compiler looks for a precompiled header in each directory just before it
34990looks for the include file in that directory. The name searched for is
34991the name specified in the @code{#include} with @samp{.gch} appended. If
34992the precompiled header file cannot be used, it is ignored.
34993
34994For instance, if you have @code{#include "all.h"}, and you have
34995@file{all.h.gch} in the same directory as @file{all.h}, then the
34996precompiled header file is used if possible, and the original
34997header is used otherwise.
34998
34999Alternatively, you might decide to put the precompiled header file in a
35000directory and use @option{-I} to ensure that directory is searched
35001before (or instead of) the directory containing the original header.
35002Then, if you want to check that the precompiled header file is always
35003used, you can put a file of the same name as the original header in this
35004directory containing an @code{#error} command.
35005
35006This also works with @option{-include}. So yet another way to use
35007precompiled headers, good for projects not designed with precompiled
35008header files in mind, is to simply take most of the header files used by
35009a project, include them from another header file, precompile that header
35010file, and @option{-include} the precompiled header. If the header files
35011have guards against multiple inclusion, they are skipped because
35012they've already been included (in the precompiled header).
35013
35014If you need to precompile the same header file for different
35015languages, targets, or compiler options, you can instead make a
35016@emph{directory} named like @file{all.h.gch}, and put each precompiled
35017header in the directory, perhaps using @option{-o}. It doesn't matter
35018what you call the files in the directory; every precompiled header in
35019the directory is considered. The first precompiled header
35020encountered in the directory that is valid for this compilation is
35021used; they're searched in no particular order.
35022
35023There are many other possibilities, limited only by your imagination,
35024good sense, and the constraints of your build system.
35025
35026A precompiled header file can be used only when these conditions apply:
35027
35028@itemize
35029@item
35030Only one precompiled header can be used in a particular compilation.
35031
35032@item
35033A precompiled header cannot be used once the first C token is seen. You
35034can have preprocessor directives before a precompiled header; you cannot
35035include a precompiled header from inside another header.
35036
35037@item
35038The precompiled header file must be produced for the same language as
35039the current compilation. You cannot use a C precompiled header for a C++
35040compilation.
35041
35042@item
35043The precompiled header file must have been produced by the same compiler
35044binary as the current compilation is using.
35045
35046@item
35047Any macros defined before the precompiled header is included must
35048either be defined in the same way as when the precompiled header was
35049generated, or must not affect the precompiled header, which usually
35050means that they don't appear in the precompiled header at all.
35051
35052The @option{-D} option is one way to define a macro before a
35053precompiled header is included; using a @code{#define} can also do it.
35054There are also some options that define macros implicitly, like
35055@option{-O} and @option{-Wdeprecated}; the same rule applies to macros
35056defined this way.
35057
35058@item If debugging information is output when using the precompiled
35059header, using @option{-g} or similar, the same kind of debugging information
35060must have been output when building the precompiled header. However,
35061a precompiled header built using @option{-g} can be used in a compilation
35062when no debugging information is being output.
35063
35064@item The same @option{-m} options must generally be used when building
35065and using the precompiled header. @xref{Submodel Options},
35066for any cases where this rule is relaxed.
35067
35068@item Each of the following options must be the same when building and using
35069the precompiled header:
35070
35071@gccoptlist{-fexceptions}
35072
35073@item
35074Some other command-line options starting with @option{-f},
35075@option{-p}, or @option{-O} must be defined in the same way as when
35076the precompiled header was generated. At present, it's not clear
35077which options are safe to change and which are not; the safest choice
35078is to use exactly the same options when generating and using the
35079precompiled header. The following are known to be safe:
35080
35081@gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock @gol
35082-fsched-spec -fsched-spec-load -fsched-spec-load-dangerous @gol
35083-fsched-verbose=@var{number} -fschedule-insns -fvisibility= @gol
35084-pedantic-errors}
35085
35086@item Address space layout randomization (ASLR) can lead to not binary identical
35087PCH files. If you rely on stable PCH file contents disable ASLR when generating
35088PCH files.
35089
35090@end itemize
35091
35092For all of these except the last, the compiler automatically
35093ignores the precompiled header if the conditions aren't met. If you
35094find an option combination that doesn't work and doesn't cause the
35095precompiled header to be ignored, please consider filing a bug report,
35096see @ref{Bugs}.
35097
35098If you do use differing options when generating and using the
35099precompiled header, the actual behavior is a mixture of the
35100behavior for the options. For instance, if you use @option{-g} to
35101generate the precompiled header but not when using it, you may or may
35102not get debugging information for routines in the precompiled header.
35103
35104@node C++ Modules
35105@section C++ Modules
35106@cindex speed of compilation
35107
35108Modules are a C++20 language feature. As the name suggests, they
35109provides a modular compilation system, intending to provide both
35110faster builds and better library isolation. The ``Merging Modules''
35111paper @uref{https://wg21.link/p1103}, provides the easiest to read set
35112of changes to the standard, although it does not capture later
35113changes.
35114
35115@emph{G++'s modules support is not complete.} Other than bugs, the
35116known missing pieces are:
35117
35118@table @emph
35119
35120@item Private Module Fragment
35121The Private Module Fragment is recognized, but an error is emitted.
35122
35123@item Partition definition visibility rules
35124Entities may be defined in implementation partitions, and those
35125definitions are not available outside of the module. This is not
35126implemented, and the definitions are available to extra-module use.
35127
35128@item Textual merging of reachable GM entities
35129Entities may be multiply defined across different header-units.
35130These must be de-duplicated, and this is implemented across imports,
35131or when an import redefines a textually-defined entity. However the
35132reverse is not implemented---textually redefining an entity that has
35133been defined in an imported header-unit. A redefinition error is
35134emitted.
35135
35136@item Translation-Unit local referencing rules
35137Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
35138(@uref{https://wg21.link/p2003}) add limitations on which entities an
35139exported region may reference (for instance, the entities an exported
35140template definition may reference). These are not fully implemented.
35141
35142@item Standard Library Header Units
35143The Standard Library is not provided as importable header units. If
35144you want to import such units, you must explicitly build them first.
35145If you do not do this with care, you may have multiple declarations,
35146which the module machinery must merge---compiler resource usage can be
35147affected by how you partition header files into header units.
35148
35149@end table
35150
35151Modular compilation is @emph{not} enabled with just the
35152@option{-std=c++20} option. You must explicitly enable it with the
35153@option{-fmodules-ts} option. It is independent of the language
35154version selected, although in pre-C++20 versions, it is of course an
35155extension.
35156
35157No new source file suffixes are required or supported. If you wish to
35158use a non-standard suffix (@pxref{Overall Options}), you also need
35159to provide a @option{-x c++} option too.@footnote{Some users like to
35160distinguish module interface files with a new suffix, such as naming
35161the source @code{module.cppm}, which involves
35162teaching all tools about the new suffix. A different scheme, such as
35163naming @code{module-m.cpp} would be less invasive.}
35164
35165Compiling a module interface unit produces an additional output (to
35166the assembly or object file), called a Compiled Module Interface
35167(CMI). This encodes the exported declarations of the module.
35168Importing a module reads in the CMI. The import graph is a Directed
35169Acyclic Graph (DAG). You must build imports before the importer.
35170
35171Header files may themselves be compiled to header units, which are a
35172transitional ability aiming at faster compilation. The
35173@option{-fmodule-header} option is used to enable this, and implies
35174the @option{-fmodules-ts} option. These CMIs are named by the fully
35175resolved underlying header file, and thus may be a complete pathname
35176containing subdirectories. If the header file is found at an absolute
35177pathname, the CMI location is still relative to a CMI root directory.
35178
35179As header files often have no suffix, you commonly have to specify a
35180@option{-x} option to tell the compiler the source is a header file.
35181You may use @option{-x c++-header}, @option{-x c++-user-header} or
35182@option{-x c++-system-header}. When used in conjunction with
35183@option{-fmodules-ts}, these all imply an appropriate
35184@option{-fmodule-header} option. The latter two variants use the
35185user or system include path to search for the file specified. This
35186allows you to, for instance, compile standard library header files as
35187header units, without needing to know exactly where they are
35188installed. Specifying the language as one of these variants also
35189inhibits output of the object file, as header files have no associated
35190object file.
35191
35192The @option{-fmodule-only} option disables generation of the
35193associated object file for compiling a module interface. Only the CMI
35194is generated. This option is implied when using the
35195@option{-fmodule-header} option.
35196
35197The @option{-flang-info-include-translate} and
35198@option{-flang-info-include-translate-not} options notes whether
35199include translation occurs or not. With no argument, the first will
35200note all include translation. The second will note all
35201non-translations of include files not known to intentionally be
35202textual. With an argument, queries about include translation of a
35203header files with that particular trailing pathname are noted. You
35204may repeat this form to cover several different header files. This
35205option may be helpful in determining whether include translation is
35206happening---if it is working correctly, it behaves as if it isn't
35207there at all.
35208
35209The @option{-flang-info-module-cmi} option can be used to determine
35210where the compiler is reading a CMI from. Without the option, the
35211compiler is silent when such a read is successful. This option has an
35212optional argument, which will restrict the notification to just the
35213set of named modules or header units specified.
35214
35215The @option{-Winvalid-imported-macros} option causes all imported macros
35216to be resolved at the end of compilation. Without this, imported
35217macros are only resolved when expanded or (re)defined. This option
35218detects conflicting import definitions for all macros.
35219
35220For details of the @option{-fmodule-mapper} family of options,
35221@pxref{C++ Module Mapper}.
35222
35223@menu
35224* C++ Module Mapper:: Module Mapper
35225* C++ Module Preprocessing:: Module Preprocessing
35226* C++ Compiled Module Interface:: Compiled Module Interface
35227@end menu
35228
35229@node C++ Module Mapper
35230@subsection Module Mapper
35231@cindex C++ Module Mapper
35232
35233A module mapper provides a server or file that the compiler queries to
35234determine the mapping between module names and CMI files. It is also
35235used to build CMIs on demand. @emph{Mapper functionality is in its
35236infancy and is intended for experimentation with build system
35237interactions.}
35238
35239You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
35240option or @env{CXX_MODULE_MAPPER} environment variable. The value may
35241have one of the following forms:
35242
35243@table @gcctabopt
35244
35245@item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
35246An optional hostname and a numeric port number to connect to. If the
35247hostname is omitted, the loopback address is used. If the hostname
35248corresponds to multiple IPV6 addresses, these are tried in turn, until
35249one is successful. If your host lacks IPv6, this form is
35250non-functional. If you must use IPv4 use
35251@option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
35252
35253@item =@var{socket}@r{[}?@var{ident}@r{]}
35254A local domain socket. If your host lacks local domain sockets, this
35255form is non-functional.
35256
35257@item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
35258A program to spawn, and communicate with on its stdin/stdout streams.
35259Your @var{PATH} environment variable is searched for the program.
35260Arguments are separated by space characters, (it is not possible for
35261one of the arguments delivered to the program to contain a space). An
35262exception is if @var{program} begins with @@. In that case
35263@var{program} (sans @@) is looked for in the compiler's internal
35264binary directory. Thus the sample mapper-server can be specified
35265with @code{@@g++-mapper-server}.
35266
35267@item <>@r{[}?@var{ident}@r{]}
35268@item <>@var{inout}@r{[}?@var{ident}@r{]}
35269@item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
35270Named pipes or file descriptors to communicate over. The first form,
35271@option{<>}, communicates over stdin and stdout. The other forms
35272allow you to specify a file descriptor or name a pipe. A numeric value
35273is interpreted as a file descriptor, otherwise named pipe is opened.
35274The second form specifies a bidirectional pipe and the last form
35275allows specifying two independent pipes. Using file descriptors
35276directly in this manner is fragile in general, as it can require the
35277cooperation of intermediate processes. In particular using stdin &
35278stdout is fraught with danger as other compiler options might also
35279cause the compiler to read stdin or write stdout, and it can have
35280unfortunate interactions with signal delivery from the terminal.
35281
35282@item @var{file}@r{[}?@var{ident}@r{]}
35283A mapping file consisting of space-separated module-name, filename
35284pairs, one per line. Only the mappings for the direct imports and any
35285module export name need be provided. If other mappings are provided,
35286they override those stored in any imported CMI files. A repository
35287root may be specified in the mapping file by using @samp{$root} as the
35288module name in the first active line. Use of this option will disable
35289any default module->CMI name mapping.
35290
35291@end table
35292
35293As shown, an optional @var{ident} may suffix the first word of the
35294option, indicated by a @samp{?} prefix. The value is used in the
35295initial handshake with the module server, or to specify a prefix on
35296mapping file lines. In the server case, the main source file name is
35297used if no @var{ident} is specified. In the file case, all non-blank
35298lines are significant, unless a value is specified, in which case only
35299lines beginning with @var{ident} are significant. The @var{ident}
35300must be separated by whitespace from the module name. Be aware that
35301@samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
35302significant to the shell, and therefore may need quoting.
35303
35304The mapper is connected to or loaded lazily, when the first module
35305mapping is required. The networking protocols are only supported on
35306hosts that provide networking. If no mapper is specified a default is
35307provided.
35308
35309A project-specific mapper is expected to be provided by the build
35310system that invokes the compiler. It is not expected that a
35311general-purpose server is provided for all compilations. As such, the
35312server will know the build configuration, the compiler it invoked, and
35313the environment (such as working directory) in which that is
35314operating. As it may parallelize builds, several compilations may
35315connect to the same socket.
35316
35317The default mapper generates CMI files in a @samp{gcm.cache}
35318directory. CMI files have a @samp{.gcm} suffix. The module unit name
35319is used directly to provide the basename. Header units construct a
35320relative path using the underlying header file name. If the path is
35321already relative, a @samp{,} directory is prepended. Internal
35322@samp{..} components are translated to @samp{,,}. No attempt is made
35323to canonicalize these filenames beyond that done by the preprocessor's
35324include search algorithm, as in general it is ambiguous when symbolic
35325links are present.
35326
35327The mapper protocol was published as ``A Module Mapper''
35328@uref{https://wg21.link/p1184}. The implementation is provided by
35329@command{libcody}, @uref{https://github.com/urnathan/libcody},
35330which specifies the canonical protocol definition. A proof of concept
35331server implementation embedded in @command{make} was described in
35332''Make Me A Module'', @uref{https://wg21.link/p1602}.
35333
35334@node C++ Module Preprocessing
35335@subsection Module Preprocessing
35336@cindex C++ Module Preprocessing
35337
35338Modules affect preprocessing because of header units and include
35339translation. Some uses of the preprocessor as a separate step either
35340do not produce a correct output, or require CMIs to be available.
35341
35342Header units import macros. These macros can affect later conditional
35343inclusion, which therefore can cascade to differing import sets. When
35344preprocessing, it is necessary to load the CMI. If a header unit is
35345unavailable, the preprocessor issues a warning and continue (when
35346not just preprocessing, an error is emitted). Detecting such imports
35347requires preprocessor tokenization of the input stream to phase 4
35348(macro expansion).
35349
35350Include translation converts @code{#include}, @code{#include_next} and
35351@code{#import} directives to internal @code{import} declarations.
35352Whether a particular directive is translated is controlled by the
35353module mapper. Header unit names are canonicalized during
35354preprocessing.
35355
35356Dependency information can be emitted for macro import, extending the
35357functionality of @option{-MD} and @option{-MMD} options. Detection of
35358import declarations also requires phase 4 preprocessing, and thus
35359requires full preprocessing (or compilation).
35360
35361The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt
35362preprocessing before phase 4.
35363
35364The @option{-save-temps} option uses @option{-fdirectives-only} for
35365preprocessing, and preserve the macro definitions in the preprocessed
35366output. Usually you also want to use this option when explicitly
35367preprocessing a header-unit, or consuming such preprocessed output:
35368
35369@smallexample
35370g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii
35371g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii
35372@end smallexample
35373
35374@node C++ Compiled Module Interface
35375@subsection Compiled Module Interface
35376@cindex C++ Compiled Module Interface
35377
35378CMIs are an additional artifact when compiling named module
35379interfaces, partitions or header units. These are read when
35380importing. CMI contents are implementation-specific, and in GCC's
35381case tied to the compiler version. Consider them a rebuildable cache
35382artifact, not a distributable object.
35383
35384When creating an output CMI, any missing directory components are
35385created in a manner that is safe for concurrent builds creating
35386multiple, different, CMIs within a common subdirectory tree.
35387
35388CMI contents are written to a temporary file, which is then atomically
35389renamed. Observers either see old contents (if there is an
35390existing file), or complete new contents. They do not observe the
35391CMI during its creation. This is unlike object file writing, which
35392may be observed by an external process.
35393
35394CMIs are read in lazily, if the host OS provides @code{mmap}
35395functionality. Generally blocks are read when name lookup or template
35396instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
35397option may be used.
35398
35399The @option{--param lazy-modules=@var{n}} parameter controls the limit
35400on the number of concurrently open module files during lazy loading.
35401Should more modules be imported, an LRU algorithm is used to determine
35402which files to close---until that file is needed again. This limit
35403may be exceeded with deep module dependency hierarchies. With large
35404code bases there may be more imports than the process limit of file
35405descriptors. By default, the limit is a few less than the per-process
35406file descriptor hard limit, if that is determinable.@footnote{Where
35407applicable the soft limit is incremented as needed towards the hard limit.}
35408
35409GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
35410You may use @command{readelf} to inspect them, although section
35411contents are largely undecipherable. There is a section named
35412@code{.gnu.c++.README}, which contains human-readable text. Other
35413than the first line, each line consists of @code{@var{tag}: @code{value}}
35414tuples.
35415
35416@smallexample
35417> @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
35418
35419String dump of section '.gnu.c++.README':
35420 [ 0] GNU C++ primary module interface
35421 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
35422 [ 6f] version: 2020/11/16-04:54
35423 [ 89] module: foo
35424 [ 95] source: c_b.ii
35425 [ a4] dialect: C++20/coroutines
35426 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
35427 [ ee] repository: gcm.cache
35428 [ 104] buildtime: 2020/11/16 15:03:21 UTC
35429 [ 127] localtime: 2020/11/16 07:03:21 PST
35430 [ 14a] export: foo:part1 foo-part1.gcm
35431@end smallexample
35432
35433Amongst other things, this lists the source that was built, C++
35434dialect used and imports of the module.@footnote{The precise contents
35435of this output may change.} The timestamp is the same value as that
35436provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
35437explicitly specified with the environment variable
35438@code{SOURCE_DATE_EPOCH}. For further details
35439@pxref{Environment Variables}.
35440
35441A set of related CMIs may be copied, provided the relative pathnames
35442are preserved.
35443
35444The @code{.gnu.c++.README} contents do not affect CMI integrity, and
35445it may be removed or altered. The section numbering of the sections
35446whose names do not begin with @code{.gnu.c++.}, or are not the string
35447section is significant and must not be altered.
This page took 3.52435 seconds and 5 git commands to generate.