]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/invoke.texi
Rust: Don't depend on unused 'target-libffi', 'target-libbacktrace'
[thirdparty/gcc.git] / gcc / doc / invoke.texi
CommitLineData
83ffe9cd 1@c Copyright (C) 1988-2023 Free Software Foundation, Inc.
d77de738
ML
2@c This is part of the GCC manual.
3@c For copying conditions, see the file gcc.texi.
4
5@ignore
6@c man begin INCLUDE
7@include gcc-vers.texi
8@c man end
9
10@c man begin COPYRIGHT
74d5206f 11Copyright @copyright{} 1988-2023 Free Software Foundation, Inc.
d77de738
ML
12
13Permission is granted to copy, distribute and/or modify this document
14under the terms of the GNU Free Documentation License, Version 1.3 or
15any later version published by the Free Software Foundation; with the
16Invariant Sections being ``GNU General Public License'' and ``Funding
17Free Software'', the Front-Cover texts being (a) (see below), and with
18the Back-Cover Texts being (b) (see below). A copy of the license is
19included in the gfdl(7) man page.
20
21(a) The FSF's Front-Cover Text is:
22
23 A GNU Manual
24
25(b) The FSF's Back-Cover Text is:
26
27 You have freedom to copy and modify this GNU Manual, like GNU
28 software. Copies published by the Free Software Foundation raise
29 funds for GNU development.
30@c man end
31@c Set file name and title for the man page.
32@setfilename gcc
33@settitle GNU project C and C++ compiler
34@c man begin SYNOPSIS
35gcc [@option{-c}|@option{-S}|@option{-E}] [@option{-std=}@var{standard}]
36 [@option{-g}] [@option{-pg}] [@option{-O}@var{level}]
37 [@option{-W}@var{warn}@dots{}] [@option{-Wpedantic}]
38 [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
39 [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
40 [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}]
41 [@option{-o} @var{outfile}] [@@@var{file}] @var{infile}@dots{}
42
43Only the most useful options are listed here; see below for the
44remainder. @command{g++} accepts mostly the same options as @command{gcc}.
45@c man end
46@c man begin SEEALSO
47gpl(7), gfdl(7), fsf-funding(7),
48cpp(1), gcov(1), as(1), ld(1), gdb(1)
49and the Info entries for @file{gcc}, @file{cpp}, @file{as},
50@file{ld}, @file{binutils} and @file{gdb}.
51@c man end
52@c man begin BUGS
53For instructions on reporting bugs, see
54@w{@value{BUGURL}}.
55@c man end
56@c man begin AUTHOR
57See the Info entry for @command{gcc}, or
58@w{@uref{https://gcc.gnu.org/onlinedocs/gcc/Contributors.html}},
59for contributors to GCC@.
60@c man end
61@end ignore
62
63@node Invoking GCC
64@chapter GCC Command Options
65@cindex GCC command options
66@cindex command options
67@cindex options, GCC command
68
69@c man begin DESCRIPTION
70When you invoke GCC, it normally does preprocessing, compilation,
71assembly and linking. The ``overall options'' allow you to stop this
72process at an intermediate stage. For example, the @option{-c} option
73says not to run the linker. Then the output consists of object files
74output by the assembler.
75@xref{Overall Options,,Options Controlling the Kind of Output}.
76
77Other options are passed on to one or more stages of processing. Some options
78control the preprocessor and others the compiler itself. Yet other
79options control the assembler and linker; most of these are not
80documented here, since you rarely need to use any of them.
81
82@cindex C compilation options
83Most of the command-line options that you can use with GCC are useful
84for C programs; when an option is only useful with another language
85(usually C++), the explanation says so explicitly. If the description
86for a particular option does not mention a source language, you can use
87that option with all supported languages.
88
89@cindex cross compiling
90@cindex specifying machine version
91@cindex specifying compiler version and target machine
92@cindex compiler version, specifying
93@cindex target machine, specifying
94The usual way to run GCC is to run the executable called @command{gcc}, or
95@command{@var{machine}-gcc} when cross-compiling, or
96@command{@var{machine}-gcc-@var{version}} to run a specific version of GCC.
97When you compile C++ programs, you should invoke GCC as @command{g++}
98instead. @xref{Invoking G++,,Compiling C++ Programs},
99for information about the differences in behavior between @command{gcc}
100and @command{g++} when compiling C++ programs.
101
102@cindex grouping options
103@cindex options, grouping
104The @command{gcc} program accepts options and file names as operands. Many
105options have multi-letter names; therefore multiple single-letter options
106may @emph{not} be grouped: @option{-dv} is very different from @w{@samp{-d
107-v}}.
108
109@cindex order of options
110@cindex options, order
111You can mix options and other arguments. For the most part, the order
112you use doesn't matter. Order does matter when you use several
113options of the same kind; for example, if you specify @option{-L} more
114than once, the directories are searched in the order specified. Also,
115the placement of the @option{-l} option is significant.
116
117Many options have long names starting with @samp{-f} or with
118@samp{-W}---for example,
119@option{-fmove-loop-invariants}, @option{-Wformat} and so on. Most of
120these have both positive and negative forms; the negative form of
121@option{-ffoo} is @option{-fno-foo}. This manual documents
122only one of these two forms, whichever one is not the default.
123
124Some options take one or more arguments typically separated either
125by a space or by the equals sign (@samp{=}) from the option name.
126Unless documented otherwise, an argument can be either numeric or
127a string. Numeric arguments must typically be small unsigned decimal
128or hexadecimal integers. Hexadecimal arguments must begin with
129the @samp{0x} prefix. Arguments to options that specify a size
130threshold of some sort may be arbitrarily large decimal or hexadecimal
131integers followed by a byte size suffix designating a multiple of bytes
132such as @code{kB} and @code{KiB} for kilobyte and kibibyte, respectively,
133@code{MB} and @code{MiB} for megabyte and mebibyte, @code{GB} and
134@code{GiB} for gigabyte and gigibyte, and so on. Such arguments are
135designated by @var{byte-size} in the following text. Refer to the NIST,
136IEC, and other relevant national and international standards for the full
137listing and explanation of the binary and decimal byte size prefixes.
138
139@c man end
140
141@xref{Option Index}, for an index to GCC's options.
142
143@menu
144* Option Summary:: Brief list of all options, without explanations.
145* Overall Options:: Controlling the kind of output:
146 an executable, object files, assembler files,
147 or preprocessed source.
148* Invoking G++:: Compiling C++ programs.
149* C Dialect Options:: Controlling the variant of C language compiled.
150* C++ Dialect Options:: Variations on C++.
151* Objective-C and Objective-C++ Dialect Options:: Variations on Objective-C
152 and Objective-C++.
153* Diagnostic Message Formatting Options:: Controlling how diagnostics should
154 be formatted.
155* Warning Options:: How picky should the compiler be?
156* Static Analyzer Options:: More expensive warnings.
157* Debugging Options:: Producing debuggable code.
158* Optimize Options:: How much optimization?
159* Instrumentation Options:: Enabling profiling and extra run-time error checking.
160* Preprocessor Options:: Controlling header files and macro definitions.
161 Also, getting dependency information for Make.
162* Assembler Options:: Passing options to the assembler.
163* Link Options:: Specifying libraries and so on.
164* Directory Options:: Where to find header files and libraries.
165 Where to find the compiler executable files.
166* Code Gen Options:: Specifying conventions for function calls, data layout
167 and register usage.
168* Developer Options:: Printing GCC configuration info, statistics, and
169 debugging dumps.
170* Submodel Options:: Target-specific options, such as compiling for a
171 specific processor variant.
172* Spec Files:: How to pass switches to sub-processes.
173* Environment Variables:: Env vars that affect GCC.
174* Precompiled Headers:: Compiling a header once, and using it many times.
175* C++ Modules:: Experimental C++20 module system.
176@end menu
177
178@c man begin OPTIONS
179
180@node Option Summary
181@section Option Summary
182
183Here is a summary of all the options, grouped by type. Explanations are
184in the following sections.
185
186@table @emph
187@item Overall Options
188@xref{Overall Options,,Options Controlling the Kind of Output}.
189@gccoptlist{-c -S -E -o @var{file} @gol
190-dumpbase @var{dumpbase} -dumpbase-ext @var{auxdropsuf} @gol
191-dumpdir @var{dumppfx} -x @var{language} @gol
192-v -### --help@r{[}=@var{class}@r{[},@dots{}@r{]]} --target-help --version @gol
193-pass-exit-codes -pipe -specs=@var{file} -wrapper @gol
194@@@var{file} -ffile-prefix-map=@var{old}=@var{new} @gol
195-fplugin=@var{file} -fplugin-arg-@var{name}=@var{arg} @gol
196-fdump-ada-spec@r{[}-slim@r{]} -fada-spec-parent=@var{unit} -fdump-go-spec=@var{file}}
197
198@item C Language Options
199@xref{C Dialect Options,,Options Controlling C Dialect}.
200@gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename} @gol
201-fno-asm @gol
202-fno-builtin -fno-builtin-@var{function} -fcond-mismatch @gol
203-ffreestanding -fgimple -fgnu-tm -fgnu89-inline -fhosted @gol
204-flax-vector-conversions -fms-extensions @gol
205-foffload=@var{arg} -foffload-options=@var{arg} @gol
206-fopenacc -fopenacc-dim=@var{geom} @gol
309e2d95 207-fopenmp -fopenmp-simd -fopenmp-target-simd-clone@r{[}=@var{device-type}@r{]} @gol
d77de738
ML
208-fpermitted-flt-eval-methods=@var{standard} @gol
209-fplan9-extensions -fsigned-bitfields -funsigned-bitfields @gol
210-fsigned-char -funsigned-char -fstrict-flex-arrays[=@var{n}] @gol
211-fsso-struct=@var{endianness}}
212
213@item C++ Language Options
214@xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
215@gccoptlist{-fabi-version=@var{n} -fno-access-control @gol
216-faligned-new=@var{n} -fargs-in-order=@var{n} -fchar8_t -fcheck-new @gol
217-fconstexpr-depth=@var{n} -fconstexpr-cache-depth=@var{n} @gol
218-fconstexpr-loop-limit=@var{n} -fconstexpr-ops-limit=@var{n} @gol
219-fno-elide-constructors @gol
220-fno-enforce-eh-specs @gol
221-fno-gnu-keywords @gol
222-fno-implicit-templates @gol
223-fno-implicit-inline-templates @gol
224-fno-implement-inlines @gol
225-fmodule-header@r{[}=@var{kind}@r{]} -fmodule-only -fmodules-ts @gol
226-fmodule-implicit-inline @gol
227-fno-module-lazy @gol
228-fmodule-mapper=@var{specification} @gol
229-fmodule-version-ignore @gol
230-fms-extensions @gol
231-fnew-inheriting-ctors @gol
232-fnew-ttp-matching @gol
233-fno-nonansi-builtins -fnothrow-opt -fno-operator-names @gol
234-fno-optional-diags -fpermissive @gol
235-fno-pretty-templates @gol
236-fno-rtti -fsized-deallocation @gol
237-ftemplate-backtrace-limit=@var{n} @gol
238-ftemplate-depth=@var{n} @gol
239-fno-threadsafe-statics -fuse-cxa-atexit @gol
240-fno-weak -nostdinc++ @gol
241-fvisibility-inlines-hidden @gol
242-fvisibility-ms-compat @gol
243-fext-numeric-literals @gol
244-flang-info-include-translate@r{[}=@var{header}@r{]} @gol
245-flang-info-include-translate-not @gol
246-flang-info-module-cmi@r{[}=@var{module}@r{]} @gol
247-stdlib=@var{libstdc++,libc++} @gol
248-Wabi-tag -Wcatch-value -Wcatch-value=@var{n} @gol
249-Wno-class-conversion -Wclass-memaccess @gol
250-Wcomma-subscript -Wconditionally-supported @gol
251-Wno-conversion-null -Wctad-maybe-unsupported @gol
252-Wctor-dtor-privacy -Wdangling-reference @gol
253-Wno-delete-incomplete @gol
254-Wdelete-non-virtual-dtor -Wno-deprecated-array-compare @gol
255-Wdeprecated-copy -Wdeprecated-copy-dtor @gol
256-Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion @gol
257-Weffc++ -Wno-exceptions -Wextra-semi -Wno-inaccessible-base @gol
258-Wno-inherited-variadic-ctor -Wno-init-list-lifetime @gol
c85f8dbb 259-Winvalid-constexpr -Winvalid-imported-macros @gol
d77de738
ML
260-Wno-invalid-offsetof -Wno-literal-suffix @gol
261-Wmismatched-new-delete -Wmismatched-tags @gol
262-Wmultiple-inheritance -Wnamespaces -Wnarrowing @gol
263-Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor @gol
264-Wpessimizing-move -Wno-placement-new -Wplacement-new=@var{n} @gol
265-Wrange-loop-construct -Wredundant-move -Wredundant-tags @gol
266-Wreorder -Wregister @gol
267-Wstrict-null-sentinel -Wno-subobject-linkage -Wtemplates @gol
268-Wno-non-template-friend -Wold-style-cast @gol
269-Woverloaded-virtual -Wno-pmf-conversions -Wself-move -Wsign-promo @gol
270-Wsized-deallocation -Wsuggest-final-methods @gol
271-Wsuggest-final-types -Wsuggest-override @gol
272-Wno-terminate -Wuseless-cast -Wno-vexing-parse @gol
273-Wvirtual-inheritance @gol
274-Wno-virtual-move-assign -Wvolatile -Wzero-as-null-pointer-constant}
275
276@item Objective-C and Objective-C++ Language Options
277@xref{Objective-C and Objective-C++ Dialect Options,,Options Controlling
278Objective-C and Objective-C++ Dialects}.
279@gccoptlist{-fconstant-string-class=@var{class-name} @gol
280-fgnu-runtime -fnext-runtime @gol
281-fno-nil-receivers @gol
282-fobjc-abi-version=@var{n} @gol
283-fobjc-call-cxx-cdtors @gol
284-fobjc-direct-dispatch @gol
285-fobjc-exceptions @gol
286-fobjc-gc @gol
287-fobjc-nilcheck @gol
288-fobjc-std=objc1 @gol
289-fno-local-ivars @gol
290-fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]} @gol
291-freplace-objc-classes @gol
292-fzero-link @gol
293-gen-decls @gol
294-Wassign-intercept -Wno-property-assign-default @gol
295-Wno-protocol -Wobjc-root-class -Wselector @gol
296-Wstrict-selector-match @gol
297-Wundeclared-selector}
298
299@item Diagnostic Message Formatting Options
300@xref{Diagnostic Message Formatting Options,,Options to Control Diagnostic Messages Formatting}.
301@gccoptlist{-fmessage-length=@var{n} @gol
302-fdiagnostics-plain-output @gol
303-fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]} @gol
304-fdiagnostics-color=@r{[}auto@r{|}never@r{|}always@r{]} @gol
305-fdiagnostics-urls=@r{[}auto@r{|}never@r{|}always@r{]} @gol
306-fdiagnostics-format=@r{[}text@r{|}sarif-stderr@r{|}sarif-file@r{|}json@r{|}json-stderr@r{|}json-file@r{]} @gol
307-fno-diagnostics-show-option -fno-diagnostics-show-caret @gol
308-fno-diagnostics-show-labels -fno-diagnostics-show-line-numbers @gol
309-fno-diagnostics-show-cwe @gol
310-fno-diagnostics-show-rule @gol
311-fdiagnostics-minimum-margin-width=@var{width} @gol
312-fdiagnostics-parseable-fixits -fdiagnostics-generate-patch @gol
313-fdiagnostics-show-template-tree -fno-elide-type @gol
314-fdiagnostics-path-format=@r{[}none@r{|}separate-events@r{|}inline-events@r{]} @gol
315-fdiagnostics-show-path-depths @gol
316-fno-show-column @gol
317-fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]} @gol
318-fdiagnostics-column-origin=@var{origin} @gol
319-fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]}}
320
321@item Warning Options
322@xref{Warning Options,,Options to Request or Suppress Warnings}.
323@gccoptlist{-fsyntax-only -fmax-errors=@var{n} -Wpedantic @gol
324-pedantic-errors @gol
325-w -Wextra -Wall -Wabi=@var{n} @gol
326-Waddress -Wno-address-of-packed-member -Waggregate-return @gol
327-Walloc-size-larger-than=@var{byte-size} -Walloc-zero @gol
328-Walloca -Walloca-larger-than=@var{byte-size} @gol
329-Wno-aggressive-loop-optimizations @gol
330-Warith-conversion @gol
331-Warray-bounds -Warray-bounds=@var{n} -Warray-compare @gol
332-Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias @gol
333-Wno-attribute-warning @gol
334-Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]} @gol
335-Wbool-compare -Wbool-operation @gol
336-Wno-builtin-declaration-mismatch @gol
337-Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat @gol
338-Wc11-c2x-compat @gol
339-Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat @gol
340-Wc++20-compat @gol
341-Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions @gol
342-Wno-c++20-extensions -Wno-c++23-extensions @gol
343-Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual @gol
344-Wchar-subscripts @gol
345-Wclobbered -Wcomment @gol
346-Wconversion -Wno-coverage-mismatch -Wno-cpp @gol
347-Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n} @gol
348-Wdate-time @gol
349-Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init @gol
350-Wdisabled-optimization @gol
351-Wno-discarded-array-qualifiers -Wno-discarded-qualifiers @gol
352-Wno-div-by-zero -Wdouble-promotion @gol
353-Wduplicated-branches -Wduplicated-cond @gol
354-Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion @gol
355-Wenum-int-mismatch @gol
356-Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors @gol
357-Wfloat-conversion -Wfloat-equal -Wformat -Wformat=2 @gol
358-Wno-format-contains-nul -Wno-format-extra-args @gol
359-Wformat-nonliteral -Wformat-overflow=@var{n} @gol
360-Wformat-security -Wformat-signedness -Wformat-truncation=@var{n} @gol
361-Wformat-y2k -Wframe-address @gol
362-Wframe-larger-than=@var{byte-size} -Wno-free-nonheap-object @gol
363-Wno-if-not-aligned -Wno-ignored-attributes @gol
364-Wignored-qualifiers -Wno-incompatible-pointer-types @gol
365-Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=@var{n} @gol
366-Wno-implicit-function-declaration -Wno-implicit-int @gol
367-Winfinite-recursion @gol
368-Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context @gol
369-Wno-int-to-pointer-cast -Wno-invalid-memory-model @gol
370-Winvalid-pch -Winvalid-utf8 -Wno-unicode -Wjump-misses-init @gol
371-Wlarger-than=@var{byte-size} -Wlogical-not-parentheses -Wlogical-op @gol
372-Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized @gol
373-Wmemset-elt-size -Wmemset-transposed-args @gol
374-Wmisleading-indentation -Wmissing-attributes -Wmissing-braces @gol
375-Wmissing-field-initializers -Wmissing-format-attribute @gol
376-Wmissing-include-dirs -Wmissing-noreturn -Wno-missing-profile @gol
377-Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare @gol
378-Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} @gol
379-Wnull-dereference -Wno-odr @gol
380-Wopenacc-parallelism @gol
381-Wopenmp-simd @gol
382-Wno-overflow -Woverlength-strings -Wno-override-init-side-effects @gol
383-Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded @gol
384-Wparentheses -Wno-pedantic-ms-format @gol
385-Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast @gol
386-Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol
387-Wrestrict -Wno-return-local-addr -Wreturn-type @gol
388-Wno-scalar-storage-order -Wsequence-point @gol
389-Wshadow -Wshadow=global -Wshadow=local -Wshadow=compatible-local @gol
390-Wno-shadow-ivar @gol
391-Wno-shift-count-negative -Wno-shift-count-overflow -Wshift-negative-value @gol
392-Wno-shift-overflow -Wshift-overflow=@var{n} @gol
393-Wsign-compare -Wsign-conversion @gol
394-Wno-sizeof-array-argument @gol
395-Wsizeof-array-div @gol
396-Wsizeof-pointer-div -Wsizeof-pointer-memaccess @gol
397-Wstack-protector -Wstack-usage=@var{byte-size} -Wstrict-aliasing @gol
398-Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n} @gol
399-Wstring-compare @gol
400-Wno-stringop-overflow -Wno-stringop-overread @gol
2a27ae32 401-Wno-stringop-truncation -Wstrict-flex-arrays @gol
d77de738
ML
402-Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}malloc@r{]} @gol
403-Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum @gol
404-Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand @gol
405-Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs @gol
406-Wtrivial-auto-var-init -Wtsan -Wtype-limits -Wundef @gol
407-Wuninitialized -Wunknown-pragmas @gol
408-Wunsuffixed-float-constants -Wunused @gol
409-Wunused-but-set-parameter -Wunused-but-set-variable @gol
410-Wunused-const-variable -Wunused-const-variable=@var{n} @gol
411-Wunused-function -Wunused-label -Wunused-local-typedefs @gol
412-Wunused-macros @gol
413-Wunused-parameter -Wno-unused-result @gol
414-Wunused-value -Wunused-variable @gol
415-Wno-varargs -Wvariadic-macros @gol
416-Wvector-operation-performance @gol
417-Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than @gol
418-Wvolatile-register-var -Wwrite-strings @gol
419-Wxor-used-as-pow @gol
420-Wzero-length-bounds}
421
422@item Static Analyzer Options
423@gccoptlist{
424-fanalyzer @gol
425-fanalyzer-call-summaries @gol
426-fanalyzer-checker=@var{name} @gol
427-fno-analyzer-feasibility @gol
428-fanalyzer-fine-grained @gol
429-fno-analyzer-state-merge @gol
430-fno-analyzer-state-purge @gol
8f636915 431-fno-analyzer-suppress-followups @gol
d77de738
ML
432-fanalyzer-transitivity @gol
433-fno-analyzer-undo-inlining @gol
434-fanalyzer-verbose-edges @gol
435-fanalyzer-verbose-state-changes @gol
436-fanalyzer-verbosity=@var{level} @gol
437-fdump-analyzer @gol
438-fdump-analyzer-callgraph @gol
439-fdump-analyzer-exploded-graph @gol
440-fdump-analyzer-exploded-nodes @gol
441-fdump-analyzer-exploded-nodes-2 @gol
442-fdump-analyzer-exploded-nodes-3 @gol
443-fdump-analyzer-exploded-paths @gol
444-fdump-analyzer-feasibility @gol
445-fdump-analyzer-json @gol
446-fdump-analyzer-state-purge @gol
447-fdump-analyzer-stderr @gol
448-fdump-analyzer-supergraph @gol
449-fdump-analyzer-untracked @gol
450-Wno-analyzer-double-fclose @gol
451-Wno-analyzer-double-free @gol
452-Wno-analyzer-exposure-through-output-file @gol
453-Wno-analyzer-exposure-through-uninit-copy @gol
454-Wno-analyzer-fd-access-mode-mismatch @gol
455-Wno-analyzer-fd-double-close @gol
456-Wno-analyzer-fd-leak @gol
86a90006
DM
457-Wno-analyzer-fd-phase-mismatch @gol
458-Wno-analyzer-fd-type-mismatch @gol
d77de738
ML
459-Wno-analyzer-fd-use-after-close @gol
460-Wno-analyzer-fd-use-without-check @gol
461-Wno-analyzer-file-leak @gol
462-Wno-analyzer-free-of-non-heap @gol
463-Wno-analyzer-imprecise-fp-arithmetic @gol
ce51e843 464-Wno-analyzer-infinite-recursion @gol
d77de738
ML
465-Wno-analyzer-jump-through-null @gol
466-Wno-analyzer-malloc-leak @gol
467-Wno-analyzer-mismatching-deallocation @gol
468-Wno-analyzer-null-argument @gol
469-Wno-analyzer-null-dereference @gol
470-Wno-analyzer-out-of-bounds @gol
471-Wno-analyzer-possible-null-argument @gol
472-Wno-analyzer-possible-null-dereference @gol
473-Wno-analyzer-putenv-of-auto-var @gol
474-Wno-analyzer-shift-count-negative @gol
475-Wno-analyzer-shift-count-overflow @gol
476-Wno-analyzer-stale-setjmp-buffer @gol
477-Wno-analyzer-tainted-allocation-size @gol
ce51e843 478-Wno-analyzer-tainted-assertion @gol
d77de738
ML
479-Wno-analyzer-tainted-array-index @gol
480-Wno-analyzer-tainted-divisor @gol
481-Wno-analyzer-tainted-offset @gol
482-Wno-analyzer-tainted-size @gol
483-Wanalyzer-too-complex @gol
484-Wno-analyzer-unsafe-call-within-signal-handler @gol
485-Wno-analyzer-use-after-free @gol
486-Wno-analyzer-use-of-pointer-in-stale-stack-frame @gol
487-Wno-analyzer-use-of-uninitialized-value @gol
488-Wno-analyzer-va-arg-type-mismatch @gol
489-Wno-analyzer-va-list-exhausted @gol
490-Wno-analyzer-va-list-leak @gol
491-Wno-analyzer-va-list-use-after-va-end @gol
492-Wno-analyzer-write-to-const @gol
493-Wno-analyzer-write-to-string-literal @gol
494}
495
496@item C and Objective-C-only Warning Options
497@gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol
498-Wmissing-parameter-type -Wmissing-prototypes -Wnested-externs @gol
499-Wold-style-declaration -Wold-style-definition @gol
500-Wstrict-prototypes -Wtraditional -Wtraditional-conversion @gol
501-Wdeclaration-after-statement -Wpointer-sign}
502
503@item Debugging Options
504@xref{Debugging Options,,Options for Debugging Your Program}.
505@gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version} @gol
506-gbtf -gctf -gctf@var{level} @gol
507-ggdb -grecord-gcc-switches -gno-record-gcc-switches @gol
508-gstrict-dwarf -gno-strict-dwarf @gol
509-gas-loc-support -gno-as-loc-support @gol
510-gas-locview-support -gno-as-locview-support @gol
511-gcolumn-info -gno-column-info -gdwarf32 -gdwarf64 @gol
512-gstatement-frontiers -gno-statement-frontiers @gol
513-gvariable-location-views -gno-variable-location-views @gol
514-ginternal-reset-location-views -gno-internal-reset-location-views @gol
515-ginline-points -gno-inline-points @gol
516-gvms -gz@r{[}=@var{type}@r{]} @gol
517-gsplit-dwarf -gdescribe-dies -gno-describe-dies @gol
518-fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section @gol
519-fno-eliminate-unused-debug-types @gol
520-femit-struct-debug-baseonly -femit-struct-debug-reduced @gol
521-femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} @gol
522-fno-eliminate-unused-debug-symbols -femit-class-debug-always @gol
523-fno-merge-debug-strings -fno-dwarf2-cfi-asm @gol
524-fvar-tracking -fvar-tracking-assignments}
525
526@item Optimization Options
527@xref{Optimize Options,,Options that Control Optimization}.
528@gccoptlist{-faggressive-loop-optimizations @gol
529-falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
530-falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
531-falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
532-falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
533-fno-allocation-dce -fallow-store-data-races @gol
534-fassociative-math -fauto-profile -fauto-profile[=@var{path}] @gol
535-fauto-inc-dec -fbranch-probabilities @gol
536-fcaller-saves @gol
537-fcombine-stack-adjustments -fconserve-stack @gol
538-fcompare-elim -fcprop-registers -fcrossjumping @gol
539-fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules @gol
540-fcx-limited-range @gol
541-fdata-sections -fdce -fdelayed-branch @gol
542-fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively @gol
543-fdevirtualize-at-ltrans -fdse @gol
544-fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects @gol
545-ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style} @gol
546-ffinite-loops @gol
547-fforward-propagate -ffp-contract=@var{style} -ffunction-sections @gol
548-fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity @gol
549-fgcse-sm -fhoist-adjacent-loads -fif-conversion @gol
550-fif-conversion2 -findirect-inlining @gol
551-finline-functions -finline-functions-called-once -finline-limit=@var{n} @gol
552-finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone @gol
553-fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const @gol
554-fipa-reference -fipa-reference-addressable @gol
555-fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm} @gol
556-flive-patching=@var{level} @gol
557-fira-region=@var{region} -fira-hoist-pressure @gol
558-fira-loop-pressure -fno-ira-share-save-slots @gol
559-fno-ira-share-spill-slots @gol
560-fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute @gol
561-fivopts -fkeep-inline-functions -fkeep-static-functions @gol
562-fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage @gol
563-floop-block -floop-interchange -floop-strip-mine @gol
564-floop-unroll-and-jam -floop-nest-optimize @gol
565-floop-parallelize-all -flra-remat -flto -flto-compression-level @gol
566-flto-partition=@var{alg} -fmerge-all-constants @gol
567-fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves @gol
568-fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg @gol
569-fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse @gol
570-fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole @gol
571-fno-peephole2 -fno-printf-return-value -fno-sched-interblock @gol
572-fno-sched-spec -fno-signed-zeros @gol
573-fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss @gol
574-fomit-frame-pointer -foptimize-sibling-calls @gol
575-fpartial-inlining -fpeel-loops -fpredictive-commoning @gol
576-fprefetch-loop-arrays @gol
577-fprofile-correction @gol
578-fprofile-use -fprofile-use=@var{path} -fprofile-partial-training @gol
579-fprofile-values -fprofile-reorder-functions @gol
580-freciprocal-math -free -frename-registers -freorder-blocks @gol
581-freorder-blocks-algorithm=@var{algorithm} @gol
582-freorder-blocks-and-partition -freorder-functions @gol
583-frerun-cse-after-loop -freschedule-modulo-scheduled-loops @gol
584-frounding-math -fsave-optimization-record @gol
585-fsched2-use-superblocks -fsched-pressure @gol
586-fsched-spec-load -fsched-spec-load-dangerous @gol
587-fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}] @gol
588-fsched-group-heuristic -fsched-critical-path-heuristic @gol
589-fsched-spec-insn-heuristic -fsched-rank-heuristic @gol
590-fsched-last-insn-heuristic -fsched-dep-count-heuristic @gol
591-fschedule-fusion @gol
592-fschedule-insns -fschedule-insns2 -fsection-anchors @gol
593-fselective-scheduling -fselective-scheduling2 @gol
594-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops @gol
595-fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate @gol
596-fsignaling-nans @gol
597-fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops@gol
598-fsplit-paths @gol
599-fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt @gol
600-fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing @gol
601-fthread-jumps -ftracer -ftree-bit-ccp @gol
602-ftree-builtin-call-dce -ftree-ccp -ftree-ch @gol
603-ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts @gol
604-ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting @gol
605-ftree-loop-if-convert -ftree-loop-im @gol
606-ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns @gol
607-ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize @gol
608-ftree-loop-vectorize @gol
609-ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta @gol
610-ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra @gol
611-ftree-switch-conversion -ftree-tail-merge @gol
612-ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init @gol
613-funconstrained-commons -funit-at-a-time -funroll-all-loops @gol
614-funroll-loops -funsafe-math-optimizations -funswitch-loops @gol
615-fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt @gol
616-fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs @gol
617--param @var{name}=@var{value}
618-O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz}
619
620@item Program Instrumentation Options
621@xref{Instrumentation Options,,Program Instrumentation Options}.
622@gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage @gol
623-fprofile-abs-path @gol
624-fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path} @gol
625-fprofile-info-section -fprofile-info-section=@var{name} @gol
626-fprofile-note=@var{path} -fprofile-prefix-path=@var{path} @gol
627-fprofile-update=@var{method} -fprofile-filter-files=@var{regex} @gol
628-fprofile-exclude-files=@var{regex} @gol
629-fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} @gol
630-fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} @gol
631-fsanitize-trap -fsanitize-trap=@var{style} @gol
632-fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... @gol
633-fsanitize-undefined-trap-on-error -fbounds-check @gol
634-fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} @gol
635-fharden-compares -fharden-conditional-branches @gol
636-fstack-protector -fstack-protector-all -fstack-protector-strong @gol
637-fstack-protector-explicit -fstack-check @gol
638-fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol
639-fno-stack-limit -fsplit-stack @gol
640-fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} @gol
641-fvtv-counts -fvtv-debug @gol
642-finstrument-functions -finstrument-functions-once @gol
643-finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} @gol
644-finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}} @gol
645-fprofile-prefix-map=@var{old}=@var{new}
646
647@item Preprocessor Options
648@xref{Preprocessor Options,,Options Controlling the Preprocessor}.
649@gccoptlist{-A@var{question}=@var{answer} @gol
650-A-@var{question}@r{[}=@var{answer}@r{]} @gol
651-C -CC -D@var{macro}@r{[}=@var{defn}@r{]} @gol
652-dD -dI -dM -dN -dU @gol
653-fdebug-cpp -fdirectives-only -fdollars-in-identifiers @gol
654-fexec-charset=@var{charset} -fextended-identifiers @gol
655-finput-charset=@var{charset} -flarge-source-files @gol
656-fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth} @gol
657-fno-canonical-system-headers -fpch-deps -fpch-preprocess @gol
658-fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion @gol
659-fwide-exec-charset=@var{charset} -fworking-directory @gol
660-H -imacros @var{file} -include @var{file} @gol
661-M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules @gol
662-no-integrated-cpp -P -pthread -remap @gol
663-traditional -traditional-cpp -trigraphs @gol
664-U@var{macro} -undef @gol
665-Wp,@var{option} -Xpreprocessor @var{option}}
666
667@item Assembler Options
668@xref{Assembler Options,,Passing Options to the Assembler}.
669@gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
670
671@item Linker Options
672@xref{Link Options,,Options for Linking}.
673@gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} @gol
674-nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++ @gol
675-e @var{entry} --entry=@var{entry} @gol
676-pie -pthread -r -rdynamic @gol
677-s -static -static-pie -static-libgcc -static-libstdc++ @gol
678-static-libasan -static-libtsan -static-liblsan -static-libubsan @gol
679-shared -shared-libgcc -symbolic @gol
680-T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol
681-u @var{symbol} -z @var{keyword}}
682
683@item Directory Options
684@xref{Directory Options,,Options for Directory Search}.
685@gccoptlist{-B@var{prefix} -I@var{dir} -I- @gol
686-idirafter @var{dir} @gol
687-imacros @var{file} -imultilib @var{dir} @gol
688-iplugindir=@var{dir} -iprefix @var{file} @gol
689-iquote @var{dir} -isysroot @var{dir} -isystem @var{dir} @gol
690-iwithprefix @var{dir} -iwithprefixbefore @var{dir} @gol
691-L@var{dir} -no-canonical-prefixes --no-sysroot-suffix @gol
692-nostdinc -nostdinc++ --sysroot=@var{dir}}
693
694@item Code Generation Options
695@xref{Code Gen Options,,Options for Code Generation Conventions}.
696@gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} @gol
697-ffixed-@var{reg} -fexceptions @gol
698-fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables @gol
699-fasynchronous-unwind-tables @gol
700-fno-gnu-unique @gol
701-finhibit-size-directive -fcommon -fno-ident @gol
702-fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt @gol
703-fno-jump-tables -fno-bit-tests @gol
704-frecord-gcc-switches @gol
705-freg-struct-return -fshort-enums -fshort-wchar @gol
706-fverbose-asm -fpack-struct[=@var{n}] @gol
707-fleading-underscore -ftls-model=@var{model} @gol
708-fstack-reuse=@var{reuse_level} @gol
709-ftrampolines -ftrapv -fwrapv @gol
710-fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} @gol
711-fstrict-volatile-bitfields -fsync-libcalls}
712
713@item Developer Options
714@xref{Developer Options,,GCC Developer Options}.
715@gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol
716-dumpfullversion -fcallgraph-info@r{[}=su,da@r{]}
717-fchecking -fchecking=@var{n}
718-fdbg-cnt-list @gol -fdbg-cnt=@var{counter-value-list} @gol
719-fdisable-ipa-@var{pass_name} @gol
720-fdisable-rtl-@var{pass_name} @gol
721-fdisable-rtl-@var{pass-name}=@var{range-list} @gol
722-fdisable-tree-@var{pass_name} @gol
723-fdisable-tree-@var{pass-name}=@var{range-list} @gol
724-fdump-debug -fdump-earlydebug @gol
725-fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links @gol
726-fdump-final-insns@r{[}=@var{file}@r{]} @gol
727-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline @gol
728-fdump-lang-all @gol
729-fdump-lang-@var{switch} @gol
730-fdump-lang-@var{switch}-@var{options} @gol
731-fdump-lang-@var{switch}-@var{options}=@var{filename} @gol
732-fdump-passes @gol
733-fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename} @gol
734-fdump-statistics @gol
735-fdump-tree-all @gol
736-fdump-tree-@var{switch} @gol
737-fdump-tree-@var{switch}-@var{options} @gol
738-fdump-tree-@var{switch}-@var{options}=@var{filename} @gol
739-fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second @gol
740-fenable-@var{kind}-@var{pass} @gol
741-fenable-@var{kind}-@var{pass}=@var{range-list} @gol
742-fira-verbose=@var{n} @gol
743-flto-report -flto-report-wpa -fmem-report-wpa @gol
744-fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report @gol
745-fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]} @gol
746-fmultiflags -fprofile-report @gol
747-frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
748-fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose @gol
749-fstats -fstack-usage -ftime-report -ftime-report-details @gol
750-fvar-tracking-assignments-toggle -gtoggle @gol
751-print-file-name=@var{library} -print-libgcc-file-name @gol
752-print-multi-directory -print-multi-lib -print-multi-os-directory @gol
753-print-prog-name=@var{program} -print-search-dirs -Q @gol
754-print-sysroot -print-sysroot-headers-suffix @gol
755-save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}
756
757@item Machine-Dependent Options
758@xref{Submodel Options,,Machine-Dependent Options}.
759@c This list is ordered alphanumerically by subsection name.
760@c Try and put the significant identifier (CPU or system) first,
761@c so users have a clue at guessing where the ones they want will be.
762
763@emph{AArch64 Options}
764@gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian @gol
765-mgeneral-regs-only @gol
766-mcmodel=tiny -mcmodel=small -mcmodel=large @gol
767-mstrict-align -mno-strict-align @gol
768-momit-leaf-frame-pointer @gol
769-mtls-dialect=desc -mtls-dialect=traditional @gol
770-mtls-size=@var{size} @gol
771-mfix-cortex-a53-835769 -mfix-cortex-a53-843419 @gol
772-mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div @gol
773-mpc-relative-literal-loads @gol
774-msign-return-address=@var{scope} @gol
775-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}
776+@var{b-key}]|@var{bti} @gol
777-mharden-sls=@var{opts} @gol
778-march=@var{name} -mcpu=@var{name} -mtune=@var{name} @gol
779-moverride=@var{string} -mverbose-cost-dump @gol
780-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg} @gol
781-mstack-protector-guard-offset=@var{offset} -mtrack-speculation @gol
782-moutline-atomics }
783
784@emph{Adapteva Epiphany Options}
785@gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs @gol
786-mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf @gol
787-msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num} @gol
788-mround-nearest -mlong-calls -mshort-calls -msmall16 @gol
789-mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num} @gol
790-msplit-vecmove-early -m1reg-@var{reg}}
791
792@emph{AMD GCN Options}
793@gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}}
794
795@emph{ARC Options}
796@gccoptlist{-mbarrel-shifter -mjli-always @gol
797-mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700 @gol
798-mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr @gol
799-mea -mno-mpy -mmul32x16 -mmul64 -matomic @gol
800-mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap @gol
801-mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape @gol
802-mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof @gol
803-mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved @gol
804-mrgf-banked-regs -mlpc-width=@var{width} -G @var{num} @gol
805-mvolatile-cache -mtp-regno=@var{regno} @gol
806-malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc @gol
807-mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi @gol
808-mexpand-adddi -mindexed-loads -mlra -mlra-priority-none @gol
809-mlra-priority-compact -mlra-priority-noncompact -mmillicode @gol
810-mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level} @gol
811-mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame @gol
812-munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo} @gol
813-mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index}
814
815@emph{ARM Options}
816@gccoptlist{-mapcs-frame -mno-apcs-frame @gol
817-mabi=@var{name} @gol
818-mapcs-stack-check -mno-apcs-stack-check @gol
819-mapcs-reentrant -mno-apcs-reentrant @gol
820-mgeneral-regs-only @gol
821-msched-prolog -mno-sched-prolog @gol
822-mlittle-endian -mbig-endian @gol
823-mbe8 -mbe32 @gol
824-mfloat-abi=@var{name} @gol
825-mfp16-format=@var{name}
826-mthumb-interwork -mno-thumb-interwork @gol
827-mcpu=@var{name} -march=@var{name} -mfpu=@var{name} @gol
828-mtune=@var{name} -mprint-tune-info @gol
829-mstructure-size-boundary=@var{n} @gol
830-mabort-on-noreturn @gol
831-mlong-calls -mno-long-calls @gol
832-msingle-pic-base -mno-single-pic-base @gol
833-mpic-register=@var{reg} @gol
834-mnop-fun-dllimport @gol
835-mpoke-function-name @gol
836-mthumb -marm -mflip-thumb @gol
837-mtpcs-frame -mtpcs-leaf-frame @gol
838-mcaller-super-interworking -mcallee-super-interworking @gol
839-mtp=@var{name} -mtls-dialect=@var{dialect} @gol
840-mword-relocations @gol
841-mfix-cortex-m3-ldrd @gol
842-mfix-cortex-a57-aes-1742098 @gol
843-mfix-cortex-a72-aes-1655431 @gol
844-munaligned-access @gol
845-mneon-for-64bits @gol
846-mslow-flash-data @gol
847-masm-syntax-unified @gol
848-mrestrict-it @gol
849-mverbose-cost-dump @gol
850-mpure-code @gol
851-mcmse @gol
852-mfix-cmse-cve-2021-35465 @gol
853-mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset} @gol
14fab5fb
AC
854-mfdpic @gol
855-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}]
856[+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]}
d77de738
ML
857
858@emph{AVR Options}
859@gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args @gol
860-mbranch-cost=@var{cost} @gol
861-mcall-prologues -mgas-isr-prologues -mint8 @gol
862-mdouble=@var{bits} -mlong-double=@var{bits} @gol
863-mn_flash=@var{size} -mno-interrupts @gol
864-mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack @gol
865-mfract-convert-truncate @gol
866-mshort-calls -nodevicelib -nodevicespecs @gol
867-Waddr-space-convert -Wmisspelled-isr}
868
869@emph{Blackfin Options}
870@gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} @gol
871-msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer @gol
872-mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly @gol
873-mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library @gol
874-mno-id-shared-library -mshared-library-id=@var{n} @gol
875-mleaf-id-shared-library -mno-leaf-id-shared-library @gol
876-msep-data -mno-sep-data -mlong-calls -mno-long-calls @gol
877-mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram @gol
878-micplb}
879
880@emph{C6X Options}
881@gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu} @gol
882-msim -msdata=@var{sdata-type}}
883
884@emph{CRIS Options}
885@gccoptlist{-mcpu=@var{cpu} -march=@var{cpu}
886-mtune=@var{cpu} -mmax-stack-frame=@var{n} @gol
887-metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects @gol
888-mstack-align -mdata-align -mconst-align @gol
889-m32-bit -m16-bit -m8-bit -mno-prologue-epilogue @gol
890-melf -maout -sim -sim2 @gol
891-mmul-bug-workaround -mno-mul-bug-workaround}
892
893@emph{C-SKY Options}
894@gccoptlist{-march=@var{arch} -mcpu=@var{cpu} @gol
895-mbig-endian -EB -mlittle-endian -EL @gol
896-mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu @gol
897-mfloat-abi=@var{name} @gol
898-melrw -mistack -mmp -mcp -mcache -msecurity -mtrust @gol
899-mdsp -medsp -mvdsp @gol
900-mdiv -msmart -mhigh-registers -manchor @gol
901-mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt @gol
902-mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim}
903
904@emph{Darwin Options}
905@gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal @gol
906-arch_only -bind_at_load -bundle -bundle_loader @gol
907-client_name -compatibility_version -current_version @gol
908-dead_strip @gol
909-dependency-file -dylib_file -dylinker_install_name @gol
910-dynamic -dynamiclib -exported_symbols_list @gol
911-filelist -flat_namespace -force_cpusubtype_ALL @gol
912-force_flat_namespace -headerpad_max_install_names @gol
913-iframework @gol
914-image_base -init -install_name -keep_private_externs @gol
915-multi_module -multiply_defined -multiply_defined_unused @gol
916-noall_load -no_dead_strip_inits_and_terms @gol
917-nofixprebinding -nomultidefs -noprebind -noseglinkedit @gol
918-pagezero_size -prebind -prebind_all_twolevel_modules @gol
919-private_bundle -read_only_relocs -sectalign @gol
920-sectobjectsymbols -whyload -seg1addr @gol
921-sectcreate -sectobjectsymbols -sectorder @gol
922-segaddr -segs_read_only_addr -segs_read_write_addr @gol
923-seg_addr_table -seg_addr_table_filename -seglinkedit @gol
924-segprot -segs_read_only_addr -segs_read_write_addr @gol
925-single_module -static -sub_library -sub_umbrella @gol
926-twolevel_namespace -umbrella -undefined @gol
927-unexported_symbols_list -weak_reference_mismatches @gol
928-whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version} @gol
929-mkernel -mone-byte-bool}
930
931@emph{DEC Alpha Options}
932@gccoptlist{-mno-fp-regs -msoft-float @gol
933-mieee -mieee-with-inexact -mieee-conformant @gol
934-mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} @gol
935-mtrap-precision=@var{mode} -mbuild-constants @gol
936-mcpu=@var{cpu-type} -mtune=@var{cpu-type} @gol
937-mbwx -mmax -mfix -mcix @gol
938-mfloat-vax -mfloat-ieee @gol
939-mexplicit-relocs -msmall-data -mlarge-data @gol
940-msmall-text -mlarge-text @gol
941-mmemory-latency=@var{time}}
942
943@emph{eBPF Options}
944@gccoptlist{-mbig-endian -mlittle-endian -mkernel=@var{version}
945-mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re
946-mjmpext -mjmp32 -malu32 -mcpu=@var{version}}
947
948@emph{FR30 Options}
949@gccoptlist{-msmall-model -mno-lsim}
950
951@emph{FT32 Options}
952@gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm}
953
954@emph{FRV Options}
955@gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 @gol
956-mhard-float -msoft-float @gol
957-malloc-cc -mfixed-cc -mdword -mno-dword @gol
958-mdouble -mno-double @gol
959-mmedia -mno-media -mmuladd -mno-muladd @gol
960-mfdpic -minline-plt -mgprel-ro -multilib-library-pic @gol
961-mlinked-fp -mlong-calls -malign-labels @gol
962-mlibrary-pic -macc-4 -macc-8 @gol
963-mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move @gol
964-moptimize-membar -mno-optimize-membar @gol
965-mscc -mno-scc -mcond-exec -mno-cond-exec @gol
966-mvliw-branch -mno-vliw-branch @gol
967-mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec @gol
968-mno-nested-cond-exec -mtomcat-stats @gol
969-mTLS -mtls @gol
970-mcpu=@var{cpu}}
971
972@emph{GNU/Linux Options}
973@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid @gol
974-tno-android-cc -tno-android-ld}
975
976@emph{H8/300 Options}
977@gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300}
978
979@emph{HPPA Options}
980@gccoptlist{-march=@var{architecture-type} @gol
cf467fb9 981-matomic-libcalls -mbig-switch @gol
d77de738 982-mcaller-copies -mdisable-fpregs -mdisable-indexing @gol
cf467fb9 983-mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld @gol
d77de738 984-mfixed-range=@var{register-range} @gol
cf467fb9
JDA
985-mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls @gol
986-mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs @gol
d77de738
ML
987-mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol
988-mno-jump-in-delay -mno-long-load-store @gol
989-mno-portable-runtime -mno-soft-float @gol
990-mno-space-regs -msoft-float -mpa-risc-1-0 @gol
991-mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol
cf467fb9 992-mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio @gol
d77de738
ML
993-munix=@var{unix-std} -nolibdld -static -threads}
994
995@emph{IA-64 Options}
996@gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol
997-mvolatile-asm-stop -mregister-names -msdata -mno-sdata @gol
998-mconstant-gp -mauto-pic -mfused-madd @gol
999-minline-float-divide-min-latency @gol
1000-minline-float-divide-max-throughput @gol
1001-mno-inline-float-divide @gol
1002-minline-int-divide-min-latency @gol
1003-minline-int-divide-max-throughput @gol
1004-mno-inline-int-divide @gol
1005-minline-sqrt-min-latency -minline-sqrt-max-throughput @gol
1006-mno-inline-sqrt @gol
1007-mdwarf2-asm -mearly-stop-bits @gol
1008-mfixed-range=@var{register-range} -mtls-size=@var{tls-size} @gol
1009-mtune=@var{cpu-type} -milp32 -mlp64 @gol
1010-msched-br-data-spec -msched-ar-data-spec -msched-control-spec @gol
1011-msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec @gol
1012-msched-spec-ldc -msched-spec-control-ldc @gol
1013-msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns @gol
1014-msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path @gol
1015-msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost @gol
1016-msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}}
1017
1018@emph{LM32 Options}
1019@gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled @gol
1020-msign-extend-enabled -muser-enabled}
1021
1022@emph{LoongArch Options}
1023@gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type} @gol
1024-mfpu=@var{fpu-type} -msoft-float -msingle-float -mdouble-float @gol
1025-mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division @gol
1026-mcond-move-int -mno-cond-move-int @gol
1027-mcond-move-float -mno-cond-move-float @gol
1028-memcpy -mno-memcpy -mstrict-align -mno-strict-align @gol
1029-mmax-inline-memcpy-size=@var{n} @gol
1030-mexplicit-relocs -mno-explicit-relocs @gol
1031-mdirect-extern-access -mno-direct-extern-access @gol
1032-mcmodel=@var{code-model}}
1033
1034@emph{M32R/D Options}
1035@gccoptlist{-m32r2 -m32rx -m32r @gol
1036-mdebug @gol
1037-malign-loops -mno-align-loops @gol
1038-missue-rate=@var{number} @gol
1039-mbranch-cost=@var{number} @gol
1040-mmodel=@var{code-size-model-type} @gol
1041-msdata=@var{sdata-type} @gol
1042-mno-flush-func -mflush-func=@var{name} @gol
1043-mno-flush-trap -mflush-trap=@var{number} @gol
1044-G @var{num}}
1045
1046@emph{M32C Options}
1047@gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
1048
1049@emph{M680x0 Options}
1050@gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune} @gol
1051-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol
1052-m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407 @gol
1053-mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020 @gol
1054-mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort @gol
1055-mno-short -mhard-float -m68881 -msoft-float -mpcrel @gol
1056-malign-int -mstrict-align -msep-data -mno-sep-data @gol
1057-mshared-library-id=n -mid-shared-library -mno-id-shared-library @gol
1058-mxgot -mno-xgot -mlong-jump-table-offsets}
1059
1060@emph{MCore Options}
1061@gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol
1062-mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol
1063-m4byte-functions -mno-4byte-functions -mcallgraph-data @gol
1064-mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol
1065-mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
1066
d77de738
ML
1067@emph{MicroBlaze Options}
1068@gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu} @gol
1069-mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift @gol
1070-mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss @gol
1071-mxl-multiply-high -mxl-float-convert -mxl-float-sqrt @gol
1072-mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model} @gol
1073-mpic-data-is-text-relative}
1074
1075@emph{MIPS Options}
1076@gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} @gol
1077-mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5 @gol
1078-mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6 @gol
1079-mips16 -mno-mips16 -mflip-mips16 @gol
1080-minterlink-compressed -mno-interlink-compressed @gol
1081-minterlink-mips16 -mno-interlink-mips16 @gol
1082-mabi=@var{abi} -mabicalls -mno-abicalls @gol
1083-mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot @gol
1084-mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float @gol
1085-mno-float -msingle-float -mdouble-float @gol
1086-modd-spreg -mno-odd-spreg @gol
1087-mabs=@var{mode} -mnan=@var{encoding} @gol
1088-mdsp -mno-dsp -mdspr2 -mno-dspr2 @gol
1089-mmcu -mmno-mcu @gol
1090-meva -mno-eva @gol
1091-mvirt -mno-virt @gol
1092-mxpa -mno-xpa @gol
1093-mcrc -mno-crc @gol
1094-mginv -mno-ginv @gol
1095-mmicromips -mno-micromips @gol
1096-mmsa -mno-msa @gol
1097-mloongson-mmi -mno-loongson-mmi @gol
1098-mloongson-ext -mno-loongson-ext @gol
1099-mloongson-ext2 -mno-loongson-ext2 @gol
1100-mfpu=@var{fpu-type} @gol
1101-msmartmips -mno-smartmips @gol
1102-mpaired-single -mno-paired-single -mdmx -mno-mdmx @gol
1103-mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc @gol
1104-mlong64 -mlong32 -msym32 -mno-sym32 @gol
1105-G@var{num} -mlocal-sdata -mno-local-sdata @gol
1106-mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt @gol
1107-membedded-data -mno-embedded-data @gol
1108-muninit-const-in-rodata -mno-uninit-const-in-rodata @gol
1109-mcode-readable=@var{setting} @gol
1110-msplit-addresses -mno-split-addresses @gol
1111-mexplicit-relocs -mno-explicit-relocs @gol
1112-mcheck-zero-division -mno-check-zero-division @gol
1113-mdivide-traps -mdivide-breaks @gol
1114-mload-store-pairs -mno-load-store-pairs @gol
1115-munaligned-access -mno-unaligned-access @gol
1116-mmemcpy -mno-memcpy -mlong-calls -mno-long-calls @gol
1117-mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp @gol
1118-mfix-24k -mno-fix-24k @gol
1119-mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 @gol
1120-mfix-r5900 -mno-fix-r5900 @gol
1121-mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000 @gol
1122-mfix-vr4120 -mno-fix-vr4120 @gol
1123-mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1 @gol
1124-mflush-func=@var{func} -mno-flush-func @gol
1125-mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely @gol
1126-mcompact-branches=@var{policy} @gol
1127-mfp-exceptions -mno-fp-exceptions @gol
1128-mvr4130-align -mno-vr4130-align -msynci -mno-synci @gol
1129-mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4 @gol
1130-mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address @gol
1131-mframe-header-opt -mno-frame-header-opt}
1132
1133@emph{MMIX Options}
1134@gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu @gol
1135-mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols @gol
1136-melf -mbranch-predict -mno-branch-predict -mbase-addresses @gol
1137-mno-base-addresses -msingle-exit -mno-single-exit}
1138
1139@emph{MN10300 Options}
1140@gccoptlist{-mmult-bug -mno-mult-bug @gol
1141-mno-am33 -mam33 -mam33-2 -mam34 @gol
1142-mtune=@var{cpu-type} @gol
1143-mreturn-pointer-on-d0 @gol
1144-mno-crt0 -mrelax -mliw -msetlb}
1145
1146@emph{Moxie Options}
1147@gccoptlist{-meb -mel -mmul.x -mno-crt0}
1148
1149@emph{MSP430 Options}
1150@gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax @gol
1151-mwarn-mcu @gol
1152-mcode-region= -mdata-region= @gol
1153-msilicon-errata= -msilicon-errata-warn= @gol
1154-mhwmult= -minrt -mtiny-printf -mmax-inline-shift=}
1155
1156@emph{NDS32 Options}
1157@gccoptlist{-mbig-endian -mlittle-endian @gol
1158-mreduced-regs -mfull-regs @gol
1159-mcmov -mno-cmov @gol
1160-mext-perf -mno-ext-perf @gol
1161-mext-perf2 -mno-ext-perf2 @gol
1162-mext-string -mno-ext-string @gol
1163-mv3push -mno-v3push @gol
1164-m16bit -mno-16bit @gol
1165-misr-vector-size=@var{num} @gol
1166-mcache-block-size=@var{num} @gol
1167-march=@var{arch} @gol
1168-mcmodel=@var{code-model} @gol
1169-mctor-dtor -mrelax}
1170
1171@emph{Nios II Options}
1172@gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt @gol
1173-mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp} @gol
1174-mel -meb @gol
1175-mno-bypass-cache -mbypass-cache @gol
1176-mno-cache-volatile -mcache-volatile @gol
1177-mno-fast-sw-div -mfast-sw-div @gol
1178-mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div @gol
1179-mcustom-@var{insn}=@var{N} -mno-custom-@var{insn} @gol
1180-mcustom-fpu-cfg=@var{name} @gol
1181-mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name} @gol
1182-march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx}
1183
1184@emph{Nvidia PTX Options}
1185@gccoptlist{-m64 -mmainkernel -moptimize}
1186
1187@emph{OpenRISC Options}
1188@gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div @gol
1189-msoft-mul -msoft-div @gol
1190-msoft-float -mhard-float -mdouble-float -munordered-float @gol
1191-mcmov -mror -mrori -msext -msfimm -mshftimm @gol
1192-mcmodel=@var{code-model}}
1193
1194@emph{PDP-11 Options}
1195@gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 @gol
1196-mint32 -mno-int16 -mint16 -mno-int32 @gol
1197-msplit -munix-asm -mdec-asm -mgnu-asm -mlra}
1198
d77de738
ML
1199@emph{PowerPC Options}
1200See RS/6000 and PowerPC Options.
1201
1202@emph{PRU Options}
1203@gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop @gol
f58e6d42 1204-mabi=@var{variant}}
d77de738
ML
1205
1206@emph{RISC-V Options}
1207@gccoptlist{-mbranch-cost=@var{N-instruction} @gol
1208-mplt -mno-plt @gol
1209-mabi=@var{ABI-string} @gol
1210-mfdiv -mno-fdiv @gol
1211-mdiv -mno-div @gol
1212-misa-spec=@var{ISA-spec-string} @gol
1213-march=@var{ISA-string} @gol
1214-mtune=@var{processor-string} @gol
1215-mpreferred-stack-boundary=@var{num} @gol
1216-msmall-data-limit=@var{N-bytes} @gol
1217-msave-restore -mno-save-restore @gol
1218-mshorten-memrefs -mno-shorten-memrefs @gol
1219-mstrict-align -mno-strict-align @gol
1220-mcmodel=medlow -mcmodel=medany @gol
1221-mexplicit-relocs -mno-explicit-relocs @gol
1222-mrelax -mno-relax @gol
1223-mriscv-attribute -mno-riscv-attribute @gol
1224-malign-data=@var{type} @gol
1225-mbig-endian -mlittle-endian @gol
1226-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol
f58e6d42
CM
1227-mstack-protector-guard-offset=@var{offset} @gol
1228-mcsr-check -mno-csr-check}
d77de738
ML
1229
1230@emph{RL78 Options}
1231@gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs @gol
1232-mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14 @gol
1233-m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts}
1234
1235@emph{RS/6000 and PowerPC Options}
1236@gccoptlist{-mcpu=@var{cpu-type} @gol
1237-mtune=@var{cpu-type} @gol
1238-mcmodel=@var{code-model} @gol
1239-mpowerpc64 @gol
1240-maltivec -mno-altivec @gol
1241-mpowerpc-gpopt -mno-powerpc-gpopt @gol
1242-mpowerpc-gfxopt -mno-powerpc-gfxopt @gol
1243-mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd @gol
1244-mfprnd -mno-fprnd @gol
1245-mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp @gol
1246-mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc @gol
1247-m64 -m32 -mxl-compat -mno-xl-compat -mpe @gol
1248-malign-power -malign-natural @gol
1249-msoft-float -mhard-float -mmultiple -mno-multiple @gol
1250-mupdate -mno-update @gol
1251-mavoid-indexed-addresses -mno-avoid-indexed-addresses @gol
1252-mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol
1253-mstrict-align -mno-strict-align -mrelocatable @gol
1254-mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol
1255-mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol
1256-mdynamic-no-pic -mswdiv -msingle-pic-base @gol
1257-mprioritize-restricted-insns=@var{priority} @gol
1258-msched-costly-dep=@var{dependence_type} @gol
1259-minsert-sched-nops=@var{scheme} @gol
1260-mcall-aixdesc -mcall-eabi -mcall-freebsd @gol
1261-mcall-linux -mcall-netbsd -mcall-openbsd @gol
1262-mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi @gol
1263-mtraceback=@var{traceback_type} @gol
1264-maix-struct-return -msvr4-struct-return @gol
1265-mabi=@var{abi-type} -msecure-plt -mbss-plt @gol
1266-mlongcall -mno-longcall -mpltseq -mno-pltseq @gol
1267-mblock-move-inline-limit=@var{num} @gol
1268-mblock-compare-inline-limit=@var{num} @gol
1269-mblock-compare-inline-loop-limit=@var{num} @gol
1270-mno-block-ops-unaligned-vsx @gol
1271-mstring-compare-inline-limit=@var{num} @gol
1272-misel -mno-isel @gol
1273-mvrsave -mno-vrsave @gol
1274-mmulhw -mno-mulhw @gol
1275-mdlmzb -mno-dlmzb @gol
1276-mprototype -mno-prototype @gol
1277-msim -mmvme -mads -myellowknife -memb -msdata @gol
1278-msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num} @gol
1279-mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision @gol
1280-mno-recip-precision @gol
1281-mveclibabi=@var{type} -mfriz -mno-friz @gol
1282-mpointers-to-nested-functions -mno-pointers-to-nested-functions @gol
1283-msave-toc-indirect -mno-save-toc-indirect @gol
1284-mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector @gol
1285-mcrypto -mno-crypto -mhtm -mno-htm @gol
1286-mquad-memory -mno-quad-memory @gol
1287-mquad-memory-atomic -mno-quad-memory-atomic @gol
1288-mcompat-align-parm -mno-compat-align-parm @gol
1289-mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware @gol
1290-mgnu-attribute -mno-gnu-attribute @gol
1291-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol
1292-mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed @gol
1293-mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect @gol
1294-mprivileged -mno-privileged}
1295
1296@emph{RX Options}
1297@gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu@gol
1298-mcpu=@gol
1299-mbig-endian-data -mlittle-endian-data @gol
1300-msmall-data @gol
1301-msim -mno-sim@gol
1302-mas100-syntax -mno-as100-syntax@gol
1303-mrelax@gol
1304-mmax-constant-size=@gol
1305-mint-register=@gol
1306-mpid@gol
1307-mallow-string-insns -mno-allow-string-insns@gol
1308-mjsr@gol
1309-mno-warn-multiple-fast-interrupts@gol
1310-msave-acc-in-interrupts}
1311
1312@emph{S/390 and zSeries Options}
1313@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
1314-mhard-float -msoft-float -mhard-dfp -mno-hard-dfp @gol
1315-mlong-double-64 -mlong-double-128 @gol
1316-mbackchain -mno-backchain -mpacked-stack -mno-packed-stack @gol
1317-msmall-exec -mno-small-exec -mmvcle -mno-mvcle @gol
1318-m64 -m31 -mdebug -mno-debug -mesa -mzarch @gol
1319-mhtm -mvx -mzvector @gol
1320-mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip @gol
1321-mfused-madd -mno-fused-madd @gol
1322-mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard @gol
1323-mhotpatch=@var{halfwords},@var{halfwords}}
1324
d77de738
ML
1325@emph{SH Options}
1326@gccoptlist{-m1 -m2 -m2e @gol
1327-m2a-nofpu -m2a-single-only -m2a-single -m2a @gol
1328-m3 -m3e @gol
1329-m4-nofpu -m4-single-only -m4-single -m4 @gol
1330-m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al @gol
1331-mb -ml -mdalign -mrelax @gol
1332-mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave @gol
1333-mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct @gol
1334-mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy} @gol
1335-mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} @gol
1336-maccumulate-outgoing-args @gol
1337-matomic-model=@var{atomic-model} @gol
1338-mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch @gol
1339-mcbranch-force-delay-slot @gol
1340-mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra @gol
1341-mpretend-cmove -mtas}
1342
1343@emph{Solaris 2 Options}
1344@gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text @gol
1345-pthreads}
1346
1347@emph{SPARC Options}
1348@gccoptlist{-mcpu=@var{cpu-type} @gol
1349-mtune=@var{cpu-type} @gol
1350-mcmodel=@var{code-model} @gol
1351-mmemory-model=@var{mem-model} @gol
1352-m32 -m64 -mapp-regs -mno-app-regs @gol
1353-mfaster-structs -mno-faster-structs -mflat -mno-flat @gol
1354-mfpu -mno-fpu -mhard-float -msoft-float @gol
1355-mhard-quad-float -msoft-quad-float @gol
1356-mstack-bias -mno-stack-bias @gol
1357-mstd-struct-return -mno-std-struct-return @gol
1358-munaligned-doubles -mno-unaligned-doubles @gol
1359-muser-mode -mno-user-mode @gol
1360-mv8plus -mno-v8plus -mvis -mno-vis @gol
1361-mvis2 -mno-vis2 -mvis3 -mno-vis3 @gol
1362-mvis4 -mno-vis4 -mvis4b -mno-vis4b @gol
1363-mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld @gol
1364-mpopc -mno-popc -msubxc -mno-subxc @gol
1365-mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc @gol
1366-mlra -mno-lra}
1367
1368@emph{System V Options}
1369@gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
1370
1371@emph{V850 Options}
1372@gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep @gol
1373-mprolog-function -mno-prolog-function -mspace @gol
1374-mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol
1375-mapp-regs -mno-app-regs @gol
1376-mdisable-callt -mno-disable-callt @gol
1377-mv850e2v3 -mv850e2 -mv850e1 -mv850es @gol
1378-mv850e -mv850 -mv850e3v5 @gol
1379-mloop @gol
1380-mrelax @gol
1381-mlong-jumps @gol
1382-msoft-float @gol
1383-mhard-float @gol
1384-mgcc-abi @gol
1385-mrh850-abi @gol
1386-mbig-switch}
1387
1388@emph{VAX Options}
1389@gccoptlist{-mg -mgnu -munix -mlra}
1390
1391@emph{Visium Options}
1392@gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float @gol
1393-mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode}
1394
1395@emph{VMS Options}
1396@gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64 @gol
1397-mpointer-size=@var{size}}
1398
1399@emph{VxWorks Options}
1400@gccoptlist{-mrtp -non-static -Bstatic -Bdynamic @gol
1401-Xbind-lazy -Xbind-now}
1402
1403@emph{x86 Options}
1404@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
1405-mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default @gol
1406-mfpmath=@var{unit} @gol
1407-masm=@var{dialect} -mno-fancy-math-387 @gol
1408-mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float @gol
1409-mno-wide-multiply -mrtd -malign-double @gol
1410-mpreferred-stack-boundary=@var{num} @gol
1411-mincoming-stack-boundary=@var{num} @gol
1412-mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait @gol
1413-mrecip -mrecip=@var{opt} @gol
1414-mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt} @gol
1415-mmove-max=@var{bits} -mstore-max=@var{bits} @gol
1416-mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx @gol
1417-mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl @gol
1418-mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes @gol
1419-mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd @gol
1420-mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves @gol
1421-msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop @gol
1422-madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp @gol
1423-mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg @gol
1424-mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call @gol
1425-mavx512vbmi2 -mavx512bf16 -menqcmd @gol
1426-mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq @gol
1427-mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid @gol
1428-mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk@gol
1429-mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni@gol
1430-mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16 @gol
1431-mprefetchi -mraoint @gol
1432-mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops @gol
1433-minline-stringops-dynamically -mstringop-strategy=@var{alg} @gol
1434-mkl -mwidekl @gol
1435-mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy} @gol
1436-mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
1437-m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128 @gol
1438-mregparm=@var{num} -msseregparm @gol
1439-mveclibabi=@var{type} -mvect8-ret-in-mem @gol
e54375d8 1440-mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign @gol
d77de738
ML
1441-momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs @gol
1442-mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} @gol
1443-m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num} @gol
1444-msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv @gol
1445-minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name} @gol
1446-mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
1447-malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
1448-mstack-protector-guard-reg=@var{reg} @gol
1449-mstack-protector-guard-offset=@var{offset} @gol
1450-mstack-protector-guard-symbol=@var{symbol} @gol
1451-mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop @gol
1452-mindirect-branch=@var{choice} -mfunction-return=@var{choice} @gol
1453-mindirect-branch-register -mharden-sls=@var{choice} @gol
ce51e843 1454-mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access @gol
bb576017 1455-munroll-only-small-loops -mlam=@var{choice}}
d77de738
ML
1456
1457@emph{x86 Windows Options}
1458@gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
1459-mnop-fun-dllimport -mthread @gol
1460-municode -mwin32 -mwindows -fno-set-stack-executable}
1461
1462@emph{Xstormy16 Options}
1463@gccoptlist{-msim}
1464
1465@emph{Xtensa Options}
1466@gccoptlist{-mconst16 -mno-const16 @gol
1467-mfused-madd -mno-fused-madd @gol
1468-mforce-no-pic @gol
1469-mserialize-volatile -mno-serialize-volatile @gol
1470-mtext-section-literals -mno-text-section-literals @gol
1471-mauto-litpools -mno-auto-litpools @gol
1472-mtarget-align -mno-target-align @gol
1473-mlongcalls -mno-longcalls @gol
1474-mabi=@var{abi-type} @gol
1475-mextra-l32r-costs=@var{cycles}}
1476
1477@emph{zSeries Options}
1478See S/390 and zSeries Options.
1479@end table
1480
1481
1482@node Overall Options
1483@section Options Controlling the Kind of Output
1484
1485Compilation can involve up to four stages: preprocessing, compilation
1486proper, assembly and linking, always in that order. GCC is capable of
1487preprocessing and compiling several files either into several
1488assembler input files, or into one assembler input file; then each
1489assembler input file produces an object file, and linking combines all
1490the object files (those newly compiled, and those specified as input)
1491into an executable file.
1492
1493@cindex file name suffix
1494For any given input file, the file name suffix determines what kind of
1495compilation is done:
1496
1497@table @gcctabopt
1498@item @var{file}.c
1499C source code that must be preprocessed.
1500
1501@item @var{file}.i
1502C source code that should not be preprocessed.
1503
1504@item @var{file}.ii
1505C++ source code that should not be preprocessed.
1506
1507@item @var{file}.m
1508Objective-C source code. Note that you must link with the @file{libobjc}
1509library to make an Objective-C program work.
1510
1511@item @var{file}.mi
1512Objective-C source code that should not be preprocessed.
1513
1514@item @var{file}.mm
1515@itemx @var{file}.M
1516Objective-C++ source code. Note that you must link with the @file{libobjc}
1517library to make an Objective-C++ program work. Note that @samp{.M} refers
1518to a literal capital M@.
1519
1520@item @var{file}.mii
1521Objective-C++ source code that should not be preprocessed.
1522
1523@item @var{file}.h
1524C, C++, Objective-C or Objective-C++ header file to be turned into a
1525precompiled header (default), or C, C++ header file to be turned into an
1526Ada spec (via the @option{-fdump-ada-spec} switch).
1527
1528@item @var{file}.cc
1529@itemx @var{file}.cp
1530@itemx @var{file}.cxx
1531@itemx @var{file}.cpp
1532@itemx @var{file}.CPP
1533@itemx @var{file}.c++
1534@itemx @var{file}.C
1535C++ source code that must be preprocessed. Note that in @samp{.cxx},
1536the last two letters must both be literally @samp{x}. Likewise,
1537@samp{.C} refers to a literal capital C@.
1538
1539@item @var{file}.mm
1540@itemx @var{file}.M
1541Objective-C++ source code that must be preprocessed.
1542
1543@item @var{file}.mii
1544Objective-C++ source code that should not be preprocessed.
1545
1546@item @var{file}.hh
1547@itemx @var{file}.H
1548@itemx @var{file}.hp
1549@itemx @var{file}.hxx
1550@itemx @var{file}.hpp
1551@itemx @var{file}.HPP
1552@itemx @var{file}.h++
1553@itemx @var{file}.tcc
1554C++ header file to be turned into a precompiled header or Ada spec.
1555
1556@item @var{file}.f
1557@itemx @var{file}.for
1558@itemx @var{file}.ftn
1559Fixed form Fortran source code that should not be preprocessed.
1560
1561@item @var{file}.F
1562@itemx @var{file}.FOR
1563@itemx @var{file}.fpp
1564@itemx @var{file}.FPP
1565@itemx @var{file}.FTN
1566Fixed form Fortran source code that must be preprocessed (with the traditional
1567preprocessor).
1568
1569@item @var{file}.f90
1570@itemx @var{file}.f95
1571@itemx @var{file}.f03
1572@itemx @var{file}.f08
1573Free form Fortran source code that should not be preprocessed.
1574
1575@item @var{file}.F90
1576@itemx @var{file}.F95
1577@itemx @var{file}.F03
1578@itemx @var{file}.F08
1579Free form Fortran source code that must be preprocessed (with the
1580traditional preprocessor).
1581
1582@item @var{file}.go
1583Go source code.
1584
1585@item @var{file}.d
1586D source code.
1587
1588@item @var{file}.di
1589D interface file.
1590
1591@item @var{file}.dd
1592D documentation code (Ddoc).
1593
1594@item @var{file}.ads
1595Ada source code file that contains a library unit declaration (a
1596declaration of a package, subprogram, or generic, or a generic
1597instantiation), or a library unit renaming declaration (a package,
1598generic, or subprogram renaming declaration). Such files are also
1599called @dfn{specs}.
1600
1601@item @var{file}.adb
1602Ada source code file containing a library unit body (a subprogram or
1603package body). Such files are also called @dfn{bodies}.
1604
1605@c GCC also knows about some suffixes for languages not yet included:
1606@c Ratfor:
1607@c @var{file}.r
1608
1609@item @var{file}.s
1610Assembler code.
1611
1612@item @var{file}.S
1613@itemx @var{file}.sx
1614Assembler code that must be preprocessed.
1615
1616@item @var{other}
1617An object file to be fed straight into linking.
1618Any file name with no recognized suffix is treated this way.
1619@end table
1620
1621@opindex x
1622You can specify the input language explicitly with the @option{-x} option:
1623
1624@table @gcctabopt
1625@item -x @var{language}
1626Specify explicitly the @var{language} for the following input files
1627(rather than letting the compiler choose a default based on the file
1628name suffix). This option applies to all following input files until
1629the next @option{-x} option. Possible values for @var{language} are:
1630@smallexample
1631c c-header cpp-output
1632c++ c++-header c++-system-header c++-user-header c++-cpp-output
1633objective-c objective-c-header objective-c-cpp-output
1634objective-c++ objective-c++-header objective-c++-cpp-output
1635assembler assembler-with-cpp
1636ada
1637d
1638f77 f77-cpp-input f95 f95-cpp-input
1639go
1640@end smallexample
1641
1642@item -x none
1643Turn off any specification of a language, so that subsequent files are
1644handled according to their file name suffixes (as they are if @option{-x}
1645has not been used at all).
1646@end table
1647
1648If you only want some of the stages of compilation, you can use
1649@option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
1650one of the options @option{-c}, @option{-S}, or @option{-E} to say where
1651@command{gcc} is to stop. Note that some combinations (for example,
1652@samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
1653
1654@table @gcctabopt
1655@item -c
1656@opindex c
1657Compile or assemble the source files, but do not link. The linking
1658stage simply is not done. The ultimate output is in the form of an
1659object file for each source file.
1660
1661By default, the object file name for a source file is made by replacing
1662the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
1663
1664Unrecognized input files, not requiring compilation or assembly, are
1665ignored.
1666
1667@item -S
1668@opindex S
1669Stop after the stage of compilation proper; do not assemble. The output
1670is in the form of an assembler code file for each non-assembler input
1671file specified.
1672
1673By default, the assembler file name for a source file is made by
1674replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
1675
1676Input files that don't require compilation are ignored.
1677
1678@item -E
1679@opindex E
1680Stop after the preprocessing stage; do not run the compiler proper. The
1681output is in the form of preprocessed source code, which is sent to the
1682standard output.
1683
1684Input files that don't require preprocessing are ignored.
1685
1686@cindex output file option
1687@item -o @var{file}
1688@opindex o
1689Place the primary output in file @var{file}. This applies to whatever
1690sort of output is being produced, whether it be an executable file, an
1691object file, an assembler file or preprocessed C code.
1692
1693If @option{-o} is not specified, the default is to put an executable
1694file in @file{a.out}, the object file for
1695@file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
1696assembler file in @file{@var{source}.s}, a precompiled header file in
1697@file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
1698standard output.
1699
1700Though @option{-o} names only the primary output, it also affects the
1701naming of auxiliary and dump outputs. See the examples below. Unless
1702overridden, both auxiliary outputs and dump outputs are placed in the
1703same directory as the primary output. In auxiliary outputs, the suffix
1704of the input file is replaced with that of the auxiliary output file
1705type; in dump outputs, the suffix of the dump file is appended to the
1706input file suffix. In compilation commands, the base name of both
1707auxiliary and dump outputs is that of the primary output; in compile and
1708link commands, the primary output name, minus the executable suffix, is
1709combined with the input file name. If both share the same base name,
1710disregarding the suffix, the result of the combination is that base
1711name, otherwise, they are concatenated, separated by a dash.
1712
1713@smallexample
1714gcc -c foo.c ...
1715@end smallexample
1716
1717will use @file{foo.o} as the primary output, and place aux outputs and
1718dumps next to it, e.g., aux file @file{foo.dwo} for
1719@option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for
1720@option{-fdump-rtl-final}.
1721
1722If a non-linker output file is explicitly specified, aux and dump files
1723by default take the same base name:
1724
1725@smallexample
1726gcc -c foo.c -o dir/foobar.o ...
1727@end smallexample
1728
1729will name aux outputs @file{dir/foobar.*} and dump outputs
1730@file{dir/foobar.c.*}.
1731
1732A linker output will instead prefix aux and dump outputs:
1733
1734@smallexample
1735gcc foo.c bar.c -o dir/foobar ...
1736@end smallexample
1737
1738will generally name aux outputs @file{dir/foobar-foo.*} and
1739@file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and
1740@file{dir/foobar-bar.c.*}.
1741
1742The one exception to the above is when the executable shares the base
1743name with the single input:
1744
1745@smallexample
1746gcc foo.c -o dir/foo ...
1747@end smallexample
1748
1749in which case aux outputs are named @file{dir/foo.*} and dump outputs
1750named @file{dir/foo.c.*}.
1751
1752The location and the names of auxiliary and dump outputs can be adjusted
1753by the options @option{-dumpbase}, @option{-dumpbase-ext},
1754@option{-dumpdir}, @option{-save-temps=cwd}, and
1755@option{-save-temps=obj}.
1756
1757
1758@item -dumpbase @var{dumpbase}
1759@opindex dumpbase
1760This option sets the base name for auxiliary and dump output files. It
1761does not affect the name of the primary output file. Intermediate
1762outputs, when preserved, are not regarded as primary outputs, but as
1763auxiliary outputs:
1764
1765@smallexample
1766gcc -save-temps -S foo.c
1767@end smallexample
1768
1769saves the (no longer) temporary preprocessed file in @file{foo.i}, and
1770then compiles to the (implied) output file @file{foo.s}, whereas:
1771
1772@smallexample
1773gcc -save-temps -dumpbase save-foo -c foo.c
1774@end smallexample
1775
1776preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now
1777an intermediate, thus auxiliary output), and then assembles to the
1778(implied) output file @file{foo.o}.
1779
1780Absent this option, dump and aux files take their names from the input
1781file, or from the (non-linker) output file, if one is explicitly
1782specified: dump output files (e.g. those requested by @option{-fdump-*}
1783options) with the input name suffix, and aux output files (those
1784requested by other non-dump options, e.g. @code{-save-temps},
1785@code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it.
1786
1787Similar suffix differentiation of dump and aux outputs can be attained
1788for explicitly-given @option{-dumpbase basename.suf} by also specifying
1789@option{-dumpbase-ext .suf}.
1790
1791If @var{dumpbase} is explicitly specified with any directory component,
1792any @var{dumppfx} specification (e.g. @option{-dumpdir} or
1793@option{-save-temps=*}) is ignored, and instead of appending to it,
1794@var{dumpbase} fully overrides it:
1795
1796@smallexample
1797gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
1798 -dumpdir pfx- -save-temps=cwd ...
1799@end smallexample
1800
1801creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding
1802@file{dir/} in @option{-o}, the @file{./} prefix implied by
1803@option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}.
1804
1805When @option{-dumpbase} is specified in a command that compiles multiple
1806inputs, or that compiles and then links, it may be combined with
1807@var{dumppfx}, as specified under @option{-dumpdir}. Then, each input
1808file is compiled using the combined @var{dumppfx}, and default values
1809for @var{dumpbase} and @var{auxdropsuf} are computed for each input
1810file:
1811
1812@smallexample
1813gcc foo.c bar.c -c -dumpbase main ...
1814@end smallexample
1815
1816creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids
1817overwriting the auxiliary and dump outputs by using the @var{dumpbase}
1818as a prefix, creating auxiliary and dump outputs named @file{main-foo.*}
1819and @file{main-bar.*}.
1820
1821An empty string specified as @var{dumpbase} avoids the influence of the
1822output basename in the naming of auxiliary and dump outputs during
1823compilation, computing default values :
1824
1825@smallexample
1826gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
1827@end smallexample
1828
1829will name aux outputs @file{dir/foo.*} and dump outputs
1830@file{dir/foo.c.*}. Note how their basenames are taken from the input
1831name, but the directory still defaults to that of the output.
1832
1833The empty-string dumpbase does not prevent the use of the output
1834basename for outputs during linking:
1835
1836@smallexample
1837gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
1838@end smallexample
1839
1840The compilation of the source files will name auxiliary outputs
1841@file{dir/foo.*} and @file{dir/bar.*}, and dump outputs
1842@file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during
1843linking will use @file{dir/foobar.} as the prefix for dumps and
1844auxiliary files.
1845
1846
1847@item -dumpbase-ext @var{auxdropsuf}
1848@opindex dumpbase-ext
1849When forming the name of an auxiliary (but not a dump) output file, drop
1850trailing @var{auxdropsuf} from @var{dumpbase} before appending any
1851suffixes. If not specified, this option defaults to the suffix of a
1852default @var{dumpbase}, i.e., the suffix of the input file when
1853@option{-dumpbase} is not present in the command line, or @var{dumpbase}
1854is combined with @var{dumppfx}.
1855
1856@smallexample
1857gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
1858@end smallexample
1859
1860creates @file{dir/foo.o} as the main output, and generates auxiliary
1861outputs in @file{dir/x-foo.*}, taking the location of the primary
1862output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump
1863outputs retain the suffix: @file{dir/x-foo.c.*}.
1864
1865This option is disregarded if it does not match the suffix of a
1866specified @var{dumpbase}, except as an alternative to the executable
1867suffix when appending the linker output base name to @var{dumppfx}, as
1868specified below:
1869
1870@smallexample
1871gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
1872@end smallexample
1873
1874creates @file{main.out} as the primary output, and avoids overwriting
1875the auxiliary and dump outputs by using the executable name minus
1876@var{auxdropsuf} as a prefix, creating auxiliary outputs named
1877@file{main-foo.*} and @file{main-bar.*} and dump outputs named
1878@file{main-foo.c.*} and @file{main-bar.c.*}.
1879
1880
1881@item -dumpdir @var{dumppfx}
1882@opindex dumpdir
1883When forming the name of an auxiliary or dump output file, use
1884@var{dumppfx} as a prefix:
1885
1886@smallexample
1887gcc -dumpdir pfx- -c foo.c ...
1888@end smallexample
1889
1890creates @file{foo.o} as the primary output, and auxiliary outputs named
1891@file{pfx-foo.*}, combining the given @var{dumppfx} with the default
1892@var{dumpbase} derived from the default primary output, derived in turn
1893from the input name. Dump outputs also take the input name suffix:
1894@file{pfx-foo.c.*}.
1895
1896If @var{dumppfx} is to be used as a directory name, it must end with a
1897directory separator:
1898
1899@smallexample
1900gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
1901@end smallexample
1902
1903creates @file{obj/bar.o} as the primary output, and auxiliary outputs
1904named @file{dir/bar.*}, combining the given @var{dumppfx} with the
1905default @var{dumpbase} derived from the primary output name. Dump
1906outputs also take the input name suffix: @file{dir/bar.c.*}.
1907
1908It defaults to the location of the output file, unless the output
1909file is a special file like @code{/dev/null}. Options
1910@option{-save-temps=cwd} and @option{-save-temps=obj} override this
1911default, just like an explicit @option{-dumpdir} option. In case
1912multiple such options are given, the last one prevails:
1913
1914@smallexample
1915gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
1916@end smallexample
1917
1918outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because
1919@option{-save-temps=*} overrides the @var{dumppfx} given by the earlier
1920@option{-dumpdir} option. It does not matter that @option{=obj} is the
1921default for @option{-save-temps}, nor that the output directory is
1922implicitly the current directory. Dump outputs are named
1923@file{foo.c.*}.
1924
1925When compiling from multiple input files, if @option{-dumpbase} is
1926specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash
1927are appended to (or override, if containing any directory components) an
1928explicit or defaulted @var{dumppfx}, so that each of the multiple
1929compilations gets differently-named aux and dump outputs.
1930
1931@smallexample
1932gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
1933@end smallexample
1934
1935outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and
1936@file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}.
1937Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*}
1938and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the
1939single-input compilation:
1940
1941@smallexample
1942gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
1943@end smallexample
1944
1945that, applying @option{-dumpbase} to a single source, does not compute
1946and append a separate @var{dumpbase} per input file. Its auxiliary and
1947dump outputs go in @file{dir/pfx-main.*}.
1948
1949When compiling and then linking from multiple input files, a defaulted
1950or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}-
1951transformation above (e.g. the compilation of @file{foo.c} and
1952@file{bar.c} above, but without @option{-c}). If neither
1953@option{-dumpdir} nor @option{-dumpbase} are given, the linker output
1954base name, minus @var{auxdropsuf}, if specified, or the executable
1955suffix otherwise, plus a dash is appended to the default @var{dumppfx}
1956instead. Note, however, that unlike earlier cases of linking:
1957
1958@smallexample
1959gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
1960@end smallexample
1961
1962does not append the output name @file{main} to @var{dumppfx}, because
1963@option{-dumpdir} is explicitly specified. The goal is that the
1964explicitly-specified @var{dumppfx} may contain the specified output name
1965as part of the prefix, if desired; only an explicitly-specified
1966@option{-dumpbase} would be combined with it, in order to avoid simply
1967discarding a meaningful option.
1968
1969When compiling and then linking from a single input file, the linker
1970output base name will only be appended to the default @var{dumppfx} as
1971above if it does not share the base name with the single input file
1972name. This has been covered in single-input linking cases above, but
1973not with an explicit @option{-dumpdir} that inhibits the combination,
1974even if overridden by @option{-save-temps=*}:
1975
1976@smallexample
1977gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
1978@end smallexample
1979
1980Auxiliary outputs are named @file{foo.*}, and dump outputs
1981@file{foo.c.*}, in the current working directory as ultimately requested
1982by @option{-save-temps=cwd}.
1983
1984Summing it all up for an intuitive though slightly imprecise data flow:
1985the primary output name is broken into a directory part and a basename
1986part; @var{dumppfx} is set to the former, unless overridden by
1987@option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set
1988to the latter, unless overriden by @option{-dumpbase}. If there are
1989multiple inputs or linking, this @var{dumpbase} may be combined with
1990@var{dumppfx} and taken from each input file. Auxiliary output names
1991for each input are formed by combining @var{dumppfx}, @var{dumpbase}
1992minus suffix, and the auxiliary output suffix; dump output names are
1993only different in that the suffix from @var{dumpbase} is retained.
1994
1995When it comes to auxiliary and dump outputs created during LTO
1996recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as
1997given or as derived from the linker output name but not from inputs,
1998even in cases in which this combination would not otherwise be used as
1999such, is passed down with a trailing period replacing the compiler-added
2000dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper};
2001being involved in linking, this program does not normally get any
2002@option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them.
2003
2004When running sub-compilers, @command{lto-wrapper} appends LTO stage
2005names to the received @var{dumppfx}, ensures it contains a directory
2006component so that it overrides any @option{-dumpdir}, and passes that as
2007@option{-dumpbase} to sub-compilers.
2008
2009@item -v
2010@opindex v
2011Print (on standard error output) the commands executed to run the stages
2012of compilation. Also print the version number of the compiler driver
2013program and of the preprocessor and the compiler proper.
2014
2015@item -###
2016@opindex ###
2017Like @option{-v} except the commands are not executed and arguments
2018are quoted unless they contain only alphanumeric characters or @code{./-_}.
2019This is useful for shell scripts to capture the driver-generated command lines.
2020
2021@item --help
2022@opindex help
2023Print (on the standard output) a description of the command-line options
2024understood by @command{gcc}. If the @option{-v} option is also specified
2025then @option{--help} is also passed on to the various processes
2026invoked by @command{gcc}, so that they can display the command-line options
2027they accept. If the @option{-Wextra} option has also been specified
2028(prior to the @option{--help} option), then command-line options that
2029have no documentation associated with them are also displayed.
2030
2031@item --target-help
2032@opindex target-help
2033Print (on the standard output) a description of target-specific command-line
2034options for each tool. For some targets extra target-specific
2035information may also be printed.
2036
2037@item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
2038Print (on the standard output) a description of the command-line
2039options understood by the compiler that fit into all specified classes
2040and qualifiers. These are the supported classes:
2041
2042@table @asis
2043@item @samp{optimizers}
2044Display all of the optimization options supported by the
2045compiler.
2046
2047@item @samp{warnings}
2048Display all of the options controlling warning messages
2049produced by the compiler.
2050
2051@item @samp{target}
2052Display target-specific options. Unlike the
2053@option{--target-help} option however, target-specific options of the
2054linker and assembler are not displayed. This is because those
2055tools do not currently support the extended @option{--help=} syntax.
2056
2057@item @samp{params}
2058Display the values recognized by the @option{--param}
2059option.
2060
2061@item @var{language}
2062Display the options supported for @var{language}, where
2063@var{language} is the name of one of the languages supported in this
2064version of GCC@. If an option is supported by all languages, one needs
2065to select @samp{common} class.
2066
2067@item @samp{common}
2068Display the options that are common to all languages.
2069@end table
2070
2071These are the supported qualifiers:
2072
2073@table @asis
2074@item @samp{undocumented}
2075Display only those options that are undocumented.
2076
2077@item @samp{joined}
2078Display options taking an argument that appears after an equal
2079sign in the same continuous piece of text, such as:
2080@samp{--help=target}.
2081
2082@item @samp{separate}
2083Display options taking an argument that appears as a separate word
2084following the original option, such as: @samp{-o output-file}.
2085@end table
2086
2087Thus for example to display all the undocumented target-specific
2088switches supported by the compiler, use:
2089
2090@smallexample
2091--help=target,undocumented
2092@end smallexample
2093
2094The sense of a qualifier can be inverted by prefixing it with the
2095@samp{^} character, so for example to display all binary warning
2096options (i.e., ones that are either on or off and that do not take an
2097argument) that have a description, use:
2098
2099@smallexample
2100--help=warnings,^joined,^undocumented
2101@end smallexample
2102
2103The argument to @option{--help=} should not consist solely of inverted
2104qualifiers.
2105
2106Combining several classes is possible, although this usually
2107restricts the output so much that there is nothing to display. One
2108case where it does work, however, is when one of the classes is
2109@var{target}. For example, to display all the target-specific
2110optimization options, use:
2111
2112@smallexample
2113--help=target,optimizers
2114@end smallexample
2115
2116The @option{--help=} option can be repeated on the command line. Each
2117successive use displays its requested class of options, skipping
2118those that have already been displayed. If @option{--help} is also
2119specified anywhere on the command line then this takes precedence
2120over any @option{--help=} option.
2121
2122If the @option{-Q} option appears on the command line before the
2123@option{--help=} option, then the descriptive text displayed by
2124@option{--help=} is changed. Instead of describing the displayed
2125options, an indication is given as to whether the option is enabled,
2126disabled or set to a specific value (assuming that the compiler
2127knows this at the point where the @option{--help=} option is used).
2128
2129Here is a truncated example from the ARM port of @command{gcc}:
2130
2131@smallexample
2132 % gcc -Q -mabi=2 --help=target -c
2133 The following options are target specific:
2134 -mabi= 2
2135 -mabort-on-noreturn [disabled]
2136 -mapcs [disabled]
2137@end smallexample
2138
2139The output is sensitive to the effects of previous command-line
2140options, so for example it is possible to find out which optimizations
2141are enabled at @option{-O2} by using:
2142
2143@smallexample
2144-Q -O2 --help=optimizers
2145@end smallexample
2146
2147Alternatively you can discover which binary optimizations are enabled
2148by @option{-O3} by using:
2149
2150@smallexample
2151gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
2152gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
2153diff /tmp/O2-opts /tmp/O3-opts | grep enabled
2154@end smallexample
2155
2156@item --version
2157@opindex version
2158Display the version number and copyrights of the invoked GCC@.
2159
2160@item -pass-exit-codes
2161@opindex pass-exit-codes
2162Normally the @command{gcc} program exits with the code of 1 if any
2163phase of the compiler returns a non-success return code. If you specify
2164@option{-pass-exit-codes}, the @command{gcc} program instead returns with
2165the numerically highest error produced by any phase returning an error
2166indication. The C, C++, and Fortran front ends return 4 if an internal
2167compiler error is encountered.
2168
2169@item -pipe
2170@opindex pipe
2171Use pipes rather than temporary files for communication between the
2172various stages of compilation. This fails to work on some systems where
2173the assembler is unable to read from a pipe; but the GNU assembler has
2174no trouble.
2175
2176@item -specs=@var{file}
2177@opindex specs
2178Process @var{file} after the compiler reads in the standard @file{specs}
2179file, in order to override the defaults which the @command{gcc} driver
2180program uses when determining what switches to pass to @command{cc1},
2181@command{cc1plus}, @command{as}, @command{ld}, etc. More than one
2182@option{-specs=@var{file}} can be specified on the command line, and they
2183are processed in order, from left to right. @xref{Spec Files}, for
2184information about the format of the @var{file}.
2185
2186@item -wrapper
2187@opindex wrapper
2188Invoke all subcommands under a wrapper program. The name of the
2189wrapper program and its parameters are passed as a comma separated
2190list.
2191
2192@smallexample
2193gcc -c t.c -wrapper gdb,--args
2194@end smallexample
2195
2196@noindent
2197This invokes all subprograms of @command{gcc} under
2198@samp{gdb --args}, thus the invocation of @command{cc1} is
2199@samp{gdb --args cc1 @dots{}}.
2200
2201@item -ffile-prefix-map=@var{old}=@var{new}
2202@opindex ffile-prefix-map
2203When compiling files residing in directory @file{@var{old}}, record
2204any references to them in the result of the compilation as if the
2205files resided in directory @file{@var{new}} instead. Specifying this
2206option is equivalent to specifying all the individual
2207@option{-f*-prefix-map} options. This can be used to make reproducible
11543b27
RP
2208builds that are location independent. Directories referenced by
2209directives are not affected by these options. See also
d77de738
ML
2210@option{-fmacro-prefix-map}, @option{-fdebug-prefix-map} and
2211@option{-fprofile-prefix-map}.
2212
2213@item -fplugin=@var{name}.so
2214@opindex fplugin
2215Load the plugin code in file @var{name}.so, assumed to be a
2216shared object to be dlopen'd by the compiler. The base name of
2217the shared object file is used to identify the plugin for the
2218purposes of argument parsing (See
2219@option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below).
2220Each plugin should define the callback functions specified in the
2221Plugins API.
2222
2223@item -fplugin-arg-@var{name}-@var{key}=@var{value}
2224@opindex fplugin-arg
2225Define an argument called @var{key} with a value of @var{value}
2226for the plugin called @var{name}.
2227
2228@item -fdump-ada-spec@r{[}-slim@r{]}
2229@opindex fdump-ada-spec
2230For C and C++ source and include files, generate corresponding Ada specs.
2231@xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
2232GNAT User's Guide}, which provides detailed documentation on this feature.
2233
2234@item -fada-spec-parent=@var{unit}
2235@opindex fada-spec-parent
2236In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate
2237Ada specs as child units of parent @var{unit}.
2238
2239@item -fdump-go-spec=@var{file}
2240@opindex fdump-go-spec
2241For input files in any language, generate corresponding Go
2242declarations in @var{file}. This generates Go @code{const},
2243@code{type}, @code{var}, and @code{func} declarations which may be a
2244useful way to start writing a Go interface to code written in some
2245other language.
2246
2247@include @value{srcdir}/../libiberty/at-file.texi
2248@end table
2249
2250@node Invoking G++
2251@section Compiling C++ Programs
2252
2253@cindex suffixes for C++ source
2254@cindex C++ source file suffixes
2255C++ source files conventionally use one of the suffixes @samp{.C},
2256@samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
2257@samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
2258@samp{.H}, or (for shared template code) @samp{.tcc}; and
2259preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
2260files with these names and compiles them as C++ programs even if you
2261call the compiler the same way as for compiling C programs (usually
2262with the name @command{gcc}).
2263
2264@findex g++
2265@findex c++
2266However, the use of @command{gcc} does not add the C++ library.
2267@command{g++} is a program that calls GCC and automatically specifies linking
2268against the C++ library. It treats @samp{.c},
2269@samp{.h} and @samp{.i} files as C++ source files instead of C source
2270files unless @option{-x} is used. This program is also useful when
2271precompiling a C header file with a @samp{.h} extension for use in C++
2272compilations. On many systems, @command{g++} is also installed with
2273the name @command{c++}.
2274
2275@cindex invoking @command{g++}
2276When you compile C++ programs, you may specify many of the same
2277command-line options that you use for compiling programs in any
2278language; or command-line options meaningful for C and related
2279languages; or options that are meaningful only for C++ programs.
2280@xref{C Dialect Options,,Options Controlling C Dialect}, for
2281explanations of options for languages related to C@.
2282@xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
2283explanations of options that are meaningful only for C++ programs.
2284
2285@node C Dialect Options
2286@section Options Controlling C Dialect
2287@cindex dialect options
2288@cindex language dialect options
2289@cindex options, dialect
2290
2291The following options control the dialect of C (or languages derived
2292from C, such as C++, Objective-C and Objective-C++) that the compiler
2293accepts:
2294
2295@table @gcctabopt
2296@cindex ANSI support
2297@cindex ISO support
2298@item -ansi
2299@opindex ansi
2300In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
2301equivalent to @option{-std=c++98}.
2302
2303This turns off certain features of GCC that are incompatible with ISO
2304C90 (when compiling C code), or of standard C++ (when compiling C++ code),
2305such as the @code{asm} and @code{typeof} keywords, and
2306predefined macros such as @code{unix} and @code{vax} that identify the
2307type of system you are using. It also enables the undesirable and
2308rarely used ISO trigraph feature. For the C compiler,
2309it disables recognition of C++ style @samp{//} comments as well as
2310the @code{inline} keyword.
2311
2312The alternate keywords @code{__asm__}, @code{__extension__},
2313@code{__inline__} and @code{__typeof__} continue to work despite
2314@option{-ansi}. You would not want to use them in an ISO C program, of
2315course, but it is useful to put them in header files that might be included
2316in compilations done with @option{-ansi}. Alternate predefined macros
2317such as @code{__unix__} and @code{__vax__} are also available, with or
2318without @option{-ansi}.
2319
2320The @option{-ansi} option does not cause non-ISO programs to be
2321rejected gratuitously. For that, @option{-Wpedantic} is required in
2322addition to @option{-ansi}. @xref{Warning Options}.
2323
2324The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
2325option is used. Some header files may notice this macro and refrain
2326from declaring certain functions or defining certain macros that the
2327ISO standard doesn't call for; this is to avoid interfering with any
2328programs that might use these names for other things.
2329
2330Functions that are normally built in but do not have semantics
2331defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
2332functions when @option{-ansi} is used. @xref{Other Builtins,,Other
2333built-in functions provided by GCC}, for details of the functions
2334affected.
2335
2336@item -std=
2337@opindex std
2338Determine the language standard. @xref{Standards,,Language Standards
2339Supported by GCC}, for details of these standard versions. This option
2340is currently only supported when compiling C or C++.
2341
2342The compiler can accept several base standards, such as @samp{c90} or
2343@samp{c++98}, and GNU dialects of those standards, such as
2344@samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the
2345compiler accepts all programs following that standard plus those
2346using GNU extensions that do not contradict it. For example,
2347@option{-std=c90} turns off certain features of GCC that are
2348incompatible with ISO C90, such as the @code{asm} and @code{typeof}
2349keywords, but not other GNU extensions that do not have a meaning in
2350ISO C90, such as omitting the middle term of a @code{?:}
2351expression. On the other hand, when a GNU dialect of a standard is
2352specified, all features supported by the compiler are enabled, even when
2353those features change the meaning of the base standard. As a result, some
2354strict-conforming programs may be rejected. The particular standard
2355is used by @option{-Wpedantic} to identify which features are GNU
2356extensions given that version of the standard. For example
2357@option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//}
2358comments, while @option{-std=gnu99 -Wpedantic} does not.
2359
2360A value for this option must be provided; possible values are
2361
2362@table @samp
2363@item c90
2364@itemx c89
2365@itemx iso9899:1990
2366Support all ISO C90 programs (certain GNU extensions that conflict
2367with ISO C90 are disabled). Same as @option{-ansi} for C code.
2368
2369@item iso9899:199409
2370ISO C90 as modified in amendment 1.
2371
2372@item c99
2373@itemx c9x
2374@itemx iso9899:1999
2375@itemx iso9899:199x
2376ISO C99. This standard is substantially completely supported, modulo
2377bugs and floating-point issues
2378(mainly but not entirely relating to optional C99 features from
2379Annexes F and G). See
2380@w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The
2381names @samp{c9x} and @samp{iso9899:199x} are deprecated.
2382
2383@item c11
2384@itemx c1x
2385@itemx iso9899:2011
2386ISO C11, the 2011 revision of the ISO C standard. This standard is
2387substantially completely supported, modulo bugs, floating-point issues
2388(mainly but not entirely relating to optional C11 features from
2389Annexes F and G) and the optional Annexes K (Bounds-checking
2390interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
2391
2392@item c17
2393@itemx c18
2394@itemx iso9899:2017
2395@itemx iso9899:2018
2396ISO C17, the 2017 revision of the ISO C standard
2397(published in 2018). This standard is
2398same as C11 except for corrections of defects (all of which are also
2399applied with @option{-std=c11}) and a new value of
2400@code{__STDC_VERSION__}, and so is supported to the same extent as C11.
2401
2402@item c2x
2403The next version of the ISO C standard, still under development. The
2404support for this version is experimental and incomplete.
2405
2406@item gnu90
2407@itemx gnu89
2408GNU dialect of ISO C90 (including some C99 features).
2409
2410@item gnu99
2411@itemx gnu9x
2412GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
2413
2414@item gnu11
2415@itemx gnu1x
2416GNU dialect of ISO C11.
2417The name @samp{gnu1x} is deprecated.
2418
2419@item gnu17
2420@itemx gnu18
2421GNU dialect of ISO C17. This is the default for C code.
2422
2423@item gnu2x
2424The next version of the ISO C standard, still under development, plus
2425GNU extensions. The support for this version is experimental and
2426incomplete.
2427
2428@item c++98
2429@itemx c++03
2430The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
2431additional defect reports. Same as @option{-ansi} for C++ code.
2432
2433@item gnu++98
2434@itemx gnu++03
2435GNU dialect of @option{-std=c++98}.
2436
2437@item c++11
2438@itemx c++0x
2439The 2011 ISO C++ standard plus amendments.
2440The name @samp{c++0x} is deprecated.
2441
2442@item gnu++11
2443@itemx gnu++0x
2444GNU dialect of @option{-std=c++11}.
2445The name @samp{gnu++0x} is deprecated.
2446
2447@item c++14
2448@itemx c++1y
2449The 2014 ISO C++ standard plus amendments.
2450The name @samp{c++1y} is deprecated.
2451
2452@item gnu++14
2453@itemx gnu++1y
2454GNU dialect of @option{-std=c++14}.
2455The name @samp{gnu++1y} is deprecated.
2456
2457@item c++17
2458@itemx c++1z
2459The 2017 ISO C++ standard plus amendments.
2460The name @samp{c++1z} is deprecated.
2461
2462@item gnu++17
2463@itemx gnu++1z
2464GNU dialect of @option{-std=c++17}.
2465This is the default for C++ code.
2466The name @samp{gnu++1z} is deprecated.
2467
2468@item c++20
2469@itemx c++2a
2470The 2020 ISO C++ standard plus amendments.
2471Support is experimental, and could change in incompatible ways in
2472future releases.
2473The name @samp{c++2a} is deprecated.
2474
2475@item gnu++20
2476@itemx gnu++2a
2477GNU dialect of @option{-std=c++20}.
2478Support is experimental, and could change in incompatible ways in
2479future releases.
2480The name @samp{gnu++2a} is deprecated.
2481
2482@item c++2b
2483@itemx c++23
2484The next revision of the ISO C++ standard, planned for
24852023. Support is highly experimental, and will almost certainly
2486change in incompatible ways in future releases.
2487
2488@item gnu++2b
2489@itemx gnu++23
2490GNU dialect of @option{-std=c++2b}. Support is highly experimental,
2491and will almost certainly change in incompatible ways in future
2492releases.
2493@end table
2494
2495@item -aux-info @var{filename}
2496@opindex aux-info
2497Output to the given filename prototyped declarations for all functions
2498declared and/or defined in a translation unit, including those in header
2499files. This option is silently ignored in any language other than C@.
2500
2501Besides declarations, the file indicates, in comments, the origin of
2502each declaration (source file and line), whether the declaration was
2503implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
2504@samp{O} for old, respectively, in the first character after the line
2505number and the colon), and whether it came from a declaration or a
2506definition (@samp{C} or @samp{F}, respectively, in the following
2507character). In the case of function definitions, a K&R-style list of
2508arguments followed by their declarations is also provided, inside
2509comments, after the declaration.
2510
2511@item -fno-asm
2512@opindex fno-asm
2513@opindex fasm
2514Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
2515keyword, so that code can use these words as identifiers. You can use
2516the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
2517instead. In C, @option{-ansi} implies @option{-fno-asm}.
2518
2519In C++, @code{inline} is a standard keyword and is not affected by
2520this switch. You may want to use the @option{-fno-gnu-keywords} flag
2521instead, which disables @code{typeof} but not @code{asm} and
2522@code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
2523this switch only affects the @code{asm} and @code{typeof} keywords,
2524since @code{inline} is a standard keyword in ISO C99. In C2X mode
2525(@option{-std=c2x} or @option{-std=gnu2x}), this switch only affects
2526the @code{asm} keyword, since @code{typeof} is a standard keyword in
2527ISO C2X.
2528
2529@item -fno-builtin
2530@itemx -fno-builtin-@var{function}
2531@opindex fno-builtin
2532@opindex fbuiltin
2533@cindex built-in functions
2534Don't recognize built-in functions that do not begin with
2535@samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
2536functions provided by GCC}, for details of the functions affected,
2537including those which are not built-in functions when @option{-ansi} or
2538@option{-std} options for strict ISO C conformance are used because they
2539do not have an ISO standard meaning.
2540
2541GCC normally generates special code to handle certain built-in functions
2542more efficiently; for instance, calls to @code{alloca} may become single
2543instructions which adjust the stack directly, and calls to @code{memcpy}
2544may become inline copy loops. The resulting code is often both smaller
2545and faster, but since the function calls no longer appear as such, you
2546cannot set a breakpoint on those calls, nor can you change the behavior
2547of the functions by linking with a different library. In addition,
2548when a function is recognized as a built-in function, GCC may use
2549information about that function to warn about problems with calls to
2550that function, or to generate more efficient code, even if the
2551resulting code still contains calls to that function. For example,
2552warnings are given with @option{-Wformat} for bad calls to
2553@code{printf} when @code{printf} is built in and @code{strlen} is
2554known not to modify global memory.
2555
2556With the @option{-fno-builtin-@var{function}} option
2557only the built-in function @var{function} is
2558disabled. @var{function} must not begin with @samp{__builtin_}. If a
2559function is named that is not built-in in this version of GCC, this
2560option is ignored. There is no corresponding
2561@option{-fbuiltin-@var{function}} option; if you wish to enable
2562built-in functions selectively when using @option{-fno-builtin} or
2563@option{-ffreestanding}, you may define macros such as:
2564
2565@smallexample
2566#define abs(n) __builtin_abs ((n))
2567#define strcpy(d, s) __builtin_strcpy ((d), (s))
2568@end smallexample
2569
2570@item -fcond-mismatch
2571@opindex fcond-mismatch
2572Allow conditional expressions with mismatched types in the second and
2573third arguments. The value of such an expression is void. This option
2574is not supported for C++.
2575
2576@item -ffreestanding
2577@opindex ffreestanding
2578@cindex hosted environment
2579
2580Assert that compilation targets a freestanding environment. This
2581implies @option{-fno-builtin}. A freestanding environment
2582is one in which the standard library may not exist, and program startup may
2583not necessarily be at @code{main}. The most obvious example is an OS kernel.
2584This is equivalent to @option{-fno-hosted}.
2585
2586@xref{Standards,,Language Standards Supported by GCC}, for details of
2587freestanding and hosted environments.
2588
2589@item -fgimple
2590@opindex fgimple
2591
2592Enable parsing of function definitions marked with @code{__GIMPLE}.
2593This is an experimental feature that allows unit testing of GIMPLE
2594passes.
2595
2596@item -fgnu-tm
2597@opindex fgnu-tm
2598When the option @option{-fgnu-tm} is specified, the compiler
2599generates code for the Linux variant of Intel's current Transactional
2600Memory ABI specification document (Revision 1.1, May 6 2009). This is
2601an experimental feature whose interface may change in future versions
2602of GCC, as the official specification changes. Please note that not
2603all architectures are supported for this feature.
2604
2605For more information on GCC's support for transactional memory,
2606@xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
2607Transactional Memory Library}.
2608
2609Note that the transactional memory feature is not supported with
2610non-call exceptions (@option{-fnon-call-exceptions}).
2611
2612@item -fgnu89-inline
2613@opindex fgnu89-inline
2614The option @option{-fgnu89-inline} tells GCC to use the traditional
2615GNU semantics for @code{inline} functions when in C99 mode.
2616@xref{Inline,,An Inline Function is As Fast As a Macro}.
2617Using this option is roughly equivalent to adding the
2618@code{gnu_inline} function attribute to all inline functions
2619(@pxref{Function Attributes}).
2620
2621The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
2622C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
2623specifies the default behavior).
2624This option is not supported in @option{-std=c90} or
2625@option{-std=gnu90} mode.
2626
2627The preprocessor macros @code{__GNUC_GNU_INLINE__} and
2628@code{__GNUC_STDC_INLINE__} may be used to check which semantics are
2629in effect for @code{inline} functions. @xref{Common Predefined
2630Macros,,,cpp,The C Preprocessor}.
2631
2632@item -fhosted
2633@opindex fhosted
2634@cindex hosted environment
2635
2636Assert that compilation targets a hosted environment. This implies
2637@option{-fbuiltin}. A hosted environment is one in which the
2638entire standard library is available, and in which @code{main} has a return
2639type of @code{int}. Examples are nearly everything except a kernel.
2640This is equivalent to @option{-fno-freestanding}.
2641
2642@item -flax-vector-conversions
2643@opindex flax-vector-conversions
2644Allow implicit conversions between vectors with differing numbers of
2645elements and/or incompatible element types. This option should not be
2646used for new code.
2647
2648@item -fms-extensions
2649@opindex fms-extensions
2650Accept some non-standard constructs used in Microsoft header files.
2651
2652In C++ code, this allows member names in structures to be similar
2653to previous types declarations.
2654
2655@smallexample
2656typedef int UOW;
2657struct ABC @{
2658 UOW UOW;
2659@};
2660@end smallexample
2661
2662Some cases of unnamed fields in structures and unions are only
2663accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
2664fields within structs/unions}, for details.
2665
2666Note that this option is off for all targets except for x86
2667targets using ms-abi.
2668
2669@item -foffload=disable
2670@itemx -foffload=default
2671@itemx -foffload=@var{target-list}
2672@opindex foffload
2673@cindex Offloading targets
2674@cindex OpenACC offloading targets
2675@cindex OpenMP offloading targets
2676Specify for which OpenMP and OpenACC offload targets code should be generated.
2677The default behavior, equivalent to @option{-foffload=default}, is to generate
2678code for all supported offload targets. The @option{-foffload=disable} form
2679generates code only for the host fallback, while
2680@option{-foffload=@var{target-list}} generates code only for the specified
2681comma-separated list of offload targets.
2682
2683Offload targets are specified in GCC's internal target-triplet format. You can
2684run the compiler with @option{-v} to show the list of configured offload targets
2685under @code{OFFLOAD_TARGET_NAMES}.
2686
2687@item -foffload-options=@var{options}
2688@itemx -foffload-options=@var{target-triplet-list}=@var{options}
2689@opindex foffload-options
2690@cindex Offloading options
2691@cindex OpenACC offloading options
2692@cindex OpenMP offloading options
2693
2694With @option{-foffload-options=@var{options}}, GCC passes the specified
2695@var{options} to the compilers for all enabled offloading targets. You can
2696specify options that apply only to a specific target or targets by using
2697the @option{-foffload-options=@var{target-list}=@var{options}} form. The
2698@var{target-list} is a comma-separated list in the same format as for the
2699@option{-foffload=} option.
2700
2701Typical command lines are
2702
2703@smallexample
2704-foffload-options=-lgfortran -foffload-options=-lm
2705-foffload-options="-lgfortran -lm" -foffload-options=nvptx-none=-latomic
2706-foffload-options=amdgcn-amdhsa=-march=gfx906 -foffload-options=-lm
2707@end smallexample
2708
2709@item -fopenacc
2710@opindex fopenacc
2711@cindex OpenACC accelerator programming
2712Enable handling of OpenACC directives @code{#pragma acc} in C/C++ and
2713@code{!$acc} in Fortran. When @option{-fopenacc} is specified, the
2714compiler generates accelerated code according to the OpenACC Application
2715Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option
2716implies @option{-pthread}, and thus is only supported on targets that
2717have support for @option{-pthread}.
2718
2719@item -fopenacc-dim=@var{geom}
2720@opindex fopenacc-dim
2721@cindex OpenACC accelerator programming
2722Specify default compute dimensions for parallel offload regions that do
2723not explicitly specify. The @var{geom} value is a triple of
2724':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size
2725can be omitted, to use a target-specific default value.
2726
2727@item -fopenmp
2728@opindex fopenmp
2729@cindex OpenMP parallel
2730Enable handling of OpenMP directives @code{#pragma omp} in C/C++,
2731@code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++ and
2732@code{!$omp} in Fortran. When @option{-fopenmp} is specified, the
2733compiler generates parallel code according to the OpenMP Application
2734Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option
2735implies @option{-pthread}, and thus is only supported on targets that
2736have support for @option{-pthread}. @option{-fopenmp} implies
2737@option{-fopenmp-simd}.
2738
2739@item -fopenmp-simd
2740@opindex fopenmp-simd
2741@cindex OpenMP SIMD
2742@cindex SIMD
2743Enable handling of OpenMP's @code{simd}, @code{declare simd},
2744@code{declare reduction}, @code{assume}, @code{ordered}, @code{scan},
2745@code{loop} directives and combined or composite directives with
2746@code{simd} as constituent with @code{#pragma omp} in C/C++,
2747@code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++
2748and @code{!$omp} in Fortran. Other OpenMP directives are ignored.
2749
309e2d95
SL
2750@item -fopenmp-target-simd-clone
2751@item -fopenmp-target-simd-clone=@var{device-type}
2752@opindex fopenmp-target-simd-clone
2753@cindex OpenMP target SIMD clone
2754In addition to generating SIMD clones for functions marked with the
2755@code{declare simd} directive, GCC also generates clones
2756for functions marked with the OpenMP @code{declare target} directive
2757that are suitable for vectorization when this option is in effect. The
2758@var{device-type} may be one of @code{none}, @code{host}, @code{nohost},
2759and @code{any}, which correspond to keywords for the @code{device_type}
2760clause of the @code{declare target} directive; clones are generated for
2761the intersection of devices specified.
2762@option{-fopenmp-target-simd-clone} is equivalent to
2763@option{-fopenmp-target-simd-clone=any} and
2764@option{-fno-openmp-target-simd-clone} is equivalent to
2765@option{-fopenmp-target-simd-clone=none}.
2766
2767At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this
2768optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise
2769it is disabled by default.
2770
d77de738
ML
2771@item -fpermitted-flt-eval-methods=@var{style}
2772@opindex fpermitted-flt-eval-methods
2773@opindex fpermitted-flt-eval-methods=c11
2774@opindex fpermitted-flt-eval-methods=ts-18661-3
2775ISO/IEC TS 18661-3 defines new permissible values for
2776@code{FLT_EVAL_METHOD} that indicate that operations and constants with
2777a semantic type that is an interchange or extended format should be
2778evaluated to the precision and range of that type. These new values are
2779a superset of those permitted under C99/C11, which does not specify the
2780meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code
2781conforming to C11 may not have been written expecting the possibility of
2782the new values.
2783
2784@option{-fpermitted-flt-eval-methods} specifies whether the compiler
2785should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11,
2786or the extended set of values specified in ISO/IEC TS 18661-3.
2787
2788@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate.
2789
2790The default when in a standards compliant mode (@option{-std=c11} or similar)
2791is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU
2792dialect (@option{-std=gnu11} or similar) is
2793@option{-fpermitted-flt-eval-methods=ts-18661-3}.
2794
2795@item -fplan9-extensions
2796@opindex fplan9-extensions
2797Accept some non-standard constructs used in Plan 9 code.
2798
2799This enables @option{-fms-extensions}, permits passing pointers to
2800structures with anonymous fields to functions that expect pointers to
2801elements of the type of the field, and permits referring to anonymous
2802fields declared using a typedef. @xref{Unnamed Fields,,Unnamed
2803struct/union fields within structs/unions}, for details. This is only
2804supported for C, not C++.
2805
2806@item -fsigned-bitfields
2807@itemx -funsigned-bitfields
2808@itemx -fno-signed-bitfields
2809@itemx -fno-unsigned-bitfields
2810@opindex fsigned-bitfields
2811@opindex funsigned-bitfields
2812@opindex fno-signed-bitfields
2813@opindex fno-unsigned-bitfields
2814These options control whether a bit-field is signed or unsigned, when the
2815declaration does not use either @code{signed} or @code{unsigned}. By
2816default, such a bit-field is signed, because this is consistent: the
2817basic integer types such as @code{int} are signed types.
2818
2819@item -fsigned-char
2820@opindex fsigned-char
2821Let the type @code{char} be signed, like @code{signed char}.
2822
2823Note that this is equivalent to @option{-fno-unsigned-char}, which is
2824the negative form of @option{-funsigned-char}. Likewise, the option
2825@option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
2826
2827@item -funsigned-char
2828@opindex funsigned-char
2829Let the type @code{char} be unsigned, like @code{unsigned char}.
2830
2831Each kind of machine has a default for what @code{char} should
2832be. It is either like @code{unsigned char} by default or like
2833@code{signed char} by default.
2834
2835Ideally, a portable program should always use @code{signed char} or
2836@code{unsigned char} when it depends on the signedness of an object.
2837But many programs have been written to use plain @code{char} and
2838expect it to be signed, or expect it to be unsigned, depending on the
2839machines they were written for. This option, and its inverse, let you
2840make such a program work with the opposite default.
2841
2842The type @code{char} is always a distinct type from each of
2843@code{signed char} or @code{unsigned char}, even though its behavior
2844is always just like one of those two.
2845
2846@item -fstrict-flex-arrays
2847@opindex fstrict-flex-arrays
2848@opindex fno-strict-flex-arrays
2849Control when to treat the trailing array of a structure as a flexible array
2850member for the purpose of accessing the elements of such an array.
2851The positive form is equivalent to @option{-fstrict-flex-arrays=3}, which is the
2852strictest. A trailing array is treated as a flexible array member only when it
2853is declared as a flexible array member per C99 standard onwards.
2854The negative form is equivalent to @option{-fstrict-flex-arrays=0}, which is the
2855least strict. All trailing arrays of structures are treated as flexible array
2856members.
2857
2858@item -fstrict-flex-arrays=@var{level}
2859@opindex fstrict-flex-arrays=@var{level}
2860Control when to treat the trailing array of a structure as a flexible array
2861member for the purpose of accessing the elements of such an array. The value
2862of @var{level} controls the level of strictness.
2863
2864The possible values of @var{level} are the same as for the
2865@code{strict_flex_array} attribute (@pxref{Variable Attributes}).
2866
2867You can control this behavior for a specific trailing array field of a
2868structure by using the variable attribute @code{strict_flex_array} attribute
2869(@pxref{Variable Attributes}).
2870
2871@item -fsso-struct=@var{endianness}
2872@opindex fsso-struct
2873Set the default scalar storage order of structures and unions to the
2874specified endianness. The accepted values are @samp{big-endian},
2875@samp{little-endian} and @samp{native} for the native endianness of
2876the target (the default). This option is not supported for C++.
2877
2878@strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate
2879code that is not binary compatible with code generated without it if the
2880specified endianness is not the native endianness of the target.
2881@end table
2882
2883@node C++ Dialect Options
2884@section Options Controlling C++ Dialect
2885
2886@cindex compiler options, C++
2887@cindex C++ options, command-line
2888@cindex options, C++
2889This section describes the command-line options that are only meaningful
2890for C++ programs. You can also use most of the GNU compiler options
2891regardless of what language your program is in. For example, you
2892might compile a file @file{firstClass.C} like this:
2893
2894@smallexample
2895g++ -g -fstrict-enums -O -c firstClass.C
2896@end smallexample
2897
2898@noindent
2899In this example, only @option{-fstrict-enums} is an option meant
2900only for C++ programs; you can use the other options with any
2901language supported by GCC@.
2902
2903Some options for compiling C programs, such as @option{-std}, are also
2904relevant for C++ programs.
2905@xref{C Dialect Options,,Options Controlling C Dialect}.
2906
2907Here is a list of options that are @emph{only} for compiling C++ programs:
2908
2909@table @gcctabopt
2910
2911@item -fabi-version=@var{n}
2912@opindex fabi-version
2913Use version @var{n} of the C++ ABI@. The default is version 0.
2914
2915Version 0 refers to the version conforming most closely to
2916the C++ ABI specification. Therefore, the ABI obtained using version 0
2917will change in different versions of G++ as ABI bugs are fixed.
2918
2919Version 1 is the version of the C++ ABI that first appeared in G++ 3.2.
2920
2921Version 2 is the version of the C++ ABI that first appeared in G++
29223.4, and was the default through G++ 4.9.
2923
2924Version 3 corrects an error in mangling a constant address as a
2925template argument.
2926
2927Version 4, which first appeared in G++ 4.5, implements a standard
2928mangling for vector types.
2929
2930Version 5, which first appeared in G++ 4.6, corrects the mangling of
2931attribute const/volatile on function pointer types, decltype of a
2932plain decl, and use of a function parameter in the declaration of
2933another parameter.
2934
2935Version 6, which first appeared in G++ 4.7, corrects the promotion
2936behavior of C++11 scoped enums and the mangling of template argument
2937packs, const/static_cast, prefix ++ and --, and a class scope function
2938used as a template argument.
2939
2940Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a
2941builtin type and corrects the mangling of lambdas in default argument
2942scope.
2943
2944Version 8, which first appeared in G++ 4.9, corrects the substitution
2945behavior of function types with function-cv-qualifiers.
2946
2947Version 9, which first appeared in G++ 5.2, corrects the alignment of
2948@code{nullptr_t}.
2949
2950Version 10, which first appeared in G++ 6.1, adds mangling of
2951attributes that affect type identity, such as ia32 calling convention
2952attributes (e.g.@: @samp{stdcall}).
2953
2954Version 11, which first appeared in G++ 7, corrects the mangling of
2955sizeof... expressions and operator names. For multiple entities with
2956the same name within a function, that are declared in different scopes,
2957the mangling now changes starting with the twelfth occurrence. It also
2958implies @option{-fnew-inheriting-ctors}.
2959
2960Version 12, which first appeared in G++ 8, corrects the calling
2961conventions for empty classes on the x86_64 target and for classes
2962with only deleted copy/move constructors. It accidentally changes the
2963calling convention for classes with a deleted copy constructor and a
2964trivial move constructor.
2965
2966Version 13, which first appeared in G++ 8.2, fixes the accidental
2967change in version 12.
2968
2969Version 14, which first appeared in G++ 10, corrects the mangling of
2970the nullptr expression.
2971
2972Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI
2973tag regression.
2974
2975Version 16, which first appeared in G++ 11, changes the mangling of
2976@code{__alignof__} to be distinct from that of @code{alignof}, and
2977dependent operator names.
2978
2979Version 17, which first appeared in G++ 12, fixes layout of classes
2980that inherit from aggregate classes with default member initializers
2981in C++14 and up.
2982
2983Version 18, which first appeard in G++ 13, fixes manglings of lambdas
2984that have additional context.
2985
2986See also @option{-Wabi}.
2987
2988@item -fabi-compat-version=@var{n}
2989@opindex fabi-compat-version
2990On targets that support strong aliases, G++
2991works around mangling changes by creating an alias with the correct
2992mangled name when defining a symbol with an incorrect mangled name.
2993This switch specifies which ABI version to use for the alias.
2994
2995With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2
2996compatibility). If another ABI version is explicitly selected, this
2997defaults to 0. For compatibility with GCC versions 3.2 through 4.9,
2998use @option{-fabi-compat-version=2}.
2999
3000If this option is not provided but @option{-Wabi=@var{n}} is, that
3001version is used for compatibility aliases. If this option is provided
3002along with @option{-Wabi} (without the version), the version from this
3003option is used for the warning.
3004
3005@item -fno-access-control
3006@opindex fno-access-control
3007@opindex faccess-control
3008Turn off all access checking. This switch is mainly useful for working
3009around bugs in the access control code.
3010
3011@item -faligned-new
3012@opindex faligned-new
3013Enable support for C++17 @code{new} of types that require more
3014alignment than @code{void* ::operator new(std::size_t)} provides. A
3015numeric argument such as @code{-faligned-new=32} can be used to
3016specify how much alignment (in bytes) is provided by that function,
3017but few users will need to override the default of
3018@code{alignof(std::max_align_t)}.
3019
3020This flag is enabled by default for @option{-std=c++17}.
3021
3022@item -fchar8_t
3023@itemx -fno-char8_t
3024@opindex fchar8_t
3025@opindex fno-char8_t
3026Enable support for @code{char8_t} as adopted for C++20. This includes
3027the addition of a new @code{char8_t} fundamental type, changes to the
3028types of UTF-8 string and character literals, new signatures for
3029user-defined literals, associated standard library updates, and new
3030@code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
3031
3032This option enables functions to be overloaded for ordinary and UTF-8
3033strings:
3034
3035@smallexample
3036int f(const char *); // #1
3037int f(const char8_t *); // #2
3038int v1 = f("text"); // Calls #1
3039int v2 = f(u8"text"); // Calls #2
3040@end smallexample
3041
3042@noindent
3043and introduces new signatures for user-defined literals:
3044
3045@smallexample
3046int operator""_udl1(char8_t);
3047int v3 = u8'x'_udl1;
3048int operator""_udl2(const char8_t*, std::size_t);
3049int v4 = u8"text"_udl2;
3050template<typename T, T...> int operator""_udl3();
3051int v5 = u8"text"_udl3;
3052@end smallexample
3053
3054@noindent
3055The change to the types of UTF-8 string and character literals introduces
3056incompatibilities with ISO C++11 and later standards. For example, the
3057following code is well-formed under ISO C++11, but is ill-formed when
3058@option{-fchar8_t} is specified.
3059
3060@smallexample
d77de738
ML
3061const char *cp = u8"xx";// error: invalid conversion from
3062 // `const char8_t*' to `const char*'
3063int f(const char*);
3064auto v = f(u8"xx"); // error: invalid conversion from
3065 // `const char8_t*' to `const char*'
3066std::string s@{u8"xx"@}; // error: no matching function for call to
3067 // `std::basic_string<char>::basic_string()'
3068using namespace std::literals;
3069s = u8"xx"s; // error: conversion from
3070 // `basic_string<char8_t>' to non-scalar
3071 // type `basic_string<char>' requested
3072@end smallexample
3073
3074@item -fcheck-new
3075@opindex fcheck-new
3076Check that the pointer returned by @code{operator new} is non-null
3077before attempting to modify the storage allocated. This check is
3078normally unnecessary because the C++ standard specifies that
3079@code{operator new} only returns @code{0} if it is declared
3080@code{throw()}, in which case the compiler always checks the
3081return value even without this option. In all other cases, when
3082@code{operator new} has a non-empty exception specification, memory
3083exhaustion is signalled by throwing @code{std::bad_alloc}. See also
3084@samp{new (nothrow)}.
3085
3086@item -fconcepts
3087@itemx -fconcepts-ts
3088@opindex fconcepts
3089@opindex fconcepts-ts
3090Enable support for the C++ Concepts feature for constraining template
3091arguments. With @option{-std=c++20} and above, Concepts are part of
3092the language standard, so @option{-fconcepts} defaults to on.
3093
3094Some constructs that were allowed by the earlier C++ Extensions for
3095Concepts Technical Specification, ISO 19217 (2015), but didn't make it
3096into the standard, can additionally be enabled by
3097@option{-fconcepts-ts}.
3098
3099@item -fconstexpr-depth=@var{n}
3100@opindex fconstexpr-depth
3101Set the maximum nested evaluation depth for C++11 constexpr functions
3102to @var{n}. A limit is needed to detect endless recursion during
3103constant expression evaluation. The minimum specified by the standard
3104is 512.
3105
3106@item -fconstexpr-cache-depth=@var{n}
3107@opindex fconstexpr-cache-depth
3108Set the maximum level of nested evaluation depth for C++11 constexpr
3109functions that will be cached to @var{n}. This is a heuristic that
3110trades off compilation speed (when the cache avoids repeated
3111calculations) against memory consumption (when the cache grows very
3112large from highly recursive evaluations). The default is 8. Very few
3113users are likely to want to adjust it, but if your code does heavy
3114constexpr calculations you might want to experiment to find which
3115value works best for you.
3116
3117@item -fconstexpr-fp-except
3118@opindex fconstexpr-fp-except
3119Annex F of the C standard specifies that IEC559 floating point
3120exceptions encountered at compile time should not stop compilation.
3121C++ compilers have historically not followed this guidance, instead
3122treating floating point division by zero as non-constant even though
3123it has a well defined value. This flag tells the compiler to give
3124Annex F priority over other rules saying that a particular operation
3125is undefined.
3126
3127@smallexample
3128constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except
3129@end smallexample
3130
3131@item -fconstexpr-loop-limit=@var{n}
3132@opindex fconstexpr-loop-limit
3133Set the maximum number of iterations for a loop in C++14 constexpr functions
3134to @var{n}. A limit is needed to detect infinite loops during
3135constant expression evaluation. The default is 262144 (1<<18).
3136
3137@item -fconstexpr-ops-limit=@var{n}
3138@opindex fconstexpr-ops-limit
3139Set the maximum number of operations during a single constexpr evaluation.
3140Even when number of iterations of a single loop is limited with the above limit,
3141if there are several nested loops and each of them has many iterations but still
3142smaller than the above limit, or if in a body of some loop or even outside
3143of a loop too many expressions need to be evaluated, the resulting constexpr
3144evaluation might take too long.
3145The default is 33554432 (1<<25).
3146
2efb237f
JCI
3147@item -fcontracts
3148@opindex fcontracts
3149Enable experimental support for the C++ Contracts feature, as briefly
3150added to and then removed from the C++20 working paper (N4820). The
3151implementation also includes proposed enhancements from papers P1290,
3152P1332, and P1429. This functionality is intended mostly for those
3153interested in experimentation towards refining the feature to get it
3154into shape for a future C++ standard.
3155
3156On violation of a checked contract, the violation handler is called.
3157Users can replace the violation handler by defining
3158@smallexample
3159void handle_contract_violation (const std::experimental::contract_violation&);
3160@end smallexample
3161
3162There are different sets of additional flags that can be used together
3163to specify which contracts will be checked and how, for N4820
3164contracts, P1332 contracts, or P1429 contracts; these sets cannot be
3165used together.
3166
3167@table @gcctabopt
3168@item -fcontract-mode=[on|off]
3169@opindex fcontract-mode
3170Control whether any contracts have any semantics at all. Defaults to on.
3171
3172@item -fcontract-assumption-mode=[on|off]
3173@opindex fcontract-assumption-mode
3174[N4820] Control whether contracts with level @samp{axiom}
3175should have the assume semantic. Defaults to on.
3176
3177@item -fcontract-build-level=[off|default|audit]
3178@opindex fcontract-build-level
3179[N4820] Specify which level of contracts to generate checks
3180for. Defaults to @samp{default}.
3181
3182@item -fcontract-continuation-mode=[on|off]
3183@opindex fcontract-continuation-mode
3184[N4820] Control whether to allow the program to continue executing
3185after a contract violation. That is, do checked contracts have the
3186@samp{maybe} semantic described below rather than the @samp{never}
3187semantic. Defaults to off.
3188
3189@item -fcontract-role=<name>:<default>,<audit>,<axiom>
3190@opindex fcontract-role
3191[P1332] Specify the concrete semantics for each contract level
3192of a particular contract role.
3193
3194@item -fcontract-semantic=[default|audit|axiom]:<semantic>
3195[P1429] Specify the concrete semantic for a particular
3196contract level.
3197
3198@item -fcontract-strict-declarations=[on|off]
3199@opindex fcontract-strict-declarations
3200Control whether to reject adding contracts to a function after its
3201first declaration. Defaults to off.
3202@end table
3203
3204The possible concrete semantics for that can be specified with
3205@samp{-fcontract-role} or @samp{-fcontract-semantic} are:
3206
3207@table @code
3208@item ignore
3209This contract has no effect.
3210
3211@item assume
3212This contract is treated like C++23 @code{[[assume]]}.
3213
3214@item check_never_continue
3215@itemx never
3216@itemx abort
3217This contract is checked. If it fails, the violation handler is
3218called. If the handler returns, @code{std::terminate} is called.
3219
3220@item check_maybe_continue
3221@itemx maybe
3222This contract is checked. If it fails, the violation handler is
3223called. If the handler returns, execution continues normally.
3224@end table
3225
d77de738
ML
3226@item -fcoroutines
3227@opindex fcoroutines
3228Enable support for the C++ coroutines extension (experimental).
3229
3230@item -fno-elide-constructors
3231@opindex fno-elide-constructors
3232@opindex felide-constructors
3233The C++ standard allows an implementation to omit creating a temporary
3234that is only used to initialize another object of the same type.
3235Specifying this option disables that optimization, and forces G++ to
3236call the copy constructor in all cases. This option also causes G++
3237to call trivial member functions which otherwise would be expanded inline.
3238
3239In C++17, the compiler is required to omit these temporaries, but this
3240option still affects trivial member functions.
3241
3242@item -fno-enforce-eh-specs
3243@opindex fno-enforce-eh-specs
3244@opindex fenforce-eh-specs
3245Don't generate code to check for violation of exception specifications
3246at run time. This option violates the C++ standard, but may be useful
3247for reducing code size in production builds, much like defining
3248@code{NDEBUG}. This does not give user code permission to throw
3249exceptions in violation of the exception specifications; the compiler
3250still optimizes based on the specifications, so throwing an
3251unexpected exception results in undefined behavior at run time.
3252
3253@item -fextern-tls-init
3254@itemx -fno-extern-tls-init
3255@opindex fextern-tls-init
3256@opindex fno-extern-tls-init
3257The C++11 and OpenMP standards allow @code{thread_local} and
3258@code{threadprivate} variables to have dynamic (runtime)
3259initialization. To support this, any use of such a variable goes
3260through a wrapper function that performs any necessary initialization.
3261When the use and definition of the variable are in the same
3262translation unit, this overhead can be optimized away, but when the
3263use is in a different translation unit there is significant overhead
3264even if the variable doesn't actually need dynamic initialization. If
3265the programmer can be sure that no use of the variable in a
3266non-defining TU needs to trigger dynamic initialization (either
3267because the variable is statically initialized, or a use of the
3268variable in the defining TU will be executed before any uses in
3269another TU), they can avoid this overhead with the
3270@option{-fno-extern-tls-init} option.
3271
3272On targets that support symbol aliases, the default is
3273@option{-fextern-tls-init}. On targets that do not support symbol
3274aliases, the default is @option{-fno-extern-tls-init}.
3275
3276@item -ffold-simple-inlines
3277@itemx -fno-fold-simple-inlines
3278@opindex ffold-simple-inlines
3279@opindex fno-fold-simple-inlines
3280Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward},
3281@code{std::addressof} and @code{std::as_const}. In contrast to inlining, this
3282means no debug information will be generated for such calls. Since these
3283functions are rarely interesting to debug, this flag is enabled by default
3284unless @option{-fno-inline} is active.
3285
3286@item -fno-gnu-keywords
3287@opindex fno-gnu-keywords
3288@opindex fgnu-keywords
3289Do not recognize @code{typeof} as a keyword, so that code can use this
3290word as an identifier. You can use the keyword @code{__typeof__} instead.
3291This option is implied by the strict ISO C++ dialects: @option{-ansi},
3292@option{-std=c++98}, @option{-std=c++11}, etc.
3293
3294@item -fimplicit-constexpr
3295@opindex fimplicit-constexpr
3296Make inline functions implicitly constexpr, if they satisfy the
3297requirements for a constexpr function. This option can be used in
3298C++14 mode or later. This can result in initialization changing from
3299dynamic to static and other optimizations.
3300
3301@item -fno-implicit-templates
3302@opindex fno-implicit-templates
3303@opindex fimplicit-templates
3304Never emit code for non-inline templates that are instantiated
3305implicitly (i.e.@: by use); only emit code for explicit instantiations.
3306If you use this option, you must take care to structure your code to
3307include all the necessary explicit instantiations to avoid getting
3308undefined symbols at link time.
3309@xref{Template Instantiation}, for more information.
3310
3311@item -fno-implicit-inline-templates
3312@opindex fno-implicit-inline-templates
3313@opindex fimplicit-inline-templates
3314Don't emit code for implicit instantiations of inline templates, either.
3315The default is to handle inlines differently so that compiles with and
3316without optimization need the same set of explicit instantiations.
3317
3318@item -fno-implement-inlines
3319@opindex fno-implement-inlines
3320@opindex fimplement-inlines
3321To save space, do not emit out-of-line copies of inline functions
3322controlled by @code{#pragma implementation}. This causes linker
3323errors if these functions are not inlined everywhere they are called.
3324
3325@item -fmodules-ts
3326@itemx -fno-modules-ts
3327@opindex fmodules-ts
3328@opindex fno-modules-ts
3329Enable support for C++20 modules (@pxref{C++ Modules}). The
3330@option{-fno-modules-ts} is usually not needed, as that is the
3331default. Even though this is a C++20 feature, it is not currently
3332implicitly enabled by selecting that standard version.
3333
3334@item -fmodule-header
3335@itemx -fmodule-header=user
3336@itemx -fmodule-header=system
3337@opindex fmodule-header
3338Compile a header file to create an importable header unit.
3339
3340@item -fmodule-implicit-inline
3341@opindex fmodule-implicit-inline
3342Member functions defined in their class definitions are not implicitly
3343inline for modular code. This is different to traditional C++
3344behavior, for good reasons. However, it may result in a difficulty
3345during code porting. This option makes such function definitions
3346implicitly inline. It does however generate an ABI incompatibility,
3347so you must use it everywhere or nowhere. (Such definitions outside
3348of a named module remain implicitly inline, regardless.)
3349
3350@item -fno-module-lazy
3351@opindex fno-module-lazy
3352@opindex fmodule-lazy
3353Disable lazy module importing and module mapper creation.
3354
3355@item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
3356@itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...}
3357@itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]}
3358@itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]}
3359@itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]}
3360@itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]}
3361@vindex CXX_MODULE_MAPPER @r{environment variable}
3362@opindex fmodule-mapper
3363An oracle to query for module name to filename mappings. If
3364unspecified the @env{CXX_MODULE_MAPPER} environment variable is used,
3365and if that is unset, an in-process default is provided.
3366
3367@item -fmodule-only
3368@opindex fmodule-only
3369Only emit the Compiled Module Interface, inhibiting any object file.
3370
3371@item -fms-extensions
3372@opindex fms-extensions
3373Disable Wpedantic warnings about constructs used in MFC, such as implicit
3374int and getting a pointer to member function via non-standard syntax.
3375
3376@item -fnew-inheriting-ctors
3377@opindex fnew-inheriting-ctors
3378Enable the P0136 adjustment to the semantics of C++11 constructor
3379inheritance. This is part of C++17 but also considered to be a Defect
3380Report against C++11 and C++14. This flag is enabled by default
3381unless @option{-fabi-version=10} or lower is specified.
3382
3383@item -fnew-ttp-matching
3384@opindex fnew-ttp-matching
3385Enable the P0522 resolution to Core issue 150, template template
3386parameters and default arguments: this allows a template with default
3387template arguments as an argument for a template template parameter
3388with fewer template parameters. This flag is enabled by default for
3389@option{-std=c++17}.
3390
3391@item -fno-nonansi-builtins
3392@opindex fno-nonansi-builtins
3393@opindex fnonansi-builtins
3394Disable built-in declarations of functions that are not mandated by
3395ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
3396@code{index}, @code{bzero}, @code{conjf}, and other related functions.
3397
3398@item -fnothrow-opt
3399@opindex fnothrow-opt
3400Treat a @code{throw()} exception specification as if it were a
3401@code{noexcept} specification to reduce or eliminate the text size
3402overhead relative to a function with no exception specification. If
3403the function has local variables of types with non-trivial
3404destructors, the exception specification actually makes the
3405function smaller because the EH cleanups for those variables can be
3406optimized away. The semantic effect is that an exception thrown out of
3407a function with such an exception specification results in a call
3408to @code{terminate} rather than @code{unexpected}.
3409
3410@item -fno-operator-names
3411@opindex fno-operator-names
3412@opindex foperator-names
3413Do not treat the operator name keywords @code{and}, @code{bitand},
3414@code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
3415synonyms as keywords.
3416
3417@item -fno-optional-diags
3418@opindex fno-optional-diags
3419@opindex foptional-diags
3420Disable diagnostics that the standard says a compiler does not need to
3421issue. Currently, the only such diagnostic issued by G++ is the one for
3422a name having multiple meanings within a class.
3423
3424@item -fpermissive
3425@opindex fpermissive
3426Downgrade some diagnostics about nonconformant code from errors to
3427warnings. Thus, using @option{-fpermissive} allows some
3428nonconforming code to compile.
3429
3430@item -fno-pretty-templates
3431@opindex fno-pretty-templates
3432@opindex fpretty-templates
3433When an error message refers to a specialization of a function
3434template, the compiler normally prints the signature of the
3435template followed by the template arguments and any typedefs or
3436typenames in the signature (e.g.@: @code{void f(T) [with T = int]}
3437rather than @code{void f(int)}) so that it's clear which template is
3438involved. When an error message refers to a specialization of a class
3439template, the compiler omits any template arguments that match
3440the default template arguments for that template. If either of these
3441behaviors make it harder to understand the error message rather than
3442easier, you can use @option{-fno-pretty-templates} to disable them.
3443
3444@item -fno-rtti
3445@opindex fno-rtti
3446@opindex frtti
3447Disable generation of information about every class with virtual
3448functions for use by the C++ run-time type identification features
3449(@code{dynamic_cast} and @code{typeid}). If you don't use those parts
3450of the language, you can save some space by using this flag. Note that
3451exception handling uses the same information, but G++ generates it as
3452needed. The @code{dynamic_cast} operator can still be used for casts that
3453do not require run-time type information, i.e.@: casts to @code{void *} or to
3454unambiguous base classes.
3455
3456Mixing code compiled with @option{-frtti} with that compiled with
3457@option{-fno-rtti} may not work. For example, programs may
3458fail to link if a class compiled with @option{-fno-rtti} is used as a base
3459for a class compiled with @option{-frtti}.
3460
3461@item -fsized-deallocation
3462@opindex fsized-deallocation
3463Enable the built-in global declarations
3464@smallexample
3465void operator delete (void *, std::size_t) noexcept;
3466void operator delete[] (void *, std::size_t) noexcept;
3467@end smallexample
3468as introduced in C++14. This is useful for user-defined replacement
3469deallocation functions that, for example, use the size of the object
3470to make deallocation faster. Enabled by default under
3471@option{-std=c++14} and above. The flag @option{-Wsized-deallocation}
3472warns about places that might want to add a definition.
3473
3474@item -fstrict-enums
3475@opindex fstrict-enums
3476Allow the compiler to optimize using the assumption that a value of
3477enumerated type can only be one of the values of the enumeration (as
3478defined in the C++ standard; basically, a value that can be
3479represented in the minimum number of bits needed to represent all the
3480enumerators). This assumption may not be valid if the program uses a
3481cast to convert an arbitrary integer value to the enumerated type.
3482
3483@item -fstrong-eval-order
3484@opindex fstrong-eval-order
3485Evaluate member access, array subscripting, and shift expressions in
3486left-to-right order, and evaluate assignment in right-to-left order,
3487as adopted for C++17. Enabled by default with @option{-std=c++17}.
3488@option{-fstrong-eval-order=some} enables just the ordering of member
3489access and shift expressions, and is the default without
3490@option{-std=c++17}.
3491
3492@item -ftemplate-backtrace-limit=@var{n}
3493@opindex ftemplate-backtrace-limit
3494Set the maximum number of template instantiation notes for a single
3495warning or error to @var{n}. The default value is 10.
3496
3497@item -ftemplate-depth=@var{n}
3498@opindex ftemplate-depth
3499Set the maximum instantiation depth for template classes to @var{n}.
3500A limit on the template instantiation depth is needed to detect
3501endless recursions during template class instantiation. ANSI/ISO C++
3502conforming programs must not rely on a maximum depth greater than 17
3503(changed to 1024 in C++11). The default value is 900, as the compiler
3504can run out of stack space before hitting 1024 in some situations.
3505
3506@item -fno-threadsafe-statics
3507@opindex fno-threadsafe-statics
3508@opindex fthreadsafe-statics
3509Do not emit the extra code to use the routines specified in the C++
3510ABI for thread-safe initialization of local statics. You can use this
3511option to reduce code size slightly in code that doesn't need to be
3512thread-safe.
3513
3514@item -fuse-cxa-atexit
3515@opindex fuse-cxa-atexit
3516Register destructors for objects with static storage duration with the
3517@code{__cxa_atexit} function rather than the @code{atexit} function.
3518This option is required for fully standards-compliant handling of static
3519destructors, but only works if your C library supports
3520@code{__cxa_atexit}.
3521
3522@item -fno-use-cxa-get-exception-ptr
3523@opindex fno-use-cxa-get-exception-ptr
3524@opindex fuse-cxa-get-exception-ptr
3525Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
3526causes @code{std::uncaught_exception} to be incorrect, but is necessary
3527if the runtime routine is not available.
3528
3529@item -fvisibility-inlines-hidden
3530@opindex fvisibility-inlines-hidden
3531This switch declares that the user does not attempt to compare
3532pointers to inline functions or methods where the addresses of the two functions
3533are taken in different shared objects.
3534
3535The effect of this is that GCC may, effectively, mark inline methods with
3536@code{__attribute__ ((visibility ("hidden")))} so that they do not
3537appear in the export table of a DSO and do not require a PLT indirection
3538when used within the DSO@. Enabling this option can have a dramatic effect
3539on load and link times of a DSO as it massively reduces the size of the
3540dynamic export table when the library makes heavy use of templates.
3541
3542The behavior of this switch is not quite the same as marking the
3543methods as hidden directly, because it does not affect static variables
3544local to the function or cause the compiler to deduce that
3545the function is defined in only one shared object.
3546
3547You may mark a method as having a visibility explicitly to negate the
3548effect of the switch for that method. For example, if you do want to
3549compare pointers to a particular inline method, you might mark it as
3550having default visibility. Marking the enclosing class with explicit
3551visibility has no effect.
3552
3553Explicitly instantiated inline methods are unaffected by this option
3554as their linkage might otherwise cross a shared library boundary.
3555@xref{Template Instantiation}.
3556
3557@item -fvisibility-ms-compat
3558@opindex fvisibility-ms-compat
3559This flag attempts to use visibility settings to make GCC's C++
3560linkage model compatible with that of Microsoft Visual Studio.
3561
3562The flag makes these changes to GCC's linkage model:
3563
3564@enumerate
3565@item
3566It sets the default visibility to @code{hidden}, like
3567@option{-fvisibility=hidden}.
3568
3569@item
3570Types, but not their members, are not hidden by default.
3571
3572@item
3573The One Definition Rule is relaxed for types without explicit
3574visibility specifications that are defined in more than one
3575shared object: those declarations are permitted if they are
3576permitted when this option is not used.
3577@end enumerate
3578
3579In new code it is better to use @option{-fvisibility=hidden} and
3580export those classes that are intended to be externally visible.
3581Unfortunately it is possible for code to rely, perhaps accidentally,
3582on the Visual Studio behavior.
3583
3584Among the consequences of these changes are that static data members
3585of the same type with the same name but defined in different shared
3586objects are different, so changing one does not change the other;
3587and that pointers to function members defined in different shared
3588objects may not compare equal. When this flag is given, it is a
3589violation of the ODR to define types with the same name differently.
3590
3591@item -fno-weak
3592@opindex fno-weak
3593@opindex fweak
3594Do not use weak symbol support, even if it is provided by the linker.
3595By default, G++ uses weak symbols if they are available. This
3596option exists only for testing, and should not be used by end-users;
3597it results in inferior code and has no benefits. This option may
3598be removed in a future release of G++.
3599
3600@item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
3601@opindex fext-numeric-literals
3602@opindex fno-ext-numeric-literals
3603Accept imaginary, fixed-point, or machine-defined
3604literal number suffixes as GNU extensions.
3605When this option is turned off these suffixes are treated
3606as C++11 user-defined literal numeric suffixes.
3607This is on by default for all pre-C++11 dialects and all GNU dialects:
3608@option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
3609@option{-std=gnu++14}.
3610This option is off by default
3611for ISO C++11 onwards (@option{-std=c++11}, ...).
3612
3613@item -nostdinc++
3614@opindex nostdinc++
3615Do not search for header files in the standard directories specific to
3616C++, but do still search the other standard directories. (This option
3617is used when building the C++ library.)
3618
3619@item -flang-info-include-translate
3620@itemx -flang-info-include-translate-not
3621@itemx -flang-info-include-translate=@var{header}
3622@opindex flang-info-include-translate
3623@opindex flang-info-include-translate-not
3624Inform of include translation events. The first will note accepted
3625include translations, the second will note declined include
3626translations. The @var{header} form will inform of include
3627translations relating to that specific header. If @var{header} is of
3628the form @code{"user"} or @code{<system>} it will be resolved to a
3629specific user or system header using the include path.
3630
3631@item -flang-info-module-cmi
3632@itemx -flang-info-module-cmi=@var{module}
3633@opindex flang-info-module-cmi
3634Inform of Compiled Module Interface pathnames. The first will note
3635all read CMI pathnames. The @var{module} form will not reading a
3636specific module's CMI. @var{module} may be a named module or a
3637header-unit (the latter indicated by either being a pathname containing
3638directory separators or enclosed in @code{<>} or @code{""}).
3639
3640@item -stdlib=@var{libstdc++,libc++}
3641@opindex stdlib
3642When G++ is configured to support this option, it allows specification of
3643alternate C++ runtime libraries. Two options are available: @var{libstdc++}
3644(the default, native C++ runtime for G++) and @var{libc++} which is the
3645C++ runtime installed on some operating systems (e.g. Darwin versions from
3646Darwin11 onwards). The option switches G++ to use the headers from the
3647specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
3648when a C++ runtime is required for linking.
3649@end table
3650
3651In addition, these warning options have meanings only for C++ programs:
3652
3653@table @gcctabopt
3654@item -Wabi-tag @r{(C++ and Objective-C++ only)}
3655@opindex Wabi-tag
3656Warn when a type with an ABI tag is used in a context that does not
3657have that ABI tag. See @ref{C++ Attributes} for more information
3658about ABI tags.
3659
3660@item -Wcomma-subscript @r{(C++ and Objective-C++ only)}
3661@opindex Wcomma-subscript
3662@opindex Wno-comma-subscript
3663Warn about uses of a comma expression within a subscripting expression.
3664This usage was deprecated in C++20 and is going to be removed in C++23.
3665However, a comma expression wrapped in @code{( )} is not deprecated. Example:
3666
3667@smallexample
3668@group
3669void f(int *a, int b, int c) @{
3670 a[b,c]; // deprecated in C++20, invalid in C++23
3671 a[(b,c)]; // OK
3672@}
3673@end group
3674@end smallexample
3675
3676In C++23 it is valid to have comma separated expressions in a subscript
3677when an overloaded subscript operator is found and supports the right
3678number and types of arguments. G++ will accept the formerly valid syntax
3679for code that is not valid in C++23 but used to be valid but deprecated
3680in C++20 with a pedantic warning that can be disabled with
3681@option{-Wno-comma-subscript}.
3682
3683Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated},
3684and with @option{-std=c++23} regardless of @option{-Wno-deprecated}.
3685
3686@item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
3687@opindex Wctad-maybe-unsupported
3688@opindex Wno-ctad-maybe-unsupported
3689Warn when performing class template argument deduction (CTAD) on a type with
3690no explicitly written deduction guides. This warning will point out cases
3691where CTAD succeeded only because the compiler synthesized the implicit
3692deduction guides, which might not be what the programmer intended. Certain
3693style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3694types that are designed to support CTAD. This warning can be suppressed with
3695the following pattern:
3696
3697@smallexample
3698struct allow_ctad_t; // any name works
3699template <typename T> struct S @{
3700 S(T) @{ @}
3701@};
3702S(allow_ctad_t) -> S<void>; // guide with incomplete parameter type will never be considered
3703@end smallexample
3704
3705@item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
3706@opindex Wctor-dtor-privacy
3707@opindex Wno-ctor-dtor-privacy
3708Warn when a class seems unusable because all the constructors or
3709destructors in that class are private, and it has neither friends nor
3710public static member functions. Also warn if there are no non-private
3711methods, and there's at least one private member function that isn't
3712a constructor or destructor.
3713
3714@item -Wdangling-reference @r{(C++ and Objective-C++ only)}
3715@opindex Wdangling-reference
3716@opindex Wno-dangling-reference
3717Warn when a reference is bound to a temporary whose lifetime has ended.
3718For example:
3719
3720@smallexample
3721int n = 1;
3722const int& r = std::max(n - 1, n + 1); // r is dangling
3723@end smallexample
3724
3725In the example above, two temporaries are created, one for each
3726argument, and a reference to one of the temporaries is returned.
3727However, both temporaries are destroyed at the end of the full
3728expression, so the reference @code{r} is dangling. This warning
3729also detects dangling references in member initializer lists:
3730
3731@smallexample
3732const int& f(const int& i) @{ return i; @}
3733struct S @{
3734 const int &r; // r is dangling
3735 S() : r(f(10)) @{ @}
3736@};
3737@end smallexample
3738
3739Member functions are checked as well, but only their object argument:
3740
3741@smallexample
3742struct S @{
3743 const S& self () @{ return *this; @}
3744@};
3745const S& s = S().self(); // s is dangling
3746@end smallexample
3747
3748Certain functions are safe in this respect, for example @code{std::use_facet}:
3749they take and return a reference, but they don't return one of its arguments,
3750which can fool the warning. Such functions can be excluded from the warning
3751by wrapping them in a @code{#pragma}:
3752
3753@smallexample
3754#pragma GCC diagnostic push
3755#pragma GCC diagnostic ignored "-Wdangling-reference"
3756const T& foo (const T&) @{ @dots{} @}
3757#pragma GCC diagnostic pop
3758@end smallexample
3759
ce51e843
ML
3760@option{-Wdangling-reference} also warns about code like
3761
3762@smallexample
3763auto p = std::minmax(1, 2);
3764@end smallexample
3765
3766where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
3767both references dangle after the end of the full expression that contains
3768the call to @code{std::minmax}.
3769
d77de738
ML
3770This warning is enabled by @option{-Wall}.
3771
3772@item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
3773@opindex Wdelete-non-virtual-dtor
3774@opindex Wno-delete-non-virtual-dtor
3775Warn when @code{delete} is used to destroy an instance of a class that
3776has virtual functions and non-virtual destructor. It is unsafe to delete
3777an instance of a derived class through a pointer to a base class if the
3778base class does not have a virtual destructor. This warning is enabled
3779by @option{-Wall}.
3780
3781@item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
3782@opindex Wdeprecated-copy
3783@opindex Wno-deprecated-copy
3784Warn that the implicit declaration of a copy constructor or copy
3785assignment operator is deprecated if the class has a user-provided
3786copy constructor or copy assignment operator, in C++11 and up. This
3787warning is enabled by @option{-Wextra}. With
3788@option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3789user-provided destructor.
3790
3791@item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
3792@opindex Wdeprecated-enum-enum-conversion
3793@opindex Wno-deprecated-enum-enum-conversion
3794Disable the warning about the case when the usual arithmetic conversions
3795are applied on operands where one is of enumeration type and the other is
3796of a different enumeration type. This conversion was deprecated in C++20.
3797For example:
3798
3799@smallexample
3800enum E1 @{ e @};
3801enum E2 @{ f @};
3802int k = f - e;
3803@end smallexample
3804
3805@option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3806@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3807by @option{-Wenum-conversion}.
3808
3809@item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
3810@opindex Wdeprecated-enum-float-conversion
3811@opindex Wno-deprecated-enum-float-conversion
3812Disable the warning about the case when the usual arithmetic conversions
3813are applied on operands where one is of enumeration type and the other is
3814of a floating-point type. This conversion was deprecated in C++20. For
3815example:
3816
3817@smallexample
3818enum E1 @{ e @};
3819enum E2 @{ f @};
3820bool b = e <= 3.7;
3821@end smallexample
3822
3823@option{-Wdeprecated-enum-float-conversion} is enabled by default with
3824@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3825by @option{-Wenum-conversion}.
3826
3827@item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
3828@opindex Winit-list-lifetime
3829@opindex Wno-init-list-lifetime
3830Do not warn about uses of @code{std::initializer_list} that are likely
3831to result in dangling pointers. Since the underlying array for an
3832@code{initializer_list} is handled like a normal C++ temporary object,
3833it is easy to inadvertently keep a pointer to the array past the end
3834of the array's lifetime. For example:
3835
3836@itemize @bullet
3837@item
3838If a function returns a temporary @code{initializer_list}, or a local
3839@code{initializer_list} variable, the array's lifetime ends at the end
3840of the return statement, so the value returned has a dangling pointer.
3841
3842@item
3843If a new-expression creates an @code{initializer_list}, the array only
3844lives until the end of the enclosing full-expression, so the
3845@code{initializer_list} in the heap has a dangling pointer.
3846
3847@item
3848When an @code{initializer_list} variable is assigned from a
3849brace-enclosed initializer list, the temporary array created for the
3850right side of the assignment only lives until the end of the
3851full-expression, so at the next statement the @code{initializer_list}
3852variable has a dangling pointer.
3853
3854@smallexample
3855// li's initial underlying array lives as long as li
3856std::initializer_list<int> li = @{ 1,2,3 @};
3857// assignment changes li to point to a temporary array
3858li = @{ 4, 5 @};
3859// now the temporary is gone and li has a dangling pointer
3860int i = li.begin()[0] // undefined behavior
3861@end smallexample
3862
3863@item
3864When a list constructor stores the @code{begin} pointer from the
3865@code{initializer_list} argument, this doesn't extend the lifetime of
3866the array, so if a class variable is constructed from a temporary
3867@code{initializer_list}, the pointer is left dangling by the end of
3868the variable declaration statement.
3869
3870@end itemize
3871
c85f8dbb
MP
3872@item -Winvalid-constexpr
3873@opindex Winvalid-constexpr
3874@opindex Wno-invalid-constexpr
3875
3876Warn when a function never produces a constant expression. In C++20
3877and earlier, for every @code{constexpr} function and function template,
3878there must be at least one set of function arguments in at least one
3879instantiation such that an invocation of the function or constructor
3880could be an evaluated subexpression of a core constant expression.
3881C++23 removed this restriction, so it's possible to have a function
3882or a function template marked @code{constexpr} for which no invocation
3883satisfies the requirements of a core constant expression.
3884
3885This warning is enabled as a pedantic warning by default in C++20 and
3886earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in
3887which case it will be an ordinary warning. For example:
3888
3889@smallexample
3890void f (int& i);
3891constexpr void
3892g (int& i)
3893@{
3894 f(i); // warns by default in C++20, in C++23 only with -Winvalid-constexpr
3895@}
3896@end smallexample
3897
d77de738
ML
3898@item -Winvalid-imported-macros
3899@opindex Winvalid-imported-macros
3900@opindex Wno-invalid-imported-macros
3901Verify all imported macro definitions are valid at the end of
3902compilation. This is not enabled by default, as it requires
3903additional processing to determine. It may be useful when preparing
3904sets of header-units to ensure consistent macros.
3905
3906@item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
3907@opindex Wliteral-suffix
3908@opindex Wno-literal-suffix
3909Do not warn when a string or character literal is followed by a
3910ud-suffix which does not begin with an underscore. As a conforming
3911extension, GCC treats such suffixes as separate preprocessing tokens
3912in order to maintain backwards compatibility with code that uses
3913formatting macros from @code{<inttypes.h>}. For example:
3914
3915@smallexample
3916#define __STDC_FORMAT_MACROS
3917#include <inttypes.h>
3918#include <stdio.h>
3919
3920int main() @{
3921 int64_t i64 = 123;
3922 printf("My int64: %" PRId64"\n", i64);
3923@}
3924@end smallexample
3925
3926In this case, @code{PRId64} is treated as a separate preprocessing token.
3927
3928This option also controls warnings when a user-defined literal
3929operator is declared with a literal suffix identifier that doesn't
3930begin with an underscore. Literal suffix identifiers that don't begin
3931with an underscore are reserved for future standardization.
3932
3933These warnings are enabled by default.
3934
3935@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
3936@opindex Wnarrowing
3937@opindex Wno-narrowing
3938For C++11 and later standards, narrowing conversions are diagnosed by default,
3939as required by the standard. A narrowing conversion from a constant produces
3940an error, and a narrowing conversion from a non-constant produces a warning,
3941but @option{-Wno-narrowing} suppresses the diagnostic.
3942Note that this does not affect the meaning of well-formed code;
3943narrowing conversions are still considered ill-formed in SFINAE contexts.
3944
3945With @option{-Wnarrowing} in C++98, warn when a narrowing
3946conversion prohibited by C++11 occurs within
3947@samp{@{ @}}, e.g.
3948
3949@smallexample
3950int i = @{ 2.2 @}; // error: narrowing from double to int
3951@end smallexample
3952
3953This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
3954
3955@item -Wnoexcept @r{(C++ and Objective-C++ only)}
3956@opindex Wnoexcept
3957@opindex Wno-noexcept
3958Warn when a noexcept-expression evaluates to false because of a call
3959to a function that does not have a non-throwing exception
3960specification (i.e. @code{throw()} or @code{noexcept}) but is known by
3961the compiler to never throw an exception.
3962
3963@item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
3964@opindex Wnoexcept-type
3965@opindex Wno-noexcept-type
3966Warn if the C++17 feature making @code{noexcept} part of a function
3967type changes the mangled name of a symbol relative to C++14. Enabled
3968by @option{-Wabi} and @option{-Wc++17-compat}.
3969
3970As an example:
3971
3972@smallexample
3973template <class T> void f(T t) @{ t(); @};
3974void g() noexcept;
3975void h() @{ f(g); @}
3976@end smallexample
3977
3978@noindent
3979In C++14, @code{f} calls @code{f<void(*)()>}, but in
3980C++17 it calls @code{f<void(*)()noexcept>}.
3981
3982@item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
3983@opindex Wclass-memaccess
3984@opindex Wno-class-memaccess
3985Warn when the destination of a call to a raw memory function such as
3986@code{memset} or @code{memcpy} is an object of class type, and when writing
3987into such an object might bypass the class non-trivial or deleted constructor
3988or copy assignment, violate const-correctness or encapsulation, or corrupt
3989virtual table pointers. Modifying the representation of such objects may
3990violate invariants maintained by member functions of the class. For example,
3991the call to @code{memset} below is undefined because it modifies a non-trivial
3992class object and is, therefore, diagnosed. The safe way to either initialize
3993or clear the storage of objects of such types is by using the appropriate
3994constructor or assignment operator, if one is available.
3995@smallexample
3996std::string str = "abc";
3997memset (&str, 0, sizeof str);
3998@end smallexample
3999The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
4000Explicitly casting the pointer to the class object to @code{void *} or
4001to a type that can be safely accessed by the raw memory function suppresses
4002the warning.
4003
4004@item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
4005@opindex Wnon-virtual-dtor
4006@opindex Wno-non-virtual-dtor
4007Warn when a class has virtual functions and an accessible non-virtual
4008destructor itself or in an accessible polymorphic base class, in which
4009case it is possible but unsafe to delete an instance of a derived
4010class through a pointer to the class itself or base class. This
4011warning is automatically enabled if @option{-Weffc++} is specified.
51f28e3a
JW
4012The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall})
4013should be preferred because it warns about the unsafe cases without false
4014positives.
d77de738
ML
4015
4016@item -Wregister @r{(C++ and Objective-C++ only)}
4017@opindex Wregister
4018@opindex Wno-register
4019Warn on uses of the @code{register} storage class specifier, except
4020when it is part of the GNU @ref{Explicit Register Variables} extension.
4021The use of the @code{register} keyword as storage class specifier has
4022been deprecated in C++11 and removed in C++17.
4023Enabled by default with @option{-std=c++17}.
4024
4025@item -Wreorder @r{(C++ and Objective-C++ only)}
4026@opindex Wreorder
4027@opindex Wno-reorder
4028@cindex reordering, warning
4029@cindex warning for reordering of member initializers
4030Warn when the order of member initializers given in the code does not
4031match the order in which they must be executed. For instance:
4032
4033@smallexample
4034struct A @{
4035 int i;
4036 int j;
4037 A(): j (0), i (1) @{ @}
4038@};
4039@end smallexample
4040
4041@noindent
4042The compiler rearranges the member initializers for @code{i}
4043and @code{j} to match the declaration order of the members, emitting
4044a warning to that effect. This warning is enabled by @option{-Wall}.
4045
4046@item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
4047@opindex Wpessimizing-move
4048@opindex Wno-pessimizing-move
4049This warning warns when a call to @code{std::move} prevents copy
4050elision. A typical scenario when copy elision can occur is when returning in
4051a function with a class return type, when the expression being returned is the
4052name of a non-volatile automatic object, and is not a function parameter, and
4053has the same type as the function return type.
4054
4055@smallexample
4056struct T @{
4057@dots{}
4058@};
4059T fn()
4060@{
4061 T t;
4062 @dots{}
4063 return std::move (t);
4064@}
4065@end smallexample
4066
4067But in this example, the @code{std::move} call prevents copy elision.
4068
4069This warning is enabled by @option{-Wall}.
4070
4071@item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
4072@opindex Wredundant-move
4073@opindex Wno-redundant-move
4074This warning warns about redundant calls to @code{std::move}; that is, when
4075a move operation would have been performed even without the @code{std::move}
4076call. This happens because the compiler is forced to treat the object as if
4077it were an rvalue in certain situations such as returning a local variable,
4078where copy elision isn't applicable. Consider:
4079
4080@smallexample
4081struct T @{
4082@dots{}
4083@};
4084T fn(T t)
4085@{
4086 @dots{}
4087 return std::move (t);
4088@}
4089@end smallexample
4090
4091Here, the @code{std::move} call is redundant. Because G++ implements Core
4092Issue 1579, another example is:
4093
4094@smallexample
4095struct T @{ // convertible to U
4096@dots{}
4097@};
4098struct U @{
4099@dots{}
4100@};
4101U fn()
4102@{
4103 T t;
4104 @dots{}
4105 return std::move (t);
4106@}
4107@end smallexample
4108In this example, copy elision isn't applicable because the type of the
4109expression being returned and the function return type differ, yet G++
4110treats the return value as if it were designated by an rvalue.
4111
4112This warning is enabled by @option{-Wextra}.
4113
4114@item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
4115@opindex Wrange-loop-construct
4116@opindex Wno-range-loop-construct
4117This warning warns when a C++ range-based for-loop is creating an unnecessary
4118copy. This can happen when the range declaration is not a reference, but
4119probably should be. For example:
4120
4121@smallexample
4122struct S @{ char arr[128]; @};
4123void fn () @{
4124 S arr[5];
4125 for (const auto x : arr) @{ @dots{} @}
4126@}
4127@end smallexample
4128
4129It does not warn when the type being copied is a trivially-copyable type whose
4130size is less than 64 bytes.
4131
4132This warning also warns when a loop variable in a range-based for-loop is
4133initialized with a value of a different type resulting in a copy. For example:
4134
4135@smallexample
4136void fn() @{
4137 int arr[10];
4138 for (const double &x : arr) @{ @dots{} @}
4139@}
4140@end smallexample
4141
4142In the example above, in every iteration of the loop a temporary value of
4143type @code{double} is created and destroyed, to which the reference
4144@code{const double &} is bound.
4145
4146This warning is enabled by @option{-Wall}.
4147
4148@item -Wredundant-tags @r{(C++ and Objective-C++ only)}
4149@opindex Wredundant-tags
4150@opindex Wno-redundant-tags
4151Warn about redundant class-key and enum-key in references to class types
4152and enumerated types in contexts where the key can be eliminated without
4153causing an ambiguity. For example:
4154
4155@smallexample
4156struct foo;
4157struct foo *p; // warn that keyword struct can be eliminated
4158@end smallexample
4159
4160@noindent
4161On the other hand, in this example there is no warning:
4162
4163@smallexample
4164struct foo;
4165void foo (); // "hides" struct foo
4166void bar (struct foo&); // no warning, keyword struct is necessary
4167@end smallexample
4168
4169@item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
4170@opindex Wsubobject-linkage
4171@opindex Wno-subobject-linkage
4172Do not warn
4173if a class type has a base or a field whose type uses the anonymous
4174namespace or depends on a type with no linkage. If a type A depends on
4175a type B with no or internal linkage, defining it in multiple
4176translation units would be an ODR violation because the meaning of B
4177is different in each translation unit. If A only appears in a single
4178translation unit, the best way to silence the warning is to give it
4179internal linkage by putting it in an anonymous namespace as well. The
4180compiler doesn't give this warning for types defined in the main .C
4181file, as those are unlikely to have multiple definitions.
4182@option{-Wsubobject-linkage} is enabled by default.
4183
4184@item -Weffc++ @r{(C++ and Objective-C++ only)}
4185@opindex Weffc++
4186@opindex Wno-effc++
4187Warn about violations of the following style guidelines from Scott Meyers'
4188@cite{Effective C++} series of books:
4189
4190@itemize @bullet
4191@item
4192Define a copy constructor and an assignment operator for classes
4193with dynamically-allocated memory.
4194
4195@item
4196Prefer initialization to assignment in constructors.
4197
4198@item
4199Have @code{operator=} return a reference to @code{*this}.
4200
4201@item
4202Don't try to return a reference when you must return an object.
4203
4204@item
4205Distinguish between prefix and postfix forms of increment and
4206decrement operators.
4207
4208@item
4209Never overload @code{&&}, @code{||}, or @code{,}.
4210
4211@end itemize
4212
4213This option also enables @option{-Wnon-virtual-dtor}, which is also
4214one of the effective C++ recommendations. However, the check is
4215extended to warn about the lack of virtual destructor in accessible
4216non-polymorphic bases classes too.
4217
4218When selecting this option, be aware that the standard library
4219headers do not obey all of these guidelines; use @samp{grep -v}
4220to filter out those warnings.
4221
4222@item -Wno-exceptions @r{(C++ and Objective-C++ only)}
4223@opindex Wexceptions
4224@opindex Wno-exceptions
4225Disable the warning about the case when an exception handler is shadowed by
4226another handler, which can point out a wrong ordering of exception handlers.
4227
4228@item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
4229@opindex Wstrict-null-sentinel
4230@opindex Wno-strict-null-sentinel
4231Warn about the use of an uncasted @code{NULL} as sentinel. When
4232compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
4233to @code{__null}. Although it is a null pointer constant rather than a
4234null pointer, it is guaranteed to be of the same size as a pointer.
4235But this use is not portable across different compilers.
4236
4237@item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
4238@opindex Wno-non-template-friend
4239@opindex Wnon-template-friend
4240Disable warnings when non-template friend functions are declared
4241within a template. In very old versions of GCC that predate implementation
4242of the ISO standard, declarations such as
4243@samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
4244could be interpreted as a particular specialization of a template
4245function; the warning exists to diagnose compatibility problems,
4246and is enabled by default.
4247
4248@item -Wold-style-cast @r{(C++ and Objective-C++ only)}
4249@opindex Wold-style-cast
4250@opindex Wno-old-style-cast
4251Warn if an old-style (C-style) cast to a non-void type is used within
4252a C++ program. The new-style casts (@code{dynamic_cast},
4253@code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4254less vulnerable to unintended effects and much easier to search for.
4255
4256@item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4257@itemx -Woverloaded-virtual=@var{n}
4258@opindex Woverloaded-virtual
4259@opindex Wno-overloaded-virtual
4260@cindex overloaded virtual function, warning
4261@cindex warning for overloaded virtual function
4262Warn when a function declaration hides virtual functions from a
4263base class. For example, in:
4264
4265@smallexample
4266struct A @{
4267 virtual void f();
4268@};
4269
4270struct B: public A @{
4271 void f(int); // does not override
4272@};
4273@end smallexample
4274
4275the @code{A} class version of @code{f} is hidden in @code{B}, and code
4276like:
4277
4278@smallexample
4279B* b;
4280b->f();
4281@end smallexample
4282
4283@noindent
4284fails to compile.
4285
d82490d5
JW
4286In cases where the different signatures are not an accident, the
4287simplest solution is to add a using-declaration to the derived class
4288to un-hide the base function, e.g. add @code{using A::f;} to @code{B}.
4289
d77de738
ML
4290The optional level suffix controls the behavior when all the
4291declarations in the derived class override virtual functions in the
4292base class, even if not all of the base functions are overridden:
4293
4294@smallexample
4295struct C @{
4296 virtual void f();
4297 virtual void f(int);
4298@};
4299
4300struct D: public C @{
4301 void f(int); // does override
4302@}
4303@end smallexample
4304
4305This pattern is less likely to be a mistake; if D is only used
4306virtually, the user might have decided that the base class semantics
4307for some of the overloads are fine.
4308
4309At level 1, this case does not warn; at level 2, it does.
4310@option{-Woverloaded-virtual} by itself selects level 2. Level 1 is
4311included in @option{-Wall}.
4312
4313@item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
4314@opindex Wno-pmf-conversions
4315@opindex Wpmf-conversions
4316Disable the diagnostic for converting a bound pointer to member function
4317to a plain pointer.
4318
4319@item -Wsign-promo @r{(C++ and Objective-C++ only)}
4320@opindex Wsign-promo
4321@opindex Wno-sign-promo
4322Warn when overload resolution chooses a promotion from unsigned or
4323enumerated type to a signed type, over a conversion to an unsigned type of
4324the same size. Previous versions of G++ tried to preserve
4325unsignedness, but the standard mandates the current behavior.
4326
4327@item -Wtemplates @r{(C++ and Objective-C++ only)}
4328@opindex Wtemplates
4329@opindex Wno-templates
4330Warn when a primary template declaration is encountered. Some coding
4331rules disallow templates, and this may be used to enforce that rule.
4332The warning is inactive inside a system header file, such as the STL, so
4333one can still use the STL. One may also instantiate or specialize
4334templates.
4335
4336@item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
4337@opindex Wmismatched-new-delete
4338@opindex Wno-mismatched-new-delete
4339Warn for mismatches between calls to @code{operator new} or @code{operator
4340delete} and the corresponding call to the allocation or deallocation function.
4341This includes invocations of C++ @code{operator delete} with pointers
4342returned from either mismatched forms of @code{operator new}, or from other
4343functions that allocate objects for which the @code{operator delete} isn't
4344a suitable deallocator, as well as calls to other deallocation functions
4345with pointers returned from @code{operator new} for which the deallocation
4346function isn't suitable.
4347
4348For example, the @code{delete} expression in the function below is diagnosed
4349because it doesn't match the array form of the @code{new} expression
4350the pointer argument was returned from. Similarly, the call to @code{free}
4351is also diagnosed.
4352
4353@smallexample
4354void f ()
4355@{
4356 int *a = new int[n];
4357 delete a; // warning: mismatch in array forms of expressions
4358
4359 char *p = new char[n];
4360 free (p); // warning: mismatch between new and free
4361@}
4362@end smallexample
4363
4364The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4365involving allocation and deallocation functions other than @code{operator
4366new} and @code{operator delete}.
4367
4368@option{-Wmismatched-new-delete} is included in @option{-Wall}.
4369
4370@item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
4371@opindex Wmismatched-tags
4372@opindex Wno-mismatched-tags
4373Warn for declarations of structs, classes, and class templates and their
4374specializations with a class-key that does not match either the definition
4375or the first declaration if no definition is provided.
4376
4377For example, the declaration of @code{struct Object} in the argument list
4378of @code{draw} triggers the warning. To avoid it, either remove the redundant
4379class-key @code{struct} or replace it with @code{class} to match its definition.
4380@smallexample
4381class Object @{
4382public:
4383 virtual ~Object () = 0;
4384@};
4385void draw (struct Object*);
4386@end smallexample
4387
4388It is not wrong to declare a class with the class-key @code{struct} as
4389the example above shows. The @option{-Wmismatched-tags} option is intended
4390to help achieve a consistent style of class declarations. In code that is
4391intended to be portable to Windows-based compilers the warning helps prevent
4392unresolved references due to the difference in the mangling of symbols
4393declared with different class-keys. The option can be used either on its
4394own or in conjunction with @option{-Wredundant-tags}.
4395
4396@item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
4397@opindex Wmultiple-inheritance
4398@opindex Wno-multiple-inheritance
4399Warn when a class is defined with multiple direct base classes. Some
4400coding rules disallow multiple inheritance, and this may be used to
4401enforce that rule. The warning is inactive inside a system header file,
4402such as the STL, so one can still use the STL. One may also define
4403classes that indirectly use multiple inheritance.
4404
4405@item -Wvirtual-inheritance
4406@opindex Wvirtual-inheritance
4407@opindex Wno-virtual-inheritance
4408Warn when a class is defined with a virtual direct base class. Some
4409coding rules disallow multiple inheritance, and this may be used to
4410enforce that rule. The warning is inactive inside a system header file,
4411such as the STL, so one can still use the STL. One may also define
4412classes that indirectly use virtual inheritance.
4413
4414@item -Wno-virtual-move-assign
4415@opindex Wvirtual-move-assign
4416@opindex Wno-virtual-move-assign
4417Suppress warnings about inheriting from a virtual base with a
4418non-trivial C++11 move assignment operator. This is dangerous because
4419if the virtual base is reachable along more than one path, it is
4420moved multiple times, which can mean both objects end up in the
4421moved-from state. If the move assignment operator is written to avoid
4422moving from a moved-from object, this warning can be disabled.
4423
4424@item -Wnamespaces
4425@opindex Wnamespaces
4426@opindex Wno-namespaces
4427Warn when a namespace definition is opened. Some coding rules disallow
4428namespaces, and this may be used to enforce that rule. The warning is
4429inactive inside a system header file, such as the STL, so one can still
4430use the STL. One may also use using directives and qualified names.
4431
4432@item -Wno-terminate @r{(C++ and Objective-C++ only)}
4433@opindex Wterminate
4434@opindex Wno-terminate
4435Disable the warning about a throw-expression that will immediately
4436result in a call to @code{terminate}.
4437
4438@item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
4439@opindex Wvexing-parse
4440@opindex Wno-vexing-parse
4441Warn about the most vexing parse syntactic ambiguity. This warns about
4442the cases when a declaration looks like a variable definition, but the
4443C++ language requires it to be interpreted as a function declaration.
4444For instance:
4445
4446@smallexample
4447void f(double a) @{
4448 int i(); // extern int i (void);
4449 int n(int(a)); // extern int n (int);
4450@}
4451@end smallexample
4452
4453Another example:
4454
4455@smallexample
4456struct S @{ S(int); @};
4457void f(double a) @{
4458 S x(int(a)); // extern struct S x (int);
4459 S y(int()); // extern struct S y (int (*) (void));
4460 S z(); // extern struct S z (void);
4461@}
4462@end smallexample
4463
4464The warning will suggest options how to deal with such an ambiguity; e.g.,
4465it can suggest removing the parentheses or using braces instead.
4466
4467This warning is enabled by default.
4468
4469@item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
4470@opindex Wno-class-conversion
4471@opindex Wclass-conversion
4472Do not warn when a conversion function converts an
4473object to the same type, to a base class of that type, or to void; such
4474a conversion function will never be called.
4475
4476@item -Wvolatile @r{(C++ and Objective-C++ only)}
4477@opindex Wvolatile
4478@opindex Wno-volatile
4479Warn about deprecated uses of the @code{volatile} qualifier. This includes
4480postfix and prefix @code{++} and @code{--} expressions of
4481@code{volatile}-qualified types, using simple assignments where the left
4482operand is a @code{volatile}-qualified non-class type for their value,
4483compound assignments where the left operand is a @code{volatile}-qualified
4484non-class type, @code{volatile}-qualified function return type,
4485@code{volatile}-qualified parameter type, and structured bindings of a
4486@code{volatile}-qualified type. This usage was deprecated in C++20.
4487
4488Enabled by default with @option{-std=c++20}.
4489
4490@item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)}
4491@opindex Wzero-as-null-pointer-constant
4492@opindex Wno-zero-as-null-pointer-constant
4493Warn when a literal @samp{0} is used as null pointer constant. This can
4494be useful to facilitate the conversion to @code{nullptr} in C++11.
4495
4496@item -Waligned-new
4497@opindex Waligned-new
4498@opindex Wno-aligned-new
4499Warn about a new-expression of a type that requires greater alignment
4500than the @code{alignof(std::max_align_t)} but uses an allocation
4501function without an explicit alignment parameter. This option is
4502enabled by @option{-Wall}.
4503
4504Normally this only warns about global allocation functions, but
4505@option{-Waligned-new=all} also warns about class member allocation
4506functions.
4507
4508@item -Wno-placement-new
4509@itemx -Wplacement-new=@var{n}
4510@opindex Wplacement-new
4511@opindex Wno-placement-new
4512Warn about placement new expressions with undefined behavior, such as
4513constructing an object in a buffer that is smaller than the type of
4514the object. For example, the placement new expression below is diagnosed
4515because it attempts to construct an array of 64 integers in a buffer only
451664 bytes large.
4517@smallexample
4518char buf [64];
4519new (buf) int[64];
4520@end smallexample
4521This warning is enabled by default.
4522
4523@table @gcctabopt
4524@item -Wplacement-new=1
4525This is the default warning level of @option{-Wplacement-new}. At this
4526level the warning is not issued for some strictly undefined constructs that
4527GCC allows as extensions for compatibility with legacy code. For example,
4528the following @code{new} expression is not diagnosed at this level even
4529though it has undefined behavior according to the C++ standard because
4530it writes past the end of the one-element array.
4531@smallexample
4532struct S @{ int n, a[1]; @};
4533S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4534new (s->a)int [32]();
4535@end smallexample
4536
4537@item -Wplacement-new=2
4538At this level, in addition to diagnosing all the same constructs as at level
45391, a diagnostic is also issued for placement new expressions that construct
4540an object in the last member of structure whose type is an array of a single
4541element and whose size is less than the size of the object being constructed.
4542While the previous example would be diagnosed, the following construct makes
4543use of the flexible member array extension to avoid the warning at level 2.
4544@smallexample
4545struct S @{ int n, a[]; @};
4546S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4547new (s->a)int [32]();
4548@end smallexample
4549
4550@end table
4551
4552@item -Wcatch-value
4553@itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
4554@opindex Wcatch-value
4555@opindex Wno-catch-value
4556Warn about catch handlers that do not catch via reference.
4557With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4558warn about polymorphic class types that are caught by value.
4559With @option{-Wcatch-value=2} warn about all class types that are caught
4560by value. With @option{-Wcatch-value=3} warn about all types that are
4561not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4562
4563@item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
4564@opindex Wconditionally-supported
4565@opindex Wno-conditionally-supported
4566Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4567
4568@item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
4569@opindex Wdelete-incomplete
4570@opindex Wno-delete-incomplete
4571Do not warn when deleting a pointer to incomplete type, which may cause
4572undefined behavior at runtime. This warning is enabled by default.
4573
4574@item -Wextra-semi @r{(C++, Objective-C++ only)}
4575@opindex Wextra-semi
4576@opindex Wno-extra-semi
4577Warn about redundant semicolons after in-class function definitions.
4578
4579@item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
4580@opindex Winaccessible-base
4581@opindex Wno-inaccessible-base
4582This option controls warnings
4583when a base class is inaccessible in a class derived from it due to
4584ambiguity. The warning is enabled by default.
4585Note that the warning for ambiguous virtual
4586bases is enabled by the @option{-Wextra} option.
4587@smallexample
4588@group
4589struct A @{ int a; @};
4590
4591struct B : A @{ @};
4592
4593struct C : B, A @{ @};
4594@end group
4595@end smallexample
4596
4597@item -Wno-inherited-variadic-ctor
4598@opindex Winherited-variadic-ctor
4599@opindex Wno-inherited-variadic-ctor
4600Suppress warnings about use of C++11 inheriting constructors when the
4601base class inherited from has a C variadic constructor; the warning is
4602on by default because the ellipsis is not inherited.
4603
4604@item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
4605@opindex Wno-invalid-offsetof
4606@opindex Winvalid-offsetof
4607Suppress warnings from applying the @code{offsetof} macro to a non-POD
4608type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4609to a non-standard-layout type is undefined. In existing C++ implementations,
4610however, @code{offsetof} typically gives meaningful results.
4611This flag is for users who are aware that they are
4612writing nonportable code and who have deliberately chosen to ignore the
4613warning about it.
4614
4615The restrictions on @code{offsetof} may be relaxed in a future version
4616of the C++ standard.
4617
4618@item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
4619@opindex Wsized-deallocation
4620@opindex Wno-sized-deallocation
4621Warn about a definition of an unsized deallocation function
4622@smallexample
4623void operator delete (void *) noexcept;
4624void operator delete[] (void *) noexcept;
4625@end smallexample
4626without a definition of the corresponding sized deallocation function
4627@smallexample
4628void operator delete (void *, std::size_t) noexcept;
4629void operator delete[] (void *, std::size_t) noexcept;
4630@end smallexample
4631or vice versa. Enabled by @option{-Wextra} along with
4632@option{-fsized-deallocation}.
4633
4634@item -Wsuggest-final-types
4635@opindex Wno-suggest-final-types
4636@opindex Wsuggest-final-types
4637Warn about types with virtual methods where code quality would be improved
4638if the type were declared with the C++11 @code{final} specifier,
4639or, if possible,
4640declared in an anonymous namespace. This allows GCC to more aggressively
4641devirtualize the polymorphic calls. This warning is more effective with
4642link-time optimization,
4643where the information about the class hierarchy graph is
4644more complete.
4645
4646@item -Wsuggest-final-methods
4647@opindex Wno-suggest-final-methods
4648@opindex Wsuggest-final-methods
4649Warn about virtual methods where code quality would be improved if the method
4650were declared with the C++11 @code{final} specifier,
4651or, if possible, its type were
4652declared in an anonymous namespace or with the @code{final} specifier.
4653This warning is
4654more effective with link-time optimization, where the information about the
4655class hierarchy graph is more complete. It is recommended to first consider
4656suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4657annotations.
4658
4659@item -Wsuggest-override
4660@opindex Wsuggest-override
4661@opindex Wno-suggest-override
4662Warn about overriding virtual functions that are not marked with the
4663@code{override} keyword.
4664
4665@item -Wuse-after-free
4666@itemx -Wuse-after-free=@var{n}
4667@opindex Wuse-after-free
4668@opindex Wno-use-after-free
4669Warn about uses of pointers to dynamically allocated objects that have
4670been rendered indeterminate by a call to a deallocation function.
4671The warning is enabled at all optimization levels but may yield different
4672results with optimization than without.
4673
4674@table @gcctabopt
4675@item -Wuse-after-free=1
4676At level 1 the warning attempts to diagnose only unconditional uses
4677of pointers made indeterminate by a deallocation call or a successful
4678call to @code{realloc}, regardless of whether or not the call resulted
4679in an actual reallocatio of memory. This includes double-@code{free}
4680calls as well as uses in arithmetic and relational expressions. Although
4681undefined, uses of indeterminate pointers in equality (or inequality)
4682expressions are not diagnosed at this level.
4683@item -Wuse-after-free=2
4684At level 2, in addition to unconditional uses, the warning also diagnoses
4685conditional uses of pointers made indeterminate by a deallocation call.
4686As at level 2, uses in equality (or inequality) expressions are not
4687diagnosed. For example, the second call to @code{free} in the following
4688function is diagnosed at this level:
4689@smallexample
4690struct A @{ int refcount; void *data; @};
4691
4692void release (struct A *p)
4693@{
4694 int refcount = --p->refcount;
4695 free (p);
4696 if (refcount == 0)
4697 free (p->data); // warning: p may be used after free
4698@}
4699@end smallexample
4700@item -Wuse-after-free=3
4701At level 3, the warning also diagnoses uses of indeterminate pointers in
4702equality expressions. All uses of indeterminate pointers are undefined
4703but equality tests sometimes appear after calls to @code{realloc} as
4704an attempt to determine whether the call resulted in relocating the object
4705to a different address. They are diagnosed at a separate level to aid
4706legacy code gradually transition to safe alternatives. For example,
4707the equality test in the function below is diagnosed at this level:
4708@smallexample
4709void adjust_pointers (int**, int);
4710
4711void grow (int **p, int n)
4712@{
4713 int **q = (int**)realloc (p, n *= 2);
4714 if (q == p)
4715 return;
4716 adjust_pointers ((int**)q, n);
4717@}
4718@end smallexample
4719To avoid the warning at this level, store offsets into allocated memory
4720instead of pointers. This approach obviates needing to adjust the stored
4721pointers after reallocation.
4722@end table
4723
4724@option{-Wuse-after-free=2} is included in @option{-Wall}.
4725
4726@item -Wuseless-cast @r{(C++ and Objective-C++ only)}
4727@opindex Wuseless-cast
4728@opindex Wno-useless-cast
4729Warn when an expression is cast to its own type. This warning does not
4730occur when a class object is converted to a non-reference type as that
4731is a way to create a temporary:
4732
4733@smallexample
4734struct S @{ @};
4735void g (S&&);
4736void f (S&& arg)
4737@{
4738 g (S(arg)); // make arg prvalue so that it can bind to S&&
4739@}
4740@end smallexample
4741
4742@item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
4743@opindex Wconversion-null
4744@opindex Wno-conversion-null
4745Do not warn for conversions between @code{NULL} and non-pointer
4746types. @option{-Wconversion-null} is enabled by default.
4747
4748@end table
4749
4750@node Objective-C and Objective-C++ Dialect Options
4751@section Options Controlling Objective-C and Objective-C++ Dialects
4752
4753@cindex compiler options, Objective-C and Objective-C++
4754@cindex Objective-C and Objective-C++ options, command-line
4755@cindex options, Objective-C and Objective-C++
4756(NOTE: This manual does not describe the Objective-C and Objective-C++
4757languages themselves. @xref{Standards,,Language Standards
4758Supported by GCC}, for references.)
4759
4760This section describes the command-line options that are only meaningful
4761for Objective-C and Objective-C++ programs. You can also use most of
4762the language-independent GNU compiler options.
4763For example, you might compile a file @file{some_class.m} like this:
4764
4765@smallexample
4766gcc -g -fgnu-runtime -O -c some_class.m
4767@end smallexample
4768
4769@noindent
4770In this example, @option{-fgnu-runtime} is an option meant only for
4771Objective-C and Objective-C++ programs; you can use the other options with
4772any language supported by GCC@.
4773
4774Note that since Objective-C is an extension of the C language, Objective-C
4775compilations may also use options specific to the C front-end (e.g.,
4776@option{-Wtraditional}). Similarly, Objective-C++ compilations may use
4777C++-specific options (e.g., @option{-Wabi}).
4778
4779Here is a list of options that are @emph{only} for compiling Objective-C
4780and Objective-C++ programs:
4781
4782@table @gcctabopt
4783@item -fconstant-string-class=@var{class-name}
4784@opindex fconstant-string-class
4785Use @var{class-name} as the name of the class to instantiate for each
4786literal string specified with the syntax @code{@@"@dots{}"}. The default
4787class name is @code{NXConstantString} if the GNU runtime is being used, and
4788@code{NSConstantString} if the NeXT runtime is being used (see below). The
4789@option{-fconstant-cfstrings} option, if also present, overrides the
4790@option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals
4791to be laid out as constant CoreFoundation strings.
4792
4793@item -fgnu-runtime
4794@opindex fgnu-runtime
4795Generate object code compatible with the standard GNU Objective-C
4796runtime. This is the default for most types of systems.
4797
4798@item -fnext-runtime
4799@opindex fnext-runtime
4800Generate output compatible with the NeXT runtime. This is the default
4801for NeXT-based systems, including Darwin and Mac OS X@. The macro
4802@code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
4803used.
4804
4805@item -fno-nil-receivers
4806@opindex fno-nil-receivers
4807@opindex fnil-receivers
4808Assume that all Objective-C message dispatches (@code{[receiver
4809message:arg]}) in this translation unit ensure that the receiver is
4810not @code{nil}. This allows for more efficient entry points in the
4811runtime to be used. This option is only available in conjunction with
4812the NeXT runtime and ABI version 0 or 1.
4813
4814@item -fobjc-abi-version=@var{n}
4815@opindex fobjc-abi-version
4816Use version @var{n} of the Objective-C ABI for the selected runtime.
4817This option is currently supported only for the NeXT runtime. In that
4818case, Version 0 is the traditional (32-bit) ABI without support for
4819properties and other Objective-C 2.0 additions. Version 1 is the
4820traditional (32-bit) ABI with support for properties and other
4821Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
4822nothing is specified, the default is Version 0 on 32-bit target
4823machines, and Version 2 on 64-bit target machines.
4824
4825@item -fobjc-call-cxx-cdtors
4826@opindex fobjc-call-cxx-cdtors
4827For each Objective-C class, check if any of its instance variables is a
4828C++ object with a non-trivial default constructor. If so, synthesize a
4829special @code{- (id) .cxx_construct} instance method which runs
4830non-trivial default constructors on any such instance variables, in order,
4831and then return @code{self}. Similarly, check if any instance variable
4832is a C++ object with a non-trivial destructor, and if so, synthesize a
4833special @code{- (void) .cxx_destruct} method which runs
4834all such default destructors, in reverse order.
4835
4836The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
4837methods thusly generated only operate on instance variables
4838declared in the current Objective-C class, and not those inherited
4839from superclasses. It is the responsibility of the Objective-C
4840runtime to invoke all such methods in an object's inheritance
4841hierarchy. The @code{- (id) .cxx_construct} methods are invoked
4842by the runtime immediately after a new object instance is allocated;
4843the @code{- (void) .cxx_destruct} methods are invoked immediately
4844before the runtime deallocates an object instance.
4845
4846As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
4847support for invoking the @code{- (id) .cxx_construct} and
4848@code{- (void) .cxx_destruct} methods.
4849
4850@item -fobjc-direct-dispatch
4851@opindex fobjc-direct-dispatch
4852Allow fast jumps to the message dispatcher. On Darwin this is
4853accomplished via the comm page.
4854
4855@item -fobjc-exceptions
4856@opindex fobjc-exceptions
4857Enable syntactic support for structured exception handling in
4858Objective-C, similar to what is offered by C++. This option
4859is required to use the Objective-C keywords @code{@@try},
4860@code{@@throw}, @code{@@catch}, @code{@@finally} and
4861@code{@@synchronized}. This option is available with both the GNU
4862runtime and the NeXT runtime (but not available in conjunction with
4863the NeXT runtime on Mac OS X 10.2 and earlier).
4864
4865@item -fobjc-gc
4866@opindex fobjc-gc
4867Enable garbage collection (GC) in Objective-C and Objective-C++
4868programs. This option is only available with the NeXT runtime; the
4869GNU runtime has a different garbage collection implementation that
4870does not require special compiler flags.
4871
4872@item -fobjc-nilcheck
4873@opindex fobjc-nilcheck
4874For the NeXT runtime with version 2 of the ABI, check for a nil
4875receiver in method invocations before doing the actual method call.
4876This is the default and can be disabled using
4877@option{-fno-objc-nilcheck}. Class methods and super calls are never
4878checked for nil in this way no matter what this flag is set to.
4879Currently this flag does nothing when the GNU runtime, or an older
4880version of the NeXT runtime ABI, is used.
4881
4882@item -fobjc-std=objc1
4883@opindex fobjc-std
4884Conform to the language syntax of Objective-C 1.0, the language
4885recognized by GCC 4.0. This only affects the Objective-C additions to
4886the C/C++ language; it does not affect conformance to C/C++ standards,
4887which is controlled by the separate C/C++ dialect option flags. When
4888this option is used with the Objective-C or Objective-C++ compiler,
4889any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
4890This is useful if you need to make sure that your Objective-C code can
4891be compiled with older versions of GCC@.
4892
4893@item -freplace-objc-classes
4894@opindex freplace-objc-classes
4895Emit a special marker instructing @command{ld(1)} not to statically link in
4896the resulting object file, and allow @command{dyld(1)} to load it in at
4897run time instead. This is used in conjunction with the Fix-and-Continue
4898debugging mode, where the object file in question may be recompiled and
4899dynamically reloaded in the course of program execution, without the need
4900to restart the program itself. Currently, Fix-and-Continue functionality
4901is only available in conjunction with the NeXT runtime on Mac OS X 10.3
4902and later.
4903
4904@item -fzero-link
4905@opindex fzero-link
4906When compiling for the NeXT runtime, the compiler ordinarily replaces calls
4907to @code{objc_getClass("@dots{}")} (when the name of the class is known at
4908compile time) with static class references that get initialized at load time,
4909which improves run-time performance. Specifying the @option{-fzero-link} flag
4910suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
4911to be retained. This is useful in Zero-Link debugging mode, since it allows
4912for individual class implementations to be modified during program execution.
4913The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
4914regardless of command-line options.
4915
4916@item -fno-local-ivars
4917@opindex fno-local-ivars
4918@opindex flocal-ivars
4919By default instance variables in Objective-C can be accessed as if
4920they were local variables from within the methods of the class they're
4921declared in. This can lead to shadowing between instance variables
4922and other variables declared either locally inside a class method or
4923globally with the same name. Specifying the @option{-fno-local-ivars}
4924flag disables this behavior thus avoiding variable shadowing issues.
4925
4926@item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
4927@opindex fivar-visibility
4928Set the default instance variable visibility to the specified option
4929so that instance variables declared outside the scope of any access
4930modifier directives default to the specified visibility.
4931
4932@item -gen-decls
4933@opindex gen-decls
4934Dump interface declarations for all classes seen in the source file to a
4935file named @file{@var{sourcename}.decl}.
4936
4937@item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
4938@opindex Wassign-intercept
4939@opindex Wno-assign-intercept
4940Warn whenever an Objective-C assignment is being intercepted by the
4941garbage collector.
4942
4943@item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
4944@opindex Wproperty-assign-default
4945@opindex Wno-property-assign-default
4946Do not warn if a property for an Objective-C object has no assign
4947semantics specified.
4948
4949@item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
4950@opindex Wno-protocol
4951@opindex Wprotocol
4952If a class is declared to implement a protocol, a warning is issued for
4953every method in the protocol that is not implemented by the class. The
4954default behavior is to issue a warning for every method not explicitly
4955implemented in the class, even if a method implementation is inherited
4956from the superclass. If you use the @option{-Wno-protocol} option, then
4957methods inherited from the superclass are considered to be implemented,
4958and no warning is issued for them.
4959
4960@item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
4961@opindex Wobjc-root-class
4962Warn if a class interface lacks a superclass. Most classes will inherit
4963from @code{NSObject} (or @code{Object}) for example. When declaring
4964classes intended to be root classes, the warning can be suppressed by
4965marking their interfaces with @code{__attribute__((objc_root_class))}.
4966
4967@item -Wselector @r{(Objective-C and Objective-C++ only)}
4968@opindex Wselector
4969@opindex Wno-selector
4970Warn if multiple methods of different types for the same selector are
4971found during compilation. The check is performed on the list of methods
4972in the final stage of compilation. Additionally, a check is performed
4973for each selector appearing in a @code{@@selector(@dots{})}
4974expression, and a corresponding method for that selector has been found
4975during compilation. Because these checks scan the method table only at
4976the end of compilation, these warnings are not produced if the final
4977stage of compilation is not reached, for example because an error is
4978found during compilation, or because the @option{-fsyntax-only} option is
4979being used.
4980
4981@item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
4982@opindex Wstrict-selector-match
4983@opindex Wno-strict-selector-match
4984Warn if multiple methods with differing argument and/or return types are
4985found for a given selector when attempting to send a message using this
4986selector to a receiver of type @code{id} or @code{Class}. When this flag
4987is off (which is the default behavior), the compiler omits such warnings
4988if any differences found are confined to types that share the same size
4989and alignment.
4990
4991@item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
4992@opindex Wundeclared-selector
4993@opindex Wno-undeclared-selector
4994Warn if a @code{@@selector(@dots{})} expression referring to an
4995undeclared selector is found. A selector is considered undeclared if no
4996method with that name has been declared before the
4997@code{@@selector(@dots{})} expression, either explicitly in an
4998@code{@@interface} or @code{@@protocol} declaration, or implicitly in
4999an @code{@@implementation} section. This option always performs its
5000checks as soon as a @code{@@selector(@dots{})} expression is found,
5001while @option{-Wselector} only performs its checks in the final stage of
5002compilation. This also enforces the coding style convention
5003that methods and selectors must be declared before being used.
5004
5005@item -print-objc-runtime-info
5006@opindex print-objc-runtime-info
5007Generate C header describing the largest structure that is passed by
5008value, if any.
5009
5010@end table
5011
5012@node Diagnostic Message Formatting Options
5013@section Options to Control Diagnostic Messages Formatting
5014@cindex options to control diagnostics formatting
5015@cindex diagnostic messages
5016@cindex message formatting
5017
5018Traditionally, diagnostic messages have been formatted irrespective of
5019the output device's aspect (e.g.@: its width, @dots{}). You can use the
5020options described below
5021to control the formatting algorithm for diagnostic messages,
5022e.g.@: how many characters per line, how often source location
5023information should be reported. Note that some language front ends may not
5024honor these options.
5025
5026@table @gcctabopt
5027@item -fmessage-length=@var{n}
5028@opindex fmessage-length
5029Try to format error messages so that they fit on lines of about
5030@var{n} characters. If @var{n} is zero, then no line-wrapping is
5031done; each error message appears on a single line. This is the
5032default for all front ends.
5033
5034Note - this option also affects the display of the @samp{#error} and
5035@samp{#warning} pre-processor directives, and the @samp{deprecated}
5036function/type/variable attribute. It does not however affect the
5037@samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
5038
5039@item -fdiagnostics-plain-output
5040This option requests that diagnostic output look as plain as possible, which
5041may be useful when running @command{dejagnu} or other utilities that need to
5042parse diagnostics output and prefer that it remain more stable over time.
5043@option{-fdiagnostics-plain-output} is currently equivalent to the following
5044options:
5045@gccoptlist{-fno-diagnostics-show-caret @gol
5046-fno-diagnostics-show-line-numbers @gol
5047-fdiagnostics-color=never @gol
5048-fdiagnostics-urls=never @gol
5049-fdiagnostics-path-format=separate-events}
5050In the future, if GCC changes the default appearance of its diagnostics, the
5051corresponding option to disable the new behavior will be added to this list.
5052
5053@item -fdiagnostics-show-location=once
5054@opindex fdiagnostics-show-location
5055Only meaningful in line-wrapping mode. Instructs the diagnostic messages
5056reporter to emit source location information @emph{once}; that is, in
5057case the message is too long to fit on a single physical line and has to
5058be wrapped, the source location won't be emitted (as prefix) again,
5059over and over, in subsequent continuation lines. This is the default
5060behavior.
5061
5062@item -fdiagnostics-show-location=every-line
5063Only meaningful in line-wrapping mode. Instructs the diagnostic
5064messages reporter to emit the same source location information (as
5065prefix) for physical lines that result from the process of breaking
5066a message which is too long to fit on a single line.
5067
5068@item -fdiagnostics-color[=@var{WHEN}]
5069@itemx -fno-diagnostics-color
5070@opindex fdiagnostics-color
5071@cindex highlight, color
5072@vindex GCC_COLORS @r{environment variable}
5073Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
5074or @samp{auto}. The default depends on how the compiler has been configured,
5075it can be any of the above @var{WHEN} options or also @samp{never}
5076if @env{GCC_COLORS} environment variable isn't present in the environment,
5077and @samp{auto} otherwise.
5078@samp{auto} makes GCC use color only when the standard error is a terminal,
5079and when not executing in an emacs shell.
5080The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
5081aliases for @option{-fdiagnostics-color=always} and
5082@option{-fdiagnostics-color=never}, respectively.
5083
5084The colors are defined by the environment variable @env{GCC_COLORS}.
5085Its value is a colon-separated list of capabilities and Select Graphic
5086Rendition (SGR) substrings. SGR commands are interpreted by the
5087terminal or terminal emulator. (See the section in the documentation
5088of your text terminal for permitted values and their meanings as
5089character attributes.) These substring values are integers in decimal
5090representation and can be concatenated with semicolons.
5091Common values to concatenate include
5092@samp{1} for bold,
5093@samp{4} for underline,
5094@samp{5} for blink,
5095@samp{7} for inverse,
5096@samp{39} for default foreground color,
5097@samp{30} to @samp{37} for foreground colors,
5098@samp{90} to @samp{97} for 16-color mode foreground colors,
5099@samp{38;5;0} to @samp{38;5;255}
5100for 88-color and 256-color modes foreground colors,
5101@samp{49} for default background color,
5102@samp{40} to @samp{47} for background colors,
5103@samp{100} to @samp{107} for 16-color mode background colors,
5104and @samp{48;5;0} to @samp{48;5;255}
5105for 88-color and 256-color modes background colors.
5106
5107The default @env{GCC_COLORS} is
5108@smallexample
5109error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
5110quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
5111diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
5112type-diff=01;32:fnname=01;32:targs=35
5113@end smallexample
5114@noindent
5115where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
5116@samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
5117@samp{01} is bold, and @samp{31} is red.
5118Setting @env{GCC_COLORS} to the empty string disables colors.
5119Supported capabilities are as follows.
5120
5121@table @code
5122@item error=
5123@vindex error GCC_COLORS @r{capability}
5124SGR substring for error: markers.
5125
5126@item warning=
5127@vindex warning GCC_COLORS @r{capability}
5128SGR substring for warning: markers.
5129
5130@item note=
5131@vindex note GCC_COLORS @r{capability}
5132SGR substring for note: markers.
5133
5134@item path=
5135@vindex path GCC_COLORS @r{capability}
5136SGR substring for colorizing paths of control-flow events as printed
5137via @option{-fdiagnostics-path-format=}, such as the identifiers of
5138individual events and lines indicating interprocedural calls and returns.
5139
5140@item range1=
5141@vindex range1 GCC_COLORS @r{capability}
5142SGR substring for first additional range.
5143
5144@item range2=
5145@vindex range2 GCC_COLORS @r{capability}
5146SGR substring for second additional range.
5147
5148@item locus=
5149@vindex locus GCC_COLORS @r{capability}
5150SGR substring for location information, @samp{file:line} or
5151@samp{file:line:column} etc.
5152
5153@item quote=
5154@vindex quote GCC_COLORS @r{capability}
5155SGR substring for information printed within quotes.
5156
5157@item fnname=
5158@vindex fnname GCC_COLORS @r{capability}
5159SGR substring for names of C++ functions.
5160
5161@item targs=
5162@vindex targs GCC_COLORS @r{capability}
5163SGR substring for C++ function template parameter bindings.
5164
5165@item fixit-insert=
5166@vindex fixit-insert GCC_COLORS @r{capability}
5167SGR substring for fix-it hints suggesting text to
5168be inserted or replaced.
5169
5170@item fixit-delete=
5171@vindex fixit-delete GCC_COLORS @r{capability}
5172SGR substring for fix-it hints suggesting text to
5173be deleted.
5174
5175@item diff-filename=
5176@vindex diff-filename GCC_COLORS @r{capability}
5177SGR substring for filename headers within generated patches.
5178
5179@item diff-hunk=
5180@vindex diff-hunk GCC_COLORS @r{capability}
5181SGR substring for the starts of hunks within generated patches.
5182
5183@item diff-delete=
5184@vindex diff-delete GCC_COLORS @r{capability}
5185SGR substring for deleted lines within generated patches.
5186
5187@item diff-insert=
5188@vindex diff-insert GCC_COLORS @r{capability}
5189SGR substring for inserted lines within generated patches.
5190
5191@item type-diff=
5192@vindex type-diff GCC_COLORS @r{capability}
5193SGR substring for highlighting mismatching types within template
5194arguments in the C++ frontend.
5195@end table
5196
5197@item -fdiagnostics-urls[=@var{WHEN}]
5198@opindex fdiagnostics-urls
5199@cindex urls
5200@vindex GCC_URLS @r{environment variable}
5201@vindex TERM_URLS @r{environment variable}
5202Use escape sequences to embed URLs in diagnostics. For example, when
5203@option{-fdiagnostics-show-option} emits text showing the command-line
5204option controlling a diagnostic, embed a URL for documentation of that
5205option.
5206
5207@var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
5208@samp{auto} makes GCC use URL escape sequences only when the standard error
5209is a terminal, and when not executing in an emacs shell or any graphical
5210terminal which is known to be incompatible with this feature, see below.
5211
5212The default depends on how the compiler has been configured.
5213It can be any of the above @var{WHEN} options.
5214
5215GCC can also be configured (via the
5216@option{--with-diagnostics-urls=auto-if-env} configure-time option)
5217so that the default is affected by environment variables.
5218Under such a configuration, GCC defaults to using @samp{auto}
5219if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
5220present and non-empty in the environment of the compiler, or @samp{never}
5221if neither are.
5222
5223However, even with @option{-fdiagnostics-urls=always} the behavior is
5224dependent on those environment variables:
5225If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
5226diagnostics. If set to @samp{st}, URLs use ST escape sequences.
5227If set to @samp{bel}, the default, URLs use BEL escape sequences.
5228Any other non-empty value enables the feature.
5229If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
5230Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
5231BEL is an ASCII character, CTRL-G that usually sounds like a beep.
5232
5233At this time GCC tries to detect also a few terminals that are known to
5234not implement the URL feature, and have bugs or at least had bugs in
5235some versions that are still in use, where the URL escapes are likely
5236to misbehave, i.e. print garbage on the screen.
5237That list is currently xfce4-terminal, certain known to be buggy
5238gnome-terminal versions, the linux console, and mingw.
5239This check can be skipped with the @option{-fdiagnostics-urls=always}.
5240
5241@item -fno-diagnostics-show-option
5242@opindex fno-diagnostics-show-option
5243@opindex fdiagnostics-show-option
5244By default, each diagnostic emitted includes text indicating the
5245command-line option that directly controls the diagnostic (if such an
5246option is known to the diagnostic machinery). Specifying the
5247@option{-fno-diagnostics-show-option} flag suppresses that behavior.
5248
5249@item -fno-diagnostics-show-caret
5250@opindex fno-diagnostics-show-caret
5251@opindex fdiagnostics-show-caret
5252By default, each diagnostic emitted includes the original source line
5253and a caret @samp{^} indicating the column. This option suppresses this
5254information. The source line is truncated to @var{n} characters, if
5255the @option{-fmessage-length=n} option is given. When the output is done
5256to the terminal, the width is limited to the width given by the
5257@env{COLUMNS} environment variable or, if not set, to the terminal width.
5258
5259@item -fno-diagnostics-show-labels
5260@opindex fno-diagnostics-show-labels
5261@opindex fdiagnostics-show-labels
5262By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5263diagnostics can label ranges of source code with pertinent information, such
5264as the types of expressions:
5265
5266@smallexample
5267 printf ("foo %s bar", long_i + long_j);
5268 ~^ ~~~~~~~~~~~~~~~
5269 | |
5270 char * long int
5271@end smallexample
5272
5273This option suppresses the printing of these labels (in the example above,
5274the vertical bars and the ``char *'' and ``long int'' text).
5275
5276@item -fno-diagnostics-show-cwe
5277@opindex fno-diagnostics-show-cwe
5278@opindex fdiagnostics-show-cwe
5279Diagnostic messages can optionally have an associated
5280@uref{https://cwe.mitre.org/index.html, CWE} identifier.
5281GCC itself only provides such metadata for some of the @option{-fanalyzer}
5282diagnostics. GCC plugins may also provide diagnostics with such metadata.
5283By default, if this information is present, it will be printed with
5284the diagnostic. This option suppresses the printing of this metadata.
5285
5286@item -fno-diagnostics-show-rules
5287@opindex fno-diagnostics-show-rules
5288@opindex fdiagnostics-show-rules
5289Diagnostic messages can optionally have rules associated with them, such
5290as from a coding standard, or a specification.
5291GCC itself does not do this for any of its diagnostics, but plugins may do so.
5292By default, if this information is present, it will be printed with
5293the diagnostic. This option suppresses the printing of this metadata.
5294
5295@item -fno-diagnostics-show-line-numbers
5296@opindex fno-diagnostics-show-line-numbers
5297@opindex fdiagnostics-show-line-numbers
5298By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5299a left margin is printed, showing line numbers. This option suppresses this
5300left margin.
5301
5302@item -fdiagnostics-minimum-margin-width=@var{width}
5303@opindex fdiagnostics-minimum-margin-width
5304This option controls the minimum width of the left margin printed by
5305@option{-fdiagnostics-show-line-numbers}. It defaults to 6.
5306
5307@item -fdiagnostics-parseable-fixits
5308@opindex fdiagnostics-parseable-fixits
5309Emit fix-it hints in a machine-parseable format, suitable for consumption
5310by IDEs. For each fix-it, a line will be printed after the relevant
5311diagnostic, starting with the string ``fix-it:''. For example:
5312
5313@smallexample
5314fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
5315@end smallexample
5316
5317The location is expressed as a half-open range, expressed as a count of
5318bytes, starting at byte 1 for the initial column. In the above example,
5319bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
5320given string:
5321
5322@smallexample
532300000000011111111112222222222
532412345678901234567890123456789
5325 gtk_widget_showall (dlg);
5326 ^^^^^^^^^^^^^^^^^^
5327 gtk_widget_show_all
5328@end smallexample
5329
5330The filename and replacement string escape backslash as ``\\", tab as ``\t'',
5331newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
5332(e.g. vertical tab as ``\013'').
5333
5334An empty replacement string indicates that the given range is to be removed.
5335An empty range (e.g. ``45:3-45:3'') indicates that the string is to
5336be inserted at the given position.
5337
5338@item -fdiagnostics-generate-patch
5339@opindex fdiagnostics-generate-patch
5340Print fix-it hints to stderr in unified diff format, after any diagnostics
5341are printed. For example:
5342
5343@smallexample
5344--- test.c
5345+++ test.c
5346@@ -42,5 +42,5 @@
5347
5348 void show_cb(GtkDialog *dlg)
5349 @{
5350- gtk_widget_showall(dlg);
5351+ gtk_widget_show_all(dlg);
5352 @}
5353
5354@end smallexample
5355
5356The diff may or may not be colorized, following the same rules
5357as for diagnostics (see @option{-fdiagnostics-color}).
5358
5359@item -fdiagnostics-show-template-tree
5360@opindex fdiagnostics-show-template-tree
5361
5362In the C++ frontend, when printing diagnostics showing mismatching
5363template types, such as:
5364
5365@smallexample
5366 could not convert 'std::map<int, std::vector<double> >()'
5367 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5368@end smallexample
5369
5370the @option{-fdiagnostics-show-template-tree} flag enables printing a
5371tree-like structure showing the common and differing parts of the types,
5372such as:
5373
5374@smallexample
5375 map<
5376 [...],
5377 vector<
5378 [double != float]>>
5379@end smallexample
5380
5381The parts that differ are highlighted with color (``double'' and
5382``float'' in this case).
5383
5384@item -fno-elide-type
5385@opindex fno-elide-type
5386@opindex felide-type
5387By default when the C++ frontend prints diagnostics showing mismatching
5388template types, common parts of the types are printed as ``[...]'' to
5389simplify the error message. For example:
5390
5391@smallexample
5392 could not convert 'std::map<int, std::vector<double> >()'
5393 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5394@end smallexample
5395
5396Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5397This flag also affects the output of the
5398@option{-fdiagnostics-show-template-tree} flag.
5399
5400@item -fdiagnostics-path-format=@var{KIND}
5401@opindex fdiagnostics-path-format
5402Specify how to print paths of control-flow events for diagnostics that
5403have such a path associated with them.
5404
5405@var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5406the default.
5407
5408@samp{none} means to not print diagnostic paths.
5409
5410@samp{separate-events} means to print a separate ``note'' diagnostic for
5411each event within the diagnostic. For example:
5412
5413@smallexample
5414test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5415test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5416test.c:27:3: note: (2) when 'i < count'
5417test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5418@end smallexample
5419
5420@samp{inline-events} means to print the events ``inline'' within the source
5421code. This view attempts to consolidate the events into runs of
5422sufficiently-close events, printing them as labelled ranges within the source.
5423
5424For example, the same events as above might be printed as:
5425
5426@smallexample
5427 'test': events 1-3
5428 |
5429 | 25 | list = PyList_New(0);
5430 | | ^~~~~~~~~~~~~
5431 | | |
5432 | | (1) when 'PyList_New' fails, returning NULL
5433 | 26 |
5434 | 27 | for (i = 0; i < count; i++) @{
5435 | | ~~~
5436 | | |
5437 | | (2) when 'i < count'
5438 | 28 | item = PyLong_FromLong(random());
5439 | 29 | PyList_Append(list, item);
5440 | | ~~~~~~~~~~~~~~~~~~~~~~~~~
5441 | | |
5442 | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5443 |
5444@end smallexample
5445
5446Interprocedural control flow is shown by grouping the events by stack frame,
5447and using indentation to show how stack frames are nested, pushed, and popped.
5448
5449For example:
5450
5451@smallexample
5452 'test': events 1-2
5453 |
5454 | 133 | @{
5455 | | ^
5456 | | |
5457 | | (1) entering 'test'
5458 | 134 | boxed_int *obj = make_boxed_int (i);
5459 | | ~~~~~~~~~~~~~~~~~~
5460 | | |
5461 | | (2) calling 'make_boxed_int'
5462 |
5463 +--> 'make_boxed_int': events 3-4
5464 |
5465 | 120 | @{
5466 | | ^
5467 | | |
5468 | | (3) entering 'make_boxed_int'
5469 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5470 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5471 | | |
5472 | | (4) calling 'wrapped_malloc'
5473 |
5474 +--> 'wrapped_malloc': events 5-6
5475 |
5476 | 7 | @{
5477 | | ^
5478 | | |
5479 | | (5) entering 'wrapped_malloc'
5480 | 8 | return malloc (size);
5481 | | ~~~~~~~~~~~~~
5482 | | |
5483 | | (6) calling 'malloc'
5484 |
5485 <-------------+
5486 |
5487 'test': event 7
5488 |
5489 | 138 | free_boxed_int (obj);
5490 | | ^~~~~~~~~~~~~~~~~~~~
5491 | | |
5492 | | (7) calling 'free_boxed_int'
5493 |
5494(etc)
5495@end smallexample
5496
5497@item -fdiagnostics-show-path-depths
5498@opindex fdiagnostics-show-path-depths
5499This option provides additional information when printing control-flow paths
5500associated with a diagnostic.
5501
5502If this is option is provided then the stack depth will be printed for
5503each run of events within @option{-fdiagnostics-path-format=inline-events}.
5504If provided with @option{-fdiagnostics-path-format=separate-events}, then
5505the stack depth and function declaration will be appended when printing
5506each event.
5507
5508This is intended for use by GCC developers and plugin developers when
5509debugging diagnostics that report interprocedural control flow.
5510
5511@item -fno-show-column
5512@opindex fno-show-column
5513@opindex fshow-column
5514Do not print column numbers in diagnostics. This may be necessary if
5515diagnostics are being scanned by a program that does not understand the
5516column numbers, such as @command{dejagnu}.
5517
5518@item -fdiagnostics-column-unit=@var{UNIT}
5519@opindex fdiagnostics-column-unit
5520Select the units for the column number. This affects traditional diagnostics
5521(in the absence of @option{-fno-show-column}), as well as JSON format
5522diagnostics if requested.
5523
5524The default @var{UNIT}, @samp{display}, considers the number of display
5525columns occupied by each character. This may be larger than the number
5526of bytes required to encode the character, in the case of tab
5527characters, or it may be smaller, in the case of multibyte characters.
5528For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5529display column, and its UTF-8 encoding requires two bytes; the character
5530``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5531its UTF-8 encoding requires four bytes.
5532
5533Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5534count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5535
5536@item -fdiagnostics-column-origin=@var{ORIGIN}
5537@opindex fdiagnostics-column-origin
5538Select the origin for column numbers, i.e. the column number assigned to the
5539first column. The default value of 1 corresponds to traditional GCC
5540behavior and to the GNU style guide. Some utilities may perform better with an
5541origin of 0; any non-negative value may be specified.
5542
5543@item -fdiagnostics-escape-format=@var{FORMAT}
5544@opindex fdiagnostics-escape-format
5545When GCC prints pertinent source lines for a diagnostic it normally attempts
5546to print the source bytes directly. However, some diagnostics relate to encoding
5547issues in the source file, such as malformed UTF-8, or issues with Unicode
5548normalization. These diagnostics are flagged so that GCC will escape bytes
5549that are not printable ASCII when printing their pertinent source lines.
5550
5551This option controls how such bytes should be escaped.
5552
5553The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5554are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5555correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5556displayed as hexadecimal in the form @samp{<XX>}.
5557
5558For example, a source line containing the string @samp{before} followed by the
5559Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
55600xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
5561the string @samp{after} will be printed for such a diagnostic as:
5562
5563@smallexample
5564 before<U+03C0><BF>after
5565@end smallexample
5566
5567Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
5568in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
5569Unicode characters. For the example above, the following will be printed:
5570
5571@smallexample
5572 before<CF><80><BF>after
5573@end smallexample
5574
5575@item -fdiagnostics-format=@var{FORMAT}
5576@opindex fdiagnostics-format
5577Select a different format for printing diagnostics.
5578@var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file},
5579@samp{json}, @samp{json-stderr}, or @samp{json-file}.
5580
5581The default is @samp{text}.
5582
5583The @samp{sarif-stderr} and @samp{sarif-file} formats both emit
5584diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file
5585named @file{@var{source}.sarif}, respectively.
5586
5587The @samp{json} format is a synonym for @samp{json-stderr}.
5588The @samp{json-stderr} and @samp{json-file} formats are identical, apart from
5589where the JSON is emitted to - with the former, the JSON is emitted to stderr,
5590whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}.
5591
5592The emitted JSON consists of a top-level JSON array containing JSON objects
5593representing the diagnostics. The JSON is emitted as one line, without
5594formatting; the examples below have been formatted for clarity.
5595
5596Diagnostics can have child diagnostics. For example, this error and note:
5597
5598@smallexample
5599misleading-indentation.c:15:3: warning: this 'if' clause does not
5600 guard... [-Wmisleading-indentation]
5601 15 | if (flag)
5602 | ^~
5603misleading-indentation.c:17:5: note: ...this statement, but the latter
5604 is misleadingly indented as if it were guarded by the 'if'
5605 17 | y = 2;
5606 | ^
5607@end smallexample
5608
5609@noindent
5610might be printed in JSON form (after formatting) like this:
5611
5612@smallexample
5613[
5614 @{
5615 "kind": "warning",
5616 "locations": [
5617 @{
5618 "caret": @{
5619 "display-column": 3,
5620 "byte-column": 3,
5621 "column": 3,
5622 "file": "misleading-indentation.c",
5623 "line": 15
5624 @},
5625 "finish": @{
5626 "display-column": 4,
5627 "byte-column": 4,
5628 "column": 4,
5629 "file": "misleading-indentation.c",
5630 "line": 15
5631 @}
5632 @}
5633 ],
5634 "message": "this \u2018if\u2019 clause does not guard...",
5635 "option": "-Wmisleading-indentation",
5636 "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation",
5637 "children": [
5638 @{
5639 "kind": "note",
5640 "locations": [
5641 @{
5642 "caret": @{
5643 "display-column": 5,
5644 "byte-column": 5,
5645 "column": 5,
5646 "file": "misleading-indentation.c",
5647 "line": 17
5648 @}
5649 @}
5650 ],
5651 "escape-source": false,
5652 "message": "...this statement, but the latter is @dots{}"
5653 @}
5654 ]
5655 "escape-source": false,
5656 "column-origin": 1,
5657 @}
5658]
5659@end smallexample
5660
5661@noindent
5662where the @code{note} is a child of the @code{warning}.
5663
5664A diagnostic has a @code{kind}. If this is @code{warning}, then there is
5665an @code{option} key describing the command-line option controlling the
5666warning.
5667
5668A diagnostic can contain zero or more locations. Each location has an
5669optional @code{label} string and up to three positions within it: a
5670@code{caret} position and optional @code{start} and @code{finish} positions.
5671A position is described by a @code{file} name, a @code{line} number, and
5672three numbers indicating a column position:
5673@itemize @bullet
5674
5675@item
5676@code{display-column} counts display columns, accounting for tabs and
5677multibyte characters.
5678
5679@item
5680@code{byte-column} counts raw bytes.
5681
5682@item
5683@code{column} is equal to one of
5684the previous two, as dictated by the @option{-fdiagnostics-column-unit}
5685option.
5686
5687@end itemize
5688All three columns are relative to the origin specified by
5689@option{-fdiagnostics-column-origin}, which is typically equal to 1 but may
5690be set, for instance, to 0 for compatibility with other utilities that
5691number columns from 0. The column origin is recorded in the JSON output in
5692the @code{column-origin} tag. In the remaining examples below, the extra
5693column number outputs have been omitted for brevity.
5694
5695For example, this error:
5696
5697@smallexample
5698bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka
5699 'struct s'@} and 'T' @{aka 'struct t'@})
5700 64 | return callee_4a () + callee_4b ();
5701 | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
5702 | | |
5703 | | T @{aka struct t@}
5704 | S @{aka struct s@}
5705@end smallexample
5706
5707@noindent
5708has three locations. Its primary location is at the ``+'' token at column
570923. It has two secondary locations, describing the left and right-hand sides
5710of the expression, which have labels. It might be printed in JSON form as:
5711
5712@smallexample
5713 @{
5714 "children": [],
5715 "kind": "error",
5716 "locations": [
5717 @{
5718 "caret": @{
5719 "column": 23, "file": "bad-binary-ops.c", "line": 64
5720 @}
5721 @},
5722 @{
5723 "caret": @{
5724 "column": 10, "file": "bad-binary-ops.c", "line": 64
5725 @},
5726 "finish": @{
5727 "column": 21, "file": "bad-binary-ops.c", "line": 64
5728 @},
5729 "label": "S @{aka struct s@}"
5730 @},
5731 @{
5732 "caret": @{
5733 "column": 25, "file": "bad-binary-ops.c", "line": 64
5734 @},
5735 "finish": @{
5736 "column": 36, "file": "bad-binary-ops.c", "line": 64
5737 @},
5738 "label": "T @{aka struct t@}"
5739 @}
5740 ],
5741 "escape-source": false,
5742 "message": "invalid operands to binary + @dots{}"
5743 @}
5744@end smallexample
5745
5746If a diagnostic contains fix-it hints, it has a @code{fixits} array,
5747consisting of half-open intervals, similar to the output of
5748@option{-fdiagnostics-parseable-fixits}. For example, this diagnostic
5749with a replacement fix-it hint:
5750
5751@smallexample
5752demo.c:8:15: error: 'struct s' has no member named 'colour'; did you
5753 mean 'color'?
5754 8 | return ptr->colour;
5755 | ^~~~~~
5756 | color
5757@end smallexample
5758
5759@noindent
5760might be printed in JSON form as:
5761
5762@smallexample
5763 @{
5764 "children": [],
5765 "fixits": [
5766 @{
5767 "next": @{
5768 "column": 21,
5769 "file": "demo.c",
5770 "line": 8
5771 @},
5772 "start": @{
5773 "column": 15,
5774 "file": "demo.c",
5775 "line": 8
5776 @},
5777 "string": "color"
5778 @}
5779 ],
5780 "kind": "error",
5781 "locations": [
5782 @{
5783 "caret": @{
5784 "column": 15,
5785 "file": "demo.c",
5786 "line": 8
5787 @},
5788 "finish": @{
5789 "column": 20,
5790 "file": "demo.c",
5791 "line": 8
5792 @}
5793 @}
5794 ],
5795 "escape-source": false,
5796 "message": "\u2018struct s\u2019 has no member named @dots{}"
5797 @}
5798@end smallexample
5799
5800@noindent
5801where the fix-it hint suggests replacing the text from @code{start} up
5802to but not including @code{next} with @code{string}'s value. Deletions
5803are expressed via an empty value for @code{string}, insertions by
5804having @code{start} equal @code{next}.
5805
5806If the diagnostic has a path of control-flow events associated with it,
5807it has a @code{path} array of objects representing the events. Each
5808event object has a @code{description} string, a @code{location} object,
5809along with a @code{function} string and a @code{depth} number for
5810representing interprocedural paths. The @code{function} represents the
5811current function at that event, and the @code{depth} represents the
5812stack depth relative to some baseline: the higher, the more frames are
5813within the stack.
5814
5815For example, the intraprocedural example shown for
5816@option{-fdiagnostics-path-format=} might have this JSON for its path:
5817
5818@smallexample
5819 "path": [
5820 @{
5821 "depth": 0,
5822 "description": "when 'PyList_New' fails, returning NULL",
5823 "function": "test",
5824 "location": @{
5825 "column": 10,
5826 "file": "test.c",
5827 "line": 25
5828 @}
5829 @},
5830 @{
5831 "depth": 0,
5832 "description": "when 'i < count'",
5833 "function": "test",
5834 "location": @{
5835 "column": 3,
5836 "file": "test.c",
5837 "line": 27
5838 @}
5839 @},
5840 @{
5841 "depth": 0,
5842 "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1",
5843 "function": "test",
5844 "location": @{
5845 "column": 5,
5846 "file": "test.c",
5847 "line": 29
5848 @}
5849 @}
5850 ]
5851@end smallexample
5852
5853Diagnostics have a boolean attribute @code{escape-source}, hinting whether
5854non-ASCII bytes should be escaped when printing the pertinent lines of
5855source code (@code{true} for diagnostics involving source encoding issues).
5856
5857@end table
5858
5859@node Warning Options
5860@section Options to Request or Suppress Warnings
5861@cindex options to control warnings
5862@cindex warning messages
5863@cindex messages, warning
5864@cindex suppressing warnings
5865
5866Warnings are diagnostic messages that report constructions that
5867are not inherently erroneous but that are risky or suggest there
5868may have been an error.
5869
5870The following language-independent options do not enable specific
5871warnings but control the kinds of diagnostics produced by GCC@.
5872
5873@table @gcctabopt
5874@cindex syntax checking
5875@item -fsyntax-only
5876@opindex fsyntax-only
5877Check the code for syntax errors, but don't do anything beyond that.
5878
5879@item -fmax-errors=@var{n}
5880@opindex fmax-errors
5881Limits the maximum number of error messages to @var{n}, at which point
5882GCC bails out rather than attempting to continue processing the source
5883code. If @var{n} is 0 (the default), there is no limit on the number
5884of error messages produced. If @option{-Wfatal-errors} is also
5885specified, then @option{-Wfatal-errors} takes precedence over this
5886option.
5887
5888@item -w
5889@opindex w
5890Inhibit all warning messages.
5891
5892@item -Werror
5893@opindex Werror
5894@opindex Wno-error
5895Make all warnings into errors.
5896
5897@item -Werror=
5898@opindex Werror=
5899@opindex Wno-error=
5900Make the specified warning into an error. The specifier for a warning
5901is appended; for example @option{-Werror=switch} turns the warnings
5902controlled by @option{-Wswitch} into errors. This switch takes a
5903negative form, to be used to negate @option{-Werror} for specific
5904warnings; for example @option{-Wno-error=switch} makes
5905@option{-Wswitch} warnings not be errors, even when @option{-Werror}
5906is in effect.
5907
5908The warning message for each controllable warning includes the
5909option that controls the warning. That option can then be used with
5910@option{-Werror=} and @option{-Wno-error=} as described above.
5911(Printing of the option in the warning message can be disabled using the
5912@option{-fno-diagnostics-show-option} flag.)
5913
5914Note that specifying @option{-Werror=}@var{foo} automatically implies
5915@option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
5916imply anything.
5917
5918@item -Wfatal-errors
5919@opindex Wfatal-errors
5920@opindex Wno-fatal-errors
5921This option causes the compiler to abort compilation on the first error
5922occurred rather than trying to keep going and printing further error
5923messages.
5924
5925@end table
5926
5927You can request many specific warnings with options beginning with
5928@samp{-W}, for example @option{-Wimplicit} to request warnings on
5929implicit declarations. Each of these specific warning options also
5930has a negative form beginning @samp{-Wno-} to turn off warnings; for
5931example, @option{-Wno-implicit}. This manual lists only one of the
5932two forms, whichever is not the default. For further
5933language-specific options also refer to @ref{C++ Dialect Options} and
5934@ref{Objective-C and Objective-C++ Dialect Options}.
5935Additional warnings can be produced by enabling the static analyzer;
5936@xref{Static Analyzer Options}.
5937
5938Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
5939options, such as @option{-Wunused}, which may turn on further options,
5940such as @option{-Wunused-value}. The combined effect of positive and
5941negative forms is that more specific options have priority over less
5942specific ones, independently of their position in the command-line. For
5943options of the same specificity, the last one takes effect. Options
5944enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
5945as if they appeared at the end of the command-line.
5946
5947When an unrecognized warning option is requested (e.g.,
5948@option{-Wunknown-warning}), GCC emits a diagnostic stating
5949that the option is not recognized. However, if the @option{-Wno-} form
5950is used, the behavior is slightly different: no diagnostic is
5951produced for @option{-Wno-unknown-warning} unless other diagnostics
5952are being produced. This allows the use of new @option{-Wno-} options
5953with old compilers, but if something goes wrong, the compiler
5954warns that an unrecognized option is present.
5955
5956The effectiveness of some warnings depends on optimizations also being
5957enabled. For example @option{-Wsuggest-final-types} is more effective
5958with link-time optimization and some instances of other warnings may
5959not be issued at all unless optimization is enabled. While optimization
5960in general improves the efficacy of control and data flow sensitive
5961warnings, in some cases it may also cause false positives.
5962
5963@table @gcctabopt
5964@item -Wpedantic
5965@itemx -pedantic
5966@opindex pedantic
5967@opindex Wpedantic
5968@opindex Wno-pedantic
5969Issue all the warnings demanded by strict ISO C and ISO C++;
5970reject all programs that use forbidden extensions, and some other
5971programs that do not follow ISO C and ISO C++. For ISO C, follows the
5972version of the ISO C standard specified by any @option{-std} option used.
5973
5974Valid ISO C and ISO C++ programs should compile properly with or without
5975this option (though a rare few require @option{-ansi} or a
5976@option{-std} option specifying the required version of ISO C)@. However,
5977without this option, certain GNU extensions and traditional C and C++
5978features are supported as well. With this option, they are rejected.
5979
5980@option{-Wpedantic} does not cause warning messages for use of the
5981alternate keywords whose names begin and end with @samp{__}. This alternate
5982format can also be used to disable warnings for non-ISO @samp{__intN} types,
5983i.e. @samp{__intN__}.
5984Pedantic warnings are also disabled in the expression that follows
5985@code{__extension__}. However, only system header files should use
5986these escape routes; application programs should avoid them.
5987@xref{Alternate Keywords}.
5988
5989Some users try to use @option{-Wpedantic} to check programs for strict ISO
5990C conformance. They soon find that it does not do quite what they want:
5991it finds some non-ISO practices, but not all---only those for which
5992ISO C @emph{requires} a diagnostic, and some others for which
5993diagnostics have been added.
5994
5995A feature to report any failure to conform to ISO C might be useful in
5996some instances, but would require considerable additional work and would
5997be quite different from @option{-Wpedantic}. We don't have plans to
5998support such a feature in the near future.
5999
6000Where the standard specified with @option{-std} represents a GNU
6001extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
6002corresponding @dfn{base standard}, the version of ISO C on which the GNU
6003extended dialect is based. Warnings from @option{-Wpedantic} are given
6004where they are required by the base standard. (It does not make sense
6005for such warnings to be given only for features not in the specified GNU
6006C dialect, since by definition the GNU dialects of C include all
6007features the compiler supports with the given option, and there would be
6008nothing to warn about.)
6009
6010@item -pedantic-errors
6011@opindex pedantic-errors
6012Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
6013requires a diagnostic, in some cases where there is undefined behavior
6014at compile-time and in some other cases that do not prevent compilation
6015of programs that are valid according to the standard. This is not
6016equivalent to @option{-Werror=pedantic}, since there are errors enabled
6017by this option and not enabled by the latter and vice versa.
6018
6019@item -Wall
6020@opindex Wall
6021@opindex Wno-all
6022This enables all the warnings about constructions that some users
6023consider questionable, and that are easy to avoid (or modify to
6024prevent the warning), even in conjunction with macros. This also
6025enables some language-specific warnings described in @ref{C++ Dialect
6026Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
6027
6028@option{-Wall} turns on the following warning flags:
6029
6030@gccoptlist{-Waddress @gol
6031-Warray-bounds=1 @r{(only with} @option{-O2}@r{)} @gol
6032-Warray-compare @gol
6033-Warray-parameter=2 @r{(C and Objective-C only)} @gol
6034-Wbool-compare @gol
6035-Wbool-operation @gol
6036-Wc++11-compat -Wc++14-compat @gol
6037-Wcatch-value @r{(C++ and Objective-C++ only)} @gol
6038-Wchar-subscripts @gol
6039-Wcomment @gol
6040-Wdangling-pointer=2 @gol
6041-Wduplicate-decl-specifier @r{(C and Objective-C only)} @gol
6042-Wenum-compare @r{(in C/ObjC; this is on by default in C++)} @gol
6043-Wenum-int-mismatch @r{(C and Objective-C only)} @gol
6044-Wformat @gol
6045-Wformat-overflow @gol
6046-Wformat-truncation @gol
6047-Wint-in-bool-context @gol
6048-Wimplicit @r{(C and Objective-C only)} @gol
6049-Wimplicit-int @r{(C and Objective-C only)} @gol
6050-Wimplicit-function-declaration @r{(C and Objective-C only)} @gol
6051-Winit-self @r{(only for C++)} @gol
6052-Wlogical-not-parentheses @gol
6053-Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} @gol
6054-Wmaybe-uninitialized @gol
6055-Wmemset-elt-size @gol
6056-Wmemset-transposed-args @gol
6057-Wmisleading-indentation @r{(only for C/C++)} @gol
6058-Wmismatched-dealloc @gol
6059-Wmismatched-new-delete @r{(only for C/C++)} @gol
6060-Wmissing-attributes @gol
6061-Wmissing-braces @r{(only for C/ObjC)} @gol
6062-Wmultistatement-macros @gol
6063-Wnarrowing @r{(only for C++)} @gol
6064-Wnonnull @gol
6065-Wnonnull-compare @gol
6066-Wopenmp-simd @gol
6067-Wparentheses @gol
6068-Wpessimizing-move @r{(only for C++)} @gol
6069-Wpointer-sign @gol
6070-Wrange-loop-construct @r{(only for C++)} @gol
6071-Wreorder @gol
6072-Wrestrict @gol
6073-Wreturn-type @gol
6074-Wself-move @r{(only for C++)} @gol
6075-Wsequence-point @gol
6076-Wsign-compare @r{(only in C++)} @gol
6077-Wsizeof-array-div @gol
6078-Wsizeof-pointer-div @gol
6079-Wsizeof-pointer-memaccess @gol
6080-Wstrict-aliasing @gol
6081-Wstrict-overflow=1 @gol
6082-Wswitch @gol
6083-Wtautological-compare @gol
6084-Wtrigraphs @gol
6085-Wuninitialized @gol
6086-Wunknown-pragmas @gol
6087-Wunused-function @gol
6088-Wunused-label @gol
6089-Wunused-value @gol
6090-Wunused-variable @gol
9dcfee4e 6091-Wuse-after-free=2 @gol
d77de738
ML
6092-Wvla-parameter @r{(C and Objective-C only)} @gol
6093-Wvolatile-register-var @gol
6094-Wzero-length-bounds}
6095
6096Note that some warning flags are not implied by @option{-Wall}. Some of
6097them warn about constructions that users generally do not consider
6098questionable, but which occasionally you might wish to check for;
6099others warn about constructions that are necessary or hard to avoid in
6100some cases, and there is no simple way to modify the code to suppress
6101the warning. Some of them are enabled by @option{-Wextra} but many of
6102them must be enabled individually.
6103
6104@item -Wextra
6105@opindex W
6106@opindex Wextra
6107@opindex Wno-extra
6108This enables some extra warning flags that are not enabled by
6109@option{-Wall}. (This option used to be called @option{-W}. The older
6110name is still supported, but the newer name is more descriptive.)
6111
6112@gccoptlist{-Wclobbered @gol
6113-Wcast-function-type @gol
6114-Wdeprecated-copy @r{(C++ only)} @gol
6115-Wempty-body @gol
6116-Wenum-conversion @r{(C only)} @gol
6117-Wignored-qualifiers @gol
6118-Wimplicit-fallthrough=3 @gol
6119-Wmissing-field-initializers @gol
6120-Wmissing-parameter-type @r{(C only)} @gol
6121-Wold-style-declaration @r{(C only)} @gol
6122-Woverride-init @gol
6123-Wsign-compare @r{(C only)} @gol
6124-Wstring-compare @gol
6125-Wredundant-move @r{(only for C++)} @gol
6126-Wtype-limits @gol
6127-Wuninitialized @gol
6128-Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)} @gol
6129-Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)} @gol
6130-Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
6131
6132
6133The option @option{-Wextra} also prints warning messages for the
6134following cases:
6135
6136@itemize @bullet
6137
6138@item
6139A pointer is compared against integer zero with @code{<}, @code{<=},
6140@code{>}, or @code{>=}.
6141
6142@item
6143(C++ only) An enumerator and a non-enumerator both appear in a
6144conditional expression.
6145
6146@item
6147(C++ only) Ambiguous virtual bases.
6148
6149@item
6150(C++ only) Subscripting an array that has been declared @code{register}.
6151
6152@item
6153(C++ only) Taking the address of a variable that has been declared
6154@code{register}.
6155
6156@item
6157(C++ only) A base class is not initialized in the copy constructor
6158of a derived class.
6159
6160@end itemize
6161
6162@item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
6163@opindex Wabi
6164@opindex Wno-abi
6165
6166Warn about code affected by ABI changes. This includes code that may
6167not be compatible with the vendor-neutral C++ ABI as well as the psABI
6168for the particular target.
6169
6170Since G++ now defaults to updating the ABI with each major release,
6171normally @option{-Wabi} warns only about C++ ABI compatibility
6172problems if there is a check added later in a release series for an
6173ABI issue discovered since the initial release. @option{-Wabi} warns
6174about more things if an older ABI version is selected (with
6175@option{-fabi-version=@var{n}}).
6176
6177@option{-Wabi} can also be used with an explicit version number to
6178warn about C++ ABI compatibility with a particular @option{-fabi-version}
6179level, e.g.@: @option{-Wabi=2} to warn about changes relative to
6180@option{-fabi-version=2}.
6181
6182If an explicit version number is provided and
6183@option{-fabi-compat-version} is not specified, the version number
6184from this option is used for compatibility aliases. If no explicit
6185version number is provided with this option, but
6186@option{-fabi-compat-version} is specified, that version number is
6187used for C++ ABI warnings.
6188
6189Although an effort has been made to warn about
6190all such cases, there are probably some cases that are not warned about,
6191even though G++ is generating incompatible code. There may also be
6192cases where warnings are emitted even though the code that is generated
6193is compatible.
6194
6195You should rewrite your code to avoid these warnings if you are
6196concerned about the fact that code generated by G++ may not be binary
6197compatible with code generated by other compilers.
6198
6199Known incompatibilities in @option{-fabi-version=2} (which was the
6200default from GCC 3.4 to 4.9) include:
6201
6202@itemize @bullet
6203
6204@item
6205A template with a non-type template parameter of reference type was
6206mangled incorrectly:
6207@smallexample
6208extern int N;
6209template <int &> struct S @{@};
6210void n (S<N>) @{2@}
6211@end smallexample
6212
6213This was fixed in @option{-fabi-version=3}.
6214
6215@item
6216SIMD vector types declared using @code{__attribute ((vector_size))} were
6217mangled in a non-standard way that does not allow for overloading of
6218functions taking vectors of different sizes.
6219
6220The mangling was changed in @option{-fabi-version=4}.
6221
6222@item
6223@code{__attribute ((const))} and @code{noreturn} were mangled as type
6224qualifiers, and @code{decltype} of a plain declaration was folded away.
6225
6226These mangling issues were fixed in @option{-fabi-version=5}.
6227
6228@item
6229Scoped enumerators passed as arguments to a variadic function are
6230promoted like unscoped enumerators, causing @code{va_arg} to complain.
6231On most targets this does not actually affect the parameter passing
6232ABI, as there is no way to pass an argument smaller than @code{int}.
6233
6234Also, the ABI changed the mangling of template argument packs,
6235@code{const_cast}, @code{static_cast}, prefix increment/decrement, and
6236a class scope function used as a template argument.
6237
6238These issues were corrected in @option{-fabi-version=6}.
6239
6240@item
6241Lambdas in default argument scope were mangled incorrectly, and the
6242ABI changed the mangling of @code{nullptr_t}.
6243
6244These issues were corrected in @option{-fabi-version=7}.
6245
6246@item
6247When mangling a function type with function-cv-qualifiers, the
6248un-qualified function type was incorrectly treated as a substitution
6249candidate.
6250
6251This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
6252
6253@item
6254@code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
6255unaligned accesses. Note that this did not affect the ABI of a
6256function with a @code{nullptr_t} parameter, as parameters have a
6257minimum alignment.
6258
6259This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
6260
6261@item
6262Target-specific attributes that affect the identity of a type, such as
6263ia32 calling conventions on a function type (stdcall, regparm, etc.),
6264did not affect the mangled name, leading to name collisions when
6265function pointers were used as template arguments.
6266
6267This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
6268
6269@end itemize
6270
6271This option also enables warnings about psABI-related changes.
6272The known psABI changes at this point include:
6273
6274@itemize @bullet
6275
6276@item
6277For SysV/x86-64, unions with @code{long double} members are
6278passed in memory as specified in psABI. Prior to GCC 4.4, this was not
6279the case. For example:
6280
6281@smallexample
6282union U @{
6283 long double ld;
6284 int i;
6285@};
6286@end smallexample
6287
6288@noindent
6289@code{union U} is now always passed in memory.
6290
6291@end itemize
6292
e2f939d3
JM
6293@item -Wno-changes-meaning @r{(C++ and Objective-C++ only)}
6294C++ requires that unqualified uses of a name within a class have the
6295same meaning in the complete scope of the class, so declaring the name
6296after using it is ill-formed:
6297@smallexample
6298struct A;
6299struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning
6300struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning
6301@end smallexample
6302By default, the B1 case is only a warning because the two declarations
6303have the same type, while the B2 case is an error. Both diagnostics
6304can be disabled with @option{-Wno-changes-meaning}. Alternately, the
6305error case can be reduced to a warning with
6306@option{-Wno-error=changes-meaning} or @option{-fpermissive}.
6307
6308Both diagnostics are also suppressed by @option{-fms-extensions}.
6309
d77de738
ML
6310@item -Wchar-subscripts
6311@opindex Wchar-subscripts
6312@opindex Wno-char-subscripts
6313Warn if an array subscript has type @code{char}. This is a common cause
6314of error, as programmers often forget that this type is signed on some
6315machines.
6316This warning is enabled by @option{-Wall}.
6317
6318@item -Wno-coverage-mismatch
6319@opindex Wno-coverage-mismatch
6320@opindex Wcoverage-mismatch
6321Warn if feedback profiles do not match when using the
6322@option{-fprofile-use} option.
6323If a source file is changed between compiling with @option{-fprofile-generate}
6324and with @option{-fprofile-use}, the files with the profile feedback can fail
6325to match the source file and GCC cannot use the profile feedback
6326information. By default, this warning is enabled and is treated as an
6327error. @option{-Wno-coverage-mismatch} can be used to disable the
6328warning or @option{-Wno-error=coverage-mismatch} can be used to
6329disable the error. Disabling the error for this warning can result in
6330poorly optimized code and is useful only in the
6331case of very minor changes such as bug fixes to an existing code-base.
6332Completely disabling the warning is not recommended.
6333
6334@item -Wno-coverage-invalid-line-number
6335@opindex Wno-coverage-invalid-line-number
6336@opindex Wcoverage-invalid-line-number
6337Warn in case a function ends earlier than it begins due
6338to an invalid linenum macros. The warning is emitted only
6339with @option{--coverage} enabled.
6340
6341By default, this warning is enabled and is treated as an
6342error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
6343warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
6344disable the error.
6345
6346@item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
6347@opindex Wno-cpp
6348@opindex Wcpp
6349Suppress warning messages emitted by @code{#warning} directives.
6350
6351@item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
6352@opindex Wdouble-promotion
6353@opindex Wno-double-promotion
6354Give a warning when a value of type @code{float} is implicitly
6355promoted to @code{double}. CPUs with a 32-bit ``single-precision''
6356floating-point unit implement @code{float} in hardware, but emulate
6357@code{double} in software. On such a machine, doing computations
6358using @code{double} values is much more expensive because of the
6359overhead required for software emulation.
6360
6361It is easy to accidentally do computations with @code{double} because
6362floating-point literals are implicitly of type @code{double}. For
6363example, in:
6364@smallexample
6365@group
6366float area(float radius)
6367@{
6368 return 3.14159 * radius * radius;
6369@}
6370@end group
6371@end smallexample
6372the compiler performs the entire computation with @code{double}
6373because the floating-point literal is a @code{double}.
6374
6375@item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
6376@opindex Wduplicate-decl-specifier
6377@opindex Wno-duplicate-decl-specifier
6378Warn if a declaration has duplicate @code{const}, @code{volatile},
6379@code{restrict} or @code{_Atomic} specifier. This warning is enabled by
6380@option{-Wall}.
6381
6382@item -Wformat
6383@itemx -Wformat=@var{n}
6384@opindex Wformat
6385@opindex Wno-format
6386@opindex ffreestanding
6387@opindex fno-builtin
6388@opindex Wformat=
6389Check calls to @code{printf} and @code{scanf}, etc., to make sure that
6390the arguments supplied have types appropriate to the format string
6391specified, and that the conversions specified in the format string make
6392sense. This includes standard functions, and others specified by format
6393attributes (@pxref{Function Attributes}), in the @code{printf},
6394@code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
6395not in the C standard) families (or other target-specific families).
6396Which functions are checked without format attributes having been
6397specified depends on the standard version selected, and such checks of
6398functions without the attribute specified are disabled by
6399@option{-ffreestanding} or @option{-fno-builtin}.
6400
6401The formats are checked against the format features supported by GNU
6402libc version 2.2. These include all ISO C90 and C99 features, as well
6403as features from the Single Unix Specification and some BSD and GNU
6404extensions. Other library implementations may not support all these
6405features; GCC does not support warning about features that go beyond a
6406particular library's limitations. However, if @option{-Wpedantic} is used
6407with @option{-Wformat}, warnings are given about format features not
6408in the selected standard version (but not for @code{strfmon} formats,
6409since those are not in any version of the C standard). @xref{C Dialect
6410Options,,Options Controlling C Dialect}.
6411
6412@table @gcctabopt
6413@item -Wformat=1
6414@itemx -Wformat
6415@opindex Wformat
6416@opindex Wformat=1
6417Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6418@option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6419@option{-Wformat} also checks for null format arguments for several
6420functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6421aspects of this level of format checking can be disabled by the
6422options: @option{-Wno-format-contains-nul},
6423@option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6424@option{-Wformat} is enabled by @option{-Wall}.
6425
6426@item -Wformat=2
6427@opindex Wformat=2
6428Enable @option{-Wformat} plus additional format checks. Currently
6429equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6430-Wformat-y2k}.
6431@end table
6432
6433@item -Wno-format-contains-nul
6434@opindex Wno-format-contains-nul
6435@opindex Wformat-contains-nul
6436If @option{-Wformat} is specified, do not warn about format strings that
6437contain NUL bytes.
6438
6439@item -Wno-format-extra-args
6440@opindex Wno-format-extra-args
6441@opindex Wformat-extra-args
6442If @option{-Wformat} is specified, do not warn about excess arguments to a
6443@code{printf} or @code{scanf} format function. The C standard specifies
6444that such arguments are ignored.
6445
6446Where the unused arguments lie between used arguments that are
6447specified with @samp{$} operand number specifications, normally
6448warnings are still given, since the implementation could not know what
6449type to pass to @code{va_arg} to skip the unused arguments. However,
6450in the case of @code{scanf} formats, this option suppresses the
6451warning if the unused arguments are all pointers, since the Single
6452Unix Specification says that such unused arguments are allowed.
6453
6454@item -Wformat-overflow
6455@itemx -Wformat-overflow=@var{level}
6456@opindex Wformat-overflow
6457@opindex Wno-format-overflow
6458Warn about calls to formatted input/output functions such as @code{sprintf}
6459and @code{vsprintf} that might overflow the destination buffer. When the
6460exact number of bytes written by a format directive cannot be determined
6461at compile-time it is estimated based on heuristics that depend on the
6462@var{level} argument and on optimization. While enabling optimization
6463will in most cases improve the accuracy of the warning, it may also
6464result in false positives.
6465
6466@table @gcctabopt
6467@item -Wformat-overflow
6468@itemx -Wformat-overflow=1
6469@opindex Wformat-overflow
6470@opindex Wno-format-overflow
6471Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6472employs a conservative approach that warns only about calls that most
6473likely overflow the buffer. At this level, numeric arguments to format
6474directives with unknown values are assumed to have the value of one, and
6475strings of unknown length to be empty. Numeric arguments that are known
6476to be bounded to a subrange of their type, or string arguments whose output
6477is bounded either by their directive's precision or by a finite set of
6478string literals, are assumed to take on the value within the range that
6479results in the most bytes on output. For example, the call to @code{sprintf}
6480below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6481the terminating NUL character (@code{'\0'}) appended by the function
6482to the destination buffer will be written past its end. Increasing
6483the size of the buffer by a single byte is sufficient to avoid the
6484warning, though it may not be sufficient to avoid the overflow.
6485
6486@smallexample
6487void f (int a, int b)
6488@{
6489 char buf [13];
6490 sprintf (buf, "a = %i, b = %i\n", a, b);
6491@}
6492@end smallexample
6493
6494@item -Wformat-overflow=2
6495Level @var{2} warns also about calls that might overflow the destination
6496buffer given an argument of sufficient length or magnitude. At level
6497@var{2}, unknown numeric arguments are assumed to have the minimum
6498representable value for signed types with a precision greater than 1, and
6499the maximum representable value otherwise. Unknown string arguments whose
6500length cannot be assumed to be bounded either by the directive's precision,
6501or by a finite set of string literals they may evaluate to, or the character
6502array they may point to, are assumed to be 1 character long.
6503
6504At level @var{2}, the call in the example above is again diagnosed, but
6505this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6506@code{%i} directive will write some of its digits beyond the end of
6507the destination buffer. To make the call safe regardless of the values
6508of the two variables, the size of the destination buffer must be increased
6509to at least 34 bytes. GCC includes the minimum size of the buffer in
6510an informational note following the warning.
6511
6512An alternative to increasing the size of the destination buffer is to
6513constrain the range of formatted values. The maximum length of string
6514arguments can be bounded by specifying the precision in the format
6515directive. When numeric arguments of format directives can be assumed
6516to be bounded by less than the precision of their type, choosing
6517an appropriate length modifier to the format specifier will reduce
6518the required buffer size. For example, if @var{a} and @var{b} in the
6519example above can be assumed to be within the precision of
6520the @code{short int} type then using either the @code{%hi} format
6521directive or casting the argument to @code{short} reduces the maximum
6522required size of the buffer to 24 bytes.
6523
6524@smallexample
6525void f (int a, int b)
6526@{
6527 char buf [23];
6528 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
6529@}
6530@end smallexample
6531@end table
6532
6533@item -Wno-format-zero-length
6534@opindex Wno-format-zero-length
6535@opindex Wformat-zero-length
6536If @option{-Wformat} is specified, do not warn about zero-length formats.
6537The C standard specifies that zero-length formats are allowed.
6538
6539@item -Wformat-nonliteral
6540@opindex Wformat-nonliteral
6541@opindex Wno-format-nonliteral
6542If @option{-Wformat} is specified, also warn if the format string is not a
6543string literal and so cannot be checked, unless the format function
6544takes its format arguments as a @code{va_list}.
6545
6546@item -Wformat-security
6547@opindex Wformat-security
6548@opindex Wno-format-security
6549If @option{-Wformat} is specified, also warn about uses of format
6550functions that represent possible security problems. At present, this
6551warns about calls to @code{printf} and @code{scanf} functions where the
6552format string is not a string literal and there are no format arguments,
6553as in @code{printf (foo);}. This may be a security hole if the format
6554string came from untrusted input and contains @samp{%n}. (This is
6555currently a subset of what @option{-Wformat-nonliteral} warns about, but
6556in future warnings may be added to @option{-Wformat-security} that are not
6557included in @option{-Wformat-nonliteral}.)
6558
6559@item -Wformat-signedness
6560@opindex Wformat-signedness
6561@opindex Wno-format-signedness
6562If @option{-Wformat} is specified, also warn if the format string
6563requires an unsigned argument and the argument is signed and vice versa.
6564
6565@item -Wformat-truncation
6566@itemx -Wformat-truncation=@var{level}
6567@opindex Wformat-truncation
6568@opindex Wno-format-truncation
6569Warn about calls to formatted input/output functions such as @code{snprintf}
6570and @code{vsnprintf} that might result in output truncation. When the exact
6571number of bytes written by a format directive cannot be determined at
6572compile-time it is estimated based on heuristics that depend on
6573the @var{level} argument and on optimization. While enabling optimization
6574will in most cases improve the accuracy of the warning, it may also result
6575in false positives. Except as noted otherwise, the option uses the same
6576logic @option{-Wformat-overflow}.
6577
6578@table @gcctabopt
6579@item -Wformat-truncation
6580@itemx -Wformat-truncation=1
6581@opindex Wformat-truncation
6582@opindex Wno-format-truncation
6583Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
6584employs a conservative approach that warns only about calls to bounded
6585functions whose return value is unused and that will most likely result
6586in output truncation.
6587
6588@item -Wformat-truncation=2
6589Level @var{2} warns also about calls to bounded functions whose return
6590value is used and that might result in truncation given an argument of
6591sufficient length or magnitude.
6592@end table
6593
6594@item -Wformat-y2k
6595@opindex Wformat-y2k
6596@opindex Wno-format-y2k
6597If @option{-Wformat} is specified, also warn about @code{strftime}
6598formats that may yield only a two-digit year.
6599
6600@item -Wnonnull
6601@opindex Wnonnull
6602@opindex Wno-nonnull
6603Warn about passing a null pointer for arguments marked as
6604requiring a non-null value by the @code{nonnull} function attribute.
6605
6606@option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
6607can be disabled with the @option{-Wno-nonnull} option.
6608
6609@item -Wnonnull-compare
6610@opindex Wnonnull-compare
6611@opindex Wno-nonnull-compare
6612Warn when comparing an argument marked with the @code{nonnull}
6613function attribute against null inside the function.
6614
6615@option{-Wnonnull-compare} is included in @option{-Wall}. It
6616can be disabled with the @option{-Wno-nonnull-compare} option.
6617
6618@item -Wnull-dereference
6619@opindex Wnull-dereference
6620@opindex Wno-null-dereference
6621Warn if the compiler detects paths that trigger erroneous or
6622undefined behavior due to dereferencing a null pointer. This option
6623is only active when @option{-fdelete-null-pointer-checks} is active,
6624which is enabled by optimizations in most targets. The precision of
6625the warnings depends on the optimization options used.
6626
6627@item -Winfinite-recursion
6628@opindex Winfinite-recursion
6629@opindex Wno-infinite-recursion
6630Warn about infinitely recursive calls. The warning is effective at all
6631optimization levels but requires optimization in order to detect infinite
6632recursion in calls between two or more functions.
6633@option{-Winfinite-recursion} is included in @option{-Wall}.
6634
ce51e843
ML
6635Compare with @option{-Wanalyzer-infinite-recursion} which provides a
6636similar diagnostic, but is implemented in a different way (as part of
6637@option{-fanalyzer}).
6638
d77de738
ML
6639@item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
6640@opindex Winit-self
6641@opindex Wno-init-self
6642Warn about uninitialized variables that are initialized with themselves.
6643Note this option can only be used with the @option{-Wuninitialized} option.
6644
6645For example, GCC warns about @code{i} being uninitialized in the
6646following snippet only when @option{-Winit-self} has been specified:
6647@smallexample
6648@group
6649int f()
6650@{
6651 int i = i;
6652 return i;
6653@}
6654@end group
6655@end smallexample
6656
6657This warning is enabled by @option{-Wall} in C++.
6658
6659@item -Wno-implicit-int @r{(C and Objective-C only)}
6660@opindex Wimplicit-int
6661@opindex Wno-implicit-int
6662This option controls warnings when a declaration does not specify a type.
6663This warning is enabled by default in C99 and later dialects of C,
6664and also by @option{-Wall}.
6665
6666@item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
6667@opindex Wimplicit-function-declaration
6668@opindex Wno-implicit-function-declaration
6669This option controls warnings when a function is used before being declared.
6670This warning is enabled by default in C99 and later dialects of C,
6671and also by @option{-Wall}.
6672The warning is made into an error by @option{-pedantic-errors}.
6673
6674@item -Wimplicit @r{(C and Objective-C only)}
6675@opindex Wimplicit
6676@opindex Wno-implicit
6677Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
6678This warning is enabled by @option{-Wall}.
6679
6680@item -Wimplicit-fallthrough
6681@opindex Wimplicit-fallthrough
6682@opindex Wno-implicit-fallthrough
6683@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
6684and @option{-Wno-implicit-fallthrough} is the same as
6685@option{-Wimplicit-fallthrough=0}.
6686
6687@item -Wimplicit-fallthrough=@var{n}
6688@opindex Wimplicit-fallthrough=
6689Warn when a switch case falls through. For example:
6690
6691@smallexample
6692@group
6693switch (cond)
6694 @{
6695 case 1:
6696 a = 1;
6697 break;
6698 case 2:
6699 a = 2;
6700 case 3:
6701 a = 3;
6702 break;
6703 @}
6704@end group
6705@end smallexample
6706
6707This warning does not warn when the last statement of a case cannot
6708fall through, e.g. when there is a return statement or a call to function
6709declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
6710also takes into account control flow statements, such as ifs, and only
6711warns when appropriate. E.g.@:
6712
6713@smallexample
6714@group
6715switch (cond)
6716 @{
6717 case 1:
6718 if (i > 3) @{
6719 bar (5);
6720 break;
6721 @} else if (i < 1) @{
6722 bar (0);
6723 @} else
6724 return;
6725 default:
6726 @dots{}
6727 @}
6728@end group
6729@end smallexample
6730
6731Since there are occasions where a switch case fall through is desirable,
6732GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
6733to be used along with a null statement to suppress this warning that
6734would normally occur:
6735
6736@smallexample
6737@group
6738switch (cond)
6739 @{
6740 case 1:
6741 bar (0);
6742 __attribute__ ((fallthrough));
6743 default:
6744 @dots{}
6745 @}
6746@end group
6747@end smallexample
6748
6749C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
6750warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
6751or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
6752Instead of these attributes, it is also possible to add a fallthrough comment
6753to silence the warning. The whole body of the C or C++ style comment should
6754match the given regular expressions listed below. The option argument @var{n}
6755specifies what kind of comments are accepted:
6756
6757@itemize @bullet
6758
6759@item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
6760
6761@item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
6762expression, any comment is used as fallthrough comment.
6763
6764@item @option{-Wimplicit-fallthrough=2} case insensitively matches
6765@code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
6766
6767@item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
6768following regular expressions:
6769
6770@itemize @bullet
6771
6772@item @code{-fallthrough}
6773
6774@item @code{@@fallthrough@@}
6775
6776@item @code{lint -fallthrough[ \t]*}
6777
6778@item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
6779
6780@item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6781
6782@item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6783
6784@end itemize
6785
6786@item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
6787following regular expressions:
6788
6789@itemize @bullet
6790
6791@item @code{-fallthrough}
6792
6793@item @code{@@fallthrough@@}
6794
6795@item @code{lint -fallthrough[ \t]*}
6796
6797@item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
6798
6799@end itemize
6800
6801@item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
6802fallthrough comments, only attributes disable the warning.
6803
6804@end itemize
6805
6806The comment needs to be followed after optional whitespace and other comments
6807by @code{case} or @code{default} keywords or by a user label that precedes some
6808@code{case} or @code{default} label.
6809
6810@smallexample
6811@group
6812switch (cond)
6813 @{
6814 case 1:
6815 bar (0);
6816 /* FALLTHRU */
6817 default:
6818 @dots{}
6819 @}
6820@end group
6821@end smallexample
6822
6823The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
6824
6825@item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
6826@opindex Wif-not-aligned
6827@opindex Wno-if-not-aligned
6828Control if warnings triggered by the @code{warn_if_not_aligned} attribute
6829should be issued. These warnings are enabled by default.
6830
6831@item -Wignored-qualifiers @r{(C and C++ only)}
6832@opindex Wignored-qualifiers
6833@opindex Wno-ignored-qualifiers
6834Warn if the return type of a function has a type qualifier
6835such as @code{const}. For ISO C such a type qualifier has no effect,
6836since the value returned by a function is not an lvalue.
6837For C++, the warning is only emitted for scalar types or @code{void}.
6838ISO C prohibits qualified @code{void} return types on function
6839definitions, so such return types always receive a warning
6840even without this option.
6841
6842This warning is also enabled by @option{-Wextra}.
6843
6844@item -Wno-ignored-attributes @r{(C and C++ only)}
6845@opindex Wignored-attributes
6846@opindex Wno-ignored-attributes
6847This option controls warnings when an attribute is ignored.
6848This is different from the
6849@option{-Wattributes} option in that it warns whenever the compiler decides
6850to drop an attribute, not that the attribute is either unknown, used in a
6851wrong place, etc. This warning is enabled by default.
6852
6853@item -Wmain
6854@opindex Wmain
6855@opindex Wno-main
6856Warn if the type of @code{main} is suspicious. @code{main} should be
6857a function with external linkage, returning int, taking either zero
6858arguments, two, or three arguments of appropriate types. This warning
6859is enabled by default in C++ and is enabled by either @option{-Wall}
6860or @option{-Wpedantic}.
6861
6862@item -Wmisleading-indentation @r{(C and C++ only)}
6863@opindex Wmisleading-indentation
6864@opindex Wno-misleading-indentation
6865Warn when the indentation of the code does not reflect the block structure.
6866Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
6867@code{for} clauses with a guarded statement that does not use braces,
6868followed by an unguarded statement with the same indentation.
6869
6870In the following example, the call to ``bar'' is misleadingly indented as
6871if it were guarded by the ``if'' conditional.
6872
6873@smallexample
6874 if (some_condition ())
6875 foo ();
6876 bar (); /* Gotcha: this is not guarded by the "if". */
6877@end smallexample
6878
6879In the case of mixed tabs and spaces, the warning uses the
6880@option{-ftabstop=} option to determine if the statements line up
6881(defaulting to 8).
6882
6883The warning is not issued for code involving multiline preprocessor logic
6884such as the following example.
6885
6886@smallexample
6887 if (flagA)
6888 foo (0);
6889#if SOME_CONDITION_THAT_DOES_NOT_HOLD
6890 if (flagB)
6891#endif
6892 foo (1);
6893@end smallexample
6894
6895The warning is not issued after a @code{#line} directive, since this
6896typically indicates autogenerated code, and no assumptions can be made
6897about the layout of the file that the directive references.
6898
6899This warning is enabled by @option{-Wall} in C and C++.
6900
6901@item -Wmissing-attributes
6902@opindex Wmissing-attributes
6903@opindex Wno-missing-attributes
6904Warn when a declaration of a function is missing one or more attributes
6905that a related function is declared with and whose absence may adversely
6906affect the correctness or efficiency of generated code. For example,
6907the warning is issued for declarations of aliases that use attributes
6908to specify less restrictive requirements than those of their targets.
6909This typically represents a potential optimization opportunity.
6910By contrast, the @option{-Wattribute-alias=2} option controls warnings
6911issued when the alias is more restrictive than the target, which could
6912lead to incorrect code generation.
6913Attributes considered include @code{alloc_align}, @code{alloc_size},
6914@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
6915@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
6916@code{returns_nonnull}, and @code{returns_twice}.
6917
6918In C++, the warning is issued when an explicit specialization of a primary
6919template declared with attribute @code{alloc_align}, @code{alloc_size},
6920@code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
6921or @code{nonnull} is declared without it. Attributes @code{deprecated},
6922@code{error}, and @code{warning} suppress the warning.
6923(@pxref{Function Attributes}).
6924
6925You can use the @code{copy} attribute to apply the same
6926set of attributes to a declaration as that on another declaration without
6927explicitly enumerating the attributes. This attribute can be applied
6928to declarations of functions (@pxref{Common Function Attributes}),
6929variables (@pxref{Common Variable Attributes}), or types
6930(@pxref{Common Type Attributes}).
6931
6932@option{-Wmissing-attributes} is enabled by @option{-Wall}.
6933
6934For example, since the declaration of the primary function template
6935below makes use of both attribute @code{malloc} and @code{alloc_size}
6936the declaration of the explicit specialization of the template is
6937diagnosed because it is missing one of the attributes.
6938
6939@smallexample
6940template <class T>
6941T* __attribute__ ((malloc, alloc_size (1)))
6942allocate (size_t);
6943
6944template <>
6945void* __attribute__ ((malloc)) // missing alloc_size
6946allocate<void> (size_t);
6947@end smallexample
6948
6949@item -Wmissing-braces
6950@opindex Wmissing-braces
6951@opindex Wno-missing-braces
6952Warn if an aggregate or union initializer is not fully bracketed. In
6953the following example, the initializer for @code{a} is not fully
6954bracketed, but that for @code{b} is fully bracketed.
6955
6956@smallexample
6957int a[2][2] = @{ 0, 1, 2, 3 @};
6958int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
6959@end smallexample
6960
6961This warning is enabled by @option{-Wall}.
6962
6963@item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
6964@opindex Wmissing-include-dirs
6965@opindex Wno-missing-include-dirs
6966Warn if a user-supplied include directory does not exist. This opions is disabled
6967by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
6968enabled by default by warning for -I and -J, only.
6969
6970@item -Wno-missing-profile
6971@opindex Wmissing-profile
6972@opindex Wno-missing-profile
6973This option controls warnings if feedback profiles are missing when using the
6974@option{-fprofile-use} option.
6975This option diagnoses those cases where a new function or a new file is added
6976between compiling with @option{-fprofile-generate} and with
6977@option{-fprofile-use}, without regenerating the profiles.
6978In these cases, the profile feedback data files do not contain any
6979profile feedback information for
6980the newly added function or file respectively. Also, in the case when profile
6981count data (.gcda) files are removed, GCC cannot use any profile feedback
6982information. In all these cases, warnings are issued to inform you that a
6983profile generation step is due.
6984Ignoring the warning can result in poorly optimized code.
6985@option{-Wno-missing-profile} can be used to
6986disable the warning, but this is not recommended and should be done only
6987when non-existent profile data is justified.
6988
6989@item -Wmismatched-dealloc
6990@opindex Wmismatched-dealloc
6991@opindex Wno-mismatched-dealloc
6992
6993Warn for calls to deallocation functions with pointer arguments returned
6994from from allocations functions for which the former isn't a suitable
6995deallocator. A pair of functions can be associated as matching allocators
6996and deallocators by use of attribute @code{malloc}. Unless disabled by
6997the @option{-fno-builtin} option the standard functions @code{calloc},
6998@code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
6999forms of C++ @code{operator new} and @code{operator delete} are implicitly
7000associated as matching allocators and deallocators. In the following
7001example @code{mydealloc} is the deallocator for pointers returned from
7002@code{myalloc}.
7003
7004@smallexample
7005void mydealloc (void*);
7006
7007__attribute__ ((malloc (mydealloc, 1))) void*
7008myalloc (size_t);
7009
7010void f (void)
7011@{
7012 void *p = myalloc (32);
7013 // @dots{}use p@dots{}
7014 free (p); // warning: not a matching deallocator for myalloc
7015 mydealloc (p); // ok
7016@}
7017@end smallexample
7018
7019In C++, the related option @option{-Wmismatched-new-delete} diagnoses
7020mismatches involving either @code{operator new} or @code{operator delete}.
7021
7022Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
7023
7024@item -Wmultistatement-macros
7025@opindex Wmultistatement-macros
7026@opindex Wno-multistatement-macros
7027Warn about unsafe multiple statement macros that appear to be guarded
7028by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
7029@code{while}, in which only the first statement is actually guarded after
7030the macro is expanded.
7031
7032For example:
7033
7034@smallexample
7035#define DOIT x++; y++
7036if (c)
7037 DOIT;
7038@end smallexample
7039
7040will increment @code{y} unconditionally, not just when @code{c} holds.
7041The can usually be fixed by wrapping the macro in a do-while loop:
7042@smallexample
7043#define DOIT do @{ x++; y++; @} while (0)
7044if (c)
7045 DOIT;
7046@end smallexample
7047
7048This warning is enabled by @option{-Wall} in C and C++.
7049
7050@item -Wparentheses
7051@opindex Wparentheses
7052@opindex Wno-parentheses
7053Warn if parentheses are omitted in certain contexts, such
7054as when there is an assignment in a context where a truth value
7055is expected, or when operators are nested whose precedence people
7056often get confused about.
7057
7058Also warn if a comparison like @code{x<=y<=z} appears; this is
7059equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
7060interpretation from that of ordinary mathematical notation.
7061
7062Also warn for dangerous uses of the GNU extension to
7063@code{?:} with omitted middle operand. When the condition
7064in the @code{?}: operator is a boolean expression, the omitted value is
7065always 1. Often programmers expect it to be a value computed
7066inside the conditional expression instead.
7067
7068For C++ this also warns for some cases of unnecessary parentheses in
7069declarations, which can indicate an attempt at a function call instead
7070of a declaration:
7071@smallexample
7072@{
7073 // Declares a local variable called mymutex.
7074 std::unique_lock<std::mutex> (mymutex);
7075 // User meant std::unique_lock<std::mutex> lock (mymutex);
7076@}
7077@end smallexample
7078
7079This warning is enabled by @option{-Wall}.
7080
7081@item -Wno-self-move @r{(C++ and Objective-C++ only)}
7082@opindex Wself-move
7083@opindex Wno-self-move
7084This warning warns when a value is moved to itself with @code{std::move}.
7085Such a @code{std::move} typically has no effect.
7086
7087@smallexample
7088struct T @{
7089@dots{}
7090@};
7091void fn()
7092@{
7093 T t;
7094 @dots{}
7095 t = std::move (t);
7096@}
7097@end smallexample
7098
7099This warning is enabled by @option{-Wall}.
7100
7101@item -Wsequence-point
7102@opindex Wsequence-point
7103@opindex Wno-sequence-point
7104Warn about code that may have undefined semantics because of violations
7105of sequence point rules in the C and C++ standards.
7106
7107The C and C++ standards define the order in which expressions in a C/C++
7108program are evaluated in terms of @dfn{sequence points}, which represent
7109a partial ordering between the execution of parts of the program: those
7110executed before the sequence point, and those executed after it. These
7111occur after the evaluation of a full expression (one which is not part
7112of a larger expression), after the evaluation of the first operand of a
7113@code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
7114function is called (but after the evaluation of its arguments and the
7115expression denoting the called function), and in certain other places.
7116Other than as expressed by the sequence point rules, the order of
7117evaluation of subexpressions of an expression is not specified. All
7118these rules describe only a partial order rather than a total order,
7119since, for example, if two functions are called within one expression
7120with no sequence point between them, the order in which the functions
7121are called is not specified. However, the standards committee have
7122ruled that function calls do not overlap.
7123
7124It is not specified when between sequence points modifications to the
7125values of objects take effect. Programs whose behavior depends on this
7126have undefined behavior; the C and C++ standards specify that ``Between
7127the previous and next sequence point an object shall have its stored
7128value modified at most once by the evaluation of an expression.
7129Furthermore, the prior value shall be read only to determine the value
7130to be stored.''. If a program breaks these rules, the results on any
7131particular implementation are entirely unpredictable.
7132
7133Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
7134= b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
7135diagnosed by this option, and it may give an occasional false positive
7136result, but in general it has been found fairly effective at detecting
7137this sort of problem in programs.
7138
7139The C++17 standard will define the order of evaluation of operands in
7140more cases: in particular it requires that the right-hand side of an
7141assignment be evaluated before the left-hand side, so the above
7142examples are no longer undefined. But this option will still warn
7143about them, to help people avoid writing code that is undefined in C
7144and earlier revisions of C++.
7145
7146The standard is worded confusingly, therefore there is some debate
7147over the precise meaning of the sequence point rules in subtle cases.
7148Links to discussions of the problem, including proposed formal
7149definitions, may be found on the GCC readings page, at
7150@uref{https://gcc.gnu.org/@/readings.html}.
7151
7152This warning is enabled by @option{-Wall} for C and C++.
7153
7154@item -Wno-return-local-addr
7155@opindex Wno-return-local-addr
7156@opindex Wreturn-local-addr
7157Do not warn about returning a pointer (or in C++, a reference) to a
7158variable that goes out of scope after the function returns.
7159
7160@item -Wreturn-type
7161@opindex Wreturn-type
7162@opindex Wno-return-type
7163Warn whenever a function is defined with a return type that defaults
7164to @code{int}. Also warn about any @code{return} statement with no
7165return value in a function whose return type is not @code{void}
7166(falling off the end of the function body is considered returning
7167without a value).
7168
7169For C only, warn about a @code{return} statement with an expression in a
7170function whose return type is @code{void}, unless the expression type is
7171also @code{void}. As a GNU extension, the latter case is accepted
7172without a warning unless @option{-Wpedantic} is used. Attempting
7173to use the return value of a non-@code{void} function other than @code{main}
7174that flows off the end by reaching the closing curly brace that terminates
7175the function is undefined.
7176
7177Unlike in C, in C++, flowing off the end of a non-@code{void} function other
7178than @code{main} results in undefined behavior even when the value of
7179the function is not used.
7180
7181This warning is enabled by default in C++ and by @option{-Wall} otherwise.
7182
7183@item -Wno-shift-count-negative
7184@opindex Wshift-count-negative
7185@opindex Wno-shift-count-negative
7186Controls warnings if a shift count is negative.
7187This warning is enabled by default.
7188
7189@item -Wno-shift-count-overflow
7190@opindex Wshift-count-overflow
7191@opindex Wno-shift-count-overflow
7192Controls warnings if a shift count is greater than or equal to the bit width
7193of the type. This warning is enabled by default.
7194
7195@item -Wshift-negative-value
7196@opindex Wshift-negative-value
7197@opindex Wno-shift-negative-value
7198Warn if left shifting a negative value. This warning is enabled by
7199@option{-Wextra} in C99 (and newer) and C++11 to C++17 modes.
7200
7201@item -Wno-shift-overflow
7202@itemx -Wshift-overflow=@var{n}
7203@opindex Wshift-overflow
7204@opindex Wno-shift-overflow
7205These options control warnings about left shift overflows.
7206
7207@table @gcctabopt
7208@item -Wshift-overflow=1
7209This is the warning level of @option{-Wshift-overflow} and is enabled
7210by default in C99 and C++11 modes (and newer). This warning level does
7211not warn about left-shifting 1 into the sign bit. (However, in C, such
7212an overflow is still rejected in contexts where an integer constant expression
7213is required.) No warning is emitted in C++20 mode (and newer), as signed left
7214shifts always wrap.
7215
7216@item -Wshift-overflow=2
7217This warning level also warns about left-shifting 1 into the sign bit,
7218unless C++14 mode (or newer) is active.
7219@end table
7220
7221@item -Wswitch
7222@opindex Wswitch
7223@opindex Wno-switch
7224Warn whenever a @code{switch} statement has an index of enumerated type
7225and lacks a @code{case} for one or more of the named codes of that
7226enumeration. (The presence of a @code{default} label prevents this
7227warning.) @code{case} labels outside the enumeration range also
7228provoke warnings when this option is used (even if there is a
7229@code{default} label).
7230This warning is enabled by @option{-Wall}.
7231
7232@item -Wswitch-default
7233@opindex Wswitch-default
7234@opindex Wno-switch-default
7235Warn whenever a @code{switch} statement does not have a @code{default}
7236case.
7237
7238@item -Wswitch-enum
7239@opindex Wswitch-enum
7240@opindex Wno-switch-enum
7241Warn whenever a @code{switch} statement has an index of enumerated type
7242and lacks a @code{case} for one or more of the named codes of that
7243enumeration. @code{case} labels outside the enumeration range also
7244provoke warnings when this option is used. The only difference
7245between @option{-Wswitch} and this option is that this option gives a
7246warning about an omitted enumeration code even if there is a
7247@code{default} label.
7248
7249@item -Wno-switch-bool
7250@opindex Wswitch-bool
7251@opindex Wno-switch-bool
7252Do not warn when a @code{switch} statement has an index of boolean type
7253and the case values are outside the range of a boolean type.
7254It is possible to suppress this warning by casting the controlling
7255expression to a type other than @code{bool}. For example:
7256@smallexample
7257@group
7258switch ((int) (a == 4))
7259 @{
7260 @dots{}
7261 @}
7262@end group
7263@end smallexample
7264This warning is enabled by default for C and C++ programs.
7265
7266@item -Wno-switch-outside-range
7267@opindex Wswitch-outside-range
7268@opindex Wno-switch-outside-range
7269This option controls warnings when a @code{switch} case has a value
7270that is outside of its
7271respective type range. This warning is enabled by default for
7272C and C++ programs.
7273
7274@item -Wno-switch-unreachable
7275@opindex Wswitch-unreachable
7276@opindex Wno-switch-unreachable
7277Do not warn when a @code{switch} statement contains statements between the
7278controlling expression and the first case label, which will never be
7279executed. For example:
7280@smallexample
7281@group
7282switch (cond)
7283 @{
7284 i = 15;
7285 @dots{}
7286 case 5:
7287 @dots{}
7288 @}
7289@end group
7290@end smallexample
7291@option{-Wswitch-unreachable} does not warn if the statement between the
7292controlling expression and the first case label is just a declaration:
7293@smallexample
7294@group
7295switch (cond)
7296 @{
7297 int i;
7298 @dots{}
7299 case 5:
7300 i = 5;
7301 @dots{}
7302 @}
7303@end group
7304@end smallexample
7305This warning is enabled by default for C and C++ programs.
7306
7307@item -Wsync-nand @r{(C and C++ only)}
7308@opindex Wsync-nand
7309@opindex Wno-sync-nand
7310Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
7311built-in functions are used. These functions changed semantics in GCC 4.4.
7312
7313@item -Wtrivial-auto-var-init
7314@opindex Wtrivial-auto-var-init
7315@opindex Wno-trivial-auto-var-init
7316Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic
7317variable. A common situation is an automatic variable that is declared
7318between the controlling expression and the first case label of a @code{switch}
7319statement.
7320
7321@item -Wunused-but-set-parameter
7322@opindex Wunused-but-set-parameter
7323@opindex Wno-unused-but-set-parameter
7324Warn whenever a function parameter is assigned to, but otherwise unused
7325(aside from its declaration).
7326
7327To suppress this warning use the @code{unused} attribute
7328(@pxref{Variable Attributes}).
7329
7330This warning is also enabled by @option{-Wunused} together with
7331@option{-Wextra}.
7332
7333@item -Wunused-but-set-variable
7334@opindex Wunused-but-set-variable
7335@opindex Wno-unused-but-set-variable
7336Warn whenever a local variable is assigned to, but otherwise unused
7337(aside from its declaration).
7338This warning is enabled by @option{-Wall}.
7339
7340To suppress this warning use the @code{unused} attribute
7341(@pxref{Variable Attributes}).
7342
7343This warning is also enabled by @option{-Wunused}, which is enabled
7344by @option{-Wall}.
7345
7346@item -Wunused-function
7347@opindex Wunused-function
7348@opindex Wno-unused-function
7349Warn whenever a static function is declared but not defined or a
7350non-inline static function is unused.
7351This warning is enabled by @option{-Wall}.
7352
7353@item -Wunused-label
7354@opindex Wunused-label
7355@opindex Wno-unused-label
7356Warn whenever a label is declared but not used.
7357This warning is enabled by @option{-Wall}.
7358
7359To suppress this warning use the @code{unused} attribute
7360(@pxref{Variable Attributes}).
7361
7362@item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
7363@opindex Wunused-local-typedefs
7364@opindex Wno-unused-local-typedefs
7365Warn when a typedef locally defined in a function is not used.
7366This warning is enabled by @option{-Wall}.
7367
7368@item -Wunused-parameter
7369@opindex Wunused-parameter
7370@opindex Wno-unused-parameter
7371Warn whenever a function parameter is unused aside from its declaration.
7372
7373To suppress this warning use the @code{unused} attribute
7374(@pxref{Variable Attributes}).
7375
7376@item -Wno-unused-result
7377@opindex Wunused-result
7378@opindex Wno-unused-result
7379Do not warn if a caller of a function marked with attribute
7380@code{warn_unused_result} (@pxref{Function Attributes}) does not use
7381its return value. The default is @option{-Wunused-result}.
7382
7383@item -Wunused-variable
7384@opindex Wunused-variable
7385@opindex Wno-unused-variable
7386Warn whenever a local or static variable is unused aside from its
7387declaration. This option implies @option{-Wunused-const-variable=1} for C,
7388but not for C++. This warning is enabled by @option{-Wall}.
7389
7390To suppress this warning use the @code{unused} attribute
7391(@pxref{Variable Attributes}).
7392
7393@item -Wunused-const-variable
7394@itemx -Wunused-const-variable=@var{n}
7395@opindex Wunused-const-variable
7396@opindex Wno-unused-const-variable
7397Warn whenever a constant static variable is unused aside from its declaration.
7398@option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable}
7399for C, but not for C++. In C this declares variable storage, but in C++ this
7400is not an error since const variables take the place of @code{#define}s.
7401
7402To suppress this warning use the @code{unused} attribute
7403(@pxref{Variable Attributes}).
7404
7405@table @gcctabopt
7406@item -Wunused-const-variable=1
7407This is the warning level that is enabled by @option{-Wunused-variable} for
7408C. It warns only about unused static const variables defined in the main
7409compilation unit, but not about static const variables declared in any
7410header included.
7411
7412@item -Wunused-const-variable=2
7413This warning level also warns for unused constant static variables in
7414headers (excluding system headers). This is the warning level of
7415@option{-Wunused-const-variable} and must be explicitly requested since
7416in C++ this isn't an error and in C it might be harder to clean up all
7417headers included.
7418@end table
7419
7420@item -Wunused-value
7421@opindex Wunused-value
7422@opindex Wno-unused-value
7423Warn whenever a statement computes a result that is explicitly not
7424used. To suppress this warning cast the unused expression to
7425@code{void}. This includes an expression-statement or the left-hand
7426side of a comma expression that contains no side effects. For example,
7427an expression such as @code{x[i,j]} causes a warning, while
7428@code{x[(void)i,j]} does not.
7429
7430This warning is enabled by @option{-Wall}.
7431
7432@item -Wunused
7433@opindex Wunused
7434@opindex Wno-unused
7435All the above @option{-Wunused} options combined.
7436
7437In order to get a warning about an unused function parameter, you must
7438either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
7439@option{-Wunused}), or separately specify @option{-Wunused-parameter}.
7440
7441@item -Wuninitialized
7442@opindex Wuninitialized
7443@opindex Wno-uninitialized
7444Warn if an object with automatic or allocated storage duration is used
7445without having been initialized. In C++, also warn if a non-static
7446reference or non-static @code{const} member appears in a class without
7447constructors.
7448
7449In addition, passing a pointer (or in C++, a reference) to an uninitialized
7450object to a @code{const}-qualified argument of a built-in function known to
7451read the object is also diagnosed by this warning.
7452(@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
7453
7454If you want to warn about code that uses the uninitialized value of the
7455variable in its own initializer, use the @option{-Winit-self} option.
7456
7457These warnings occur for individual uninitialized elements of
7458structure, union or array variables as well as for variables that are
7459uninitialized as a whole. They do not occur for variables or elements
7460declared @code{volatile}. Because these warnings depend on
7461optimization, the exact variables or elements for which there are
7462warnings depend on the precise optimization options and version of GCC
7463used.
7464
7465Note that there may be no warning about a variable that is used only
7466to compute a value that itself is never used, because such
7467computations may be deleted by data flow analysis before the warnings
7468are printed.
7469
7470In C++, this warning also warns about using uninitialized objects in
7471member-initializer-lists. For example, GCC warns about @code{b} being
7472uninitialized in the following snippet:
7473
7474@smallexample
7475struct A @{
7476 int a;
7477 int b;
7478 A() : a(b) @{ @}
7479@};
7480@end smallexample
7481
7482@item -Wno-invalid-memory-model
7483@opindex Winvalid-memory-model
7484@opindex Wno-invalid-memory-model
7485This option controls warnings
7486for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
7487and the C11 atomic generic functions with a memory consistency argument
7488that is either invalid for the operation or outside the range of values
7489of the @code{memory_order} enumeration. For example, since the
7490@code{__atomic_store} and @code{__atomic_store_n} built-ins are only
7491defined for the relaxed, release, and sequentially consistent memory
7492orders the following code is diagnosed:
7493
7494@smallexample
7495void store (int *i)
7496@{
7497 __atomic_store_n (i, 0, memory_order_consume);
7498@}
7499@end smallexample
7500
7501@option{-Winvalid-memory-model} is enabled by default.
7502
7503@item -Wmaybe-uninitialized
7504@opindex Wmaybe-uninitialized
7505@opindex Wno-maybe-uninitialized
7506For an object with automatic or allocated storage duration, if there exists
7507a path from the function entry to a use of the object that is initialized,
7508but there exist some other paths for which the object is not initialized,
7509the compiler emits a warning if it cannot prove the uninitialized paths
7510are not executed at run time.
7511
7512In addition, passing a pointer (or in C++, a reference) to an uninitialized
7513object to a @code{const}-qualified function argument is also diagnosed by
7514this warning. (@option{-Wuninitialized} is issued for built-in functions
7515known to read the object.) Annotating the function with attribute
7516@code{access (none)} indicates that the argument isn't used to access
7517the object and avoids the warning (@pxref{Common Function Attributes}).
7518
7519These warnings are only possible in optimizing compilation, because otherwise
7520GCC does not keep track of the state of variables.
7521
7522These warnings are made optional because GCC may not be able to determine when
7523the code is correct in spite of appearing to have an error. Here is one
7524example of how this can happen:
7525
7526@smallexample
7527@group
7528@{
7529 int x;
7530 switch (y)
7531 @{
7532 case 1: x = 1;
7533 break;
7534 case 2: x = 4;
7535 break;
7536 case 3: x = 5;
7537 @}
7538 foo (x);
7539@}
7540@end group
7541@end smallexample
7542
7543@noindent
7544If the value of @code{y} is always 1, 2 or 3, then @code{x} is
7545always initialized, but GCC doesn't know this. To suppress the
7546warning, you need to provide a default case with assert(0) or
7547similar code.
7548
7549@cindex @code{longjmp} warnings
7550This option also warns when a non-volatile automatic variable might be
7551changed by a call to @code{longjmp}.
7552The compiler sees only the calls to @code{setjmp}. It cannot know
7553where @code{longjmp} will be called; in fact, a signal handler could
7554call it at any point in the code. As a result, you may get a warning
7555even when there is in fact no problem because @code{longjmp} cannot
7556in fact be called at the place that would cause a problem.
7557
7558Some spurious warnings can be avoided if you declare all the functions
7559you use that never return as @code{noreturn}. @xref{Function
7560Attributes}.
7561
7562This warning is enabled by @option{-Wall} or @option{-Wextra}.
7563
7564@item -Wunknown-pragmas
7565@opindex Wunknown-pragmas
7566@opindex Wno-unknown-pragmas
7567@cindex warning for unknown pragmas
7568@cindex unknown pragmas, warning
7569@cindex pragmas, warning of unknown
7570Warn when a @code{#pragma} directive is encountered that is not understood by
7571GCC@. If this command-line option is used, warnings are even issued
7572for unknown pragmas in system header files. This is not the case if
7573the warnings are only enabled by the @option{-Wall} command-line option.
7574
7575@item -Wno-pragmas
7576@opindex Wno-pragmas
7577@opindex Wpragmas
7578Do not warn about misuses of pragmas, such as incorrect parameters,
7579invalid syntax, or conflicts between pragmas. See also
7580@option{-Wunknown-pragmas}.
7581
7582@item -Wno-prio-ctor-dtor
7583@opindex Wno-prio-ctor-dtor
7584@opindex Wprio-ctor-dtor
7585Do not warn if a priority from 0 to 100 is used for constructor or destructor.
7586The use of constructor and destructor attributes allow you to assign a
7587priority to the constructor/destructor to control its order of execution
7588before @code{main} is called or after it returns. The priority values must be
7589greater than 100 as the compiler reserves priority values between 0--100 for
7590the implementation.
7591
7592@item -Wstrict-aliasing
7593@opindex Wstrict-aliasing
7594@opindex Wno-strict-aliasing
7595This option is only active when @option{-fstrict-aliasing} is active.
7596It warns about code that might break the strict aliasing rules that the
7597compiler is using for optimization. The warning does not catch all
7598cases, but does attempt to catch the more common pitfalls. It is
7599included in @option{-Wall}.
7600It is equivalent to @option{-Wstrict-aliasing=3}
7601
7602@item -Wstrict-aliasing=n
7603@opindex Wstrict-aliasing=n
7604This option is only active when @option{-fstrict-aliasing} is active.
7605It warns about code that might break the strict aliasing rules that the
7606compiler is using for optimization.
7607Higher levels correspond to higher accuracy (fewer false positives).
7608Higher levels also correspond to more effort, similar to the way @option{-O}
7609works.
7610@option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
7611
7612Level 1: Most aggressive, quick, least accurate.
7613Possibly useful when higher levels
7614do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
7615false negatives. However, it has many false positives.
7616Warns for all pointer conversions between possibly incompatible types,
7617even if never dereferenced. Runs in the front end only.
7618
7619Level 2: Aggressive, quick, not too precise.
7620May still have many false positives (not as many as level 1 though),
7621and few false negatives (but possibly more than level 1).
7622Unlike level 1, it only warns when an address is taken. Warns about
7623incomplete types. Runs in the front end only.
7624
7625Level 3 (default for @option{-Wstrict-aliasing}):
7626Should have very few false positives and few false
7627negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
7628Takes care of the common pun+dereference pattern in the front end:
7629@code{*(int*)&some_float}.
7630If optimization is enabled, it also runs in the back end, where it deals
7631with multiple statement cases using flow-sensitive points-to information.
7632Only warns when the converted pointer is dereferenced.
7633Does not warn about incomplete types.
7634
7635@item -Wstrict-overflow
7636@itemx -Wstrict-overflow=@var{n}
7637@opindex Wstrict-overflow
7638@opindex Wno-strict-overflow
7639This option is only active when signed overflow is undefined.
7640It warns about cases where the compiler optimizes based on the
7641assumption that signed overflow does not occur. Note that it does not
7642warn about all cases where the code might overflow: it only warns
7643about cases where the compiler implements some optimization. Thus
7644this warning depends on the optimization level.
7645
7646An optimization that assumes that signed overflow does not occur is
7647perfectly safe if the values of the variables involved are such that
7648overflow never does, in fact, occur. Therefore this warning can
7649easily give a false positive: a warning about code that is not
7650actually a problem. To help focus on important issues, several
7651warning levels are defined. No warnings are issued for the use of
7652undefined signed overflow when estimating how many iterations a loop
7653requires, in particular when determining whether a loop will be
7654executed at all.
7655
7656@table @gcctabopt
7657@item -Wstrict-overflow=1
7658Warn about cases that are both questionable and easy to avoid. For
7659example the compiler simplifies
7660@code{x + 1 > x} to @code{1}. This level of
7661@option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
7662are not, and must be explicitly requested.
7663
7664@item -Wstrict-overflow=2
7665Also warn about other cases where a comparison is simplified to a
7666constant. For example: @code{abs (x) >= 0}. This can only be
7667simplified when signed integer overflow is undefined, because
7668@code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
7669zero. @option{-Wstrict-overflow} (with no level) is the same as
7670@option{-Wstrict-overflow=2}.
7671
7672@item -Wstrict-overflow=3
7673Also warn about other cases where a comparison is simplified. For
7674example: @code{x + 1 > 1} is simplified to @code{x > 0}.
7675
7676@item -Wstrict-overflow=4
7677Also warn about other simplifications not covered by the above cases.
7678For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
7679
7680@item -Wstrict-overflow=5
7681Also warn about cases where the compiler reduces the magnitude of a
7682constant involved in a comparison. For example: @code{x + 2 > y} is
7683simplified to @code{x + 1 >= y}. This is reported only at the
7684highest warning level because this simplification applies to many
7685comparisons, so this warning level gives a very large number of
7686false positives.
7687@end table
7688
7689@item -Wstring-compare
7690@opindex Wstring-compare
7691@opindex Wno-string-compare
7692Warn for calls to @code{strcmp} and @code{strncmp} whose result is
7693determined to be either zero or non-zero in tests for such equality
7694owing to the length of one argument being greater than the size of
7695the array the other argument is stored in (or the bound in the case
7696of @code{strncmp}). Such calls could be mistakes. For example,
7697the call to @code{strcmp} below is diagnosed because its result is
7698necessarily non-zero irrespective of the contents of the array @code{a}.
7699
7700@smallexample
7701extern char a[4];
7702void f (char *d)
7703@{
7704 strcpy (d, "string");
7705 @dots{}
7706 if (0 == strcmp (a, d)) // cannot be true
7707 puts ("a and d are the same");
7708@}
7709@end smallexample
7710
7711@option{-Wstring-compare} is enabled by @option{-Wextra}.
7712
7713@item -Wno-stringop-overflow
7714@item -Wstringop-overflow
7715@itemx -Wstringop-overflow=@var{type}
7716@opindex Wstringop-overflow
7717@opindex Wno-stringop-overflow
7718Warn for calls to string manipulation functions such as @code{memcpy} and
7719@code{strcpy} that are determined to overflow the destination buffer. The
7720optional argument is one greater than the type of Object Size Checking to
7721perform to determine the size of the destination. @xref{Object Size Checking}.
7722The argument is meaningful only for functions that operate on character arrays
7723but not for raw memory functions like @code{memcpy} which always make use
7724of Object Size type-0. The option also warns for calls that specify a size
7725in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
7726The option produces the best results with optimization enabled but can detect
7727a small subset of simple buffer overflows even without optimization in
7728calls to the GCC built-in functions like @code{__builtin_memcpy} that
7729correspond to the standard functions. In any case, the option warns about
7730just a subset of buffer overflows detected by the corresponding overflow
7731checking built-ins. For example, the option issues a warning for
7732the @code{strcpy} call below because it copies at least 5 characters
7733(the string @code{"blue"} including the terminating NUL) into the buffer
7734of size 4.
7735
7736@smallexample
7737enum Color @{ blue, purple, yellow @};
7738const char* f (enum Color clr)
7739@{
7740 static char buf [4];
7741 const char *str;
7742 switch (clr)
7743 @{
7744 case blue: str = "blue"; break;
7745 case purple: str = "purple"; break;
7746 case yellow: str = "yellow"; break;
7747 @}
7748
7749 return strcpy (buf, str); // warning here
7750@}
7751@end smallexample
7752
7753Option @option{-Wstringop-overflow=2} is enabled by default.
7754
7755@table @gcctabopt
7756@item -Wstringop-overflow
7757@itemx -Wstringop-overflow=1
7758@opindex Wstringop-overflow
7759@opindex Wno-stringop-overflow
7760The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
7761to determine the sizes of destination objects. At this setting the option
7762does not warn for writes past the end of subobjects of larger objects accessed
7763by pointers unless the size of the largest surrounding object is known. When
7764the destination may be one of several objects it is assumed to be the largest
7765one of them. On Linux systems, when optimization is enabled at this setting
7766the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
7767is defined to a non-zero value.
7768
7769@item -Wstringop-overflow=2
7770The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
7771to determine the sizes of destination objects. At this setting the option
7772warns about overflows when writing to members of the largest complete
7773objects whose exact size is known. However, it does not warn for excessive
7774writes to the same members of unknown objects referenced by pointers since
7775they may point to arrays containing unknown numbers of elements. This is
7776the default setting of the option.
7777
7778@item -Wstringop-overflow=3
7779The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
7780to determine the sizes of destination objects. At this setting the option
7781warns about overflowing the smallest object or data member. This is the
7782most restrictive setting of the option that may result in warnings for safe
7783code.
7784
7785@item -Wstringop-overflow=4
7786The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
7787to determine the sizes of destination objects. At this setting the option
7788warns about overflowing any data members, and when the destination is
7789one of several objects it uses the size of the largest of them to decide
7790whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
7791setting of the option may result in warnings for benign code.
7792@end table
7793
7794@item -Wno-stringop-overread
7795@opindex Wstringop-overread
7796@opindex Wno-stringop-overread
7797Warn for calls to string manipulation functions such as @code{memchr}, or
7798@code{strcpy} that are determined to read past the end of the source
7799sequence.
7800
7801Option @option{-Wstringop-overread} is enabled by default.
7802
7803@item -Wno-stringop-truncation
7804@opindex Wstringop-truncation
7805@opindex Wno-stringop-truncation
7806Do not warn for calls to bounded string manipulation functions
7807such as @code{strncat},
7808@code{strncpy}, and @code{stpncpy} that may either truncate the copied string
7809or leave the destination unchanged.
7810
7811In the following example, the call to @code{strncat} specifies a bound that
7812is less than the length of the source string. As a result, the copy of
7813the source will be truncated and so the call is diagnosed. To avoid the
7814warning use @code{bufsize - strlen (buf) - 1)} as the bound.
7815
7816@smallexample
7817void append (char *buf, size_t bufsize)
7818@{
7819 strncat (buf, ".txt", 3);
7820@}
7821@end smallexample
7822
7823As another example, the following call to @code{strncpy} results in copying
7824to @code{d} just the characters preceding the terminating NUL, without
7825appending the NUL to the end. Assuming the result of @code{strncpy} is
7826necessarily a NUL-terminated string is a common mistake, and so the call
7827is diagnosed. To avoid the warning when the result is not expected to be
7828NUL-terminated, call @code{memcpy} instead.
7829
7830@smallexample
7831void copy (char *d, const char *s)
7832@{
7833 strncpy (d, s, strlen (s));
7834@}
7835@end smallexample
7836
7837In the following example, the call to @code{strncpy} specifies the size
7838of the destination buffer as the bound. If the length of the source
7839string is equal to or greater than this size the result of the copy will
7840not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
7841the warning, specify @code{sizeof buf - 1} as the bound and set the last
7842element of the buffer to @code{NUL}.
7843
7844@smallexample
7845void copy (const char *s)
7846@{
7847 char buf[80];
7848 strncpy (buf, s, sizeof buf);
7849 @dots{}
7850@}
7851@end smallexample
7852
7853In situations where a character array is intended to store a sequence
7854of bytes with no terminating @code{NUL} such an array may be annotated
7855with attribute @code{nonstring} to avoid this warning. Such arrays,
7856however, are not suitable arguments to functions that expect
7857@code{NUL}-terminated strings. To help detect accidental misuses of
7858such arrays GCC issues warnings unless it can prove that the use is
7859safe. @xref{Common Variable Attributes}.
7860
2a27ae32
QZ
7861@item -Wstrict-flex-arrays
7862@opindex Wstrict-flex-arrays
7863@opindex Wno-strict-flex-arrays
7864Warn about inproper usages of flexible array members
7865according to the @var{level} of the @code{strict_flex_array (@var{level})}
7866attribute attached to the trailing array field of a structure if it's
7867available, otherwise according to the @var{level} of the option
7868@option{-fstrict-flex-arrays=@var{level}}.
7869
7870This option is effective only when @var{level} is bigger than 0. Otherwise,
7871it will be ignored with a warning.
7872
7873when @var{level}=1, warnings will be issued for a trailing array reference
7874of a structure that have 2 or more elements if the trailing array is referenced
7875as a flexible array member.
7876
7877when @var{level}=2, in addition to @var{level}=1, additional warnings will be
7878issued for a trailing one-element array reference of a structure
7879if the array is referenced as a flexible array member.
7880
7881when @var{level}=3, in addition to @var{level}=2, additional warnings will be
7882issued for a trailing zero-length array reference of a structure
7883if the array is referenced as a flexible array member.
7884
7885
d77de738
ML
7886@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}
7887@opindex Wsuggest-attribute=
7888@opindex Wno-suggest-attribute=
7889Warn for cases where adding an attribute may be beneficial. The
7890attributes currently supported are listed below.
7891
7892@table @gcctabopt
7893@item -Wsuggest-attribute=pure
7894@itemx -Wsuggest-attribute=const
7895@itemx -Wsuggest-attribute=noreturn
7896@itemx -Wmissing-noreturn
7897@itemx -Wsuggest-attribute=malloc
7898@opindex Wsuggest-attribute=pure
7899@opindex Wno-suggest-attribute=pure
7900@opindex Wsuggest-attribute=const
7901@opindex Wno-suggest-attribute=const
7902@opindex Wsuggest-attribute=noreturn
7903@opindex Wno-suggest-attribute=noreturn
7904@opindex Wmissing-noreturn
7905@opindex Wno-missing-noreturn
7906@opindex Wsuggest-attribute=malloc
7907@opindex Wno-suggest-attribute=malloc
7908
7909Warn about functions that might be candidates for attributes
7910@code{pure}, @code{const} or @code{noreturn} or @code{malloc}. The compiler
7911only warns for functions visible in other compilation units or (in the case of
7912@code{pure} and @code{const}) if it cannot prove that the function returns
7913normally. A function returns normally if it doesn't contain an infinite loop or
7914return abnormally by throwing, calling @code{abort} or trapping. This analysis
7915requires option @option{-fipa-pure-const}, which is enabled by default at
7916@option{-O} and higher. Higher optimization levels improve the accuracy
7917of the analysis.
7918
7919@item -Wsuggest-attribute=format
7920@itemx -Wmissing-format-attribute
7921@opindex Wsuggest-attribute=format
7922@opindex Wmissing-format-attribute
7923@opindex Wno-suggest-attribute=format
7924@opindex Wno-missing-format-attribute
7925@opindex Wformat
7926@opindex Wno-format
7927
7928Warn about function pointers that might be candidates for @code{format}
7929attributes. Note these are only possible candidates, not absolute ones.
7930GCC guesses that function pointers with @code{format} attributes that
7931are used in assignment, initialization, parameter passing or return
7932statements should have a corresponding @code{format} attribute in the
7933resulting type. I.e.@: the left-hand side of the assignment or
7934initialization, the type of the parameter variable, or the return type
7935of the containing function respectively should also have a @code{format}
7936attribute to avoid the warning.
7937
7938GCC also warns about function definitions that might be
7939candidates for @code{format} attributes. Again, these are only
7940possible candidates. GCC guesses that @code{format} attributes
7941might be appropriate for any function that calls a function like
7942@code{vprintf} or @code{vscanf}, but this might not always be the
7943case, and some functions for which @code{format} attributes are
7944appropriate may not be detected.
7945
7946@item -Wsuggest-attribute=cold
7947@opindex Wsuggest-attribute=cold
7948@opindex Wno-suggest-attribute=cold
7949
7950Warn about functions that might be candidates for @code{cold} attribute. This
7951is based on static detection and generally only warns about functions which
7952always leads to a call to another @code{cold} function such as wrappers of
7953C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
7954@end table
7955
7956@item -Walloc-zero
7957@opindex Wno-alloc-zero
7958@opindex Walloc-zero
7959Warn about calls to allocation functions decorated with attribute
7960@code{alloc_size} that specify zero bytes, including those to the built-in
7961forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
7962@code{malloc}, and @code{realloc}. Because the behavior of these functions
7963when called with a zero size differs among implementations (and in the case
7964of @code{realloc} has been deprecated) relying on it may result in subtle
7965portability bugs and should be avoided.
7966
7967@item -Walloc-size-larger-than=@var{byte-size}
7968@opindex Walloc-size-larger-than=
7969@opindex Wno-alloc-size-larger-than
7970Warn about calls to functions decorated with attribute @code{alloc_size}
7971that attempt to allocate objects larger than the specified number of bytes,
7972or where the result of the size computation in an integer type with infinite
7973precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
7974@option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
7975Warnings controlled by the option can be disabled either by specifying
7976@var{byte-size} of @samp{SIZE_MAX} or more or by
7977@option{-Wno-alloc-size-larger-than}.
7978@xref{Function Attributes}.
7979
7980@item -Wno-alloc-size-larger-than
7981@opindex Wno-alloc-size-larger-than
7982Disable @option{-Walloc-size-larger-than=} warnings. The option is
7983equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
7984larger.
7985
7986@item -Walloca
7987@opindex Wno-alloca
7988@opindex Walloca
7989This option warns on all uses of @code{alloca} in the source.
7990
7991@item -Walloca-larger-than=@var{byte-size}
7992@opindex Walloca-larger-than=
7993@opindex Wno-alloca-larger-than
7994This option warns on calls to @code{alloca} with an integer argument whose
7995value is either zero, or that is not bounded by a controlling predicate
7996that limits its value to at most @var{byte-size}. It also warns for calls
7997to @code{alloca} where the bound value is unknown. Arguments of non-integer
7998types are considered unbounded even if they appear to be constrained to
7999the expected range.
8000
8001For example, a bounded case of @code{alloca} could be:
8002
8003@smallexample
8004void func (size_t n)
8005@{
8006 void *p;
8007 if (n <= 1000)
8008 p = alloca (n);
8009 else
8010 p = malloc (n);
8011 f (p);
8012@}
8013@end smallexample
8014
8015In the above example, passing @code{-Walloca-larger-than=1000} would not
8016issue a warning because the call to @code{alloca} is known to be at most
80171000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
8018the compiler would emit a warning.
8019
8020Unbounded uses, on the other hand, are uses of @code{alloca} with no
8021controlling predicate constraining its integer argument. For example:
8022
8023@smallexample
8024void func ()
8025@{
8026 void *p = alloca (n);
8027 f (p);
8028@}
8029@end smallexample
8030
8031If @code{-Walloca-larger-than=500} were passed, the above would trigger
8032a warning, but this time because of the lack of bounds checking.
8033
8034Note, that even seemingly correct code involving signed integers could
8035cause a warning:
8036
8037@smallexample
8038void func (signed int n)
8039@{
8040 if (n < 500)
8041 @{
8042 p = alloca (n);
8043 f (p);
8044 @}
8045@}
8046@end smallexample
8047
8048In the above example, @var{n} could be negative, causing a larger than
8049expected argument to be implicitly cast into the @code{alloca} call.
8050
8051This option also warns when @code{alloca} is used in a loop.
8052
8053@option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
8054but is usually only effective when @option{-ftree-vrp} is active (default
8055for @option{-O2} and above).
8056
8057See also @option{-Wvla-larger-than=}@samp{byte-size}.
8058
8059@item -Wno-alloca-larger-than
8060@opindex Wno-alloca-larger-than
8061Disable @option{-Walloca-larger-than=} warnings. The option is
8062equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
8063
8064@item -Warith-conversion
8065@opindex Warith-conversion
8066@opindex Wno-arith-conversion
8067Do warn about implicit conversions from arithmetic operations even
8068when conversion of the operands to the same type cannot change their
8069values. This affects warnings from @option{-Wconversion},
8070@option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
8071
8072@smallexample
8073@group
8074void f (char c, int i)
8075@{
8076 c = c + i; // warns with @option{-Wconversion}
8077 c = c + 1; // only warns with @option{-Warith-conversion}
8078@}
8079@end group
8080@end smallexample
8081
8082@item -Warray-bounds
8083@itemx -Warray-bounds=@var{n}
8084@opindex Wno-array-bounds
8085@opindex Warray-bounds
8086Warn about out of bounds subscripts or offsets into arrays. This warning
8087is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp}
8088is active (the default for @option{-O2} and above) but a subset of instances
8089are issued even without optimization.
8090
710c9676
QZ
8091By default, the trailing array of a structure will be treated as a flexible
8092array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}}
8093if it is declared as either a flexible array member per C99 standard onwards
8094(@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element
8095array (@samp{[1]}). As a result, out of bounds subscripts or offsets into
8096zero-length arrays or one-element arrays are not warned by default.
8097
8098You can add the option @option{-fstrict-flex-arrays} or
8099@option{-fstrict-flex-arrays=@var{level}} to control how this
8100option treat trailing array of a structure as a flexible array member:
8101
8102when @var{level}<=1, no change to the default behavior.
8103
8104when @var{level}=2, additional warnings will be issued for out of bounds
8105subscripts or offsets into one-element arrays;
8106
8107when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8108issued for out of bounds subscripts or offsets into zero-length arrays.
8109
d77de738
ML
8110@table @gcctabopt
8111@item -Warray-bounds=1
8112This is the default warning level of @option{-Warray-bounds} and is enabled
8113by @option{-Wall}; higher levels are not, and must be explicitly requested.
8114
8115@item -Warray-bounds=2
710c9676
QZ
8116This warning level also warns about the intermediate results of pointer
8117arithmetic that may yield out of bounds values. This warning level may
8118give a larger number of false positives and is deactivated by default.
d77de738
ML
8119@end table
8120
8121@item -Warray-compare
8122@opindex Warray-compare
8123@opindex Wno-array-compare
8124Warn about equality and relational comparisons between two operands of array
8125type. This comparison was deprecated in C++20. For example:
8126
8127@smallexample
8128int arr1[5];
8129int arr2[5];
8130bool same = arr1 == arr2;
8131@end smallexample
8132
8133@option{-Warray-compare} is enabled by @option{-Wall}.
8134
8135@item -Warray-parameter
8136@itemx -Warray-parameter=@var{n}
8137@opindex Wno-array-parameter
8138Warn about redeclarations of functions involving arguments of array or
8139pointer types of inconsistent kinds or forms, and enable the detection
8140of out-of-bounds accesses to such parameters by warnings such as
8141@option{-Warray-bounds}.
8142
8143If the first function declaration uses the array form the bound specified
8144in the array is assumed to be the minimum number of elements expected to
8145be provided in calls to the function and the maximum number of elements
8146accessed by it. Failing to provide arguments of sufficient size or accessing
8147more than the maximum number of elements may be diagnosed by warnings such
8148as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies
8149involving array parameters declared using the @code{T[static N]} form.
8150
8151For example, the warning triggers for the following redeclarations because
8152the first one allows an array of any size to be passed to @code{f} while
8153the second one with the keyword @code{static} specifies that the array
8154argument must have at least four elements.
8155
8156@smallexample
8157void f (int[static 4]);
8158void f (int[]); // warning (inconsistent array form)
8159
8160void g (void)
8161@{
8162 int *p = (int *)malloc (4);
8163 f (p); // warning (array too small)
8164 @dots{}
8165@}
8166@end smallexample
8167
8168At level 2 the warning also triggers for redeclarations involving any other
8169inconsistency in array or pointer argument forms denoting array sizes.
8170Pointers and arrays of unspecified bound are considered equivalent and do
8171not trigger a warning.
8172
8173@smallexample
8174void g (int*);
8175void g (int[]); // no warning
8176void g (int[8]); // warning (inconsistent array bound)
8177@end smallexample
8178
8179@option{-Warray-parameter=2} is included in @option{-Wall}. The
8180@option{-Wvla-parameter} option triggers warnings for similar inconsistencies
8181involving Variable Length Array arguments.
8182
8183@item -Wattribute-alias=@var{n}
8184@itemx -Wno-attribute-alias
8185@opindex Wattribute-alias
8186@opindex Wno-attribute-alias
8187Warn about declarations using the @code{alias} and similar attributes whose
8188target is incompatible with the type of the alias.
8189@xref{Function Attributes,,Declaring Attributes of Functions}.
8190
8191@table @gcctabopt
8192@item -Wattribute-alias=1
8193The default warning level of the @option{-Wattribute-alias} option diagnoses
8194incompatibilities between the type of the alias declaration and that of its
8195target. Such incompatibilities are typically indicative of bugs.
8196
8197@item -Wattribute-alias=2
8198
8199At this level @option{-Wattribute-alias} also diagnoses cases where
8200the attributes of the alias declaration are more restrictive than the
8201attributes applied to its target. These mismatches can potentially
8202result in incorrect code generation. In other cases they may be
8203benign and could be resolved simply by adding the missing attribute to
8204the target. For comparison, see the @option{-Wmissing-attributes}
8205option, which controls diagnostics when the alias declaration is less
8206restrictive than the target, rather than more restrictive.
8207
8208Attributes considered include @code{alloc_align}, @code{alloc_size},
8209@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
8210@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
8211@code{returns_nonnull}, and @code{returns_twice}.
8212@end table
8213
8214@option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
8215This is the default. You can disable these warnings with either
8216@option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
8217
8218@item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
8219@opindex Wbidi-chars=
8220@opindex Wbidi-chars
8221@opindex Wno-bidi-chars
8222Warn about possibly misleading UTF-8 bidirectional control characters in
8223comments, string literals, character constants, and identifiers. Such
8224characters can change left-to-right writing direction into right-to-left
8225(and vice versa), which can cause confusion between the logical order and
8226visual order. This may be dangerous; for instance, it may seem that a piece
8227of code is not commented out, whereas it in fact is.
8228
8229There are three levels of warning supported by GCC@. The default is
8230@option{-Wbidi-chars=unpaired}, which warns about improperly terminated
8231bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
8232@option{-Wbidi-chars=any} warns about any use of bidirectional control
8233characters.
8234
8235By default, this warning does not warn about UCNs. It is, however, possible
8236to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or
8237@option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid,
8238and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous
8239@option{-Wbidi-chars=any} was specified.
8240
8241@item -Wbool-compare
8242@opindex Wno-bool-compare
8243@opindex Wbool-compare
8244Warn about boolean expression compared with an integer value different from
8245@code{true}/@code{false}. For instance, the following comparison is
8246always false:
8247@smallexample
8248int n = 5;
8249@dots{}
8250if ((n > 1) == 2) @{ @dots{} @}
8251@end smallexample
8252This warning is enabled by @option{-Wall}.
8253
8254@item -Wbool-operation
8255@opindex Wno-bool-operation
8256@opindex Wbool-operation
8257Warn about suspicious operations on expressions of a boolean type. For
8258instance, bitwise negation of a boolean is very likely a bug in the program.
8259For C, this warning also warns about incrementing or decrementing a boolean,
8260which rarely makes sense. (In C++, decrementing a boolean is always invalid.
8261Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
8262
8263This warning is enabled by @option{-Wall}.
8264
8265@item -Wduplicated-branches
8266@opindex Wno-duplicated-branches
8267@opindex Wduplicated-branches
8268Warn when an if-else has identical branches. This warning detects cases like
8269@smallexample
8270if (p != NULL)
8271 return 0;
8272else
8273 return 0;
8274@end smallexample
8275It doesn't warn when both branches contain just a null statement. This warning
8276also warn for conditional operators:
8277@smallexample
8278 int i = x ? *p : *p;
8279@end smallexample
8280
8281@item -Wduplicated-cond
8282@opindex Wno-duplicated-cond
8283@opindex Wduplicated-cond
8284Warn about duplicated conditions in an if-else-if chain. For instance,
8285warn for the following code:
8286@smallexample
8287if (p->q != NULL) @{ @dots{} @}
8288else if (p->q != NULL) @{ @dots{} @}
8289@end smallexample
8290
8291@item -Wframe-address
8292@opindex Wno-frame-address
8293@opindex Wframe-address
8294Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
8295is called with an argument greater than 0. Such calls may return indeterminate
8296values or crash the program. The warning is included in @option{-Wall}.
8297
8298@item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
8299@opindex Wno-discarded-qualifiers
8300@opindex Wdiscarded-qualifiers
8301Do not warn if type qualifiers on pointers are being discarded.
8302Typically, the compiler warns if a @code{const char *} variable is
8303passed to a function that takes a @code{char *} parameter. This option
8304can be used to suppress such a warning.
8305
8306@item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
8307@opindex Wno-discarded-array-qualifiers
8308@opindex Wdiscarded-array-qualifiers
8309Do not warn if type qualifiers on arrays which are pointer targets
8310are being discarded. Typically, the compiler warns if a
8311@code{const int (*)[]} variable is passed to a function that
8312takes a @code{int (*)[]} parameter. This option can be used to
8313suppress such a warning.
8314
8315@item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
8316@opindex Wno-incompatible-pointer-types
8317@opindex Wincompatible-pointer-types
8318Do not warn when there is a conversion between pointers that have incompatible
8319types. This warning is for cases not covered by @option{-Wno-pointer-sign},
8320which warns for pointer argument passing or assignment with different
8321signedness.
8322
8323@item -Wno-int-conversion @r{(C and Objective-C only)}
8324@opindex Wno-int-conversion
8325@opindex Wint-conversion
8326Do not warn about incompatible integer to pointer and pointer to integer
8327conversions. This warning is about implicit conversions; for explicit
8328conversions the warnings @option{-Wno-int-to-pointer-cast} and
8329@option{-Wno-pointer-to-int-cast} may be used.
8330
8331@item -Wzero-length-bounds
8332@opindex Wzero-length-bounds
8333@opindex Wzero-length-bounds
8334Warn about accesses to elements of zero-length array members that might
8335overlap other members of the same object. Declaring interior zero-length
8336arrays is discouraged because accesses to them are undefined. See
8337@xref{Zero Length}.
8338
8339For example, the first two stores in function @code{bad} are diagnosed
8340because the array elements overlap the subsequent members @code{b} and
8341@code{c}. The third store is diagnosed by @option{-Warray-bounds}
8342because it is beyond the bounds of the enclosing object.
8343
8344@smallexample
8345struct X @{ int a[0]; int b, c; @};
8346struct X x;
8347
8348void bad (void)
8349@{
8350 x.a[0] = 0; // -Wzero-length-bounds
8351 x.a[1] = 1; // -Wzero-length-bounds
8352 x.a[2] = 2; // -Warray-bounds
8353@}
8354@end smallexample
8355
8356Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
8357
8358@item -Wno-div-by-zero
8359@opindex Wno-div-by-zero
8360@opindex Wdiv-by-zero
8361Do not warn about compile-time integer division by zero. Floating-point
8362division by zero is not warned about, as it can be a legitimate way of
8363obtaining infinities and NaNs.
8364
8365@item -Wsystem-headers
8366@opindex Wsystem-headers
8367@opindex Wno-system-headers
8368@cindex warnings from system headers
8369@cindex system headers, warnings from
8370Print warning messages for constructs found in system header files.
8371Warnings from system headers are normally suppressed, on the assumption
8372that they usually do not indicate real problems and would only make the
8373compiler output harder to read. Using this command-line option tells
8374GCC to emit warnings from system headers as if they occurred in user
8375code. However, note that using @option{-Wall} in conjunction with this
8376option does @emph{not} warn about unknown pragmas in system
8377headers---for that, @option{-Wunknown-pragmas} must also be used.
8378
8379@item -Wtautological-compare
8380@opindex Wtautological-compare
8381@opindex Wno-tautological-compare
8382Warn if a self-comparison always evaluates to true or false. This
8383warning detects various mistakes such as:
8384@smallexample
8385int i = 1;
8386@dots{}
8387if (i > i) @{ @dots{} @}
8388@end smallexample
8389
8390This warning also warns about bitwise comparisons that always evaluate
8391to true or false, for instance:
8392@smallexample
8393if ((a & 16) == 10) @{ @dots{} @}
8394@end smallexample
8395will always be false.
8396
8397This warning is enabled by @option{-Wall}.
8398
8399@item -Wtrampolines
8400@opindex Wtrampolines
8401@opindex Wno-trampolines
8402Warn about trampolines generated for pointers to nested functions.
8403A trampoline is a small piece of data or code that is created at run
8404time on the stack when the address of a nested function is taken, and is
8405used to call the nested function indirectly. For some targets, it is
8406made up of data only and thus requires no special treatment. But, for
8407most targets, it is made up of code and thus requires the stack to be
8408made executable in order for the program to work properly.
8409
8410@item -Wfloat-equal
8411@opindex Wfloat-equal
8412@opindex Wno-float-equal
8413Warn if floating-point values are used in equality comparisons.
8414
8415The idea behind this is that sometimes it is convenient (for the
8416programmer) to consider floating-point values as approximations to
8417infinitely precise real numbers. If you are doing this, then you need
8418to compute (by analyzing the code, or in some other way) the maximum or
8419likely maximum error that the computation introduces, and allow for it
8420when performing comparisons (and when producing output, but that's a
8421different problem). In particular, instead of testing for equality, you
8422should check to see whether the two values have ranges that overlap; and
8423this is done with the relational operators, so equality comparisons are
8424probably mistaken.
8425
8426@item -Wtraditional @r{(C and Objective-C only)}
8427@opindex Wtraditional
8428@opindex Wno-traditional
8429Warn about certain constructs that behave differently in traditional and
8430ISO C@. Also warn about ISO C constructs that have no traditional C
8431equivalent, and/or problematic constructs that should be avoided.
8432
8433@itemize @bullet
8434@item
8435Macro parameters that appear within string literals in the macro body.
8436In traditional C macro replacement takes place within string literals,
8437but in ISO C it does not.
8438
8439@item
8440In traditional C, some preprocessor directives did not exist.
8441Traditional preprocessors only considered a line to be a directive
8442if the @samp{#} appeared in column 1 on the line. Therefore
8443@option{-Wtraditional} warns about directives that traditional C
8444understands but ignores because the @samp{#} does not appear as the
8445first character on the line. It also suggests you hide directives like
8446@code{#pragma} not understood by traditional C by indenting them. Some
8447traditional implementations do not recognize @code{#elif}, so this option
8448suggests avoiding it altogether.
8449
8450@item
8451A function-like macro that appears without arguments.
8452
8453@item
8454The unary plus operator.
8455
8456@item
8457The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
8458constant suffixes. (Traditional C does support the @samp{L} suffix on integer
8459constants.) Note, these suffixes appear in macros defined in the system
8460headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
8461Use of these macros in user code might normally lead to spurious
8462warnings, however GCC's integrated preprocessor has enough context to
8463avoid warning in these cases.
8464
8465@item
8466A function declared external in one block and then used after the end of
8467the block.
8468
8469@item
8470A @code{switch} statement has an operand of type @code{long}.
8471
8472@item
8473A non-@code{static} function declaration follows a @code{static} one.
8474This construct is not accepted by some traditional C compilers.
8475
8476@item
8477The ISO type of an integer constant has a different width or
8478signedness from its traditional type. This warning is only issued if
8479the base of the constant is ten. I.e.@: hexadecimal or octal values, which
8480typically represent bit patterns, are not warned about.
8481
8482@item
8483Usage of ISO string concatenation is detected.
8484
8485@item
8486Initialization of automatic aggregates.
8487
8488@item
8489Identifier conflicts with labels. Traditional C lacks a separate
8490namespace for labels.
8491
8492@item
8493Initialization of unions. If the initializer is zero, the warning is
8494omitted. This is done under the assumption that the zero initializer in
8495user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
8496initializer warnings and relies on default initialization to zero in the
8497traditional C case.
8498
8499@item
8500Conversions by prototypes between fixed/floating-point values and vice
8501versa. The absence of these prototypes when compiling with traditional
8502C causes serious problems. This is a subset of the possible
8503conversion warnings; for the full set use @option{-Wtraditional-conversion}.
8504
8505@item
8506Use of ISO C style function definitions. This warning intentionally is
8507@emph{not} issued for prototype declarations or variadic functions
8508because these ISO C features appear in your code when using
8509libiberty's traditional C compatibility macros, @code{PARAMS} and
8510@code{VPARAMS}. This warning is also bypassed for nested functions
8511because that feature is already a GCC extension and thus not relevant to
8512traditional C compatibility.
8513@end itemize
8514
8515@item -Wtraditional-conversion @r{(C and Objective-C only)}
8516@opindex Wtraditional-conversion
8517@opindex Wno-traditional-conversion
8518Warn if a prototype causes a type conversion that is different from what
8519would happen to the same argument in the absence of a prototype. This
8520includes conversions of fixed point to floating and vice versa, and
8521conversions changing the width or signedness of a fixed-point argument
8522except when the same as the default promotion.
8523
8524@item -Wdeclaration-after-statement @r{(C and Objective-C only)}
8525@opindex Wdeclaration-after-statement
8526@opindex Wno-declaration-after-statement
8527Warn when a declaration is found after a statement in a block. This
8528construct, known from C++, was introduced with ISO C99 and is by default
8529allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
8530
8531@item -Wshadow
8532@opindex Wshadow
8533@opindex Wno-shadow
8534Warn whenever a local variable or type declaration shadows another
8535variable, parameter, type, class member (in C++), or instance variable
8536(in Objective-C) or whenever a built-in function is shadowed. Note
8537that in C++, the compiler warns if a local variable shadows an
8538explicit typedef, but not if it shadows a struct/class/enum.
8539If this warning is enabled, it includes also all instances of
8540local shadowing. This means that @option{-Wno-shadow=local}
8541and @option{-Wno-shadow=compatible-local} are ignored when
8542@option{-Wshadow} is used.
8543Same as @option{-Wshadow=global}.
8544
8545@item -Wno-shadow-ivar @r{(Objective-C only)}
8546@opindex Wno-shadow-ivar
8547@opindex Wshadow-ivar
8548Do not warn whenever a local variable shadows an instance variable in an
8549Objective-C method.
8550
8551@item -Wshadow=global
8552@opindex Wshadow=global
8553Warn for any shadowing.
8554Same as @option{-Wshadow}.
8555
8556@item -Wshadow=local
8557@opindex Wshadow=local
8558Warn when a local variable shadows another local variable or parameter.
8559
8560@item -Wshadow=compatible-local
8561@opindex Wshadow=compatible-local
8562Warn when a local variable shadows another local variable or parameter
8563whose type is compatible with that of the shadowing variable. In C++,
8564type compatibility here means the type of the shadowing variable can be
8565converted to that of the shadowed variable. The creation of this flag
8566(in addition to @option{-Wshadow=local}) is based on the idea that when
8567a local variable shadows another one of incompatible type, it is most
8568likely intentional, not a bug or typo, as shown in the following example:
8569
8570@smallexample
8571@group
8572for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
8573@{
8574 for (int i = 0; i < N; ++i)
8575 @{
8576 ...
8577 @}
8578 ...
8579@}
8580@end group
8581@end smallexample
8582
8583Since the two variable @code{i} in the example above have incompatible types,
8584enabling only @option{-Wshadow=compatible-local} does not emit a warning.
8585Because their types are incompatible, if a programmer accidentally uses one
8586in place of the other, type checking is expected to catch that and emit an
8587error or warning. Use of this flag instead of @option{-Wshadow=local} can
8588possibly reduce the number of warnings triggered by intentional shadowing.
8589Note that this also means that shadowing @code{const char *i} by
8590@code{char *i} does not emit a warning.
8591
8592This warning is also enabled by @option{-Wshadow=local}.
8593
8594@item -Wlarger-than=@var{byte-size}
8595@opindex Wlarger-than=
8596@opindex Wlarger-than-@var{byte-size}
8597Warn whenever an object is defined whose size exceeds @var{byte-size}.
8598@option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8599Warnings controlled by the option can be disabled either by specifying
8600@var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
8601
8602Also warn for calls to bounded functions such as @code{memchr} or
8603@code{strnlen} that specify a bound greater than the largest possible
8604object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
8605can only be disabled by @option{-Wno-larger-than}.
8606
8607@item -Wno-larger-than
8608@opindex Wno-larger-than
8609Disable @option{-Wlarger-than=} warnings. The option is equivalent
8610to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
8611
8612@item -Wframe-larger-than=@var{byte-size}
8613@opindex Wframe-larger-than=
8614@opindex Wno-frame-larger-than
8615Warn if the size of a function frame exceeds @var{byte-size}.
8616The computation done to determine the stack frame size is approximate
8617and not conservative.
8618The actual requirements may be somewhat greater than @var{byte-size}
8619even if you do not get a warning. In addition, any space allocated
8620via @code{alloca}, variable-length arrays, or related constructs
8621is not included by the compiler when determining
8622whether or not to issue a warning.
8623@option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8624Warnings controlled by the option can be disabled either by specifying
8625@var{byte-size} of @samp{SIZE_MAX} or more or by
8626@option{-Wno-frame-larger-than}.
8627
8628@item -Wno-frame-larger-than
8629@opindex Wno-frame-larger-than
8630Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
8631to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
8632
8633@item -Wfree-nonheap-object
8634@opindex Wfree-nonheap-object
8635@opindex Wno-free-nonheap-object
8636Warn when attempting to deallocate an object that was either not allocated
8637on the heap, or by using a pointer that was not returned from a prior call
8638to the corresponding allocation function. For example, because the call
8639to @code{stpcpy} returns a pointer to the terminating nul character and
8640not to the beginning of the object, the call to @code{free} below is
8641diagnosed.
8642
8643@smallexample
8644void f (char *p)
8645@{
8646 p = stpcpy (p, "abc");
8647 // ...
8648 free (p); // warning
8649@}
8650@end smallexample
8651
8652@option{-Wfree-nonheap-object} is included in @option{-Wall}.
8653
8654@item -Wstack-usage=@var{byte-size}
8655@opindex Wstack-usage
8656@opindex Wno-stack-usage
8657Warn if the stack usage of a function might exceed @var{byte-size}.
8658The computation done to determine the stack usage is conservative.
8659Any space allocated via @code{alloca}, variable-length arrays, or related
8660constructs is included by the compiler when determining whether or not to
8661issue a warning.
8662
8663The message is in keeping with the output of @option{-fstack-usage}.
8664
8665@itemize
8666@item
8667If the stack usage is fully static but exceeds the specified amount, it's:
8668
8669@smallexample
8670 warning: stack usage is 1120 bytes
8671@end smallexample
8672@item
8673If the stack usage is (partly) dynamic but bounded, it's:
8674
8675@smallexample
8676 warning: stack usage might be 1648 bytes
8677@end smallexample
8678@item
8679If the stack usage is (partly) dynamic and not bounded, it's:
8680
8681@smallexample
8682 warning: stack usage might be unbounded
8683@end smallexample
8684@end itemize
8685
8686@option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
8687Warnings controlled by the option can be disabled either by specifying
8688@var{byte-size} of @samp{SIZE_MAX} or more or by
8689@option{-Wno-stack-usage}.
8690
8691@item -Wno-stack-usage
8692@opindex Wno-stack-usage
8693Disable @option{-Wstack-usage=} warnings. The option is equivalent
8694to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
8695
8696@item -Wunsafe-loop-optimizations
8697@opindex Wunsafe-loop-optimizations
8698@opindex Wno-unsafe-loop-optimizations
8699Warn if the loop cannot be optimized because the compiler cannot
8700assume anything on the bounds of the loop indices. With
8701@option{-funsafe-loop-optimizations} warn if the compiler makes
8702such assumptions.
8703
8704@item -Wno-pedantic-ms-format @r{(MinGW targets only)}
8705@opindex Wno-pedantic-ms-format
8706@opindex Wpedantic-ms-format
8707When used in combination with @option{-Wformat}
8708and @option{-pedantic} without GNU extensions, this option
8709disables the warnings about non-ISO @code{printf} / @code{scanf} format
8710width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
8711which depend on the MS runtime.
8712
8713@item -Wpointer-arith
8714@opindex Wpointer-arith
8715@opindex Wno-pointer-arith
8716Warn about anything that depends on the ``size of'' a function type or
8717of @code{void}. GNU C assigns these types a size of 1, for
8718convenience in calculations with @code{void *} pointers and pointers
8719to functions. In C++, warn also when an arithmetic operation involves
8720@code{NULL}. This warning is also enabled by @option{-Wpedantic}.
8721
8722@item -Wno-pointer-compare
8723@opindex Wpointer-compare
8724@opindex Wno-pointer-compare
8725Do not warn if a pointer is compared with a zero character constant.
8726This usually
8727means that the pointer was meant to be dereferenced. For example:
8728
8729@smallexample
8730const char *p = foo ();
8731if (p == '\0')
8732 return 42;
8733@end smallexample
8734
8735Note that the code above is invalid in C++11.
8736
8737This warning is enabled by default.
8738
8739@item -Wtsan
8740@opindex Wtsan
8741@opindex Wno-tsan
8742Warn about unsupported features in ThreadSanitizer.
8743
8744ThreadSanitizer does not support @code{std::atomic_thread_fence} and
8745can report false positives.
8746
8747This warning is enabled by default.
8748
8749@item -Wtype-limits
8750@opindex Wtype-limits
8751@opindex Wno-type-limits
8752Warn if a comparison is always true or always false due to the limited
8753range of the data type, but do not warn for constant expressions. For
8754example, warn if an unsigned variable is compared against zero with
8755@code{<} or @code{>=}. This warning is also enabled by
8756@option{-Wextra}.
8757
8758@item -Wabsolute-value @r{(C and Objective-C only)}
8759@opindex Wabsolute-value
8760@opindex Wno-absolute-value
8761Warn for calls to standard functions that compute the absolute value
8762of an argument when a more appropriate standard function is available.
8763For example, calling @code{abs(3.14)} triggers the warning because the
8764appropriate function to call to compute the absolute value of a double
8765argument is @code{fabs}. The option also triggers warnings when the
8766argument in a call to such a function has an unsigned type. This
8767warning can be suppressed with an explicit type cast and it is also
8768enabled by @option{-Wextra}.
8769
8770@include cppwarnopts.texi
8771
8772@item -Wbad-function-cast @r{(C and Objective-C only)}
8773@opindex Wbad-function-cast
8774@opindex Wno-bad-function-cast
8775Warn when a function call is cast to a non-matching type.
8776For example, warn if a call to a function returning an integer type
8777is cast to a pointer type.
8778
8779@item -Wc90-c99-compat @r{(C and Objective-C only)}
8780@opindex Wc90-c99-compat
8781@opindex Wno-c90-c99-compat
8782Warn about features not present in ISO C90, but present in ISO C99.
8783For instance, warn about use of variable length arrays, @code{long long}
8784type, @code{bool} type, compound literals, designated initializers, and so
8785on. This option is independent of the standards mode. Warnings are disabled
8786in the expression that follows @code{__extension__}.
8787
8788@item -Wc99-c11-compat @r{(C and Objective-C only)}
8789@opindex Wc99-c11-compat
8790@opindex Wno-c99-c11-compat
8791Warn about features not present in ISO C99, but present in ISO C11.
8792For instance, warn about use of anonymous structures and unions,
8793@code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
8794@code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
8795and so on. This option is independent of the standards mode. Warnings are
8796disabled in the expression that follows @code{__extension__}.
8797
8798@item -Wc11-c2x-compat @r{(C and Objective-C only)}
8799@opindex Wc11-c2x-compat
8800@opindex Wno-c11-c2x-compat
8801Warn about features not present in ISO C11, but present in ISO C2X.
8802For instance, warn about omitting the string in @code{_Static_assert},
8803use of @samp{[[]]} syntax for attributes, use of decimal
8804floating-point types, and so on. This option is independent of the
8805standards mode. Warnings are disabled in the expression that follows
8806@code{__extension__}.
8807
8808@item -Wc++-compat @r{(C and Objective-C only)}
8809@opindex Wc++-compat
8810@opindex Wno-c++-compat
8811Warn about ISO C constructs that are outside of the common subset of
8812ISO C and ISO C++, e.g.@: request for implicit conversion from
8813@code{void *} to a pointer to non-@code{void} type.
8814
8815@item -Wc++11-compat @r{(C++ and Objective-C++ only)}
8816@opindex Wc++11-compat
8817@opindex Wno-c++11-compat
8818Warn about C++ constructs whose meaning differs between ISO C++ 1998
8819and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
8820in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
8821enabled by @option{-Wall}.
8822
8823@item -Wc++14-compat @r{(C++ and Objective-C++ only)}
8824@opindex Wc++14-compat
8825@opindex Wno-c++14-compat
8826Warn about C++ constructs whose meaning differs between ISO C++ 2011
8827and ISO C++ 2014. This warning is enabled by @option{-Wall}.
8828
8829@item -Wc++17-compat @r{(C++ and Objective-C++ only)}
8830@opindex Wc++17-compat
8831@opindex Wno-c++17-compat
8832Warn about C++ constructs whose meaning differs between ISO C++ 2014
8833and ISO C++ 2017. This warning is enabled by @option{-Wall}.
8834
8835@item -Wc++20-compat @r{(C++ and Objective-C++ only)}
8836@opindex Wc++20-compat
8837@opindex Wno-c++20-compat
8838Warn about C++ constructs whose meaning differs between ISO C++ 2017
8839and ISO C++ 2020. This warning is enabled by @option{-Wall}.
8840
8841@item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
8842@opindex Wc++11-extensions
8843@opindex Wno-c++11-extensions
8844Do not warn about C++11 constructs in code being compiled using
8845an older C++ standard. Even without this option, some C++11 constructs
8846will only be diagnosed if @option{-Wpedantic} is used.
8847
8848@item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
8849@opindex Wc++14-extensions
8850@opindex Wno-c++14-extensions
8851Do not warn about C++14 constructs in code being compiled using
8852an older C++ standard. Even without this option, some C++14 constructs
8853will only be diagnosed if @option{-Wpedantic} is used.
8854
8855@item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
8856@opindex Wc++17-extensions
8857@opindex Wno-c++17-extensions
8858Do not warn about C++17 constructs in code being compiled using
8859an older C++ standard. Even without this option, some C++17 constructs
8860will only be diagnosed if @option{-Wpedantic} is used.
8861
8862@item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
8863@opindex Wc++20-extensions
8864@opindex Wno-c++20-extensions
8865Do not warn about C++20 constructs in code being compiled using
8866an older C++ standard. Even without this option, some C++20 constructs
8867will only be diagnosed if @option{-Wpedantic} is used.
8868
8869@item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
8870@opindex Wc++23-extensions
8871@opindex Wno-c++23-extensions
8872Do not warn about C++23 constructs in code being compiled using
8873an older C++ standard. Even without this option, some C++23 constructs
8874will only be diagnosed if @option{-Wpedantic} is used.
8875
8876@item -Wcast-qual
8877@opindex Wcast-qual
8878@opindex Wno-cast-qual
8879Warn whenever a pointer is cast so as to remove a type qualifier from
8880the target type. For example, warn if a @code{const char *} is cast
8881to an ordinary @code{char *}.
8882
8883Also warn when making a cast that introduces a type qualifier in an
8884unsafe way. For example, casting @code{char **} to @code{const char **}
8885is unsafe, as in this example:
8886
8887@smallexample
8888 /* p is char ** value. */
8889 const char **q = (const char **) p;
8890 /* Assignment of readonly string to const char * is OK. */
8891 *q = "string";
8892 /* Now char** pointer points to read-only memory. */
8893 **p = 'b';
8894@end smallexample
8895
8896@item -Wcast-align
8897@opindex Wcast-align
8898@opindex Wno-cast-align
8899Warn whenever a pointer is cast such that the required alignment of the
8900target is increased. For example, warn if a @code{char *} is cast to
8901an @code{int *} on machines where integers can only be accessed at
8902two- or four-byte boundaries.
8903
8904@item -Wcast-align=strict
8905@opindex Wcast-align=strict
8906Warn whenever a pointer is cast such that the required alignment of the
8907target is increased. For example, warn if a @code{char *} is cast to
8908an @code{int *} regardless of the target machine.
8909
8910@item -Wcast-function-type
8911@opindex Wcast-function-type
8912@opindex Wno-cast-function-type
8913Warn when a function pointer is cast to an incompatible function pointer.
8914In a cast involving function types with a variable argument list only
8915the types of initial arguments that are provided are considered.
8916Any parameter of pointer-type matches any other pointer-type. Any benign
8917differences in integral types are ignored, like @code{int} vs.@: @code{long}
8918on ILP32 targets. Likewise type qualifiers are ignored. The function
8919type @code{void (*) (void)} is special and matches everything, which can
8920be used to suppress this warning.
8921In a cast involving pointer to member types this warning warns whenever
8922the type cast is changing the pointer to member type.
8923This warning is enabled by @option{-Wextra}.
8924
8925@item -Wwrite-strings
8926@opindex Wwrite-strings
8927@opindex Wno-write-strings
8928When compiling C, give string constants the type @code{const
8929char[@var{length}]} so that copying the address of one into a
8930non-@code{const} @code{char *} pointer produces a warning. These
8931warnings help you find at compile time code that can try to write
8932into a string constant, but only if you have been very careful about
8933using @code{const} in declarations and prototypes. Otherwise, it is
8934just a nuisance. This is why we did not make @option{-Wall} request
8935these warnings.
8936
8937When compiling C++, warn about the deprecated conversion from string
8938literals to @code{char *}. This warning is enabled by default for C++
8939programs.
8940
8941@item -Wclobbered
8942@opindex Wclobbered
8943@opindex Wno-clobbered
8944Warn for variables that might be changed by @code{longjmp} or
8945@code{vfork}. This warning is also enabled by @option{-Wextra}.
8946
8947@item -Wconversion
8948@opindex Wconversion
8949@opindex Wno-conversion
8950Warn for implicit conversions that may alter a value. This includes
8951conversions between real and integer, like @code{abs (x)} when
8952@code{x} is @code{double}; conversions between signed and unsigned,
8953like @code{unsigned ui = -1}; and conversions to smaller types, like
8954@code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
8955((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
8956changed by the conversion like in @code{abs (2.0)}. Warnings about
8957conversions between signed and unsigned integers can be disabled by
8958using @option{-Wno-sign-conversion}.
8959
8960For C++, also warn for confusing overload resolution for user-defined
8961conversions; and conversions that never use a type conversion
8962operator: conversions to @code{void}, the same type, a base class or a
8963reference to them. Warnings about conversions between signed and
8964unsigned integers are disabled by default in C++ unless
8965@option{-Wsign-conversion} is explicitly enabled.
8966
8967Warnings about conversion from arithmetic on a small type back to that
8968type are only given with @option{-Warith-conversion}.
8969
8970@item -Wdangling-else
8971@opindex Wdangling-else
8972@opindex Wno-dangling-else
8973Warn about constructions where there may be confusion to which
8974@code{if} statement an @code{else} branch belongs. Here is an example of
8975such a case:
8976
8977@smallexample
8978@group
8979@{
8980 if (a)
8981 if (b)
8982 foo ();
8983 else
8984 bar ();
8985@}
8986@end group
8987@end smallexample
8988
8989In C/C++, every @code{else} branch belongs to the innermost possible
8990@code{if} statement, which in this example is @code{if (b)}. This is
8991often not what the programmer expected, as illustrated in the above
8992example by indentation the programmer chose. When there is the
8993potential for this confusion, GCC issues a warning when this flag
8994is specified. To eliminate the warning, add explicit braces around
8995the innermost @code{if} statement so there is no way the @code{else}
8996can belong to the enclosing @code{if}. The resulting code
8997looks like this:
8998
8999@smallexample
9000@group
9001@{
9002 if (a)
9003 @{
9004 if (b)
9005 foo ();
9006 else
9007 bar ();
9008 @}
9009@}
9010@end group
9011@end smallexample
9012
9013This warning is enabled by @option{-Wparentheses}.
9014
9015@item -Wdangling-pointer
9016@itemx -Wdangling-pointer=@var{n}
9017@opindex Wdangling-pointer
9018@opindex Wno-dangling-pointer
9019Warn about uses of pointers (or C++ references) to objects with automatic
9020storage duration after their lifetime has ended. This includes local
9021variables declared in nested blocks, compound literals and other unnamed
9022temporary objects. In addition, warn about storing the address of such
9023objects in escaped pointers. The warning is enabled at all optimization
9024levels but may yield different results with optimization than without.
9025
9026@table @gcctabopt
9027@item -Wdangling-pointer=1
9028At level 1 the warning diagnoses only unconditional uses of dangling pointers.
9029For example
9030@smallexample
9031int f (int c1, int c2, x)
9032@{
9033 char *p = strchr ((char[])@{ c1, c2 @}, c3);
9034 return p ? *p : 'x'; // warning: dangling pointer to a compound literal
9035@}
9036@end smallexample
9037In the following function the store of the address of the local variable
9038@code{x} in the escaped pointer @code{*p} also triggers the warning.
9039@smallexample
9040void g (int **p)
9041@{
9042 int x = 7;
9043 *p = &x; // warning: storing the address of a local variable in *p
9044@}
9045@end smallexample
9046
9047@item -Wdangling-pointer=2
9048At level 2, in addition to unconditional uses the warning also diagnoses
9049conditional uses of dangling pointers.
9050
9051For example, because the array @var{a} in the following function is out of
9052scope when the pointer @var{s} that was set to point is used, the warning
9053triggers at this level.
9054
9055@smallexample
9056void f (char *s)
9057@{
9058 if (!s)
9059 @{
9060 char a[12] = "tmpname";
9061 s = a;
9062 @}
9063 strcat (s, ".tmp"); // warning: dangling pointer to a may be used
9064 ...
9065@}
9066@end smallexample
9067@end table
9068
9069@option{-Wdangling-pointer=2} is included in @option{-Wall}.
9070
9071@item -Wdate-time
9072@opindex Wdate-time
9073@opindex Wno-date-time
9074Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
9075are encountered as they might prevent bit-wise-identical reproducible
9076compilations.
9077
9078@item -Wempty-body
9079@opindex Wempty-body
9080@opindex Wno-empty-body
9081Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
9082while} statement. This warning is also enabled by @option{-Wextra}.
9083
9084@item -Wno-endif-labels
9085@opindex Wendif-labels
9086@opindex Wno-endif-labels
9087Do not warn about stray tokens after @code{#else} and @code{#endif}.
9088
9089@item -Wenum-compare
9090@opindex Wenum-compare
9091@opindex Wno-enum-compare
9092Warn about a comparison between values of different enumerated types.
9093In C++ enumerated type mismatches in conditional expressions are also
9094diagnosed and the warning is enabled by default. In C this warning is
9095enabled by @option{-Wall}.
9096
9097@item -Wenum-conversion
9098@opindex Wenum-conversion
9099@opindex Wno-enum-conversion
9100Warn when a value of enumerated type is implicitly converted to a
9101different enumerated type. This warning is enabled by @option{-Wextra}
9102in C@.
9103
9104@item -Wenum-int-mismatch @r{(C and Objective-C only)}
9105@opindex Wenum-int-mismatch
9106@opindex Wno-enum-int-mismatch
9107Warn about mismatches between an enumerated type and an integer type in
9108declarations. For example:
9109
9110@smallexample
9111enum E @{ l = -1, z = 0, g = 1 @};
9112int foo(void);
9113enum E foo(void);
9114@end smallexample
9115
9116In C, an enumerated type is compatible with @code{char}, a signed
9117integer type, or an unsigned integer type. However, since the choice
9118of the underlying type of an enumerated type is implementation-defined,
9119such mismatches may cause portability issues. In C++, such mismatches
9120are an error. In C, this warning is enabled by @option{-Wall} and
9121@option{-Wc++-compat}.
9122
9123@item -Wjump-misses-init @r{(C, Objective-C only)}
9124@opindex Wjump-misses-init
9125@opindex Wno-jump-misses-init
9126Warn if a @code{goto} statement or a @code{switch} statement jumps
9127forward across the initialization of a variable, or jumps backward to a
9128label after the variable has been initialized. This only warns about
9129variables that are initialized when they are declared. This warning is
9130only supported for C and Objective-C; in C++ this sort of branch is an
9131error in any case.
9132
9133@option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
9134can be disabled with the @option{-Wno-jump-misses-init} option.
9135
9136@item -Wsign-compare
9137@opindex Wsign-compare
9138@opindex Wno-sign-compare
9139@cindex warning for comparison of signed and unsigned values
9140@cindex comparison of signed and unsigned values, warning
9141@cindex signed and unsigned values, comparison warning
9142Warn when a comparison between signed and unsigned values could produce
9143an incorrect result when the signed value is converted to unsigned.
9144In C++, this warning is also enabled by @option{-Wall}. In C, it is
9145also enabled by @option{-Wextra}.
9146
9147@item -Wsign-conversion
9148@opindex Wsign-conversion
9149@opindex Wno-sign-conversion
9150Warn for implicit conversions that may change the sign of an integer
9151value, like assigning a signed integer expression to an unsigned
9152integer variable. An explicit cast silences the warning. In C, this
9153option is enabled also by @option{-Wconversion}.
9154
9155@item -Wfloat-conversion
9156@opindex Wfloat-conversion
9157@opindex Wno-float-conversion
9158Warn for implicit conversions that reduce the precision of a real value.
9159This includes conversions from real to integer, and from higher precision
9160real to lower precision real values. This option is also enabled by
9161@option{-Wconversion}.
9162
9163@item -Wno-scalar-storage-order
9164@opindex Wno-scalar-storage-order
9165@opindex Wscalar-storage-order
9166Do not warn on suspicious constructs involving reverse scalar storage order.
9167
9168@item -Wsizeof-array-div
9169@opindex Wsizeof-array-div
9170@opindex Wno-sizeof-array-div
9171Warn about divisions of two sizeof operators when the first one is applied
9172to an array and the divisor does not equal the size of the array element.
9173In such a case, the computation will not yield the number of elements in the
9174array, which is likely what the user intended. This warning warns e.g. about
9175@smallexample
9176int fn ()
9177@{
9178 int arr[10];
9179 return sizeof (arr) / sizeof (short);
9180@}
9181@end smallexample
9182
9183This warning is enabled by @option{-Wall}.
9184
9185@item -Wsizeof-pointer-div
9186@opindex Wsizeof-pointer-div
9187@opindex Wno-sizeof-pointer-div
9188Warn for suspicious divisions of two sizeof expressions that divide
9189the pointer size by the element size, which is the usual way to compute
9190the array size but won't work out correctly with pointers. This warning
9191warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
9192not an array, but a pointer. This warning is enabled by @option{-Wall}.
9193
9194@item -Wsizeof-pointer-memaccess
9195@opindex Wsizeof-pointer-memaccess
9196@opindex Wno-sizeof-pointer-memaccess
9197Warn for suspicious length parameters to certain string and memory built-in
9198functions if the argument uses @code{sizeof}. This warning triggers for
9199example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
9200an array, but a pointer, and suggests a possible fix, or about
9201@code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
9202also warns about calls to bounded string copy functions like @code{strncat}
9203or @code{strncpy} that specify as the bound a @code{sizeof} expression of
9204the source array. For example, in the following function the call to
9205@code{strncat} specifies the size of the source string as the bound. That
9206is almost certainly a mistake and so the call is diagnosed.
9207@smallexample
9208void make_file (const char *name)
9209@{
9210 char path[PATH_MAX];
9211 strncpy (path, name, sizeof path - 1);
9212 strncat (path, ".text", sizeof ".text");
9213 @dots{}
9214@}
9215@end smallexample
9216
9217The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
9218
9219@item -Wno-sizeof-array-argument
9220@opindex Wsizeof-array-argument
9221@opindex Wno-sizeof-array-argument
9222Do not warn when the @code{sizeof} operator is applied to a parameter that is
9223declared as an array in a function definition. This warning is enabled by
9224default for C and C++ programs.
9225
9226@item -Wmemset-elt-size
9227@opindex Wmemset-elt-size
9228@opindex Wno-memset-elt-size
9229Warn for suspicious calls to the @code{memset} built-in function, if the
9230first argument references an array, and the third argument is a number
9231equal to the number of elements, but not equal to the size of the array
9232in memory. This indicates that the user has omitted a multiplication by
9233the element size. This warning is enabled by @option{-Wall}.
9234
9235@item -Wmemset-transposed-args
9236@opindex Wmemset-transposed-args
9237@opindex Wno-memset-transposed-args
9238Warn for suspicious calls to the @code{memset} built-in function where
9239the second argument is not zero and the third argument is zero. For
9240example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
9241@code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
9242is only emitted if the third argument is a literal zero. Otherwise, if
9243it is an expression that is folded to zero, or a cast of zero to some
9244type, it is far less likely that the arguments have been mistakenly
9245transposed and no warning is emitted. This warning is enabled
9246by @option{-Wall}.
9247
9248@item -Waddress
9249@opindex Waddress
9250@opindex Wno-address
9251Warn about suspicious uses of address expressions. These include comparing
9252the address of a function or a declared object to the null pointer constant
9253such as in
9254@smallexample
9255void f (void);
9256void g (void)
9257@{
9258 if (!f) // warning: expression evaluates to false
9259 abort ();
9260@}
9261@end smallexample
9262comparisons of a pointer to a string literal, such as in
9263@smallexample
9264void f (const char *x)
9265@{
9266 if (x == "abc") // warning: expression evaluates to false
9267 puts ("equal");
9268@}
9269@end smallexample
9270and tests of the results of pointer addition or subtraction for equality
9271to null, such as in
9272@smallexample
9273void f (const int *p, int i)
9274@{
9275 return p + i == NULL;
9276@}
9277@end smallexample
9278Such uses typically indicate a programmer error: the address of most
9279functions and objects necessarily evaluates to true (the exception are
9280weak symbols), so their use in a conditional might indicate missing
9281parentheses in a function call or a missing dereference in an array
9282expression. The subset of the warning for object pointers can be
9283suppressed by casting the pointer operand to an integer type such
9284as @code{intptr_t} or @code{uintptr_t}.
9285Comparisons against string literals result in unspecified behavior
9286and are not portable, and suggest the intent was to call @code{strcmp}.
9287The warning is suppressed if the suspicious expression is the result
9288of macro expansion.
9289@option{-Waddress} warning is enabled by @option{-Wall}.
9290
9291@item -Wno-address-of-packed-member
9292@opindex Waddress-of-packed-member
9293@opindex Wno-address-of-packed-member
9294Do not warn when the address of packed member of struct or union is taken,
9295which usually results in an unaligned pointer value. This is
9296enabled by default.
9297
9298@item -Wlogical-op
9299@opindex Wlogical-op
9300@opindex Wno-logical-op
9301Warn about suspicious uses of logical operators in expressions.
9302This includes using logical operators in contexts where a
9303bit-wise operator is likely to be expected. Also warns when
9304the operands of a logical operator are the same:
9305@smallexample
9306extern int a;
9307if (a < 0 && a < 0) @{ @dots{} @}
9308@end smallexample
9309
9310@item -Wlogical-not-parentheses
9311@opindex Wlogical-not-parentheses
9312@opindex Wno-logical-not-parentheses
9313Warn about logical not used on the left hand side operand of a comparison.
9314This option does not warn if the right operand is considered to be a boolean
9315expression. Its purpose is to detect suspicious code like the following:
9316@smallexample
9317int a;
9318@dots{}
9319if (!a > 1) @{ @dots{} @}
9320@end smallexample
9321
9322It is possible to suppress the warning by wrapping the LHS into
9323parentheses:
9324@smallexample
9325if ((!a) > 1) @{ @dots{} @}
9326@end smallexample
9327
9328This warning is enabled by @option{-Wall}.
9329
9330@item -Waggregate-return
9331@opindex Waggregate-return
9332@opindex Wno-aggregate-return
9333Warn if any functions that return structures or unions are defined or
9334called. (In languages where you can return an array, this also elicits
9335a warning.)
9336
9337@item -Wno-aggressive-loop-optimizations
9338@opindex Wno-aggressive-loop-optimizations
9339@opindex Waggressive-loop-optimizations
9340Warn if in a loop with constant number of iterations the compiler detects
9341undefined behavior in some statement during one or more of the iterations.
9342
9343@item -Wno-attributes
9344@opindex Wno-attributes
9345@opindex Wattributes
9346Do not warn if an unexpected @code{__attribute__} is used, such as
9347unrecognized attributes, function attributes applied to variables,
9348etc. This does not stop errors for incorrect use of supported
9349attributes.
9350
9351Additionally, using @option{-Wno-attributes=}, it is possible to suppress
9352warnings about unknown scoped attributes (in C++11 and C2X). For example,
9353@option{-Wno-attributes=vendor::attr} disables warning about the following
9354declaration:
9355
9356@smallexample
9357[[vendor::attr]] void f();
9358@end smallexample
9359
9360It is also possible to disable warning about all attributes in a namespace
9361using @option{-Wno-attributes=vendor::} which prevents warning about both
9362of these declarations:
9363
9364@smallexample
9365[[vendor::safe]] void f();
9366[[vendor::unsafe]] void f2();
9367@end smallexample
9368
9369Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
9370
9371@item -Wno-builtin-declaration-mismatch
9372@opindex Wno-builtin-declaration-mismatch
9373@opindex Wbuiltin-declaration-mismatch
9374Warn if a built-in function is declared with an incompatible signature
9375or as a non-function, or when a built-in function declared with a type
9376that does not include a prototype is called with arguments whose promoted
9377types do not match those expected by the function. When @option{-Wextra}
9378is specified, also warn when a built-in function that takes arguments is
9379declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
9380warning is enabled by default. To avoid the warning include the appropriate
9381header to bring the prototypes of built-in functions into scope.
9382
9383For example, the call to @code{memset} below is diagnosed by the warning
9384because the function expects a value of type @code{size_t} as its argument
9385but the type of @code{32} is @code{int}. With @option{-Wextra},
9386the declaration of the function is diagnosed as well.
9387@smallexample
9388extern void* memset ();
9389void f (void *d)
9390@{
9391 memset (d, '\0', 32);
9392@}
9393@end smallexample
9394
9395@item -Wno-builtin-macro-redefined
9396@opindex Wno-builtin-macro-redefined
9397@opindex Wbuiltin-macro-redefined
9398Do not warn if certain built-in macros are redefined. This suppresses
9399warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
9400@code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
9401
9402@item -Wstrict-prototypes @r{(C and Objective-C only)}
9403@opindex Wstrict-prototypes
9404@opindex Wno-strict-prototypes
9405Warn if a function is declared or defined without specifying the
9406argument types. (An old-style function definition is permitted without
9407a warning if preceded by a declaration that specifies the argument
9408types.)
9409
9410@item -Wold-style-declaration @r{(C and Objective-C only)}
9411@opindex Wold-style-declaration
9412@opindex Wno-old-style-declaration
9413Warn for obsolescent usages, according to the C Standard, in a
9414declaration. For example, warn if storage-class specifiers like
9415@code{static} are not the first things in a declaration. This warning
9416is also enabled by @option{-Wextra}.
9417
9418@item -Wold-style-definition @r{(C and Objective-C only)}
9419@opindex Wold-style-definition
9420@opindex Wno-old-style-definition
9421Warn if an old-style function definition is used. A warning is given
9422even if there is a previous prototype. A definition using @samp{()}
9423is not considered an old-style definition in C2X mode, because it is
9424equivalent to @samp{(void)} in that case, but is considered an
9425old-style definition for older standards.
9426
9427@item -Wmissing-parameter-type @r{(C and Objective-C only)}
9428@opindex Wmissing-parameter-type
9429@opindex Wno-missing-parameter-type
9430A function parameter is declared without a type specifier in K&R-style
9431functions:
9432
9433@smallexample
9434void foo(bar) @{ @}
9435@end smallexample
9436
9437This warning is also enabled by @option{-Wextra}.
9438
9439@item -Wmissing-prototypes @r{(C and Objective-C only)}
9440@opindex Wmissing-prototypes
9441@opindex Wno-missing-prototypes
9442Warn if a global function is defined without a previous prototype
9443declaration. This warning is issued even if the definition itself
9444provides a prototype. Use this option to detect global functions
9445that do not have a matching prototype declaration in a header file.
9446This option is not valid for C++ because all function declarations
9447provide prototypes and a non-matching declaration declares an
9448overload rather than conflict with an earlier declaration.
9449Use @option{-Wmissing-declarations} to detect missing declarations in C++.
9450
9451@item -Wmissing-declarations
9452@opindex Wmissing-declarations
9453@opindex Wno-missing-declarations
9454Warn if a global function is defined without a previous declaration.
9455Do so even if the definition itself provides a prototype.
9456Use this option to detect global functions that are not declared in
9457header files. In C, no warnings are issued for functions with previous
9458non-prototype declarations; use @option{-Wmissing-prototypes} to detect
9459missing prototypes. In C++, no warnings are issued for function templates,
9460or for inline functions, or for functions in anonymous namespaces.
9461
9462@item -Wmissing-field-initializers
9463@opindex Wmissing-field-initializers
9464@opindex Wno-missing-field-initializers
9465@opindex W
9466@opindex Wextra
9467@opindex Wno-extra
9468Warn if a structure's initializer has some fields missing. For
9469example, the following code causes such a warning, because
9470@code{x.h} is implicitly zero:
9471
9472@smallexample
9473struct s @{ int f, g, h; @};
9474struct s x = @{ 3, 4 @};
9475@end smallexample
9476
9477This option does not warn about designated initializers, so the following
9478modification does not trigger a warning:
9479
9480@smallexample
9481struct s @{ int f, g, h; @};
9482struct s x = @{ .f = 3, .g = 4 @};
9483@end smallexample
9484
9485In C this option does not warn about the universal zero initializer
9486@samp{@{ 0 @}}:
9487
9488@smallexample
9489struct s @{ int f, g, h; @};
9490struct s x = @{ 0 @};
9491@end smallexample
9492
9493Likewise, in C++ this option does not warn about the empty @{ @}
9494initializer, for example:
9495
9496@smallexample
9497struct s @{ int f, g, h; @};
9498s x = @{ @};
9499@end smallexample
9500
9501This warning is included in @option{-Wextra}. To get other @option{-Wextra}
9502warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
9503
9504@item -Wno-missing-requires
9505@opindex Wmissing-requires
9506@opindex Wno-missing-requires
9507
9508By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
9509
9510@smallexample
9511bool satisfied = requires @{ C<T> @};
9512@end smallexample
9513
9514Here @samp{satisfied} will be true if @samp{C<T>} is a valid
9515expression, which it is for all T. Presumably the user meant to write
9516
9517@smallexample
9518bool satisfied = requires @{ requires C<T> @};
9519@end smallexample
9520
9521so @samp{satisfied} is only true if concept @samp{C} is satisfied for
9522type @samp{T}.
9523
9524This warning can be disabled with @option{-Wno-missing-requires}.
9525
9526@item -Wno-missing-template-keyword
9527@opindex Wmissing-template-keyword
9528@opindex Wno-missing-template-keyword
9529
9530The member access tokens ., -> and :: must be followed by the @code{template}
9531keyword if the parent object is dependent and the member being named is a
9532template.
9533
9534@smallexample
9535template <class X>
9536void DoStuff (X x)
9537@{
9538 x.template DoSomeOtherStuff<X>(); // Good.
9539 x.DoMoreStuff<X>(); // Warning, x is dependent.
9540@}
9541@end smallexample
9542
9543In rare cases it is possible to get false positives. To silence this, wrap
9544the expression in parentheses. For example, the following is treated as a
9545template, even where m and N are integers:
9546
9547@smallexample
9548void NotATemplate (my_class t)
9549@{
9550 int N = 5;
9551
9552 bool test = t.m < N > (0); // Treated as a template.
9553 test = (t.m < N) > (0); // Same meaning, but not treated as a template.
9554@}
9555@end smallexample
9556
9557This warning can be disabled with @option{-Wno-missing-template-keyword}.
9558
9559@item -Wno-multichar
9560@opindex Wno-multichar
9561@opindex Wmultichar
9562Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
9563Usually they indicate a typo in the user's code, as they have
9564implementation-defined values, and should not be used in portable code.
9565
9566@item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
9567@opindex Wnormalized=
9568@opindex Wnormalized
9569@opindex Wno-normalized
9570@cindex NFC
9571@cindex NFKC
9572@cindex character set, input normalization
9573In ISO C and ISO C++, two identifiers are different if they are
9574different sequences of characters. However, sometimes when characters
9575outside the basic ASCII character set are used, you can have two
9576different character sequences that look the same. To avoid confusion,
9577the ISO 10646 standard sets out some @dfn{normalization rules} which
9578when applied ensure that two sequences that look the same are turned into
9579the same sequence. GCC can warn you if you are using identifiers that
9580have not been normalized; this option controls that warning.
9581
9582There are four levels of warning supported by GCC@. The default is
9583@option{-Wnormalized=nfc}, which warns about any identifier that is
9584not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
9585recommended form for most uses. It is equivalent to
9586@option{-Wnormalized}.
9587
9588Unfortunately, there are some characters allowed in identifiers by
9589ISO C and ISO C++ that, when turned into NFC, are not allowed in
9590identifiers. That is, there's no way to use these symbols in portable
9591ISO C or C++ and have all your identifiers in NFC@.
9592@option{-Wnormalized=id} suppresses the warning for these characters.
9593It is hoped that future versions of the standards involved will correct
9594this, which is why this option is not the default.
9595
9596You can switch the warning off for all characters by writing
9597@option{-Wnormalized=none} or @option{-Wno-normalized}. You should
9598only do this if you are using some other normalization scheme (like
9599``D''), because otherwise you can easily create bugs that are
9600literally impossible to see.
9601
9602Some characters in ISO 10646 have distinct meanings but look identical
9603in some fonts or display methodologies, especially once formatting has
9604been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
9605LETTER N'', displays just like a regular @code{n} that has been
9606placed in a superscript. ISO 10646 defines the @dfn{NFKC}
9607normalization scheme to convert all these into a standard form as
9608well, and GCC warns if your code is not in NFKC if you use
9609@option{-Wnormalized=nfkc}. This warning is comparable to warning
9610about every identifier that contains the letter O because it might be
9611confused with the digit 0, and so is not the default, but may be
9612useful as a local coding convention if the programming environment
9613cannot be fixed to display these characters distinctly.
9614
9615@item -Wno-attribute-warning
9616@opindex Wno-attribute-warning
9617@opindex Wattribute-warning
9618Do not warn about usage of functions (@pxref{Function Attributes})
9619declared with @code{warning} attribute. By default, this warning is
9620enabled. @option{-Wno-attribute-warning} can be used to disable the
9621warning or @option{-Wno-error=attribute-warning} can be used to
9622disable the error when compiled with @option{-Werror} flag.
9623
9624@item -Wno-deprecated
9625@opindex Wno-deprecated
9626@opindex Wdeprecated
9627Do not warn about usage of deprecated features. @xref{Deprecated Features}.
9628
9629@item -Wno-deprecated-declarations
9630@opindex Wno-deprecated-declarations
9631@opindex Wdeprecated-declarations
9632Do not warn about uses of functions (@pxref{Function Attributes}),
9633variables (@pxref{Variable Attributes}), and types (@pxref{Type
9634Attributes}) marked as deprecated by using the @code{deprecated}
9635attribute.
9636
9637@item -Wno-overflow
9638@opindex Wno-overflow
9639@opindex Woverflow
9640Do not warn about compile-time overflow in constant expressions.
9641
9642@item -Wno-odr
9643@opindex Wno-odr
9644@opindex Wodr
9645Warn about One Definition Rule violations during link-time optimization.
9646Enabled by default.
9647
9648@item -Wopenacc-parallelism
9649@opindex Wopenacc-parallelism
9650@opindex Wno-openacc-parallelism
9651@cindex OpenACC accelerator programming
9652Warn about potentially suboptimal choices related to OpenACC parallelism.
9653
9654@item -Wopenmp-simd
9655@opindex Wopenmp-simd
9656@opindex Wno-openmp-simd
9657Warn if the vectorizer cost model overrides the OpenMP
9658simd directive set by user. The @option{-fsimd-cost-model=unlimited}
9659option can be used to relax the cost model.
9660
9661@item -Woverride-init @r{(C and Objective-C only)}
9662@opindex Woverride-init
9663@opindex Wno-override-init
9664@opindex W
9665@opindex Wextra
9666@opindex Wno-extra
9667Warn if an initialized field without side effects is overridden when
9668using designated initializers (@pxref{Designated Inits, , Designated
9669Initializers}).
9670
9671This warning is included in @option{-Wextra}. To get other
9672@option{-Wextra} warnings without this one, use @option{-Wextra
9673-Wno-override-init}.
9674
9675@item -Wno-override-init-side-effects @r{(C and Objective-C only)}
9676@opindex Woverride-init-side-effects
9677@opindex Wno-override-init-side-effects
9678Do not warn if an initialized field with side effects is overridden when
9679using designated initializers (@pxref{Designated Inits, , Designated
9680Initializers}). This warning is enabled by default.
9681
9682@item -Wpacked
9683@opindex Wpacked
9684@opindex Wno-packed
9685Warn if a structure is given the packed attribute, but the packed
9686attribute has no effect on the layout or size of the structure.
9687Such structures may be mis-aligned for little benefit. For
9688instance, in this code, the variable @code{f.x} in @code{struct bar}
9689is misaligned even though @code{struct bar} does not itself
9690have the packed attribute:
9691
9692@smallexample
9693@group
9694struct foo @{
9695 int x;
9696 char a, b, c, d;
9697@} __attribute__((packed));
9698struct bar @{
9699 char z;
9700 struct foo f;
9701@};
9702@end group
9703@end smallexample
9704
9705@item -Wnopacked-bitfield-compat
9706@opindex Wpacked-bitfield-compat
9707@opindex Wno-packed-bitfield-compat
9708The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
9709on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
9710the change can lead to differences in the structure layout. GCC
9711informs you when the offset of such a field has changed in GCC 4.4.
9712For example there is no longer a 4-bit padding between field @code{a}
9713and @code{b} in this structure:
9714
9715@smallexample
9716struct foo
9717@{
9718 char a:4;
9719 char b:8;
9720@} __attribute__ ((packed));
9721@end smallexample
9722
9723This warning is enabled by default. Use
9724@option{-Wno-packed-bitfield-compat} to disable this warning.
9725
9726@item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
9727@opindex Wpacked-not-aligned
9728@opindex Wno-packed-not-aligned
9729Warn if a structure field with explicitly specified alignment in a
9730packed struct or union is misaligned. For example, a warning will
9731be issued on @code{struct S}, like, @code{warning: alignment 1 of
9732'struct S' is less than 8}, in this code:
9733
9734@smallexample
9735@group
9736struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
9737struct __attribute__ ((packed)) S @{
9738 struct S8 s8;
9739@};
9740@end group
9741@end smallexample
9742
9743This warning is enabled by @option{-Wall}.
9744
9745@item -Wpadded
9746@opindex Wpadded
9747@opindex Wno-padded
9748Warn if padding is included in a structure, either to align an element
9749of the structure or to align the whole structure. Sometimes when this
9750happens it is possible to rearrange the fields of the structure to
9751reduce the padding and so make the structure smaller.
9752
9753@item -Wredundant-decls
9754@opindex Wredundant-decls
9755@opindex Wno-redundant-decls
9756Warn if anything is declared more than once in the same scope, even in
9757cases where multiple declaration is valid and changes nothing.
9758
9759@item -Wrestrict
9760@opindex Wrestrict
9761@opindex Wno-restrict
9762Warn when an object referenced by a @code{restrict}-qualified parameter
9763(or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
9764argument, or when copies between such objects overlap. For example,
9765the call to the @code{strcpy} function below attempts to truncate the string
9766by replacing its initial characters with the last four. However, because
9767the call writes the terminating NUL into @code{a[4]}, the copies overlap and
9768the call is diagnosed.
9769
9770@smallexample
9771void foo (void)
9772@{
9773 char a[] = "abcd1234";
9774 strcpy (a, a + 4);
9775 @dots{}
9776@}
9777@end smallexample
9778The @option{-Wrestrict} option detects some instances of simple overlap
9779even without optimization but works best at @option{-O2} and above. It
9780is included in @option{-Wall}.
9781
9782@item -Wnested-externs @r{(C and Objective-C only)}
9783@opindex Wnested-externs
9784@opindex Wno-nested-externs
9785Warn if an @code{extern} declaration is encountered within a function.
9786
9787@item -Winline
9788@opindex Winline
9789@opindex Wno-inline
9790Warn if a function that is declared as inline cannot be inlined.
9791Even with this option, the compiler does not warn about failures to
9792inline functions declared in system headers.
9793
9794The compiler uses a variety of heuristics to determine whether or not
9795to inline a function. For example, the compiler takes into account
9796the size of the function being inlined and the amount of inlining
9797that has already been done in the current function. Therefore,
9798seemingly insignificant changes in the source program can cause the
9799warnings produced by @option{-Winline} to appear or disappear.
9800
9801@item -Winterference-size
9802@opindex Winterference-size
9803Warn about use of C++17 @code{std::hardware_destructive_interference_size}
9804without specifying its value with @option{--param destructive-interference-size}.
9805Also warn about questionable values for that option.
9806
9807This variable is intended to be used for controlling class layout, to
9808avoid false sharing in concurrent code:
9809
9810@smallexample
9811struct independent_fields @{
9812 alignas(std::hardware_destructive_interference_size) std::atomic<int> one;
9813 alignas(std::hardware_destructive_interference_size) std::atomic<int> two;
9814@};
9815@end smallexample
9816
9817Here @samp{one} and @samp{two} are intended to be far enough apart
9818that stores to one won't require accesses to the other to reload the
9819cache line.
9820
9821By default, @option{--param destructive-interference-size} and
9822@option{--param constructive-interference-size} are set based on the
9823current @option{-mtune} option, typically to the L1 cache line size
9824for the particular target CPU, sometimes to a range if tuning for a
9825generic target. So all translation units that depend on ABI
9826compatibility for the use of these variables must be compiled with
9827the same @option{-mtune} (or @option{-mcpu}).
9828
9829If ABI stability is important, such as if the use is in a header for a
9830library, you should probably not use the hardware interference size
9831variables at all. Alternatively, you can force a particular value
9832with @option{--param}.
9833
9834If you are confident that your use of the variable does not affect ABI
9835outside a single build of your project, you can turn off the warning
9836with @option{-Wno-interference-size}.
9837
9838@item -Wint-in-bool-context
9839@opindex Wint-in-bool-context
9840@opindex Wno-int-in-bool-context
9841Warn for suspicious use of integer values where boolean values are expected,
9842such as conditional expressions (?:) using non-boolean integer constants in
9843boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
9844integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
9845for all kinds of multiplications regardless of the data type.
9846This warning is enabled by @option{-Wall}.
9847
9848@item -Wno-int-to-pointer-cast
9849@opindex Wno-int-to-pointer-cast
9850@opindex Wint-to-pointer-cast
9851Suppress warnings from casts to pointer type of an integer of a
9852different size. In C++, casting to a pointer type of smaller size is
9853an error. @option{Wint-to-pointer-cast} is enabled by default.
9854
9855
9856@item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
9857@opindex Wno-pointer-to-int-cast
9858@opindex Wpointer-to-int-cast
9859Suppress warnings from casts from a pointer to an integer type of a
9860different size.
9861
9862@item -Winvalid-pch
9863@opindex Winvalid-pch
9864@opindex Wno-invalid-pch
9865Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
9866the search path but cannot be used.
9867
9868@item -Winvalid-utf8
9869@opindex Winvalid-utf8
9870@opindex Wno-invalid-utf8
9871Warn if an invalid UTF-8 character is found.
9872This warning is on by default for C++23 if @option{-finput-charset=UTF-8}
9873is used and turned into error with @option{-pedantic-errors}.
9874
9875@item -Wno-unicode
9876@opindex Wunicode
9877@opindex Wno-unicode
9878Don't diagnose invalid forms of delimited or named escape sequences which are
9879treated as separate tokens. @option{Wunicode} is enabled by default.
9880
9881@item -Wlong-long
9882@opindex Wlong-long
9883@opindex Wno-long-long
9884Warn if @code{long long} type is used. This is enabled by either
9885@option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
9886modes. To inhibit the warning messages, use @option{-Wno-long-long}.
9887
9888@item -Wvariadic-macros
9889@opindex Wvariadic-macros
9890@opindex Wno-variadic-macros
9891Warn if variadic macros are used in ISO C90 mode, or if the GNU
9892alternate syntax is used in ISO C99 mode. This is enabled by either
9893@option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
9894messages, use @option{-Wno-variadic-macros}.
9895
9896@item -Wno-varargs
9897@opindex Wvarargs
9898@opindex Wno-varargs
9899Do not warn upon questionable usage of the macros used to handle variable
9900arguments like @code{va_start}. These warnings are enabled by default.
9901
9902@item -Wvector-operation-performance
9903@opindex Wvector-operation-performance
9904@opindex Wno-vector-operation-performance
9905Warn if vector operation is not implemented via SIMD capabilities of the
9906architecture. Mainly useful for the performance tuning.
9907Vector operation can be implemented @code{piecewise}, which means that the
9908scalar operation is performed on every vector element;
9909@code{in parallel}, which means that the vector operation is implemented
9910using scalars of wider type, which normally is more performance efficient;
9911and @code{as a single scalar}, which means that vector fits into a
9912scalar type.
9913
9914@item -Wvla
9915@opindex Wvla
9916@opindex Wno-vla
9917Warn if a variable-length array is used in the code.
9918@option{-Wno-vla} prevents the @option{-Wpedantic} warning of
9919the variable-length array.
9920
9921@item -Wvla-larger-than=@var{byte-size}
9922@opindex Wvla-larger-than=
9923@opindex Wno-vla-larger-than
9924If this option is used, the compiler warns for declarations of
9925variable-length arrays whose size is either unbounded, or bounded
9926by an argument that allows the array size to exceed @var{byte-size}
9927bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
9928works, but with variable-length arrays.
9929
9930Note that GCC may optimize small variable-length arrays of a known
9931value into plain arrays, so this warning may not get triggered for
9932such arrays.
9933
9934@option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
9935is typically only effective when @option{-ftree-vrp} is active (default
9936for @option{-O2} and above).
9937
9938See also @option{-Walloca-larger-than=@var{byte-size}}.
9939
9940@item -Wno-vla-larger-than
9941@opindex Wno-vla-larger-than
9942Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
9943to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
9944
9945@item -Wvla-parameter
9946@opindex Wno-vla-parameter
9947Warn about redeclarations of functions involving arguments of Variable
9948Length Array types of inconsistent kinds or forms, and enable the detection
9949of out-of-bounds accesses to such parameters by warnings such as
9950@option{-Warray-bounds}.
9951
9952If the first function declaration uses the VLA form the bound specified
9953in the array is assumed to be the minimum number of elements expected to
9954be provided in calls to the function and the maximum number of elements
9955accessed by it. Failing to provide arguments of sufficient size or
9956accessing more than the maximum number of elements may be diagnosed.
9957
9958For example, the warning triggers for the following redeclarations because
9959the first one allows an array of any size to be passed to @code{f} while
9960the second one specifies that the array argument must have at least @code{n}
9961elements. In addition, calling @code{f} with the associated VLA bound
9962parameter in excess of the actual VLA bound triggers a warning as well.
9963
9964@smallexample
9965void f (int n, int[n]);
9966void f (int, int[]); // warning: argument 2 previously declared as a VLA
9967
9968void g (int n)
9969@{
9970 if (n > 4)
9971 return;
9972 int a[n];
9973 f (sizeof a, a); // warning: access to a by f may be out of bounds
9974 @dots{}
9975@}
9976
9977@end smallexample
9978
9979@option{-Wvla-parameter} is included in @option{-Wall}. The
9980@option{-Warray-parameter} option triggers warnings for similar problems
9981involving ordinary array arguments.
9982
9983@item -Wvolatile-register-var
9984@opindex Wvolatile-register-var
9985@opindex Wno-volatile-register-var
9986Warn if a register variable is declared volatile. The volatile
9987modifier does not inhibit all optimizations that may eliminate reads
9988and/or writes to register variables. This warning is enabled by
9989@option{-Wall}.
9990
9991@item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)}
9992@opindex Wxor-used-as-pow
9993@opindex Wno-xor-used-as-pow
9994Warn about uses of @code{^}, the exclusive or operator, where it appears
9995the user meant exponentiation. Specifically, the warning occurs when the
9996left-hand side is the decimal constant 2 or 10 and the right-hand side
9997is also a decimal constant.
9998
9999In C and C++, @code{^} means exclusive or, whereas in some other languages
10000(e.g. TeX and some versions of BASIC) it means exponentiation.
10001
10002This warning is enabled by default. It can be silenced by converting one
10003of the operands to hexadecimal.
10004
10005@item -Wdisabled-optimization
10006@opindex Wdisabled-optimization
10007@opindex Wno-disabled-optimization
10008Warn if a requested optimization pass is disabled. This warning does
10009not generally indicate that there is anything wrong with your code; it
10010merely indicates that GCC's optimizers are unable to handle the code
10011effectively. Often, the problem is that your code is too big or too
10012complex; GCC refuses to optimize programs when the optimization
10013itself is likely to take inordinate amounts of time.
10014
10015@item -Wpointer-sign @r{(C and Objective-C only)}
10016@opindex Wpointer-sign
10017@opindex Wno-pointer-sign
10018Warn for pointer argument passing or assignment with different signedness.
10019This option is only supported for C and Objective-C@. It is implied by
10020@option{-Wall} and by @option{-Wpedantic}, which can be disabled with
10021@option{-Wno-pointer-sign}.
10022
10023@item -Wstack-protector
10024@opindex Wstack-protector
10025@opindex Wno-stack-protector
10026This option is only active when @option{-fstack-protector} is active. It
10027warns about functions that are not protected against stack smashing.
10028
10029@item -Woverlength-strings
10030@opindex Woverlength-strings
10031@opindex Wno-overlength-strings
10032Warn about string constants that are longer than the ``minimum
10033maximum'' length specified in the C standard. Modern compilers
10034generally allow string constants that are much longer than the
10035standard's minimum limit, but very portable programs should avoid
10036using longer strings.
10037
10038The limit applies @emph{after} string constant concatenation, and does
10039not count the trailing NUL@. In C90, the limit was 509 characters; in
10040C99, it was raised to 4095. C++98 does not specify a normative
10041minimum maximum, so we do not diagnose overlength strings in C++@.
10042
10043This option is implied by @option{-Wpedantic}, and can be disabled with
10044@option{-Wno-overlength-strings}.
10045
10046@item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
10047@opindex Wunsuffixed-float-constants
10048@opindex Wno-unsuffixed-float-constants
10049
10050Issue a warning for any floating constant that does not have
10051a suffix. When used together with @option{-Wsystem-headers} it
10052warns about such constants in system header files. This can be useful
10053when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
10054from the decimal floating-point extension to C99.
10055
10056@item -Wno-lto-type-mismatch
10057@opindex Wlto-type-mismatch
10058@opindex Wno-lto-type-mismatch
10059
10060During the link-time optimization, do not warn about type mismatches in
10061global declarations from different compilation units.
10062Requires @option{-flto} to be enabled. Enabled by default.
10063
10064@item -Wno-designated-init @r{(C and Objective-C only)}
10065@opindex Wdesignated-init
10066@opindex Wno-designated-init
10067Suppress warnings when a positional initializer is used to initialize
10068a structure that has been marked with the @code{designated_init}
10069attribute.
10070
10071@end table
10072
10073@node Static Analyzer Options
10074@section Options That Control Static Analysis
10075
10076@table @gcctabopt
10077@item -fanalyzer
10078@opindex analyzer
10079@opindex fanalyzer
10080@opindex fno-analyzer
10081This option enables an static analysis of program flow which looks
10082for ``interesting'' interprocedural paths through the
10083code, and issues warnings for problems found on them.
10084
10085This analysis is much more expensive than other GCC warnings.
10086
a90316c6
DM
10087In technical terms, it performs coverage-guided symbolic execution of
10088the code being compiled. It is neither sound nor complete: it can
10089have false positives and false negatives. It is a bug-finding tool,
10090rather than a tool for proving program correctness.
10091
10092The analyzer is only suitable for use on C code in this release.
10093
d77de738
ML
10094Enabling this option effectively enables the following warnings:
10095
10096@gccoptlist{ @gol
10097-Wanalyzer-allocation-size @gol
ce51e843 10098-Wanalyzer-deref-before-check @gol
d77de738
ML
10099-Wanalyzer-double-fclose @gol
10100-Wanalyzer-double-free @gol
10101-Wanalyzer-exposure-through-output-file @gol
10102-Wanalyzer-exposure-through-uninit-copy @gol
10103-Wanalyzer-fd-access-mode-mismatch @gol
10104-Wanalyzer-fd-double-close @gol
10105-Wanalyzer-fd-leak @gol
86a90006
DM
10106-Wanalyzer-fd-phase-mismatch @gol
10107-Wanalyzer-fd-type-mismatch @gol
d77de738
ML
10108-Wanalyzer-fd-use-after-close @gol
10109-Wanalyzer-fd-use-without-check @gol
10110-Wanalyzer-file-leak @gol
10111-Wanalyzer-free-of-non-heap @gol
10112-Wanalyzer-imprecise-fp-arithmetic @gol
ce51e843 10113-Wanalyzer-infinite-recursion @gol
d77de738
ML
10114-Wanalyzer-jump-through-null @gol
10115-Wanalyzer-malloc-leak @gol
10116-Wanalyzer-mismatching-deallocation @gol
10117-Wanalyzer-null-argument @gol
10118-Wanalyzer-null-dereference @gol
10119-Wanalyzer-out-of-bounds @gol
10120-Wanalyzer-possible-null-argument @gol
10121-Wanalyzer-possible-null-dereference @gol
10122-Wanalyzer-putenv-of-auto-var @gol
10123-Wanalyzer-shift-count-negative @gol
10124-Wanalyzer-shift-count-overflow @gol
10125-Wanalyzer-stale-setjmp-buffer @gol
10126-Wanalyzer-unsafe-call-within-signal-handler @gol
10127-Wanalyzer-use-after-free @gol
10128-Wanalyzer-use-of-pointer-in-stale-stack-frame @gol
10129-Wanalyzer-use-of-uninitialized-value @gol
10130-Wanalyzer-va-arg-type-mismatch @gol
10131-Wanalyzer-va-list-exhausted @gol
10132-Wanalyzer-va-list-leak @gol
10133-Wanalyzer-va-list-use-after-va-end @gol
10134-Wanalyzer-write-to-const @gol
10135-Wanalyzer-write-to-string-literal @gol
10136}
10137@ignore
10138-Wanalyzer-tainted-allocation-size @gol
10139-Wanalyzer-tainted-array-index @gol
10140-Wanalyzer-tainted-divisor @gol
10141-Wanalyzer-tainted-offset @gol
10142-Wanalyzer-tainted-size @gol
10143@end ignore
10144
10145This option is only available if GCC was configured with analyzer
10146support enabled.
10147
10148@item -Wanalyzer-too-complex
10149@opindex Wanalyzer-too-complex
10150@opindex Wno-analyzer-too-complex
10151If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
10152to attempt to explore the control flow and data flow in the program,
10153but these can be defeated by sufficiently complicated code.
10154
10155By default, the analysis silently stops if the code is too
10156complicated for the analyzer to fully explore and it reaches an internal
10157limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
10158
10159@item -Wno-analyzer-allocation-size
10160@opindex Wanalyzer-allocation-size
10161@opindex Wno-analyzer-allocation-size
10162This warning requires @option{-fanalyzer}, which enables it; use
10163@option{-Wno-analyzer-allocation-size}
10164to disable it.
10165
10166This diagnostic warns for paths through the code in which a pointer to
10167a buffer is assigned to point at a buffer with a size that is not a
10168multiple of @code{sizeof (*pointer)}.
10169
10170See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}.
10171
ce51e843
ML
10172@item -Wno-analyzer-deref-before-check
10173@opindex Wanalyzer-deref-before-check
10174@opindex Wno-analyzer-deref-before-check
10175This warning requires @option{-fanalyzer}, which enables it; use
10176@option{-Wno-analyzer-deref-before-check}
10177to disable it.
10178
10179This diagnostic warns for paths through the code in which a pointer
10180is checked for @code{NULL} *after* it has already been
10181dereferenced, suggesting that the pointer could have been NULL.
10182Such cases suggest that the check for NULL is either redundant,
10183or that it needs to be moved to before the pointer is dereferenced.
10184
10185This diagnostic also considers values passed to a function argument
10186marked with @code{__attribute__((nonnull))} as requiring a non-NULL
10187value, and thus will complain if such values are checked for @code{NULL}
10188after returning from such a function call.
10189
10190This diagnostic is unlikely to be reported when any level of optimization
10191is enabled, as GCC's optimization logic will typically consider such
10192checks for NULL as being redundant, and optimize them away before the
10193analyzer "sees" them. Hence optimization should be disabled when
10194attempting to trigger this diagnostic.
10195
d77de738
ML
10196@item -Wno-analyzer-double-fclose
10197@opindex Wanalyzer-double-fclose
10198@opindex Wno-analyzer-double-fclose
10199This warning requires @option{-fanalyzer}, which enables it; use
10200@option{-Wno-analyzer-double-fclose} to disable it.
10201
10202This diagnostic warns for paths through the code in which a @code{FILE *}
10203can have @code{fclose} called on it more than once.
10204
10205See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10206
10207@item -Wno-analyzer-double-free
10208@opindex Wanalyzer-double-free
10209@opindex Wno-analyzer-double-free
10210This warning requires @option{-fanalyzer}, which enables it; use
10211@option{-Wno-analyzer-double-free} to disable it.
10212
10213This diagnostic warns for paths through the code in which a pointer
10214can have a deallocator called on it more than once, either @code{free},
10215or a deallocator referenced by attribute @code{malloc}.
10216
10217See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}.
10218
10219@item -Wno-analyzer-exposure-through-output-file
10220@opindex Wanalyzer-exposure-through-output-file
10221@opindex Wno-analyzer-exposure-through-output-file
10222This warning requires @option{-fanalyzer}, which enables it; use
10223@option{-Wno-analyzer-exposure-through-output-file}
10224to disable it.
10225
10226This diagnostic warns for paths through the code in which a
10227security-sensitive value is written to an output file
10228(such as writing a password to a log file).
10229
10230See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}.
10231
10232@item -Wanalyzer-exposure-through-uninit-copy
10233@opindex Wanalyzer-exposure-through-uninit-copy
10234@opindex Wno-analyzer-exposure-through-uninit-copy
10235This warning requires both @option{-fanalyzer} and the use of a plugin
10236to specify a function that copies across a ``trust boundary''. Use
10237@option{-Wno-analyzer-exposure-through-uninit-copy} to disable it.
10238
10239This diagnostic warns for ``infoleaks'' - paths through the code in which
10240uninitialized values are copied across a security boundary
10241(such as code within an OS kernel that copies a partially-initialized
10242struct on the stack to user space).
10243
10244See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}.
10245
10246@item -Wno-analyzer-fd-access-mode-mismatch
10247@opindex Wanalyzer-fd-access-mode-mismatch
10248@opindex Wno-analyzer-fd-access-mode-mismatch
10249This warning requires @option{-fanalyzer}, which enables it; use
10250@option{-Wno-analyzer-fd-access-mode-mismatch}
10251to disable it.
10252
10253This diagnostic warns for paths through code in which a
10254@code{read} on a write-only file descriptor is attempted, or vice versa.
10255
10256This diagnostic also warns for code paths in a which a function with attribute
10257@code{fd_arg_read (N)} is called with a file descriptor opened with
10258@code{O_WRONLY} at referenced argument @code{N} or a function with attribute
10259@code{fd_arg_write (N)} is called with a file descriptor opened with
10260@code{O_RDONLY} at referenced argument @var{N}.
10261
10262@item -Wno-analyzer-fd-double-close
10263@opindex Wanalyzer-fd-double-close
10264@opindex Wno-analyzer-fd-double-close
10265This warning requires @option{-fanalyzer}, which enables it; use
10266@option{-Wno-analyzer-fd-double-close}
10267to disable it.
10268
10269This diagnostic warns for paths through code in which a
10270file descriptor can be closed more than once.
10271
10272See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10273
10274@item -Wno-analyzer-fd-leak
10275@opindex Wanalyzer-fd-leak
10276@opindex Wno-analyzer-fd-leak
10277This warning requires @option{-fanalyzer}, which enables it; use
10278@option{-Wno-analyzer-fd-leak}
10279to disable it.
10280
10281This diagnostic warns for paths through code in which an
10282open file descriptor is leaked.
10283
10284See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10285
86a90006
DM
10286@item -Wno-analyzer-fd-phase-mismatch
10287@opindex Wanalyzer-fd-phase-mismatch
10288@opindex Wno-analyzer-fd-phase-mismatch
10289This warning requires @option{-fanalyzer}, which enables it; use
10290@option{-Wno-analyzer-fd-phase-mismatch}
10291to disable it.
10292
10293This diagnostic warns for paths through code in which an operation is
10294attempted in the wrong phase of a file descriptor's lifetime.
10295For example, it will warn on attempts to call @code{accept} on a stream
10296socket that has not yet had @code{listen} successfully called on it.
10297
10298See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}.
10299
10300@item -Wno-analyzer-fd-type-mismatch
10301@opindex Wanalyzer-fd-type-mismatch
10302@opindex Wno-analyzer-fd-type-mismatch
10303This warning requires @option{-fanalyzer}, which enables it; use
10304@option{-Wno-analyzer-fd-type-mismatch}
10305to disable it.
10306
10307This diagnostic warns for paths through code in which an
10308operation is attempted on the wrong type of file descriptor.
10309For example, it will warn on attempts to use socket operations
10310on a file descriptor obtained via @code{open}, or when attempting
10311to use a stream socket operation on a datagram socket.
10312
d77de738
ML
10313@item -Wno-analyzer-fd-use-after-close
10314@opindex Wanalyzer-fd-use-after-close
10315@opindex Wno-analyzer-fd-use-after-close
10316This warning requires @option{-fanalyzer}, which enables it; use
10317@option{-Wno-analyzer-fd-use-after-close}
10318to disable it.
10319
10320This diagnostic warns for paths through code in which a
10321read or write is called on a closed file descriptor.
10322
10323This diagnostic also warns for paths through code in which
10324a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10325or @code{fd_arg_write (N)} is called with a closed file descriptor at
10326referenced argument @code{N}.
10327
10328@item -Wno-analyzer-fd-use-without-check
10329@opindex Wanalyzer-fd-use-without-check
10330@opindex Wno-analyzer-fd-use-without-check
10331This warning requires @option{-fanalyzer}, which enables it; use
10332@option{-Wno-analyzer-fd-use-without-check}
10333to disable it.
10334
10335This diagnostic warns for paths through code in which a
10336file descriptor is used without being checked for validity.
10337
10338This diagnostic also warns for paths through code in which
10339a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10340or @code{fd_arg_write (N)} is called with a file descriptor, at referenced
10341argument @code{N}, without being checked for validity.
10342
10343@item -Wno-analyzer-file-leak
10344@opindex Wanalyzer-file-leak
10345@opindex Wno-analyzer-file-leak
10346This warning requires @option{-fanalyzer}, which enables it; use
10347@option{-Wno-analyzer-file-leak}
10348to disable it.
10349
10350This diagnostic warns for paths through the code in which a
10351@code{<stdio.h>} @code{FILE *} stream object is leaked.
10352
10353See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10354
10355@item -Wno-analyzer-free-of-non-heap
10356@opindex Wanalyzer-free-of-non-heap
10357@opindex Wno-analyzer-free-of-non-heap
10358This warning requires @option{-fanalyzer}, which enables it; use
10359@option{-Wno-analyzer-free-of-non-heap}
10360to disable it.
10361
10362This diagnostic warns for paths through the code in which @code{free}
10363is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
10364
10365See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}.
10366
10367@item -Wno-analyzer-imprecise-fp-arithmetic
10368@opindex Wanalyzer-imprecise-fp-arithmetic
10369@opindex Wno-analyzer-imprecise-fp-arithmetic
10370This warning requires @option{-fanalyzer}, which enables it; use
10371@option{-Wno-analyzer-imprecise-fp-arithmetic}
10372to disable it.
10373
10374This diagnostic warns for paths through the code in which floating-point
10375arithmetic is used in locations where precise computation is needed. This
10376diagnostic only warns on use of floating-point operands inside the
10377calculation of an allocation size at the moment.
10378
ce51e843
ML
10379@item -Wno-analyzer-infinite-recursion
10380@opindex Wanalyzer-infinite-recursion
10381@opindex Wno-analyzer-infinite-recursion
10382This warning requires @option{-fanalyzer}, which enables it; use
10383@option{-Wno-analyzer-infinite-recursion} to disable it.
10384
10385This diagnostics warns for paths through the code which appear to
10386lead to infinite recursion.
10387
10388Specifically, when the analyzer "sees" a recursive call, it will compare
10389the state of memory at the entry to the new frame with that at the entry
10390to the previous frame of that function on the stack. The warning is
10391issued if nothing in memory appears to be changing; any changes observed
10392to parameters or globals are assumed to lead to termination of the
10393recursion and thus suppress the warning.
10394
10395This diagnostic is likely to miss cases of infinite recursion that
10396are convered to iteration by the optimizer before the analyzer "sees"
10397them. Hence optimization should be disabled when attempting to trigger
10398this diagnostic.
10399
10400Compare with @option{-Winfinite-recursion}, which provides a similar
10401diagnostic, but is implemented in a different way.
10402
d77de738
ML
10403@item -Wno-analyzer-jump-through-null
10404@opindex Wanalyzer-jump-through-null
10405@opindex Wno-analyzer-jump-through-null
10406This warning requires @option{-fanalyzer}, which enables it; use
10407@option{-Wno-analyzer-jump-through-null}
10408to disable it.
10409
10410This diagnostic warns for paths through the code in which a @code{NULL}
10411function pointer is called.
10412
10413@item -Wno-analyzer-malloc-leak
10414@opindex Wanalyzer-malloc-leak
10415@opindex Wno-analyzer-malloc-leak
10416This warning requires @option{-fanalyzer}, which enables it; use
10417@option{-Wno-analyzer-malloc-leak}
10418to disable it.
10419
10420This diagnostic warns for paths through the code in which a
10421pointer allocated via an allocator is leaked: either @code{malloc},
10422or a function marked with attribute @code{malloc}.
10423
10424See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}.
10425
10426@item -Wno-analyzer-mismatching-deallocation
10427@opindex Wanalyzer-mismatching-deallocation
10428@opindex Wno-analyzer-mismatching-deallocation
10429This warning requires @option{-fanalyzer}, which enables it; use
10430@option{-Wno-analyzer-mismatching-deallocation}
10431to disable it.
10432
10433This diagnostic warns for paths through the code in which the
10434wrong deallocation function is called on a pointer value, based on
10435which function was used to allocate the pointer value. The diagnostic
10436will warn about mismatches between @code{free}, scalar @code{delete}
10437and vector @code{delete[]}, and those marked as allocator/deallocator
10438pairs using attribute @code{malloc}.
10439
10440See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}.
10441
10442@item -Wno-analyzer-out-of-bounds
10443@opindex Wanalyzer-out-of-bounds
10444@opindex Wno-analyzer-out-of-bounds
10445This warning requires @option{-fanalyzer} to enable it; use
10446@option{-Wno-analyzer-out-of-bounds} to disable it.
10447
10448This diagnostic warns for path through the code in which a buffer is
10449definitely read or written out-of-bounds. The diagnostic applies for
10450cases where the analyzer is able to determine a constant offset and for
10451accesses past the end of a buffer, also a constant capacity. Further,
10452the diagnostic does limited checking for accesses past the end when the
10453offset as well as the capacity is symbolic.
10454
10455See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}.
10456
10457@item -Wno-analyzer-possible-null-argument
10458@opindex Wanalyzer-possible-null-argument
10459@opindex Wno-analyzer-possible-null-argument
10460This warning requires @option{-fanalyzer}, which enables it; use
10461@option{-Wno-analyzer-possible-null-argument} to disable it.
10462
10463This diagnostic warns for paths through the code in which a
10464possibly-NULL value is passed to a function argument marked
10465with @code{__attribute__((nonnull))} as requiring a non-NULL
10466value.
10467
10468See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10469
10470@item -Wno-analyzer-possible-null-dereference
10471@opindex Wanalyzer-possible-null-dereference
10472@opindex Wno-analyzer-possible-null-dereference
10473This warning requires @option{-fanalyzer}, which enables it; use
10474@option{-Wno-analyzer-possible-null-dereference} to disable it.
10475
10476This diagnostic warns for paths through the code in which a
10477possibly-NULL value is dereferenced.
10478
10479See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10480
10481@item -Wno-analyzer-null-argument
10482@opindex Wanalyzer-null-argument
10483@opindex Wno-analyzer-null-argument
10484This warning requires @option{-fanalyzer}, which enables it; use
10485@option{-Wno-analyzer-null-argument} to disable it.
10486
10487This diagnostic warns for paths through the code in which a
10488value known to be NULL is passed to a function argument marked
10489with @code{__attribute__((nonnull))} as requiring a non-NULL
10490value.
10491
10492See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10493
10494@item -Wno-analyzer-null-dereference
10495@opindex Wanalyzer-null-dereference
10496@opindex Wno-analyzer-null-dereference
10497This warning requires @option{-fanalyzer}, which enables it; use
10498@option{-Wno-analyzer-null-dereference} to disable it.
10499
10500This diagnostic warns for paths through the code in which a
10501value known to be NULL is dereferenced.
10502
10503See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10504
10505@item -Wno-analyzer-putenv-of-auto-var
10506@opindex Wanalyzer-putenv-of-auto-var
10507@opindex Wno-analyzer-putenv-of-auto-var
10508This warning requires @option{-fanalyzer}, which enables it; use
10509@option{-Wno-analyzer-putenv-of-auto-var} to disable it.
10510
10511This diagnostic warns for paths through the code in which a
10512call to @code{putenv} is passed a pointer to an automatic variable
10513or an on-stack buffer.
10514
10515See @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}.
10516
10517@item -Wno-analyzer-shift-count-negative
10518@opindex Wanalyzer-shift-count-negative
10519@opindex Wno-analyzer-shift-count-negative
10520This warning requires @option{-fanalyzer}, which enables it; use
10521@option{-Wno-analyzer-shift-count-negative} to disable it.
10522
10523This diagnostic warns for paths through the code in which a
10524shift is attempted with a negative count. It is analogous to
10525the @option{-Wshift-count-negative} diagnostic implemented in
10526the C/C++ front ends, but is implemented based on analyzing
10527interprocedural paths, rather than merely parsing the syntax tree.
10528However, the analyzer does not prioritize detection of such paths, so
10529false negatives are more likely relative to other warnings.
10530
10531@item -Wno-analyzer-shift-count-overflow
10532@opindex Wanalyzer-shift-count-overflow
10533@opindex Wno-analyzer-shift-count-overflow
10534This warning requires @option{-fanalyzer}, which enables it; use
10535@option{-Wno-analyzer-shift-count-overflow} to disable it.
10536
10537This diagnostic warns for paths through the code in which a
10538shift is attempted with a count greater than or equal to the
10539precision of the operand's type. It is analogous to
10540the @option{-Wshift-count-overflow} diagnostic implemented in
10541the C/C++ front ends, but is implemented based on analyzing
10542interprocedural paths, rather than merely parsing the syntax tree.
10543However, the analyzer does not prioritize detection of such paths, so
10544false negatives are more likely relative to other warnings.
10545
10546@item -Wno-analyzer-stale-setjmp-buffer
10547@opindex Wanalyzer-stale-setjmp-buffer
10548@opindex Wno-analyzer-stale-setjmp-buffer
10549This warning requires @option{-fanalyzer}, which enables it; use
10550@option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
10551
10552This diagnostic warns for paths through the code in which
10553@code{longjmp} is called to rewind to a @code{jmp_buf} relating
10554to a @code{setjmp} call in a function that has returned.
10555
10556When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
10557location, it records the stack frame. The stack frame becomes invalid
10558when the function containing the @code{setjmp} call returns. Attempting
10559to rewind to it via @code{longjmp} would reference a stack frame that
10560no longer exists, and likely lead to a crash (or worse).
10561
10562@item -Wno-analyzer-tainted-allocation-size
10563@opindex Wanalyzer-tainted-allocation-size
10564@opindex Wno-analyzer-tainted-allocation-size
10565This warning requires both @option{-fanalyzer} and
10566@option{-fanalyzer-checker=taint} to enable it;
10567use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
10568
10569This diagnostic warns for paths through the code in which a value
10570that could be under an attacker's control is used as the size
10571of an allocation without being sanitized, so that an attacker could
10572inject an excessively large allocation and potentially cause a denial
10573of service attack.
10574
10575See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
10576
ce51e843
ML
10577@item -Wno-analyzer-tainted-assertion
10578@opindex Wanalyzer-tainted-assertion
10579@opindex Wno-analyzer-tainted-assertion
10580
10581This warning requires both @option{-fanalyzer} and
10582@option{-fanalyzer-checker=taint} to enable it;
10583use @option{-Wno-analyzer-tainted-assertion} to disable it.
10584
10585This diagnostic warns for paths through the code in which a value
10586that could be under an attacker's control is used as part of a
10587condition without being first sanitized, and that condition guards a
10588call to a function marked with attribute @code{noreturn}
10589(such as the function @code{__builtin_unreachable}). Such functions
10590typically indicate abnormal termination of the program, such as for
10591assertion failure handlers. For example:
10592
10593@smallexample
10594assert (some_tainted_value < SOME_LIMIT);
10595@end smallexample
10596
10597In such cases:
10598
10599@itemize
10600@item
10601when assertion-checking is enabled: an attacker could trigger
10602a denial of service by injecting an assertion failure
10603
10604@item
10605when assertion-checking is disabled, such as by defining @code{NDEBUG},
10606an attacker could inject data that subverts the process, since it
10607presumably violates a precondition that is being assumed by the code.
10608
10609@end itemize
10610
10611Note that when assertion-checking is disabled, the assertions are
10612typically removed by the preprocessor before the analyzer has a chance
10613to "see" them, so this diagnostic can only generate warnings on builds
10614in which assertion-checking is enabled.
10615
10616For the purpose of this warning, any function marked with attribute
10617@code{noreturn} is considered as a possible assertion failure
10618handler, including @code{__builtin_unreachable}. Note that these functions
10619are sometimes removed by the optimizer before the analyzer "sees" them.
10620Hence optimization should be disabled when attempting to trigger this
10621diagnostic.
10622
10623See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}.
10624
10625The warning can also report problematic constructions such as
10626
10627@smallexample
10628switch (some_tainted_value) @{
10629case 0:
10630 /* [...etc; various valid cases omitted...] */
10631 break;
10632
10633default:
10634 __builtin_unreachable (); /* BUG: attacker can trigger this */
10635@}
10636@end smallexample
10637
10638despite the above not being an assertion failure, strictly speaking.
10639
d77de738
ML
10640@item -Wno-analyzer-tainted-array-index
10641@opindex Wanalyzer-tainted-array-index
10642@opindex Wno-analyzer-tainted-array-index
10643This warning requires both @option{-fanalyzer} and
10644@option{-fanalyzer-checker=taint} to enable it;
10645use @option{-Wno-analyzer-tainted-array-index} to disable it.
10646
10647This diagnostic warns for paths through the code in which a value
10648that could be under an attacker's control is used as the index
10649of an array access without being sanitized, so that an attacker
10650could inject an out-of-bounds access.
10651
10652See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10653
10654@item -Wno-analyzer-tainted-divisor
10655@opindex Wanalyzer-tainted-divisor
10656@opindex Wno-analyzer-tainted-divisor
10657This warning requires both @option{-fanalyzer} and
10658@option{-fanalyzer-checker=taint} to enable it;
10659use @option{-Wno-analyzer-tainted-divisor} to disable it.
10660
10661This diagnostic warns for paths through the code in which a value
10662that could be under an attacker's control is used as the divisor
10663in a division or modulus operation without being sanitized, so that
10664an attacker could inject a division-by-zero.
10665
10666See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}.
10667
10668@item -Wno-analyzer-tainted-offset
10669@opindex Wanalyzer-tainted-offset
10670@opindex Wno-analyzer-tainted-offset
10671This warning requires both @option{-fanalyzer} and
10672@option{-fanalyzer-checker=taint} to enable it;
10673use @option{-Wno-analyzer-tainted-offset} to disable it.
10674
10675This diagnostic warns for paths through the code in which a value
10676that could be under an attacker's control is used as a pointer offset
10677without being sanitized, so that an attacker could inject an out-of-bounds
10678access.
10679
10680See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
10681
10682@item -Wno-analyzer-tainted-size
10683@opindex Wanalyzer-tainted-size
10684@opindex Wno-analyzer-tainted-size
10685This warning requires both @option{-fanalyzer} and
10686@option{-fanalyzer-checker=taint} to enable it;
10687use @option{-Wno-analyzer-tainted-size} to disable it.
10688
10689This diagnostic warns for paths through the code in which a value
10690that could be under an attacker's control is used as the size of
10691an operation such as @code{memset} without being sanitized, so that an
10692attacker could inject an out-of-bounds access.
10693
10694See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10695
10696@item -Wno-analyzer-unsafe-call-within-signal-handler
10697@opindex Wanalyzer-unsafe-call-within-signal-handler
10698@opindex Wno-analyzer-unsafe-call-within-signal-handler
10699This warning requires @option{-fanalyzer}, which enables it; use
10700@option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
10701
10702This diagnostic warns for paths through the code in which a
10703function known to be async-signal-unsafe (such as @code{fprintf}) is
10704called from a signal handler.
10705
10706See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}.
10707
10708@item -Wno-analyzer-use-after-free
10709@opindex Wanalyzer-use-after-free
10710@opindex Wno-analyzer-use-after-free
10711This warning requires @option{-fanalyzer}, which enables it; use
10712@option{-Wno-analyzer-use-after-free} to disable it.
10713
10714This diagnostic warns for paths through the code in which a
10715pointer is used after a deallocator is called on it: either @code{free},
10716or a deallocator referenced by attribute @code{malloc}.
10717
10718See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}.
10719
10720@item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
10721@opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
10722@opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
10723This warning requires @option{-fanalyzer}, which enables it; use
10724@option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
10725to disable it.
10726
10727This diagnostic warns for paths through the code in which a pointer
10728is dereferenced that points to a variable in a stale stack frame.
10729
10730@item -Wno-analyzer-va-arg-type-mismatch
10731@opindex Wanalyzer-va-arg-type-mismatch
10732@opindex Wno-analyzer-va-arg-type-mismatch
10733This warning requires @option{-fanalyzer}, which enables it; use
10734@option{-Wno-analyzer-va-arg-type-mismatch}
10735to disable it.
10736
10737This diagnostic warns for interprocedural paths through the code for which
10738the analyzer detects an attempt to use @code{va_arg} to extract a value
10739passed to a variadic call, but uses a type that does not match that of
10740the expression passed to the call.
10741
10742See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}.
10743
10744@item -Wno-analyzer-va-list-exhausted
10745@opindex Wanalyzer-va-list-exhausted
10746@opindex Wno-analyzer-va-list-exhausted
10747This warning requires @option{-fanalyzer}, which enables it; use
10748@option{-Wno-analyzer-va-list-exhausted}
10749to disable it.
10750
10751This diagnostic warns for interprocedural paths through the code for which
10752the analyzer detects an attempt to use @code{va_arg} to access the next
10753value passed to a variadic call, but all of the values in the
10754@code{va_list} have already been consumed.
10755
10756See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}.
10757
10758@item -Wno-analyzer-va-list-leak
10759@opindex Wanalyzer-va-list-leak
10760@opindex Wno-analyzer-va-list-leak
10761This warning requires @option{-fanalyzer}, which enables it; use
10762@option{-Wno-analyzer-va-list-leak}
10763to disable it.
10764
10765This diagnostic warns for interprocedural paths through the code for which
10766the analyzer detects that @code{va_start} or @code{va_copy} has been called
10767on a @code{va_list} without a corresponding call to @code{va_end}.
10768
10769@item -Wno-analyzer-va-list-use-after-va-end
10770@opindex Wanalyzer-va-list-use-after-va-end
10771@opindex Wno-analyzer-va-list-use-after-va-end
10772This warning requires @option{-fanalyzer}, which enables it; use
10773@option{-Wno-analyzer-va-list-use-after-va-end}
10774to disable it.
10775
10776This diagnostic warns for interprocedural paths through the code for which
10777the analyzer detects an attempt to use a @code{va_list} after
10778@code{va_end} has been called on it.
10779@code{va_list}.
10780
10781@item -Wno-analyzer-write-to-const
10782@opindex Wanalyzer-write-to-const
10783@opindex Wno-analyzer-write-to-const
10784This warning requires @option{-fanalyzer}, which enables it; use
10785@option{-Wno-analyzer-write-to-const}
10786to disable it.
10787
10788This diagnostic warns for paths through the code in which the analyzer
10789detects an attempt to write through a pointer to a @code{const} object.
10790However, the analyzer does not prioritize detection of such paths, so
10791false negatives are more likely relative to other warnings.
10792
10793@item -Wno-analyzer-write-to-string-literal
10794@opindex Wanalyzer-write-to-string-literal
10795@opindex Wno-analyzer-write-to-string-literal
10796This warning requires @option{-fanalyzer}, which enables it; use
10797@option{-Wno-analyzer-write-to-string-literal}
10798to disable it.
10799
10800This diagnostic warns for paths through the code in which the analyzer
10801detects an attempt to write through a pointer to a string literal.
10802However, the analyzer does not prioritize detection of such paths, so
10803false negatives are more likely relative to other warnings.
10804
10805@item -Wno-analyzer-use-of-uninitialized-value
10806@opindex Wanalyzer-use-of-uninitialized-value
10807@opindex Wno-analyzer-use-of-uninitialized-value
10808This warning requires @option{-fanalyzer}, which enables it; use
10809@option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
10810
10811This diagnostic warns for paths through the code in which an uninitialized
10812value is used.
10813
10814See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}.
10815
10816@end table
10817
10818The analyzer has hardcoded knowledge about the behavior of the following
10819memory-management functions:
10820
10821@itemize @bullet
10822@item @code{alloca}
10823@item The built-in functions @code{__builtin_alloc},
10824@code{__builtin_alloc_with_align}, @item @code{__builtin_calloc},
10825@code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy},
10826@code{__builtin_memcpy_chk}, @code{__builtin_memset},
10827@code{__builtin_memset_chk}, @code{__builtin_realloc},
10828@code{__builtin_stack_restore}, and @code{__builtin_stack_save}
10829@item @code{calloc}
10830@item @code{free}
10831@item @code{malloc}
10832@item @code{memset}
10833@item @code{operator delete}
10834@item @code{operator delete []}
10835@item @code{operator new}
10836@item @code{operator new []}
10837@item @code{realloc}
10838@item @code{strdup}
10839@item @code{strndup}
10840@end itemize
10841
10842of the following functions for working with file descriptors:
10843
10844@itemize @bullet
10845@item @code{open}
10846@item @code{close}
10847@item @code{creat}
10848@item @code{dup}, @code{dup2} and @code{dup3}
78a17f44 10849@item @code{isatty}
d77de738
ML
10850@item @code{pipe}, and @code{pipe2}
10851@item @code{read}
10852@item @code{write}
86a90006 10853@item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect}
d77de738
ML
10854@end itemize
10855
10856of the following functions for working with @code{<stdio.h>} streams:
10857@itemize @bullet
10858@item The built-in functions @code{__builtin_fprintf},
10859@code{__builtin_fprintf_unlocked}, @code{__builtin_fputc},
10860@code{__builtin_fputc_unlocked}, @code{__builtin_fputs},
10861@code{__builtin_fputs_unlocked}, @code{__builtin_fwrite},
10862@code{__builtin_fwrite_unlocked}, @code{__builtin_printf},
10863@code{__builtin_printf_unlocked}, @code{__builtin_putc},
10864@code{__builtin_putchar}, @code{__builtin_putchar_unlocked},
10865@code{__builtin_putc_unlocked}, @code{__builtin_puts},
10866@code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and
10867@code{__builtin_vprintf}
10868@item @code{fopen}
10869@item @code{fclose}
78a17f44 10870@item @code{ferror}
d77de738
ML
10871@item @code{fgets}
10872@item @code{fgets_unlocked}
78a17f44 10873@item @code{fileno}
d77de738 10874@item @code{fread}
78a17f44 10875@item @code{getc}
d77de738
ML
10876@item @code{getchar}
10877@item @code{fprintf}
10878@item @code{printf}
10879@item @code{fwrite}
10880@end itemize
10881
10882and of the following functions:
10883
10884@itemize @bullet
10885@item The built-in functions @code{__builtin_expect},
10886@code{__builtin_expect_with_probability}, @code{__builtin_strchr},
10887@code{__builtin_strcpy}, @code{__builtin_strcpy_chk},
10888@code{__builtin_strlen}, @code{__builtin_va_copy}, and
10889@code{__builtin_va_start}
10890@item The GNU extensions @code{error} and @code{error_at_line}
10891@item @code{getpass}
10892@item @code{longjmp}
10893@item @code{putenv}
10894@item @code{setjmp}
10895@item @code{siglongjmp}
10896@item @code{signal}
10897@item @code{sigsetjmp}
10898@item @code{strchr}
10899@item @code{strlen}
10900@end itemize
10901
10902In addition, various functions with an @code{__analyzer_} prefix have
10903special meaning to the analyzer, described in the GCC Internals manual.
10904
10905Pertinent parameters for controlling the exploration are:
10906@option{--param analyzer-bb-explosion-factor=@var{value}},
10907@option{--param analyzer-max-enodes-per-program-point=@var{value}},
10908@option{--param analyzer-max-recursion-depth=@var{value}}, and
10909@option{--param analyzer-min-snodes-for-call-summary=@var{value}}.
10910
10911The following options control the analyzer.
10912
10913@table @gcctabopt
10914
10915@item -fanalyzer-call-summaries
10916@opindex fanalyzer-call-summaries
10917@opindex fno-analyzer-call-summaries
10918Simplify interprocedural analysis by computing the effect of certain calls,
10919rather than exploring all paths through the function from callsite to each
10920possible return.
10921
10922If enabled, call summaries are only used for functions with more than one
10923call site, and that are sufficiently complicated (as per
10924@option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
10925
10926@item -fanalyzer-checker=@var{name}
10927@opindex fanalyzer-checker
10928Restrict the analyzer to run just the named checker, and enable it.
10929
10930Some checkers are disabled by default (even with @option{-fanalyzer}),
10931such as the @code{taint} checker that implements
10932@option{-Wanalyzer-tainted-array-index}, and this option is required
10933to enable them.
10934
10935@emph{Note:} currently, @option{-fanalyzer-checker=taint} disables the
10936following warnings from @option{-fanalyzer}:
10937
10938@gccoptlist{ @gol
ce51e843 10939-Wanalyzer-deref-before-check @gol
d77de738
ML
10940-Wanalyzer-double-fclose @gol
10941-Wanalyzer-double-free @gol
10942-Wanalyzer-exposure-through-output-file @gol
10943-Wanalyzer-fd-access-mode-mismatch @gol
10944-Wanalyzer-fd-double-close @gol
10945-Wanalyzer-fd-leak @gol
10946-Wanalyzer-fd-use-after-close @gol
10947-Wanalyzer-fd-use-without-check @gol
10948-Wanalyzer-file-leak @gol
10949-Wanalyzer-free-of-non-heap @gol
10950-Wanalyzer-malloc-leak @gol
10951-Wanalyzer-mismatching-deallocation @gol
10952-Wanalyzer-null-argument @gol
10953-Wanalyzer-null-dereference @gol
10954-Wanalyzer-possible-null-argument @gol
10955-Wanalyzer-possible-null-dereference @gol
10956-Wanalyzer-unsafe-call-within-signal-handler @gol
10957-Wanalyzer-use-after-free @gol
10958-Wanalyzer-va-list-leak @gol
10959-Wanalyzer-va-list-use-after-va-end @gol
10960}
10961
10962@item -fno-analyzer-feasibility
10963@opindex fanalyzer-feasibility
10964@opindex fno-analyzer-feasibility
10965This option is intended for analyzer developers.
10966
10967By default the analyzer verifies that there is a feasible control flow path
10968for each diagnostic it emits: that the conditions that hold are not mutually
10969exclusive. Diagnostics for which no feasible path can be found are rejected.
10970This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
10971debugging issues in this code.
10972
10973@item -fanalyzer-fine-grained
10974@opindex fanalyzer-fine-grained
10975@opindex fno-analyzer-fine-grained
10976This option is intended for analyzer developers.
10977
10978Internally the analyzer builds an ``exploded graph'' that combines
10979control flow graphs with data flow information.
10980
10981By default, an edge in this graph can contain the effects of a run
10982of multiple statements within a basic block. With
10983@option{-fanalyzer-fine-grained}, each statement gets its own edge.
10984
10985@item -fanalyzer-show-duplicate-count
10986@opindex fanalyzer-show-duplicate-count
10987@opindex fno-analyzer-show-duplicate-count
10988This option is intended for analyzer developers: if multiple diagnostics
10989have been detected as being duplicates of each other, it emits a note when
10990reporting the best diagnostic, giving the number of additional diagnostics
10991that were suppressed by the deduplication logic.
10992
10993@item -fno-analyzer-state-merge
10994@opindex fanalyzer-state-merge
10995@opindex fno-analyzer-state-merge
10996This option is intended for analyzer developers.
10997
10998By default the analyzer attempts to simplify analysis by merging
10999sufficiently similar states at each program point as it builds its
11000``exploded graph''. With @option{-fno-analyzer-state-merge} this
11001merging can be suppressed, for debugging state-handling issues.
11002
11003@item -fno-analyzer-state-purge
11004@opindex fanalyzer-state-purge
11005@opindex fno-analyzer-state-purge
11006This option is intended for analyzer developers.
11007
11008By default the analyzer attempts to simplify analysis by purging
11009aspects of state at a program point that appear to no longer be relevant
11010e.g. the values of locals that aren't accessed later in the function
11011and which aren't relevant to leak analysis.
11012
11013With @option{-fno-analyzer-state-purge} this purging of state can
11014be suppressed, for debugging state-handling issues.
11015
8f636915
DM
11016@item -fno-analyzer-suppress-followups
11017@opindex fanalyzer-suppress-followups
11018@opindex fno-analyzer-suppress-followups
11019This option is intended for analyzer developers.
11020
11021By default the analyzer will stop exploring an execution path after
11022encountering certain diagnostics, in order to avoid potentially issuing a
11023cascade of follow-up diagnostics.
11024
11025The diagnostics that terminate analysis along a path are:
11026
11027@itemize
11028@item @option{-Wanalyzer-null-argument}
11029@item @option{-Wanalyzer-null-dereference}
11030@item @option{-Wanalyzer-use-after-free}
11031@item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame}
11032@item @option{-Wanalyzer-use-of-uninitialized-value}
11033@end itemize
11034
11035With @option{-fno-analyzer-suppress-followups} the analyzer will
11036continue to explore such paths even after such diagnostics, which may
11037be helpful for debugging issues in the analyzer, or for microbenchmarks
11038for detecting undefined behavior.
11039
d77de738
ML
11040@item -fanalyzer-transitivity
11041@opindex fanalyzer-transitivity
11042@opindex fno-analyzer-transitivity
11043This option enables transitivity of constraints within the analyzer.
11044
11045@item -fno-analyzer-undo-inlining
11046@opindex fanalyzer-undo-inlining
11047@opindex fno-analyzer-undo-inlining
11048This option is intended for analyzer developers.
11049
11050@option{-fanalyzer} runs relatively late compared to other code analysis
11051tools, and some optimizations have already been applied to the code. In
11052particular function inlining may have occurred, leading to the
11053interprocedural execution paths emitted by the analyzer containing
11054function frames that don't correspond to those in the original source
11055code.
11056
11057By default the analyzer attempts to reconstruct the original function
11058frames, and to emit events showing the inlined calls.
11059
11060With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct
11061the original frame information can be be disabled, which may be of help
11062when debugging issues in the analyzer.
11063
11064@item -fanalyzer-verbose-edges
11065This option is intended for analyzer developers. It enables more
11066verbose, lower-level detail in the descriptions of control flow
11067within diagnostic paths.
11068
11069@item -fanalyzer-verbose-state-changes
11070This option is intended for analyzer developers. It enables more
11071verbose, lower-level detail in the descriptions of events relating
11072to state machines within diagnostic paths.
11073
11074@item -fanalyzer-verbosity=@var{level}
11075This option controls the complexity of the control flow paths that are
11076emitted for analyzer diagnostics.
11077
11078The @var{level} can be one of:
11079
11080@table @samp
11081@item 0
11082At this level, interprocedural call and return events are displayed,
11083along with the most pertinent state-change events relating to
11084a diagnostic. For example, for a double-@code{free} diagnostic,
11085both calls to @code{free} will be shown.
11086
11087@item 1
11088As per the previous level, but also show events for the entry
11089to each function.
11090
11091@item 2
11092As per the previous level, but also show events relating to
11093control flow that are significant to triggering the issue
11094(e.g. ``true path taken'' at a conditional).
11095
11096This level is the default.
11097
11098@item 3
11099As per the previous level, but show all control flow events, not
11100just significant ones.
11101
11102@item 4
11103This level is intended for analyzer developers; it adds various
11104other events intended for debugging the analyzer.
11105
11106@end table
11107
11108@item -fdump-analyzer
11109@opindex fdump-analyzer
11110Dump internal details about what the analyzer is doing to
11111@file{@var{file}.analyzer.txt}.
11112This option is overridden by @option{-fdump-analyzer-stderr}.
11113
11114@item -fdump-analyzer-stderr
11115@opindex fdump-analyzer-stderr
11116Dump internal details about what the analyzer is doing to stderr.
11117This option overrides @option{-fdump-analyzer}.
11118
11119@item -fdump-analyzer-callgraph
11120@opindex fdump-analyzer-callgraph
11121Dump a representation of the call graph suitable for viewing with
11122GraphViz to @file{@var{file}.callgraph.dot}.
11123
11124@item -fdump-analyzer-exploded-graph
11125@opindex fdump-analyzer-exploded-graph
11126Dump a representation of the ``exploded graph'' suitable for viewing with
11127GraphViz to @file{@var{file}.eg.dot}.
11128Nodes are color-coded based on state-machine states to emphasize
11129state changes.
11130
11131@item -fdump-analyzer-exploded-nodes
11132@opindex dump-analyzer-exploded-nodes
11133Emit diagnostics showing where nodes in the ``exploded graph'' are
11134in relation to the program source.
11135
11136@item -fdump-analyzer-exploded-nodes-2
11137@opindex dump-analyzer-exploded-nodes-2
11138Dump a textual representation of the ``exploded graph'' to
11139@file{@var{file}.eg.txt}.
11140
11141@item -fdump-analyzer-exploded-nodes-3
11142@opindex dump-analyzer-exploded-nodes-3
11143Dump a textual representation of the ``exploded graph'' to
11144one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
11145This is typically a large number of dump files.
11146
11147@item -fdump-analyzer-exploded-paths
11148@opindex fdump-analyzer-exploded-paths
11149Dump a textual representation of the ``exploded path'' for each
11150diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
11151
11152@item -fdump-analyzer-feasibility
11153@opindex dump-analyzer-feasibility
11154Dump internal details about the analyzer's search for feasible paths.
11155The details are written in a form suitable for viewing with GraphViz
11156to filenames of the form @file{@var{file}.*.fg.dot},
11157@file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
11158
11159@item -fdump-analyzer-json
11160@opindex fdump-analyzer-json
11161Dump a compressed JSON representation of analyzer internals to
11162@file{@var{file}.analyzer.json.gz}. The precise format is subject
11163to change.
11164
11165@item -fdump-analyzer-state-purge
11166@opindex fdump-analyzer-state-purge
11167As per @option{-fdump-analyzer-supergraph}, dump a representation of the
11168``supergraph'' suitable for viewing with GraphViz, but annotate the
11169graph with information on what state will be purged at each node.
11170The graph is written to @file{@var{file}.state-purge.dot}.
11171
11172@item -fdump-analyzer-supergraph
11173@opindex fdump-analyzer-supergraph
11174Dump representations of the ``supergraph'' suitable for viewing with
11175GraphViz to @file{@var{file}.supergraph.dot} and to
11176@file{@var{file}.supergraph-eg.dot}. These show all of the
11177control flow graphs in the program, with interprocedural edges for
11178calls and returns. The second dump contains annotations showing nodes
11179in the ``exploded graph'' and diagnostics associated with them.
11180
11181@item -fdump-analyzer-untracked
11182@opindex fdump-analyzer-untracked
11183Emit custom warnings with internal details intended for analyzer developers.
11184
11185@end table
11186
11187@node Debugging Options
11188@section Options for Debugging Your Program
11189@cindex options, debugging
11190@cindex debugging information options
11191
11192To tell GCC to emit extra information for use by a debugger, in almost
11193all cases you need only to add @option{-g} to your other options. Some debug
11194formats can co-exist (like DWARF with CTF) when each of them is enabled
11195explicitly by adding the respective command line option to your other options.
11196
11197GCC allows you to use @option{-g} with
11198@option{-O}. The shortcuts taken by optimized code may occasionally
11199be surprising: some variables you declared may not exist
11200at all; flow of control may briefly move where you did not expect it;
11201some statements may not be executed because they compute constant
11202results or their values are already at hand; some statements may
11203execute in different places because they have been moved out of loops.
11204Nevertheless it is possible to debug optimized output. This makes
11205it reasonable to use the optimizer for programs that might have bugs.
11206
11207If you are not using some other optimization option, consider
11208using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
11209With no @option{-O} option at all, some compiler passes that collect
11210information useful for debugging do not run at all, so that
11211@option{-Og} may result in a better debugging experience.
11212
11213@table @gcctabopt
11214@item -g
11215@opindex g
11216Produce debugging information in the operating system's native format
11217(stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
11218information.
11219
11220On most systems that use stabs format, @option{-g} enables use of extra
11221debugging information that only GDB can use; this extra information
11222makes debugging work better in GDB but probably makes other debuggers
11223crash or refuse to read the program. If you want to control for certain whether
11224to generate the extra information, use @option{-gvms} (see below).
11225
11226@item -ggdb
11227@opindex ggdb
11228Produce debugging information for use by GDB@. This means to use the
11229most expressive format available (DWARF, stabs, or the native format
11230if neither of those are supported), including GDB extensions if at all
11231possible.
11232
11233@item -gdwarf
11234@itemx -gdwarf-@var{version}
11235@opindex gdwarf
11236Produce debugging information in DWARF format (if that is supported).
11237The value of @var{version} may be either 2, 3, 4 or 5; the default
11238version for most targets is 5 (with the exception of VxWorks, TPF and
11239Darwin/Mac OS X, which default to version 2, and AIX, which defaults
11240to version 4).
11241
11242Note that with DWARF Version 2, some ports require and always
11243use some non-conflicting DWARF 3 extensions in the unwind tables.
11244
11245Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
11246for maximum benefit. Version 5 requires GDB 8.0 or higher.
11247
11248GCC no longer supports DWARF Version 1, which is substantially
11249different than Version 2 and later. For historical reasons, some
11250other DWARF-related options such as
11251@option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
11252in their names, but apply to all currently-supported versions of DWARF.
11253
11254@item -gbtf
11255@opindex gbtf
11256Request BTF debug information. BTF is the default debugging format for the
11257eBPF target. On other targets, like x86, BTF debug information can be
11258generated along with DWARF debug information when both of the debug formats are
11259enabled explicitly via their respective command line options.
11260
11261@item -gctf
11262@itemx -gctf@var{level}
11263@opindex gctf
11264Request CTF debug information and use level to specify how much CTF debug
11265information should be produced. If @option{-gctf} is specified
11266without a value for level, the default level of CTF debug information is 2.
11267
11268CTF debug information can be generated along with DWARF debug information when
11269both of the debug formats are enabled explicitly via their respective command
11270line options.
11271
11272Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
11273negates @option{-gctf}.
11274
11275Level 1 produces CTF information for tracebacks only. This includes callsite
11276information, but does not include type information.
11277
11278Level 2 produces type information for entities (functions, data objects etc.)
11279at file-scope or global-scope only.
11280
11281@item -gvms
11282@opindex gvms
11283Produce debugging information in Alpha/VMS debug format (if that is
11284supported). This is the format used by DEBUG on Alpha/VMS systems.
11285
11286@item -g@var{level}
11287@itemx -ggdb@var{level}
11288@itemx -gvms@var{level}
11289Request debugging information and also use @var{level} to specify how
11290much information. The default level is 2.
11291
11292Level 0 produces no debug information at all. Thus, @option{-g0} negates
11293@option{-g}.
11294
11295Level 1 produces minimal information, enough for making backtraces in
11296parts of the program that you don't plan to debug. This includes
11297descriptions of functions and external variables, and line number
11298tables, but no information about local variables.
11299
11300Level 3 includes extra information, such as all the macro definitions
11301present in the program. Some debuggers support macro expansion when
11302you use @option{-g3}.
11303
11304If you use multiple @option{-g} options, with or without level numbers,
11305the last such option is the one that is effective.
11306
11307@option{-gdwarf} does not accept a concatenated debug level, to avoid
11308confusion with @option{-gdwarf-@var{level}}.
11309Instead use an additional @option{-g@var{level}} option to change the
11310debug level for DWARF.
11311
11312@item -fno-eliminate-unused-debug-symbols
11313@opindex feliminate-unused-debug-symbols
11314@opindex fno-eliminate-unused-debug-symbols
11315By default, no debug information is produced for symbols that are not actually
11316used. Use this option if you want debug information for all symbols.
11317
11318@item -femit-class-debug-always
11319@opindex femit-class-debug-always
11320Instead of emitting debugging information for a C++ class in only one
11321object file, emit it in all object files using the class. This option
11322should be used only with debuggers that are unable to handle the way GCC
11323normally emits debugging information for classes because using this
11324option increases the size of debugging information by as much as a
11325factor of two.
11326
11327@item -fno-merge-debug-strings
11328@opindex fmerge-debug-strings
11329@opindex fno-merge-debug-strings
11330Direct the linker to not merge together strings in the debugging
11331information that are identical in different object files. Merging is
11332not supported by all assemblers or linkers. Merging decreases the size
11333of the debug information in the output file at the cost of increasing
11334link processing time. Merging is enabled by default.
11335
11336@item -fdebug-prefix-map=@var{old}=@var{new}
11337@opindex fdebug-prefix-map
11338When compiling files residing in directory @file{@var{old}}, record
11339debugging information describing them as if the files resided in
11340directory @file{@var{new}} instead. This can be used to replace a
11341build-time path with an install-time path in the debug info. It can
11342also be used to change an absolute path to a relative path by using
11343@file{.} for @var{new}. This can give more reproducible builds, which
11344are location independent, but may require an extra command to tell GDB
11345where to find the source files. See also @option{-ffile-prefix-map}.
11346
11347@item -fvar-tracking
11348@opindex fvar-tracking
11349Run variable tracking pass. It computes where variables are stored at each
11350position in code. Better debugging information is then generated
11351(if the debugging information format supports this information).
11352
11353It is enabled by default when compiling with optimization (@option{-Os},
11354@option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
11355the debug info format supports it.
11356
11357@item -fvar-tracking-assignments
11358@opindex fvar-tracking-assignments
11359@opindex fno-var-tracking-assignments
11360Annotate assignments to user variables early in the compilation and
11361attempt to carry the annotations over throughout the compilation all the
11362way to the end, in an attempt to improve debug information while
11363optimizing. Use of @option{-gdwarf-4} is recommended along with it.
11364
11365It can be enabled even if var-tracking is disabled, in which case
11366annotations are created and maintained, but discarded at the end.
11367By default, this flag is enabled together with @option{-fvar-tracking},
11368except when selective scheduling is enabled.
11369
11370@item -gsplit-dwarf
11371@opindex gsplit-dwarf
11372If DWARF debugging information is enabled, separate as much debugging
11373information as possible into a separate output file with the extension
11374@file{.dwo}. This option allows the build system to avoid linking files with
11375debug information. To be useful, this option requires a debugger capable of
11376reading @file{.dwo} files.
11377
11378@item -gdwarf32
11379@itemx -gdwarf64
11380@opindex gdwarf32
11381@opindex gdwarf64
11382If DWARF debugging information is enabled, the @option{-gdwarf32} selects
11383the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
11384DWARF format. The default is target specific, on most targets it is
11385@option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
11386can't support more than 2GiB of debug information in any of the DWARF
11387debug information sections. The 64-bit DWARF format allows larger debug
11388information and might not be well supported by all consumers yet.
11389
11390@item -gdescribe-dies
11391@opindex gdescribe-dies
11392Add description attributes to some DWARF DIEs that have no name attribute,
11393such as artificial variables, external references and call site
11394parameter DIEs.
11395
11396@item -gpubnames
11397@opindex gpubnames
11398Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
11399
11400@item -ggnu-pubnames
11401@opindex ggnu-pubnames
11402Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
11403suitable for conversion into a GDB@ index. This option is only useful
11404with a linker that can produce GDB@ index version 7.
11405
11406@item -fdebug-types-section
11407@opindex fdebug-types-section
11408@opindex fno-debug-types-section
11409When using DWARF Version 4 or higher, type DIEs can be put into
11410their own @code{.debug_types} section instead of making them part of the
11411@code{.debug_info} section. It is more efficient to put them in a separate
11412comdat section since the linker can then remove duplicates.
11413But not all DWARF consumers support @code{.debug_types} sections yet
11414and on some objects @code{.debug_types} produces larger instead of smaller
11415debugging information.
11416
11417@item -grecord-gcc-switches
11418@itemx -gno-record-gcc-switches
11419@opindex grecord-gcc-switches
11420@opindex gno-record-gcc-switches
11421This switch causes the command-line options used to invoke the
11422compiler that may affect code generation to be appended to the
11423DW_AT_producer attribute in DWARF debugging information. The options
11424are concatenated with spaces separating them from each other and from
11425the compiler version.
11426It is enabled by default.
11427See also @option{-frecord-gcc-switches} for another
11428way of storing compiler options into the object file.
11429
11430@item -gstrict-dwarf
11431@opindex gstrict-dwarf
11432Disallow using extensions of later DWARF standard version than selected
11433with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
11434DWARF extensions from later standard versions is allowed.
11435
11436@item -gno-strict-dwarf
11437@opindex gno-strict-dwarf
11438Allow using extensions of later DWARF standard version than selected with
11439@option{-gdwarf-@var{version}}.
11440
11441@item -gas-loc-support
11442@opindex gas-loc-support
11443Inform the compiler that the assembler supports @code{.loc} directives.
11444It may then use them for the assembler to generate DWARF2+ line number
11445tables.
11446
11447This is generally desirable, because assembler-generated line-number
11448tables are a lot more compact than those the compiler can generate
11449itself.
11450
11451This option will be enabled by default if, at GCC configure time, the
11452assembler was found to support such directives.
11453
11454@item -gno-as-loc-support
11455@opindex gno-as-loc-support
11456Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
11457line number tables are to be generated.
11458
11459@item -gas-locview-support
11460@opindex gas-locview-support
11461Inform the compiler that the assembler supports @code{view} assignment
11462and reset assertion checking in @code{.loc} directives.
11463
11464This option will be enabled by default if, at GCC configure time, the
11465assembler was found to support them.
11466
11467@item -gno-as-locview-support
11468Force GCC to assign view numbers internally, if
11469@option{-gvariable-location-views} are explicitly requested.
11470
11471@item -gcolumn-info
11472@itemx -gno-column-info
11473@opindex gcolumn-info
11474@opindex gno-column-info
11475Emit location column information into DWARF debugging information, rather
11476than just file and line.
11477This option is enabled by default.
11478
11479@item -gstatement-frontiers
11480@itemx -gno-statement-frontiers
11481@opindex gstatement-frontiers
11482@opindex gno-statement-frontiers
11483This option causes GCC to create markers in the internal representation
11484at the beginning of statements, and to keep them roughly in place
11485throughout compilation, using them to guide the output of @code{is_stmt}
11486markers in the line number table. This is enabled by default when
11487compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
11488@dots{}), and outputting DWARF 2 debug information at the normal level.
11489
11490@item -gvariable-location-views
11491@itemx -gvariable-location-views=incompat5
11492@itemx -gno-variable-location-views
11493@opindex gvariable-location-views
11494@opindex gvariable-location-views=incompat5
11495@opindex gno-variable-location-views
11496Augment variable location lists with progressive view numbers implied
11497from the line number table. This enables debug information consumers to
11498inspect state at certain points of the program, even if no instructions
11499associated with the corresponding source locations are present at that
11500point. If the assembler lacks support for view numbers in line number
11501tables, this will cause the compiler to emit the line number table,
11502which generally makes them somewhat less compact. The augmented line
11503number tables and location lists are fully backward-compatible, so they
11504can be consumed by debug information consumers that are not aware of
11505these augmentations, but they won't derive any benefit from them either.
11506
11507This is enabled by default when outputting DWARF 2 debug information at
11508the normal level, as long as there is assembler support,
11509@option{-fvar-tracking-assignments} is enabled and
11510@option{-gstrict-dwarf} is not. When assembler support is not
11511available, this may still be enabled, but it will force GCC to output
11512internal line number tables, and if
11513@option{-ginternal-reset-location-views} is not enabled, that will most
11514certainly lead to silently mismatching location views.
11515
11516There is a proposed representation for view numbers that is not backward
11517compatible with the location list format introduced in DWARF 5, that can
11518be enabled with @option{-gvariable-location-views=incompat5}. This
11519option may be removed in the future, is only provided as a reference
11520implementation of the proposed representation. Debug information
11521consumers are not expected to support this extended format, and they
11522would be rendered unable to decode location lists using it.
11523
11524@item -ginternal-reset-location-views
11525@itemx -gno-internal-reset-location-views
11526@opindex ginternal-reset-location-views
11527@opindex gno-internal-reset-location-views
11528Attempt to determine location views that can be omitted from location
11529view lists. This requires the compiler to have very accurate insn
11530length estimates, which isn't always the case, and it may cause
11531incorrect view lists to be generated silently when using an assembler
11532that does not support location view lists. The GNU assembler will flag
11533any such error as a @code{view number mismatch}. This is only enabled
11534on ports that define a reliable estimation function.
11535
11536@item -ginline-points
11537@itemx -gno-inline-points
11538@opindex ginline-points
11539@opindex gno-inline-points
11540Generate extended debug information for inlined functions. Location
11541view tracking markers are inserted at inlined entry points, so that
11542address and view numbers can be computed and output in debug
11543information. This can be enabled independently of location views, in
11544which case the view numbers won't be output, but it can only be enabled
11545along with statement frontiers, and it is only enabled by default if
11546location views are enabled.
11547
11548@item -gz@r{[}=@var{type}@r{]}
11549@opindex gz
11550Produce compressed debug sections in DWARF format, if that is supported.
11551If @var{type} is not given, the default type depends on the capabilities
11552of the assembler and linker used. @var{type} may be one of
11553@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
11554compression in ELF gABI format). If the linker doesn't support writing
11555compressed debug sections, the option is rejected. Otherwise, if the
11556assembler does not support them, @option{-gz} is silently ignored when
11557producing object files.
11558
11559@item -femit-struct-debug-baseonly
11560@opindex femit-struct-debug-baseonly
11561Emit debug information for struct-like types
11562only when the base name of the compilation source file
11563matches the base name of file in which the struct is defined.
11564
11565This option substantially reduces the size of debugging information,
11566but at significant potential loss in type information to the debugger.
11567See @option{-femit-struct-debug-reduced} for a less aggressive option.
11568See @option{-femit-struct-debug-detailed} for more detailed control.
11569
11570This option works only with DWARF debug output.
11571
11572@item -femit-struct-debug-reduced
11573@opindex femit-struct-debug-reduced
11574Emit debug information for struct-like types
11575only when the base name of the compilation source file
11576matches the base name of file in which the type is defined,
11577unless the struct is a template or defined in a system header.
11578
11579This option significantly reduces the size of debugging information,
11580with some potential loss in type information to the debugger.
11581See @option{-femit-struct-debug-baseonly} for a more aggressive option.
11582See @option{-femit-struct-debug-detailed} for more detailed control.
11583
11584This option works only with DWARF debug output.
11585
11586@item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
11587@opindex femit-struct-debug-detailed
11588Specify the struct-like types
11589for which the compiler generates debug information.
11590The intent is to reduce duplicate struct debug information
11591between different object files within the same program.
11592
11593This option is a detailed version of
11594@option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
11595which serves for most needs.
11596
11597A specification has the syntax@*
11598[@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
11599
11600The optional first word limits the specification to
11601structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
11602A struct type is used directly when it is the type of a variable, member.
11603Indirect uses arise through pointers to structs.
11604That is, when use of an incomplete struct is valid, the use is indirect.
11605An example is
11606@samp{struct one direct; struct two * indirect;}.
11607
11608The optional second word limits the specification to
11609ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
11610Generic structs are a bit complicated to explain.
11611For C++, these are non-explicit specializations of template classes,
11612or non-template classes within the above.
11613Other programming languages have generics,
11614but @option{-femit-struct-debug-detailed} does not yet implement them.
11615
11616The third word specifies the source files for those
11617structs for which the compiler should emit debug information.
11618The values @samp{none} and @samp{any} have the normal meaning.
11619The value @samp{base} means that
11620the base of name of the file in which the type declaration appears
11621must match the base of the name of the main compilation file.
11622In practice, this means that when compiling @file{foo.c}, debug information
11623is generated for types declared in that file and @file{foo.h},
11624but not other header files.
11625The value @samp{sys} means those types satisfying @samp{base}
11626or declared in system or compiler headers.
11627
11628You may need to experiment to determine the best settings for your application.
11629
11630The default is @option{-femit-struct-debug-detailed=all}.
11631
11632This option works only with DWARF debug output.
11633
11634@item -fno-dwarf2-cfi-asm
11635@opindex fdwarf2-cfi-asm
11636@opindex fno-dwarf2-cfi-asm
11637Emit DWARF unwind info as compiler generated @code{.eh_frame} section
11638instead of using GAS @code{.cfi_*} directives.
11639
11640@item -fno-eliminate-unused-debug-types
11641@opindex feliminate-unused-debug-types
11642@opindex fno-eliminate-unused-debug-types
11643Normally, when producing DWARF output, GCC avoids producing debug symbol
11644output for types that are nowhere used in the source file being compiled.
11645Sometimes it is useful to have GCC emit debugging
11646information for all types declared in a compilation
11647unit, regardless of whether or not they are actually used
11648in that compilation unit, for example
11649if, in the debugger, you want to cast a value to a type that is
11650not actually used in your program (but is declared). More often,
11651however, this results in a significant amount of wasted space.
11652@end table
11653
11654@node Optimize Options
11655@section Options That Control Optimization
11656@cindex optimize options
11657@cindex options, optimization
11658
11659These options control various sorts of optimizations.
11660
11661Without any optimization option, the compiler's goal is to reduce the
11662cost of compilation and to make debugging produce the expected
11663results. Statements are independent: if you stop the program with a
11664breakpoint between statements, you can then assign a new value to any
11665variable or change the program counter to any other statement in the
11666function and get exactly the results you expect from the source
11667code.
11668
11669Turning on optimization flags makes the compiler attempt to improve
11670the performance and/or code size at the expense of compilation time
11671and possibly the ability to debug the program.
11672
11673The compiler performs optimization based on the knowledge it has of the
11674program. Compiling multiple files at once to a single output file mode allows
11675the compiler to use information gained from all of the files when compiling
11676each of them.
11677
11678Not all optimizations are controlled directly by a flag. Only
11679optimizations that have a flag are listed in this section.
11680
11681Most optimizations are completely disabled at @option{-O0} or if an
11682@option{-O} level is not set on the command line, even if individual
11683optimization flags are specified. Similarly, @option{-Og} suppresses
11684many optimization passes.
11685
11686Depending on the target and how GCC was configured, a slightly different
11687set of optimizations may be enabled at each @option{-O} level than
11688those listed here. You can invoke GCC with @option{-Q --help=optimizers}
11689to find out the exact set of optimizations that are enabled at each level.
11690@xref{Overall Options}, for examples.
11691
11692@table @gcctabopt
11693@item -O
11694@itemx -O1
11695@opindex O
11696@opindex O1
11697Optimize. Optimizing compilation takes somewhat more time, and a lot
11698more memory for a large function.
11699
11700With @option{-O}, the compiler tries to reduce code size and execution
11701time, without performing any optimizations that take a great deal of
11702compilation time.
11703
11704@c Note that in addition to the default_options_table list in opts.cc,
11705@c several optimization flags default to true but control optimization
11706@c passes that are explicitly disabled at -O0.
11707
11708@option{-O} turns on the following optimization flags:
11709
11710@c Please keep the following list alphabetized.
11711@gccoptlist{-fauto-inc-dec @gol
11712-fbranch-count-reg @gol
11713-fcombine-stack-adjustments @gol
11714-fcompare-elim @gol
11715-fcprop-registers @gol
11716-fdce @gol
11717-fdefer-pop @gol
11718-fdelayed-branch @gol
11719-fdse @gol
11720-fforward-propagate @gol
11721-fguess-branch-probability @gol
11722-fif-conversion @gol
11723-fif-conversion2 @gol
11724-finline-functions-called-once @gol
11725-fipa-modref @gol
11726-fipa-profile @gol
11727-fipa-pure-const @gol
11728-fipa-reference @gol
11729-fipa-reference-addressable @gol
11730-fmerge-constants @gol
11731-fmove-loop-invariants @gol
11732-fmove-loop-stores@gol
11733-fomit-frame-pointer @gol
11734-freorder-blocks @gol
11735-fshrink-wrap @gol
11736-fshrink-wrap-separate @gol
11737-fsplit-wide-types @gol
11738-fssa-backprop @gol
11739-fssa-phiopt @gol
11740-ftree-bit-ccp @gol
11741-ftree-ccp @gol
11742-ftree-ch @gol
11743-ftree-coalesce-vars @gol
11744-ftree-copy-prop @gol
11745-ftree-dce @gol
11746-ftree-dominator-opts @gol
11747-ftree-dse @gol
11748-ftree-forwprop @gol
11749-ftree-fre @gol
11750-ftree-phiprop @gol
11751-ftree-pta @gol
11752-ftree-scev-cprop @gol
11753-ftree-sink @gol
11754-ftree-slsr @gol
11755-ftree-sra @gol
11756-ftree-ter @gol
11757-funit-at-a-time}
11758
11759@item -O2
11760@opindex O2
11761Optimize even more. GCC performs nearly all supported optimizations
11762that do not involve a space-speed tradeoff.
11763As compared to @option{-O}, this option increases both compilation time
11764and the performance of the generated code.
11765
11766@option{-O2} turns on all optimization flags specified by @option{-O1}. It
11767also turns on the following optimization flags:
11768
11769@c Please keep the following list alphabetized!
11770@gccoptlist{-falign-functions -falign-jumps @gol
11771-falign-labels -falign-loops @gol
11772-fcaller-saves @gol
11773-fcode-hoisting @gol
11774-fcrossjumping @gol
11775-fcse-follow-jumps -fcse-skip-blocks @gol
11776-fdelete-null-pointer-checks @gol
11777-fdevirtualize -fdevirtualize-speculatively @gol
11778-fexpensive-optimizations @gol
11779-ffinite-loops @gol
11780-fgcse -fgcse-lm @gol
11781-fhoist-adjacent-loads @gol
11782-finline-functions @gol
11783-finline-small-functions @gol
11784-findirect-inlining @gol
11785-fipa-bit-cp -fipa-cp -fipa-icf @gol
11786-fipa-ra -fipa-sra -fipa-vrp @gol
11787-fisolate-erroneous-paths-dereference @gol
11788-flra-remat @gol
11789-foptimize-sibling-calls @gol
11790-foptimize-strlen @gol
11791-fpartial-inlining @gol
11792-fpeephole2 @gol
11793-freorder-blocks-algorithm=stc @gol
11794-freorder-blocks-and-partition -freorder-functions @gol
11795-frerun-cse-after-loop @gol
11796-fschedule-insns -fschedule-insns2 @gol
11797-fsched-interblock -fsched-spec @gol
11798-fstore-merging @gol
11799-fstrict-aliasing @gol
11800-fthread-jumps @gol
11801-ftree-builtin-call-dce @gol
11802-ftree-loop-vectorize @gol
11803-ftree-pre @gol
11804-ftree-slp-vectorize @gol
11805-ftree-switch-conversion -ftree-tail-merge @gol
11806-ftree-vrp @gol
11807-fvect-cost-model=very-cheap}
11808
11809Please note the warning under @option{-fgcse} about
11810invoking @option{-O2} on programs that use computed gotos.
11811
11812@item -O3
11813@opindex O3
11814Optimize yet more. @option{-O3} turns on all optimizations specified
11815by @option{-O2} and also turns on the following optimization flags:
11816
11817@c Please keep the following list alphabetized!
11818@gccoptlist{-fgcse-after-reload @gol
11819-fipa-cp-clone
11820-floop-interchange @gol
11821-floop-unroll-and-jam @gol
11822-fpeel-loops @gol
11823-fpredictive-commoning @gol
11824-fsplit-loops @gol
11825-fsplit-paths @gol
11826-ftree-loop-distribution @gol
11827-ftree-partial-pre @gol
11828-funswitch-loops @gol
11829-fvect-cost-model=dynamic @gol
11830-fversion-loops-for-strides}
11831
11832@item -O0
11833@opindex O0
11834Reduce compilation time and make debugging produce the expected
11835results. This is the default.
11836
11837@item -Os
11838@opindex Os
11839Optimize for size. @option{-Os} enables all @option{-O2} optimizations
11840except those that often increase code size:
11841
11842@gccoptlist{-falign-functions -falign-jumps @gol
11843-falign-labels -falign-loops @gol
11844-fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
11845
11846It also enables @option{-finline-functions}, causes the compiler to tune for
11847code size rather than execution speed, and performs further optimizations
11848designed to reduce code size.
11849
11850@item -Ofast
11851@opindex Ofast
11852Disregard strict standards compliance. @option{-Ofast} enables all
11853@option{-O3} optimizations. It also enables optimizations that are not
11854valid for all standard-compliant programs.
11855It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
11856and the Fortran-specific @option{-fstack-arrays}, unless
11857@option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
11858It turns off @option{-fsemantic-interposition}.
11859
11860@item -Og
11861@opindex Og
11862Optimize debugging experience. @option{-Og} should be the optimization
11863level of choice for the standard edit-compile-debug cycle, offering
11864a reasonable level of optimization while maintaining fast compilation
11865and a good debugging experience. It is a better choice than @option{-O0}
11866for producing debuggable code because some compiler passes
11867that collect debug information are disabled at @option{-O0}.
11868
11869Like @option{-O0}, @option{-Og} completely disables a number of
11870optimization passes so that individual options controlling them have
11871no effect. Otherwise @option{-Og} enables all @option{-O1}
11872optimization flags except for those that may interfere with debugging:
11873
11874@gccoptlist{-fbranch-count-reg -fdelayed-branch @gol
11875-fdse -fif-conversion -fif-conversion2 @gol
11876-finline-functions-called-once @gol
11877-fmove-loop-invariants -fmove-loop-stores -fssa-phiopt @gol
11878-ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
11879
11880@item -Oz
11881@opindex Oz
11882Optimize aggressively for size rather than speed. This may increase
11883the number of instructions executed if those instructions require
11884fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
11885including enabling most @option{-O2} optimizations.
11886
11887@end table
11888
11889If you use multiple @option{-O} options, with or without level numbers,
11890the last such option is the one that is effective.
11891
11892Options of the form @option{-f@var{flag}} specify machine-independent
11893flags. Most flags have both positive and negative forms; the negative
11894form of @option{-ffoo} is @option{-fno-foo}. In the table
11895below, only one of the forms is listed---the one you typically
11896use. You can figure out the other form by either removing @samp{no-}
11897or adding it.
11898
11899The following options control specific optimizations. They are either
11900activated by @option{-O} options or are related to ones that are. You
11901can use the following flags in the rare cases when ``fine-tuning'' of
11902optimizations to be performed is desired.
11903
11904@table @gcctabopt
11905@item -fno-defer-pop
11906@opindex fno-defer-pop
11907@opindex fdefer-pop
11908For machines that must pop arguments after a function call, always pop
11909the arguments as soon as each function returns.
11910At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
11911this allows the compiler to let arguments accumulate on the stack for several
11912function calls and pop them all at once.
11913
11914@item -fforward-propagate
11915@opindex fforward-propagate
11916Perform a forward propagation pass on RTL@. The pass tries to combine two
11917instructions and checks if the result can be simplified. If loop unrolling
11918is active, two passes are performed and the second is scheduled after
11919loop unrolling.
11920
11921This option is enabled by default at optimization levels @option{-O1},
11922@option{-O2}, @option{-O3}, @option{-Os}.
11923
11924@item -ffp-contract=@var{style}
11925@opindex ffp-contract
11926@option{-ffp-contract=off} disables floating-point expression contraction.
11927@option{-ffp-contract=fast} enables floating-point expression contraction
11928such as forming of fused multiply-add operations if the target has
11929native support for them.
11930@option{-ffp-contract=on} enables floating-point expression contraction
11931if allowed by the language standard. This is currently not implemented
11932and treated equal to @option{-ffp-contract=off}.
11933
11934The default is @option{-ffp-contract=fast}.
11935
11936@item -fomit-frame-pointer
11937@opindex fomit-frame-pointer
11938Omit the frame pointer in functions that don't need one. This avoids the
11939instructions to save, set up and restore the frame pointer; on many targets
11940it also makes an extra register available.
11941
11942On some targets this flag has no effect because the standard calling sequence
11943always uses a frame pointer, so it cannot be omitted.
11944
11945Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
11946is used in all functions. Several targets always omit the frame pointer in
11947leaf functions.
11948
11949Enabled by default at @option{-O1} and higher.
11950
11951@item -foptimize-sibling-calls
11952@opindex foptimize-sibling-calls
11953Optimize sibling and tail recursive calls.
11954
11955Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11956
11957@item -foptimize-strlen
11958@opindex foptimize-strlen
11959Optimize various standard C string functions (e.g.@: @code{strlen},
11960@code{strchr} or @code{strcpy}) and
11961their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
11962
11963Enabled at levels @option{-O2}, @option{-O3}.
11964
11965@item -fno-inline
11966@opindex fno-inline
11967@opindex finline
11968Do not expand any functions inline apart from those marked with
11969the @code{always_inline} attribute. This is the default when not
11970optimizing.
11971
11972Single functions can be exempted from inlining by marking them
11973with the @code{noinline} attribute.
11974
11975@item -finline-small-functions
11976@opindex finline-small-functions
11977Integrate functions into their callers when their body is smaller than expected
11978function call code (so overall size of program gets smaller). The compiler
11979heuristically decides which functions are simple enough to be worth integrating
11980in this way. This inlining applies to all functions, even those not declared
11981inline.
11982
11983Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11984
11985@item -findirect-inlining
11986@opindex findirect-inlining
11987Inline also indirect calls that are discovered to be known at compile
11988time thanks to previous inlining. This option has any effect only
11989when inlining itself is turned on by the @option{-finline-functions}
11990or @option{-finline-small-functions} options.
11991
11992Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11993
11994@item -finline-functions
11995@opindex finline-functions
11996Consider all functions for inlining, even if they are not declared inline.
11997The compiler heuristically decides which functions are worth integrating
11998in this way.
11999
12000If all calls to a given function are integrated, and the function is
12001declared @code{static}, then the function is normally not output as
12002assembler code in its own right.
12003
12004Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
12005by @option{-fprofile-use} and @option{-fauto-profile}.
12006
12007@item -finline-functions-called-once
12008@opindex finline-functions-called-once
12009Consider all @code{static} functions called once for inlining into their
12010caller even if they are not marked @code{inline}. If a call to a given
12011function is integrated, then the function is not output as assembler code
12012in its own right.
12013
12014Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
12015but not @option{-Og}.
12016
12017@item -fearly-inlining
12018@opindex fearly-inlining
12019Inline functions marked by @code{always_inline} and functions whose body seems
12020smaller than the function call overhead early before doing
12021@option{-fprofile-generate} instrumentation and real inlining pass. Doing so
12022makes profiling significantly cheaper and usually inlining faster on programs
12023having large chains of nested wrapper functions.
12024
12025Enabled by default.
12026
12027@item -fipa-sra
12028@opindex fipa-sra
12029Perform interprocedural scalar replacement of aggregates, removal of
12030unused parameters and replacement of parameters passed by reference
12031by parameters passed by value.
12032
12033Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
12034
12035@item -finline-limit=@var{n}
12036@opindex finline-limit
12037By default, GCC limits the size of functions that can be inlined. This flag
12038allows coarse control of this limit. @var{n} is the size of functions that
12039can be inlined in number of pseudo instructions.
12040
12041Inlining is actually controlled by a number of parameters, which may be
12042specified individually by using @option{--param @var{name}=@var{value}}.
12043The @option{-finline-limit=@var{n}} option sets some of these parameters
12044as follows:
12045
12046@table @gcctabopt
12047@item max-inline-insns-single
12048is set to @var{n}/2.
12049@item max-inline-insns-auto
12050is set to @var{n}/2.
12051@end table
12052
12053See below for a documentation of the individual
12054parameters controlling inlining and for the defaults of these parameters.
12055
12056@emph{Note:} there may be no value to @option{-finline-limit} that results
12057in default behavior.
12058
12059@emph{Note:} pseudo instruction represents, in this particular context, an
12060abstract measurement of function's size. In no way does it represent a count
12061of assembly instructions and as such its exact meaning might change from one
12062release to an another.
12063
12064@item -fno-keep-inline-dllexport
12065@opindex fno-keep-inline-dllexport
12066@opindex fkeep-inline-dllexport
12067This is a more fine-grained version of @option{-fkeep-inline-functions},
12068which applies only to functions that are declared using the @code{dllexport}
12069attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
12070Functions}.
12071
12072@item -fkeep-inline-functions
12073@opindex fkeep-inline-functions
12074In C, emit @code{static} functions that are declared @code{inline}
12075into the object file, even if the function has been inlined into all
12076of its callers. This switch does not affect functions using the
12077@code{extern inline} extension in GNU C90@. In C++, emit any and all
12078inline functions into the object file.
12079
12080@item -fkeep-static-functions
12081@opindex fkeep-static-functions
12082Emit @code{static} functions into the object file, even if the function
12083is never used.
12084
12085@item -fkeep-static-consts
12086@opindex fkeep-static-consts
12087Emit variables declared @code{static const} when optimization isn't turned
12088on, even if the variables aren't referenced.
12089
12090GCC enables this option by default. If you want to force the compiler to
12091check if a variable is referenced, regardless of whether or not
12092optimization is turned on, use the @option{-fno-keep-static-consts} option.
12093
12094@item -fmerge-constants
12095@opindex fmerge-constants
12096Attempt to merge identical constants (string constants and floating-point
12097constants) across compilation units.
12098
12099This option is the default for optimized compilation if the assembler and
12100linker support it. Use @option{-fno-merge-constants} to inhibit this
12101behavior.
12102
12103Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12104
12105@item -fmerge-all-constants
12106@opindex fmerge-all-constants
12107Attempt to merge identical constants and identical variables.
12108
12109This option implies @option{-fmerge-constants}. In addition to
12110@option{-fmerge-constants} this considers e.g.@: even constant initialized
12111arrays or initialized constant variables with integral or floating-point
12112types. Languages like C or C++ require each variable, including multiple
12113instances of the same variable in recursive calls, to have distinct locations,
12114so using this option results in non-conforming
12115behavior.
12116
12117@item -fmodulo-sched
12118@opindex fmodulo-sched
12119Perform swing modulo scheduling immediately before the first scheduling
12120pass. This pass looks at innermost loops and reorders their
12121instructions by overlapping different iterations.
12122
12123@item -fmodulo-sched-allow-regmoves
12124@opindex fmodulo-sched-allow-regmoves
12125Perform more aggressive SMS-based modulo scheduling with register moves
12126allowed. By setting this flag certain anti-dependences edges are
12127deleted, which triggers the generation of reg-moves based on the
12128life-range analysis. This option is effective only with
12129@option{-fmodulo-sched} enabled.
12130
12131@item -fno-branch-count-reg
12132@opindex fno-branch-count-reg
12133@opindex fbranch-count-reg
12134Disable the optimization pass that scans for opportunities to use
12135``decrement and branch'' instructions on a count register instead of
12136instruction sequences that decrement a register, compare it against zero, and
12137then branch based upon the result. This option is only meaningful on
12138architectures that support such instructions, which include x86, PowerPC,
12139IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
12140doesn't remove the decrement and branch instructions from the generated
12141instruction stream introduced by other optimization passes.
12142
12143The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
12144except for @option{-Og}.
12145
12146@item -fno-function-cse
12147@opindex fno-function-cse
12148@opindex ffunction-cse
12149Do not put function addresses in registers; make each instruction that
12150calls a constant function contain the function's address explicitly.
12151
12152This option results in less efficient code, but some strange hacks
12153that alter the assembler output may be confused by the optimizations
12154performed when this option is not used.
12155
12156The default is @option{-ffunction-cse}
12157
12158@item -fno-zero-initialized-in-bss
12159@opindex fno-zero-initialized-in-bss
12160@opindex fzero-initialized-in-bss
12161If the target supports a BSS section, GCC by default puts variables that
12162are initialized to zero into BSS@. This can save space in the resulting
12163code.
12164
12165This option turns off this behavior because some programs explicitly
12166rely on variables going to the data section---e.g., so that the
12167resulting executable can find the beginning of that section and/or make
12168assumptions based on that.
12169
12170The default is @option{-fzero-initialized-in-bss}.
12171
12172@item -fthread-jumps
12173@opindex fthread-jumps
12174Perform optimizations that check to see if a jump branches to a
12175location where another comparison subsumed by the first is found. If
12176so, the first branch is redirected to either the destination of the
12177second branch or a point immediately following it, depending on whether
12178the condition is known to be true or false.
12179
12180Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12181
12182@item -fsplit-wide-types
12183@opindex fsplit-wide-types
12184When using a type that occupies multiple registers, such as @code{long
12185long} on a 32-bit system, split the registers apart and allocate them
12186independently. This normally generates better code for those types,
12187but may make debugging more difficult.
12188
12189Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
12190@option{-Os}.
12191
12192@item -fsplit-wide-types-early
12193@opindex fsplit-wide-types-early
12194Fully split wide types early, instead of very late.
12195This option has no effect unless @option{-fsplit-wide-types} is turned on.
12196
12197This is the default on some targets.
12198
12199@item -fcse-follow-jumps
12200@opindex fcse-follow-jumps
12201In common subexpression elimination (CSE), scan through jump instructions
12202when the target of the jump is not reached by any other path. For
12203example, when CSE encounters an @code{if} statement with an
12204@code{else} clause, CSE follows the jump when the condition
12205tested is false.
12206
12207Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12208
12209@item -fcse-skip-blocks
12210@opindex fcse-skip-blocks
12211This is similar to @option{-fcse-follow-jumps}, but causes CSE to
12212follow jumps that conditionally skip over blocks. When CSE
12213encounters a simple @code{if} statement with no else clause,
12214@option{-fcse-skip-blocks} causes CSE to follow the jump around the
12215body of the @code{if}.
12216
12217Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12218
12219@item -frerun-cse-after-loop
12220@opindex frerun-cse-after-loop
12221Re-run common subexpression elimination after loop optimizations are
12222performed.
12223
12224Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12225
12226@item -fgcse
12227@opindex fgcse
12228Perform a global common subexpression elimination pass.
12229This pass also performs global constant and copy propagation.
12230
12231@emph{Note:} When compiling a program using computed gotos, a GCC
12232extension, you may get better run-time performance if you disable
12233the global common subexpression elimination pass by adding
12234@option{-fno-gcse} to the command line.
12235
12236Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12237
12238@item -fgcse-lm
12239@opindex fgcse-lm
12240When @option{-fgcse-lm} is enabled, global common subexpression elimination
12241attempts to move loads that are only killed by stores into themselves. This
12242allows a loop containing a load/store sequence to be changed to a load outside
12243the loop, and a copy/store within the loop.
12244
12245Enabled by default when @option{-fgcse} is enabled.
12246
12247@item -fgcse-sm
12248@opindex fgcse-sm
12249When @option{-fgcse-sm} is enabled, a store motion pass is run after
12250global common subexpression elimination. This pass attempts to move
12251stores out of loops. When used in conjunction with @option{-fgcse-lm},
12252loops containing a load/store sequence can be changed to a load before
12253the loop and a store after the loop.
12254
12255Not enabled at any optimization level.
12256
12257@item -fgcse-las
12258@opindex fgcse-las
12259When @option{-fgcse-las} is enabled, the global common subexpression
12260elimination pass eliminates redundant loads that come after stores to the
12261same memory location (both partial and full redundancies).
12262
12263Not enabled at any optimization level.
12264
12265@item -fgcse-after-reload
12266@opindex fgcse-after-reload
12267When @option{-fgcse-after-reload} is enabled, a redundant load elimination
12268pass is performed after reload. The purpose of this pass is to clean up
12269redundant spilling.
12270
12271Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
12272
12273@item -faggressive-loop-optimizations
12274@opindex faggressive-loop-optimizations
12275This option tells the loop optimizer to use language constraints to
12276derive bounds for the number of iterations of a loop. This assumes that
12277loop code does not invoke undefined behavior by for example causing signed
12278integer overflows or out-of-bound array accesses. The bounds for the
12279number of iterations of a loop are used to guide loop unrolling and peeling
12280and loop exit test optimizations.
12281This option is enabled by default.
12282
12283@item -funconstrained-commons
12284@opindex funconstrained-commons
12285This option tells the compiler that variables declared in common blocks
12286(e.g.@: Fortran) may later be overridden with longer trailing arrays. This
12287prevents certain optimizations that depend on knowing the array bounds.
12288
12289@item -fcrossjumping
12290@opindex fcrossjumping
12291Perform cross-jumping transformation.
12292This transformation unifies equivalent code and saves code size. The
12293resulting code may or may not perform better than without cross-jumping.
12294
12295Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12296
12297@item -fauto-inc-dec
12298@opindex fauto-inc-dec
12299Combine increments or decrements of addresses with memory accesses.
12300This pass is always skipped on architectures that do not have
12301instructions to support this. Enabled by default at @option{-O1} and
12302higher on architectures that support this.
12303
12304@item -fdce
12305@opindex fdce
12306Perform dead code elimination (DCE) on RTL@.
12307Enabled by default at @option{-O1} and higher.
12308
12309@item -fdse
12310@opindex fdse
12311Perform dead store elimination (DSE) on RTL@.
12312Enabled by default at @option{-O1} and higher.
12313
12314@item -fif-conversion
12315@opindex fif-conversion
12316Attempt to transform conditional jumps into branch-less equivalents. This
12317includes use of conditional moves, min, max, set flags and abs instructions, and
12318some tricks doable by standard arithmetics. The use of conditional execution
12319on chips where it is available is controlled by @option{-fif-conversion2}.
12320
12321Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12322not with @option{-Og}.
12323
12324@item -fif-conversion2
12325@opindex fif-conversion2
12326Use conditional execution (where available) to transform conditional jumps into
12327branch-less equivalents.
12328
12329Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12330not with @option{-Og}.
12331
12332@item -fdeclone-ctor-dtor
12333@opindex fdeclone-ctor-dtor
12334The C++ ABI requires multiple entry points for constructors and
12335destructors: one for a base subobject, one for a complete object, and
12336one for a virtual destructor that calls operator delete afterwards.
12337For a hierarchy with virtual bases, the base and complete variants are
12338clones, which means two copies of the function. With this option, the
12339base and complete variants are changed to be thunks that call a common
12340implementation.
12341
12342Enabled by @option{-Os}.
12343
12344@item -fdelete-null-pointer-checks
12345@opindex fdelete-null-pointer-checks
12346Assume that programs cannot safely dereference null pointers, and that
12347no code or data element resides at address zero.
12348This option enables simple constant
12349folding optimizations at all optimization levels. In addition, other
12350optimization passes in GCC use this flag to control global dataflow
12351analyses that eliminate useless checks for null pointers; these assume
12352that a memory access to address zero always results in a trap, so
12353that if a pointer is checked after it has already been dereferenced,
12354it cannot be null.
12355
12356Note however that in some environments this assumption is not true.
12357Use @option{-fno-delete-null-pointer-checks} to disable this optimization
12358for programs that depend on that behavior.
12359
12360This option is enabled by default on most targets. On Nios II ELF, it
12361defaults to off. On AVR and MSP430, this option is completely disabled.
12362
12363Passes that use the dataflow information
12364are enabled independently at different optimization levels.
12365
12366@item -fdevirtualize
12367@opindex fdevirtualize
12368Attempt to convert calls to virtual functions to direct calls. This
12369is done both within a procedure and interprocedurally as part of
12370indirect inlining (@option{-findirect-inlining}) and interprocedural constant
12371propagation (@option{-fipa-cp}).
12372Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12373
12374@item -fdevirtualize-speculatively
12375@opindex fdevirtualize-speculatively
12376Attempt to convert calls to virtual functions to speculative direct calls.
12377Based on the analysis of the type inheritance graph, determine for a given call
12378the set of likely targets. If the set is small, preferably of size 1, change
12379the call into a conditional deciding between direct and indirect calls. The
12380speculative calls enable more optimizations, such as inlining. When they seem
12381useless after further optimization, they are converted back into original form.
12382
12383@item -fdevirtualize-at-ltrans
12384@opindex fdevirtualize-at-ltrans
12385Stream extra information needed for aggressive devirtualization when running
12386the link-time optimizer in local transformation mode.
12387This option enables more devirtualization but
12388significantly increases the size of streamed data. For this reason it is
12389disabled by default.
12390
12391@item -fexpensive-optimizations
12392@opindex fexpensive-optimizations
12393Perform a number of minor optimizations that are relatively expensive.
12394
12395Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12396
12397@item -free
12398@opindex free
12399Attempt to remove redundant extension instructions. This is especially
12400helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
12401registers after writing to their lower 32-bit half.
12402
12403Enabled for Alpha, AArch64 and x86 at levels @option{-O2},
12404@option{-O3}, @option{-Os}.
12405
12406@item -fno-lifetime-dse
12407@opindex fno-lifetime-dse
12408@opindex flifetime-dse
12409In C++ the value of an object is only affected by changes within its
12410lifetime: when the constructor begins, the object has an indeterminate
12411value, and any changes during the lifetime of the object are dead when
12412the object is destroyed. Normally dead store elimination will take
12413advantage of this; if your code relies on the value of the object
12414storage persisting beyond the lifetime of the object, you can use this
12415flag to disable this optimization. To preserve stores before the
12416constructor starts (e.g.@: because your operator new clears the object
12417storage) but still treat the object as dead after the destructor, you
12418can use @option{-flifetime-dse=1}. The default behavior can be
12419explicitly selected with @option{-flifetime-dse=2}.
12420@option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
12421
12422@item -flive-range-shrinkage
12423@opindex flive-range-shrinkage
12424Attempt to decrease register pressure through register live range
12425shrinkage. This is helpful for fast processors with small or moderate
12426size register sets.
12427
12428@item -fira-algorithm=@var{algorithm}
12429@opindex fira-algorithm
12430Use the specified coloring algorithm for the integrated register
12431allocator. The @var{algorithm} argument can be @samp{priority}, which
12432specifies Chow's priority coloring, or @samp{CB}, which specifies
12433Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
12434for all architectures, but for those targets that do support it, it is
12435the default because it generates better code.
12436
12437@item -fira-region=@var{region}
12438@opindex fira-region
12439Use specified regions for the integrated register allocator. The
12440@var{region} argument should be one of the following:
12441
12442@table @samp
12443
12444@item all
12445Use all loops as register allocation regions.
12446This can give the best results for machines with a small and/or
12447irregular register set.
12448
12449@item mixed
12450Use all loops except for loops with small register pressure
12451as the regions. This value usually gives
12452the best results in most cases and for most architectures,
12453and is enabled by default when compiling with optimization for speed
12454(@option{-O}, @option{-O2}, @dots{}).
12455
12456@item one
12457Use all functions as a single region.
12458This typically results in the smallest code size, and is enabled by default for
12459@option{-Os} or @option{-O0}.
12460
12461@end table
12462
12463@item -fira-hoist-pressure
12464@opindex fira-hoist-pressure
12465Use IRA to evaluate register pressure in the code hoisting pass for
12466decisions to hoist expressions. This option usually results in smaller
12467code, but it can slow the compiler down.
12468
12469This option is enabled at level @option{-Os} for all targets.
12470
12471@item -fira-loop-pressure
12472@opindex fira-loop-pressure
12473Use IRA to evaluate register pressure in loops for decisions to move
12474loop invariants. This option usually results in generation
12475of faster and smaller code on machines with large register files (>= 32
12476registers), but it can slow the compiler down.
12477
12478This option is enabled at level @option{-O3} for some targets.
12479
12480@item -fno-ira-share-save-slots
12481@opindex fno-ira-share-save-slots
12482@opindex fira-share-save-slots
12483Disable sharing of stack slots used for saving call-used hard
12484registers living through a call. Each hard register gets a
12485separate stack slot, and as a result function stack frames are
12486larger.
12487
12488@item -fno-ira-share-spill-slots
12489@opindex fno-ira-share-spill-slots
12490@opindex fira-share-spill-slots
12491Disable sharing of stack slots allocated for pseudo-registers. Each
12492pseudo-register that does not get a hard register gets a separate
12493stack slot, and as a result function stack frames are larger.
12494
12495@item -flra-remat
12496@opindex flra-remat
12497Enable CFG-sensitive rematerialization in LRA. Instead of loading
12498values of spilled pseudos, LRA tries to rematerialize (recalculate)
12499values if it is profitable.
12500
12501Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12502
12503@item -fdelayed-branch
12504@opindex fdelayed-branch
12505If supported for the target machine, attempt to reorder instructions
12506to exploit instruction slots available after delayed branch
12507instructions.
12508
12509Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
12510but not at @option{-Og}.
12511
12512@item -fschedule-insns
12513@opindex fschedule-insns
12514If supported for the target machine, attempt to reorder instructions to
12515eliminate execution stalls due to required data being unavailable. This
12516helps machines that have slow floating point or memory load instructions
12517by allowing other instructions to be issued until the result of the load
12518or floating-point instruction is required.
12519
12520Enabled at levels @option{-O2}, @option{-O3}.
12521
12522@item -fschedule-insns2
12523@opindex fschedule-insns2
12524Similar to @option{-fschedule-insns}, but requests an additional pass of
12525instruction scheduling after register allocation has been done. This is
12526especially useful on machines with a relatively small number of
12527registers and where memory load instructions take more than one cycle.
12528
12529Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12530
12531@item -fno-sched-interblock
12532@opindex fno-sched-interblock
12533@opindex fsched-interblock
12534Disable instruction scheduling across basic blocks, which
12535is normally enabled when scheduling before register allocation, i.e.@:
12536with @option{-fschedule-insns} or at @option{-O2} or higher.
12537
12538@item -fno-sched-spec
12539@opindex fno-sched-spec
12540@opindex fsched-spec
12541Disable speculative motion of non-load instructions, which
12542is normally enabled when scheduling before register allocation, i.e.@:
12543with @option{-fschedule-insns} or at @option{-O2} or higher.
12544
12545@item -fsched-pressure
12546@opindex fsched-pressure
12547Enable register pressure sensitive insn scheduling before register
12548allocation. This only makes sense when scheduling before register
12549allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
12550@option{-O2} or higher. Usage of this option can improve the
12551generated code and decrease its size by preventing register pressure
12552increase above the number of available hard registers and subsequent
12553spills in register allocation.
12554
12555@item -fsched-spec-load
12556@opindex fsched-spec-load
12557Allow speculative motion of some load instructions. This only makes
12558sense when scheduling before register allocation, i.e.@: with
12559@option{-fschedule-insns} or at @option{-O2} or higher.
12560
12561@item -fsched-spec-load-dangerous
12562@opindex fsched-spec-load-dangerous
12563Allow speculative motion of more load instructions. This only makes
12564sense when scheduling before register allocation, i.e.@: with
12565@option{-fschedule-insns} or at @option{-O2} or higher.
12566
12567@item -fsched-stalled-insns
12568@itemx -fsched-stalled-insns=@var{n}
12569@opindex fsched-stalled-insns
12570Define how many insns (if any) can be moved prematurely from the queue
12571of stalled insns into the ready list during the second scheduling pass.
12572@option{-fno-sched-stalled-insns} means that no insns are moved
12573prematurely, @option{-fsched-stalled-insns=0} means there is no limit
12574on how many queued insns can be moved prematurely.
12575@option{-fsched-stalled-insns} without a value is equivalent to
12576@option{-fsched-stalled-insns=1}.
12577
12578@item -fsched-stalled-insns-dep
12579@itemx -fsched-stalled-insns-dep=@var{n}
12580@opindex fsched-stalled-insns-dep
12581Define how many insn groups (cycles) are examined for a dependency
12582on a stalled insn that is a candidate for premature removal from the queue
12583of stalled insns. This has an effect only during the second scheduling pass,
12584and only if @option{-fsched-stalled-insns} is used.
12585@option{-fno-sched-stalled-insns-dep} is equivalent to
12586@option{-fsched-stalled-insns-dep=0}.
12587@option{-fsched-stalled-insns-dep} without a value is equivalent to
12588@option{-fsched-stalled-insns-dep=1}.
12589
12590@item -fsched2-use-superblocks
12591@opindex fsched2-use-superblocks
12592When scheduling after register allocation, use superblock scheduling.
12593This allows motion across basic block boundaries,
12594resulting in faster schedules. This option is experimental, as not all machine
12595descriptions used by GCC model the CPU closely enough to avoid unreliable
12596results from the algorithm.
12597
12598This only makes sense when scheduling after register allocation, i.e.@: with
12599@option{-fschedule-insns2} or at @option{-O2} or higher.
12600
12601@item -fsched-group-heuristic
12602@opindex fsched-group-heuristic
12603Enable the group heuristic in the scheduler. This heuristic favors
12604the instruction that belongs to a schedule group. This is enabled
12605by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12606or @option{-fschedule-insns2} or at @option{-O2} or higher.
12607
12608@item -fsched-critical-path-heuristic
12609@opindex fsched-critical-path-heuristic
12610Enable the critical-path heuristic in the scheduler. This heuristic favors
12611instructions on the critical path. This is enabled by default when
12612scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12613or @option{-fschedule-insns2} or at @option{-O2} or higher.
12614
12615@item -fsched-spec-insn-heuristic
12616@opindex fsched-spec-insn-heuristic
12617Enable the speculative instruction heuristic in the scheduler. This
12618heuristic favors speculative instructions with greater dependency weakness.
12619This is enabled by default when scheduling is enabled, i.e.@:
12620with @option{-fschedule-insns} or @option{-fschedule-insns2}
12621or at @option{-O2} or higher.
12622
12623@item -fsched-rank-heuristic
12624@opindex fsched-rank-heuristic
12625Enable the rank heuristic in the scheduler. This heuristic favors
12626the instruction belonging to a basic block with greater size or frequency.
12627This is enabled by default when scheduling is enabled, i.e.@:
12628with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12629at @option{-O2} or higher.
12630
12631@item -fsched-last-insn-heuristic
12632@opindex fsched-last-insn-heuristic
12633Enable the last-instruction heuristic in the scheduler. This heuristic
12634favors the instruction that is less dependent on the last instruction
12635scheduled. This is enabled by default when scheduling is enabled,
12636i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12637at @option{-O2} or higher.
12638
12639@item -fsched-dep-count-heuristic
12640@opindex fsched-dep-count-heuristic
12641Enable the dependent-count heuristic in the scheduler. This heuristic
12642favors the instruction that has more instructions depending on it.
12643This is enabled by default when scheduling is enabled, i.e.@:
12644with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12645at @option{-O2} or higher.
12646
12647@item -freschedule-modulo-scheduled-loops
12648@opindex freschedule-modulo-scheduled-loops
12649Modulo scheduling is performed before traditional scheduling. If a loop
12650is modulo scheduled, later scheduling passes may change its schedule.
12651Use this option to control that behavior.
12652
12653@item -fselective-scheduling
12654@opindex fselective-scheduling
12655Schedule instructions using selective scheduling algorithm. Selective
12656scheduling runs instead of the first scheduler pass.
12657
12658@item -fselective-scheduling2
12659@opindex fselective-scheduling2
12660Schedule instructions using selective scheduling algorithm. Selective
12661scheduling runs instead of the second scheduler pass.
12662
12663@item -fsel-sched-pipelining
12664@opindex fsel-sched-pipelining
12665Enable software pipelining of innermost loops during selective scheduling.
12666This option has no effect unless one of @option{-fselective-scheduling} or
12667@option{-fselective-scheduling2} is turned on.
12668
12669@item -fsel-sched-pipelining-outer-loops
12670@opindex fsel-sched-pipelining-outer-loops
12671When pipelining loops during selective scheduling, also pipeline outer loops.
12672This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
12673
12674@item -fsemantic-interposition
12675@opindex fsemantic-interposition
12676Some object formats, like ELF, allow interposing of symbols by the
12677dynamic linker.
12678This means that for symbols exported from the DSO, the compiler cannot perform
12679interprocedural propagation, inlining and other optimizations in anticipation
12680that the function or variable in question may change. While this feature is
12681useful, for example, to rewrite memory allocation functions by a debugging
12682implementation, it is expensive in the terms of code quality.
12683With @option{-fno-semantic-interposition} the compiler assumes that
12684if interposition happens for functions the overwriting function will have
12685precisely the same semantics (and side effects).
12686Similarly if interposition happens
12687for variables, the constructor of the variable will be the same. The flag
12688has no effect for functions explicitly declared inline
12689(where it is never allowed for interposition to change semantics)
12690and for symbols explicitly declared weak.
12691
12692@item -fshrink-wrap
12693@opindex fshrink-wrap
12694Emit function prologues only before parts of the function that need it,
12695rather than at the top of the function. This flag is enabled by default at
12696@option{-O} and higher.
12697
12698@item -fshrink-wrap-separate
12699@opindex fshrink-wrap-separate
12700Shrink-wrap separate parts of the prologue and epilogue separately, so that
12701those parts are only executed when needed.
12702This option is on by default, but has no effect unless @option{-fshrink-wrap}
12703is also turned on and the target supports this.
12704
12705@item -fcaller-saves
12706@opindex fcaller-saves
12707Enable allocation of values to registers that are clobbered by
12708function calls, by emitting extra instructions to save and restore the
12709registers around such calls. Such allocation is done only when it
12710seems to result in better code.
12711
12712This option is always enabled by default on certain machines, usually
12713those which have no call-preserved registers to use instead.
12714
12715Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12716
12717@item -fcombine-stack-adjustments
12718@opindex fcombine-stack-adjustments
12719Tracks stack adjustments (pushes and pops) and stack memory references
12720and then tries to find ways to combine them.
12721
12722Enabled by default at @option{-O1} and higher.
12723
12724@item -fipa-ra
12725@opindex fipa-ra
12726Use caller save registers for allocation if those registers are not used by
12727any called function. In that case it is not necessary to save and restore
12728them around calls. This is only possible if called functions are part of
12729same compilation unit as current function and they are compiled before it.
12730
12731Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
12732is disabled if generated code will be instrumented for profiling
12733(@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
12734exactly (this happens on targets that do not expose prologues
12735and epilogues in RTL).
12736
12737@item -fconserve-stack
12738@opindex fconserve-stack
12739Attempt to minimize stack usage. The compiler attempts to use less
12740stack space, even if that makes the program slower. This option
12741implies setting the @option{large-stack-frame} parameter to 100
12742and the @option{large-stack-frame-growth} parameter to 400.
12743
12744@item -ftree-reassoc
12745@opindex ftree-reassoc
12746Perform reassociation on trees. This flag is enabled by default
12747at @option{-O1} and higher.
12748
12749@item -fcode-hoisting
12750@opindex fcode-hoisting
12751Perform code hoisting. Code hoisting tries to move the
12752evaluation of expressions executed on all paths to the function exit
12753as early as possible. This is especially useful as a code size
12754optimization, but it often helps for code speed as well.
12755This flag is enabled by default at @option{-O2} and higher.
12756
12757@item -ftree-pre
12758@opindex ftree-pre
12759Perform partial redundancy elimination (PRE) on trees. This flag is
12760enabled by default at @option{-O2} and @option{-O3}.
12761
12762@item -ftree-partial-pre
12763@opindex ftree-partial-pre
12764Make partial redundancy elimination (PRE) more aggressive. This flag is
12765enabled by default at @option{-O3}.
12766
12767@item -ftree-forwprop
12768@opindex ftree-forwprop
12769Perform forward propagation on trees. This flag is enabled by default
12770at @option{-O1} and higher.
12771
12772@item -ftree-fre
12773@opindex ftree-fre
12774Perform full redundancy elimination (FRE) on trees. The difference
12775between FRE and PRE is that FRE only considers expressions
12776that are computed on all paths leading to the redundant computation.
12777This analysis is faster than PRE, though it exposes fewer redundancies.
12778This flag is enabled by default at @option{-O1} and higher.
12779
12780@item -ftree-phiprop
12781@opindex ftree-phiprop
12782Perform hoisting of loads from conditional pointers on trees. This
12783pass is enabled by default at @option{-O1} and higher.
12784
12785@item -fhoist-adjacent-loads
12786@opindex fhoist-adjacent-loads
12787Speculatively hoist loads from both branches of an if-then-else if the
12788loads are from adjacent locations in the same structure and the target
12789architecture has a conditional move instruction. This flag is enabled
12790by default at @option{-O2} and higher.
12791
12792@item -ftree-copy-prop
12793@opindex ftree-copy-prop
12794Perform copy propagation on trees. This pass eliminates unnecessary
12795copy operations. This flag is enabled by default at @option{-O1} and
12796higher.
12797
12798@item -fipa-pure-const
12799@opindex fipa-pure-const
12800Discover which functions are pure or constant.
12801Enabled by default at @option{-O1} and higher.
12802
12803@item -fipa-reference
12804@opindex fipa-reference
12805Discover which static variables do not escape the
12806compilation unit.
12807Enabled by default at @option{-O1} and higher.
12808
12809@item -fipa-reference-addressable
12810@opindex fipa-reference-addressable
12811Discover read-only, write-only and non-addressable static variables.
12812Enabled by default at @option{-O1} and higher.
12813
12814@item -fipa-stack-alignment
12815@opindex fipa-stack-alignment
12816Reduce stack alignment on call sites if possible.
12817Enabled by default.
12818
12819@item -fipa-pta
12820@opindex fipa-pta
12821Perform interprocedural pointer analysis and interprocedural modification
12822and reference analysis. This option can cause excessive memory and
12823compile-time usage on large compilation units. It is not enabled by
12824default at any optimization level.
12825
12826@item -fipa-profile
12827@opindex fipa-profile
12828Perform interprocedural profile propagation. The functions called only from
12829cold functions are marked as cold. Also functions executed once (such as
12830@code{cold}, @code{noreturn}, static constructors or destructors) are
12831identified. Cold functions and loop less parts of functions executed once are
12832then optimized for size.
12833Enabled by default at @option{-O1} and higher.
12834
12835@item -fipa-modref
12836@opindex fipa-modref
12837Perform interprocedural mod/ref analysis. This optimization analyzes the side
12838effects of functions (memory locations that are modified or referenced) and
12839enables better optimization across the function call boundary. This flag is
12840enabled by default at @option{-O1} and higher.
12841
12842@item -fipa-cp
12843@opindex fipa-cp
12844Perform interprocedural constant propagation.
12845This optimization analyzes the program to determine when values passed
12846to functions are constants and then optimizes accordingly.
12847This optimization can substantially increase performance
12848if the application has constants passed to functions.
12849This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
12850It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12851
12852@item -fipa-cp-clone
12853@opindex fipa-cp-clone
12854Perform function cloning to make interprocedural constant propagation stronger.
12855When enabled, interprocedural constant propagation performs function cloning
12856when externally visible function can be called with constant arguments.
12857Because this optimization can create multiple copies of functions,
12858it may significantly increase code size
12859(see @option{--param ipa-cp-unit-growth=@var{value}}).
12860This flag is enabled by default at @option{-O3}.
12861It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12862
12863@item -fipa-bit-cp
12864@opindex fipa-bit-cp
12865When enabled, perform interprocedural bitwise constant
12866propagation. This flag is enabled by default at @option{-O2} and
12867by @option{-fprofile-use} and @option{-fauto-profile}.
12868It requires that @option{-fipa-cp} is enabled.
12869
12870@item -fipa-vrp
12871@opindex fipa-vrp
12872When enabled, perform interprocedural propagation of value
12873ranges. This flag is enabled by default at @option{-O2}. It requires
12874that @option{-fipa-cp} is enabled.
12875
12876@item -fipa-icf
12877@opindex fipa-icf
12878Perform Identical Code Folding for functions and read-only variables.
12879The optimization reduces code size and may disturb unwind stacks by replacing
12880a function by equivalent one with a different name. The optimization works
12881more effectively with link-time optimization enabled.
12882
12883Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
12884works on different levels and thus the optimizations are not same - there are
12885equivalences that are found only by GCC and equivalences found only by Gold.
12886
12887This flag is enabled by default at @option{-O2} and @option{-Os}.
12888
12889@item -flive-patching=@var{level}
12890@opindex flive-patching
12891Control GCC's optimizations to produce output suitable for live-patching.
12892
12893If the compiler's optimization uses a function's body or information extracted
12894from its body to optimize/change another function, the latter is called an
12895impacted function of the former. If a function is patched, its impacted
12896functions should be patched too.
12897
12898The impacted functions are determined by the compiler's interprocedural
12899optimizations. For example, a caller is impacted when inlining a function
12900into its caller,
12901cloning a function and changing its caller to call this new clone,
12902or extracting a function's pureness/constness information to optimize
12903its direct or indirect callers, etc.
12904
12905Usually, the more IPA optimizations enabled, the larger the number of
12906impacted functions for each function. In order to control the number of
12907impacted functions and more easily compute the list of impacted function,
12908IPA optimizations can be partially enabled at two different levels.
12909
12910The @var{level} argument should be one of the following:
12911
12912@table @samp
12913
12914@item inline-clone
12915
12916Only enable inlining and cloning optimizations, which includes inlining,
12917cloning, interprocedural scalar replacement of aggregates and partial inlining.
12918As a result, when patching a function, all its callers and its clones'
12919callers are impacted, therefore need to be patched as well.
12920
12921@option{-flive-patching=inline-clone} disables the following optimization flags:
12922@gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra @gol
12923-fipa-icf -fipa-icf-functions -fipa-icf-variables @gol
12924-fipa-bit-cp -fipa-vrp -fipa-pure-const -fipa-reference-addressable @gol
12925-fipa-stack-alignment -fipa-modref}
12926
12927@item inline-only-static
12928
12929Only enable inlining of static functions.
12930As a result, when patching a static function, all its callers are impacted
12931and so need to be patched as well.
12932
12933In addition to all the flags that @option{-flive-patching=inline-clone}
12934disables,
12935@option{-flive-patching=inline-only-static} disables the following additional
12936optimization flags:
12937@gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
12938
12939@end table
12940
12941When @option{-flive-patching} is specified without any value, the default value
12942is @var{inline-clone}.
12943
12944This flag is disabled by default.
12945
12946Note that @option{-flive-patching} is not supported with link-time optimization
12947(@option{-flto}).
12948
12949@item -fisolate-erroneous-paths-dereference
12950@opindex fisolate-erroneous-paths-dereference
12951Detect paths that trigger erroneous or undefined behavior due to
12952dereferencing a null pointer. Isolate those paths from the main control
12953flow and turn the statement with erroneous or undefined behavior into a trap.
12954This flag is enabled by default at @option{-O2} and higher and depends on
12955@option{-fdelete-null-pointer-checks} also being enabled.
12956
12957@item -fisolate-erroneous-paths-attribute
12958@opindex fisolate-erroneous-paths-attribute
12959Detect paths that trigger erroneous or undefined behavior due to a null value
12960being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
12961attribute. Isolate those paths from the main control flow and turn the
12962statement with erroneous or undefined behavior into a trap. This is not
12963currently enabled, but may be enabled by @option{-O2} in the future.
12964
12965@item -ftree-sink
12966@opindex ftree-sink
12967Perform forward store motion on trees. This flag is
12968enabled by default at @option{-O1} and higher.
12969
12970@item -ftree-bit-ccp
12971@opindex ftree-bit-ccp
12972Perform sparse conditional bit constant propagation on trees and propagate
12973pointer alignment information.
12974This pass only operates on local scalar variables and is enabled by default
12975at @option{-O1} and higher, except for @option{-Og}.
12976It requires that @option{-ftree-ccp} is enabled.
12977
12978@item -ftree-ccp
12979@opindex ftree-ccp
12980Perform sparse conditional constant propagation (CCP) on trees. This
12981pass only operates on local scalar variables and is enabled by default
12982at @option{-O1} and higher.
12983
12984@item -fssa-backprop
12985@opindex fssa-backprop
12986Propagate information about uses of a value up the definition chain
12987in order to simplify the definitions. For example, this pass strips
12988sign operations if the sign of a value never matters. The flag is
12989enabled by default at @option{-O1} and higher.
12990
12991@item -fssa-phiopt
12992@opindex fssa-phiopt
12993Perform pattern matching on SSA PHI nodes to optimize conditional
12994code. This pass is enabled by default at @option{-O1} and higher,
12995except for @option{-Og}.
12996
12997@item -ftree-switch-conversion
12998@opindex ftree-switch-conversion
12999Perform conversion of simple initializations in a switch to
13000initializations from a scalar array. This flag is enabled by default
13001at @option{-O2} and higher.
13002
13003@item -ftree-tail-merge
13004@opindex ftree-tail-merge
13005Look for identical code sequences. When found, replace one with a jump to the
13006other. This optimization is known as tail merging or cross jumping. This flag
13007is enabled by default at @option{-O2} and higher. The compilation time
13008in this pass can
13009be limited using @option{max-tail-merge-comparisons} parameter and
13010@option{max-tail-merge-iterations} parameter.
13011
13012@item -ftree-dce
13013@opindex ftree-dce
13014Perform dead code elimination (DCE) on trees. This flag is enabled by
13015default at @option{-O1} and higher.
13016
13017@item -ftree-builtin-call-dce
13018@opindex ftree-builtin-call-dce
13019Perform conditional dead code elimination (DCE) for calls to built-in functions
13020that may set @code{errno} but are otherwise free of side effects. This flag is
13021enabled by default at @option{-O2} and higher if @option{-Os} is not also
13022specified.
13023
13024@item -ffinite-loops
13025@opindex ffinite-loops
13026@opindex fno-finite-loops
13027Assume that a loop with an exit will eventually take the exit and not loop
13028indefinitely. This allows the compiler to remove loops that otherwise have
13029no side-effects, not considering eventual endless looping as such.
13030
13031This option is enabled by default at @option{-O2} for C++ with -std=c++11
13032or higher.
13033
13034@item -ftree-dominator-opts
13035@opindex ftree-dominator-opts
13036Perform a variety of simple scalar cleanups (constant/copy
13037propagation, redundancy elimination, range propagation and expression
13038simplification) based on a dominator tree traversal. This also
13039performs jump threading (to reduce jumps to jumps). This flag is
13040enabled by default at @option{-O1} and higher.
13041
13042@item -ftree-dse
13043@opindex ftree-dse
13044Perform dead store elimination (DSE) on trees. A dead store is a store into
13045a memory location that is later overwritten by another store without
13046any intervening loads. In this case the earlier store can be deleted. This
13047flag is enabled by default at @option{-O1} and higher.
13048
13049@item -ftree-ch
13050@opindex ftree-ch
13051Perform loop header copying on trees. This is beneficial since it increases
13052effectiveness of code motion optimizations. It also saves one jump. This flag
13053is enabled by default at @option{-O1} and higher. It is not enabled
13054for @option{-Os}, since it usually increases code size.
13055
13056@item -ftree-loop-optimize
13057@opindex ftree-loop-optimize
13058Perform loop optimizations on trees. This flag is enabled by default
13059at @option{-O1} and higher.
13060
13061@item -ftree-loop-linear
13062@itemx -floop-strip-mine
13063@itemx -floop-block
13064@opindex ftree-loop-linear
13065@opindex floop-strip-mine
13066@opindex floop-block
13067Perform loop nest optimizations. Same as
13068@option{-floop-nest-optimize}. To use this code transformation, GCC has
13069to be configured with @option{--with-isl} to enable the Graphite loop
13070transformation infrastructure.
13071
13072@item -fgraphite-identity
13073@opindex fgraphite-identity
13074Enable the identity transformation for graphite. For every SCoP we generate
13075the polyhedral representation and transform it back to gimple. Using
13076@option{-fgraphite-identity} we can check the costs or benefits of the
13077GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
13078are also performed by the code generator isl, like index splitting and
13079dead code elimination in loops.
13080
13081@item -floop-nest-optimize
13082@opindex floop-nest-optimize
13083Enable the isl based loop nest optimizer. This is a generic loop nest
13084optimizer based on the Pluto optimization algorithms. It calculates a loop
13085structure optimized for data-locality and parallelism. This option
13086is experimental.
13087
13088@item -floop-parallelize-all
13089@opindex floop-parallelize-all
13090Use the Graphite data dependence analysis to identify loops that can
13091be parallelized. Parallelize all the loops that can be analyzed to
13092not contain loop carried dependences without checking that it is
13093profitable to parallelize the loops.
13094
13095@item -ftree-coalesce-vars
13096@opindex ftree-coalesce-vars
13097While transforming the program out of the SSA representation, attempt to
13098reduce copying by coalescing versions of different user-defined
13099variables, instead of just compiler temporaries. This may severely
13100limit the ability to debug an optimized program compiled with
13101@option{-fno-var-tracking-assignments}. In the negated form, this flag
13102prevents SSA coalescing of user variables. This option is enabled by
13103default if optimization is enabled, and it does very little otherwise.
13104
13105@item -ftree-loop-if-convert
13106@opindex ftree-loop-if-convert
13107Attempt to transform conditional jumps in the innermost loops to
13108branch-less equivalents. The intent is to remove control-flow from
13109the innermost loops in order to improve the ability of the
13110vectorization pass to handle these loops. This is enabled by default
13111if vectorization is enabled.
13112
13113@item -ftree-loop-distribution
13114@opindex ftree-loop-distribution
13115Perform loop distribution. This flag can improve cache performance on
13116big loop bodies and allow further loop optimizations, like
13117parallelization or vectorization, to take place. For example, the loop
13118@smallexample
13119DO I = 1, N
13120 A(I) = B(I) + C
13121 D(I) = E(I) * F
13122ENDDO
13123@end smallexample
13124is transformed to
13125@smallexample
13126DO I = 1, N
13127 A(I) = B(I) + C
13128ENDDO
13129DO I = 1, N
13130 D(I) = E(I) * F
13131ENDDO
13132@end smallexample
13133This flag is enabled by default at @option{-O3}.
13134It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13135
13136@item -ftree-loop-distribute-patterns
13137@opindex ftree-loop-distribute-patterns
13138Perform loop distribution of patterns that can be code generated with
13139calls to a library. This flag is enabled by default at @option{-O2} and
13140higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
13141
13142This pass distributes the initialization loops and generates a call to
13143memset zero. For example, the loop
13144@smallexample
13145DO I = 1, N
13146 A(I) = 0
13147 B(I) = A(I) + I
13148ENDDO
13149@end smallexample
13150is transformed to
13151@smallexample
13152DO I = 1, N
13153 A(I) = 0
13154ENDDO
13155DO I = 1, N
13156 B(I) = A(I) + I
13157ENDDO
13158@end smallexample
13159and the initialization loop is transformed into a call to memset zero.
13160This flag is enabled by default at @option{-O3}.
13161It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13162
13163@item -floop-interchange
13164@opindex floop-interchange
13165Perform loop interchange outside of graphite. This flag can improve cache
13166performance on loop nest and allow further loop optimizations, like
13167vectorization, to take place. For example, the loop
13168@smallexample
13169for (int i = 0; i < N; i++)
13170 for (int j = 0; j < N; j++)
13171 for (int k = 0; k < N; k++)
13172 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13173@end smallexample
13174is transformed to
13175@smallexample
13176for (int i = 0; i < N; i++)
13177 for (int k = 0; k < N; k++)
13178 for (int j = 0; j < N; j++)
13179 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13180@end smallexample
13181This flag is enabled by default at @option{-O3}.
13182It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13183
13184@item -floop-unroll-and-jam
13185@opindex floop-unroll-and-jam
13186Apply unroll and jam transformations on feasible loops. In a loop
13187nest this unrolls the outer loop by some factor and fuses the resulting
13188multiple inner loops. This flag is enabled by default at @option{-O3}.
13189It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13190
13191@item -ftree-loop-im
13192@opindex ftree-loop-im
13193Perform loop invariant motion on trees. This pass moves only invariants that
13194are hard to handle at RTL level (function calls, operations that expand to
13195nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
13196operands of conditions that are invariant out of the loop, so that we can use
13197just trivial invariantness analysis in loop unswitching. The pass also includes
13198store motion.
13199
13200@item -ftree-loop-ivcanon
13201@opindex ftree-loop-ivcanon
13202Create a canonical counter for number of iterations in loops for which
13203determining number of iterations requires complicated analysis. Later
13204optimizations then may determine the number easily. Useful especially
13205in connection with unrolling.
13206
13207@item -ftree-scev-cprop
13208@opindex ftree-scev-cprop
13209Perform final value replacement. If a variable is modified in a loop
13210in such a way that its value when exiting the loop can be determined using
13211only its initial value and the number of loop iterations, replace uses of
13212the final value by such a computation, provided it is sufficiently cheap.
13213This reduces data dependencies and may allow further simplifications.
13214Enabled by default at @option{-O1} and higher.
13215
13216@item -fivopts
13217@opindex fivopts
13218Perform induction variable optimizations (strength reduction, induction
13219variable merging and induction variable elimination) on trees.
13220
13221@item -ftree-parallelize-loops=n
13222@opindex ftree-parallelize-loops
13223Parallelize loops, i.e., split their iteration space to run in n threads.
13224This is only possible for loops whose iterations are independent
13225and can be arbitrarily reordered. The optimization is only
13226profitable on multiprocessor machines, for loops that are CPU-intensive,
13227rather than constrained e.g.@: by memory bandwidth. This option
13228implies @option{-pthread}, and thus is only supported on targets
13229that have support for @option{-pthread}.
13230
13231@item -ftree-pta
13232@opindex ftree-pta
13233Perform function-local points-to analysis on trees. This flag is
13234enabled by default at @option{-O1} and higher, except for @option{-Og}.
13235
13236@item -ftree-sra
13237@opindex ftree-sra
13238Perform scalar replacement of aggregates. This pass replaces structure
13239references with scalars to prevent committing structures to memory too
13240early. This flag is enabled by default at @option{-O1} and higher,
13241except for @option{-Og}.
13242
13243@item -fstore-merging
13244@opindex fstore-merging
13245Perform merging of narrow stores to consecutive memory addresses. This pass
13246merges contiguous stores of immediate values narrower than a word into fewer
13247wider stores to reduce the number of instructions. This is enabled by default
13248at @option{-O2} and higher as well as @option{-Os}.
13249
13250@item -ftree-ter
13251@opindex ftree-ter
13252Perform temporary expression replacement during the SSA->normal phase. Single
13253use/single def temporaries are replaced at their use location with their
13254defining expression. This results in non-GIMPLE code, but gives the expanders
13255much more complex trees to work on resulting in better RTL generation. This is
13256enabled by default at @option{-O1} and higher.
13257
13258@item -ftree-slsr
13259@opindex ftree-slsr
13260Perform straight-line strength reduction on trees. This recognizes related
13261expressions involving multiplications and replaces them by less expensive
13262calculations when possible. This is enabled by default at @option{-O1} and
13263higher.
13264
13265@item -ftree-vectorize
13266@opindex ftree-vectorize
13267Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
13268and @option{-ftree-slp-vectorize} if not explicitly specified.
13269
13270@item -ftree-loop-vectorize
13271@opindex ftree-loop-vectorize
13272Perform loop vectorization on trees. This flag is enabled by default at
13273@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13274and @option{-fauto-profile}.
13275
13276@item -ftree-slp-vectorize
13277@opindex ftree-slp-vectorize
13278Perform basic block vectorization on trees. This flag is enabled by default at
13279@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13280and @option{-fauto-profile}.
13281
13282@item -ftrivial-auto-var-init=@var{choice}
13283@opindex ftrivial-auto-var-init
13284Initialize automatic variables with either a pattern or with zeroes to increase
13285the security and predictability of a program by preventing uninitialized memory
13286disclosure and use.
13287GCC still considers an automatic variable that doesn't have an explicit
13288initializer as uninitialized, @option{-Wuninitialized} and
13289@option{-Wanalyzer-use-of-uninitialized-value} will still report
8f4634fb
RB
13290warning messages on such automatic variables and the compiler will
13291perform optimization as if the variable were uninitialized.
d77de738
ML
13292With this option, GCC will also initialize any padding of automatic variables
13293that have structure or union types to zeroes.
13294However, the current implementation cannot initialize automatic variables that
13295are declared between the controlling expression and the first case of a
13296@code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all
13297such cases.
13298
13299The three values of @var{choice} are:
13300
13301@itemize @bullet
13302@item
13303@samp{uninitialized} doesn't initialize any automatic variables.
13304This is C and C++'s default.
13305
13306@item
13307@samp{pattern} Initialize automatic variables with values which will likely
13308transform logic bugs into crashes down the line, are easily recognized in a
13309crash dump and without being values that programmers can rely on for useful
13310program semantics.
13311The current value is byte-repeatable pattern with byte "0xFE".
13312The values used for pattern initialization might be changed in the future.
13313
13314@item
13315@samp{zero} Initialize automatic variables with zeroes.
13316@end itemize
13317
13318The default is @samp{uninitialized}.
13319
13320You can control this behavior for a specific variable by using the variable
13321attribute @code{uninitialized} (@pxref{Variable Attributes}).
13322
13323@item -fvect-cost-model=@var{model}
13324@opindex fvect-cost-model
13325Alter the cost model used for vectorization. The @var{model} argument
13326should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
13327@samp{very-cheap}.
13328With the @samp{unlimited} model the vectorized code-path is assumed
13329to be profitable while with the @samp{dynamic} model a runtime check
13330guards the vectorized code-path to enable it only for iteration
13331counts that will likely execute faster than when executing the original
13332scalar loop. The @samp{cheap} model disables vectorization of
13333loops where doing so would be cost prohibitive for example due to
13334required runtime checks for data dependence or alignment but otherwise
13335is equal to the @samp{dynamic} model. The @samp{very-cheap} model only
13336allows vectorization if the vector code would entirely replace the
13337scalar code that is being vectorized. For example, if each iteration
13338of a vectorized loop would only be able to handle exactly four iterations
13339of the scalar loop, the @samp{very-cheap} model would only allow
13340vectorization if the scalar iteration count is known to be a multiple
13341of four.
13342
13343The default cost model depends on other optimization flags and is
13344either @samp{dynamic} or @samp{cheap}.
13345
13346@item -fsimd-cost-model=@var{model}
13347@opindex fsimd-cost-model
13348Alter the cost model used for vectorization of loops marked with the OpenMP
13349simd directive. The @var{model} argument should be one of
13350@samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
13351have the same meaning as described in @option{-fvect-cost-model} and by
13352default a cost model defined with @option{-fvect-cost-model} is used.
13353
13354@item -ftree-vrp
13355@opindex ftree-vrp
13356Perform Value Range Propagation on trees. This is similar to the
13357constant propagation pass, but instead of values, ranges of values are
13358propagated. This allows the optimizers to remove unnecessary range
13359checks like array bound checks and null pointer checks. This is
13360enabled by default at @option{-O2} and higher. Null pointer check
13361elimination is only done if @option{-fdelete-null-pointer-checks} is
13362enabled.
13363
13364@item -fsplit-paths
13365@opindex fsplit-paths
13366Split paths leading to loop backedges. This can improve dead code
13367elimination and common subexpression elimination. This is enabled by
13368default at @option{-O3} and above.
13369
13370@item -fsplit-ivs-in-unroller
13371@opindex fsplit-ivs-in-unroller
13372Enables expression of values of induction variables in later iterations
13373of the unrolled loop using the value in the first iteration. This breaks
13374long dependency chains, thus improving efficiency of the scheduling passes.
13375
13376A combination of @option{-fweb} and CSE is often sufficient to obtain the
13377same effect. However, that is not reliable in cases where the loop body
13378is more complicated than a single basic block. It also does not work at all
13379on some architectures due to restrictions in the CSE pass.
13380
13381This optimization is enabled by default.
13382
13383@item -fvariable-expansion-in-unroller
13384@opindex fvariable-expansion-in-unroller
13385With this option, the compiler creates multiple copies of some
13386local variables when unrolling a loop, which can result in superior code.
13387
13388This optimization is enabled by default for PowerPC targets, but disabled
13389by default otherwise.
13390
13391@item -fpartial-inlining
13392@opindex fpartial-inlining
13393Inline parts of functions. This option has any effect only
13394when inlining itself is turned on by the @option{-finline-functions}
13395or @option{-finline-small-functions} options.
13396
13397Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13398
13399@item -fpredictive-commoning
13400@opindex fpredictive-commoning
13401Perform predictive commoning optimization, i.e., reusing computations
13402(especially memory loads and stores) performed in previous
13403iterations of loops.
13404
13405This option is enabled at level @option{-O3}.
13406It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13407
13408@item -fprefetch-loop-arrays
13409@opindex fprefetch-loop-arrays
13410If supported by the target machine, generate instructions to prefetch
13411memory to improve the performance of loops that access large arrays.
13412
13413This option may generate better or worse code; results are highly
13414dependent on the structure of loops within the source code.
13415
13416Disabled at level @option{-Os}.
13417
13418@item -fno-printf-return-value
13419@opindex fno-printf-return-value
13420@opindex fprintf-return-value
13421Do not substitute constants for known return value of formatted output
13422functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
13423@code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
13424transformation allows GCC to optimize or even eliminate branches based
13425on the known return value of these functions called with arguments that
13426are either constant, or whose values are known to be in a range that
13427makes determining the exact return value possible. For example, when
13428@option{-fprintf-return-value} is in effect, both the branch and the
13429body of the @code{if} statement (but not the call to @code{snprint})
13430can be optimized away when @code{i} is a 32-bit or smaller integer
13431because the return value is guaranteed to be at most 8.
13432
13433@smallexample
13434char buf[9];
13435if (snprintf (buf, "%08x", i) >= sizeof buf)
13436 @dots{}
13437@end smallexample
13438
13439The @option{-fprintf-return-value} option relies on other optimizations
13440and yields best results with @option{-O2} and above. It works in tandem
13441with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
13442options. The @option{-fprintf-return-value} option is enabled by default.
13443
13444@item -fno-peephole
13445@itemx -fno-peephole2
13446@opindex fno-peephole
13447@opindex fpeephole
13448@opindex fno-peephole2
13449@opindex fpeephole2
13450Disable any machine-specific peephole optimizations. The difference
13451between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
13452are implemented in the compiler; some targets use one, some use the
13453other, a few use both.
13454
13455@option{-fpeephole} is enabled by default.
13456@option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13457
13458@item -fno-guess-branch-probability
13459@opindex fno-guess-branch-probability
13460@opindex fguess-branch-probability
13461Do not guess branch probabilities using heuristics.
13462
13463GCC uses heuristics to guess branch probabilities if they are
13464not provided by profiling feedback (@option{-fprofile-arcs}). These
13465heuristics are based on the control flow graph. If some branch probabilities
13466are specified by @code{__builtin_expect}, then the heuristics are
13467used to guess branch probabilities for the rest of the control flow graph,
13468taking the @code{__builtin_expect} info into account. The interactions
13469between the heuristics and @code{__builtin_expect} can be complex, and in
13470some cases, it may be useful to disable the heuristics so that the effects
13471of @code{__builtin_expect} are easier to understand.
13472
13473It is also possible to specify expected probability of the expression
13474with @code{__builtin_expect_with_probability} built-in function.
13475
13476The default is @option{-fguess-branch-probability} at levels
13477@option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
13478
13479@item -freorder-blocks
13480@opindex freorder-blocks
13481Reorder basic blocks in the compiled function in order to reduce number of
13482taken branches and improve code locality.
13483
13484Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13485
13486@item -freorder-blocks-algorithm=@var{algorithm}
13487@opindex freorder-blocks-algorithm
13488Use the specified algorithm for basic block reordering. The
13489@var{algorithm} argument can be @samp{simple}, which does not increase
13490code size (except sometimes due to secondary effects like alignment),
13491or @samp{stc}, the ``software trace cache'' algorithm, which tries to
13492put all often executed code together, minimizing the number of branches
13493executed by making extra copies of code.
13494
13495The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
13496@samp{stc} at levels @option{-O2}, @option{-O3}.
13497
13498@item -freorder-blocks-and-partition
13499@opindex freorder-blocks-and-partition
13500In addition to reordering basic blocks in the compiled function, in order
13501to reduce number of taken branches, partitions hot and cold basic blocks
13502into separate sections of the assembly and @file{.o} files, to improve
13503paging and cache locality performance.
13504
13505This optimization is automatically turned off in the presence of
13506exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
13507section attribute and on any architecture that does not support named
13508sections. When @option{-fsplit-stack} is used this option is not
13509enabled by default (to avoid linker errors), but may be enabled
13510explicitly (if using a working linker).
13511
13512Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
13513
13514@item -freorder-functions
13515@opindex freorder-functions
13516Reorder functions in the object file in order to
13517improve code locality. This is implemented by using special
13518subsections @code{.text.hot} for most frequently executed functions and
13519@code{.text.unlikely} for unlikely executed functions. Reordering is done by
13520the linker so object file format must support named sections and linker must
13521place them in a reasonable way.
13522
13523This option isn't effective unless you either provide profile feedback
13524(see @option{-fprofile-arcs} for details) or manually annotate functions with
13525@code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
13526
13527Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13528
13529@item -fstrict-aliasing
13530@opindex fstrict-aliasing
13531Allow the compiler to assume the strictest aliasing rules applicable to
13532the language being compiled. For C (and C++), this activates
13533optimizations based on the type of expressions. In particular, an
13534object of one type is assumed never to reside at the same address as an
13535object of a different type, unless the types are almost the same. For
13536example, an @code{unsigned int} can alias an @code{int}, but not a
13537@code{void*} or a @code{double}. A character type may alias any other
13538type.
13539
13540@anchor{Type-punning}Pay special attention to code like this:
13541@smallexample
13542union a_union @{
13543 int i;
13544 double d;
13545@};
13546
13547int f() @{
13548 union a_union t;
13549 t.d = 3.0;
13550 return t.i;
13551@}
13552@end smallexample
13553The practice of reading from a different union member than the one most
13554recently written to (called ``type-punning'') is common. Even with
13555@option{-fstrict-aliasing}, type-punning is allowed, provided the memory
13556is accessed through the union type. So, the code above works as
13557expected. @xref{Structures unions enumerations and bit-fields
13558implementation}. However, this code might not:
13559@smallexample
13560int f() @{
13561 union a_union t;
13562 int* ip;
13563 t.d = 3.0;
13564 ip = &t.i;
13565 return *ip;
13566@}
13567@end smallexample
13568
13569Similarly, access by taking the address, casting the resulting pointer
13570and dereferencing the result has undefined behavior, even if the cast
13571uses a union type, e.g.:
13572@smallexample
13573int f() @{
13574 double d = 3.0;
13575 return ((union a_union *) &d)->i;
13576@}
13577@end smallexample
13578
13579The @option{-fstrict-aliasing} option is enabled at levels
13580@option{-O2}, @option{-O3}, @option{-Os}.
13581
13582@item -fipa-strict-aliasing
13583@opindex fipa-strict-aliasing
13584Controls whether rules of @option{-fstrict-aliasing} are applied across
13585function boundaries. Note that if multiple functions gets inlined into a
13586single function the memory accesses are no longer considered to be crossing a
13587function boundary.
13588
13589The @option{-fipa-strict-aliasing} option is enabled by default and is
13590effective only in combination with @option{-fstrict-aliasing}.
13591
13592@item -falign-functions
13593@itemx -falign-functions=@var{n}
13594@itemx -falign-functions=@var{n}:@var{m}
13595@itemx -falign-functions=@var{n}:@var{m}:@var{n2}
13596@itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
13597@opindex falign-functions
13598Align the start of functions to the next power-of-two greater than or
13599equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
13600least the first @var{m} bytes of the function can be fetched by the CPU
13601without crossing an @var{n}-byte alignment boundary.
13602
13603If @var{m} is not specified, it defaults to @var{n}.
13604
13605Examples: @option{-falign-functions=32} aligns functions to the next
1360632-byte boundary, @option{-falign-functions=24} aligns to the next
1360732-byte boundary only if this can be done by skipping 23 bytes or less,
13608@option{-falign-functions=32:7} aligns to the next
1360932-byte boundary only if this can be done by skipping 6 bytes or less.
13610
13611The second pair of @var{n2}:@var{m2} values allows you to specify
13612a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
13613the next 64-byte boundary if this can be done by skipping 6 bytes or less,
13614otherwise aligns to the next 32-byte boundary if this can be done
13615by skipping 2 bytes or less.
13616If @var{m2} is not specified, it defaults to @var{n2}.
13617
13618Some assemblers only support this flag when @var{n} is a power of two;
13619in that case, it is rounded up.
13620
13621@option{-fno-align-functions} and @option{-falign-functions=1} are
13622equivalent and mean that functions are not aligned.
13623
13624If @var{n} is not specified or is zero, use a machine-dependent default.
13625The maximum allowed @var{n} option value is 65536.
13626
13627Enabled at levels @option{-O2}, @option{-O3}.
13628
13629@item -flimit-function-alignment
13630If this option is enabled, the compiler tries to avoid unnecessarily
13631overaligning functions. It attempts to instruct the assembler to align
13632by the amount specified by @option{-falign-functions}, but not to
13633skip more bytes than the size of the function.
13634
13635@item -falign-labels
13636@itemx -falign-labels=@var{n}
13637@itemx -falign-labels=@var{n}:@var{m}
13638@itemx -falign-labels=@var{n}:@var{m}:@var{n2}
13639@itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
13640@opindex falign-labels
13641Align all branch targets to a power-of-two boundary.
13642
13643Parameters of this option are analogous to the @option{-falign-functions} option.
13644@option{-fno-align-labels} and @option{-falign-labels=1} are
13645equivalent and mean that labels are not aligned.
13646
13647If @option{-falign-loops} or @option{-falign-jumps} are applicable and
13648are greater than this value, then their values are used instead.
13649
13650If @var{n} is not specified or is zero, use a machine-dependent default
13651which is very likely to be @samp{1}, meaning no alignment.
13652The maximum allowed @var{n} option value is 65536.
13653
13654Enabled at levels @option{-O2}, @option{-O3}.
13655
13656@item -falign-loops
13657@itemx -falign-loops=@var{n}
13658@itemx -falign-loops=@var{n}:@var{m}
13659@itemx -falign-loops=@var{n}:@var{m}:@var{n2}
13660@itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
13661@opindex falign-loops
13662Align loops to a power-of-two boundary. If the loops are executed
13663many times, this makes up for any execution of the dummy padding
13664instructions.
13665
13666If @option{-falign-labels} is greater than this value, then its value
13667is used instead.
13668
13669Parameters of this option are analogous to the @option{-falign-functions} option.
13670@option{-fno-align-loops} and @option{-falign-loops=1} are
13671equivalent and mean that loops are not aligned.
13672The maximum allowed @var{n} option value is 65536.
13673
13674If @var{n} is not specified or is zero, use a machine-dependent default.
13675
13676Enabled at levels @option{-O2}, @option{-O3}.
13677
13678@item -falign-jumps
13679@itemx -falign-jumps=@var{n}
13680@itemx -falign-jumps=@var{n}:@var{m}
13681@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
13682@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
13683@opindex falign-jumps
13684Align branch targets to a power-of-two boundary, for branch targets
13685where the targets can only be reached by jumping. In this case,
13686no dummy operations need be executed.
13687
13688If @option{-falign-labels} is greater than this value, then its value
13689is used instead.
13690
13691Parameters of this option are analogous to the @option{-falign-functions} option.
13692@option{-fno-align-jumps} and @option{-falign-jumps=1} are
13693equivalent and mean that loops are not aligned.
13694
13695If @var{n} is not specified or is zero, use a machine-dependent default.
13696The maximum allowed @var{n} option value is 65536.
13697
13698Enabled at levels @option{-O2}, @option{-O3}.
13699
13700@item -fno-allocation-dce
13701@opindex fno-allocation-dce
13702Do not remove unused C++ allocations in dead code elimination.
13703
13704@item -fallow-store-data-races
13705@opindex fallow-store-data-races
13706Allow the compiler to perform optimizations that may introduce new data races
13707on stores, without proving that the variable cannot be concurrently accessed
13708by other threads. Does not affect optimization of local data. It is safe to
13709use this option if it is known that global data will not be accessed by
13710multiple threads.
13711
13712Examples of optimizations enabled by @option{-fallow-store-data-races} include
13713hoisting or if-conversions that may cause a value that was already in memory
13714to be re-written with that same value. Such re-writing is safe in a single
13715threaded context but may be unsafe in a multi-threaded context. Note that on
13716some processors, if-conversions may be required in order to enable
13717vectorization.
13718
13719Enabled at level @option{-Ofast}.
13720
13721@item -funit-at-a-time
13722@opindex funit-at-a-time
13723This option is left for compatibility reasons. @option{-funit-at-a-time}
13724has no effect, while @option{-fno-unit-at-a-time} implies
13725@option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
13726
13727Enabled by default.
13728
13729@item -fno-toplevel-reorder
13730@opindex fno-toplevel-reorder
13731@opindex ftoplevel-reorder
13732Do not reorder top-level functions, variables, and @code{asm}
13733statements. Output them in the same order that they appear in the
13734input file. When this option is used, unreferenced static variables
13735are not removed. This option is intended to support existing code
13736that relies on a particular ordering. For new code, it is better to
13737use attributes when possible.
13738
13739@option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
13740also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
13741Additionally @option{-fno-toplevel-reorder} implies
13742@option{-fno-section-anchors}.
13743
13744@item -funreachable-traps
13745@opindex funreachable-traps
13746With this option, the compiler turns calls to
13747@code{__builtin_unreachable} into traps, instead of using them for
13748optimization. This also affects any such calls implicitly generated
13749by the compiler.
13750
13751This option has the same effect as @option{-fsanitize=unreachable
13752-fsanitize-trap=unreachable}, but does not affect the values of those
13753options. If @option{-fsanitize=unreachable} is enabled, that option
13754takes priority over this one.
13755
13756This option is enabled by default at @option{-O0} and @option{-Og}.
13757
13758@item -fweb
13759@opindex fweb
13760Constructs webs as commonly used for register allocation purposes and assign
13761each web individual pseudo register. This allows the register allocation pass
13762to operate on pseudos directly, but also strengthens several other optimization
13763passes, such as CSE, loop optimizer and trivial dead code remover. It can,
13764however, make debugging impossible, since variables no longer stay in a
13765``home register''.
13766
13767Enabled by default with @option{-funroll-loops}.
13768
13769@item -fwhole-program
13770@opindex fwhole-program
13771Assume that the current compilation unit represents the whole program being
13772compiled. All public functions and variables with the exception of @code{main}
13773and those merged by attribute @code{externally_visible} become static functions
13774and in effect are optimized more aggressively by interprocedural optimizers.
13775
39ebd3a9
JH
13776With @option{-flto} this option has a limited use. In most cases the
13777precise list of symbols used or exported from the binary is known the
13778resolution info passed to the link-time optimizer by the linker plugin. It is
13779still useful if no linker plugin is used or during incremental link step when
13780final code is produced (with @option{-flto}
13781@option{-flinker-output=nolto-rel}).
d77de738
ML
13782
13783@item -flto[=@var{n}]
13784@opindex flto
13785This option runs the standard link-time optimizer. When invoked
13786with source code, it generates GIMPLE (one of GCC's internal
13787representations) and writes it to special ELF sections in the object
13788file. When the object files are linked together, all the function
13789bodies are read from these ELF sections and instantiated as if they
13790had been part of the same translation unit.
13791
13792To use the link-time optimizer, @option{-flto} and optimization
13793options should be specified at compile time and during the final link.
13794It is recommended that you compile all the files participating in the
13795same link with the same options and also specify those options at
13796link time.
13797For example:
13798
13799@smallexample
13800gcc -c -O2 -flto foo.c
13801gcc -c -O2 -flto bar.c
13802gcc -o myprog -flto -O2 foo.o bar.o
13803@end smallexample
13804
13805The first two invocations to GCC save a bytecode representation
13806of GIMPLE into special ELF sections inside @file{foo.o} and
13807@file{bar.o}. The final invocation reads the GIMPLE bytecode from
13808@file{foo.o} and @file{bar.o}, merges the two files into a single
13809internal image, and compiles the result as usual. Since both
13810@file{foo.o} and @file{bar.o} are merged into a single image, this
13811causes all the interprocedural analyses and optimizations in GCC to
13812work across the two files as if they were a single one. This means,
13813for example, that the inliner is able to inline functions in
13814@file{bar.o} into functions in @file{foo.o} and vice-versa.
13815
13816Another (simpler) way to enable link-time optimization is:
13817
13818@smallexample
13819gcc -o myprog -flto -O2 foo.c bar.c
13820@end smallexample
13821
13822The above generates bytecode for @file{foo.c} and @file{bar.c},
13823merges them together into a single GIMPLE representation and optimizes
13824them as usual to produce @file{myprog}.
13825
13826The important thing to keep in mind is that to enable link-time
13827optimizations you need to use the GCC driver to perform the link step.
13828GCC automatically performs link-time optimization if any of the
13829objects involved were compiled with the @option{-flto} command-line option.
13830You can always override
13831the automatic decision to do link-time optimization
13832by passing @option{-fno-lto} to the link command.
13833
13834To make whole program optimization effective, it is necessary to make
13835certain whole program assumptions. The compiler needs to know
13836what functions and variables can be accessed by libraries and runtime
13837outside of the link-time optimized unit. When supported by the linker,
13838the linker plugin (see @option{-fuse-linker-plugin}) passes information
13839to the compiler about used and externally visible symbols. When
13840the linker plugin is not available, @option{-fwhole-program} should be
13841used to allow the compiler to make these assumptions, which leads
13842to more aggressive optimization decisions.
13843
13844When a file is compiled with @option{-flto} without
13845@option{-fuse-linker-plugin}, the generated object file is larger than
13846a regular object file because it contains GIMPLE bytecodes and the usual
13847final code (see @option{-ffat-lto-objects}). This means that
13848object files with LTO information can be linked as normal object
13849files; if @option{-fno-lto} is passed to the linker, no
13850interprocedural optimizations are applied. Note that when
13851@option{-fno-fat-lto-objects} is enabled the compile stage is faster
13852but you cannot perform a regular, non-LTO link on them.
13853
13854When producing the final binary, GCC only
13855applies link-time optimizations to those files that contain bytecode.
13856Therefore, you can mix and match object files and libraries with
13857GIMPLE bytecodes and final object code. GCC automatically selects
13858which files to optimize in LTO mode and which files to link without
13859further processing.
13860
13861Generally, options specified at link time override those
13862specified at compile time, although in some cases GCC attempts to infer
13863link-time options from the settings used to compile the input files.
13864
13865If you do not specify an optimization level option @option{-O} at
13866link time, then GCC uses the highest optimization level
13867used when compiling the object files. Note that it is generally
13868ineffective to specify an optimization level option only at link time and
13869not at compile time, for two reasons. First, compiling without
13870optimization suppresses compiler passes that gather information
13871needed for effective optimization at link time. Second, some early
13872optimization passes can be performed only at compile time and
13873not at link time.
13874
13875There are some code generation flags preserved by GCC when
13876generating bytecodes, as they need to be used during the final link.
13877Currently, the following options and their settings are taken from
13878the first object file that explicitly specifies them:
13879@option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
13880@option{-fgnu-tm} and all the @option{-m} target flags.
13881
13882The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
13883@option{-fPIE} are combined based on the following scheme:
13884
13885@smallexample
13886@option{-fPIC} + @option{-fpic} = @option{-fpic}
13887@option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
13888@option{-fpic/-fPIC} + (no option) = (no option)
13889@option{-fPIC} + @option{-fPIE} = @option{-fPIE}
13890@option{-fpic} + @option{-fPIE} = @option{-fpie}
13891@option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
13892@end smallexample
13893
13894Certain ABI-changing flags are required to match in all compilation units,
13895and trying to override this at link time with a conflicting value
13896is ignored. This includes options such as @option{-freg-struct-return}
13897and @option{-fpcc-struct-return}.
13898
13899Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
13900@option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
13901are passed through to the link stage and merged conservatively for
13902conflicting translation units. Specifically
13903@option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
13904precedence; and for example @option{-ffp-contract=off} takes precedence
13905over @option{-ffp-contract=fast}. You can override them at link time.
13906
13907Diagnostic options such as @option{-Wstringop-overflow} are passed
13908through to the link stage and their setting matches that of the
13909compile-step at function granularity. Note that this matters only
13910for diagnostics emitted during optimization. Note that code
13911transforms such as inlining can lead to warnings being enabled
13912or disabled for regions if code not consistent with the setting
13913at compile time.
13914
13915When you need to pass options to the assembler via @option{-Wa} or
13916@option{-Xassembler} make sure to either compile such translation
13917units with @option{-fno-lto} or consistently use the same assembler
13918options on all translation units. You can alternatively also
13919specify assembler options at LTO link time.
13920
13921To enable debug info generation you need to supply @option{-g} at
13922compile time. If any of the input files at link time were built
13923with debug info generation enabled the link will enable debug info
13924generation as well. Any elaborate debug info settings
13925like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
13926at the linker command line and mixing different settings in different
13927translation units is discouraged.
13928
13929If LTO encounters objects with C linkage declared with incompatible
13930types in separate translation units to be linked together (undefined
13931behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
13932issued. The behavior is still undefined at run time. Similar
13933diagnostics may be raised for other languages.
13934
13935Another feature of LTO is that it is possible to apply interprocedural
13936optimizations on files written in different languages:
13937
13938@smallexample
13939gcc -c -flto foo.c
13940g++ -c -flto bar.cc
13941gfortran -c -flto baz.f90
13942g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
13943@end smallexample
13944
13945Notice that the final link is done with @command{g++} to get the C++
13946runtime libraries and @option{-lgfortran} is added to get the Fortran
13947runtime libraries. In general, when mixing languages in LTO mode, you
13948should use the same link command options as when mixing languages in a
13949regular (non-LTO) compilation.
13950
13951If object files containing GIMPLE bytecode are stored in a library archive, say
13952@file{libfoo.a}, it is possible to extract and use them in an LTO link if you
13953are using a linker with plugin support. To create static libraries suitable
13954for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
13955and @command{ranlib};
13956to show the symbols of object files with GIMPLE bytecode, use
13957@command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
13958and @command{nm} have been compiled with plugin support. At link time, use the
13959flag @option{-fuse-linker-plugin} to ensure that the library participates in
13960the LTO optimization process:
13961
13962@smallexample
13963gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
13964@end smallexample
13965
13966With the linker plugin enabled, the linker extracts the needed
13967GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
13968to make them part of the aggregated GIMPLE image to be optimized.
13969
13970If you are not using a linker with plugin support and/or do not
13971enable the linker plugin, then the objects inside @file{libfoo.a}
13972are extracted and linked as usual, but they do not participate
13973in the LTO optimization process. In order to make a static library suitable
13974for both LTO optimization and usual linkage, compile its object files with
13975@option{-flto} @option{-ffat-lto-objects}.
13976
13977Link-time optimizations do not require the presence of the whole program to
13978operate. If the program does not require any symbols to be exported, it is
13979possible to combine @option{-flto} and @option{-fwhole-program} to allow
13980the interprocedural optimizers to use more aggressive assumptions which may
13981lead to improved optimization opportunities.
13982Use of @option{-fwhole-program} is not needed when linker plugin is
13983active (see @option{-fuse-linker-plugin}).
13984
13985The current implementation of LTO makes no
13986attempt to generate bytecode that is portable between different
13987types of hosts. The bytecode files are versioned and there is a
13988strict version check, so bytecode files generated in one version of
13989GCC do not work with an older or newer version of GCC.
13990
13991Link-time optimization does not work well with generation of debugging
13992information on systems other than those using a combination of ELF and
13993DWARF.
13994
13995If you specify the optional @var{n}, the optimization and code
13996generation done at link time is executed in parallel using @var{n}
13997parallel jobs by utilizing an installed @command{make} program. The
13998environment variable @env{MAKE} may be used to override the program
13999used.
14000
14001You can also specify @option{-flto=jobserver} to use GNU make's
14002job server mode to determine the number of parallel jobs. This
14003is useful when the Makefile calling GCC is already executing in parallel.
14004You must prepend a @samp{+} to the command recipe in the parent Makefile
14005for this to work. This option likely only works if @env{MAKE} is
14006GNU make. Even without the option value, GCC tries to automatically
14007detect a running GNU make's job server.
14008
14009Use @option{-flto=auto} to use GNU make's job server, if available,
14010or otherwise fall back to autodetection of the number of CPU threads
14011present in your system.
14012
14013@item -flto-partition=@var{alg}
14014@opindex flto-partition
14015Specify the partitioning algorithm used by the link-time optimizer.
14016The value is either @samp{1to1} to specify a partitioning mirroring
14017the original source files or @samp{balanced} to specify partitioning
14018into equally sized chunks (whenever possible) or @samp{max} to create
14019new partition for every symbol where possible. Specifying @samp{none}
14020as an algorithm disables partitioning and streaming completely.
14021The default value is @samp{balanced}. While @samp{1to1} can be used
14022as an workaround for various code ordering issues, the @samp{max}
14023partitioning is intended for internal testing only.
14024The value @samp{one} specifies that exactly one partition should be
14025used while the value @samp{none} bypasses partitioning and executes
14026the link-time optimization step directly from the WPA phase.
14027
14028@item -flto-compression-level=@var{n}
14029@opindex flto-compression-level
14030This option specifies the level of compression used for intermediate
14031language written to LTO object files, and is only meaningful in
14032conjunction with LTO mode (@option{-flto}). GCC currently supports two
14033LTO compression algorithms. For zstd, valid values are 0 (no compression)
14034to 19 (maximum compression), while zlib supports values from 0 to 9.
14035Values outside this range are clamped to either minimum or maximum
14036of the supported values. If the option is not given,
14037a default balanced compression setting is used.
14038
14039@item -fuse-linker-plugin
14040@opindex fuse-linker-plugin
14041Enables the use of a linker plugin during link-time optimization. This
14042option relies on plugin support in the linker, which is available in gold
14043or in GNU ld 2.21 or newer.
14044
14045This option enables the extraction of object files with GIMPLE bytecode out
14046of library archives. This improves the quality of optimization by exposing
14047more code to the link-time optimizer. This information specifies what
14048symbols can be accessed externally (by non-LTO object or during dynamic
14049linking). Resulting code quality improvements on binaries (and shared
14050libraries that use hidden visibility) are similar to @option{-fwhole-program}.
14051See @option{-flto} for a description of the effect of this flag and how to
14052use it.
14053
14054This option is enabled by default when LTO support in GCC is enabled
14055and GCC was configured for use with
14056a linker supporting plugins (GNU ld 2.21 or newer or gold).
14057
14058@item -ffat-lto-objects
14059@opindex ffat-lto-objects
14060Fat LTO objects are object files that contain both the intermediate language
14061and the object code. This makes them usable for both LTO linking and normal
14062linking. This option is effective only when compiling with @option{-flto}
14063and is ignored at link time.
14064
14065@option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
14066requires the complete toolchain to be aware of LTO. It requires a linker with
14067linker plugin support for basic functionality. Additionally,
14068@command{nm}, @command{ar} and @command{ranlib}
14069need to support linker plugins to allow a full-featured build environment
14070(capable of building static libraries etc). GCC provides the @command{gcc-ar},
14071@command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
14072to these tools. With non fat LTO makefiles need to be modified to use them.
14073
14074Note that modern binutils provide plugin auto-load mechanism.
14075Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
14076effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
14077@command{gcc-ranlib}).
14078
14079The default is @option{-fno-fat-lto-objects} on targets with linker plugin
14080support.
14081
14082@item -fcompare-elim
14083@opindex fcompare-elim
14084After register allocation and post-register allocation instruction splitting,
14085identify arithmetic instructions that compute processor flags similar to a
14086comparison operation based on that arithmetic. If possible, eliminate the
14087explicit comparison operation.
14088
14089This pass only applies to certain targets that cannot explicitly represent
14090the comparison operation before register allocation is complete.
14091
14092Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14093
14094@item -fcprop-registers
14095@opindex fcprop-registers
14096After register allocation and post-register allocation instruction splitting,
14097perform a copy-propagation pass to try to reduce scheduling dependencies
14098and occasionally eliminate the copy.
14099
14100Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14101
14102@item -fprofile-correction
14103@opindex fprofile-correction
14104Profiles collected using an instrumented binary for multi-threaded programs may
14105be inconsistent due to missed counter updates. When this option is specified,
14106GCC uses heuristics to correct or smooth out such inconsistencies. By
14107default, GCC emits an error message when an inconsistent profile is detected.
14108
14109This option is enabled by @option{-fauto-profile}.
14110
14111@item -fprofile-partial-training
14112@opindex fprofile-partial-training
14113With @code{-fprofile-use} all portions of programs not executed during train
14114run are optimized agressively for size rather than speed. In some cases it is
14115not practical to train all possible hot paths in the program. (For
14116example, program may contain functions specific for a given hardware and
14117trianing may not cover all hardware configurations program is run on.) With
14118@code{-fprofile-partial-training} profile feedback will be ignored for all
14119functions not executed during the train run leading them to be optimized as if
14120they were compiled without profile feedback. This leads to better performance
14121when train run is not representative but also leads to significantly bigger
14122code.
14123
14124@item -fprofile-use
14125@itemx -fprofile-use=@var{path}
14126@opindex fprofile-use
14127Enable profile feedback-directed optimizations,
14128and the following optimizations, many of which
14129are generally profitable only with profile feedback available:
14130
14131@gccoptlist{-fbranch-probabilities -fprofile-values @gol
14132-funroll-loops -fpeel-loops -ftracer -fvpt @gol
14133-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp @gol
14134-fpredictive-commoning -fsplit-loops -funswitch-loops @gol
14135-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize @gol
14136-fvect-cost-model=dynamic -ftree-loop-distribute-patterns @gol
14137-fprofile-reorder-functions}
14138
14139Before you can use this option, you must first generate profiling information.
14140@xref{Instrumentation Options}, for information about the
14141@option{-fprofile-generate} option.
14142
14143By default, GCC emits an error message if the feedback profiles do not
14144match the source code. This error can be turned into a warning by using
14145@option{-Wno-error=coverage-mismatch}. Note this may result in poorly
14146optimized code. Additionally, by default, GCC also emits a warning message if
14147the feedback profiles do not exist (see @option{-Wmissing-profile}).
14148
14149If @var{path} is specified, GCC looks at the @var{path} to find
14150the profile feedback data files. See @option{-fprofile-dir}.
14151
14152@item -fauto-profile
14153@itemx -fauto-profile=@var{path}
14154@opindex fauto-profile
14155Enable sampling-based feedback-directed optimizations,
14156and the following optimizations,
14157many of which are generally profitable only with profile feedback available:
14158
14159@gccoptlist{-fbranch-probabilities -fprofile-values @gol
14160-funroll-loops -fpeel-loops -ftracer -fvpt @gol
14161-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp @gol
14162-fpredictive-commoning -fsplit-loops -funswitch-loops @gol
14163-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize @gol
14164-fvect-cost-model=dynamic -ftree-loop-distribute-patterns @gol
14165-fprofile-correction}
14166
14167@var{path} is the name of a file containing AutoFDO profile information.
14168If omitted, it defaults to @file{fbdata.afdo} in the current directory.
14169
14170Producing an AutoFDO profile data file requires running your program
14171with the @command{perf} utility on a supported GNU/Linux target system.
14172For more information, see @uref{https://perf.wiki.kernel.org/}.
14173
14174E.g.
14175@smallexample
14176perf record -e br_inst_retired:near_taken -b -o perf.data \
14177 -- your_program
14178@end smallexample
14179
14180Then use the @command{create_gcov} tool to convert the raw profile data
14181to a format that can be used by GCC.@ You must also supply the
14182unstripped binary for your program to this tool.
14183See @uref{https://github.com/google/autofdo}.
14184
14185E.g.
14186@smallexample
14187create_gcov --binary=your_program.unstripped --profile=perf.data \
14188 --gcov=profile.afdo
14189@end smallexample
14190@end table
14191
14192The following options control compiler behavior regarding floating-point
14193arithmetic. These options trade off between speed and
14194correctness. All must be specifically enabled.
14195
14196@table @gcctabopt
14197@item -ffloat-store
14198@opindex ffloat-store
14199Do not store floating-point variables in registers, and inhibit other
14200options that might change whether a floating-point value is taken from a
14201register or memory.
14202
14203@cindex floating-point precision
14204This option prevents undesirable excess precision on machines such as
14205the 68000 where the floating registers (of the 68881) keep more
14206precision than a @code{double} is supposed to have. Similarly for the
14207x86 architecture. For most programs, the excess precision does only
14208good, but a few programs rely on the precise definition of IEEE floating
14209point. Use @option{-ffloat-store} for such programs, after modifying
14210them to store all pertinent intermediate computations into variables.
14211
14212@item -fexcess-precision=@var{style}
14213@opindex fexcess-precision
14214This option allows further control over excess precision on machines
14215where floating-point operations occur in a format with more precision or
14216range than the IEEE standard and interchange floating-point types. By
14217default, @option{-fexcess-precision=fast} is in effect; this means that
14218operations may be carried out in a wider precision than the types specified
14219in the source if that would result in faster code, and it is unpredictable
14220when rounding to the types specified in the source code takes place.
14221When compiling C or C++, if @option{-fexcess-precision=standard} is specified
14222then excess precision follows the rules specified in ISO C99 or C++; in particular,
14223both casts and assignments cause values to be rounded to their
14224semantic types (whereas @option{-ffloat-store} only affects
14225assignments). This option is enabled by default for C or C++ if a strict
14226conformance option such as @option{-std=c99} or @option{-std=c++17} is used.
14227@option{-ffast-math} enables @option{-fexcess-precision=fast} by default
14228regardless of whether a strict conformance option is used.
14229
14230@opindex mfpmath
14231@option{-fexcess-precision=standard} is not implemented for languages
14232other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse}
14233or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
14234semantics apply without excess precision, and in the latter, rounding
14235is unpredictable.
14236
14237@item -ffast-math
14238@opindex ffast-math
14239Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
14240@option{-ffinite-math-only}, @option{-fno-rounding-math},
14241@option{-fno-signaling-nans}, @option{-fcx-limited-range} and
14242@option{-fexcess-precision=fast}.
14243
14244This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
14245
14246This option is not turned on by any @option{-O} option besides
14247@option{-Ofast} since it can result in incorrect output for programs
14248that depend on an exact implementation of IEEE or ISO rules/specifications
14249for math functions. It may, however, yield faster code for programs
14250that do not require the guarantees of these specifications.
14251
14252@item -fno-math-errno
14253@opindex fno-math-errno
14254@opindex fmath-errno
14255Do not set @code{errno} after calling math functions that are executed
14256with a single instruction, e.g., @code{sqrt}. A program that relies on
14257IEEE exceptions for math error handling may want to use this flag
14258for speed while maintaining IEEE arithmetic compatibility.
14259
14260This option is not turned on by any @option{-O} option since
14261it can result in incorrect output for programs that depend on
14262an exact implementation of IEEE or ISO rules/specifications for
14263math functions. It may, however, yield faster code for programs
14264that do not require the guarantees of these specifications.
14265
14266The default is @option{-fmath-errno}.
14267
14268On Darwin systems, the math library never sets @code{errno}. There is
14269therefore no reason for the compiler to consider the possibility that
14270it might, and @option{-fno-math-errno} is the default.
14271
14272@item -funsafe-math-optimizations
14273@opindex funsafe-math-optimizations
14274
14275Allow optimizations for floating-point arithmetic that (a) assume
14276that arguments and results are valid and (b) may violate IEEE or
14277ANSI standards. When used at link time, it may include libraries
14278or startup files that change the default FPU control word or other
14279similar optimizations.
14280
14281This option is not turned on by any @option{-O} option since
14282it can result in incorrect output for programs that depend on
14283an exact implementation of IEEE or ISO rules/specifications for
14284math functions. It may, however, yield faster code for programs
14285that do not require the guarantees of these specifications.
14286Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
14287@option{-fassociative-math} and @option{-freciprocal-math}.
14288
14289The default is @option{-fno-unsafe-math-optimizations}.
14290
14291@item -fassociative-math
14292@opindex fassociative-math
14293
14294Allow re-association of operands in series of floating-point operations.
14295This violates the ISO C and C++ language standard by possibly changing
14296computation result. NOTE: re-ordering may change the sign of zero as
14297well as ignore NaNs and inhibit or create underflow or overflow (and
14298thus cannot be used on code that relies on rounding behavior like
14299@code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
14300and thus may not be used when ordered comparisons are required.
14301This option requires that both @option{-fno-signed-zeros} and
14302@option{-fno-trapping-math} be in effect. Moreover, it doesn't make
14303much sense with @option{-frounding-math}. For Fortran the option
14304is automatically enabled when both @option{-fno-signed-zeros} and
14305@option{-fno-trapping-math} are in effect.
14306
14307The default is @option{-fno-associative-math}.
14308
14309@item -freciprocal-math
14310@opindex freciprocal-math
14311
14312Allow the reciprocal of a value to be used instead of dividing by
14313the value if this enables optimizations. For example @code{x / y}
14314can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
14315is subject to common subexpression elimination. Note that this loses
14316precision and increases the number of flops operating on the value.
14317
14318The default is @option{-fno-reciprocal-math}.
14319
14320@item -ffinite-math-only
14321@opindex ffinite-math-only
14322Allow optimizations for floating-point arithmetic that assume
14323that arguments and results are not NaNs or +-Infs.
14324
14325This option is not turned on by any @option{-O} option since
14326it can result in incorrect output for programs that depend on
14327an exact implementation of IEEE or ISO rules/specifications for
14328math functions. It may, however, yield faster code for programs
14329that do not require the guarantees of these specifications.
14330
14331The default is @option{-fno-finite-math-only}.
14332
14333@item -fno-signed-zeros
14334@opindex fno-signed-zeros
14335@opindex fsigned-zeros
14336Allow optimizations for floating-point arithmetic that ignore the
14337signedness of zero. IEEE arithmetic specifies the behavior of
14338distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
14339of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
14340This option implies that the sign of a zero result isn't significant.
14341
14342The default is @option{-fsigned-zeros}.
14343
14344@item -fno-trapping-math
14345@opindex fno-trapping-math
14346@opindex ftrapping-math
14347Compile code assuming that floating-point operations cannot generate
14348user-visible traps. These traps include division by zero, overflow,
14349underflow, inexact result and invalid operation. This option requires
14350that @option{-fno-signaling-nans} be in effect. Setting this option may
14351allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
14352
14353This option should never be turned on by any @option{-O} option since
14354it can result in incorrect output for programs that depend on
14355an exact implementation of IEEE or ISO rules/specifications for
14356math functions.
14357
14358The default is @option{-ftrapping-math}.
14359
14360Future versions of GCC may provide finer control of this setting
14361using C99's @code{FENV_ACCESS} pragma. This command-line option
14362will be used along with @option{-frounding-math} to specify the
14363default state for @code{FENV_ACCESS}.
14364
14365@item -frounding-math
14366@opindex frounding-math
14367Disable transformations and optimizations that assume default floating-point
14368rounding behavior. This is round-to-zero for all floating point
14369to integer conversions, and round-to-nearest for all other arithmetic
14370truncations. This option should be specified for programs that change
14371the FP rounding mode dynamically, or that may be executed with a
14372non-default rounding mode. This option disables constant folding of
14373floating-point expressions at compile time (which may be affected by
14374rounding mode) and arithmetic transformations that are unsafe in the
14375presence of sign-dependent rounding modes.
14376
14377The default is @option{-fno-rounding-math}.
14378
14379This option is experimental and does not currently guarantee to
14380disable all GCC optimizations that are affected by rounding mode.
14381Future versions of GCC may provide finer control of this setting
14382using C99's @code{FENV_ACCESS} pragma. This command-line option
14383will be used along with @option{-ftrapping-math} to specify the
14384default state for @code{FENV_ACCESS}.
14385
14386@item -fsignaling-nans
14387@opindex fsignaling-nans
14388Compile code assuming that IEEE signaling NaNs may generate user-visible
14389traps during floating-point operations. Setting this option disables
14390optimizations that may change the number of exceptions visible with
14391signaling NaNs. This option implies @option{-ftrapping-math}.
14392
14393This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
14394be defined.
14395
14396The default is @option{-fno-signaling-nans}.
14397
14398This option is experimental and does not currently guarantee to
14399disable all GCC optimizations that affect signaling NaN behavior.
14400
14401@item -fno-fp-int-builtin-inexact
14402@opindex fno-fp-int-builtin-inexact
14403@opindex ffp-int-builtin-inexact
14404Do not allow the built-in functions @code{ceil}, @code{floor},
14405@code{round} and @code{trunc}, and their @code{float} and @code{long
14406double} variants, to generate code that raises the ``inexact''
14407floating-point exception for noninteger arguments. ISO C99 and C11
14408allow these functions to raise the ``inexact'' exception, but ISO/IEC
14409TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
14410ISO C2X, does not allow these functions to do so.
14411
14412The default is @option{-ffp-int-builtin-inexact}, allowing the
14413exception to be raised, unless C2X or a later C standard is selected.
14414This option does nothing unless @option{-ftrapping-math} is in effect.
14415
14416Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
14417generate a call to a library function then the ``inexact'' exception
14418may be raised if the library implementation does not follow TS 18661.
14419
14420@item -fsingle-precision-constant
14421@opindex fsingle-precision-constant
14422Treat floating-point constants as single precision instead of
14423implicitly converting them to double-precision constants.
14424
14425@item -fcx-limited-range
14426@opindex fcx-limited-range
14427When enabled, this option states that a range reduction step is not
14428needed when performing complex division. Also, there is no checking
14429whether the result of a complex multiplication or division is @code{NaN
14430+ I*NaN}, with an attempt to rescue the situation in that case. The
14431default is @option{-fno-cx-limited-range}, but is enabled by
14432@option{-ffast-math}.
14433
14434This option controls the default setting of the ISO C99
14435@code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
14436all languages.
14437
14438@item -fcx-fortran-rules
14439@opindex fcx-fortran-rules
14440Complex multiplication and division follow Fortran rules. Range
14441reduction is done as part of complex division, but there is no checking
14442whether the result of a complex multiplication or division is @code{NaN
14443+ I*NaN}, with an attempt to rescue the situation in that case.
14444
14445The default is @option{-fno-cx-fortran-rules}.
14446
14447@end table
14448
14449The following options control optimizations that may improve
14450performance, but are not enabled by any @option{-O} options. This
14451section includes experimental options that may produce broken code.
14452
14453@table @gcctabopt
14454@item -fbranch-probabilities
14455@opindex fbranch-probabilities
14456After running a program compiled with @option{-fprofile-arcs}
14457(@pxref{Instrumentation Options}),
14458you can compile it a second time using
14459@option{-fbranch-probabilities}, to improve optimizations based on
14460the number of times each branch was taken. When a program
14461compiled with @option{-fprofile-arcs} exits, it saves arc execution
14462counts to a file called @file{@var{sourcename}.gcda} for each source
14463file. The information in this data file is very dependent on the
14464structure of the generated code, so you must use the same source code
14465and the same optimization options for both compilations.
14466See details about the file naming in @option{-fprofile-arcs}.
14467
14468With @option{-fbranch-probabilities}, GCC puts a
14469@samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
14470These can be used to improve optimization. Currently, they are only
14471used in one place: in @file{reorg.cc}, instead of guessing which path a
14472branch is most likely to take, the @samp{REG_BR_PROB} values are used to
14473exactly determine which path is taken more often.
14474
14475Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14476
14477@item -fprofile-values
14478@opindex fprofile-values
14479If combined with @option{-fprofile-arcs}, it adds code so that some
14480data about values of expressions in the program is gathered.
14481
14482With @option{-fbranch-probabilities}, it reads back the data gathered
14483from profiling values of expressions for usage in optimizations.
14484
14485Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
14486@option{-fauto-profile}.
14487
14488@item -fprofile-reorder-functions
14489@opindex fprofile-reorder-functions
14490Function reordering based on profile instrumentation collects
14491first time of execution of a function and orders these functions
14492in ascending order.
14493
14494Enabled with @option{-fprofile-use}.
14495
14496@item -fvpt
14497@opindex fvpt
14498If combined with @option{-fprofile-arcs}, this option instructs the compiler
14499to add code to gather information about values of expressions.
14500
14501With @option{-fbranch-probabilities}, it reads back the data gathered
14502and actually performs the optimizations based on them.
14503Currently the optimizations include specialization of division operations
14504using the knowledge about the value of the denominator.
14505
14506Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
14507
14508@item -frename-registers
14509@opindex frename-registers
14510Attempt to avoid false dependencies in scheduled code by making use
14511of registers left over after register allocation. This optimization
14512most benefits processors with lots of registers. Depending on the
14513debug information format adopted by the target, however, it can
14514make debugging impossible, since variables no longer stay in
14515a ``home register''.
14516
14517Enabled by default with @option{-funroll-loops}.
14518
14519@item -fschedule-fusion
14520@opindex fschedule-fusion
14521Performs a target dependent pass over the instruction stream to schedule
14522instructions of same type together because target machine can execute them
14523more efficiently if they are adjacent to each other in the instruction flow.
14524
14525Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14526
14527@item -ftracer
14528@opindex ftracer
14529Perform tail duplication to enlarge superblock size. This transformation
14530simplifies the control flow of the function allowing other optimizations to do
14531a better job.
14532
14533Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14534
14535@item -funroll-loops
14536@opindex funroll-loops
14537Unroll loops whose number of iterations can be determined at compile time or
14538upon entry to the loop. @option{-funroll-loops} implies
14539@option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
14540It also turns on complete loop peeling (i.e.@: complete removal of loops with
14541a small constant number of iterations). This option makes code larger, and may
14542or may not make it run faster.
14543
14544Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14545
14546@item -funroll-all-loops
14547@opindex funroll-all-loops
14548Unroll all loops, even if their number of iterations is uncertain when
14549the loop is entered. This usually makes programs run more slowly.
14550@option{-funroll-all-loops} implies the same options as
14551@option{-funroll-loops}.
14552
14553@item -fpeel-loops
14554@opindex fpeel-loops
14555Peels loops for which there is enough information that they do not
14556roll much (from profile feedback or static analysis). It also turns on
14557complete loop peeling (i.e.@: complete removal of loops with small constant
14558number of iterations).
14559
14560Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
14561
14562@item -fmove-loop-invariants
14563@opindex fmove-loop-invariants
14564Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
14565at level @option{-O1} and higher, except for @option{-Og}.
14566
14567@item -fmove-loop-stores
14568@opindex fmove-loop-stores
14569Enables the loop store motion pass in the GIMPLE loop optimizer. This
14570moves invariant stores to after the end of the loop in exchange for
14571carrying the stored value in a register across the iteration.
14572Note for this option to have an effect @option{-ftree-loop-im} has to
14573be enabled as well. Enabled at level @option{-O1} and higher, except
14574for @option{-Og}.
14575
14576@item -fsplit-loops
14577@opindex fsplit-loops
14578Split a loop into two if it contains a condition that's always true
14579for one side of the iteration space and false for the other.
14580
14581Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14582
14583@item -funswitch-loops
14584@opindex funswitch-loops
14585Move branches with loop invariant conditions out of the loop, with duplicates
14586of the loop on both branches (modified according to result of the condition).
14587
14588Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14589
14590@item -fversion-loops-for-strides
14591@opindex fversion-loops-for-strides
14592If a loop iterates over an array with a variable stride, create another
14593version of the loop that assumes the stride is always one. For example:
14594
14595@smallexample
14596for (int i = 0; i < n; ++i)
14597 x[i * stride] = @dots{};
14598@end smallexample
14599
14600becomes:
14601
14602@smallexample
14603if (stride == 1)
14604 for (int i = 0; i < n; ++i)
14605 x[i] = @dots{};
14606else
14607 for (int i = 0; i < n; ++i)
14608 x[i * stride] = @dots{};
14609@end smallexample
14610
14611This is particularly useful for assumed-shape arrays in Fortran where
14612(for example) it allows better vectorization assuming contiguous accesses.
14613This flag is enabled by default at @option{-O3}.
14614It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14615
14616@item -ffunction-sections
14617@itemx -fdata-sections
14618@opindex ffunction-sections
14619@opindex fdata-sections
14620Place each function or data item into its own section in the output
14621file if the target supports arbitrary sections. The name of the
14622function or the name of the data item determines the section's name
14623in the output file.
14624
14625Use these options on systems where the linker can perform optimizations to
14626improve locality of reference in the instruction space. Most systems using the
14627ELF object format have linkers with such optimizations. On AIX, the linker
14628rearranges sections (CSECTs) based on the call graph. The performance impact
14629varies.
14630
14631Together with a linker garbage collection (linker @option{--gc-sections}
14632option) these options may lead to smaller statically-linked executables (after
14633stripping).
14634
14635On ELF/DWARF systems these options do not degenerate the quality of the debug
14636information. There could be issues with other object files/debug info formats.
14637
14638Only use these options when there are significant benefits from doing so. When
14639you specify these options, the assembler and linker create larger object and
14640executable files and are also slower. These options affect code generation.
14641They prevent optimizations by the compiler and assembler using relative
14642locations inside a translation unit since the locations are unknown until
14643link time. An example of such an optimization is relaxing calls to short call
14644instructions.
14645
14646@item -fstdarg-opt
14647@opindex fstdarg-opt
14648Optimize the prologue of variadic argument functions with respect to usage of
14649those arguments.
14650
14651@item -fsection-anchors
14652@opindex fsection-anchors
14653Try to reduce the number of symbolic address calculations by using
14654shared ``anchor'' symbols to address nearby objects. This transformation
14655can help to reduce the number of GOT entries and GOT accesses on some
14656targets.
14657
14658For example, the implementation of the following function @code{foo}:
14659
14660@smallexample
14661static int a, b, c;
14662int foo (void) @{ return a + b + c; @}
14663@end smallexample
14664
14665@noindent
14666usually calculates the addresses of all three variables, but if you
14667compile it with @option{-fsection-anchors}, it accesses the variables
14668from a common anchor point instead. The effect is similar to the
14669following pseudocode (which isn't valid C):
14670
14671@smallexample
14672int foo (void)
14673@{
14674 register int *xr = &x;
14675 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
14676@}
14677@end smallexample
14678
14679Not all targets support this option.
14680
14681@item -fzero-call-used-regs=@var{choice}
14682@opindex fzero-call-used-regs
14683Zero call-used registers at function return to increase program
14684security by either mitigating Return-Oriented Programming (ROP)
14685attacks or preventing information leakage through registers.
14686
14687The possible values of @var{choice} are the same as for the
14688@code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
14689The default is @samp{skip}.
14690
14691You can control this behavior for a specific function by using the function
14692attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
14693
14694@item --param @var{name}=@var{value}
14695@opindex param
14696In some places, GCC uses various constants to control the amount of
14697optimization that is done. For example, GCC does not inline functions
14698that contain more than a certain number of instructions. You can
14699control some of these constants on the command line using the
14700@option{--param} option.
14701
14702The names of specific parameters, and the meaning of the values, are
14703tied to the internals of the compiler, and are subject to change
14704without notice in future releases.
14705
c381327d
GP
14706In order to get the minimal, maximal and default values of a parameter,
14707use the @option{--help=param -Q} options.
d77de738
ML
14708
14709In each case, the @var{value} is an integer. The following choices
14710of @var{name} are recognized for all targets:
14711
14712@table @gcctabopt
14713@item predictable-branch-outcome
14714When branch is predicted to be taken with probability lower than this threshold
14715(in percent), then it is considered well predictable.
14716
14717@item max-rtl-if-conversion-insns
14718RTL if-conversion tries to remove conditional branches around a block and
14719replace them with conditionally executed instructions. This parameter
14720gives the maximum number of instructions in a block which should be
14721considered for if-conversion. The compiler will
14722also use other heuristics to decide whether if-conversion is likely to be
14723profitable.
14724
14725@item max-rtl-if-conversion-predictable-cost
14726RTL if-conversion will try to remove conditional branches around a block
14727and replace them with conditionally executed instructions. These parameters
14728give the maximum permissible cost for the sequence that would be generated
14729by if-conversion depending on whether the branch is statically determined
14730to be predictable or not. The units for this parameter are the same as
14731those for the GCC internal seq_cost metric. The compiler will try to
14732provide a reasonable default for this parameter using the BRANCH_COST
14733target macro.
14734
14735@item max-crossjump-edges
14736The maximum number of incoming edges to consider for cross-jumping.
14737The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
14738the number of edges incoming to each block. Increasing values mean
14739more aggressive optimization, making the compilation time increase with
14740probably small improvement in executable size.
14741
14742@item min-crossjump-insns
14743The minimum number of instructions that must be matched at the end
14744of two blocks before cross-jumping is performed on them. This
14745value is ignored in the case where all instructions in the block being
14746cross-jumped from are matched.
14747
14748@item max-grow-copy-bb-insns
14749The maximum code size expansion factor when copying basic blocks
14750instead of jumping. The expansion is relative to a jump instruction.
14751
14752@item max-goto-duplication-insns
14753The maximum number of instructions to duplicate to a block that jumps
14754to a computed goto. To avoid @math{O(N^2)} behavior in a number of
14755passes, GCC factors computed gotos early in the compilation process,
14756and unfactors them as late as possible. Only computed jumps at the
14757end of a basic blocks with no more than max-goto-duplication-insns are
14758unfactored.
14759
14760@item max-delay-slot-insn-search
14761The maximum number of instructions to consider when looking for an
14762instruction to fill a delay slot. If more than this arbitrary number of
14763instructions are searched, the time savings from filling the delay slot
14764are minimal, so stop searching. Increasing values mean more
14765aggressive optimization, making the compilation time increase with probably
14766small improvement in execution time.
14767
14768@item max-delay-slot-live-search
14769When trying to fill delay slots, the maximum number of instructions to
14770consider when searching for a block with valid live register
14771information. Increasing this arbitrarily chosen value means more
14772aggressive optimization, increasing the compilation time. This parameter
14773should be removed when the delay slot code is rewritten to maintain the
14774control-flow graph.
14775
14776@item max-gcse-memory
14777The approximate maximum amount of memory in @code{kB} that can be allocated in
14778order to perform the global common subexpression elimination
14779optimization. If more memory than specified is required, the
14780optimization is not done.
14781
14782@item max-gcse-insertion-ratio
14783If the ratio of expression insertions to deletions is larger than this value
14784for any expression, then RTL PRE inserts or removes the expression and thus
14785leaves partially redundant computations in the instruction stream.
14786
14787@item max-pending-list-length
14788The maximum number of pending dependencies scheduling allows
14789before flushing the current state and starting over. Large functions
14790with few branches or calls can create excessively large lists which
14791needlessly consume memory and resources.
14792
14793@item max-modulo-backtrack-attempts
14794The maximum number of backtrack attempts the scheduler should make
14795when modulo scheduling a loop. Larger values can exponentially increase
14796compilation time.
14797
14798@item max-inline-functions-called-once-loop-depth
14799Maximal loop depth of a call considered by inline heuristics that tries to
14800inline all functions called once.
14801
14802@item max-inline-functions-called-once-insns
14803Maximal estimated size of functions produced while inlining functions called
14804once.
14805
14806@item max-inline-insns-single
14807Several parameters control the tree inliner used in GCC@. This number sets the
14808maximum number of instructions (counted in GCC's internal representation) in a
14809single function that the tree inliner considers for inlining. This only
14810affects functions declared inline and methods implemented in a class
14811declaration (C++).
14812
14813
14814@item max-inline-insns-auto
14815When you use @option{-finline-functions} (included in @option{-O3}),
14816a lot of functions that would otherwise not be considered for inlining
14817by the compiler are investigated. To those functions, a different
14818(more restrictive) limit compared to functions declared inline can
14819be applied (@option{--param max-inline-insns-auto}).
14820
14821@item max-inline-insns-small
14822This is bound applied to calls which are considered relevant with
14823@option{-finline-small-functions}.
14824
14825@item max-inline-insns-size
14826This is bound applied to calls which are optimized for size. Small growth
14827may be desirable to anticipate optimization oppurtunities exposed by inlining.
14828
14829@item uninlined-function-insns
14830Number of instructions accounted by inliner for function overhead such as
14831function prologue and epilogue.
14832
14833@item uninlined-function-time
14834Extra time accounted by inliner for function overhead such as time needed to
14835execute function prologue and epilogue.
14836
14837@item inline-heuristics-hint-percent
14838The scale (in percents) applied to @option{inline-insns-single},
14839@option{inline-insns-single-O2}, @option{inline-insns-auto}
14840when inline heuristics hints that inlining is
14841very profitable (will enable later optimizations).
14842
14843@item uninlined-thunk-insns
14844@item uninlined-thunk-time
14845Same as @option{--param uninlined-function-insns} and
14846@option{--param uninlined-function-time} but applied to function thunks.
14847
14848@item inline-min-speedup
14849When estimated performance improvement of caller + callee runtime exceeds this
14850threshold (in percent), the function can be inlined regardless of the limit on
14851@option{--param max-inline-insns-single} and @option{--param
14852max-inline-insns-auto}.
14853
14854@item large-function-insns
14855The limit specifying really large functions. For functions larger than this
14856limit after inlining, inlining is constrained by
14857@option{--param large-function-growth}. This parameter is useful primarily
14858to avoid extreme compilation time caused by non-linear algorithms used by the
14859back end.
14860
14861@item large-function-growth
14862Specifies maximal growth of large function caused by inlining in percents.
14863For example, parameter value 100 limits large function growth to 2.0 times
14864the original size.
14865
14866@item large-unit-insns
14867The limit specifying large translation unit. Growth caused by inlining of
14868units larger than this limit is limited by @option{--param inline-unit-growth}.
14869For small units this might be too tight.
14870For example, consider a unit consisting of function A
14871that is inline and B that just calls A three times. If B is small relative to
14872A, the growth of unit is 300\% and yet such inlining is very sane. For very
14873large units consisting of small inlineable functions, however, the overall unit
14874growth limit is needed to avoid exponential explosion of code size. Thus for
14875smaller units, the size is increased to @option{--param large-unit-insns}
14876before applying @option{--param inline-unit-growth}.
14877
14878@item lazy-modules
14879Maximum number of concurrently open C++ module files when lazy loading.
14880
14881@item inline-unit-growth
14882Specifies maximal overall growth of the compilation unit caused by inlining.
14883For example, parameter value 20 limits unit growth to 1.2 times the original
14884size. Cold functions (either marked cold via an attribute or by profile
14885feedback) are not accounted into the unit size.
14886
14887@item ipa-cp-unit-growth
14888Specifies maximal overall growth of the compilation unit caused by
14889interprocedural constant propagation. For example, parameter value 10 limits
14890unit growth to 1.1 times the original size.
14891
14892@item ipa-cp-large-unit-insns
14893The size of translation unit that IPA-CP pass considers large.
14894
14895@item large-stack-frame
14896The limit specifying large stack frames. While inlining the algorithm is trying
14897to not grow past this limit too much.
14898
14899@item large-stack-frame-growth
14900Specifies maximal growth of large stack frames caused by inlining in percents.
14901For example, parameter value 1000 limits large stack frame growth to 11 times
14902the original size.
14903
14904@item max-inline-insns-recursive
14905@itemx max-inline-insns-recursive-auto
14906Specifies the maximum number of instructions an out-of-line copy of a
14907self-recursive inline
14908function can grow into by performing recursive inlining.
14909
14910@option{--param max-inline-insns-recursive} applies to functions
14911declared inline.
14912For functions not declared inline, recursive inlining
14913happens only when @option{-finline-functions} (included in @option{-O3}) is
14914enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
14915
14916@item max-inline-recursive-depth
14917@itemx max-inline-recursive-depth-auto
14918Specifies the maximum recursion depth used for recursive inlining.
14919
14920@option{--param max-inline-recursive-depth} applies to functions
14921declared inline. For functions not declared inline, recursive inlining
14922happens only when @option{-finline-functions} (included in @option{-O3}) is
14923enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
14924
14925@item min-inline-recursive-probability
14926Recursive inlining is profitable only for function having deep recursion
14927in average and can hurt for function having little recursion depth by
14928increasing the prologue size or complexity of function body to other
14929optimizers.
14930
14931When profile feedback is available (see @option{-fprofile-generate}) the actual
14932recursion depth can be guessed from the probability that function recurses
14933via a given call expression. This parameter limits inlining only to call
14934expressions whose probability exceeds the given threshold (in percents).
14935
14936@item early-inlining-insns
14937Specify growth that the early inliner can make. In effect it increases
14938the amount of inlining for code having a large abstraction penalty.
14939
14940@item max-early-inliner-iterations
14941Limit of iterations of the early inliner. This basically bounds
14942the number of nested indirect calls the early inliner can resolve.
14943Deeper chains are still handled by late inlining.
14944
14945@item comdat-sharing-probability
14946Probability (in percent) that C++ inline function with comdat visibility
14947are shared across multiple compilation units.
14948
14949@item modref-max-bases
14950@item modref-max-refs
14951@item modref-max-accesses
14952Specifies the maximal number of base pointers, references and accesses stored
14953for a single function by mod/ref analysis.
14954
14955@item modref-max-tests
14956Specifies the maxmal number of tests alias oracle can perform to disambiguate
14957memory locations using the mod/ref information. This parameter ought to be
14958bigger than @option{--param modref-max-bases} and @option{--param
14959modref-max-refs}.
14960
14961@item modref-max-depth
14962Specifies the maximum depth of DFS walk used by modref escape analysis.
14963Setting to 0 disables the analysis completely.
14964
14965@item modref-max-escape-points
14966Specifies the maximum number of escape points tracked by modref per SSA-name.
14967
14968@item modref-max-adjustments
14969Specifies the maximum number the access range is enlarged during modref dataflow
14970analysis.
14971
14972@item profile-func-internal-id
14973A parameter to control whether to use function internal id in profile
14974database lookup. If the value is 0, the compiler uses an id that
14975is based on function assembler name and filename, which makes old profile
14976data more tolerant to source changes such as function reordering etc.
14977
14978@item min-vect-loop-bound
14979The minimum number of iterations under which loops are not vectorized
14980when @option{-ftree-vectorize} is used. The number of iterations after
14981vectorization needs to be greater than the value specified by this option
14982to allow vectorization.
14983
14984@item gcse-cost-distance-ratio
14985Scaling factor in calculation of maximum distance an expression
14986can be moved by GCSE optimizations. This is currently supported only in the
14987code hoisting pass. The bigger the ratio, the more aggressive code hoisting
14988is with simple expressions, i.e., the expressions that have cost
14989less than @option{gcse-unrestricted-cost}. Specifying 0 disables
14990hoisting of simple expressions.
14991
14992@item gcse-unrestricted-cost
14993Cost, roughly measured as the cost of a single typical machine
14994instruction, at which GCSE optimizations do not constrain
14995the distance an expression can travel. This is currently
14996supported only in the code hoisting pass. The lesser the cost,
14997the more aggressive code hoisting is. Specifying 0
14998allows all expressions to travel unrestricted distances.
14999
15000@item max-hoist-depth
15001The depth of search in the dominator tree for expressions to hoist.
15002This is used to avoid quadratic behavior in hoisting algorithm.
15003The value of 0 does not limit on the search, but may slow down compilation
15004of huge functions.
15005
15006@item max-tail-merge-comparisons
15007The maximum amount of similar bbs to compare a bb with. This is used to
15008avoid quadratic behavior in tree tail merging.
15009
15010@item max-tail-merge-iterations
15011The maximum amount of iterations of the pass over the function. This is used to
15012limit compilation time in tree tail merging.
15013
15014@item store-merging-allow-unaligned
15015Allow the store merging pass to introduce unaligned stores if it is legal to
15016do so.
15017
15018@item max-stores-to-merge
15019The maximum number of stores to attempt to merge into wider stores in the store
15020merging pass.
15021
15022@item max-store-chains-to-track
15023The maximum number of store chains to track at the same time in the attempt
15024to merge them into wider stores in the store merging pass.
15025
15026@item max-stores-to-track
15027The maximum number of stores to track at the same time in the attemt to
15028to merge them into wider stores in the store merging pass.
15029
15030@item max-unrolled-insns
15031The maximum number of instructions that a loop may have to be unrolled.
15032If a loop is unrolled, this parameter also determines how many times
15033the loop code is unrolled.
15034
15035@item max-average-unrolled-insns
15036The maximum number of instructions biased by probabilities of their execution
15037that a loop may have to be unrolled. If a loop is unrolled,
15038this parameter also determines how many times the loop code is unrolled.
15039
15040@item max-unroll-times
15041The maximum number of unrollings of a single loop.
15042
15043@item max-peeled-insns
15044The maximum number of instructions that a loop may have to be peeled.
15045If a loop is peeled, this parameter also determines how many times
15046the loop code is peeled.
15047
15048@item max-peel-times
15049The maximum number of peelings of a single loop.
15050
15051@item max-peel-branches
15052The maximum number of branches on the hot path through the peeled sequence.
15053
15054@item max-completely-peeled-insns
15055The maximum number of insns of a completely peeled loop.
15056
15057@item max-completely-peel-times
15058The maximum number of iterations of a loop to be suitable for complete peeling.
15059
15060@item max-completely-peel-loop-nest-depth
15061The maximum depth of a loop nest suitable for complete peeling.
15062
15063@item max-unswitch-insns
15064The maximum number of insns of an unswitched loop.
15065
5b50850c
RB
15066@item max-unswitch-depth
15067The maximum depth of a loop nest to be unswitched.
15068
d77de738
ML
15069@item lim-expensive
15070The minimum cost of an expensive expression in the loop invariant motion.
15071
15072@item min-loop-cond-split-prob
15073When FDO profile information is available, @option{min-loop-cond-split-prob}
15074specifies minimum threshold for probability of semi-invariant condition
15075statement to trigger loop split.
15076
15077@item iv-consider-all-candidates-bound
15078Bound on number of candidates for induction variables, below which
15079all candidates are considered for each use in induction variable
15080optimizations. If there are more candidates than this,
15081only the most relevant ones are considered to avoid quadratic time complexity.
15082
15083@item iv-max-considered-uses
15084The induction variable optimizations give up on loops that contain more
15085induction variable uses.
15086
15087@item iv-always-prune-cand-set-bound
15088If the number of candidates in the set is smaller than this value,
15089always try to remove unnecessary ivs from the set
15090when adding a new one.
15091
15092@item avg-loop-niter
15093Average number of iterations of a loop.
15094
15095@item dse-max-object-size
15096Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
15097Larger values may result in larger compilation times.
15098
15099@item dse-max-alias-queries-per-store
15100Maximum number of queries into the alias oracle per store.
15101Larger values result in larger compilation times and may result in more
15102removed dead stores.
15103
15104@item scev-max-expr-size
15105Bound on size of expressions used in the scalar evolutions analyzer.
15106Large expressions slow the analyzer.
15107
15108@item scev-max-expr-complexity
15109Bound on the complexity of the expressions in the scalar evolutions analyzer.
15110Complex expressions slow the analyzer.
15111
15112@item max-tree-if-conversion-phi-args
15113Maximum number of arguments in a PHI supported by TREE if conversion
15114unless the loop is marked with simd pragma.
15115
15116@item vect-max-layout-candidates
15117The maximum number of possible vector layouts (such as permutations)
15118to consider when optimizing to-be-vectorized code.
15119
15120@item vect-max-version-for-alignment-checks
15121The maximum number of run-time checks that can be performed when
15122doing loop versioning for alignment in the vectorizer.
15123
15124@item vect-max-version-for-alias-checks
15125The maximum number of run-time checks that can be performed when
15126doing loop versioning for alias in the vectorizer.
15127
15128@item vect-max-peeling-for-alignment
15129The maximum number of loop peels to enhance access alignment
15130for vectorizer. Value -1 means no limit.
15131
15132@item max-iterations-to-track
15133The maximum number of iterations of a loop the brute-force algorithm
15134for analysis of the number of iterations of the loop tries to evaluate.
15135
15136@item hot-bb-count-fraction
15137The denominator n of fraction 1/n of the maximal execution count of a
15138basic block in the entire program that a basic block needs to at least
15139have in order to be considered hot. The default is 10000, which means
15140that a basic block is considered hot if its execution count is greater
15141than 1/10000 of the maximal execution count. 0 means that it is never
15142considered hot. Used in non-LTO mode.
15143
15144@item hot-bb-count-ws-permille
15145The number of most executed permilles, ranging from 0 to 1000, of the
15146profiled execution of the entire program to which the execution count
15147of a basic block must be part of in order to be considered hot. The
15148default is 990, which means that a basic block is considered hot if
15149its execution count contributes to the upper 990 permilles, or 99.0%,
15150of the profiled execution of the entire program. 0 means that it is
15151never considered hot. Used in LTO mode.
15152
15153@item hot-bb-frequency-fraction
15154The denominator n of fraction 1/n of the execution frequency of the
15155entry block of a function that a basic block of this function needs
15156to at least have in order to be considered hot. The default is 1000,
15157which means that a basic block is considered hot in a function if it
15158is executed more frequently than 1/1000 of the frequency of the entry
15159block of the function. 0 means that it is never considered hot.
15160
15161@item unlikely-bb-count-fraction
15162The denominator n of fraction 1/n of the number of profiled runs of
15163the entire program below which the execution count of a basic block
15164must be in order for the basic block to be considered unlikely executed.
15165The default is 20, which means that a basic block is considered unlikely
15166executed if it is executed in fewer than 1/20, or 5%, of the runs of
15167the program. 0 means that it is always considered unlikely executed.
15168
15169@item max-predicted-iterations
15170The maximum number of loop iterations we predict statically. This is useful
15171in cases where a function contains a single loop with known bound and
15172another loop with unknown bound.
15173The known number of iterations is predicted correctly, while
15174the unknown number of iterations average to roughly 10. This means that the
15175loop without bounds appears artificially cold relative to the other one.
15176
15177@item builtin-expect-probability
15178Control the probability of the expression having the specified value. This
15179parameter takes a percentage (i.e.@: 0 ... 100) as input.
15180
15181@item builtin-string-cmp-inline-length
15182The maximum length of a constant string for a builtin string cmp call
15183eligible for inlining.
15184
15185@item align-threshold
15186
15187Select fraction of the maximal frequency of executions of a basic block in
15188a function to align the basic block.
15189
15190@item align-loop-iterations
15191
15192A loop expected to iterate at least the selected number of iterations is
15193aligned.
15194
15195@item tracer-dynamic-coverage
15196@itemx tracer-dynamic-coverage-feedback
15197
15198This value is used to limit superblock formation once the given percentage of
15199executed instructions is covered. This limits unnecessary code size
15200expansion.
15201
15202The @option{tracer-dynamic-coverage-feedback} parameter
15203is used only when profile
15204feedback is available. The real profiles (as opposed to statically estimated
15205ones) are much less balanced allowing the threshold to be larger value.
15206
15207@item tracer-max-code-growth
15208Stop tail duplication once code growth has reached given percentage. This is
15209a rather artificial limit, as most of the duplicates are eliminated later in
15210cross jumping, so it may be set to much higher values than is the desired code
15211growth.
15212
15213@item tracer-min-branch-ratio
15214
15215Stop reverse growth when the reverse probability of best edge is less than this
15216threshold (in percent).
15217
15218@item tracer-min-branch-probability
15219@itemx tracer-min-branch-probability-feedback
15220
15221Stop forward growth if the best edge has probability lower than this
15222threshold.
15223
15224Similarly to @option{tracer-dynamic-coverage} two parameters are
15225provided. @option{tracer-min-branch-probability-feedback} is used for
15226compilation with profile feedback and @option{tracer-min-branch-probability}
15227compilation without. The value for compilation with profile feedback
15228needs to be more conservative (higher) in order to make tracer
15229effective.
15230
15231@item stack-clash-protection-guard-size
15232Specify the size of the operating system provided stack guard as
152332 raised to @var{num} bytes. Higher values may reduce the
15234number of explicit probes, but a value larger than the operating system
15235provided guard will leave code vulnerable to stack clash style attacks.
15236
15237@item stack-clash-protection-probe-interval
15238Stack clash protection involves probing stack space as it is allocated. This
15239param controls the maximum distance between probes into the stack as 2 raised
15240to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
15241larger than the operating system provided guard will leave code vulnerable to
15242stack clash style attacks.
15243
15244@item max-cse-path-length
15245
15246The maximum number of basic blocks on path that CSE considers.
15247
15248@item max-cse-insns
15249The maximum number of instructions CSE processes before flushing.
15250
15251@item ggc-min-expand
15252
15253GCC uses a garbage collector to manage its own memory allocation. This
15254parameter specifies the minimum percentage by which the garbage
15255collector's heap should be allowed to expand between collections.
15256Tuning this may improve compilation speed; it has no effect on code
15257generation.
15258
15259The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
15260RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
15261the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
15262GCC is not able to calculate RAM on a particular platform, the lower
15263bound of 30% is used. Setting this parameter and
15264@option{ggc-min-heapsize} to zero causes a full collection to occur at
15265every opportunity. This is extremely slow, but can be useful for
15266debugging.
15267
15268@item ggc-min-heapsize
15269
15270Minimum size of the garbage collector's heap before it begins bothering
15271to collect garbage. The first collection occurs after the heap expands
15272by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
15273tuning this may improve compilation speed, and has no effect on code
15274generation.
15275
15276The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
15277tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
15278with a lower bound of 4096 (four megabytes) and an upper bound of
15279131072 (128 megabytes). If GCC is not able to calculate RAM on a
15280particular platform, the lower bound is used. Setting this parameter
15281very large effectively disables garbage collection. Setting this
15282parameter and @option{ggc-min-expand} to zero causes a full collection
15283to occur at every opportunity.
15284
15285@item max-reload-search-insns
15286The maximum number of instruction reload should look backward for equivalent
15287register. Increasing values mean more aggressive optimization, making the
15288compilation time increase with probably slightly better performance.
15289
15290@item max-cselib-memory-locations
15291The maximum number of memory locations cselib should take into account.
15292Increasing values mean more aggressive optimization, making the compilation time
15293increase with probably slightly better performance.
15294
15295@item max-sched-ready-insns
15296The maximum number of instructions ready to be issued the scheduler should
15297consider at any given time during the first scheduling pass. Increasing
15298values mean more thorough searches, making the compilation time increase
15299with probably little benefit.
15300
15301@item max-sched-region-blocks
15302The maximum number of blocks in a region to be considered for
15303interblock scheduling.
15304
15305@item max-pipeline-region-blocks
15306The maximum number of blocks in a region to be considered for
15307pipelining in the selective scheduler.
15308
15309@item max-sched-region-insns
15310The maximum number of insns in a region to be considered for
15311interblock scheduling.
15312
15313@item max-pipeline-region-insns
15314The maximum number of insns in a region to be considered for
15315pipelining in the selective scheduler.
15316
15317@item min-spec-prob
15318The minimum probability (in percents) of reaching a source block
15319for interblock speculative scheduling.
15320
15321@item max-sched-extend-regions-iters
15322The maximum number of iterations through CFG to extend regions.
15323A value of 0 disables region extensions.
15324
15325@item max-sched-insn-conflict-delay
15326The maximum conflict delay for an insn to be considered for speculative motion.
15327
15328@item sched-spec-prob-cutoff
15329The minimal probability of speculation success (in percents), so that
15330speculative insns are scheduled.
15331
15332@item sched-state-edge-prob-cutoff
15333The minimum probability an edge must have for the scheduler to save its
15334state across it.
15335
15336@item sched-mem-true-dep-cost
15337Minimal distance (in CPU cycles) between store and load targeting same
15338memory locations.
15339
15340@item selsched-max-lookahead
15341The maximum size of the lookahead window of selective scheduling. It is a
15342depth of search for available instructions.
15343
15344@item selsched-max-sched-times
15345The maximum number of times that an instruction is scheduled during
15346selective scheduling. This is the limit on the number of iterations
15347through which the instruction may be pipelined.
15348
15349@item selsched-insns-to-rename
15350The maximum number of best instructions in the ready list that are considered
15351for renaming in the selective scheduler.
15352
15353@item sms-min-sc
15354The minimum value of stage count that swing modulo scheduler
15355generates.
15356
15357@item max-last-value-rtl
15358The maximum size measured as number of RTLs that can be recorded in an expression
15359in combiner for a pseudo register as last known value of that register.
15360
15361@item max-combine-insns
15362The maximum number of instructions the RTL combiner tries to combine.
15363
15364@item integer-share-limit
15365Small integer constants can use a shared data structure, reducing the
15366compiler's memory usage and increasing its speed. This sets the maximum
15367value of a shared integer constant.
15368
15369@item ssp-buffer-size
15370The minimum size of buffers (i.e.@: arrays) that receive stack smashing
15371protection when @option{-fstack-protector} is used.
15372
15373@item min-size-for-stack-sharing
15374The minimum size of variables taking part in stack slot sharing when not
15375optimizing.
15376
15377@item max-jump-thread-duplication-stmts
15378Maximum number of statements allowed in a block that needs to be
15379duplicated when threading jumps.
15380
15381@item max-jump-thread-paths
15382The maximum number of paths to consider when searching for jump threading
15383opportunities. When arriving at a block, incoming edges are only considered
15384if the number of paths to be searched so far multiplied by the number of
15385incoming edges does not exhaust the specified maximum number of paths to
15386consider.
15387
15388@item max-fields-for-field-sensitive
15389Maximum number of fields in a structure treated in
15390a field sensitive manner during pointer analysis.
15391
15392@item prefetch-latency
15393Estimate on average number of instructions that are executed before
15394prefetch finishes. The distance prefetched ahead is proportional
15395to this constant. Increasing this number may also lead to less
15396streams being prefetched (see @option{simultaneous-prefetches}).
15397
15398@item simultaneous-prefetches
15399Maximum number of prefetches that can run at the same time.
15400
15401@item l1-cache-line-size
15402The size of cache line in L1 data cache, in bytes.
15403
15404@item l1-cache-size
15405The size of L1 data cache, in kilobytes.
15406
15407@item l2-cache-size
15408The size of L2 data cache, in kilobytes.
15409
15410@item prefetch-dynamic-strides
15411Whether the loop array prefetch pass should issue software prefetch hints
15412for strides that are non-constant. In some cases this may be
15413beneficial, though the fact the stride is non-constant may make it
15414hard to predict when there is clear benefit to issuing these hints.
15415
15416Set to 1 if the prefetch hints should be issued for non-constant
15417strides. Set to 0 if prefetch hints should be issued only for strides that
15418are known to be constant and below @option{prefetch-minimum-stride}.
15419
15420@item prefetch-minimum-stride
15421Minimum constant stride, in bytes, to start using prefetch hints for. If
15422the stride is less than this threshold, prefetch hints will not be issued.
15423
15424This setting is useful for processors that have hardware prefetchers, in
15425which case there may be conflicts between the hardware prefetchers and
15426the software prefetchers. If the hardware prefetchers have a maximum
15427stride they can handle, it should be used here to improve the use of
15428software prefetchers.
15429
15430A value of -1 means we don't have a threshold and therefore
15431prefetch hints can be issued for any constant stride.
15432
15433This setting is only useful for strides that are known and constant.
15434
15435@item destructive-interference-size
15436@item constructive-interference-size
15437The values for the C++17 variables
15438@code{std::hardware_destructive_interference_size} and
15439@code{std::hardware_constructive_interference_size}. The destructive
15440interference size is the minimum recommended offset between two
15441independent concurrently-accessed objects; the constructive
15442interference size is the maximum recommended size of contiguous memory
15443accessed together. Typically both will be the size of an L1 cache
15444line for the target, in bytes. For a generic target covering a range of L1
15445cache line sizes, typically the constructive interference size will be
15446the small end of the range and the destructive size will be the large
15447end.
15448
15449The destructive interference size is intended to be used for layout,
15450and thus has ABI impact. The default value is not expected to be
15451stable, and on some targets varies with @option{-mtune}, so use of
15452this variable in a context where ABI stability is important, such as
15453the public interface of a library, is strongly discouraged; if it is
15454used in that context, users can stabilize the value using this
15455option.
15456
15457The constructive interference size is less sensitive, as it is
15458typically only used in a @samp{static_assert} to make sure that a type
15459fits within a cache line.
15460
15461See also @option{-Winterference-size}.
15462
15463@item loop-interchange-max-num-stmts
15464The maximum number of stmts in a loop to be interchanged.
15465
15466@item loop-interchange-stride-ratio
15467The minimum ratio between stride of two loops for interchange to be profitable.
15468
15469@item min-insn-to-prefetch-ratio
15470The minimum ratio between the number of instructions and the
15471number of prefetches to enable prefetching in a loop.
15472
15473@item prefetch-min-insn-to-mem-ratio
15474The minimum ratio between the number of instructions and the
15475number of memory references to enable prefetching in a loop.
15476
15477@item use-canonical-types
15478Whether the compiler should use the ``canonical'' type system.
15479Should always be 1, which uses a more efficient internal
15480mechanism for comparing types in C++ and Objective-C++. However, if
15481bugs in the canonical type system are causing compilation failures,
15482set this value to 0 to disable canonical types.
15483
15484@item switch-conversion-max-branch-ratio
15485Switch initialization conversion refuses to create arrays that are
15486bigger than @option{switch-conversion-max-branch-ratio} times the number of
15487branches in the switch.
15488
15489@item max-partial-antic-length
15490Maximum length of the partial antic set computed during the tree
15491partial redundancy elimination optimization (@option{-ftree-pre}) when
15492optimizing at @option{-O3} and above. For some sorts of source code
15493the enhanced partial redundancy elimination optimization can run away,
15494consuming all of the memory available on the host machine. This
15495parameter sets a limit on the length of the sets that are computed,
15496which prevents the runaway behavior. Setting a value of 0 for
15497this parameter allows an unlimited set length.
15498
15499@item rpo-vn-max-loop-depth
15500Maximum loop depth that is value-numbered optimistically.
15501When the limit hits the innermost
15502@var{rpo-vn-max-loop-depth} loops and the outermost loop in the
15503loop nest are value-numbered optimistically and the remaining ones not.
15504
15505@item sccvn-max-alias-queries-per-access
15506Maximum number of alias-oracle queries we perform when looking for
15507redundancies for loads and stores. If this limit is hit the search
15508is aborted and the load or store is not considered redundant. The
15509number of queries is algorithmically limited to the number of
15510stores on all paths from the load to the function entry.
15511
15512@item ira-max-loops-num
15513IRA uses regional register allocation by default. If a function
15514contains more loops than the number given by this parameter, only at most
15515the given number of the most frequently-executed loops form regions
15516for regional register allocation.
15517
15518@item ira-max-conflict-table-size
15519Although IRA uses a sophisticated algorithm to compress the conflict
15520table, the table can still require excessive amounts of memory for
15521huge functions. If the conflict table for a function could be more
15522than the size in MB given by this parameter, the register allocator
15523instead uses a faster, simpler, and lower-quality
15524algorithm that does not require building a pseudo-register conflict table.
15525
15526@item ira-loop-reserved-regs
15527IRA can be used to evaluate more accurate register pressure in loops
15528for decisions to move loop invariants (see @option{-O3}). The number
15529of available registers reserved for some other purposes is given
15530by this parameter. Default of the parameter
15531is the best found from numerous experiments.
15532
15533@item ira-consider-dup-in-all-alts
15534Make IRA to consider matching constraint (duplicated operand number)
15535heavily in all available alternatives for preferred register class.
15536If it is set as zero, it means IRA only respects the matching
15537constraint when it's in the only available alternative with an
15538appropriate register class. Otherwise, it means IRA will check all
15539available alternatives for preferred register class even if it has
15540found some choice with an appropriate register class and respect the
15541found qualified matching constraint.
15542
9847c753
ML
15543@item ira-simple-lra-insn-threshold
15544Approximate function insn number in 1K units triggering simple local RA.
15545
d77de738
ML
15546@item lra-inheritance-ebb-probability-cutoff
15547LRA tries to reuse values reloaded in registers in subsequent insns.
15548This optimization is called inheritance. EBB is used as a region to
15549do this optimization. The parameter defines a minimal fall-through
15550edge probability in percentage used to add BB to inheritance EBB in
15551LRA. The default value was chosen
15552from numerous runs of SPEC2000 on x86-64.
15553
15554@item loop-invariant-max-bbs-in-loop
15555Loop invariant motion can be very expensive, both in compilation time and
15556in amount of needed compile-time memory, with very large loops. Loops
15557with more basic blocks than this parameter won't have loop invariant
15558motion optimization performed on them.
15559
15560@item loop-max-datarefs-for-datadeps
15561Building data dependencies is expensive for very large loops. This
15562parameter limits the number of data references in loops that are
15563considered for data dependence analysis. These large loops are no
15564handled by the optimizations using loop data dependencies.
15565
15566@item max-vartrack-size
15567Sets a maximum number of hash table slots to use during variable
15568tracking dataflow analysis of any function. If this limit is exceeded
15569with variable tracking at assignments enabled, analysis for that
15570function is retried without it, after removing all debug insns from
15571the function. If the limit is exceeded even without debug insns, var
15572tracking analysis is completely disabled for the function. Setting
15573the parameter to zero makes it unlimited.
15574
15575@item max-vartrack-expr-depth
15576Sets a maximum number of recursion levels when attempting to map
15577variable names or debug temporaries to value expressions. This trades
15578compilation time for more complete debug information. If this is set too
15579low, value expressions that are available and could be represented in
15580debug information may end up not being used; setting this higher may
15581enable the compiler to find more complex debug expressions, but compile
15582time and memory use may grow.
15583
15584@item max-debug-marker-count
15585Sets a threshold on the number of debug markers (e.g.@: begin stmt
15586markers) to avoid complexity explosion at inlining or expanding to RTL.
15587If a function has more such gimple stmts than the set limit, such stmts
15588will be dropped from the inlined copy of a function, and from its RTL
15589expansion.
15590
15591@item min-nondebug-insn-uid
15592Use uids starting at this parameter for nondebug insns. The range below
15593the parameter is reserved exclusively for debug insns created by
15594@option{-fvar-tracking-assignments}, but debug insns may get
15595(non-overlapping) uids above it if the reserved range is exhausted.
15596
10478270
MJ
15597@item ipa-sra-deref-prob-threshold
15598IPA-SRA replaces a pointer which is known not be NULL with one or more
15599new parameters only when the probability (in percent, relative to
15600function entry) of it being dereferenced is higher than this parameter.
15601
d77de738
ML
15602@item ipa-sra-ptr-growth-factor
15603IPA-SRA replaces a pointer to an aggregate with one or more new
15604parameters only when their cumulative size is less or equal to
15605@option{ipa-sra-ptr-growth-factor} times the size of the original
15606pointer parameter.
15607
69363825
ML
15608@item ipa-sra-ptrwrap-growth-factor
15609Additional maximum allowed growth of total size of new parameters
15610that ipa-sra replaces a pointer to an aggregate with,
049dccd0
MJ
15611if it points to a local variable that the caller only writes to and
15612passes it as an argument to other functions.
69363825 15613
d77de738
ML
15614@item ipa-sra-max-replacements
15615Maximum pieces of an aggregate that IPA-SRA tracks. As a
15616consequence, it is also the maximum number of replacements of a formal
15617parameter.
15618
15619@item sra-max-scalarization-size-Ospeed
15620@itemx sra-max-scalarization-size-Osize
15621The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
15622replace scalar parts of aggregates with uses of independent scalar
15623variables. These parameters control the maximum size, in storage units,
15624of aggregate which is considered for replacement when compiling for
15625speed
15626(@option{sra-max-scalarization-size-Ospeed}) or size
15627(@option{sra-max-scalarization-size-Osize}) respectively.
15628
15629@item sra-max-propagations
15630The maximum number of artificial accesses that Scalar Replacement of
15631Aggregates (SRA) will track, per one local variable, in order to
15632facilitate copy propagation.
15633
15634@item tm-max-aggregate-size
15635When making copies of thread-local variables in a transaction, this
15636parameter specifies the size in bytes after which variables are
15637saved with the logging functions as opposed to save/restore code
15638sequence pairs. This option only applies when using
15639@option{-fgnu-tm}.
15640
15641@item graphite-max-nb-scop-params
15642To avoid exponential effects in the Graphite loop transforms, the
15643number of parameters in a Static Control Part (SCoP) is bounded.
15644A value of zero can be used to lift
15645the bound. A variable whose value is unknown at compilation time and
15646defined outside a SCoP is a parameter of the SCoP.
15647
15648@item loop-block-tile-size
15649Loop blocking or strip mining transforms, enabled with
15650@option{-floop-block} or @option{-floop-strip-mine}, strip mine each
15651loop in the loop nest by a given number of iterations. The strip
15652length can be changed using the @option{loop-block-tile-size}
15653parameter.
15654
15655@item ipa-jump-function-lookups
15656Specifies number of statements visited during jump function offset discovery.
15657
15658@item ipa-cp-value-list-size
15659IPA-CP attempts to track all possible values and types passed to a function's
15660parameter in order to propagate them and perform devirtualization.
15661@option{ipa-cp-value-list-size} is the maximum number of values and types it
15662stores per one formal parameter of a function.
15663
15664@item ipa-cp-eval-threshold
15665IPA-CP calculates its own score of cloning profitability heuristics
15666and performs those cloning opportunities with scores that exceed
15667@option{ipa-cp-eval-threshold}.
15668
15669@item ipa-cp-max-recursive-depth
15670Maximum depth of recursive cloning for self-recursive function.
15671
15672@item ipa-cp-min-recursive-probability
15673Recursive cloning only when the probability of call being executed exceeds
15674the parameter.
15675
15676@item ipa-cp-profile-count-base
15677When using @option{-fprofile-use} option, IPA-CP will consider the measured
15678execution count of a call graph edge at this percentage position in their
15679histogram as the basis for its heuristics calculation.
15680
15681@item ipa-cp-recursive-freq-factor
15682The number of times interprocedural copy propagation expects recursive
15683functions to call themselves.
15684
15685@item ipa-cp-recursion-penalty
15686Percentage penalty the recursive functions will receive when they
15687are evaluated for cloning.
15688
15689@item ipa-cp-single-call-penalty
15690Percentage penalty functions containing a single call to another
15691function will receive when they are evaluated for cloning.
15692
15693@item ipa-max-agg-items
15694IPA-CP is also capable to propagate a number of scalar values passed
15695in an aggregate. @option{ipa-max-agg-items} controls the maximum
15696number of such values per one parameter.
15697
15698@item ipa-cp-loop-hint-bonus
15699When IPA-CP determines that a cloning candidate would make the number
15700of iterations of a loop known, it adds a bonus of
15701@option{ipa-cp-loop-hint-bonus} to the profitability score of
15702the candidate.
15703
15704@item ipa-max-loop-predicates
15705The maximum number of different predicates IPA will use to describe when
15706loops in a function have known properties.
15707
15708@item ipa-max-aa-steps
15709During its analysis of function bodies, IPA-CP employs alias analysis
15710in order to track values pointed to by function parameters. In order
15711not spend too much time analyzing huge functions, it gives up and
15712consider all memory clobbered after examining
15713@option{ipa-max-aa-steps} statements modifying memory.
15714
15715@item ipa-max-switch-predicate-bounds
15716Maximal number of boundary endpoints of case ranges of switch statement.
15717For switch exceeding this limit, IPA-CP will not construct cloning cost
15718predicate, which is used to estimate cloning benefit, for default case
15719of the switch statement.
15720
15721@item ipa-max-param-expr-ops
15722IPA-CP will analyze conditional statement that references some function
15723parameter to estimate benefit for cloning upon certain constant value.
15724But if number of operations in a parameter expression exceeds
15725@option{ipa-max-param-expr-ops}, the expression is treated as complicated
15726one, and is not handled by IPA analysis.
15727
15728@item lto-partitions
15729Specify desired number of partitions produced during WHOPR compilation.
15730The number of partitions should exceed the number of CPUs used for compilation.
15731
15732@item lto-min-partition
15733Size of minimal partition for WHOPR (in estimated instructions).
15734This prevents expenses of splitting very small programs into too many
15735partitions.
15736
15737@item lto-max-partition
15738Size of max partition for WHOPR (in estimated instructions).
15739to provide an upper bound for individual size of partition.
15740Meant to be used only with balanced partitioning.
15741
15742@item lto-max-streaming-parallelism
15743Maximal number of parallel processes used for LTO streaming.
15744
15745@item cxx-max-namespaces-for-diagnostic-help
15746The maximum number of namespaces to consult for suggestions when C++
15747name lookup fails for an identifier.
15748
15749@item sink-frequency-threshold
15750The maximum relative execution frequency (in percents) of the target block
15751relative to a statement's original block to allow statement sinking of a
15752statement. Larger numbers result in more aggressive statement sinking.
15753A small positive adjustment is applied for
15754statements with memory operands as those are even more profitable so sink.
15755
15756@item max-stores-to-sink
15757The maximum number of conditional store pairs that can be sunk. Set to 0
15758if either vectorization (@option{-ftree-vectorize}) or if-conversion
15759(@option{-ftree-loop-if-convert}) is disabled.
15760
15761@item case-values-threshold
15762The smallest number of different values for which it is best to use a
15763jump-table instead of a tree of conditional branches. If the value is
157640, use the default for the machine.
15765
15766@item jump-table-max-growth-ratio-for-size
15767The maximum code size growth ratio when expanding
15768into a jump table (in percent). The parameter is used when
15769optimizing for size.
15770
15771@item jump-table-max-growth-ratio-for-speed
15772The maximum code size growth ratio when expanding
15773into a jump table (in percent). The parameter is used when
15774optimizing for speed.
15775
15776@item tree-reassoc-width
15777Set the maximum number of instructions executed in parallel in
15778reassociated tree. This parameter overrides target dependent
15779heuristics used by default if has non zero value.
15780
15781@item sched-pressure-algorithm
15782Choose between the two available implementations of
15783@option{-fsched-pressure}. Algorithm 1 is the original implementation
15784and is the more likely to prevent instructions from being reordered.
15785Algorithm 2 was designed to be a compromise between the relatively
15786conservative approach taken by algorithm 1 and the rather aggressive
15787approach taken by the default scheduler. It relies more heavily on
15788having a regular register file and accurate register pressure classes.
15789See @file{haifa-sched.cc} in the GCC sources for more details.
15790
15791The default choice depends on the target.
15792
15793@item max-slsr-cand-scan
15794Set the maximum number of existing candidates that are considered when
15795seeking a basis for a new straight-line strength reduction candidate.
15796
15797@item asan-globals
15798Enable buffer overflow detection for global objects. This kind
15799of protection is enabled by default if you are using
15800@option{-fsanitize=address} option.
15801To disable global objects protection use @option{--param asan-globals=0}.
15802
15803@item asan-stack
15804Enable buffer overflow detection for stack objects. This kind of
15805protection is enabled by default when using @option{-fsanitize=address}.
15806To disable stack protection use @option{--param asan-stack=0} option.
15807
15808@item asan-instrument-reads
15809Enable buffer overflow detection for memory reads. This kind of
15810protection is enabled by default when using @option{-fsanitize=address}.
15811To disable memory reads protection use
15812@option{--param asan-instrument-reads=0}.
15813
15814@item asan-instrument-writes
15815Enable buffer overflow detection for memory writes. This kind of
15816protection is enabled by default when using @option{-fsanitize=address}.
15817To disable memory writes protection use
15818@option{--param asan-instrument-writes=0} option.
15819
15820@item asan-memintrin
15821Enable detection for built-in functions. This kind of protection
15822is enabled by default when using @option{-fsanitize=address}.
15823To disable built-in functions protection use
15824@option{--param asan-memintrin=0}.
15825
15826@item asan-use-after-return
15827Enable detection of use-after-return. This kind of protection
15828is enabled by default when using the @option{-fsanitize=address} option.
15829To disable it use @option{--param asan-use-after-return=0}.
15830
15831Note: By default the check is disabled at run time. To enable it,
15832add @code{detect_stack_use_after_return=1} to the environment variable
15833@env{ASAN_OPTIONS}.
15834
15835@item asan-instrumentation-with-call-threshold
15836If number of memory accesses in function being instrumented
15837is greater or equal to this number, use callbacks instead of inline checks.
15838E.g. to disable inline code use
15839@option{--param asan-instrumentation-with-call-threshold=0}.
15840
545c9f8b
ML
15841@item asan-kernel-mem-intrinsic-prefix
15842Prefix calls to memcpy, memset and memmove with __asan_ or __hwasan_
15843for -fsanitize=kernel-address or -fsanitize=kernel-hwaddress.
15844
d77de738
ML
15845@item hwasan-instrument-stack
15846Enable hwasan instrumentation of statically sized stack-allocated variables.
15847This kind of instrumentation is enabled by default when using
15848@option{-fsanitize=hwaddress} and disabled by default when using
15849@option{-fsanitize=kernel-hwaddress}.
15850To disable stack instrumentation use
15851@option{--param hwasan-instrument-stack=0}, and to enable it use
15852@option{--param hwasan-instrument-stack=1}.
15853
15854@item hwasan-random-frame-tag
15855When using stack instrumentation, decide tags for stack variables using a
15856deterministic sequence beginning at a random tag for each frame. With this
15857parameter unset tags are chosen using the same sequence but beginning from 1.
15858This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
15859for @option{-fsanitize=kernel-hwaddress}.
15860To disable it use @option{--param hwasan-random-frame-tag=0}.
15861
15862@item hwasan-instrument-allocas
15863Enable hwasan instrumentation of dynamically sized stack-allocated variables.
15864This kind of instrumentation is enabled by default when using
15865@option{-fsanitize=hwaddress} and disabled by default when using
15866@option{-fsanitize=kernel-hwaddress}.
15867To disable instrumentation of such variables use
15868@option{--param hwasan-instrument-allocas=0}, and to enable it use
15869@option{--param hwasan-instrument-allocas=1}.
15870
15871@item hwasan-instrument-reads
15872Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
15873default for both @option{-fsanitize=hwaddress} and
15874@option{-fsanitize=kernel-hwaddress}.
15875To disable checking memory reads use
15876@option{--param hwasan-instrument-reads=0}.
15877
15878@item hwasan-instrument-writes
15879Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
15880default for both @option{-fsanitize=hwaddress} and
15881@option{-fsanitize=kernel-hwaddress}.
15882To disable checking memory writes use
15883@option{--param hwasan-instrument-writes=0}.
15884
15885@item hwasan-instrument-mem-intrinsics
15886Enable hwasan instrumentation of builtin functions. Instrumentation of these
15887builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
15888and @option{-fsanitize=kernel-hwaddress}.
15889To disable instrumentation of builtin functions use
15890@option{--param hwasan-instrument-mem-intrinsics=0}.
15891
15892@item use-after-scope-direct-emission-threshold
15893If the size of a local variable in bytes is smaller or equal to this
15894number, directly poison (or unpoison) shadow memory instead of using
15895run-time callbacks.
15896
15897@item tsan-distinguish-volatile
15898Emit special instrumentation for accesses to volatiles.
15899
15900@item tsan-instrument-func-entry-exit
15901Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
15902
15903@item max-fsm-thread-path-insns
15904Maximum number of instructions to copy when duplicating blocks on a
15905finite state automaton jump thread path.
15906
15907@item threader-debug
15908threader-debug=[none|all] Enables verbose dumping of the threader solver.
15909
15910@item parloops-chunk-size
15911Chunk size of omp schedule for loops parallelized by parloops.
15912
15913@item parloops-schedule
15914Schedule type of omp schedule for loops parallelized by parloops (static,
15915dynamic, guided, auto, runtime).
15916
15917@item parloops-min-per-thread
15918The minimum number of iterations per thread of an innermost parallelized
15919loop for which the parallelized variant is preferred over the single threaded
15920one. Note that for a parallelized loop nest the
15921minimum number of iterations of the outermost loop per thread is two.
15922
15923@item max-ssa-name-query-depth
15924Maximum depth of recursion when querying properties of SSA names in things
15925like fold routines. One level of recursion corresponds to following a
15926use-def chain.
15927
15928@item max-speculative-devirt-maydefs
15929The maximum number of may-defs we analyze when looking for a must-def
15930specifying the dynamic type of an object that invokes a virtual call
15931we may be able to devirtualize speculatively.
15932
d77de738
ML
15933@item evrp-sparse-threshold
15934Maximum number of basic blocks before EVRP uses a sparse cache.
15935
d77de738
ML
15936@item ranger-debug
15937Specifies the type of debug output to be issued for ranges.
15938
15939@item evrp-switch-limit
15940Specifies the maximum number of switch cases before EVRP ignores a switch.
15941
15942@item unroll-jam-min-percent
15943The minimum percentage of memory references that must be optimized
15944away for the unroll-and-jam transformation to be considered profitable.
15945
15946@item unroll-jam-max-unroll
15947The maximum number of times the outer loop should be unrolled by
15948the unroll-and-jam transformation.
15949
15950@item max-rtl-if-conversion-unpredictable-cost
15951Maximum permissible cost for the sequence that would be generated
15952by the RTL if-conversion pass for a branch that is considered unpredictable.
15953
15954@item max-variable-expansions-in-unroller
15955If @option{-fvariable-expansion-in-unroller} is used, the maximum number
15956of times that an individual variable will be expanded during loop unrolling.
15957
15958@item partial-inlining-entry-probability
15959Maximum probability of the entry BB of split region
15960(in percent relative to entry BB of the function)
15961to make partial inlining happen.
15962
15963@item max-tracked-strlens
15964Maximum number of strings for which strlen optimization pass will
15965track string lengths.
15966
15967@item gcse-after-reload-partial-fraction
15968The threshold ratio for performing partial redundancy
15969elimination after reload.
15970
15971@item gcse-after-reload-critical-fraction
15972The threshold ratio of critical edges execution count that
15973permit performing redundancy elimination after reload.
15974
15975@item max-loop-header-insns
15976The maximum number of insns in loop header duplicated
15977by the copy loop headers pass.
15978
15979@item vect-epilogues-nomask
15980Enable loop epilogue vectorization using smaller vector size.
15981
15982@item vect-partial-vector-usage
15983Controls when the loop vectorizer considers using partial vector loads
15984and stores as an alternative to falling back to scalar code. 0 stops
15985the vectorizer from ever using partial vector loads and stores. 1 allows
15986partial vector loads and stores if vectorization removes the need for the
15987code to iterate. 2 allows partial vector loads and stores in all loops.
15988The parameter only has an effect on targets that support partial
15989vector loads and stores.
15990
15991@item vect-inner-loop-cost-factor
15992The maximum factor which the loop vectorizer applies to the cost of statements
15993in an inner loop relative to the loop being vectorized. The factor applied
15994is the maximum of the estimated number of iterations of the inner loop and
15995this parameter. The default value of this parameter is 50.
15996
15997@item vect-induction-float
15998Enable loop vectorization of floating point inductions.
15999
16000@item avoid-fma-max-bits
16001Maximum number of bits for which we avoid creating FMAs.
16002
16003@item sms-loop-average-count-threshold
16004A threshold on the average loop count considered by the swing modulo scheduler.
16005
16006@item sms-dfa-history
16007The number of cycles the swing modulo scheduler considers when checking
16008conflicts using DFA.
16009
16010@item graphite-allow-codegen-errors
16011Whether codegen errors should be ICEs when @option{-fchecking}.
16012
16013@item sms-max-ii-factor
16014A factor for tuning the upper bound that swing modulo scheduler
16015uses for scheduling a loop.
16016
16017@item lra-max-considered-reload-pseudos
16018The max number of reload pseudos which are considered during
16019spilling a non-reload pseudo.
16020
16021@item max-pow-sqrt-depth
16022Maximum depth of sqrt chains to use when synthesizing exponentiation
16023by a real constant.
16024
16025@item max-dse-active-local-stores
16026Maximum number of active local stores in RTL dead store elimination.
16027
16028@item asan-instrument-allocas
16029Enable asan allocas/VLAs protection.
16030
16031@item max-iterations-computation-cost
16032Bound on the cost of an expression to compute the number of iterations.
16033
16034@item max-isl-operations
16035Maximum number of isl operations, 0 means unlimited.
16036
16037@item graphite-max-arrays-per-scop
16038Maximum number of arrays per scop.
16039
16040@item max-vartrack-reverse-op-size
16041Max. size of loc list for which reverse ops should be added.
16042
16043@item fsm-scale-path-stmts
16044Scale factor to apply to the number of statements in a threading path
7c9f20fc
RB
16045crossing a loop backedge when comparing to
16046@option{--param=max-jump-thread-duplication-stmts}.
d77de738
ML
16047
16048@item uninit-control-dep-attempts
16049Maximum number of nested calls to search for control dependencies
16050during uninitialized variable analysis.
16051
d77de738
ML
16052@item sched-autopref-queue-depth
16053Hardware autoprefetcher scheduler model control flag.
16054Number of lookahead cycles the model looks into; at '
16055' only enable instruction sorting heuristic.
16056
16057@item loop-versioning-max-inner-insns
16058The maximum number of instructions that an inner loop can have
16059before the loop versioning pass considers it too big to copy.
16060
16061@item loop-versioning-max-outer-insns
16062The maximum number of instructions that an outer loop can have
16063before the loop versioning pass considers it too big to copy,
16064discounting any instructions in inner loops that directly benefit
16065from versioning.
16066
16067@item ssa-name-def-chain-limit
16068The maximum number of SSA_NAME assignments to follow in determining
16069a property of a variable such as its value. This limits the number
16070of iterations or recursive calls GCC performs when optimizing certain
16071statements or when determining their validity prior to issuing
16072diagnostics.
16073
16074@item store-merging-max-size
16075Maximum size of a single store merging region in bytes.
16076
16077@item hash-table-verification-limit
16078The number of elements for which hash table verification is done
16079for each searched element.
16080
16081@item max-find-base-term-values
16082Maximum number of VALUEs handled during a single find_base_term call.
16083
16084@item analyzer-max-enodes-per-program-point
16085The maximum number of exploded nodes per program point within
16086the analyzer, before terminating analysis of that point.
16087
16088@item analyzer-max-constraints
16089The maximum number of constraints per state.
16090
16091@item analyzer-min-snodes-for-call-summary
16092The minimum number of supernodes within a function for the
16093analyzer to consider summarizing its effects at call sites.
16094
16095@item analyzer-max-enodes-for-full-dump
16096The maximum depth of exploded nodes that should appear in a dot dump
16097before switching to a less verbose format.
16098
16099@item analyzer-max-recursion-depth
16100The maximum number of times a callsite can appear in a call stack
16101within the analyzer, before terminating analysis of a call that would
16102recurse deeper.
16103
16104@item analyzer-max-svalue-depth
16105The maximum depth of a symbolic value, before approximating
16106the value as unknown.
16107
16108@item analyzer-max-infeasible-edges
16109The maximum number of infeasible edges to reject before declaring
16110a diagnostic as infeasible.
16111
16112@item gimple-fe-computed-hot-bb-threshold
16113The number of executions of a basic block which is considered hot.
16114The parameter is used only in GIMPLE FE.
16115
16116@item analyzer-bb-explosion-factor
16117The maximum number of 'after supernode' exploded nodes within the analyzer
16118per supernode, before terminating analysis.
16119
16120@item ranger-logical-depth
16121Maximum depth of logical expression evaluation ranger will look through
16122when evaluating outgoing edge ranges.
16123
16124@item relation-block-limit
16125Maximum number of relations the oracle will register in a basic block.
16126
16127@item min-pagesize
16128Minimum page size for warning purposes.
16129
16130@item openacc-kernels
16131Specify mode of OpenACC `kernels' constructs handling.
16132With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
16133constructs are decomposed into parts, a sequence of compute
16134constructs, each then handled individually.
16135This is work in progress.
16136With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
16137constructs are handled by the @samp{parloops} pass, en bloc.
16138This is the current default.
16139
16140@item openacc-privatization
16141Specify mode of OpenACC privatization diagnostics for
16142@option{-fopt-info-omp-note} and applicable
16143@option{-fdump-tree-*-details}.
16144With @option{--param=openacc-privatization=quiet}, don't diagnose.
16145This is the current default.
16146With @option{--param=openacc-privatization=noisy}, do diagnose.
16147
16148@end table
16149
16150The following choices of @var{name} are available on AArch64 targets:
16151
16152@table @gcctabopt
16153@item aarch64-sve-compare-costs
16154When vectorizing for SVE, consider using ``unpacked'' vectors for
16155smaller elements and use the cost model to pick the cheapest approach.
16156Also use the cost model to choose between SVE and Advanced SIMD vectorization.
16157
16158Using unpacked vectors includes storing smaller elements in larger
16159containers and accessing elements with extending loads and truncating
16160stores.
16161
16162@item aarch64-float-recp-precision
16163The number of Newton iterations for calculating the reciprocal for float type.
16164The precision of division is proportional to this param when division
16165approximation is enabled. The default value is 1.
16166
16167@item aarch64-double-recp-precision
16168The number of Newton iterations for calculating the reciprocal for double type.
16169The precision of division is propotional to this param when division
16170approximation is enabled. The default value is 2.
16171
16172@item aarch64-autovec-preference
16173Force an ISA selection strategy for auto-vectorization. Accepts values from
161740 to 4, inclusive.
16175@table @samp
16176@item 0
16177Use the default heuristics.
16178@item 1
16179Use only Advanced SIMD for auto-vectorization.
16180@item 2
16181Use only SVE for auto-vectorization.
16182@item 3
16183Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
16184deemed equal.
16185@item 4
16186Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
16187@end table
16188The default value is 0.
16189
16190@item aarch64-loop-vect-issue-rate-niters
16191The tuning for some AArch64 CPUs tries to take both latencies and issue
16192rates into account when deciding whether a loop should be vectorized
16193using SVE, vectorized using Advanced SIMD, or not vectorized at all.
16194If this parameter is set to @var{n}, GCC will not use this heuristic
16195for loops that are known to execute in fewer than @var{n} Advanced
16196SIMD iterations.
16197
16198@item aarch64-vect-unroll-limit
16199The vectorizer will use available tuning information to determine whether it
16200would be beneficial to unroll the main vectorized loop and by how much. This
16201parameter set's the upper bound of how much the vectorizer will unroll the main
16202loop. The default value is four.
16203
16204@end table
16205
16206The following choices of @var{name} are available on i386 and x86_64 targets:
16207
16208@table @gcctabopt
16209@item x86-stlf-window-ninsns
16210Instructions number above which STFL stall penalty can be compensated.
16211
16212@end table
16213
16214@end table
16215
16216@node Instrumentation Options
16217@section Program Instrumentation Options
16218@cindex instrumentation options
16219@cindex program instrumentation options
16220@cindex run-time error checking options
16221@cindex profiling options
16222@cindex options, program instrumentation
16223@cindex options, run-time error checking
16224@cindex options, profiling
16225
16226GCC supports a number of command-line options that control adding
16227run-time instrumentation to the code it normally generates.
16228For example, one purpose of instrumentation is collect profiling
16229statistics for use in finding program hot spots, code coverage
16230analysis, or profile-guided optimizations.
16231Another class of program instrumentation is adding run-time checking
16232to detect programming errors like invalid pointer
16233dereferences or out-of-bounds array accesses, as well as deliberately
16234hostile attacks such as stack smashing or C++ vtable hijacking.
16235There is also a general hook which can be used to implement other
16236forms of tracing or function-level instrumentation for debug or
16237program analysis purposes.
16238
16239@table @gcctabopt
16240@cindex @command{prof}
16241@cindex @command{gprof}
16242@item -p
16243@itemx -pg
16244@opindex p
16245@opindex pg
16246Generate extra code to write profile information suitable for the
16247analysis program @command{prof} (for @option{-p}) or @command{gprof}
16248(for @option{-pg}). You must use this option when compiling
16249the source files you want data about, and you must also use it when
16250linking.
16251
16252You can use the function attribute @code{no_instrument_function} to
16253suppress profiling of individual functions when compiling with these options.
16254@xref{Common Function Attributes}.
16255
16256@item -fprofile-arcs
16257@opindex fprofile-arcs
16258Add code so that program flow @dfn{arcs} are instrumented. During
16259execution the program records how many times each branch and call is
16260executed and how many times it is taken or returns. On targets that support
16261constructors with priority support, profiling properly handles constructors,
16262destructors and C++ constructors (and destructors) of classes which are used
16263as a type of a global variable.
16264
16265When the compiled
16266program exits it saves this data to a file called
16267@file{@var{auxname}.gcda} for each source file. The data may be used for
16268profile-directed optimizations (@option{-fbranch-probabilities}), or for
16269test coverage analysis (@option{-ftest-coverage}). Each object file's
16270@var{auxname} is generated from the name of the output file, if
16271explicitly specified and it is not the final executable, otherwise it is
16272the basename of the source file. In both cases any suffix is removed
16273(e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
16274@file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
16275
16276Note that if a command line directly links source files, the corresponding
16277@var{.gcda} files will be prefixed with the unsuffixed name of the output file.
16278E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and
16279@file{binary-b.gcda} files.
16280
16281@xref{Cross-profiling}.
16282
16283@cindex @command{gcov}
16284@item --coverage
16285@opindex coverage
16286
16287This option is used to compile and link code instrumented for coverage
16288analysis. The option is a synonym for @option{-fprofile-arcs}
16289@option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
16290linking). See the documentation for those options for more details.
16291
16292@itemize
16293
16294@item
16295Compile the source files with @option{-fprofile-arcs} plus optimization
16296and code generation options. For test coverage analysis, use the
16297additional @option{-ftest-coverage} option. You do not need to profile
16298every source file in a program.
16299
16300@item
16301Compile the source files additionally with @option{-fprofile-abs-path}
16302to create absolute path names in the @file{.gcno} files. This allows
16303@command{gcov} to find the correct sources in projects where compilations
16304occur with different working directories.
16305
16306@item
16307Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
16308(the latter implies the former).
16309
16310@item
16311Run the program on a representative workload to generate the arc profile
16312information. This may be repeated any number of times. You can run
16313concurrent instances of your program, and provided that the file system
16314supports locking, the data files will be correctly updated. Unless
16315a strict ISO C dialect option is in effect, @code{fork} calls are
16316detected and correctly handled without double counting.
16317
16318Moreover, an object file can be recompiled multiple times
16319and the corresponding @file{.gcda} file merges as long as
16320the source file and the compiler options are unchanged.
16321
16322@item
16323For profile-directed optimizations, compile the source files again with
16324the same optimization and code generation options plus
16325@option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
16326Control Optimization}).
16327
16328@item
16329For test coverage analysis, use @command{gcov} to produce human readable
16330information from the @file{.gcno} and @file{.gcda} files. Refer to the
16331@command{gcov} documentation for further information.
16332
16333@end itemize
16334
16335With @option{-fprofile-arcs}, for each function of your program GCC
16336creates a program flow graph, then finds a spanning tree for the graph.
16337Only arcs that are not on the spanning tree have to be instrumented: the
16338compiler adds code to count the number of times that these arcs are
16339executed. When an arc is the only exit or only entrance to a block, the
16340instrumentation code can be added to the block; otherwise, a new basic
16341block must be created to hold the instrumentation code.
16342
16343@need 2000
16344@item -ftest-coverage
16345@opindex ftest-coverage
16346Produce a notes file that the @command{gcov} code-coverage utility
16347(@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
16348show program coverage. Each source file's note file is called
16349@file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
16350above for a description of @var{auxname} and instructions on how to
16351generate test coverage data. Coverage data matches the source files
16352more closely if you do not optimize.
16353
16354@item -fprofile-abs-path
16355@opindex fprofile-abs-path
16356Automatically convert relative source file names to absolute path names
16357in the @file{.gcno} files. This allows @command{gcov} to find the correct
16358sources in projects where compilations occur with different working
16359directories.
16360
16361@item -fprofile-dir=@var{path}
16362@opindex fprofile-dir
16363
16364Set the directory to search for the profile data files in to @var{path}.
16365This option affects only the profile data generated by
16366@option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
16367and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
16368and its related options. Both absolute and relative paths can be used.
16369By default, GCC uses the current directory as @var{path}, thus the
16370profile data file appears in the same directory as the object file.
16371In order to prevent the file name clashing, if the object file name is
16372not an absolute path, we mangle the absolute path of the
16373@file{@var{sourcename}.gcda} file and use it as the file name of a
16374@file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}.
16375See similar option @option{-fprofile-note}.
16376
16377When an executable is run in a massive parallel environment, it is recommended
16378to save profile to different folders. That can be done with variables
16379in @var{path} that are exported during run-time:
16380
16381@table @gcctabopt
16382
16383@item %p
16384process ID.
16385
16386@item %q@{VAR@}
16387value of environment variable @var{VAR}
16388
16389@end table
16390
16391@item -fprofile-generate
16392@itemx -fprofile-generate=@var{path}
16393@opindex fprofile-generate
16394
16395Enable options usually used for instrumenting application to produce
16396profile useful for later recompilation with profile feedback based
16397optimization. You must use @option{-fprofile-generate} both when
16398compiling and when linking your program.
16399
16400The following options are enabled:
16401@option{-fprofile-arcs}, @option{-fprofile-values},
16402@option{-finline-functions}, and @option{-fipa-bit-cp}.
16403
16404If @var{path} is specified, GCC looks at the @var{path} to find
16405the profile feedback data files. See @option{-fprofile-dir}.
16406
16407To optimize the program based on the collected profile information, use
16408@option{-fprofile-use}. @xref{Optimize Options}, for more information.
16409
16410@item -fprofile-info-section
16411@itemx -fprofile-info-section=@var{name}
16412@opindex fprofile-info-section
16413
16414Register the profile information in the specified section instead of using a
16415constructor/destructor. The section name is @var{name} if it is specified,
16416otherwise the section name defaults to @code{.gcov_info}. A pointer to the
16417profile information generated by @option{-fprofile-arcs} is placed in the
16418specified section for each translation unit. This option disables the profile
16419information registration through a constructor and it disables the profile
16420information processing through a destructor. This option is not intended to be
16421used in hosted environments such as GNU/Linux. It targets freestanding
16422environments (for example embedded systems) with limited resources which do not
16423support constructors/destructors or the C library file I/O.
16424
16425The linker could collect the input sections in a continuous memory block and
16426define start and end symbols. A GNU linker script example which defines a
16427linker output section follows:
16428
16429@smallexample
16430 .gcov_info :
16431 @{
16432 PROVIDE (__gcov_info_start = .);
16433 KEEP (*(.gcov_info))
16434 PROVIDE (__gcov_info_end = .);
16435 @}
16436@end smallexample
16437
16438The program could dump the profiling information registered in this linker set
16439for example like this:
16440
16441@smallexample
16442#include <gcov.h>
16443#include <stdio.h>
16444#include <stdlib.h>
16445
16446extern const struct gcov_info *const __gcov_info_start[];
16447extern const struct gcov_info *const __gcov_info_end[];
16448
16449static void
16450dump (const void *d, unsigned n, void *arg)
16451@{
16452 const unsigned char *c = d;
16453
16454 for (unsigned i = 0; i < n; ++i)
16455 printf ("%02x", c[i]);
16456@}
16457
16458static void
16459filename (const char *f, void *arg)
16460@{
16461 __gcov_filename_to_gcfn (f, dump, arg );
16462@}
16463
16464static void *
16465allocate (unsigned length, void *arg)
16466@{
16467 return malloc (length);
16468@}
16469
16470static void
16471dump_gcov_info (void)
16472@{
16473 const struct gcov_info *const *info = __gcov_info_start;
16474 const struct gcov_info *const *end = __gcov_info_end;
16475
16476 /* Obfuscate variable to prevent compiler optimizations. */
16477 __asm__ ("" : "+r" (info));
16478
16479 while (info != end)
16480 @{
16481 void *arg = NULL;
16482 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
16483 putchar ('\n');
16484 ++info;
16485 @}
16486@}
16487
16488int
16489main (void)
16490@{
16491 dump_gcov_info ();
16492 return 0;
16493@}
16494@end smallexample
16495
16496The @command{merge-stream} subcommand of @command{gcov-tool} may be used to
16497deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and
16498@code{__gcov_info_to_gcda} functions and merge the profile information into
16499@file{.gcda} files on the host filesystem.
16500
16501@item -fprofile-note=@var{path}
16502@opindex fprofile-note
16503
16504If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
16505location. If you combine the option with multiple source files,
16506the @file{.gcno} file will be overwritten.
16507
16508@item -fprofile-prefix-path=@var{path}
16509@opindex fprofile-prefix-path
16510
16511This option can be used in combination with
16512@option{profile-generate=}@var{profile_dir} and
16513@option{profile-use=}@var{profile_dir} to inform GCC where is the base
16514directory of built source tree. By default @var{profile_dir} will contain
16515files with mangled absolute paths of all object files in the built project.
16516This is not desirable when directory used to build the instrumented binary
16517differs from the directory used to build the binary optimized with profile
16518feedback because the profile data will not be found during the optimized build.
16519In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
16520pointing to the base directory of the build can be used to strip the irrelevant
16521part of the path and keep all file names relative to the main build directory.
16522
16523@item -fprofile-prefix-map=@var{old}=@var{new}
16524@opindex fprofile-prefix-map
16525When compiling files residing in directory @file{@var{old}}, record
16526profiling information (with @option{--coverage})
16527describing them as if the files resided in
16528directory @file{@var{new}} instead.
16529See also @option{-ffile-prefix-map}.
16530
16531@item -fprofile-update=@var{method}
16532@opindex fprofile-update
16533
16534Alter the update method for an application instrumented for profile
16535feedback based optimization. The @var{method} argument should be one of
16536@samp{single}, @samp{atomic} or @samp{prefer-atomic}.
16537The first one is useful for single-threaded applications,
16538while the second one prevents profile corruption by emitting thread-safe code.
16539
16540@strong{Warning:} When an application does not properly join all threads
16541(or creates an detached thread), a profile file can be still corrupted.
16542
16543Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
16544when supported by a target, or to @samp{single} otherwise. The GCC driver
16545automatically selects @samp{prefer-atomic} when @option{-pthread}
16546is present in the command line.
16547
16548@item -fprofile-filter-files=@var{regex}
16549@opindex fprofile-filter-files
16550
16551Instrument only functions from files whose name matches
16552any of the regular expressions (separated by semi-colons).
16553
16554For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
16555only @file{main.c} and all C files starting with 'module'.
16556
16557@item -fprofile-exclude-files=@var{regex}
16558@opindex fprofile-exclude-files
16559
16560Instrument only functions from files whose name does not match
16561any of the regular expressions (separated by semi-colons).
16562
16563For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
16564of all files that are located in the @file{/usr/} folder.
16565
16566@item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
16567@opindex fprofile-reproducible
16568Control level of reproducibility of profile gathered by
16569@code{-fprofile-generate}. This makes it possible to rebuild program
16570with same outcome which is useful, for example, for distribution
16571packages.
16572
16573With @option{-fprofile-reproducible=serial} the profile gathered by
16574@option{-fprofile-generate} is reproducible provided the trained program
16575behaves the same at each invocation of the train run, it is not
16576multi-threaded and profile data streaming is always done in the same
16577order. Note that profile streaming happens at the end of program run but
16578also before @code{fork} function is invoked.
16579
16580Note that it is quite common that execution counts of some part of
16581programs depends, for example, on length of temporary file names or
16582memory space randomization (that may affect hash-table collision rate).
16583Such non-reproducible part of programs may be annotated by
16584@code{no_instrument_function} function attribute. @command{gcov-dump} with
16585@option{-l} can be used to dump gathered data and verify that they are
16586indeed reproducible.
16587
16588With @option{-fprofile-reproducible=parallel-runs} collected profile
16589stays reproducible regardless the order of streaming of the data into
16590gcda files. This setting makes it possible to run multiple instances of
16591instrumented program in parallel (such as with @code{make -j}). This
16592reduces quality of gathered data, in particular of indirect call
16593profiling.
16594
16595@item -fsanitize=address
16596@opindex fsanitize=address
16597Enable AddressSanitizer, a fast memory error detector.
16598Memory access instructions are instrumented to detect
16599out-of-bounds and use-after-free bugs.
16600The option enables @option{-fsanitize-address-use-after-scope}.
16601See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
16602more details. The run-time behavior can be influenced using the
16603@env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
16604the available options are shown at startup of the instrumented program. See
16605@url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
16606for a list of supported options.
16607The option cannot be combined with @option{-fsanitize=thread} or
16608@option{-fsanitize=hwaddress}. Note that the only target
16609@option{-fsanitize=hwaddress} is currently supported on is AArch64.
16610
6a07798c
MP
16611To get more accurate stack traces, it is possible to use options such as
16612@option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent
16613most function inlining), @option{-fno-optimize-sibling-calls} (which prevents
16614optimizing sibling and tail recursive calls; this option is implicit for
16615@option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which
16616disables Identical Code Folding for functions). Since multiple runs of the
16617program may yield backtraces with different addresses due to ASLR (Address
16618Space Layout Randomization), it may be desirable to turn ASLR off. On Linux,
16619this can be achieved with @samp{setarch `uname -m` -R ./prog}.
16620
d77de738
ML
16621@item -fsanitize=kernel-address
16622@opindex fsanitize=kernel-address
16623Enable AddressSanitizer for Linux kernel.
a0bf71be 16624See @uref{https://github.com/google/kernel-sanitizers} for more details.
d77de738
ML
16625
16626@item -fsanitize=hwaddress
16627@opindex fsanitize=hwaddress
16628Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
16629ignore the top byte of a pointer to allow the detection of memory errors with
16630a low memory overhead.
16631Memory access instructions are instrumented to detect out-of-bounds and
16632use-after-free bugs.
16633The option enables @option{-fsanitize-address-use-after-scope}.
16634See
16635@uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
16636for more details. The run-time behavior can be influenced using the
16637@env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
16638the available options are shown at startup of the instrumented program.
16639The option cannot be combined with @option{-fsanitize=thread} or
16640@option{-fsanitize=address}, and is currently only available on AArch64.
16641
16642@item -fsanitize=kernel-hwaddress
16643@opindex fsanitize=kernel-hwaddress
16644Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
16645Similar to @option{-fsanitize=kernel-address} but using an alternate
16646instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
16647instrumentation differences necessary for compiling the Linux kernel.
16648These differences are to avoid hwasan library initialization calls and to
16649account for the stack pointer having a different value in its top byte.
16650
16651@emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
16652Instrumenting the stack and alloca calls are not on by default but are still
16653possible by specifying the command-line options
16654@option{--param hwasan-instrument-stack=1} and
16655@option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
16656tag is not implemented for kernel instrumentation.
16657
16658@item -fsanitize=pointer-compare
16659@opindex fsanitize=pointer-compare
16660Instrument comparison operation (<, <=, >, >=) with pointer operands.
16661The option must be combined with either @option{-fsanitize=kernel-address} or
16662@option{-fsanitize=address}
16663The option cannot be combined with @option{-fsanitize=thread}.
16664Note: By default the check is disabled at run time. To enable it,
16665add @code{detect_invalid_pointer_pairs=2} to the environment variable
16666@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16667invalid operation only when both pointers are non-null.
16668
16669@item -fsanitize=pointer-subtract
16670@opindex fsanitize=pointer-subtract
16671Instrument subtraction with pointer operands.
16672The option must be combined with either @option{-fsanitize=kernel-address} or
16673@option{-fsanitize=address}
16674The option cannot be combined with @option{-fsanitize=thread}.
16675Note: By default the check is disabled at run time. To enable it,
16676add @code{detect_invalid_pointer_pairs=2} to the environment variable
16677@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16678invalid operation only when both pointers are non-null.
16679
16680@item -fsanitize=shadow-call-stack
16681@opindex fsanitize=shadow-call-stack
16682Enable ShadowCallStack, a security enhancement mechanism used to protect
16683programs against return address overwrites (e.g. stack buffer overflows.)
16684It works by saving a function's return address to a separately allocated
16685shadow call stack in the function prologue and restoring the return address
16686from the shadow call stack in the function epilogue. Instrumentation only
16687occurs in functions that need to save the return address to the stack.
16688
16689Currently it only supports the aarch64 platform. It is specifically
16690designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option.
16691For the user space programs, runtime support is not currently provided
16692in libc and libgcc. Users who want to use this feature in user space need
16693to provide their own support for the runtime. It should be noted that
16694this may cause the ABI rules to be broken.
16695
16696On aarch64, the instrumentation makes use of the platform register @code{x18}.
16697This generally means that any code that may run on the same thread as code
16698compiled with ShadowCallStack must be compiled with the flag
16699@option{-ffixed-x18}, otherwise functions compiled without
16700@option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow
16701stack pointer.
16702
16703Also, because there is no userspace runtime support, code compiled with
16704ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions}
16705to turn off exceptions.
16706
16707See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more
16708details.
16709
16710@item -fsanitize=thread
16711@opindex fsanitize=thread
16712Enable ThreadSanitizer, a fast data race detector.
16713Memory access instructions are instrumented to detect
16714data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
16715details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
16716environment variable; see
16717@url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
16718supported options.
16719The option cannot be combined with @option{-fsanitize=address},
16720@option{-fsanitize=leak}.
16721
16722Note that sanitized atomic builtins cannot throw exceptions when
16723operating on invalid memory addresses with non-call exceptions
16724(@option{-fnon-call-exceptions}).
16725
16726@item -fsanitize=leak
16727@opindex fsanitize=leak
16728Enable LeakSanitizer, a memory leak detector.
16729This option only matters for linking of executables and
16730the executable is linked against a library that overrides @code{malloc}
16731and other allocator functions. See
16732@uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
16733details. The run-time behavior can be influenced using the
16734@env{LSAN_OPTIONS} environment variable.
16735The option cannot be combined with @option{-fsanitize=thread}.
16736
16737@item -fsanitize=undefined
16738@opindex fsanitize=undefined
16739Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
16740Various computations are instrumented to detect undefined behavior
16741at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
16742@env{UBSAN_OPTIONS} environment variable. Current suboptions are:
16743
16744@table @gcctabopt
16745
16746@item -fsanitize=shift
16747@opindex fsanitize=shift
16748This option enables checking that the result of a shift operation is
16749not undefined. Note that what exactly is considered undefined differs
16750slightly between C and C++, as well as between ISO C90 and C99, etc.
16751This option has two suboptions, @option{-fsanitize=shift-base} and
16752@option{-fsanitize=shift-exponent}.
16753
16754@item -fsanitize=shift-exponent
16755@opindex fsanitize=shift-exponent
16756This option enables checking that the second argument of a shift operation
16757is not negative and is smaller than the precision of the promoted first
16758argument.
16759
16760@item -fsanitize=shift-base
16761@opindex fsanitize=shift-base
16762If the second argument of a shift operation is within range, check that the
16763result of a shift operation is not undefined. Note that what exactly is
16764considered undefined differs slightly between C and C++, as well as between
16765ISO C90 and C99, etc.
16766
16767@item -fsanitize=integer-divide-by-zero
16768@opindex fsanitize=integer-divide-by-zero
16769Detect integer division by zero.
16770
16771@item -fsanitize=unreachable
16772@opindex fsanitize=unreachable
16773With this option, the compiler turns the @code{__builtin_unreachable}
16774call into a diagnostics message call instead. When reaching the
16775@code{__builtin_unreachable} call, the behavior is undefined.
16776
16777@item -fsanitize=vla-bound
16778@opindex fsanitize=vla-bound
16779This option instructs the compiler to check that the size of a variable
16780length array is positive.
16781
16782@item -fsanitize=null
16783@opindex fsanitize=null
16784This option enables pointer checking. Particularly, the application
16785built with this option turned on will issue an error message when it
16786tries to dereference a NULL pointer, or if a reference (possibly an
16787rvalue reference) is bound to a NULL pointer, or if a method is invoked
16788on an object pointed by a NULL pointer.
16789
16790@item -fsanitize=return
16791@opindex fsanitize=return
16792This option enables return statement checking. Programs
16793built with this option turned on will issue an error message
16794when the end of a non-void function is reached without actually
16795returning a value. This option works in C++ only.
16796
16797@item -fsanitize=signed-integer-overflow
16798@opindex fsanitize=signed-integer-overflow
16799This option enables signed integer overflow checking. We check that
16800the result of @code{+}, @code{*}, and both unary and binary @code{-}
16801does not overflow in the signed arithmetics. This also detects
16802@code{INT_MIN / -1} signed division. Note, integer promotion
16803rules must be taken into account. That is, the following is not an
16804overflow:
16805@smallexample
16806signed char a = SCHAR_MAX;
16807a++;
16808@end smallexample
16809
16810@item -fsanitize=bounds
16811@opindex fsanitize=bounds
16812This option enables instrumentation of array bounds. Various out of bounds
16813accesses are detected. Flexible array members, flexible array member-like
16814arrays, and initializers of variables with static storage are not instrumented.
16815
16816@item -fsanitize=bounds-strict
16817@opindex fsanitize=bounds-strict
16818This option enables strict instrumentation of array bounds. Most out of bounds
16819accesses are detected, including flexible array members and flexible array
16820member-like arrays. Initializers of variables with static storage are not
16821instrumented.
16822
16823@item -fsanitize=alignment
16824@opindex fsanitize=alignment
16825
16826This option enables checking of alignment of pointers when they are
16827dereferenced, or when a reference is bound to insufficiently aligned target,
16828or when a method or constructor is invoked on insufficiently aligned object.
16829
16830@item -fsanitize=object-size
16831@opindex fsanitize=object-size
16832This option enables instrumentation of memory references using the
7283380a
SP
16833@code{__builtin_dynamic_object_size} function. Various out of bounds
16834pointer accesses are detected.
d77de738
ML
16835
16836@item -fsanitize=float-divide-by-zero
16837@opindex fsanitize=float-divide-by-zero
16838Detect floating-point division by zero. Unlike other similar options,
16839@option{-fsanitize=float-divide-by-zero} is not enabled by
16840@option{-fsanitize=undefined}, since floating-point division by zero can
16841be a legitimate way of obtaining infinities and NaNs.
16842
16843@item -fsanitize=float-cast-overflow
16844@opindex fsanitize=float-cast-overflow
16845This option enables floating-point type to integer conversion checking.
16846We check that the result of the conversion does not overflow.
16847Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
16848not enabled by @option{-fsanitize=undefined}.
16849This option does not work well with @code{FE_INVALID} exceptions enabled.
16850
16851@item -fsanitize=nonnull-attribute
16852@opindex fsanitize=nonnull-attribute
16853
16854This option enables instrumentation of calls, checking whether null values
16855are not passed to arguments marked as requiring a non-null value by the
16856@code{nonnull} function attribute.
16857
16858@item -fsanitize=returns-nonnull-attribute
16859@opindex fsanitize=returns-nonnull-attribute
16860
16861This option enables instrumentation of return statements in functions
16862marked with @code{returns_nonnull} function attribute, to detect returning
16863of null values from such functions.
16864
16865@item -fsanitize=bool
16866@opindex fsanitize=bool
16867
16868This option enables instrumentation of loads from bool. If a value other
16869than 0/1 is loaded, a run-time error is issued.
16870
16871@item -fsanitize=enum
16872@opindex fsanitize=enum
16873
16874This option enables instrumentation of loads from an enum type. If
16875a value outside the range of values for the enum type is loaded,
16876a run-time error is issued.
16877
16878@item -fsanitize=vptr
16879@opindex fsanitize=vptr
16880
16881This option enables instrumentation of C++ member function calls, member
16882accesses and some conversions between pointers to base and derived classes,
16883to verify the referenced object has the correct dynamic type.
16884
16885@item -fsanitize=pointer-overflow
16886@opindex fsanitize=pointer-overflow
16887
16888This option enables instrumentation of pointer arithmetics. If the pointer
16889arithmetics overflows, a run-time error is issued.
16890
16891@item -fsanitize=builtin
16892@opindex fsanitize=builtin
16893
16894This option enables instrumentation of arguments to selected builtin
16895functions. If an invalid value is passed to such arguments, a run-time
16896error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
16897or @code{__builtin_clz} invokes undefined behavior and is diagnosed
16898by this option.
16899
16900@end table
16901
16902Note that sanitizers tend to increase the rate of false positive
16903warnings, most notably those around @option{-Wmaybe-uninitialized}.
16904We recommend against combining @option{-Werror} and [the use of]
16905sanitizers.
16906
16907While @option{-ftrapv} causes traps for signed overflows to be emitted,
16908@option{-fsanitize=undefined} gives a diagnostic message.
16909This currently works only for the C family of languages.
16910
16911@item -fno-sanitize=all
16912@opindex fno-sanitize=all
16913
16914This option disables all previously enabled sanitizers.
16915@option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
16916together.
16917
16918@item -fasan-shadow-offset=@var{number}
16919@opindex fasan-shadow-offset
16920This option forces GCC to use custom shadow offset in AddressSanitizer checks.
16921It is useful for experimenting with different shadow memory layouts in
16922Kernel AddressSanitizer.
16923
16924@item -fsanitize-sections=@var{s1},@var{s2},...
16925@opindex fsanitize-sections
16926Sanitize global variables in selected user-defined sections. @var{si} may
16927contain wildcards.
16928
16929@item -fsanitize-recover@r{[}=@var{opts}@r{]}
16930@opindex fsanitize-recover
16931@opindex fno-sanitize-recover
16932@option{-fsanitize-recover=} controls error recovery mode for sanitizers
16933mentioned in comma-separated list of @var{opts}. Enabling this option
16934for a sanitizer component causes it to attempt to continue
16935running the program as if no error happened. This means multiple
16936runtime errors can be reported in a single program run, and the exit
16937code of the program may indicate success even when errors
16938have been reported. The @option{-fno-sanitize-recover=} option
16939can be used to alter
16940this behavior: only the first detected error is reported
16941and program then exits with a non-zero exit code.
16942
16943Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
16944except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
16945@option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
16946@option{-fsanitize=bounds-strict},
16947@option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
16948For these sanitizers error recovery is turned on by default,
16949except @option{-fsanitize=address}, for which this feature is experimental.
16950@option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
16951accepted, the former enables recovery for all sanitizers that support it,
16952the latter disables recovery for all sanitizers that support it.
16953
16954Even if a recovery mode is turned on the compiler side, it needs to be also
16955enabled on the runtime library side, otherwise the failures are still fatal.
16956The runtime library defaults to @code{halt_on_error=0} for
16957ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
16958AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
16959setting the @code{halt_on_error} flag in the corresponding environment variable.
16960
16961Syntax without an explicit @var{opts} parameter is deprecated. It is
16962equivalent to specifying an @var{opts} list of:
16963
16964@smallexample
16965undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
16966@end smallexample
16967
16968@item -fsanitize-address-use-after-scope
16969@opindex fsanitize-address-use-after-scope
16970Enable sanitization of local variables to detect use-after-scope bugs.
16971The option sets @option{-fstack-reuse} to @samp{none}.
16972
16973@item -fsanitize-trap@r{[}=@var{opts}@r{]}
16974@opindex fsanitize-trap
16975@opindex fno-sanitize-trap
16976The @option{-fsanitize-trap=} option instructs the compiler to
16977report for sanitizers mentioned in comma-separated list of @var{opts}
16978undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
16979library routine. If this option is enabled for certain sanitizer,
16980it takes precedence over the @option{-fsanitizer-recover=} for that
16981sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
16982of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
16983
16984The advantage of this is that the @code{libubsan} library is not needed
16985and is not linked in, so this is usable even in freestanding environments.
16986
16987Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
16988except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
16989@option{-fsanitize=float-divide-by-zero} and
16990@option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
16991specified, which enables it for @code{undefined} suboptions,
16992@option{-fsanitize=float-cast-overflow},
16993@option{-fsanitize=float-divide-by-zero} and
16994@option{-fsanitize=bounds-strict}.
16995If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
16996and @code{-fsanitize=vptr} is enabled on the command line, the
16997instrumentation is silently ignored as the instrumentation always needs
16998@code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
16999
17000@item -fsanitize-undefined-trap-on-error
17001@opindex fsanitize-undefined-trap-on-error
17002The @option{-fsanitize-undefined-trap-on-error} option is deprecated
17003equivalent of @option{-fsanitize-trap=all}.
17004
17005@item -fsanitize-coverage=trace-pc
17006@opindex fsanitize-coverage=trace-pc
17007Enable coverage-guided fuzzing code instrumentation.
17008Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
17009
17010@item -fsanitize-coverage=trace-cmp
17011@opindex fsanitize-coverage=trace-cmp
17012Enable dataflow guided fuzzing code instrumentation.
17013Inserts a call to @code{__sanitizer_cov_trace_cmp1},
17014@code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
17015@code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
17016variable or @code{__sanitizer_cov_trace_const_cmp1},
17017@code{__sanitizer_cov_trace_const_cmp2},
17018@code{__sanitizer_cov_trace_const_cmp4} or
17019@code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
17020operand constant, @code{__sanitizer_cov_trace_cmpf} or
17021@code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
17022@code{__sanitizer_cov_trace_switch} for switch statements.
17023
17024@item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
17025@opindex fcf-protection
17026Enable code instrumentation of control-flow transfers to increase
17027program security by checking that target addresses of control-flow
17028transfer instructions (such as indirect function call, function return,
17029indirect jump) are valid. This prevents diverting the flow of control
17030to an unexpected target. This is intended to protect against such
17031threats as Return-oriented Programming (ROP), and similarly
17032call/jmp-oriented programming (COP/JOP).
17033
17034The value @code{branch} tells the compiler to implement checking of
17035validity of control-flow transfer at the point of indirect branch
17036instructions, i.e.@: call/jmp instructions. The value @code{return}
17037implements checking of validity at the point of returning from a
17038function. The value @code{full} is an alias for specifying both
17039@code{branch} and @code{return}. The value @code{none} turns off
17040instrumentation.
17041
17042The value @code{check} is used for the final link with link-time
17043optimization (LTO). An error is issued if LTO object files are
17044compiled with different @option{-fcf-protection} values. The
17045value @code{check} is ignored at the compile time.
17046
17047The macro @code{__CET__} is defined when @option{-fcf-protection} is
17048used. The first bit of @code{__CET__} is set to 1 for the value
17049@code{branch} and the second bit of @code{__CET__} is set to 1 for
17050the @code{return}.
17051
17052You can also use the @code{nocf_check} attribute to identify
17053which functions and calls should be skipped from instrumentation
17054(@pxref{Function Attributes}).
17055
17056Currently the x86 GNU/Linux target provides an implementation based
17057on Intel Control-flow Enforcement Technology (CET) which works for
17058i686 processor or newer.
17059
17060@item -fharden-compares
17061@opindex fharden-compares
17062For every logical test that survives gimple optimizations and is
17063@emph{not} the condition in a conditional branch (for example,
17064conditions tested for conditional moves, or to store in boolean
17065variables), emit extra code to compute and verify the reversed
17066condition, and to call @code{__builtin_trap} if the results do not
17067match. Use with @samp{-fharden-conditional-branches} to cover all
17068conditionals.
17069
17070@item -fharden-conditional-branches
17071@opindex fharden-conditional-branches
17072For every non-vectorized conditional branch that survives gimple
17073optimizations, emit extra code to compute and verify the reversed
17074condition, and to call @code{__builtin_trap} if the result is
17075unexpected. Use with @samp{-fharden-compares} to cover all
17076conditionals.
17077
17078@item -fstack-protector
17079@opindex fstack-protector
17080Emit extra code to check for buffer overflows, such as stack smashing
17081attacks. This is done by adding a guard variable to functions with
17082vulnerable objects. This includes functions that call @code{alloca}, and
17083functions with buffers larger than or equal to 8 bytes. The guards are
17084initialized when a function is entered and then checked when the function
17085exits. If a guard check fails, an error message is printed and the program
17086exits. Only variables that are actually allocated on the stack are
17087considered, optimized away variables or variables allocated in registers
17088don't count.
17089
17090@item -fstack-protector-all
17091@opindex fstack-protector-all
17092Like @option{-fstack-protector} except that all functions are protected.
17093
17094@item -fstack-protector-strong
17095@opindex fstack-protector-strong
17096Like @option{-fstack-protector} but includes additional functions to
17097be protected --- those that have local array definitions, or have
17098references to local frame addresses. Only variables that are actually
17099allocated on the stack are considered, optimized away variables or variables
17100allocated in registers don't count.
17101
17102@item -fstack-protector-explicit
17103@opindex fstack-protector-explicit
17104Like @option{-fstack-protector} but only protects those functions which
17105have the @code{stack_protect} attribute.
17106
17107@item -fstack-check
17108@opindex fstack-check
17109Generate code to verify that you do not go beyond the boundary of the
17110stack. You should specify this flag if you are running in an
17111environment with multiple threads, but you only rarely need to specify it in
17112a single-threaded environment since stack overflow is automatically
17113detected on nearly all systems if there is only one stack.
17114
17115Note that this switch does not actually cause checking to be done; the
17116operating system or the language runtime must do that. The switch causes
17117generation of code to ensure that they see the stack being extended.
17118
17119You can additionally specify a string parameter: @samp{no} means no
17120checking, @samp{generic} means force the use of old-style checking,
17121@samp{specific} means use the best checking method and is equivalent
17122to bare @option{-fstack-check}.
17123
17124Old-style checking is a generic mechanism that requires no specific
17125target support in the compiler but comes with the following drawbacks:
17126
17127@enumerate
17128@item
17129Modified allocation strategy for large objects: they are always
17130allocated dynamically if their size exceeds a fixed threshold. Note this
17131may change the semantics of some code.
17132
17133@item
17134Fixed limit on the size of the static frame of functions: when it is
17135topped by a particular function, stack checking is not reliable and
17136a warning is issued by the compiler.
17137
17138@item
17139Inefficiency: because of both the modified allocation strategy and the
17140generic implementation, code performance is hampered.
17141@end enumerate
17142
17143Note that old-style stack checking is also the fallback method for
17144@samp{specific} if no target support has been added in the compiler.
17145
17146@samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
17147and stack overflows. @samp{specific} is an excellent choice when compiling
17148Ada code. It is not generally sufficient to protect against stack-clash
17149attacks. To protect against those you want @samp{-fstack-clash-protection}.
17150
17151@item -fstack-clash-protection
17152@opindex fstack-clash-protection
17153Generate code to prevent stack clash style attacks. When this option is
17154enabled, the compiler will only allocate one page of stack space at a time
17155and each page is accessed immediately after allocation. Thus, it prevents
17156allocations from jumping over any stack guard page provided by the
17157operating system.
17158
17159Most targets do not fully support stack clash protection. However, on
17160those targets @option{-fstack-clash-protection} will protect dynamic stack
17161allocations. @option{-fstack-clash-protection} may also provide limited
17162protection for static stack allocations if the target supports
17163@option{-fstack-check=specific}.
17164
17165@item -fstack-limit-register=@var{reg}
17166@itemx -fstack-limit-symbol=@var{sym}
17167@itemx -fno-stack-limit
17168@opindex fstack-limit-register
17169@opindex fstack-limit-symbol
17170@opindex fno-stack-limit
17171Generate code to ensure that the stack does not grow beyond a certain value,
17172either the value of a register or the address of a symbol. If a larger
17173stack is required, a signal is raised at run time. For most targets,
17174the signal is raised before the stack overruns the boundary, so
17175it is possible to catch the signal without taking special precautions.
17176
17177For instance, if the stack starts at absolute address @samp{0x80000000}
17178and grows downwards, you can use the flags
17179@option{-fstack-limit-symbol=__stack_limit} and
17180@option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
17181of 128KB@. Note that this may only work with the GNU linker.
17182
17183You can locally override stack limit checking by using the
17184@code{no_stack_limit} function attribute (@pxref{Function Attributes}).
17185
17186@item -fsplit-stack
17187@opindex fsplit-stack
17188Generate code to automatically split the stack before it overflows.
17189The resulting program has a discontiguous stack which can only
17190overflow if the program is unable to allocate any more memory. This
17191is most useful when running threaded programs, as it is no longer
17192necessary to calculate a good stack size to use for each thread. This
17193is currently only implemented for the x86 targets running
17194GNU/Linux.
17195
17196When code compiled with @option{-fsplit-stack} calls code compiled
17197without @option{-fsplit-stack}, there may not be much stack space
17198available for the latter code to run. If compiling all code,
17199including library code, with @option{-fsplit-stack} is not an option,
17200then the linker can fix up these calls so that the code compiled
17201without @option{-fsplit-stack} always has a large stack. Support for
17202this is implemented in the gold linker in GNU binutils release 2.21
17203and later.
17204
17205@item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
17206@opindex fvtable-verify
17207This option is only available when compiling C++ code.
17208It turns on (or off, if using @option{-fvtable-verify=none}) the security
17209feature that verifies at run time, for every virtual call, that
17210the vtable pointer through which the call is made is valid for the type of
17211the object, and has not been corrupted or overwritten. If an invalid vtable
17212pointer is detected at run time, an error is reported and execution of the
17213program is immediately halted.
17214
17215This option causes run-time data structures to be built at program startup,
17216which are used for verifying the vtable pointers.
17217The options @samp{std} and @samp{preinit}
17218control the timing of when these data structures are built. In both cases the
17219data structures are built before execution reaches @code{main}. Using
17220@option{-fvtable-verify=std} causes the data structures to be built after
17221shared libraries have been loaded and initialized.
17222@option{-fvtable-verify=preinit} causes them to be built before shared
17223libraries have been loaded and initialized.
17224
17225If this option appears multiple times in the command line with different
17226values specified, @samp{none} takes highest priority over both @samp{std} and
17227@samp{preinit}; @samp{preinit} takes priority over @samp{std}.
17228
17229@item -fvtv-debug
17230@opindex fvtv-debug
17231When used in conjunction with @option{-fvtable-verify=std} or
17232@option{-fvtable-verify=preinit}, causes debug versions of the
17233runtime functions for the vtable verification feature to be called.
17234This flag also causes the compiler to log information about which
17235vtable pointers it finds for each class.
17236This information is written to a file named @file{vtv_set_ptr_data.log}
17237in the directory named by the environment variable @env{VTV_LOGS_DIR}
17238if that is defined or the current working directory otherwise.
17239
17240Note: This feature @emph{appends} data to the log file. If you want a fresh log
17241file, be sure to delete any existing one.
17242
17243@item -fvtv-counts
17244@opindex fvtv-counts
17245This is a debugging flag. When used in conjunction with
17246@option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
17247causes the compiler to keep track of the total number of virtual calls
17248it encounters and the number of verifications it inserts. It also
17249counts the number of calls to certain run-time library functions
17250that it inserts and logs this information for each compilation unit.
17251The compiler writes this information to a file named
17252@file{vtv_count_data.log} in the directory named by the environment
17253variable @env{VTV_LOGS_DIR} if that is defined or the current working
17254directory otherwise. It also counts the size of the vtable pointer sets
17255for each class, and writes this information to @file{vtv_class_set_sizes.log}
17256in the same directory.
17257
17258Note: This feature @emph{appends} data to the log files. To get fresh log
17259files, be sure to delete any existing ones.
17260
17261@item -finstrument-functions
17262@opindex finstrument-functions
17263Generate instrumentation calls for entry and exit to functions. Just
17264after function entry and just before function exit, the following
17265profiling functions are called with the address of the current
17266function and its call site. (On some platforms,
17267@code{__builtin_return_address} does not work beyond the current
17268function, so the call site information may not be available to the
17269profiling functions otherwise.)
17270
17271@smallexample
17272void __cyg_profile_func_enter (void *this_fn,
17273 void *call_site);
17274void __cyg_profile_func_exit (void *this_fn,
17275 void *call_site);
17276@end smallexample
17277
17278The first argument is the address of the start of the current function,
17279which may be looked up exactly in the symbol table.
17280
17281This instrumentation is also done for functions expanded inline in other
17282functions. The profiling calls indicate where, conceptually, the
17283inline function is entered and exited. This means that addressable
17284versions of such functions must be available. If all your uses of a
17285function are expanded inline, this may mean an additional expansion of
17286code size. If you use @code{extern inline} in your C code, an
17287addressable version of such functions must be provided. (This is
17288normally the case anyway, but if you get lucky and the optimizer always
17289expands the functions inline, you might have gotten away without
17290providing static copies.)
17291
17292A function may be given the attribute @code{no_instrument_function}, in
17293which case this instrumentation is not done. This can be used, for
17294example, for the profiling functions listed above, high-priority
17295interrupt routines, and any functions from which the profiling functions
17296cannot safely be called (perhaps signal handlers, if the profiling
17297routines generate output or allocate memory).
17298@xref{Common Function Attributes}.
17299
17300@item -finstrument-functions-once
9c19597c 17301@opindex finstrument-functions-once
d77de738
ML
17302This is similar to @option{-finstrument-functions}, but the profiling
17303functions are called only once per instrumented function, i.e. the first
17304profiling function is called after the first entry into the instrumented
17305function and the second profiling function is called before the exit
17306corresponding to this first entry.
17307
17308The definition of @code{once} for the purpose of this option is a little
17309vague because the implementation is not protected against data races.
17310As a result, the implementation only guarantees that the profiling
17311functions are called at @emph{least} once per process and at @emph{most}
17312once per thread, but the calls are always paired, that is to say, if a
17313thread calls the first function, then it will call the second function,
17314unless it never reaches the exit of the instrumented function.
17315
17316@item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
17317@opindex finstrument-functions-exclude-file-list
17318
17319Set the list of functions that are excluded from instrumentation (see
17320the description of @option{-finstrument-functions}). If the file that
17321contains a function definition matches with one of @var{file}, then
17322that function is not instrumented. The match is done on substrings:
17323if the @var{file} parameter is a substring of the file name, it is
17324considered to be a match.
17325
17326For example:
17327
17328@smallexample
17329-finstrument-functions-exclude-file-list=/bits/stl,include/sys
17330@end smallexample
17331
17332@noindent
17333excludes any inline function defined in files whose pathnames
17334contain @file{/bits/stl} or @file{include/sys}.
17335
17336If, for some reason, you want to include letter @samp{,} in one of
17337@var{sym}, write @samp{\,}. For example,
17338@option{-finstrument-functions-exclude-file-list='\,\,tmp'}
17339(note the single quote surrounding the option).
17340
17341@item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
17342@opindex finstrument-functions-exclude-function-list
17343
17344This is similar to @option{-finstrument-functions-exclude-file-list},
17345but this option sets the list of function names to be excluded from
17346instrumentation. The function name to be matched is its user-visible
17347name, such as @code{vector<int> blah(const vector<int> &)}, not the
17348internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
17349match is done on substrings: if the @var{sym} parameter is a substring
17350of the function name, it is considered to be a match. For C99 and C++
17351extended identifiers, the function name must be given in UTF-8, not
17352using universal character names.
17353
17354@item -fpatchable-function-entry=@var{N}[,@var{M}]
17355@opindex fpatchable-function-entry
17356Generate @var{N} NOPs right at the beginning
17357of each function, with the function entry point before the @var{M}th NOP.
17358If @var{M} is omitted, it defaults to @code{0} so the
17359function entry points to the address just at the first NOP.
17360The NOP instructions reserve extra space which can be used to patch in
17361any desired instrumentation at run time, provided that the code segment
17362is writable. The amount of space is controllable indirectly via
17363the number of NOPs; the NOP instruction used corresponds to the instruction
17364emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
17365is target-specific and may also depend on the architecture variant and/or
17366other compilation options.
17367
17368For run-time identification, the starting addresses of these areas,
17369which correspond to their respective function entries minus @var{M},
17370are additionally collected in the @code{__patchable_function_entries}
17371section of the resulting binary.
17372
17373Note that the value of @code{__attribute__ ((patchable_function_entry
17374(N,M)))} takes precedence over command-line option
17375@option{-fpatchable-function-entry=N,M}. This can be used to increase
17376the area size or to remove it completely on a single function.
17377If @code{N=0}, no pad location is recorded.
17378
17379The NOP instructions are inserted at---and maybe before, depending on
17380@var{M}---the function entry address, even before the prologue. On
17381PowerPC with the ELFv2 ABI, for a function with dual entry points,
17382the local entry point is this function entry address.
17383
17384The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the
17385ELFv2 ABI, for a function with dual entry points, the supported values
17386for @var{M} are 0, 2, 6 and 14.
17387@end table
17388
17389
17390@node Preprocessor Options
17391@section Options Controlling the Preprocessor
17392@cindex preprocessor options
17393@cindex options, preprocessor
17394
17395These options control the C preprocessor, which is run on each C source
17396file before actual compilation.
17397
17398If you use the @option{-E} option, nothing is done except preprocessing.
17399Some of these options make sense only together with @option{-E} because
17400they cause the preprocessor output to be unsuitable for actual
17401compilation.
17402
17403In addition to the options listed here, there are a number of options
17404to control search paths for include files documented in
17405@ref{Directory Options}.
17406Options to control preprocessor diagnostics are listed in
17407@ref{Warning Options}.
17408
17409@table @gcctabopt
17410@include cppopts.texi
17411
17412@item -Wp,@var{option}
17413@opindex Wp
17414You can use @option{-Wp,@var{option}} to bypass the compiler driver
17415and pass @var{option} directly through to the preprocessor. If
17416@var{option} contains commas, it is split into multiple options at the
17417commas. However, many options are modified, translated or interpreted
17418by the compiler driver before being passed to the preprocessor, and
17419@option{-Wp} forcibly bypasses this phase. The preprocessor's direct
17420interface is undocumented and subject to change, so whenever possible
17421you should avoid using @option{-Wp} and let the driver handle the
17422options instead.
17423
17424@item -Xpreprocessor @var{option}
17425@opindex Xpreprocessor
17426Pass @var{option} as an option to the preprocessor. You can use this to
17427supply system-specific preprocessor options that GCC does not
17428recognize.
17429
17430If you want to pass an option that takes an argument, you must use
17431@option{-Xpreprocessor} twice, once for the option and once for the argument.
17432
17433@item -no-integrated-cpp
17434@opindex no-integrated-cpp
17435Perform preprocessing as a separate pass before compilation.
17436By default, GCC performs preprocessing as an integrated part of
17437input tokenization and parsing.
17438If this option is provided, the appropriate language front end
17439(@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
17440and Objective-C, respectively) is instead invoked twice,
17441once for preprocessing only and once for actual compilation
17442of the preprocessed input.
17443This option may be useful in conjunction with the @option{-B} or
17444@option{-wrapper} options to specify an alternate preprocessor or
17445perform additional processing of the program source between
17446normal preprocessing and compilation.
17447
17448@item -flarge-source-files
17449@opindex flarge-source-files
17450Adjust GCC to expect large source files, at the expense of slower
17451compilation and higher memory usage.
17452
17453Specifically, GCC normally tracks both column numbers and line numbers
17454within source files and it normally prints both of these numbers in
17455diagnostics. However, once it has processed a certain number of source
17456lines, it stops tracking column numbers and only tracks line numbers.
17457This means that diagnostics for later lines do not include column numbers.
17458It also means that options like @option{-Wmisleading-indentation} cease to work
17459at that point, although the compiler prints a note if this happens.
17460Passing @option{-flarge-source-files} significantly increases the number
17461of source lines that GCC can process before it stops tracking columns.
17462
17463@end table
17464
17465@node Assembler Options
17466@section Passing Options to the Assembler
17467
17468@c prevent bad page break with this line
17469You can pass options to the assembler.
17470
17471@table @gcctabopt
17472@item -Wa,@var{option}
17473@opindex Wa
17474Pass @var{option} as an option to the assembler. If @var{option}
17475contains commas, it is split into multiple options at the commas.
17476
17477@item -Xassembler @var{option}
17478@opindex Xassembler
17479Pass @var{option} as an option to the assembler. You can use this to
17480supply system-specific assembler options that GCC does not
17481recognize.
17482
17483If you want to pass an option that takes an argument, you must use
17484@option{-Xassembler} twice, once for the option and once for the argument.
17485
17486@end table
17487
17488@node Link Options
17489@section Options for Linking
17490@cindex link options
17491@cindex options, linking
17492
17493These options come into play when the compiler links object files into
17494an executable output file. They are meaningless if the compiler is
17495not doing a link step.
17496
17497@table @gcctabopt
17498@cindex file names
17499@item @var{object-file-name}
17500A file name that does not end in a special recognized suffix is
17501considered to name an object file or library. (Object files are
17502distinguished from libraries by the linker according to the file
17503contents.) If linking is done, these object files are used as input
17504to the linker.
17505
17506@item -c
17507@itemx -S
17508@itemx -E
17509@opindex c
17510@opindex S
17511@opindex E
17512If any of these options is used, then the linker is not run, and
17513object file names should not be used as arguments. @xref{Overall
17514Options}.
17515
17516@item -flinker-output=@var{type}
17517@opindex flinker-output
17518This option controls code generation of the link-time optimizer. By
17519default the linker output is automatically determined by the linker
17520plugin. For debugging the compiler and if incremental linking with a
17521non-LTO object file is desired, it may be useful to control the type
17522manually.
17523
17524If @var{type} is @samp{exec}, code generation produces a static
17525binary. In this case @option{-fpic} and @option{-fpie} are both
17526disabled.
17527
17528If @var{type} is @samp{dyn}, code generation produces a shared
17529library. In this case @option{-fpic} or @option{-fPIC} is preserved,
17530but not enabled automatically. This allows to build shared libraries
17531without position-independent code on architectures where this is
17532possible, i.e.@: on x86.
17533
17534If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
17535executable. This results in similar optimizations as @samp{exec}
17536except that @option{-fpie} is not disabled if specified at compilation
17537time.
17538
17539If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
17540done. The sections containing intermediate code for link-time optimization are
17541merged, pre-optimized, and output to the resulting object file. In addition, if
17542@option{-ffat-lto-objects} is specified, binary code is produced for future
17543non-LTO linking. The object file produced by incremental linking is smaller
17544than a static library produced from the same object files. At link time the
17545result of incremental linking also loads faster than a static
17546library assuming that the majority of objects in the library are used.
17547
17548Finally @samp{nolto-rel} configures the compiler for incremental linking where
17549code generation is forced, a final binary is produced, and the intermediate
17550code for later link-time optimization is stripped. When multiple object files
17551are linked together the resulting code is better optimized than with
17552link-time optimizations disabled (for example, cross-module inlining
17553happens), but most of benefits of whole program optimizations are lost.
17554
17555During the incremental link (by @option{-r}) the linker plugin defaults to
17556@option{rel}. With current interfaces to GNU Binutils it is however not
17557possible to incrementally link LTO objects and non-LTO objects into a single
17558mixed object file. If any of object files in incremental link cannot
17559be used for link-time optimization, the linker plugin issues a warning and
17560uses @samp{nolto-rel}. To maintain whole program optimization, it is
17561recommended to link such objects into static library instead. Alternatively it
17562is possible to use H.J. Lu's binutils with support for mixed objects.
17563
17564@item -fuse-ld=bfd
17565@opindex fuse-ld=bfd
17566Use the @command{bfd} linker instead of the default linker.
17567
17568@item -fuse-ld=gold
17569@opindex fuse-ld=gold
17570Use the @command{gold} linker instead of the default linker.
17571
17572@item -fuse-ld=lld
17573@opindex fuse-ld=lld
17574Use the LLVM @command{lld} linker instead of the default linker.
17575
17576@item -fuse-ld=mold
17577@opindex fuse-ld=mold
17578Use the Modern Linker (@command{mold}) instead of the default linker.
17579
17580@cindex Libraries
17581@item -l@var{library}
17582@itemx -l @var{library}
17583@opindex l
17584Search the library named @var{library} when linking. (The second
17585alternative with the library as a separate argument is only for
17586POSIX compliance and is not recommended.)
17587
17588The @option{-l} option is passed directly to the linker by GCC. Refer
17589to your linker documentation for exact details. The general
17590description below applies to the GNU linker.
17591
17592The linker searches a standard list of directories for the library.
17593The directories searched include several standard system directories
17594plus any that you specify with @option{-L}.
17595
17596Static libraries are archives of object files, and have file names
17597like @file{lib@var{library}.a}. Some targets also support shared
17598libraries, which typically have names like @file{lib@var{library}.so}.
17599If both static and shared libraries are found, the linker gives
17600preference to linking with the shared library unless the
17601@option{-static} option is used.
17602
17603It makes a difference where in the command you write this option; the
17604linker searches and processes libraries and object files in the order they
17605are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
17606after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
17607to functions in @samp{z}, those functions may not be loaded.
17608
17609@item -lobjc
17610@opindex lobjc
17611You need this special case of the @option{-l} option in order to
17612link an Objective-C or Objective-C++ program.
17613
17614@item -nostartfiles
17615@opindex nostartfiles
17616Do not use the standard system startup files when linking.
17617The standard system libraries are used normally, unless @option{-nostdlib},
17618@option{-nolibc}, or @option{-nodefaultlibs} is used.
17619
17620@item -nodefaultlibs
17621@opindex nodefaultlibs
17622Do not use the standard system libraries when linking.
17623Only the libraries you specify are passed to the linker, and options
17624specifying linkage of the system libraries, such as @option{-static-libgcc}
17625or @option{-shared-libgcc}, are ignored.
17626The standard startup files are used normally, unless @option{-nostartfiles}
17627is used.
17628
17629The compiler may generate calls to @code{memcmp},
17630@code{memset}, @code{memcpy} and @code{memmove}.
17631These entries are usually resolved by entries in
17632libc. These entry points should be supplied through some other
17633mechanism when this option is specified.
17634
17635@item -nolibc
17636@opindex nolibc
17637Do not use the C library or system libraries tightly coupled with it when
17638linking. Still link with the startup files, @file{libgcc} or toolchain
17639provided language support libraries such as @file{libgnat}, @file{libgfortran}
17640or @file{libstdc++} unless options preventing their inclusion are used as
17641well. This typically removes @option{-lc} from the link command line, as well
17642as system libraries that normally go with it and become meaningless when
17643absence of a C library is assumed, for example @option{-lpthread} or
17644@option{-lm} in some configurations. This is intended for bare-board
17645targets when there is indeed no C library available.
17646
17647@item -nostdlib
17648@opindex nostdlib
17649Do not use the standard system startup files or libraries when linking.
17650No startup files and only the libraries you specify are passed to
17651the linker, and options specifying linkage of the system libraries, such as
17652@option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
17653
17654The compiler may generate calls to @code{memcmp}, @code{memset},
17655@code{memcpy} and @code{memmove}.
17656These entries are usually resolved by entries in
17657libc. These entry points should be supplied through some other
17658mechanism when this option is specified.
17659
17660@cindex @option{-lgcc}, use with @option{-nostdlib}
17661@cindex @option{-nostdlib} and unresolved references
17662@cindex unresolved references and @option{-nostdlib}
17663@cindex @option{-lgcc}, use with @option{-nodefaultlibs}
17664@cindex @option{-nodefaultlibs} and unresolved references
17665@cindex unresolved references and @option{-nodefaultlibs}
17666One of the standard libraries bypassed by @option{-nostdlib} and
17667@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
17668which GCC uses to overcome shortcomings of particular machines, or special
17669needs for some languages.
17670(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
17671Collection (GCC) Internals},
17672for more discussion of @file{libgcc.a}.)
17673In most cases, you need @file{libgcc.a} even when you want to avoid
17674other standard libraries. In other words, when you specify @option{-nostdlib}
17675or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
17676This ensures that you have no unresolved references to internal GCC
17677library subroutines.
17678(An example of such an internal subroutine is @code{__main}, used to ensure C++
17679constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
17680GNU Compiler Collection (GCC) Internals}.)
17681
17682@item -nostdlib++
17683@opindex nostdlib++
17684Do not implicitly link with standard C++ libraries.
17685
17686@item -e @var{entry}
17687@itemx --entry=@var{entry}
17688@opindex e
17689@opindex entry
17690
17691Specify that the program entry point is @var{entry}. The argument is
17692interpreted by the linker; the GNU linker accepts either a symbol name
17693or an address.
17694
17695@item -pie
17696@opindex pie
17697Produce a dynamically linked position independent executable on targets
17698that support it. For predictable results, you must also specify the same
17699set of options used for compilation (@option{-fpie}, @option{-fPIE},
17700or model suboptions) when you specify this linker option.
17701
17702@item -no-pie
17703@opindex no-pie
17704Don't produce a dynamically linked position independent executable.
17705
17706@item -static-pie
17707@opindex static-pie
17708Produce a static position independent executable on targets that support
17709it. A static position independent executable is similar to a static
17710executable, but can be loaded at any address without a dynamic linker.
17711For predictable results, you must also specify the same set of options
17712used for compilation (@option{-fpie}, @option{-fPIE}, or model
17713suboptions) when you specify this linker option.
17714
17715@item -pthread
17716@opindex pthread
17717Link with the POSIX threads library. This option is supported on
17718GNU/Linux targets, most other Unix derivatives, and also on
17719x86 Cygwin and MinGW targets. On some targets this option also sets
17720flags for the preprocessor, so it should be used consistently for both
17721compilation and linking.
17722
17723@item -r
17724@opindex r
17725Produce a relocatable object as output. This is also known as partial
17726linking.
17727
17728@item -rdynamic
17729@opindex rdynamic
17730Pass the flag @option{-export-dynamic} to the ELF linker, on targets
17731that support it. This instructs the linker to add all symbols, not
17732only used ones, to the dynamic symbol table. This option is needed
17733for some uses of @code{dlopen} or to allow obtaining backtraces
17734from within a program.
17735
17736@item -s
17737@opindex s
17738Remove all symbol table and relocation information from the executable.
17739
17740@item -static
17741@opindex static
17742On systems that support dynamic linking, this overrides @option{-pie}
17743and prevents linking with the shared libraries. On other systems, this
17744option has no effect.
17745
17746@item -shared
17747@opindex shared
17748Produce a shared object which can then be linked with other objects to
17749form an executable. Not all systems support this option. For predictable
17750results, you must also specify the same set of options used for compilation
17751(@option{-fpic}, @option{-fPIC}, or model suboptions) when
17752you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
17753needs to build supplementary stub code for constructors to work. On
17754multi-libbed systems, @samp{gcc -shared} must select the correct support
17755libraries to link against. Failing to supply the correct flags may lead
17756to subtle defects. Supplying them in cases where they are not necessary
b799acef
RB
17757is innocuous. @option{-shared} suppresses the addition of startup code
17758to alter the floating-point environment as done with @option{-ffast-math},
17759@option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.}
d77de738
ML
17760
17761@item -shared-libgcc
17762@itemx -static-libgcc
17763@opindex shared-libgcc
17764@opindex static-libgcc
17765On systems that provide @file{libgcc} as a shared library, these options
17766force the use of either the shared or static version, respectively.
17767If no shared version of @file{libgcc} was built when the compiler was
17768configured, these options have no effect.
17769
17770There are several situations in which an application should use the
17771shared @file{libgcc} instead of the static version. The most common
17772of these is when the application wishes to throw and catch exceptions
17773across different shared libraries. In that case, each of the libraries
17774as well as the application itself should use the shared @file{libgcc}.
17775
17776Therefore, the G++ driver automatically adds @option{-shared-libgcc}
17777whenever you build a shared library or a main executable, because C++
17778programs typically use exceptions, so this is the right thing to do.
17779
17780If, instead, you use the GCC driver to create shared libraries, you may
17781find that they are not always linked with the shared @file{libgcc}.
17782If GCC finds, at its configuration time, that you have a non-GNU linker
17783or a GNU linker that does not support option @option{--eh-frame-hdr},
17784it links the shared version of @file{libgcc} into shared libraries
17785by default. Otherwise, it takes advantage of the linker and optimizes
17786away the linking with the shared version of @file{libgcc}, linking with
17787the static version of libgcc by default. This allows exceptions to
17788propagate through such shared libraries, without incurring relocation
17789costs at library load time.
17790
17791However, if a library or main executable is supposed to throw or catch
17792exceptions, you must link it using the G++ driver, or using the option
17793@option{-shared-libgcc}, such that it is linked with the shared
17794@file{libgcc}.
17795
17796@item -static-libasan
17797@opindex static-libasan
17798When the @option{-fsanitize=address} option is used to link a program,
17799the GCC driver automatically links against @option{libasan}. If
17800@file{libasan} is available as a shared library, and the @option{-static}
17801option is not used, then this links against the shared version of
17802@file{libasan}. The @option{-static-libasan} option directs the GCC
17803driver to link @file{libasan} statically, without necessarily linking
17804other libraries statically.
17805
17806@item -static-libtsan
17807@opindex static-libtsan
17808When the @option{-fsanitize=thread} option is used to link a program,
17809the GCC driver automatically links against @option{libtsan}. If
17810@file{libtsan} is available as a shared library, and the @option{-static}
17811option is not used, then this links against the shared version of
17812@file{libtsan}. The @option{-static-libtsan} option directs the GCC
17813driver to link @file{libtsan} statically, without necessarily linking
17814other libraries statically.
17815
17816@item -static-liblsan
17817@opindex static-liblsan
17818When the @option{-fsanitize=leak} option is used to link a program,
17819the GCC driver automatically links against @option{liblsan}. If
17820@file{liblsan} is available as a shared library, and the @option{-static}
17821option is not used, then this links against the shared version of
17822@file{liblsan}. The @option{-static-liblsan} option directs the GCC
17823driver to link @file{liblsan} statically, without necessarily linking
17824other libraries statically.
17825
17826@item -static-libubsan
17827@opindex static-libubsan
17828When the @option{-fsanitize=undefined} option is used to link a program,
17829the GCC driver automatically links against @option{libubsan}. If
17830@file{libubsan} is available as a shared library, and the @option{-static}
17831option is not used, then this links against the shared version of
17832@file{libubsan}. The @option{-static-libubsan} option directs the GCC
17833driver to link @file{libubsan} statically, without necessarily linking
17834other libraries statically.
17835
17836@item -static-libstdc++
17837@opindex static-libstdc++
17838When the @command{g++} program is used to link a C++ program, it
17839normally automatically links against @option{libstdc++}. If
17840@file{libstdc++} is available as a shared library, and the
17841@option{-static} option is not used, then this links against the
17842shared version of @file{libstdc++}. That is normally fine. However, it
17843is sometimes useful to freeze the version of @file{libstdc++} used by
17844the program without going all the way to a fully static link. The
17845@option{-static-libstdc++} option directs the @command{g++} driver to
17846link @file{libstdc++} statically, without necessarily linking other
17847libraries statically.
17848
17849@item -symbolic
17850@opindex symbolic
17851Bind references to global symbols when building a shared object. Warn
17852about any unresolved references (unless overridden by the link editor
17853option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
17854this option.
17855
17856@item -T @var{script}
17857@opindex T
17858@cindex linker script
17859Use @var{script} as the linker script. This option is supported by most
17860systems using the GNU linker. On some targets, such as bare-board
17861targets without an operating system, the @option{-T} option may be required
17862when linking to avoid references to undefined symbols.
17863
17864@item -Xlinker @var{option}
17865@opindex Xlinker
17866Pass @var{option} as an option to the linker. You can use this to
17867supply system-specific linker options that GCC does not recognize.
17868
17869If you want to pass an option that takes a separate argument, you must use
17870@option{-Xlinker} twice, once for the option and once for the argument.
17871For example, to pass @option{-assert definitions}, you must write
17872@option{-Xlinker -assert -Xlinker definitions}. It does not work to write
17873@option{-Xlinker "-assert definitions"}, because this passes the entire
17874string as a single argument, which is not what the linker expects.
17875
17876When using the GNU linker, it is usually more convenient to pass
17877arguments to linker options using the @option{@var{option}=@var{value}}
17878syntax than as separate arguments. For example, you can specify
17879@option{-Xlinker -Map=output.map} rather than
17880@option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
17881this syntax for command-line options.
17882
17883@item -Wl,@var{option}
17884@opindex Wl
17885Pass @var{option} as an option to the linker. If @var{option} contains
17886commas, it is split into multiple options at the commas. You can use this
17887syntax to pass an argument to the option.
17888For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
17889linker. When using the GNU linker, you can also get the same effect with
17890@option{-Wl,-Map=output.map}.
17891
17892@item -u @var{symbol}
17893@opindex u
17894Pretend the symbol @var{symbol} is undefined, to force linking of
17895library modules to define it. You can use @option{-u} multiple times with
17896different symbols to force loading of additional library modules.
17897
17898@item -z @var{keyword}
17899@opindex z
17900@option{-z} is passed directly on to the linker along with the keyword
17901@var{keyword}. See the section in the documentation of your linker for
17902permitted values and their meanings.
17903@end table
17904
17905@node Directory Options
17906@section Options for Directory Search
17907@cindex directory options
17908@cindex options, directory search
17909@cindex search path
17910
17911These options specify directories to search for header files, for
17912libraries and for parts of the compiler:
17913
17914@table @gcctabopt
17915@include cppdiropts.texi
17916
17917@item -iplugindir=@var{dir}
17918@opindex iplugindir=
17919Set the directory to search for plugins that are passed
17920by @option{-fplugin=@var{name}} instead of
17921@option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
17922to be used by the user, but only passed by the driver.
17923
17924@item -L@var{dir}
17925@opindex L
17926Add directory @var{dir} to the list of directories to be searched
17927for @option{-l}.
17928
17929@item -B@var{prefix}
17930@opindex B
17931This option specifies where to find the executables, libraries,
17932include files, and data files of the compiler itself.
17933
17934The compiler driver program runs one or more of the subprograms
17935@command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
17936@var{prefix} as a prefix for each program it tries to run, both with and
17937without @samp{@var{machine}/@var{version}/} for the corresponding target
17938machine and compiler version.
17939
17940For each subprogram to be run, the compiler driver first tries the
17941@option{-B} prefix, if any. If that name is not found, or if @option{-B}
17942is not specified, the driver tries two standard prefixes,
17943@file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
17944those results in a file name that is found, the unmodified program
17945name is searched for using the directories specified in your
17946@env{PATH} environment variable.
17947
17948The compiler checks to see if the path provided by @option{-B}
17949refers to a directory, and if necessary it adds a directory
17950separator character at the end of the path.
17951
17952@option{-B} prefixes that effectively specify directory names also apply
17953to libraries in the linker, because the compiler translates these
17954options into @option{-L} options for the linker. They also apply to
17955include files in the preprocessor, because the compiler translates these
17956options into @option{-isystem} options for the preprocessor. In this case,
17957the compiler appends @samp{include} to the prefix.
17958
17959The runtime support file @file{libgcc.a} can also be searched for using
17960the @option{-B} prefix, if needed. If it is not found there, the two
17961standard prefixes above are tried, and that is all. The file is left
17962out of the link if it is not found by those means.
17963
17964Another way to specify a prefix much like the @option{-B} prefix is to use
17965the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
17966Variables}.
17967
17968As a special kludge, if the path provided by @option{-B} is
17969@file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
179709, then it is replaced by @file{[dir/]include}. This is to help
17971with boot-strapping the compiler.
17972
17973@item -no-canonical-prefixes
17974@opindex no-canonical-prefixes
17975Do not expand any symbolic links, resolve references to @samp{/../}
17976or @samp{/./}, or make the path absolute when generating a relative
17977prefix.
17978
17979@item --sysroot=@var{dir}
17980@opindex sysroot
17981Use @var{dir} as the logical root directory for headers and libraries.
17982For example, if the compiler normally searches for headers in
17983@file{/usr/include} and libraries in @file{/usr/lib}, it instead
17984searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
17985
17986If you use both this option and the @option{-isysroot} option, then
17987the @option{--sysroot} option applies to libraries, but the
17988@option{-isysroot} option applies to header files.
17989
17990The GNU linker (beginning with version 2.16) has the necessary support
17991for this option. If your linker does not support this option, the
17992header file aspect of @option{--sysroot} still works, but the
17993library aspect does not.
17994
17995@item --no-sysroot-suffix
17996@opindex no-sysroot-suffix
17997For some targets, a suffix is added to the root directory specified
17998with @option{--sysroot}, depending on the other options used, so that
17999headers may for example be found in
18000@file{@var{dir}/@var{suffix}/usr/include} instead of
18001@file{@var{dir}/usr/include}. This option disables the addition of
18002such a suffix.
18003
18004@end table
18005
18006@node Code Gen Options
18007@section Options for Code Generation Conventions
18008@cindex code generation conventions
18009@cindex options, code generation
18010@cindex run-time options
18011
18012These machine-independent options control the interface conventions
18013used in code generation.
18014
18015Most of them have both positive and negative forms; the negative form
18016of @option{-ffoo} is @option{-fno-foo}. In the table below, only
18017one of the forms is listed---the one that is not the default. You
18018can figure out the other form by either removing @samp{no-} or adding
18019it.
18020
18021@table @gcctabopt
18022@item -fstack-reuse=@var{reuse-level}
18023@opindex fstack_reuse
18024This option controls stack space reuse for user declared local/auto variables
18025and compiler generated temporaries. @var{reuse_level} can be @samp{all},
18026@samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
18027local variables and temporaries, @samp{named_vars} enables the reuse only for
18028user defined local variables with names, and @samp{none} disables stack reuse
18029completely. The default value is @samp{all}. The option is needed when the
18030program extends the lifetime of a scoped local variable or a compiler generated
18031temporary beyond the end point defined by the language. When a lifetime of
18032a variable ends, and if the variable lives in memory, the optimizing compiler
18033has the freedom to reuse its stack space with other temporaries or scoped
18034local variables whose live range does not overlap with it. Legacy code extending
18035local lifetime is likely to break with the stack reuse optimization.
18036
18037For example,
18038
18039@smallexample
18040 int *p;
18041 @{
18042 int local1;
18043
18044 p = &local1;
18045 local1 = 10;
18046 ....
18047 @}
18048 @{
18049 int local2;
18050 local2 = 20;
18051 ...
18052 @}
18053
18054 if (*p == 10) // out of scope use of local1
18055 @{
18056
18057 @}
18058@end smallexample
18059
18060Another example:
18061@smallexample
18062
18063 struct A
18064 @{
18065 A(int k) : i(k), j(k) @{ @}
18066 int i;
18067 int j;
18068 @};
18069
18070 A *ap;
18071
18072 void foo(const A& ar)
18073 @{
18074 ap = &ar;
18075 @}
18076
18077 void bar()
18078 @{
18079 foo(A(10)); // temp object's lifetime ends when foo returns
18080
18081 @{
18082 A a(20);
18083 ....
18084 @}
18085 ap->i+= 10; // ap references out of scope temp whose space
18086 // is reused with a. What is the value of ap->i?
18087 @}
18088
18089@end smallexample
18090
18091The lifetime of a compiler generated temporary is well defined by the C++
18092standard. When a lifetime of a temporary ends, and if the temporary lives
18093in memory, the optimizing compiler has the freedom to reuse its stack
18094space with other temporaries or scoped local variables whose live range
18095does not overlap with it. However some of the legacy code relies on
18096the behavior of older compilers in which temporaries' stack space is
18097not reused, the aggressive stack reuse can lead to runtime errors. This
18098option is used to control the temporary stack reuse optimization.
18099
18100@item -ftrapv
18101@opindex ftrapv
18102This option generates traps for signed overflow on addition, subtraction,
18103multiplication operations.
18104The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18105@option{-ftrapv} @option{-fwrapv} on the command-line results in
18106@option{-fwrapv} being effective. Note that only active options override, so
18107using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18108results in @option{-ftrapv} being effective.
18109
18110@item -fwrapv
18111@opindex fwrapv
18112This option instructs the compiler to assume that signed arithmetic
18113overflow of addition, subtraction and multiplication wraps around
18114using twos-complement representation. This flag enables some optimizations
18115and disables others.
18116The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18117@option{-ftrapv} @option{-fwrapv} on the command-line results in
18118@option{-fwrapv} being effective. Note that only active options override, so
18119using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18120results in @option{-ftrapv} being effective.
18121
18122@item -fwrapv-pointer
18123@opindex fwrapv-pointer
18124This option instructs the compiler to assume that pointer arithmetic
18125overflow on addition and subtraction wraps around using twos-complement
18126representation. This flag disables some optimizations which assume
18127pointer overflow is invalid.
18128
18129@item -fstrict-overflow
18130@opindex fstrict-overflow
18131This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
18132negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
18133
18134@item -fexceptions
18135@opindex fexceptions
18136Enable exception handling. Generates extra code needed to propagate
18137exceptions. For some targets, this implies GCC generates frame
18138unwind information for all functions, which can produce significant data
18139size overhead, although it does not affect execution. If you do not
18140specify this option, GCC enables it by default for languages like
18141C++ that normally require exception handling, and disables it for
18142languages like C that do not normally require it. However, you may need
18143to enable this option when compiling C code that needs to interoperate
18144properly with exception handlers written in C++. You may also wish to
18145disable this option if you are compiling older C++ programs that don't
18146use exception handling.
18147
18148@item -fnon-call-exceptions
18149@opindex fnon-call-exceptions
18150Generate code that allows trapping instructions to throw exceptions.
18151Note that this requires platform-specific runtime support that does
18152not exist everywhere. Moreover, it only allows @emph{trapping}
18153instructions to throw exceptions, i.e.@: memory references or floating-point
18154instructions. It does not allow exceptions to be thrown from
18155arbitrary signal handlers such as @code{SIGALRM}. This enables
18156@option{-fexceptions}.
18157
18158@item -fdelete-dead-exceptions
18159@opindex fdelete-dead-exceptions
18160Consider that instructions that may throw exceptions but don't otherwise
18161contribute to the execution of the program can be optimized away.
18162This does not affect calls to functions except those with the
18163@code{pure} or @code{const} attributes.
18164This option is enabled by default for the Ada and C++ compilers, as permitted by
18165the language specifications.
18166Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
18167
18168@item -funwind-tables
18169@opindex funwind-tables
18170Similar to @option{-fexceptions}, except that it just generates any needed
18171static data, but does not affect the generated code in any other way.
18172You normally do not need to enable this option; instead, a language processor
18173that needs this handling enables it on your behalf.
18174
18175@item -fasynchronous-unwind-tables
18176@opindex fasynchronous-unwind-tables
18177Generate unwind table in DWARF format, if supported by target machine. The
18178table is exact at each instruction boundary, so it can be used for stack
18179unwinding from asynchronous events (such as debugger or garbage collector).
18180
18181@item -fno-gnu-unique
18182@opindex fno-gnu-unique
18183@opindex fgnu-unique
18184On systems with recent GNU assembler and C library, the C++ compiler
18185uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
18186of template static data members and static local variables in inline
18187functions are unique even in the presence of @code{RTLD_LOCAL}; this
18188is necessary to avoid problems with a library used by two different
18189@code{RTLD_LOCAL} plugins depending on a definition in one of them and
18190therefore disagreeing with the other one about the binding of the
18191symbol. But this causes @code{dlclose} to be ignored for affected
18192DSOs; if your program relies on reinitialization of a DSO via
18193@code{dlclose} and @code{dlopen}, you can use
18194@option{-fno-gnu-unique}.
18195
18196@item -fpcc-struct-return
18197@opindex fpcc-struct-return
18198Return ``short'' @code{struct} and @code{union} values in memory like
18199longer ones, rather than in registers. This convention is less
18200efficient, but it has the advantage of allowing intercallability between
18201GCC-compiled files and files compiled with other compilers, particularly
18202the Portable C Compiler (pcc).
18203
18204The precise convention for returning structures in memory depends
18205on the target configuration macros.
18206
18207Short structures and unions are those whose size and alignment match
18208that of some integer type.
18209
18210@strong{Warning:} code compiled with the @option{-fpcc-struct-return}
18211switch is not binary compatible with code compiled with the
18212@option{-freg-struct-return} switch.
18213Use it to conform to a non-default application binary interface.
18214
18215@item -freg-struct-return
18216@opindex freg-struct-return
18217Return @code{struct} and @code{union} values in registers when possible.
18218This is more efficient for small structures than
18219@option{-fpcc-struct-return}.
18220
18221If you specify neither @option{-fpcc-struct-return} nor
18222@option{-freg-struct-return}, GCC defaults to whichever convention is
18223standard for the target. If there is no standard convention, GCC
18224defaults to @option{-fpcc-struct-return}, except on targets where GCC is
18225the principal compiler. In those cases, we can choose the standard, and
18226we chose the more efficient register return alternative.
18227
18228@strong{Warning:} code compiled with the @option{-freg-struct-return}
18229switch is not binary compatible with code compiled with the
18230@option{-fpcc-struct-return} switch.
18231Use it to conform to a non-default application binary interface.
18232
18233@item -fshort-enums
18234@opindex fshort-enums
18235Allocate to an @code{enum} type only as many bytes as it needs for the
18236declared range of possible values. Specifically, the @code{enum} type
18237is equivalent to the smallest integer type that has enough room.
18238
18239@strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
18240code that is not binary compatible with code generated without that switch.
18241Use it to conform to a non-default application binary interface.
18242
18243@item -fshort-wchar
18244@opindex fshort-wchar
18245Override the underlying type for @code{wchar_t} to be @code{short
18246unsigned int} instead of the default for the target. This option is
18247useful for building programs to run under WINE@.
18248
18249@strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
18250code that is not binary compatible with code generated without that switch.
18251Use it to conform to a non-default application binary interface.
18252
18253@item -fcommon
18254@opindex fcommon
18255@opindex fno-common
18256@cindex tentative definitions
18257In C code, this option controls the placement of global variables
18258defined without an initializer, known as @dfn{tentative definitions}
18259in the C standard. Tentative definitions are distinct from declarations
18260of a variable with the @code{extern} keyword, which do not allocate storage.
18261
18262The default is @option{-fno-common}, which specifies that the compiler places
18263uninitialized global variables in the BSS section of the object file.
18264This inhibits the merging of tentative definitions by the linker so you get a
18265multiple-definition error if the same variable is accidentally defined in more
18266than one compilation unit.
18267
18268The @option{-fcommon} places uninitialized global variables in a common block.
18269This allows the linker to resolve all tentative definitions of the same variable
18270in different compilation units to the same object, or to a non-tentative
18271definition. This behavior is inconsistent with C++, and on many targets implies
18272a speed and code size penalty on global variable references. It is mainly
18273useful to enable legacy code to link without errors.
18274
18275@item -fno-ident
18276@opindex fno-ident
18277@opindex fident
18278Ignore the @code{#ident} directive.
18279
18280@item -finhibit-size-directive
18281@opindex finhibit-size-directive
18282Don't output a @code{.size} assembler directive, or anything else that
18283would cause trouble if the function is split in the middle, and the
18284two halves are placed at locations far apart in memory. This option is
18285used when compiling @file{crtstuff.c}; you should not need to use it
18286for anything else.
18287
18288@item -fverbose-asm
18289@opindex fverbose-asm
18290Put extra commentary information in the generated assembly code to
18291make it more readable. This option is generally only of use to those
18292who actually need to read the generated assembly code (perhaps while
18293debugging the compiler itself).
18294
18295@option{-fno-verbose-asm}, the default, causes the
18296extra information to be omitted and is useful when comparing two assembler
18297files.
18298
18299The added comments include:
18300
18301@itemize @bullet
18302
18303@item
18304information on the compiler version and command-line options,
18305
18306@item
18307the source code lines associated with the assembly instructions,
18308in the form FILENAME:LINENUMBER:CONTENT OF LINE,
18309
18310@item
18311hints on which high-level expressions correspond to
18312the various assembly instruction operands.
18313
18314@end itemize
18315
18316For example, given this C source file:
18317
18318@smallexample
18319int test (int n)
18320@{
18321 int i;
18322 int total = 0;
18323
18324 for (i = 0; i < n; i++)
18325 total += i * i;
18326
18327 return total;
18328@}
18329@end smallexample
18330
18331compiling to (x86_64) assembly via @option{-S} and emitting the result
18332direct to stdout via @option{-o} @option{-}
18333
18334@smallexample
18335gcc -S test.c -fverbose-asm -Os -o -
18336@end smallexample
18337
18338gives output similar to this:
18339
18340@smallexample
18341 .file "test.c"
18342# GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
18343 [...snip...]
18344# options passed:
18345 [...snip...]
18346
18347 .text
18348 .globl test
18349 .type test, @@function
18350test:
18351.LFB0:
18352 .cfi_startproc
18353# test.c:4: int total = 0;
18354 xorl %eax, %eax # <retval>
18355# test.c:6: for (i = 0; i < n; i++)
18356 xorl %edx, %edx # i
18357.L2:
18358# test.c:6: for (i = 0; i < n; i++)
18359 cmpl %edi, %edx # n, i
18360 jge .L5 #,
18361# test.c:7: total += i * i;
18362 movl %edx, %ecx # i, tmp92
18363 imull %edx, %ecx # i, tmp92
18364# test.c:6: for (i = 0; i < n; i++)
18365 incl %edx # i
18366# test.c:7: total += i * i;
18367 addl %ecx, %eax # tmp92, <retval>
18368 jmp .L2 #
18369.L5:
18370# test.c:10: @}
18371 ret
18372 .cfi_endproc
18373.LFE0:
18374 .size test, .-test
18375 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
18376 .section .note.GNU-stack,"",@@progbits
18377@end smallexample
18378
18379The comments are intended for humans rather than machines and hence the
18380precise format of the comments is subject to change.
18381
18382@item -frecord-gcc-switches
18383@opindex frecord-gcc-switches
18384This switch causes the command line used to invoke the
18385compiler to be recorded into the object file that is being created.
18386This switch is only implemented on some targets and the exact format
18387of the recording is target and binary file format dependent, but it
18388usually takes the form of a section containing ASCII text. This
18389switch is related to the @option{-fverbose-asm} switch, but that
18390switch only records information in the assembler output file as
18391comments, so it never reaches the object file.
18392See also @option{-grecord-gcc-switches} for another
18393way of storing compiler options into the object file.
18394
18395@item -fpic
18396@opindex fpic
18397@cindex global offset table
18398@cindex PIC
18399Generate position-independent code (PIC) suitable for use in a shared
18400library, if supported for the target machine. Such code accesses all
18401constant addresses through a global offset table (GOT)@. The dynamic
18402loader resolves the GOT entries when the program starts (the dynamic
18403loader is not part of GCC; it is part of the operating system). If
18404the GOT size for the linked executable exceeds a machine-specific
18405maximum size, you get an error message from the linker indicating that
18406@option{-fpic} does not work; in that case, recompile with @option{-fPIC}
18407instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
18408on the m68k and RS/6000. The x86 has no such limit.)
18409
18410Position-independent code requires special support, and therefore works
18411only on certain machines. For the x86, GCC supports PIC for System V
18412but not for the Sun 386i. Code generated for the IBM RS/6000 is always
18413position-independent.
18414
18415When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18416are defined to 1.
18417
18418@item -fPIC
18419@opindex fPIC
18420If supported for the target machine, emit position-independent code,
18421suitable for dynamic linking and avoiding any limit on the size of the
18422global offset table. This option makes a difference on AArch64, m68k,
18423PowerPC and SPARC@.
18424
18425Position-independent code requires special support, and therefore works
18426only on certain machines.
18427
18428When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18429are defined to 2.
18430
18431@item -fpie
18432@itemx -fPIE
18433@opindex fpie
18434@opindex fPIE
18435These options are similar to @option{-fpic} and @option{-fPIC}, but the
18436generated position-independent code can be only linked into executables.
18437Usually these options are used to compile code that will be linked using
18438the @option{-pie} GCC option.
18439
18440@option{-fpie} and @option{-fPIE} both define the macros
18441@code{__pie__} and @code{__PIE__}. The macros have the value 1
18442for @option{-fpie} and 2 for @option{-fPIE}.
18443
18444@item -fno-plt
18445@opindex fno-plt
18446@opindex fplt
18447Do not use the PLT for external function calls in position-independent code.
18448Instead, load the callee address at call sites from the GOT and branch to it.
18449This leads to more efficient code by eliminating PLT stubs and exposing
18450GOT loads to optimizations. On architectures such as 32-bit x86 where
18451PLT stubs expect the GOT pointer in a specific register, this gives more
18452register allocation freedom to the compiler.
18453Lazy binding requires use of the PLT;
18454with @option{-fno-plt} all external symbols are resolved at load time.
18455
18456Alternatively, the function attribute @code{noplt} can be used to avoid calls
18457through the PLT for specific external functions.
18458
18459In position-dependent code, a few targets also convert calls to
18460functions that are marked to not use the PLT to use the GOT instead.
18461
18462@item -fno-jump-tables
18463@opindex fno-jump-tables
18464@opindex fjump-tables
18465Do not use jump tables for switch statements even where it would be
18466more efficient than other code generation strategies. This option is
18467of use in conjunction with @option{-fpic} or @option{-fPIC} for
18468building code that forms part of a dynamic linker and cannot
18469reference the address of a jump table. On some targets, jump tables
18470do not require a GOT and this option is not needed.
18471
18472@item -fno-bit-tests
18473@opindex fno-bit-tests
18474@opindex fbit-tests
18475Do not use bit tests for switch statements even where it would be
18476more efficient than other code generation strategies.
18477
18478@item -ffixed-@var{reg}
18479@opindex ffixed
18480Treat the register named @var{reg} as a fixed register; generated code
18481should never refer to it (except perhaps as a stack pointer, frame
18482pointer or in some other fixed role).
18483
18484@var{reg} must be the name of a register. The register names accepted
18485are machine-specific and are defined in the @code{REGISTER_NAMES}
18486macro in the machine description macro file.
18487
18488This flag does not have a negative form, because it specifies a
18489three-way choice.
18490
18491@item -fcall-used-@var{reg}
18492@opindex fcall-used
18493Treat the register named @var{reg} as an allocable register that is
18494clobbered by function calls. It may be allocated for temporaries or
18495variables that do not live across a call. Functions compiled this way
18496do not save and restore the register @var{reg}.
18497
18498It is an error to use this flag with the frame pointer or stack pointer.
18499Use of this flag for other registers that have fixed pervasive roles in
18500the machine's execution model produces disastrous results.
18501
18502This flag does not have a negative form, because it specifies a
18503three-way choice.
18504
18505@item -fcall-saved-@var{reg}
18506@opindex fcall-saved
18507Treat the register named @var{reg} as an allocable register saved by
18508functions. It may be allocated even for temporaries or variables that
18509live across a call. Functions compiled this way save and restore
18510the register @var{reg} if they use it.
18511
18512It is an error to use this flag with the frame pointer or stack pointer.
18513Use of this flag for other registers that have fixed pervasive roles in
18514the machine's execution model produces disastrous results.
18515
18516A different sort of disaster results from the use of this flag for
18517a register in which function values may be returned.
18518
18519This flag does not have a negative form, because it specifies a
18520three-way choice.
18521
18522@item -fpack-struct[=@var{n}]
18523@opindex fpack-struct
18524Without a value specified, pack all structure members together without
18525holes. When a value is specified (which must be a small power of two), pack
18526structure members according to this value, representing the maximum
18527alignment (that is, objects with default alignment requirements larger than
18528this are output potentially unaligned at the next fitting location.
18529
18530@strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
18531code that is not binary compatible with code generated without that switch.
18532Additionally, it makes the code suboptimal.
18533Use it to conform to a non-default application binary interface.
18534
18535@item -fleading-underscore
18536@opindex fleading-underscore
18537This option and its counterpart, @option{-fno-leading-underscore}, forcibly
18538change the way C symbols are represented in the object file. One use
18539is to help link with legacy assembly code.
18540
18541@strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
18542generate code that is not binary compatible with code generated without that
18543switch. Use it to conform to a non-default application binary interface.
18544Not all targets provide complete support for this switch.
18545
18546@item -ftls-model=@var{model}
18547@opindex ftls-model
18548Alter the thread-local storage model to be used (@pxref{Thread-Local}).
18549The @var{model} argument should be one of @samp{global-dynamic},
18550@samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
18551Note that the choice is subject to optimization: the compiler may use
18552a more efficient model for symbols not visible outside of the translation
18553unit, or if @option{-fpic} is not given on the command line.
18554
18555The default without @option{-fpic} is @samp{initial-exec}; with
18556@option{-fpic} the default is @samp{global-dynamic}.
18557
18558@item -ftrampolines
18559@opindex ftrampolines
18560For targets that normally need trampolines for nested functions, always
18561generate them instead of using descriptors. Otherwise, for targets that
18562do not need them, like for example HP-PA or IA-64, do nothing.
18563
18564A trampoline is a small piece of code that is created at run time on the
18565stack when the address of a nested function is taken, and is used to call
18566the nested function indirectly. Therefore, it requires the stack to be
18567made executable in order for the program to work properly.
18568
18569@option{-fno-trampolines} is enabled by default on a language by language
18570basis to let the compiler avoid generating them, if it computes that this
18571is safe, and replace them with descriptors. Descriptors are made up of data
18572only, but the generated code must be prepared to deal with them. As of this
18573writing, @option{-fno-trampolines} is enabled by default only for Ada.
18574
18575Moreover, code compiled with @option{-ftrampolines} and code compiled with
18576@option{-fno-trampolines} are not binary compatible if nested functions are
18577present. This option must therefore be used on a program-wide basis and be
18578manipulated with extreme care.
18579
18580For languages other than Ada, the @code{-ftrampolines} and
18581@code{-fno-trampolines} options currently have no effect, and
18582trampolines are always generated on platforms that need them
18583for nested functions.
18584
18585@item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
18586@opindex fvisibility
18587Set the default ELF image symbol visibility to the specified option---all
18588symbols are marked with this unless overridden within the code.
18589Using this feature can very substantially improve linking and
18590load times of shared object libraries, produce more optimized
18591code, provide near-perfect API export and prevent symbol clashes.
18592It is @strong{strongly} recommended that you use this in any shared objects
18593you distribute.
18594
18595Despite the nomenclature, @samp{default} always means public; i.e.,
18596available to be linked against from outside the shared object.
18597@samp{protected} and @samp{internal} are pretty useless in real-world
18598usage so the only other commonly used option is @samp{hidden}.
18599The default if @option{-fvisibility} isn't specified is
18600@samp{default}, i.e., make every symbol public.
18601
18602A good explanation of the benefits offered by ensuring ELF
18603symbols have the correct visibility is given by ``How To Write
18604Shared Libraries'' by Ulrich Drepper (which can be found at
18605@w{@uref{https://www.akkadia.org/drepper/}})---however a superior
18606solution made possible by this option to marking things hidden when
18607the default is public is to make the default hidden and mark things
18608public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
18609and @code{__attribute__ ((visibility("default")))} instead of
18610@code{__declspec(dllexport)} you get almost identical semantics with
18611identical syntax. This is a great boon to those working with
18612cross-platform projects.
18613
18614For those adding visibility support to existing code, you may find
18615@code{#pragma GCC visibility} of use. This works by you enclosing
18616the declarations you wish to set visibility for with (for example)
18617@code{#pragma GCC visibility push(hidden)} and
18618@code{#pragma GCC visibility pop}.
18619Bear in mind that symbol visibility should be viewed @strong{as
18620part of the API interface contract} and thus all new code should
18621always specify visibility when it is not the default; i.e., declarations
18622only for use within the local DSO should @strong{always} be marked explicitly
18623as hidden as so to avoid PLT indirection overheads---making this
18624abundantly clear also aids readability and self-documentation of the code.
18625Note that due to ISO C++ specification requirements, @code{operator new} and
18626@code{operator delete} must always be of default visibility.
18627
18628Be aware that headers from outside your project, in particular system
18629headers and headers from any other library you use, may not be
18630expecting to be compiled with visibility other than the default. You
18631may need to explicitly say @code{#pragma GCC visibility push(default)}
18632before including any such headers.
18633
18634@code{extern} declarations are not affected by @option{-fvisibility}, so
18635a lot of code can be recompiled with @option{-fvisibility=hidden} with
18636no modifications. However, this means that calls to @code{extern}
18637functions with no explicit visibility use the PLT, so it is more
18638effective to use @code{__attribute ((visibility))} and/or
18639@code{#pragma GCC visibility} to tell the compiler which @code{extern}
18640declarations should be treated as hidden.
18641
18642Note that @option{-fvisibility} does affect C++ vague linkage
18643entities. This means that, for instance, an exception class that is
18644be thrown between DSOs must be explicitly marked with default
18645visibility so that the @samp{type_info} nodes are unified between
18646the DSOs.
18647
18648An overview of these techniques, their benefits and how to use them
18649is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
18650
18651@item -fstrict-volatile-bitfields
18652@opindex fstrict-volatile-bitfields
18653This option should be used if accesses to volatile bit-fields (or other
18654structure fields, although the compiler usually honors those types
18655anyway) should use a single access of the width of the
18656field's type, aligned to a natural alignment if possible. For
18657example, targets with memory-mapped peripheral registers might require
18658all such accesses to be 16 bits wide; with this flag you can
18659declare all peripheral bit-fields as @code{unsigned short} (assuming short
18660is 16 bits on these targets) to force GCC to use 16-bit accesses
18661instead of, perhaps, a more efficient 32-bit access.
18662
18663If this option is disabled, the compiler uses the most efficient
18664instruction. In the previous example, that might be a 32-bit load
18665instruction, even though that accesses bytes that do not contain
18666any portion of the bit-field, or memory-mapped registers unrelated to
18667the one being updated.
18668
18669In some cases, such as when the @code{packed} attribute is applied to a
18670structure field, it may not be possible to access the field with a single
18671read or write that is correctly aligned for the target machine. In this
18672case GCC falls back to generating multiple accesses rather than code that
18673will fault or truncate the result at run time.
18674
18675Note: Due to restrictions of the C/C++11 memory model, write accesses are
18676not allowed to touch non bit-field members. It is therefore recommended
18677to define all bits of the field's type as bit-field members.
18678
18679The default value of this option is determined by the application binary
18680interface for the target processor.
18681
18682@item -fsync-libcalls
18683@opindex fsync-libcalls
18684This option controls whether any out-of-line instance of the @code{__sync}
18685family of functions may be used to implement the C++11 @code{__atomic}
18686family of functions.
18687
18688The default value of this option is enabled, thus the only useful form
18689of the option is @option{-fno-sync-libcalls}. This option is used in
18690the implementation of the @file{libatomic} runtime library.
18691
18692@end table
18693
18694@node Developer Options
18695@section GCC Developer Options
18696@cindex developer options
18697@cindex debugging GCC
18698@cindex debug dump options
18699@cindex dump options
18700@cindex compilation statistics
18701
18702This section describes command-line options that are primarily of
18703interest to GCC developers, including options to support compiler
18704testing and investigation of compiler bugs and compile-time
18705performance problems. This includes options that produce debug dumps
18706at various points in the compilation; that print statistics such as
18707memory use and execution time; and that print information about GCC's
18708configuration, such as where it searches for libraries. You should
18709rarely need to use any of these options for ordinary compilation and
18710linking tasks.
18711
18712Many developer options that cause GCC to dump output to a file take an
18713optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
18714or @samp{-} to dump to standard output, and @samp{stderr} for standard
18715error.
18716
18717If @samp{=@var{filename}} is omitted, a default dump file name is
18718constructed by concatenating the base dump file name, a pass number,
18719phase letter, and pass name. The base dump file name is the name of
18720output file produced by the compiler if explicitly specified and not
18721an executable; otherwise it is the source file name.
18722The pass number is determined by the order passes are registered with
18723the compiler's pass manager.
18724This is generally the same as the order of execution, but passes
18725registered by plugins, target-specific passes, or passes that are
18726otherwise registered late are numbered higher than the pass named
18727@samp{final}, even if they are executed earlier. The phase letter is
18728one of @samp{i} (inter-procedural analysis), @samp{l}
18729(language-specific), @samp{r} (RTL), or @samp{t} (tree).
18730The files are created in the directory of the output file.
18731
18732@table @gcctabopt
18733
18734@item -fcallgraph-info
18735@itemx -fcallgraph-info=@var{MARKERS}
18736@opindex fcallgraph-info
18737Makes the compiler output callgraph information for the program, on a
18738per-object-file basis. The information is generated in the common VCG
18739format. It can be decorated with additional, per-node and/or per-edge
18740information, if a list of comma-separated markers is additionally
18741specified. When the @code{su} marker is specified, the callgraph is
18742decorated with stack usage information; it is equivalent to
18743@option{-fstack-usage}. When the @code{da} marker is specified, the
18744callgraph is decorated with information about dynamically allocated
18745objects.
18746
18747When compiling with @option{-flto}, no callgraph information is output
18748along with the object file. At LTO link time, @option{-fcallgraph-info}
18749may generate multiple callgraph information files next to intermediate
18750LTO output files.
18751
18752@item -d@var{letters}
18753@itemx -fdump-rtl-@var{pass}
18754@itemx -fdump-rtl-@var{pass}=@var{filename}
18755@opindex d
18756@opindex fdump-rtl-@var{pass}
18757Says to make debugging dumps during compilation at times specified by
18758@var{letters}. This is used for debugging the RTL-based passes of the
18759compiler.
18760
18761Some @option{-d@var{letters}} switches have different meaning when
18762@option{-E} is used for preprocessing. @xref{Preprocessor Options},
18763for information about preprocessor-specific dump options.
18764
18765Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
18766@option{-d} option @var{letters}. Here are the possible
18767letters for use in @var{pass} and @var{letters}, and their meanings:
18768
18769@table @gcctabopt
18770
18771@item -fdump-rtl-alignments
18772@opindex fdump-rtl-alignments
18773Dump after branch alignments have been computed.
18774
18775@item -fdump-rtl-asmcons
18776@opindex fdump-rtl-asmcons
18777Dump after fixing rtl statements that have unsatisfied in/out constraints.
18778
18779@item -fdump-rtl-auto_inc_dec
18780@opindex fdump-rtl-auto_inc_dec
18781Dump after auto-inc-dec discovery. This pass is only run on
18782architectures that have auto inc or auto dec instructions.
18783
18784@item -fdump-rtl-barriers
18785@opindex fdump-rtl-barriers
18786Dump after cleaning up the barrier instructions.
18787
18788@item -fdump-rtl-bbpart
18789@opindex fdump-rtl-bbpart
18790Dump after partitioning hot and cold basic blocks.
18791
18792@item -fdump-rtl-bbro
18793@opindex fdump-rtl-bbro
18794Dump after block reordering.
18795
18796@item -fdump-rtl-btl1
18797@itemx -fdump-rtl-btl2
18798@opindex fdump-rtl-btl2
18799@opindex fdump-rtl-btl2
18800@option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
18801after the two branch
18802target load optimization passes.
18803
18804@item -fdump-rtl-bypass
18805@opindex fdump-rtl-bypass
18806Dump after jump bypassing and control flow optimizations.
18807
18808@item -fdump-rtl-combine
18809@opindex fdump-rtl-combine
18810Dump after the RTL instruction combination pass.
18811
18812@item -fdump-rtl-compgotos
18813@opindex fdump-rtl-compgotos
18814Dump after duplicating the computed gotos.
18815
18816@item -fdump-rtl-ce1
18817@itemx -fdump-rtl-ce2
18818@itemx -fdump-rtl-ce3
18819@opindex fdump-rtl-ce1
18820@opindex fdump-rtl-ce2
18821@opindex fdump-rtl-ce3
18822@option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
18823@option{-fdump-rtl-ce3} enable dumping after the three
18824if conversion passes.
18825
18826@item -fdump-rtl-cprop_hardreg
18827@opindex fdump-rtl-cprop_hardreg
18828Dump after hard register copy propagation.
18829
18830@item -fdump-rtl-csa
18831@opindex fdump-rtl-csa
18832Dump after combining stack adjustments.
18833
18834@item -fdump-rtl-cse1
18835@itemx -fdump-rtl-cse2
18836@opindex fdump-rtl-cse1
18837@opindex fdump-rtl-cse2
18838@option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
18839the two common subexpression elimination passes.
18840
18841@item -fdump-rtl-dce
18842@opindex fdump-rtl-dce
18843Dump after the standalone dead code elimination passes.
18844
18845@item -fdump-rtl-dbr
18846@opindex fdump-rtl-dbr
18847Dump after delayed branch scheduling.
18848
18849@item -fdump-rtl-dce1
18850@itemx -fdump-rtl-dce2
18851@opindex fdump-rtl-dce1
18852@opindex fdump-rtl-dce2
18853@option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
18854the two dead store elimination passes.
18855
18856@item -fdump-rtl-eh
18857@opindex fdump-rtl-eh
18858Dump after finalization of EH handling code.
18859
18860@item -fdump-rtl-eh_ranges
18861@opindex fdump-rtl-eh_ranges
18862Dump after conversion of EH handling range regions.
18863
18864@item -fdump-rtl-expand
18865@opindex fdump-rtl-expand
18866Dump after RTL generation.
18867
18868@item -fdump-rtl-fwprop1
18869@itemx -fdump-rtl-fwprop2
18870@opindex fdump-rtl-fwprop1
18871@opindex fdump-rtl-fwprop2
18872@option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
18873dumping after the two forward propagation passes.
18874
18875@item -fdump-rtl-gcse1
18876@itemx -fdump-rtl-gcse2
18877@opindex fdump-rtl-gcse1
18878@opindex fdump-rtl-gcse2
18879@option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
18880after global common subexpression elimination.
18881
18882@item -fdump-rtl-init-regs
18883@opindex fdump-rtl-init-regs
18884Dump after the initialization of the registers.
18885
18886@item -fdump-rtl-initvals
18887@opindex fdump-rtl-initvals
18888Dump after the computation of the initial value sets.
18889
18890@item -fdump-rtl-into_cfglayout
18891@opindex fdump-rtl-into_cfglayout
18892Dump after converting to cfglayout mode.
18893
18894@item -fdump-rtl-ira
18895@opindex fdump-rtl-ira
18896Dump after iterated register allocation.
18897
18898@item -fdump-rtl-jump
18899@opindex fdump-rtl-jump
18900Dump after the second jump optimization.
18901
18902@item -fdump-rtl-loop2
18903@opindex fdump-rtl-loop2
18904@option{-fdump-rtl-loop2} enables dumping after the rtl
18905loop optimization passes.
18906
18907@item -fdump-rtl-mach
18908@opindex fdump-rtl-mach
18909Dump after performing the machine dependent reorganization pass, if that
18910pass exists.
18911
18912@item -fdump-rtl-mode_sw
18913@opindex fdump-rtl-mode_sw
18914Dump after removing redundant mode switches.
18915
18916@item -fdump-rtl-rnreg
18917@opindex fdump-rtl-rnreg
18918Dump after register renumbering.
18919
18920@item -fdump-rtl-outof_cfglayout
18921@opindex fdump-rtl-outof_cfglayout
18922Dump after converting from cfglayout mode.
18923
18924@item -fdump-rtl-peephole2
18925@opindex fdump-rtl-peephole2
18926Dump after the peephole pass.
18927
18928@item -fdump-rtl-postreload
18929@opindex fdump-rtl-postreload
18930Dump after post-reload optimizations.
18931
18932@item -fdump-rtl-pro_and_epilogue
18933@opindex fdump-rtl-pro_and_epilogue
18934Dump after generating the function prologues and epilogues.
18935
18936@item -fdump-rtl-sched1
18937@itemx -fdump-rtl-sched2
18938@opindex fdump-rtl-sched1
18939@opindex fdump-rtl-sched2
18940@option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
18941after the basic block scheduling passes.
18942
18943@item -fdump-rtl-ree
18944@opindex fdump-rtl-ree
18945Dump after sign/zero extension elimination.
18946
18947@item -fdump-rtl-seqabstr
18948@opindex fdump-rtl-seqabstr
18949Dump after common sequence discovery.
18950
18951@item -fdump-rtl-shorten
18952@opindex fdump-rtl-shorten
18953Dump after shortening branches.
18954
18955@item -fdump-rtl-sibling
18956@opindex fdump-rtl-sibling
18957Dump after sibling call optimizations.
18958
18959@item -fdump-rtl-split1
18960@itemx -fdump-rtl-split2
18961@itemx -fdump-rtl-split3
18962@itemx -fdump-rtl-split4
18963@itemx -fdump-rtl-split5
18964@opindex fdump-rtl-split1
18965@opindex fdump-rtl-split2
18966@opindex fdump-rtl-split3
18967@opindex fdump-rtl-split4
18968@opindex fdump-rtl-split5
18969These options enable dumping after five rounds of
18970instruction splitting.
18971
18972@item -fdump-rtl-sms
18973@opindex fdump-rtl-sms
18974Dump after modulo scheduling. This pass is only run on some
18975architectures.
18976
18977@item -fdump-rtl-stack
18978@opindex fdump-rtl-stack
18979Dump after conversion from GCC's ``flat register file'' registers to the
18980x87's stack-like registers. This pass is only run on x86 variants.
18981
18982@item -fdump-rtl-subreg1
18983@itemx -fdump-rtl-subreg2
18984@opindex fdump-rtl-subreg1
18985@opindex fdump-rtl-subreg2
18986@option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
18987the two subreg expansion passes.
18988
18989@item -fdump-rtl-unshare
18990@opindex fdump-rtl-unshare
18991Dump after all rtl has been unshared.
18992
18993@item -fdump-rtl-vartrack
18994@opindex fdump-rtl-vartrack
18995Dump after variable tracking.
18996
18997@item -fdump-rtl-vregs
18998@opindex fdump-rtl-vregs
18999Dump after converting virtual registers to hard registers.
19000
19001@item -fdump-rtl-web
19002@opindex fdump-rtl-web
19003Dump after live range splitting.
19004
19005@item -fdump-rtl-regclass
19006@itemx -fdump-rtl-subregs_of_mode_init
19007@itemx -fdump-rtl-subregs_of_mode_finish
19008@itemx -fdump-rtl-dfinit
19009@itemx -fdump-rtl-dfinish
19010@opindex fdump-rtl-regclass
19011@opindex fdump-rtl-subregs_of_mode_init
19012@opindex fdump-rtl-subregs_of_mode_finish
19013@opindex fdump-rtl-dfinit
19014@opindex fdump-rtl-dfinish
19015These dumps are defined but always produce empty files.
19016
19017@item -da
19018@itemx -fdump-rtl-all
19019@opindex da
19020@opindex fdump-rtl-all
19021Produce all the dumps listed above.
19022
19023@item -dA
19024@opindex dA
19025Annotate the assembler output with miscellaneous debugging information.
19026
19027@item -dD
19028@opindex dD
19029Dump all macro definitions, at the end of preprocessing, in addition to
19030normal output.
19031
19032@item -dH
19033@opindex dH
19034Produce a core dump whenever an error occurs.
19035
19036@item -dp
19037@opindex dp
19038Annotate the assembler output with a comment indicating which
19039pattern and alternative is used. The length and cost of each instruction are
19040also printed.
19041
19042@item -dP
19043@opindex dP
19044Dump the RTL in the assembler output as a comment before each instruction.
19045Also turns on @option{-dp} annotation.
19046
19047@item -dx
19048@opindex dx
19049Just generate RTL for a function instead of compiling it. Usually used
19050with @option{-fdump-rtl-expand}.
19051@end table
19052
19053@item -fdump-debug
19054@opindex fdump-debug
19055Dump debugging information generated during the debug
19056generation phase.
19057
19058@item -fdump-earlydebug
19059@opindex fdump-earlydebug
19060Dump debugging information generated during the early debug
19061generation phase.
19062
19063@item -fdump-noaddr
19064@opindex fdump-noaddr
19065When doing debugging dumps, suppress address output. This makes it more
19066feasible to use diff on debugging dumps for compiler invocations with
19067different compiler binaries and/or different
19068text / bss / data / heap / stack / dso start locations.
19069
19070@item -freport-bug
19071@opindex freport-bug
19072Collect and dump debug information into a temporary file if an
19073internal compiler error (ICE) occurs.
19074
19075@item -fdump-unnumbered
19076@opindex fdump-unnumbered
19077When doing debugging dumps, suppress instruction numbers and address output.
19078This makes it more feasible to use diff on debugging dumps for compiler
19079invocations with different options, in particular with and without
19080@option{-g}.
19081
19082@item -fdump-unnumbered-links
19083@opindex fdump-unnumbered-links
19084When doing debugging dumps (see @option{-d} option above), suppress
19085instruction numbers for the links to the previous and next instructions
19086in a sequence.
19087
19088@item -fdump-ipa-@var{switch}
19089@itemx -fdump-ipa-@var{switch}-@var{options}
19090@opindex fdump-ipa
19091Control the dumping at various stages of inter-procedural analysis
19092language tree to a file. The file name is generated by appending a
19093switch specific suffix to the source file name, and the file is created
19094in the same directory as the output file. The following dumps are
19095possible:
19096
19097@table @samp
19098@item all
19099Enables all inter-procedural analysis dumps.
19100
19101@item cgraph
19102Dumps information about call-graph optimization, unused function removal,
19103and inlining decisions.
19104
19105@item inline
19106Dump after function inlining.
19107
19108@end table
19109
19110Additionally, the options @option{-optimized}, @option{-missed},
19111@option{-note}, and @option{-all} can be provided, with the same meaning
19112as for @option{-fopt-info}, defaulting to @option{-optimized}.
19113
19114For example, @option{-fdump-ipa-inline-optimized-missed} will emit
19115information on callsites that were inlined, along with callsites
19116that were not inlined.
19117
19118By default, the dump will contain messages about successful
19119optimizations (equivalent to @option{-optimized}) together with
19120low-level details about the analysis.
19121
19122@item -fdump-lang
19123@opindex fdump-lang
19124Dump language-specific information. The file name is made by appending
19125@file{.lang} to the source file name.
19126
19127@item -fdump-lang-all
19128@itemx -fdump-lang-@var{switch}
19129@itemx -fdump-lang-@var{switch}-@var{options}
19130@itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
19131@opindex fdump-lang-all
19132@opindex fdump-lang
19133Control the dumping of language-specific information. The @var{options}
19134and @var{filename} portions behave as described in the
19135@option{-fdump-tree} option. The following @var{switch} values are
19136accepted:
19137
19138@table @samp
19139@item all
19140
19141Enable all language-specific dumps.
19142
19143@item class
19144Dump class hierarchy information. Virtual table information is emitted
19145unless '@option{slim}' is specified. This option is applicable to C++ only.
19146
19147@item module
19148Dump module information. Options @option{lineno} (locations),
19149@option{graph} (reachability), @option{blocks} (clusters),
19150@option{uid} (serialization), @option{alias} (mergeable),
19151@option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
19152(macros) may provide additional information. This option is
19153applicable to C++ only.
19154
19155@item raw
19156Dump the raw internal tree data. This option is applicable to C++ only.
19157
19158@end table
19159
19160@item -fdump-passes
19161@opindex fdump-passes
19162Print on @file{stderr} the list of optimization passes that are turned
19163on and off by the current command-line options.
19164
19165@item -fdump-statistics-@var{option}
19166@opindex fdump-statistics
19167Enable and control dumping of pass statistics in a separate file. The
19168file name is generated by appending a suffix ending in
19169@samp{.statistics} to the source file name, and the file is created in
19170the same directory as the output file. If the @samp{-@var{option}}
19171form is used, @samp{-stats} causes counters to be summed over the
19172whole compilation unit while @samp{-details} dumps every event as
19173the passes generate them. The default with no option is to sum
19174counters for each function compiled.
19175
19176@item -fdump-tree-all
19177@itemx -fdump-tree-@var{switch}
19178@itemx -fdump-tree-@var{switch}-@var{options}
19179@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
19180@opindex fdump-tree-all
19181@opindex fdump-tree
19182Control the dumping at various stages of processing the intermediate
19183language tree to a file. If the @samp{-@var{options}}
19184form is used, @var{options} is a list of @samp{-} separated options
19185which control the details of the dump. Not all options are applicable
19186to all dumps; those that are not meaningful are ignored. The
19187following options are available
19188
19189@table @samp
19190@item address
19191Print the address of each node. Usually this is not meaningful as it
19192changes according to the environment and source file. Its primary use
19193is for tying up a dump file with a debug environment.
19194@item asmname
19195If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
19196in the dump instead of @code{DECL_NAME}. Its primary use is ease of
19197use working backward from mangled names in the assembly file.
19198@item slim
19199When dumping front-end intermediate representations, inhibit dumping
19200of members of a scope or body of a function merely because that scope
19201has been reached. Only dump such items when they are directly reachable
19202by some other path.
19203
19204When dumping pretty-printed trees, this option inhibits dumping the
19205bodies of control structures.
19206
19207When dumping RTL, print the RTL in slim (condensed) form instead of
19208the default LISP-like representation.
19209@item raw
19210Print a raw representation of the tree. By default, trees are
19211pretty-printed into a C-like representation.
19212@item details
19213Enable more detailed dumps (not honored by every dump option). Also
19214include information from the optimization passes.
19215@item stats
19216Enable dumping various statistics about the pass (not honored by every dump
19217option).
19218@item blocks
19219Enable showing basic block boundaries (disabled in raw dumps).
19220@item graph
19221For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
19222dump a representation of the control flow graph suitable for viewing with
19223GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
19224the file is pretty-printed as a subgraph, so that GraphViz can render them
19225all in a single plot.
19226
19227This option currently only works for RTL dumps, and the RTL is always
19228dumped in slim form.
19229@item vops
19230Enable showing virtual operands for every statement.
19231@item lineno
19232Enable showing line numbers for statements.
19233@item uid
19234Enable showing the unique ID (@code{DECL_UID}) for each variable.
19235@item verbose
19236Enable showing the tree dump for each statement.
19237@item eh
19238Enable showing the EH region number holding each statement.
19239@item scev
19240Enable showing scalar evolution analysis details.
19241@item optimized
19242Enable showing optimization information (only available in certain
19243passes).
19244@item missed
19245Enable showing missed optimization information (only available in certain
19246passes).
19247@item note
19248Enable other detailed optimization information (only available in
19249certain passes).
19250@item all
19251Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
19252and @option{lineno}.
19253@item optall
19254Turn on all optimization options, i.e., @option{optimized},
19255@option{missed}, and @option{note}.
19256@end table
19257
19258To determine what tree dumps are available or find the dump for a pass
19259of interest follow the steps below.
19260
19261@enumerate
19262@item
19263Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
19264look for a code that corresponds to the pass you are interested in.
19265For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
19266@code{tree-vrp2} correspond to the three Value Range Propagation passes.
19267The number at the end distinguishes distinct invocations of the same pass.
19268@item
19269To enable the creation of the dump file, append the pass code to
19270the @option{-fdump-} option prefix and invoke GCC with it. For example,
19271to enable the dump from the Early Value Range Propagation pass, invoke
19272GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
19273specify the name of the dump file. If you don't specify one, GCC
19274creates as described below.
19275@item
19276Find the pass dump in a file whose name is composed of three components
19277separated by a period: the name of the source file GCC was invoked to
19278compile, a numeric suffix indicating the pass number followed by the
19279letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
19280and finally the pass code. For example, the Early VRP pass dump might
19281be in a file named @file{myfile.c.038t.evrp} in the current working
19282directory. Note that the numeric codes are not stable and may change
19283from one version of GCC to another.
19284@end enumerate
19285
19286@item -fopt-info
19287@itemx -fopt-info-@var{options}
19288@itemx -fopt-info-@var{options}=@var{filename}
19289@opindex fopt-info
19290Controls optimization dumps from various optimization passes. If the
19291@samp{-@var{options}} form is used, @var{options} is a list of
19292@samp{-} separated option keywords to select the dump details and
19293optimizations.
19294
19295The @var{options} can be divided into three groups:
19296@enumerate
19297@item
19298options describing what kinds of messages should be emitted,
19299@item
19300options describing the verbosity of the dump, and
19301@item
19302options describing which optimizations should be included.
19303@end enumerate
19304The options from each group can be freely mixed as they are
19305non-overlapping. However, in case of any conflicts,
19306the later options override the earlier options on the command
19307line.
19308
19309The following options control which kinds of messages should be emitted:
19310
19311@table @samp
19312@item optimized
19313Print information when an optimization is successfully applied. It is
19314up to a pass to decide which information is relevant. For example, the
19315vectorizer passes print the source location of loops which are
19316successfully vectorized.
19317@item missed
19318Print information about missed optimizations. Individual passes
19319control which information to include in the output.
19320@item note
19321Print verbose information about optimizations, such as certain
19322transformations, more detailed messages about decisions etc.
19323@item all
19324Print detailed optimization information. This includes
19325@samp{optimized}, @samp{missed}, and @samp{note}.
19326@end table
19327
19328The following option controls the dump verbosity:
19329
19330@table @samp
19331@item internals
19332By default, only ``high-level'' messages are emitted. This option enables
19333additional, more detailed, messages, which are likely to only be of interest
19334to GCC developers.
19335@end table
19336
19337One or more of the following option keywords can be used to describe a
19338group of optimizations:
19339
19340@table @samp
19341@item ipa
19342Enable dumps from all interprocedural optimizations.
19343@item loop
19344Enable dumps from all loop optimizations.
19345@item inline
19346Enable dumps from all inlining optimizations.
19347@item omp
19348Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
19349@item vec
19350Enable dumps from all vectorization optimizations.
19351@item optall
19352Enable dumps from all optimizations. This is a superset of
19353the optimization groups listed above.
19354@end table
19355
19356If @var{options} is
19357omitted, it defaults to @samp{optimized-optall}, which means to dump messages
19358about successful optimizations from all the passes, omitting messages
19359that are treated as ``internals''.
19360
19361If the @var{filename} is provided, then the dumps from all the
19362applicable optimizations are concatenated into the @var{filename}.
19363Otherwise the dump is output onto @file{stderr}. Though multiple
19364@option{-fopt-info} options are accepted, only one of them can include
19365a @var{filename}. If other filenames are provided then all but the
19366first such option are ignored.
19367
19368Note that the output @var{filename} is overwritten
19369in case of multiple translation units. If a combined output from
19370multiple translation units is desired, @file{stderr} should be used
19371instead.
19372
19373In the following example, the optimization info is output to
19374@file{stderr}:
19375
19376@smallexample
19377gcc -O3 -fopt-info
19378@end smallexample
19379
19380This example:
19381@smallexample
19382gcc -O3 -fopt-info-missed=missed.all
19383@end smallexample
19384
19385@noindent
19386outputs missed optimization report from all the passes into
19387@file{missed.all}, and this one:
19388
19389@smallexample
19390gcc -O2 -ftree-vectorize -fopt-info-vec-missed
19391@end smallexample
19392
19393@noindent
19394prints information about missed optimization opportunities from
19395vectorization passes on @file{stderr}.
19396Note that @option{-fopt-info-vec-missed} is equivalent to
19397@option{-fopt-info-missed-vec}. The order of the optimization group
19398names and message types listed after @option{-fopt-info} does not matter.
19399
19400As another example,
19401@smallexample
19402gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
19403@end smallexample
19404
19405@noindent
19406outputs information about missed optimizations as well as
19407optimized locations from all the inlining passes into
19408@file{inline.txt}.
19409
19410Finally, consider:
19411
19412@smallexample
19413gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
19414@end smallexample
19415
19416@noindent
19417Here the two output filenames @file{vec.miss} and @file{loop.opt} are
19418in conflict since only one output file is allowed. In this case, only
19419the first option takes effect and the subsequent options are
19420ignored. Thus only @file{vec.miss} is produced which contains
19421dumps from the vectorizer about missed opportunities.
19422
19423@item -fsave-optimization-record
19424@opindex fsave-optimization-record
19425Write a SRCFILE.opt-record.json.gz file detailing what optimizations
19426were performed, for those optimizations that support @option{-fopt-info}.
19427
19428This option is experimental and the format of the data within the
19429compressed JSON file is subject to change.
19430
19431It is roughly equivalent to a machine-readable version of
19432@option{-fopt-info-all}, as a collection of messages with source file,
19433line number and column number, with the following additional data for
19434each message:
19435
19436@itemize @bullet
19437
19438@item
19439the execution count of the code being optimized, along with metadata about
19440whether this was from actual profile data, or just an estimate, allowing
19441consumers to prioritize messages by code hotness,
19442
19443@item
19444the function name of the code being optimized, where applicable,
19445
19446@item
19447the ``inlining chain'' for the code being optimized, so that when
19448a function is inlined into several different places (which might
19449themselves be inlined), the reader can distinguish between the copies,
19450
19451@item
19452objects identifying those parts of the message that refer to expressions,
19453statements or symbol-table nodes, which of these categories they are, and,
19454when available, their source code location,
19455
19456@item
19457the GCC pass that emitted the message, and
19458
19459@item
19460the location in GCC's own code from which the message was emitted
19461
19462@end itemize
19463
19464Additionally, some messages are logically nested within other
19465messages, reflecting implementation details of the optimization
19466passes.
19467
19468@item -fsched-verbose=@var{n}
19469@opindex fsched-verbose
19470On targets that use instruction scheduling, this option controls the
19471amount of debugging output the scheduler prints to the dump files.
19472
19473For @var{n} greater than zero, @option{-fsched-verbose} outputs the
19474same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
19475For @var{n} greater than one, it also output basic block probabilities,
19476detailed ready list information and unit/insn info. For @var{n} greater
19477than two, it includes RTL at abort point, control-flow and regions info.
19478And for @var{n} over four, @option{-fsched-verbose} also includes
19479dependence info.
19480
19481
19482
19483@item -fenable-@var{kind}-@var{pass}
19484@itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
19485@opindex fdisable-
19486@opindex fenable-
19487
19488This is a set of options that are used to explicitly disable/enable
19489optimization passes. These options are intended for use for debugging GCC.
19490Compiler users should use regular options for enabling/disabling
19491passes instead.
19492
19493@table @gcctabopt
19494
19495@item -fdisable-ipa-@var{pass}
19496Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19497statically invoked in the compiler multiple times, the pass name should be
19498appended with a sequential number starting from 1.
19499
19500@item -fdisable-rtl-@var{pass}
19501@itemx -fdisable-rtl-@var{pass}=@var{range-list}
19502Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
19503statically invoked in the compiler multiple times, the pass name should be
19504appended with a sequential number starting from 1. @var{range-list} is a
19505comma-separated list of function ranges or assembler names. Each range is a number
19506pair separated by a colon. The range is inclusive in both ends. If the range
19507is trivial, the number pair can be simplified as a single number. If the
19508function's call graph node's @var{uid} falls within one of the specified ranges,
19509the @var{pass} is disabled for that function. The @var{uid} is shown in the
19510function header of a dump file, and the pass names can be dumped by using
19511option @option{-fdump-passes}.
19512
19513@item -fdisable-tree-@var{pass}
19514@itemx -fdisable-tree-@var{pass}=@var{range-list}
19515Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
19516option arguments.
19517
19518@item -fenable-ipa-@var{pass}
19519Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19520statically invoked in the compiler multiple times, the pass name should be
19521appended with a sequential number starting from 1.
19522
19523@item -fenable-rtl-@var{pass}
19524@itemx -fenable-rtl-@var{pass}=@var{range-list}
19525Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
19526description and examples.
19527
19528@item -fenable-tree-@var{pass}
19529@itemx -fenable-tree-@var{pass}=@var{range-list}
19530Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
19531of option arguments.
19532
19533@end table
19534
19535Here are some examples showing uses of these options.
19536
19537@smallexample
19538
19539# disable ccp1 for all functions
19540 -fdisable-tree-ccp1
19541# disable complete unroll for function whose cgraph node uid is 1
19542 -fenable-tree-cunroll=1
19543# disable gcse2 for functions at the following ranges [1,1],
19544# [300,400], and [400,1000]
19545# disable gcse2 for functions foo and foo2
19546 -fdisable-rtl-gcse2=foo,foo2
19547# disable early inlining
19548 -fdisable-tree-einline
19549# disable ipa inlining
19550 -fdisable-ipa-inline
19551# enable tree full unroll
19552 -fenable-tree-unroll
19553
19554@end smallexample
19555
19556@item -fchecking
19557@itemx -fchecking=@var{n}
19558@opindex fchecking
19559@opindex fno-checking
19560Enable internal consistency checking. The default depends on
19561the compiler configuration. @option{-fchecking=2} enables further
19562internal consistency checking that might affect code generation.
19563
19564@item -frandom-seed=@var{string}
19565@opindex frandom-seed
19566This option provides a seed that GCC uses in place of
19567random numbers in generating certain symbol names
19568that have to be different in every compiled file. It is also used to
19569place unique stamps in coverage data files and the object files that
19570produce them. You can use the @option{-frandom-seed} option to produce
19571reproducibly identical object files.
19572
19573The @var{string} can either be a number (decimal, octal or hex) or an
19574arbitrary string (in which case it's converted to a number by
19575computing CRC32).
19576
19577The @var{string} should be different for every file you compile.
19578
19579@item -save-temps
19580@opindex save-temps
19581Store the usual ``temporary'' intermediate files permanently; name them
19582as auxiliary output files, as specified described under
19583@option{-dumpbase} and @option{-dumpdir}.
19584
19585When used in combination with the @option{-x} command-line option,
19586@option{-save-temps} is sensible enough to avoid overwriting an
19587input source file with the same extension as an intermediate file.
19588The corresponding intermediate file may be obtained by renaming the
19589source file before using @option{-save-temps}.
19590
19591@item -save-temps=cwd
19592@opindex save-temps=cwd
19593Equivalent to @option{-save-temps -dumpdir ./}.
19594
19595@item -save-temps=obj
19596@opindex save-temps=obj
19597Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
19598@file{outdir/} is the directory of the output file specified after the
19599@option{-o} option, including any directory separators. If the
19600@option{-o} option is not used, the @option{-save-temps=obj} switch
19601behaves like @option{-save-temps=cwd}.
19602
19603@item -time@r{[}=@var{file}@r{]}
19604@opindex time
19605Report the CPU time taken by each subprocess in the compilation
19606sequence. For C source files, this is the compiler proper and assembler
19607(plus the linker if linking is done).
19608
19609Without the specification of an output file, the output looks like this:
19610
19611@smallexample
19612# cc1 0.12 0.01
19613# as 0.00 0.01
19614@end smallexample
19615
19616The first number on each line is the ``user time'', that is time spent
19617executing the program itself. The second number is ``system time'',
19618time spent executing operating system routines on behalf of the program.
19619Both numbers are in seconds.
19620
19621With the specification of an output file, the output is appended to the
19622named file, and it looks like this:
19623
19624@smallexample
196250.12 0.01 cc1 @var{options}
196260.00 0.01 as @var{options}
19627@end smallexample
19628
19629The ``user time'' and the ``system time'' are moved before the program
19630name, and the options passed to the program are displayed, so that one
19631can later tell what file was being compiled, and with which options.
19632
19633@item -fdump-final-insns@r{[}=@var{file}@r{]}
19634@opindex fdump-final-insns
19635Dump the final internal representation (RTL) to @var{file}. If the
19636optional argument is omitted (or if @var{file} is @code{.}), the name
19637of the dump file is determined by appending @code{.gkd} to the
19638dump base name, see @option{-dumpbase}.
19639
19640@item -fcompare-debug@r{[}=@var{opts}@r{]}
19641@opindex fcompare-debug
19642@opindex fno-compare-debug
19643If no error occurs during compilation, run the compiler a second time,
19644adding @var{opts} and @option{-fcompare-debug-second} to the arguments
19645passed to the second compilation. Dump the final internal
19646representation in both compilations, and print an error if they differ.
19647
19648If the equal sign is omitted, the default @option{-gtoggle} is used.
19649
19650The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
19651and nonzero, implicitly enables @option{-fcompare-debug}. If
19652@env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
19653then it is used for @var{opts}, otherwise the default @option{-gtoggle}
19654is used.
19655
19656@option{-fcompare-debug=}, with the equal sign but without @var{opts},
19657is equivalent to @option{-fno-compare-debug}, which disables the dumping
19658of the final representation and the second compilation, preventing even
19659@env{GCC_COMPARE_DEBUG} from taking effect.
19660
19661To verify full coverage during @option{-fcompare-debug} testing, set
19662@env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
19663which GCC rejects as an invalid option in any actual compilation
19664(rather than preprocessing, assembly or linking). To get just a
19665warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
19666not overridden} will do.
19667
19668@item -fcompare-debug-second
19669@opindex fcompare-debug-second
19670This option is implicitly passed to the compiler for the second
19671compilation requested by @option{-fcompare-debug}, along with options to
19672silence warnings, and omitting other options that would cause the compiler
19673to produce output to files or to standard output as a side effect. Dump
19674files and preserved temporary files are renamed so as to contain the
19675@code{.gk} additional extension during the second compilation, to avoid
19676overwriting those generated by the first.
19677
19678When this option is passed to the compiler driver, it causes the
19679@emph{first} compilation to be skipped, which makes it useful for little
19680other than debugging the compiler proper.
19681
19682@item -gtoggle
19683@opindex gtoggle
19684Turn off generation of debug info, if leaving out this option
19685generates it, or turn it on at level 2 otherwise. The position of this
19686argument in the command line does not matter; it takes effect after all
19687other options are processed, and it does so only once, no matter how
19688many times it is given. This is mainly intended to be used with
19689@option{-fcompare-debug}.
19690
19691@item -fvar-tracking-assignments-toggle
19692@opindex fvar-tracking-assignments-toggle
19693@opindex fno-var-tracking-assignments-toggle
19694Toggle @option{-fvar-tracking-assignments}, in the same way that
19695@option{-gtoggle} toggles @option{-g}.
19696
19697@item -Q
19698@opindex Q
19699Makes the compiler print out each function name as it is compiled, and
19700print some statistics about each pass when it finishes.
19701
19702@item -ftime-report
19703@opindex ftime-report
19704Makes the compiler print some statistics about the time consumed by each
19705pass when it finishes.
19706
19707@item -ftime-report-details
19708@opindex ftime-report-details
19709Record the time consumed by infrastructure parts separately for each pass.
19710
19711@item -fira-verbose=@var{n}
19712@opindex fira-verbose
19713Control the verbosity of the dump file for the integrated register allocator.
19714The default value is 5. If the value @var{n} is greater or equal to 10,
19715the dump output is sent to stderr using the same format as @var{n} minus 10.
19716
19717@item -flto-report
19718@opindex flto-report
19719Prints a report with internal details on the workings of the link-time
19720optimizer. The contents of this report vary from version to version.
19721It is meant to be useful to GCC developers when processing object
19722files in LTO mode (via @option{-flto}).
19723
19724Disabled by default.
19725
19726@item -flto-report-wpa
19727@opindex flto-report-wpa
19728Like @option{-flto-report}, but only print for the WPA phase of link-time
19729optimization.
19730
19731@item -fmem-report
19732@opindex fmem-report
19733Makes the compiler print some statistics about permanent memory
19734allocation when it finishes.
19735
19736@item -fmem-report-wpa
19737@opindex fmem-report-wpa
19738Makes the compiler print some statistics about permanent memory
19739allocation for the WPA phase only.
19740
19741@item -fpre-ipa-mem-report
19742@opindex fpre-ipa-mem-report
19743@item -fpost-ipa-mem-report
19744@opindex fpost-ipa-mem-report
19745Makes the compiler print some statistics about permanent memory
19746allocation before or after interprocedural optimization.
19747
19748@item -fmultiflags
19749@opindex fmultiflags
19750This option enables multilib-aware @code{TFLAGS} to be used to build
19751target libraries with options different from those the compiler is
19752configured to use by default, through the use of specs (@xref{Spec
19753Files}) set up by compiler internals, by the target, or by builders at
19754configure time.
19755
19756Like @code{TFLAGS}, this allows the target libraries to be built for
19757portable baseline environments, while the compiler defaults to more
19758demanding ones. That's useful because users can easily override the
19759defaults the compiler is configured to use to build their own programs,
19760if the defaults are not ideal for their target environment, whereas
19761rebuilding the runtime libraries is usually not as easy or desirable.
19762
19763Unlike @code{TFLAGS}, the use of specs enables different flags to be
19764selected for different multilibs. The way to accomplish that is to
19765build with @samp{make TFLAGS=-fmultiflags}, after configuring
19766@samp{--with-specs=%@{fmultiflags:...@}}.
19767
19768This option is discarded by the driver once it's done processing driver
19769self spec.
19770
19771It is also useful to check that @code{TFLAGS} are being used to build
19772all target libraries, by configuring a non-bootstrap compiler
19773@samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building
19774the compiler and target libraries.
19775
19776@item -fprofile-report
19777@opindex fprofile-report
19778Makes the compiler print some statistics about consistency of the
19779(estimated) profile and effect of individual passes.
19780
19781@item -fstack-usage
19782@opindex fstack-usage
19783Makes the compiler output stack usage information for the program, on a
19784per-function basis. The filename for the dump is made by appending
19785@file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
19786the output file, if explicitly specified and it is not an executable,
19787otherwise it is the basename of the source file. An entry is made up
19788of three fields:
19789
19790@itemize
19791@item
19792The name of the function.
19793@item
19794A number of bytes.
19795@item
19796One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
19797@end itemize
19798
19799The qualifier @code{static} means that the function manipulates the stack
19800statically: a fixed number of bytes are allocated for the frame on function
19801entry and released on function exit; no stack adjustments are otherwise made
19802in the function. The second field is this fixed number of bytes.
19803
19804The qualifier @code{dynamic} means that the function manipulates the stack
19805dynamically: in addition to the static allocation described above, stack
19806adjustments are made in the body of the function, for example to push/pop
19807arguments around function calls. If the qualifier @code{bounded} is also
19808present, the amount of these adjustments is bounded at compile time and
19809the second field is an upper bound of the total amount of stack used by
19810the function. If it is not present, the amount of these adjustments is
19811not bounded at compile time and the second field only represents the
19812bounded part.
19813
19814@item -fstats
19815@opindex fstats
19816Emit statistics about front-end processing at the end of the compilation.
19817This option is supported only by the C++ front end, and
19818the information is generally only useful to the G++ development team.
19819
19820@item -fdbg-cnt-list
19821@opindex fdbg-cnt-list
19822Print the name and the counter upper bound for all debug counters.
19823
19824
19825@item -fdbg-cnt=@var{counter-value-list}
19826@opindex fdbg-cnt
19827Set the internal debug counter lower and upper bound. @var{counter-value-list}
19828is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
19829[:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
19830the name of the counter and list of closed intervals.
19831The @var{lower_bound} is optional and is zero
19832initialized if not set.
19833For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
19834@code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
19835eleventh invocation.
19836For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
19837
19838@item -print-file-name=@var{library}
19839@opindex print-file-name
19840Print the full absolute name of the library file @var{library} that
19841would be used when linking---and don't do anything else. With this
19842option, GCC does not compile or link anything; it just prints the
19843file name.
19844
19845@item -print-multi-directory
19846@opindex print-multi-directory
19847Print the directory name corresponding to the multilib selected by any
19848other switches present in the command line. This directory is supposed
19849to exist in @env{GCC_EXEC_PREFIX}.
19850
19851@item -print-multi-lib
19852@opindex print-multi-lib
19853Print the mapping from multilib directory names to compiler switches
19854that enable them. The directory name is separated from the switches by
19855@samp{;}, and each switch starts with an @samp{@@} instead of the
19856@samp{-}, without spaces between multiple switches. This is supposed to
19857ease shell processing.
19858
19859@item -print-multi-os-directory
19860@opindex print-multi-os-directory
19861Print the path to OS libraries for the selected
19862multilib, relative to some @file{lib} subdirectory. If OS libraries are
19863present in the @file{lib} subdirectory and no multilibs are used, this is
19864usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
19865sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
19866@file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
19867subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
19868
19869@item -print-multiarch
19870@opindex print-multiarch
19871Print the path to OS libraries for the selected multiarch,
19872relative to some @file{lib} subdirectory.
19873
19874@item -print-prog-name=@var{program}
19875@opindex print-prog-name
19876Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
19877
19878@item -print-libgcc-file-name
19879@opindex print-libgcc-file-name
19880Same as @option{-print-file-name=libgcc.a}.
19881
19882This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
19883but you do want to link with @file{libgcc.a}. You can do:
19884
19885@smallexample
19886gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
19887@end smallexample
19888
19889@item -print-search-dirs
19890@opindex print-search-dirs
19891Print the name of the configured installation directory and a list of
19892program and library directories @command{gcc} searches---and don't do anything else.
19893
19894This is useful when @command{gcc} prints the error message
19895@samp{installation problem, cannot exec cpp0: No such file or directory}.
19896To resolve this you either need to put @file{cpp0} and the other compiler
19897components where @command{gcc} expects to find them, or you can set the environment
19898variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
19899Don't forget the trailing @samp{/}.
19900@xref{Environment Variables}.
19901
19902@item -print-sysroot
19903@opindex print-sysroot
19904Print the target sysroot directory that is used during
19905compilation. This is the target sysroot specified either at configure
19906time or using the @option{--sysroot} option, possibly with an extra
19907suffix that depends on compilation options. If no target sysroot is
19908specified, the option prints nothing.
19909
19910@item -print-sysroot-headers-suffix
19911@opindex print-sysroot-headers-suffix
19912Print the suffix added to the target sysroot when searching for
19913headers, or give an error if the compiler is not configured with such
19914a suffix---and don't do anything else.
19915
19916@item -dumpmachine
19917@opindex dumpmachine
19918Print the compiler's target machine (for example,
19919@samp{i686-pc-linux-gnu})---and don't do anything else.
19920
19921@item -dumpversion
19922@opindex dumpversion
19923Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
19924anything else. This is the compiler version used in filesystem paths and
19925specs. Depending on how the compiler has been configured it can be just
19926a single number (major version), two numbers separated by a dot (major and
19927minor version) or three numbers separated by dots (major, minor and patchlevel
19928version).
19929
19930@item -dumpfullversion
19931@opindex dumpfullversion
19932Print the full compiler version---and don't do anything else. The output is
19933always three numbers separated by dots, major, minor and patchlevel version.
19934
19935@item -dumpspecs
19936@opindex dumpspecs
19937Print the compiler's built-in specs---and don't do anything else. (This
19938is used when GCC itself is being built.) @xref{Spec Files}.
19939@end table
19940
19941@node Submodel Options
19942@section Machine-Dependent Options
19943@cindex submodel options
19944@cindex specifying hardware config
19945@cindex hardware models and configurations, specifying
19946@cindex target-dependent options
19947@cindex machine-dependent options
19948
19949Each target machine supported by GCC can have its own options---for
19950example, to allow you to compile for a particular processor variant or
19951ABI, or to control optimizations specific to that machine. By
19952convention, the names of machine-specific options start with
19953@samp{-m}.
19954
19955Some configurations of the compiler also support additional target-specific
19956options, usually for compatibility with other compilers on the same
19957platform.
19958
19959@c This list is ordered alphanumerically by subsection name.
19960@c It should be the same order and spelling as these options are listed
19961@c in Machine Dependent Options
19962
19963@menu
19964* AArch64 Options::
19965* Adapteva Epiphany Options::
19966* AMD GCN Options::
19967* ARC Options::
19968* ARM Options::
19969* AVR Options::
19970* Blackfin Options::
19971* C6X Options::
19972* CRIS Options::
19973* C-SKY Options::
19974* Darwin Options::
19975* DEC Alpha Options::
19976* eBPF Options::
19977* FR30 Options::
19978* FT32 Options::
19979* FRV Options::
19980* GNU/Linux Options::
19981* H8/300 Options::
19982* HPPA Options::
19983* IA-64 Options::
19984* LM32 Options::
19985* LoongArch Options::
19986* M32C Options::
19987* M32R/D Options::
19988* M680x0 Options::
19989* MCore Options::
d77de738
ML
19990* MicroBlaze Options::
19991* MIPS Options::
19992* MMIX Options::
19993* MN10300 Options::
19994* Moxie Options::
19995* MSP430 Options::
19996* NDS32 Options::
19997* Nios II Options::
19998* Nvidia PTX Options::
19999* OpenRISC Options::
20000* PDP-11 Options::
d77de738
ML
20001* PowerPC Options::
20002* PRU Options::
20003* RISC-V Options::
20004* RL78 Options::
20005* RS/6000 and PowerPC Options::
20006* RX Options::
20007* S/390 and zSeries Options::
d77de738
ML
20008* SH Options::
20009* Solaris 2 Options::
20010* SPARC Options::
20011* System V Options::
20012* V850 Options::
20013* VAX Options::
20014* Visium Options::
20015* VMS Options::
20016* VxWorks Options::
20017* x86 Options::
20018* x86 Windows Options::
20019* Xstormy16 Options::
20020* Xtensa Options::
20021* zSeries Options::
20022@end menu
20023
20024@node AArch64 Options
20025@subsection AArch64 Options
20026@cindex AArch64 Options
20027
20028These options are defined for AArch64 implementations:
20029
20030@table @gcctabopt
20031
20032@item -mabi=@var{name}
20033@opindex mabi
20034Generate code for the specified data model. Permissible values
20035are @samp{ilp32} for SysV-like data model where int, long int and pointers
20036are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
20037but long int and pointers are 64 bits.
20038
20039The default depends on the specific target configuration. Note that
20040the LP64 and ILP32 ABIs are not link-compatible; you must compile your
20041entire program with the same ABI, and link with a compatible set of libraries.
20042
20043@item -mbig-endian
20044@opindex mbig-endian
20045Generate big-endian code. This is the default when GCC is configured for an
20046@samp{aarch64_be-*-*} target.
20047
20048@item -mgeneral-regs-only
20049@opindex mgeneral-regs-only
20050Generate code which uses only the general-purpose registers. This will prevent
20051the compiler from using floating-point and Advanced SIMD registers but will not
20052impose any restrictions on the assembler.
20053
20054@item -mlittle-endian
20055@opindex mlittle-endian
20056Generate little-endian code. This is the default when GCC is configured for an
20057@samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
20058
20059@item -mcmodel=tiny
20060@opindex mcmodel=tiny
20061Generate code for the tiny code model. The program and its statically defined
20062symbols must be within 1MB of each other. Programs can be statically or
20063dynamically linked.
20064
20065@item -mcmodel=small
20066@opindex mcmodel=small
20067Generate code for the small code model. The program and its statically defined
20068symbols must be within 4GB of each other. Programs can be statically or
20069dynamically linked. This is the default code model.
20070
20071@item -mcmodel=large
20072@opindex mcmodel=large
20073Generate code for the large code model. This makes no assumptions about
20074addresses and sizes of sections. Programs can be statically linked only. The
20075@option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
20076@option{-fpic} and @option{-fPIC}.
20077
20078@item -mstrict-align
20079@itemx -mno-strict-align
20080@opindex mstrict-align
20081@opindex mno-strict-align
20082Avoid or allow generating memory accesses that may not be aligned on a natural
20083object boundary as described in the architecture specification.
20084
20085@item -momit-leaf-frame-pointer
20086@itemx -mno-omit-leaf-frame-pointer
20087@opindex momit-leaf-frame-pointer
20088@opindex mno-omit-leaf-frame-pointer
20089Omit or keep the frame pointer in leaf functions. The former behavior is the
20090default.
20091
20092@item -mstack-protector-guard=@var{guard}
20093@itemx -mstack-protector-guard-reg=@var{reg}
20094@itemx -mstack-protector-guard-offset=@var{offset}
20095@opindex mstack-protector-guard
20096@opindex mstack-protector-guard-reg
20097@opindex mstack-protector-guard-offset
20098Generate stack protection code using canary at @var{guard}. Supported
20099locations are @samp{global} for a global canary or @samp{sysreg} for a
20100canary in an appropriate system register.
20101
20102With the latter choice the options
20103@option{-mstack-protector-guard-reg=@var{reg}} and
20104@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
20105which system register to use as base register for reading the canary,
20106and from what offset from that base register. There is no default
20107register or offset as this is entirely for use within the Linux
20108kernel.
20109
20110@item -mtls-dialect=desc
20111@opindex mtls-dialect=desc
20112Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
20113of TLS variables. This is the default.
20114
20115@item -mtls-dialect=traditional
20116@opindex mtls-dialect=traditional
20117Use traditional TLS as the thread-local storage mechanism for dynamic accesses
20118of TLS variables.
20119
20120@item -mtls-size=@var{size}
20121@opindex mtls-size
20122Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
20123This option requires binutils 2.26 or newer.
20124
20125@item -mfix-cortex-a53-835769
20126@itemx -mno-fix-cortex-a53-835769
20127@opindex mfix-cortex-a53-835769
20128@opindex mno-fix-cortex-a53-835769
20129Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
20130This involves inserting a NOP instruction between memory instructions and
2013164-bit integer multiply-accumulate instructions.
20132
20133@item -mfix-cortex-a53-843419
20134@itemx -mno-fix-cortex-a53-843419
20135@opindex mfix-cortex-a53-843419
20136@opindex mno-fix-cortex-a53-843419
20137Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
20138This erratum workaround is made at link time and this will only pass the
20139corresponding flag to the linker.
20140
20141@item -mlow-precision-recip-sqrt
20142@itemx -mno-low-precision-recip-sqrt
20143@opindex mlow-precision-recip-sqrt
20144@opindex mno-low-precision-recip-sqrt
20145Enable or disable the reciprocal square root approximation.
20146This option only has an effect if @option{-ffast-math} or
20147@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20148precision of reciprocal square root results to about 16 bits for
20149single precision and to 32 bits for double precision.
20150
20151@item -mlow-precision-sqrt
20152@itemx -mno-low-precision-sqrt
20153@opindex mlow-precision-sqrt
20154@opindex mno-low-precision-sqrt
20155Enable or disable the square root approximation.
20156This option only has an effect if @option{-ffast-math} or
20157@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20158precision of square root results to about 16 bits for
20159single precision and to 32 bits for double precision.
20160If enabled, it implies @option{-mlow-precision-recip-sqrt}.
20161
20162@item -mlow-precision-div
20163@itemx -mno-low-precision-div
20164@opindex mlow-precision-div
20165@opindex mno-low-precision-div
20166Enable or disable the division approximation.
20167This option only has an effect if @option{-ffast-math} or
20168@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20169precision of division results to about 16 bits for
20170single precision and to 32 bits for double precision.
20171
20172@item -mtrack-speculation
20173@itemx -mno-track-speculation
20174Enable or disable generation of additional code to track speculative
20175execution through conditional branches. The tracking state can then
20176be used by the compiler when expanding calls to
20177@code{__builtin_speculation_safe_copy} to permit a more efficient code
20178sequence to be generated.
20179
20180@item -moutline-atomics
20181@itemx -mno-outline-atomics
20182Enable or disable calls to out-of-line helpers to implement atomic operations.
20183These helpers will, at runtime, determine if the LSE instructions from
20184ARMv8.1-A can be used; if not, they will use the load/store-exclusive
20185instructions that are present in the base ARMv8.0 ISA.
20186
20187This option is only applicable when compiling for the base ARMv8.0
20188instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
20189or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
20190used directly. The same applies when using @option{-mcpu=} when the
20191selected cpu supports the @samp{lse} feature.
20192This option is on by default.
20193
20194@item -march=@var{name}
20195@opindex march
20196Specify the name of the target architecture and, optionally, one or
20197more feature modifiers. This option has the form
20198@option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
20199
20200The table below summarizes the permissible values for @var{arch}
20201and the features that they enable by default:
20202
20203@multitable @columnfractions 0.20 0.20 0.60
20204@headitem @var{arch} value @tab Architecture @tab Includes by default
20205@item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
20206@item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
20207@item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
20208@item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}
20209@item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}
20210@item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}
20211@item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
20212@item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64}
20213@item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
20214@item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
20215@item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
20216@item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64}
20217@item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
20218@item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
20219@end multitable
20220
20221The value @samp{native} is available on native AArch64 GNU/Linux and
20222causes the compiler to pick the architecture of the host system. This
20223option has no effect if the compiler is unable to recognize the
20224architecture of the host system,
20225
20226The permissible values for @var{feature} are listed in the sub-section
20227on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20228Feature Modifiers}. Where conflicting feature modifiers are
20229specified, the right-most feature is used.
20230
20231GCC uses @var{name} to determine what kind of instructions it can emit
20232when generating assembly code. If @option{-march} is specified
20233without either of @option{-mtune} or @option{-mcpu} also being
20234specified, the code is tuned to perform well across a range of target
20235processors implementing the target architecture.
20236
20237@item -mtune=@var{name}
20238@opindex mtune
20239Specify the name of the target processor for which GCC should tune the
20240performance of the code. Permissible values for this option are:
20241@samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
20242@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
20243@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
20244@samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
20245@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
20246@samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
20247@samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
20248@samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx},
20249@samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
20250@samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
20251@samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
20252@samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
20253@samp{octeontx2f95mm},
20254@samp{a64fx},
20255@samp{thunderx}, @samp{thunderxt88},
20256@samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
20257@samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
20258@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20259@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20260@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
ce51e843 20261@samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2},
e07556a8
SP
20262@samp{cortex-x3}, @samp{cortex-a510}, @samp{cortex-a710}, @samp{cortex-a715},
20263@samp{ampere1}, @samp{ampere1a}, and @samp{native}.
d77de738
ML
20264
20265The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20266@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20267@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC
20268should tune for a big.LITTLE system.
20269
20270The value @samp{neoverse-512tvb} specifies that GCC should tune
20271for Neoverse cores that (a) implement SVE and (b) have a total vector
20272bandwidth of 512 bits per cycle. In other words, the option tells GCC to
20273tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
20274instructions a cycle and that can execute an equivalent number of SVE
20275arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
20276This is more general than tuning for a specific core like Neoverse V1
20277but is more specific than the default tuning described below.
20278
20279Additionally on native AArch64 GNU/Linux systems the value
20280@samp{native} tunes performance to the host system. This option has no effect
20281if the compiler is unable to recognize the processor of the host system.
20282
20283Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
20284are specified, the code is tuned to perform well across a range
20285of target processors.
20286
20287This option cannot be suffixed by feature modifiers.
20288
20289@item -mcpu=@var{name}
20290@opindex mcpu
20291Specify the name of the target processor, optionally suffixed by one
20292or more feature modifiers. This option has the form
20293@option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
20294the permissible values for @var{cpu} are the same as those available
20295for @option{-mtune}. The permissible values for @var{feature} are
20296documented in the sub-section on
20297@ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20298Feature Modifiers}. Where conflicting feature modifiers are
20299specified, the right-most feature is used.
20300
20301GCC uses @var{name} to determine what kind of instructions it can emit when
20302generating assembly code (as if by @option{-march}) and to determine
20303the target processor for which to tune for performance (as if
20304by @option{-mtune}). Where this option is used in conjunction
20305with @option{-march} or @option{-mtune}, those options take precedence
20306over the appropriate part of this option.
20307
20308@option{-mcpu=neoverse-512tvb} is special in that it does not refer
20309to a specific core, but instead refers to all Neoverse cores that
20310(a) implement SVE and (b) have a total vector bandwidth of 512 bits
20311a cycle. Unless overridden by @option{-march},
20312@option{-mcpu=neoverse-512tvb} generates code that can run on a
20313Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
20314these properties. Unless overridden by @option{-mtune},
20315@option{-mcpu=neoverse-512tvb} tunes code in the same way as for
20316@option{-mtune=neoverse-512tvb}.
20317
20318@item -moverride=@var{string}
20319@opindex moverride
20320Override tuning decisions made by the back-end in response to a
20321@option{-mtune=} switch. The syntax, semantics, and accepted values
20322for @var{string} in this option are not guaranteed to be consistent
20323across releases.
20324
20325This option is only intended to be useful when developing GCC.
20326
20327@item -mverbose-cost-dump
20328@opindex mverbose-cost-dump
20329Enable verbose cost model dumping in the debug dump files. This option is
20330provided for use in debugging the compiler.
20331
20332@item -mpc-relative-literal-loads
20333@itemx -mno-pc-relative-literal-loads
20334@opindex mpc-relative-literal-loads
20335@opindex mno-pc-relative-literal-loads
20336Enable or disable PC-relative literal loads. With this option literal pools are
20337accessed using a single instruction and emitted after each function. This
20338limits the maximum size of functions to 1MB. This is enabled by default for
20339@option{-mcmodel=tiny}.
20340
20341@item -msign-return-address=@var{scope}
20342@opindex msign-return-address
20343Select the function scope on which return address signing will be applied.
20344Permissible values are @samp{none}, which disables return address signing,
20345@samp{non-leaf}, which enables pointer signing for functions which are not leaf
20346functions, and @samp{all}, which enables pointer signing for all functions. The
20347default value is @samp{none}. This option has been deprecated by
20348-mbranch-protection.
20349
20350@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}
20351@opindex mbranch-protection
20352Select the branch protection features to use.
20353@samp{none} is the default and turns off all types of branch protection.
20354@samp{standard} turns on all types of branch protection features. If a feature
20355has additional tuning options, then @samp{standard} sets it to its standard
20356level.
20357@samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
20358level: signing functions that save the return address to memory (non-leaf
20359functions will practically always do this) using the a-key. The optional
20360argument @samp{leaf} can be used to extend the signing to include leaf
20361functions. The optional argument @samp{b-key} can be used to sign the functions
20362with the B-key instead of the A-key.
20363@samp{bti} turns on branch target identification mechanism.
20364
20365@item -mharden-sls=@var{opts}
20366@opindex mharden-sls
20367Enable compiler hardening against straight line speculation (SLS).
20368@var{opts} is a comma-separated list of the following options:
20369@table @samp
20370@item retbr
20371@item blr
20372@end table
20373In addition, @samp{-mharden-sls=all} enables all SLS hardening while
20374@samp{-mharden-sls=none} disables all SLS hardening.
20375
20376@item -msve-vector-bits=@var{bits}
20377@opindex msve-vector-bits
20378Specify the number of bits in an SVE vector register. This option only has
20379an effect when SVE is enabled.
20380
20381GCC supports two forms of SVE code generation: ``vector-length
20382agnostic'' output that works with any size of vector register and
20383``vector-length specific'' output that allows GCC to make assumptions
20384about the vector length when it is useful for optimization reasons.
20385The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
20386@samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
20387Specifying @samp{scalable} selects vector-length agnostic
20388output. At present @samp{-msve-vector-bits=128} also generates vector-length
20389agnostic output for big-endian targets. All other values generate
20390vector-length specific code. The behavior of these values may change
20391in future releases and no value except @samp{scalable} should be
20392relied on for producing code that is portable across different
20393hardware SVE vector lengths.
20394
20395The default is @samp{-msve-vector-bits=scalable}, which produces
20396vector-length agnostic code.
20397@end table
20398
20399@subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
20400@anchor{aarch64-feature-modifiers}
20401@cindex @option{-march} feature modifiers
20402@cindex @option{-mcpu} feature modifiers
20403Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
20404the following and their inverses @option{no@var{feature}}:
20405
20406@table @samp
20407@item crc
20408Enable CRC extension. This is on by default for
20409@option{-march=armv8.1-a}.
20410@item crypto
20411Enable Crypto extension. This also enables Advanced SIMD and floating-point
20412instructions.
20413@item fp
20414Enable floating-point instructions. This is on by default for all possible
20415values for options @option{-march} and @option{-mcpu}.
20416@item simd
20417Enable Advanced SIMD instructions. This also enables floating-point
20418instructions. This is on by default for all possible values for options
20419@option{-march} and @option{-mcpu}.
20420@item sve
20421Enable Scalable Vector Extension instructions. This also enables Advanced
20422SIMD and floating-point instructions.
20423@item lse
20424Enable Large System Extension instructions. This is on by default for
20425@option{-march=armv8.1-a}.
20426@item rdma
20427Enable Round Double Multiply Accumulate instructions. This is on by default
20428for @option{-march=armv8.1-a}.
20429@item fp16
20430Enable FP16 extension. This also enables floating-point instructions.
20431@item fp16fml
20432Enable FP16 fmla extension. This also enables FP16 extensions and
20433floating-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.
20434
20435@item rcpc
0431e8ae
AV
20436Enable the RCpc extension. This enables the use of the LDAPR instructions for
20437load-acquire atomic semantics, and passes it on to the assembler, enabling
20438inline asm statements to use instructions from the RCpc extension.
d77de738
ML
20439@item dotprod
20440Enable the Dot Product extension. This also enables Advanced SIMD instructions.
20441@item aes
20442Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
20443SIMD instructions.
20444@item sha2
20445Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
20446@item sha3
20447Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
20448instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
20449@item sm4
20450Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
20451Use of this option with architectures prior to Armv8.2-A is not supported.
20452@item profile
20453Enable the Statistical Profiling extension. This option is only to enable the
20454extension at the assembler level and does not affect code generation.
20455@item rng
20456Enable the Armv8.5-a Random Number instructions. This option is only to
20457enable the extension at the assembler level and does not affect code
20458generation.
20459@item memtag
20460Enable the Armv8.5-a Memory Tagging Extensions.
20461Use of this option with architectures prior to Armv8.5-A is not supported.
20462@item sb
20463Enable the Armv8-a Speculation Barrier instruction. This option is only to
20464enable the extension at the assembler level and does not affect code
20465generation. This option is enabled by default for @option{-march=armv8.5-a}.
20466@item ssbs
20467Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
20468is only to enable the extension at the assembler level and does not affect code
20469generation. This option is enabled by default for @option{-march=armv8.5-a}.
20470@item predres
20471Enable the Armv8-a Execution and Data Prediction Restriction instructions.
20472This option is only to enable the extension at the assembler level and does
20473not affect code generation. This option is enabled by default for
20474@option{-march=armv8.5-a}.
20475@item sve2
20476Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
20477instructions.
20478@item sve2-bitperm
20479Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
20480@item sve2-sm4
20481Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
20482@item sve2-aes
20483Enable SVE2 aes instructions. This also enables SVE2 instructions.
20484@item sve2-sha3
20485Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
20486@item tme
20487Enable the Transactional Memory Extension.
20488@item i8mm
20489Enable 8-bit Integer Matrix Multiply instructions. This also enables
20490Advanced SIMD and floating-point instructions. This option is enabled by
20491default for @option{-march=armv8.6-a}. Use of this option with architectures
20492prior to Armv8.2-A is not supported.
20493@item f32mm
20494Enable 32-bit Floating point Matrix Multiply instructions. This also enables
20495SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20496not supported.
20497@item f64mm
20498Enable 64-bit Floating point Matrix Multiply instructions. This also enables
20499SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20500not supported.
20501@item bf16
20502Enable brain half-precision floating-point instructions. This also enables
20503Advanced SIMD and floating-point instructions. This option is enabled by
20504default for @option{-march=armv8.6-a}. Use of this option with architectures
20505prior to Armv8.2-A is not supported.
20506@item ls64
20507Enable the 64-byte atomic load and store instructions for accelerators.
20508This option is enabled by default for @option{-march=armv8.7-a}.
20509@item mops
20510Enable the instructions to accelerate memory operations like @code{memcpy},
20511@code{memmove}, @code{memset}. This option is enabled by default for
20512@option{-march=armv8.8-a}
20513@item flagm
20514Enable the Flag Manipulation instructions Extension.
20515@item pauth
20516Enable the Pointer Authentication Extension.
d758d190
KT
20517@item cssc
20518Enable the Common Short Sequence Compression instructions.
d77de738
ML
20519
20520@end table
20521
20522Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
20523which implies @option{fp}.
20524Conversely, @option{nofp} implies @option{nosimd}, which implies
20525@option{nocrypto}, @option{noaes} and @option{nosha2}.
20526
20527@node Adapteva Epiphany Options
20528@subsection Adapteva Epiphany Options
20529
20530These @samp{-m} options are defined for Adapteva Epiphany:
20531
20532@table @gcctabopt
20533@item -mhalf-reg-file
20534@opindex mhalf-reg-file
20535Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
20536That allows code to run on hardware variants that lack these registers.
20537
20538@item -mprefer-short-insn-regs
20539@opindex mprefer-short-insn-regs
20540Preferentially allocate registers that allow short instruction generation.
20541This can result in increased instruction count, so this may either reduce or
20542increase overall code size.
20543
20544@item -mbranch-cost=@var{num}
20545@opindex mbranch-cost
20546Set the cost of branches to roughly @var{num} ``simple'' instructions.
20547This cost is only a heuristic and is not guaranteed to produce
20548consistent results across releases.
20549
20550@item -mcmove
20551@opindex mcmove
20552Enable the generation of conditional moves.
20553
20554@item -mnops=@var{num}
20555@opindex mnops
20556Emit @var{num} NOPs before every other generated instruction.
20557
20558@item -mno-soft-cmpsf
20559@opindex mno-soft-cmpsf
20560@opindex msoft-cmpsf
20561For single-precision floating-point comparisons, emit an @code{fsub} instruction
20562and test the flags. This is faster than a software comparison, but can
20563get incorrect results in the presence of NaNs, or when two different small
20564numbers are compared such that their difference is calculated as zero.
20565The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
20566software comparisons.
20567
20568@item -mstack-offset=@var{num}
20569@opindex mstack-offset
20570Set the offset between the top of the stack and the stack pointer.
20571E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
20572can be used by leaf functions without stack allocation.
20573Values other than @samp{8} or @samp{16} are untested and unlikely to work.
20574Note also that this option changes the ABI; compiling a program with a
20575different stack offset than the libraries have been compiled with
20576generally does not work.
20577This option can be useful if you want to evaluate if a different stack
20578offset would give you better code, but to actually use a different stack
20579offset to build working programs, it is recommended to configure the
20580toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
20581
20582@item -mno-round-nearest
20583@opindex mno-round-nearest
20584@opindex mround-nearest
20585Make the scheduler assume that the rounding mode has been set to
20586truncating. The default is @option{-mround-nearest}.
20587
20588@item -mlong-calls
20589@opindex mlong-calls
20590If not otherwise specified by an attribute, assume all calls might be beyond
20591the offset range of the @code{b} / @code{bl} instructions, and therefore load the
20592function address into a register before performing a (otherwise direct) call.
20593This is the default.
20594
20595@item -mshort-calls
20596@opindex short-calls
20597If not otherwise specified by an attribute, assume all direct calls are
20598in the range of the @code{b} / @code{bl} instructions, so use these instructions
20599for direct calls. The default is @option{-mlong-calls}.
20600
20601@item -msmall16
20602@opindex msmall16
20603Assume addresses can be loaded as 16-bit unsigned values. This does not
20604apply to function addresses for which @option{-mlong-calls} semantics
20605are in effect.
20606
20607@item -mfp-mode=@var{mode}
20608@opindex mfp-mode
20609Set the prevailing mode of the floating-point unit.
20610This determines the floating-point mode that is provided and expected
20611at function call and return time. Making this mode match the mode you
20612predominantly need at function start can make your programs smaller and
20613faster by avoiding unnecessary mode switches.
20614
20615@var{mode} can be set to one the following values:
20616
20617@table @samp
20618@item caller
20619Any mode at function entry is valid, and retained or restored when
20620the function returns, and when it calls other functions.
20621This mode is useful for compiling libraries or other compilation units
20622you might want to incorporate into different programs with different
20623prevailing FPU modes, and the convenience of being able to use a single
20624object file outweighs the size and speed overhead for any extra
20625mode switching that might be needed, compared with what would be needed
20626with a more specific choice of prevailing FPU mode.
20627
20628@item truncate
20629This is the mode used for floating-point calculations with
20630truncating (i.e.@: round towards zero) rounding mode. That includes
20631conversion from floating point to integer.
20632
20633@item round-nearest
20634This is the mode used for floating-point calculations with
20635round-to-nearest-or-even rounding mode.
20636
20637@item int
20638This is the mode used to perform integer calculations in the FPU, e.g.@:
20639integer multiply, or integer multiply-and-accumulate.
20640@end table
20641
20642The default is @option{-mfp-mode=caller}
20643
20644@item -mno-split-lohi
20645@itemx -mno-postinc
20646@itemx -mno-postmodify
20647@opindex mno-split-lohi
20648@opindex msplit-lohi
20649@opindex mno-postinc
20650@opindex mpostinc
20651@opindex mno-postmodify
20652@opindex mpostmodify
20653Code generation tweaks that disable, respectively, splitting of 32-bit
20654loads, generation of post-increment addresses, and generation of
20655post-modify addresses. The defaults are @option{msplit-lohi},
20656@option{-mpost-inc}, and @option{-mpost-modify}.
20657
20658@item -mnovect-double
20659@opindex mno-vect-double
20660@opindex mvect-double
20661Change the preferred SIMD mode to SImode. The default is
20662@option{-mvect-double}, which uses DImode as preferred SIMD mode.
20663
20664@item -max-vect-align=@var{num}
20665@opindex max-vect-align
20666The maximum alignment for SIMD vector mode types.
20667@var{num} may be 4 or 8. The default is 8.
20668Note that this is an ABI change, even though many library function
20669interfaces are unaffected if they don't use SIMD vector modes
20670in places that affect size and/or alignment of relevant types.
20671
20672@item -msplit-vecmove-early
20673@opindex msplit-vecmove-early
20674Split vector moves into single word moves before reload. In theory this
20675can give better register allocation, but so far the reverse seems to be
20676generally the case.
20677
20678@item -m1reg-@var{reg}
20679@opindex m1reg-
20680Specify a register to hold the constant @minus{}1, which makes loading small negative
20681constants and certain bitmasks faster.
20682Allowable values for @var{reg} are @samp{r43} and @samp{r63},
20683which specify use of that register as a fixed register,
20684and @samp{none}, which means that no register is used for this
20685purpose. The default is @option{-m1reg-none}.
20686
20687@end table
20688
20689@node AMD GCN Options
20690@subsection AMD GCN Options
20691@cindex AMD GCN Options
20692
20693These options are defined specifically for the AMD GCN port.
20694
20695@table @gcctabopt
20696
20697@item -march=@var{gpu}
20698@opindex march
20699@itemx -mtune=@var{gpu}
20700@opindex mtune
20701Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
20702are
20703
20704@table @samp
20705@item fiji
20706Compile for GCN3 Fiji devices (gfx803).
20707
20708@item gfx900
20709Compile for GCN5 Vega 10 devices (gfx900).
20710
20711@item gfx906
20712Compile for GCN5 Vega 20 devices (gfx906).
20713
20714@item gfx908
20715Compile for CDNA1 Instinct MI100 series devices (gfx908).
20716
20717@item gfx90a
20718Compile for CDNA2 Instinct MI200 series devices (gfx90a).
20719
20720@end table
20721
20722@item -msram-ecc=on
20723@itemx -msram-ecc=off
20724@itemx -msram-ecc=any
20725@opindex msram-ecc
20726Compile binaries suitable for devices with the SRAM-ECC feature enabled,
20727disabled, or either mode. This feature can be enabled per-process on some
20728devices. The compiled code must match the device mode. The default is
20729@samp{any}, for devices that support it.
20730
20731@item -mstack-size=@var{bytes}
20732@opindex mstack-size
20733Specify how many @var{bytes} of stack space will be requested for each GPU
20734thread (wave-front). Beware that there may be many threads and limited memory
20735available. The size of the stack allocation may also have an impact on
20736run-time performance. The default is 32KB when using OpenACC or OpenMP, and
207371MB otherwise.
20738
20739@item -mxnack
20740@opindex mxnack
20741Compile binaries suitable for devices with the XNACK feature enabled. Some
20742devices always require XNACK and some allow the user to configure XNACK. The
20743compiled code must match the device mode. The default is @samp{-mno-xnack}.
20744At present this option is a placeholder for support that is not yet
20745implemented.
20746
20747@end table
20748
20749@node ARC Options
20750@subsection ARC Options
20751@cindex ARC options
20752
20753The following options control the architecture variant for which code
20754is being compiled:
20755
20756@c architecture variants
20757@table @gcctabopt
20758
20759@item -mbarrel-shifter
20760@opindex mbarrel-shifter
20761Generate instructions supported by barrel shifter. This is the default
20762unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
20763
20764@item -mjli-always
20765@opindex mjli-always
20766Force to call a function using jli_s instruction. This option is
20767valid only for ARCv2 architecture.
20768
20769@item -mcpu=@var{cpu}
20770@opindex mcpu
20771Set architecture type, register usage, and instruction scheduling
20772parameters for @var{cpu}. There are also shortcut alias options
20773available for backward compatibility and convenience. Supported
20774values for @var{cpu} are
20775
20776@table @samp
20777@opindex mA6
20778@opindex mARC600
20779@item arc600
20780Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
20781
20782@item arc601
20783@opindex mARC601
20784Compile for ARC601. Alias: @option{-mARC601}.
20785
20786@item arc700
20787@opindex mA7
20788@opindex mARC700
20789Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
20790This is the default when configured with @option{--with-cpu=arc700}@.
20791
20792@item arcem
20793Compile for ARC EM.
20794
20795@item archs
20796Compile for ARC HS.
20797
20798@item em
20799Compile for ARC EM CPU with no hardware extensions.
20800
20801@item em4
20802Compile for ARC EM4 CPU.
20803
20804@item em4_dmips
20805Compile for ARC EM4 DMIPS CPU.
20806
20807@item em4_fpus
20808Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
20809extension.
20810
20811@item em4_fpuda
20812Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
20813double assist instructions.
20814
20815@item hs
20816Compile for ARC HS CPU with no hardware extensions except the atomic
20817instructions.
20818
20819@item hs34
20820Compile for ARC HS34 CPU.
20821
20822@item hs38
20823Compile for ARC HS38 CPU.
20824
20825@item hs38_linux
20826Compile for ARC HS38 CPU with all hardware extensions on.
20827
20828@item hs4x
20829Compile for ARC HS4x CPU.
20830
20831@item hs4xd
20832Compile for ARC HS4xD CPU.
20833
20834@item hs4x_rel31
20835Compile for ARC HS4x CPU release 3.10a.
20836
20837@item arc600_norm
20838Compile for ARC 600 CPU with @code{norm} instructions enabled.
20839
20840@item arc600_mul32x16
20841Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
20842instructions enabled.
20843
20844@item arc600_mul64
20845Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
20846instructions enabled.
20847
20848@item arc601_norm
20849Compile for ARC 601 CPU with @code{norm} instructions enabled.
20850
20851@item arc601_mul32x16
20852Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
20853instructions enabled.
20854
20855@item arc601_mul64
20856Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
20857instructions enabled.
20858
20859@item nps400
20860Compile for ARC 700 on NPS400 chip.
20861
20862@item em_mini
20863Compile for ARC EM minimalist configuration featuring reduced register
20864set.
20865
20866@end table
20867
20868@item -mdpfp
20869@opindex mdpfp
20870@itemx -mdpfp-compact
20871@opindex mdpfp-compact
20872Generate double-precision FPX instructions, tuned for the compact
20873implementation.
20874
20875@item -mdpfp-fast
20876@opindex mdpfp-fast
20877Generate double-precision FPX instructions, tuned for the fast
20878implementation.
20879
20880@item -mno-dpfp-lrsr
20881@opindex mno-dpfp-lrsr
20882Disable @code{lr} and @code{sr} instructions from using FPX extension
20883aux registers.
20884
20885@item -mea
20886@opindex mea
20887Generate extended arithmetic instructions. Currently only
20888@code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
20889supported. Only valid for @option{-mcpu=ARC700}.
20890
20891@item -mno-mpy
20892@opindex mno-mpy
20893@opindex mmpy
20894Do not generate @code{mpy}-family instructions for ARC700. This option is
20895deprecated.
20896
20897@item -mmul32x16
20898@opindex mmul32x16
20899Generate 32x16-bit multiply and multiply-accumulate instructions.
20900
20901@item -mmul64
20902@opindex mmul64
20903Generate @code{mul64} and @code{mulu64} instructions.
20904Only valid for @option{-mcpu=ARC600}.
20905
20906@item -mnorm
20907@opindex mnorm
20908Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
20909is in effect.
20910
20911@item -mspfp
20912@opindex mspfp
20913@itemx -mspfp-compact
20914@opindex mspfp-compact
20915Generate single-precision FPX instructions, tuned for the compact
20916implementation.
20917
20918@item -mspfp-fast
20919@opindex mspfp-fast
20920Generate single-precision FPX instructions, tuned for the fast
20921implementation.
20922
20923@item -msimd
20924@opindex msimd
20925Enable generation of ARC SIMD instructions via target-specific
20926builtins. Only valid for @option{-mcpu=ARC700}.
20927
20928@item -msoft-float
20929@opindex msoft-float
20930This option ignored; it is provided for compatibility purposes only.
20931Software floating-point code is emitted by default, and this default
20932can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
20933@option{-mspfp-fast} for single precision, and @option{-mdpfp},
20934@option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
20935
20936@item -mswap
20937@opindex mswap
20938Generate @code{swap} instructions.
20939
20940@item -matomic
20941@opindex matomic
20942This enables use of the locked load/store conditional extension to implement
20943atomic memory built-in functions. Not available for ARC 6xx or ARC
20944EM cores.
20945
20946@item -mdiv-rem
20947@opindex mdiv-rem
20948Enable @code{div} and @code{rem} instructions for ARCv2 cores.
20949
20950@item -mcode-density
20951@opindex mcode-density
20952Enable code density instructions for ARC EM.
20953This option is on by default for ARC HS.
20954
20955@item -mll64
20956@opindex mll64
20957Enable double load/store operations for ARC HS cores.
20958
20959@item -mtp-regno=@var{regno}
20960@opindex mtp-regno
20961Specify thread pointer register number.
20962
20963@item -mmpy-option=@var{multo}
20964@opindex mmpy-option
20965Compile ARCv2 code with a multiplier design option. You can specify
20966the option using either a string or numeric value for @var{multo}.
20967@samp{wlh1} is the default value. The recognized values are:
20968
20969@table @samp
20970@item 0
20971@itemx none
20972No multiplier available.
20973
20974@item 1
20975@itemx w
2097616x16 multiplier, fully pipelined.
20977The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
20978
20979@item 2
20980@itemx wlh1
2098132x32 multiplier, fully
20982pipelined (1 stage). The following instructions are additionally
20983enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20984
20985@item 3
20986@itemx wlh2
2098732x32 multiplier, fully pipelined
20988(2 stages). The following instructions are additionally enabled: @code{mpy},
20989@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20990
20991@item 4
20992@itemx wlh3
20993Two 16x16 multipliers, blocking,
20994sequential. The following instructions are additionally enabled: @code{mpy},
20995@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20996
20997@item 5
20998@itemx wlh4
20999One 16x16 multiplier, blocking,
21000sequential. The following instructions are additionally enabled: @code{mpy},
21001@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21002
21003@item 6
21004@itemx wlh5
21005One 32x4 multiplier, blocking,
21006sequential. The following instructions are additionally enabled: @code{mpy},
21007@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21008
21009@item 7
21010@itemx plus_dmpy
21011ARC HS SIMD support.
21012
21013@item 8
21014@itemx plus_macd
21015ARC HS SIMD support.
21016
21017@item 9
21018@itemx plus_qmacw
21019ARC HS SIMD support.
21020
21021@end table
21022
21023This option is only available for ARCv2 cores@.
21024
21025@item -mfpu=@var{fpu}
21026@opindex mfpu
21027Enables support for specific floating-point hardware extensions for ARCv2
21028cores. Supported values for @var{fpu} are:
21029
21030@table @samp
21031
21032@item fpus
21033Enables support for single-precision floating-point hardware
21034extensions@.
21035
21036@item fpud
21037Enables support for double-precision floating-point hardware
21038extensions. The single-precision floating-point extension is also
21039enabled. Not available for ARC EM@.
21040
21041@item fpuda
21042Enables support for double-precision floating-point hardware
21043extensions using double-precision assist instructions. The single-precision
21044floating-point extension is also enabled. This option is
21045only available for ARC EM@.
21046
21047@item fpuda_div
21048Enables support for double-precision floating-point hardware
21049extensions using double-precision assist instructions.
21050The single-precision floating-point, square-root, and divide
21051extensions are also enabled. This option is
21052only available for ARC EM@.
21053
21054@item fpuda_fma
21055Enables support for double-precision floating-point hardware
21056extensions using double-precision assist instructions.
21057The single-precision floating-point and fused multiply and add
21058hardware extensions are also enabled. This option is
21059only available for ARC EM@.
21060
21061@item fpuda_all
21062Enables support for double-precision floating-point hardware
21063extensions using double-precision assist instructions.
21064All single-precision floating-point hardware extensions are also
21065enabled. This option is only available for ARC EM@.
21066
21067@item fpus_div
21068Enables support for single-precision floating-point, square-root and divide
21069hardware extensions@.
21070
21071@item fpud_div
21072Enables support for double-precision floating-point, square-root and divide
21073hardware extensions. This option
21074includes option @samp{fpus_div}. Not available for ARC EM@.
21075
21076@item fpus_fma
21077Enables support for single-precision floating-point and
21078fused multiply and add hardware extensions@.
21079
21080@item fpud_fma
21081Enables support for double-precision floating-point and
21082fused multiply and add hardware extensions. This option
21083includes option @samp{fpus_fma}. Not available for ARC EM@.
21084
21085@item fpus_all
21086Enables support for all single-precision floating-point hardware
21087extensions@.
21088
21089@item fpud_all
21090Enables support for all single- and double-precision floating-point
21091hardware extensions. Not available for ARC EM@.
21092
21093@end table
21094
21095@item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
21096@opindex mirq-ctrl-saved
21097Specifies general-purposes registers that the processor automatically
21098saves/restores on interrupt entry and exit. @var{register-range} is
21099specified as two registers separated by a dash. The register range
21100always starts with @code{r0}, the upper limit is @code{fp} register.
21101@var{blink} and @var{lp_count} are optional. This option is only
21102valid for ARC EM and ARC HS cores.
21103
21104@item -mrgf-banked-regs=@var{number}
21105@opindex mrgf-banked-regs
21106Specifies the number of registers replicated in second register bank
21107on entry to fast interrupt. Fast interrupts are interrupts with the
21108highest priority level P0. These interrupts save only PC and STATUS32
21109registers to avoid memory transactions during interrupt entry and exit
21110sequences. Use this option when you are using fast interrupts in an
21111ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
21112
21113@item -mlpc-width=@var{width}
21114@opindex mlpc-width
21115Specify the width of the @code{lp_count} register. Valid values for
21116@var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
21117fixed to 32 bits. If the width is less than 32, the compiler does not
21118attempt to transform loops in your program to use the zero-delay loop
21119mechanism unless it is known that the @code{lp_count} register can
21120hold the required loop-counter value. Depending on the width
21121specified, the compiler and run-time library might continue to use the
21122loop mechanism for various needs. This option defines macro
21123@code{__ARC_LPC_WIDTH__} with the value of @var{width}.
21124
21125@item -mrf16
21126@opindex mrf16
21127This option instructs the compiler to generate code for a 16-entry
21128register file. This option defines the @code{__ARC_RF16__}
21129preprocessor macro.
21130
21131@item -mbranch-index
21132@opindex mbranch-index
21133Enable use of @code{bi} or @code{bih} instructions to implement jump
21134tables.
21135
21136@end table
21137
21138The following options are passed through to the assembler, and also
21139define preprocessor macro symbols.
21140
21141@c Flags used by the assembler, but for which we define preprocessor
21142@c macro symbols as well.
21143@table @gcctabopt
21144@item -mdsp-packa
21145@opindex mdsp-packa
21146Passed down to the assembler to enable the DSP Pack A extensions.
21147Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
21148deprecated.
21149
21150@item -mdvbf
21151@opindex mdvbf
21152Passed down to the assembler to enable the dual Viterbi butterfly
21153extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
21154option is deprecated.
21155
21156@c ARC700 4.10 extension instruction
21157@item -mlock
21158@opindex mlock
21159Passed down to the assembler to enable the locked load/store
21160conditional extension. Also sets the preprocessor symbol
21161@code{__Xlock}.
21162
21163@item -mmac-d16
21164@opindex mmac-d16
21165Passed down to the assembler. Also sets the preprocessor symbol
21166@code{__Xxmac_d16}. This option is deprecated.
21167
21168@item -mmac-24
21169@opindex mmac-24
21170Passed down to the assembler. Also sets the preprocessor symbol
21171@code{__Xxmac_24}. This option is deprecated.
21172
21173@c ARC700 4.10 extension instruction
21174@item -mrtsc
21175@opindex mrtsc
21176Passed down to the assembler to enable the 64-bit time-stamp counter
21177extension instruction. Also sets the preprocessor symbol
21178@code{__Xrtsc}. This option is deprecated.
21179
21180@c ARC700 4.10 extension instruction
21181@item -mswape
21182@opindex mswape
21183Passed down to the assembler to enable the swap byte ordering
21184extension instruction. Also sets the preprocessor symbol
21185@code{__Xswape}.
21186
21187@item -mtelephony
21188@opindex mtelephony
21189Passed down to the assembler to enable dual- and single-operand
21190instructions for telephony. Also sets the preprocessor symbol
21191@code{__Xtelephony}. This option is deprecated.
21192
21193@item -mxy
21194@opindex mxy
21195Passed down to the assembler to enable the XY memory extension. Also
21196sets the preprocessor symbol @code{__Xxy}.
21197
21198@end table
21199
21200The following options control how the assembly code is annotated:
21201
21202@c Assembly annotation options
21203@table @gcctabopt
21204@item -misize
21205@opindex misize
21206Annotate assembler instructions with estimated addresses.
21207
21208@item -mannotate-align
21209@opindex mannotate-align
21210Explain what alignment considerations lead to the decision to make an
21211instruction short or long.
21212
21213@end table
21214
21215The following options are passed through to the linker:
21216
21217@c options passed through to the linker
21218@table @gcctabopt
21219@item -marclinux
21220@opindex marclinux
21221Passed through to the linker, to specify use of the @code{arclinux} emulation.
21222This option is enabled by default in tool chains built for
21223@w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
21224when profiling is not requested.
21225
21226@item -marclinux_prof
21227@opindex marclinux_prof
21228Passed through to the linker, to specify use of the
21229@code{arclinux_prof} emulation. This option is enabled by default in
21230tool chains built for @w{@code{arc-linux-uclibc}} and
21231@w{@code{arceb-linux-uclibc}} targets when profiling is requested.
21232
21233@end table
21234
21235The following options control the semantics of generated code:
21236
21237@c semantically relevant code generation options
21238@table @gcctabopt
21239@item -mlong-calls
21240@opindex mlong-calls
21241Generate calls as register indirect calls, thus providing access
21242to the full 32-bit address range.
21243
21244@item -mmedium-calls
21245@opindex mmedium-calls
21246Don't use less than 25-bit addressing range for calls, which is the
21247offset available for an unconditional branch-and-link
21248instruction. Conditional execution of function calls is suppressed, to
21249allow use of the 25-bit range, rather than the 21-bit range with
21250conditional branch-and-link. This is the default for tool chains built
21251for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
21252
21253@item -G @var{num}
21254@opindex G
21255Put definitions of externally-visible data in a small data section if
21256that data is no bigger than @var{num} bytes. The default value of
21257@var{num} is 4 for any ARC configuration, or 8 when we have double
21258load/store operations.
21259
21260@item -mno-sdata
21261@opindex mno-sdata
21262@opindex msdata
21263Do not generate sdata references. This is the default for tool chains
21264built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
21265targets.
21266
21267@item -mvolatile-cache
21268@opindex mvolatile-cache
21269Use ordinarily cached memory accesses for volatile references. This is the
21270default.
21271
21272@item -mno-volatile-cache
21273@opindex mno-volatile-cache
21274@opindex mvolatile-cache
21275Enable cache bypass for volatile references.
21276
21277@end table
21278
21279The following options fine tune code generation:
21280@c code generation tuning options
21281@table @gcctabopt
21282@item -malign-call
21283@opindex malign-call
21284Does nothing. Preserved for backward compatibility.
21285
21286@item -mauto-modify-reg
21287@opindex mauto-modify-reg
21288Enable the use of pre/post modify with register displacement.
21289
21290@item -mbbit-peephole
21291@opindex mbbit-peephole
21292Enable bbit peephole2.
21293
21294@item -mno-brcc
21295@opindex mno-brcc
21296This option disables a target-specific pass in @file{arc_reorg} to
21297generate compare-and-branch (@code{br@var{cc}}) instructions.
21298It has no effect on
21299generation of these instructions driven by the combiner pass.
21300
21301@item -mcase-vector-pcrel
21302@opindex mcase-vector-pcrel
21303Use PC-relative switch case tables to enable case table shortening.
21304This is the default for @option{-Os}.
21305
21306@item -mcompact-casesi
21307@opindex mcompact-casesi
21308Enable compact @code{casesi} pattern. This is the default for @option{-Os},
21309and only available for ARCv1 cores. This option is deprecated.
21310
21311@item -mno-cond-exec
21312@opindex mno-cond-exec
21313Disable the ARCompact-specific pass to generate conditional
21314execution instructions.
21315
21316Due to delay slot scheduling and interactions between operand numbers,
21317literal sizes, instruction lengths, and the support for conditional execution,
21318the target-independent pass to generate conditional execution is often lacking,
21319so the ARC port has kept a special pass around that tries to find more
21320conditional execution generation opportunities after register allocation,
21321branch shortening, and delay slot scheduling have been done. This pass
21322generally, but not always, improves performance and code size, at the cost of
21323extra compilation time, which is why there is an option to switch it off.
21324If you have a problem with call instructions exceeding their allowable
21325offset range because they are conditionalized, you should consider using
21326@option{-mmedium-calls} instead.
21327
21328@item -mearly-cbranchsi
21329@opindex mearly-cbranchsi
21330Enable pre-reload use of the @code{cbranchsi} pattern.
21331
21332@item -mexpand-adddi
21333@opindex mexpand-adddi
21334Expand @code{adddi3} and @code{subdi3} at RTL generation time into
21335@code{add.f}, @code{adc} etc. This option is deprecated.
21336
21337@item -mindexed-loads
21338@opindex mindexed-loads
21339Enable the use of indexed loads. This can be problematic because some
21340optimizers then assume that indexed stores exist, which is not
21341the case.
21342
21343@item -mlra
21344@opindex mlra
21345Enable Local Register Allocation. This is still experimental for ARC,
21346so by default the compiler uses standard reload
21347(i.e.@: @option{-mno-lra}).
21348
21349@item -mlra-priority-none
21350@opindex mlra-priority-none
21351Don't indicate any priority for target registers.
21352
21353@item -mlra-priority-compact
21354@opindex mlra-priority-compact
21355Indicate target register priority for r0..r3 / r12..r15.
21356
21357@item -mlra-priority-noncompact
21358@opindex mlra-priority-noncompact
21359Reduce target register priority for r0..r3 / r12..r15.
21360
21361@item -mmillicode
21362@opindex mmillicode
21363When optimizing for size (using @option{-Os}), prologues and epilogues
21364that have to save or restore a large number of registers are often
21365shortened by using call to a special function in libgcc; this is
21366referred to as a @emph{millicode} call. As these calls can pose
21367performance issues, and/or cause linking issues when linking in a
21368nonstandard way, this option is provided to turn on or off millicode
21369call generation.
21370
21371@item -mcode-density-frame
21372@opindex mcode-density-frame
21373This option enable the compiler to emit @code{enter} and @code{leave}
21374instructions. These instructions are only valid for CPUs with
21375code-density feature.
21376
21377@item -mmixed-code
21378@opindex mmixed-code
21379Does nothing. Preserved for backward compatibility.
21380
21381@item -mq-class
21382@opindex mq-class
21383Ths option is deprecated. Enable @samp{q} instruction alternatives.
21384This is the default for @option{-Os}.
21385
21386@item -mRcq
21387@opindex mRcq
21388Does nothing. Preserved for backward compatibility.
21389
21390@item -mRcw
21391@opindex mRcw
21392Does nothing. Preserved for backward compatibility.
21393
21394@item -msize-level=@var{level}
21395@opindex msize-level
21396Fine-tune size optimization with regards to instruction lengths and alignment.
21397The recognized values for @var{level} are:
21398@table @samp
21399@item 0
21400No size optimization. This level is deprecated and treated like @samp{1}.
21401
21402@item 1
21403Short instructions are used opportunistically.
21404
21405@item 2
21406In addition, alignment of loops and of code after barriers are dropped.
21407
21408@item 3
21409In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
21410
21411@end table
21412
21413This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
21414the behavior when this is not set is equivalent to level @samp{1}.
21415
21416@item -mtune=@var{cpu}
21417@opindex mtune
21418Set instruction scheduling parameters for @var{cpu}, overriding any implied
21419by @option{-mcpu=}.
21420
21421Supported values for @var{cpu} are
21422
21423@table @samp
21424@item ARC600
21425Tune for ARC600 CPU.
21426
21427@item ARC601
21428Tune for ARC601 CPU.
21429
21430@item ARC700
21431Tune for ARC700 CPU with standard multiplier block.
21432
21433@item ARC700-xmac
21434Tune for ARC700 CPU with XMAC block.
21435
21436@item ARC725D
21437Tune for ARC725D CPU.
21438
21439@item ARC750D
21440Tune for ARC750D CPU.
21441
21442@item core3
21443Tune for ARCv2 core3 type CPU. This option enable usage of
21444@code{dbnz} instruction.
21445
21446@item release31a
21447Tune for ARC4x release 3.10a.
21448
21449@end table
21450
21451@item -mmultcost=@var{num}
21452@opindex mmultcost
21453Cost to assume for a multiply instruction, with @samp{4} being equal to a
21454normal instruction.
21455
21456@item -munalign-prob-threshold=@var{probability}
21457@opindex munalign-prob-threshold
21458Does nothing. Preserved for backward compatibility.
21459
21460@end table
21461
21462The following options are maintained for backward compatibility, but
21463are now deprecated and will be removed in a future release:
21464
21465@c Deprecated options
21466@table @gcctabopt
21467
21468@item -margonaut
21469@opindex margonaut
21470Obsolete FPX.
21471
21472@item -mbig-endian
21473@opindex mbig-endian
21474@itemx -EB
21475@opindex EB
21476Compile code for big-endian targets. Use of these options is now
21477deprecated. Big-endian code is supported by configuring GCC to build
21478@w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
21479for which big endian is the default.
21480
21481@item -mlittle-endian
21482@opindex mlittle-endian
21483@itemx -EL
21484@opindex EL
21485Compile code for little-endian targets. Use of these options is now
21486deprecated. Little-endian code is supported by configuring GCC to build
21487@w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
21488for which little endian is the default.
21489
21490@item -mbarrel_shifter
21491@opindex mbarrel_shifter
21492Replaced by @option{-mbarrel-shifter}.
21493
21494@item -mdpfp_compact
21495@opindex mdpfp_compact
21496Replaced by @option{-mdpfp-compact}.
21497
21498@item -mdpfp_fast
21499@opindex mdpfp_fast
21500Replaced by @option{-mdpfp-fast}.
21501
21502@item -mdsp_packa
21503@opindex mdsp_packa
21504Replaced by @option{-mdsp-packa}.
21505
21506@item -mEA
21507@opindex mEA
21508Replaced by @option{-mea}.
21509
21510@item -mmac_24
21511@opindex mmac_24
21512Replaced by @option{-mmac-24}.
21513
21514@item -mmac_d16
21515@opindex mmac_d16
21516Replaced by @option{-mmac-d16}.
21517
21518@item -mspfp_compact
21519@opindex mspfp_compact
21520Replaced by @option{-mspfp-compact}.
21521
21522@item -mspfp_fast
21523@opindex mspfp_fast
21524Replaced by @option{-mspfp-fast}.
21525
21526@item -mtune=@var{cpu}
21527@opindex mtune
21528Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
21529@samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
21530@samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
21531
21532@item -multcost=@var{num}
21533@opindex multcost
21534Replaced by @option{-mmultcost}.
21535
21536@end table
21537
21538@node ARM Options
21539@subsection ARM Options
21540@cindex ARM options
21541
21542These @samp{-m} options are defined for the ARM port:
21543
21544@table @gcctabopt
21545@item -mabi=@var{name}
21546@opindex mabi
21547Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
21548@samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}.
21549
21550@item -mapcs-frame
21551@opindex mapcs-frame
21552Generate a stack frame that is compliant with the ARM Procedure Call
21553Standard for all functions, even if this is not strictly necessary for
21554correct execution of the code. Specifying @option{-fomit-frame-pointer}
21555with this option causes the stack frames not to be generated for
21556leaf functions. The default is @option{-mno-apcs-frame}.
21557This option is deprecated.
21558
21559@item -mapcs
21560@opindex mapcs
21561This is a synonym for @option{-mapcs-frame} and is deprecated.
21562
21563@ignore
21564@c not currently implemented
21565@item -mapcs-stack-check
21566@opindex mapcs-stack-check
21567Generate code to check the amount of stack space available upon entry to
21568every function (that actually uses some stack space). If there is
21569insufficient space available then either the function
21570@code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
21571called, depending upon the amount of stack space required. The runtime
21572system is required to provide these functions. The default is
21573@option{-mno-apcs-stack-check}, since this produces smaller code.
21574
21575@c not currently implemented
21576@item -mapcs-reentrant
21577@opindex mapcs-reentrant
21578Generate reentrant, position-independent code. The default is
21579@option{-mno-apcs-reentrant}.
21580@end ignore
21581
21582@item -mthumb-interwork
21583@opindex mthumb-interwork
21584Generate code that supports calling between the ARM and Thumb
21585instruction sets. Without this option, on pre-v5 architectures, the
21586two instruction sets cannot be reliably used inside one program. The
21587default is @option{-mno-thumb-interwork}, since slightly larger code
21588is generated when @option{-mthumb-interwork} is specified. In AAPCS
21589configurations this option is meaningless.
21590
21591@item -mno-sched-prolog
21592@opindex mno-sched-prolog
21593@opindex msched-prolog
21594Prevent the reordering of instructions in the function prologue, or the
21595merging of those instruction with the instructions in the function's
21596body. This means that all functions start with a recognizable set
21597of instructions (or in fact one of a choice from a small set of
21598different function prologues), and this information can be used to
21599locate the start of functions inside an executable piece of code. The
21600default is @option{-msched-prolog}.
21601
21602@item -mfloat-abi=@var{name}
21603@opindex mfloat-abi
21604Specifies which floating-point ABI to use. Permissible values
21605are: @samp{soft}, @samp{softfp} and @samp{hard}.
21606
21607Specifying @samp{soft} causes GCC to generate output containing
21608library calls for floating-point operations.
21609@samp{softfp} allows the generation of code using hardware floating-point
21610instructions, but still uses the soft-float calling conventions.
21611@samp{hard} allows generation of floating-point instructions
21612and uses FPU-specific calling conventions.
21613
21614The default depends on the specific target configuration. Note that
21615the hard-float and soft-float ABIs are not link-compatible; you must
21616compile your entire program with the same ABI, and link with a
21617compatible set of libraries.
21618
21619@item -mgeneral-regs-only
21620@opindex mgeneral-regs-only
21621Generate code which uses only the general-purpose registers. This will prevent
21622the compiler from using floating-point and Advanced SIMD registers but will not
21623impose any restrictions on the assembler.
21624
21625@item -mlittle-endian
21626@opindex mlittle-endian
21627Generate code for a processor running in little-endian mode. This is
21628the default for all standard configurations.
21629
21630@item -mbig-endian
21631@opindex mbig-endian
21632Generate code for a processor running in big-endian mode; the default is
21633to compile code for a little-endian processor.
21634
21635@item -mbe8
21636@itemx -mbe32
21637@opindex mbe8
21638When linking a big-endian image select between BE8 and BE32 formats.
21639The option has no effect for little-endian images and is ignored. The
21640default is dependent on the selected target architecture. For ARMv6
21641and later architectures the default is BE8, for older architectures
21642the default is BE32. BE32 format has been deprecated by ARM.
21643
21644@item -march=@var{name}@r{[}+extension@dots{}@r{]}
21645@opindex march
21646This specifies the name of the target ARM architecture. GCC uses this
21647name to determine what kind of instructions it can emit when generating
21648assembly code. This option can be used in conjunction with or instead
21649of the @option{-mcpu=} option.
21650
21651Permissible names are:
21652@samp{armv4t},
21653@samp{armv5t}, @samp{armv5te},
21654@samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
21655@samp{armv6z}, @samp{armv6zk},
21656@samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
21657@samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
21658@samp{armv8.4-a},
21659@samp{armv8.5-a},
21660@samp{armv8.6-a},
21661@samp{armv9-a},
21662@samp{armv7-r},
21663@samp{armv8-r},
21664@samp{armv6-m}, @samp{armv6s-m},
21665@samp{armv7-m}, @samp{armv7e-m},
21666@samp{armv8-m.base}, @samp{armv8-m.main},
21667@samp{armv8.1-m.main},
21668@samp{armv9-a},
21669@samp{iwmmxt} and @samp{iwmmxt2}.
21670
21671Additionally, the following architectures, which lack support for the
21672Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
21673
21674Many of the architectures support extensions. These can be added by
21675appending @samp{+@var{extension}} to the architecture name. Extension
21676options are processed in order and capabilities accumulate. An extension
21677will also enable any necessary base extensions
21678upon which it depends. For example, the @samp{+crypto} extension
21679will always enable the @samp{+simd} extension. The exception to the
21680additive construction is for extensions that are prefixed with
21681@samp{+no@dots{}}: these extensions disable the specified option and
21682any other extensions that may depend on the presence of that
21683extension.
21684
21685For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
21686writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
21687entirely disabled by the @samp{+nofp} option that follows it.
21688
21689Most extension names are generically named, but have an effect that is
21690dependent upon the architecture to which it is applied. For example,
21691the @samp{+simd} option can be applied to both @samp{armv7-a} and
21692@samp{armv8-a} architectures, but will enable the original ARMv7-A
21693Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
21694variant for @samp{armv8-a}.
21695
21696The table below lists the supported extensions for each architecture.
21697Architectures not mentioned do not support any extensions.
21698
21699@table @samp
21700@item armv5te
21701@itemx armv6
21702@itemx armv6j
21703@itemx armv6k
21704@itemx armv6kz
21705@itemx armv6t2
21706@itemx armv6z
21707@itemx armv6zk
21708@table @samp
21709@item +fp
21710The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
21711used as an alias for this extension.
21712
21713@item +nofp
21714Disable the floating-point instructions.
21715@end table
21716
21717@item armv7
21718The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
21719@table @samp
21720@item +fp
21721The VFPv3 floating-point instructions, with 16 double-precision
21722registers. The extension @samp{+vfpv3-d16} can be used as an alias
21723for this extension. Note that floating-point is not supported by the
21724base ARMv7-M architecture, but is compatible with both the ARMv7-A and
21725ARMv7-R architectures.
21726
21727@item +nofp
21728Disable the floating-point instructions.
21729@end table
21730
21731@item armv7-a
21732@table @samp
21733@item +mp
21734The multiprocessing extension.
21735
21736@item +sec
21737The security extension.
21738
21739@item +fp
21740The VFPv3 floating-point instructions, with 16 double-precision
21741registers. The extension @samp{+vfpv3-d16} can be used as an alias
21742for this extension.
21743
21744@item +simd
21745The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21746The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
21747for this extension.
21748
21749@item +vfpv3
21750The VFPv3 floating-point instructions, with 32 double-precision
21751registers.
21752
21753@item +vfpv3-d16-fp16
21754The VFPv3 floating-point instructions, with 16 double-precision
21755registers and the half-precision floating-point conversion operations.
21756
21757@item +vfpv3-fp16
21758The VFPv3 floating-point instructions, with 32 double-precision
21759registers and the half-precision floating-point conversion operations.
21760
21761@item +vfpv4-d16
21762The VFPv4 floating-point instructions, with 16 double-precision
21763registers.
21764
21765@item +vfpv4
21766The VFPv4 floating-point instructions, with 32 double-precision
21767registers.
21768
21769@item +neon-fp16
21770The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21771the half-precision floating-point conversion operations.
21772
21773@item +neon-vfpv4
21774The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
21775
21776@item +nosimd
21777Disable the Advanced SIMD instructions (does not disable floating point).
21778
21779@item +nofp
21780Disable the floating-point and Advanced SIMD instructions.
21781@end table
21782
21783@item armv7ve
21784The extended version of the ARMv7-A architecture with support for
21785virtualization.
21786@table @samp
21787@item +fp
21788The VFPv4 floating-point instructions, with 16 double-precision registers.
21789The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
21790
21791@item +simd
21792The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
21793extension @samp{+neon-vfpv4} can be used as an alias for this extension.
21794
21795@item +vfpv3-d16
21796The VFPv3 floating-point instructions, with 16 double-precision
21797registers.
21798
21799@item +vfpv3
21800The VFPv3 floating-point instructions, with 32 double-precision
21801registers.
21802
21803@item +vfpv3-d16-fp16
21804The VFPv3 floating-point instructions, with 16 double-precision
21805registers and the half-precision floating-point conversion operations.
21806
21807@item +vfpv3-fp16
21808The VFPv3 floating-point instructions, with 32 double-precision
21809registers and the half-precision floating-point conversion operations.
21810
21811@item +vfpv4-d16
21812The VFPv4 floating-point instructions, with 16 double-precision
21813registers.
21814
21815@item +vfpv4
21816The VFPv4 floating-point instructions, with 32 double-precision
21817registers.
21818
21819@item +neon
21820The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21821The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
21822
21823@item +neon-fp16
21824The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21825the half-precision floating-point conversion operations.
21826
21827@item +nosimd
21828Disable the Advanced SIMD instructions (does not disable floating point).
21829
21830@item +nofp
21831Disable the floating-point and Advanced SIMD instructions.
21832@end table
21833
21834@item armv8-a
21835@table @samp
21836@item +crc
21837The Cyclic Redundancy Check (CRC) instructions.
21838@item +simd
21839The ARMv8-A Advanced SIMD and floating-point instructions.
21840@item +crypto
21841The cryptographic instructions.
21842@item +nocrypto
21843Disable the cryptographic instructions.
21844@item +nofp
21845Disable the floating-point, Advanced SIMD and cryptographic instructions.
21846@item +sb
21847Speculation Barrier Instruction.
21848@item +predres
21849Execution and Data Prediction Restriction Instructions.
21850@end table
21851
21852@item armv8.1-a
21853@table @samp
21854@item +simd
21855The ARMv8.1-A Advanced SIMD and floating-point instructions.
21856
21857@item +crypto
21858The cryptographic instructions. This also enables the Advanced SIMD and
21859floating-point instructions.
21860
21861@item +nocrypto
21862Disable the cryptographic instructions.
21863
21864@item +nofp
21865Disable the floating-point, Advanced SIMD and cryptographic instructions.
21866
21867@item +sb
21868Speculation Barrier Instruction.
21869
21870@item +predres
21871Execution and Data Prediction Restriction Instructions.
21872@end table
21873
21874@item armv8.2-a
21875@itemx armv8.3-a
21876@table @samp
21877@item +fp16
21878The half-precision floating-point data processing instructions.
21879This also enables the Advanced SIMD and floating-point instructions.
21880
21881@item +fp16fml
21882The half-precision floating-point fmla extension. This also enables
21883the half-precision floating-point extension and Advanced SIMD and
21884floating-point instructions.
21885
21886@item +simd
21887The ARMv8.1-A Advanced SIMD and floating-point instructions.
21888
21889@item +crypto
21890The cryptographic instructions. This also enables the Advanced SIMD and
21891floating-point instructions.
21892
21893@item +dotprod
21894Enable the Dot Product extension. This also enables Advanced SIMD instructions.
21895
21896@item +nocrypto
21897Disable the cryptographic extension.
21898
21899@item +nofp
21900Disable the floating-point, Advanced SIMD and cryptographic instructions.
21901
21902@item +sb
21903Speculation Barrier Instruction.
21904
21905@item +predres
21906Execution and Data Prediction Restriction Instructions.
21907
21908@item +i8mm
219098-bit Integer Matrix Multiply instructions.
21910This also enables Advanced SIMD and floating-point instructions.
21911
21912@item +bf16
21913Brain half-precision floating-point instructions.
21914This also enables Advanced SIMD and floating-point instructions.
21915@end table
21916
21917@item armv8.4-a
21918@table @samp
21919@item +fp16
21920The half-precision floating-point data processing instructions.
21921This also enables the Advanced SIMD and floating-point instructions as well
21922as the Dot Product extension and the half-precision floating-point fmla
21923extension.
21924
21925@item +simd
21926The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21927Dot Product extension.
21928
21929@item +crypto
21930The cryptographic instructions. This also enables the Advanced SIMD and
21931floating-point instructions as well as the Dot Product extension.
21932
21933@item +nocrypto
21934Disable the cryptographic extension.
21935
21936@item +nofp
21937Disable the floating-point, Advanced SIMD and cryptographic instructions.
21938
21939@item +sb
21940Speculation Barrier Instruction.
21941
21942@item +predres
21943Execution and Data Prediction Restriction Instructions.
21944
21945@item +i8mm
219468-bit Integer Matrix Multiply instructions.
21947This also enables Advanced SIMD and floating-point instructions.
21948
21949@item +bf16
21950Brain half-precision floating-point instructions.
21951This also enables Advanced SIMD and floating-point instructions.
21952@end table
21953
21954@item armv8.5-a
21955@table @samp
21956@item +fp16
21957The half-precision floating-point data processing instructions.
21958This also enables the Advanced SIMD and floating-point instructions as well
21959as the Dot Product extension and the half-precision floating-point fmla
21960extension.
21961
21962@item +simd
21963The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21964Dot Product extension.
21965
21966@item +crypto
21967The cryptographic instructions. This also enables the Advanced SIMD and
21968floating-point instructions as well as the Dot Product extension.
21969
21970@item +nocrypto
21971Disable the cryptographic extension.
21972
21973@item +nofp
21974Disable the floating-point, Advanced SIMD and cryptographic instructions.
21975
21976@item +i8mm
219778-bit Integer Matrix Multiply instructions.
21978This also enables Advanced SIMD and floating-point instructions.
21979
21980@item +bf16
21981Brain half-precision floating-point instructions.
21982This also enables Advanced SIMD and floating-point instructions.
21983@end table
21984
21985@item armv8.6-a
21986@table @samp
21987@item +fp16
21988The half-precision floating-point data processing instructions.
21989This also enables the Advanced SIMD and floating-point instructions as well
21990as the Dot Product extension and the half-precision floating-point fmla
21991extension.
21992
21993@item +simd
21994The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21995Dot Product extension.
21996
21997@item +crypto
21998The cryptographic instructions. This also enables the Advanced SIMD and
21999floating-point instructions as well as the Dot Product extension.
22000
22001@item +nocrypto
22002Disable the cryptographic extension.
22003
22004@item +nofp
22005Disable the floating-point, Advanced SIMD and cryptographic instructions.
22006
22007@item +i8mm
220088-bit Integer Matrix Multiply instructions.
22009This also enables Advanced SIMD and floating-point instructions.
22010
22011@item +bf16
22012Brain half-precision floating-point instructions.
22013This also enables Advanced SIMD and floating-point instructions.
22014@end table
22015
22016@item armv7-r
22017@table @samp
22018@item +fp.sp
22019The single-precision VFPv3 floating-point instructions. The extension
22020@samp{+vfpv3xd} can be used as an alias for this extension.
22021
22022@item +fp
22023The VFPv3 floating-point instructions with 16 double-precision registers.
22024The extension +vfpv3-d16 can be used as an alias for this extension.
22025
22026@item +vfpv3xd-d16-fp16
22027The single-precision VFPv3 floating-point instructions with 16 double-precision
22028registers and the half-precision floating-point conversion operations.
22029
22030@item +vfpv3-d16-fp16
22031The VFPv3 floating-point instructions with 16 double-precision
22032registers and the half-precision floating-point conversion operations.
22033
22034@item +nofp
22035Disable the floating-point extension.
22036
22037@item +idiv
22038The ARM-state integer division instructions.
22039
22040@item +noidiv
22041Disable the ARM-state integer division extension.
22042@end table
22043
22044@item armv7e-m
22045@table @samp
22046@item +fp
22047The single-precision VFPv4 floating-point instructions.
22048
22049@item +fpv5
22050The single-precision FPv5 floating-point instructions.
22051
22052@item +fp.dp
22053The single- and double-precision FPv5 floating-point instructions.
22054
22055@item +nofp
22056Disable the floating-point extensions.
22057@end table
22058
22059@item armv8.1-m.main
22060@table @samp
22061
22062@item +dsp
22063The DSP instructions.
22064
22065@item +mve
22066The M-Profile Vector Extension (MVE) integer instructions.
22067
22068@item +mve.fp
22069The M-Profile Vector Extension (MVE) integer and single precision
22070floating-point instructions.
22071
22072@item +fp
22073The single-precision floating-point instructions.
22074
22075@item +fp.dp
22076The single- and double-precision floating-point instructions.
22077
22078@item +nofp
22079Disable the floating-point extension.
22080
22081@item +cdecp0, +cdecp1, ... , +cdecp7
22082Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22083to the numbers given in the options in the range 0 to 7.
c91bb7b9
AC
22084
22085@item +pacbti
22086Enable the Pointer Authentication and Branch Target Identification Extension.
d77de738
ML
22087@end table
22088
22089@item armv8-m.main
22090@table @samp
22091@item +dsp
22092The DSP instructions.
22093
22094@item +nodsp
22095Disable the DSP extension.
22096
22097@item +fp
22098The single-precision floating-point instructions.
22099
22100@item +fp.dp
22101The single- and double-precision floating-point instructions.
22102
22103@item +nofp
22104Disable the floating-point extension.
22105
22106@item +cdecp0, +cdecp1, ... , +cdecp7
22107Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22108to the numbers given in the options in the range 0 to 7.
22109@end table
22110
22111@item armv8-r
22112@table @samp
22113@item +crc
22114The Cyclic Redundancy Check (CRC) instructions.
22115@item +fp.sp
22116The single-precision FPv5 floating-point instructions.
22117@item +simd
22118The ARMv8-A Advanced SIMD and floating-point instructions.
22119@item +crypto
22120The cryptographic instructions.
22121@item +nocrypto
22122Disable the cryptographic instructions.
22123@item +nofp
22124Disable the floating-point, Advanced SIMD and cryptographic instructions.
22125@end table
22126
22127@end table
22128
22129@option{-march=native} causes the compiler to auto-detect the architecture
22130of the build computer. At present, this feature is only supported on
22131GNU/Linux, and not all architectures are recognized. If the auto-detect
22132is unsuccessful the option has no effect.
22133
22134@item -mtune=@var{name}
22135@opindex mtune
22136This option specifies the name of the target ARM processor for
22137which GCC should tune the performance of the code.
22138For some ARM implementations better performance can be obtained by using
22139this option.
22140Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
22141@samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
22142@samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
22143@samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
22144@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
22145@samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
22146@samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
22147@samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
22148@samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
22149@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
22150@samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
22151@samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
22152@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
22153@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
22154@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
22155@samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
22156@samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
22157@samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
22158@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
ccfd1e7f
SP
22159@samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1},
22160@samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
d77de738
ML
22161@samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
22162@samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
22163@samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
22164@samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1},
22165@samp{xgene1}.
22166
22167Additionally, this option can specify that GCC should tune the performance
22168of the code for a big.LITTLE system. Permissible names are:
22169@samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
22170@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22171@samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
22172@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
22173
22174@option{-mtune=generic-@var{arch}} specifies that GCC should tune the
22175performance for a blend of processors within architecture @var{arch}.
22176The aim is to generate code that run well on the current most popular
22177processors, balancing between optimizations that benefit some CPUs in the
22178range, and avoiding performance pitfalls of other CPUs. The effects of
22179this option may change in future GCC versions as CPU models come and go.
22180
22181@option{-mtune} permits the same extension options as @option{-mcpu}, but
22182the extension options do not affect the tuning of the generated code.
22183
22184@option{-mtune=native} causes the compiler to auto-detect the CPU
22185of the build computer. At present, this feature is only supported on
22186GNU/Linux, and not all architectures are recognized. If the auto-detect is
22187unsuccessful the option has no effect.
22188
22189@item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
22190@opindex mcpu
22191This specifies the name of the target ARM processor. GCC uses this name
22192to derive the name of the target ARM architecture (as if specified
22193by @option{-march}) and the ARM processor type for which to tune for
22194performance (as if specified by @option{-mtune}). Where this option
22195is used in conjunction with @option{-march} or @option{-mtune},
22196those options take precedence over the appropriate part of this option.
22197
22198Many of the supported CPUs implement optional architectural
22199extensions. Where this is so the architectural extensions are
22200normally enabled by default. If implementations that lack the
22201extension exist, then the extension syntax can be used to disable
22202those extensions that have been omitted. For floating-point and
22203Advanced SIMD (Neon) instructions, the settings of the options
22204@option{-mfloat-abi} and @option{-mfpu} must also be considered:
22205floating-point and Advanced SIMD instructions will only be used if
22206@option{-mfloat-abi} is not set to @samp{soft}; and any setting of
22207@option{-mfpu} other than @samp{auto} will override the available
22208floating-point and SIMD extension instructions.
22209
22210For example, @samp{cortex-a9} can be found in three major
22211configurations: integer only, with just a floating-point unit or with
22212floating-point and Advanced SIMD. The default is to enable all the
22213instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
22214be used to disable just the SIMD or both the SIMD and floating-point
22215instructions respectively.
22216
22217Permissible names for this option are the same as those for
22218@option{-mtune}.
22219
22220The following extension options are common to the listed CPUs:
22221
22222@table @samp
22223@item +nodsp
ccfd1e7f
SP
22224Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p},
22225@samp{cortex-m55} and @samp{cortex-m85}. Also disable the M-Profile Vector
22226Extension (MVE) integer and single precision floating-point instructions on
22227@samp{cortex-m55} and @samp{cortex-m85}.
22228
22229@item +nopacbti
22230Disable the Pointer Authentication and Branch Target Identification Extension
22231on @samp{cortex-m85}.
d77de738
ML
22232
22233@item +nomve
22234Disable the M-Profile Vector Extension (MVE) integer and single precision
ccfd1e7f 22235floating-point instructions on @samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
22236
22237@item +nomve.fp
22238Disable the M-Profile Vector Extension (MVE) single precision floating-point
ccfd1e7f 22239instructions on @samp{cortex-m55} and @samp{cortex-m85}.
d77de738 22240
798a0d05
SP
22241@item +cdecp0, +cdecp1, ... , +cdecp7
22242Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22243to the numbers given in the options in the range 0 to 7 on @samp{cortex-m55}.
22244
d77de738
ML
22245@item +nofp
22246Disables the floating-point instructions on @samp{arm9e},
22247@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
22248@samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
22249@samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
22250@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}
ccfd1e7f
SP
22251@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p},
22252@samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
22253Disables the floating-point and SIMD instructions on
22254@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
22255@samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
22256@samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
22257@samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
22258@samp{cortex-a53} and @samp{cortex-a55}.
22259
22260@item +nofp.dp
22261Disables the double-precision component of the floating-point instructions
22262on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
22263@samp{cortex-r52plus} and @samp{cortex-m7}.
22264
22265@item +nosimd
22266Disables the SIMD (but not floating-point) instructions on
22267@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
22268and @samp{cortex-a9}.
22269
22270@item +crypto
22271Enables the cryptographic instructions on @samp{cortex-a32},
22272@samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
22273@samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
22274@samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22275@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
22276@samp{cortex-a75.cortex-a55}.
22277@end table
22278
22279Additionally the @samp{generic-armv7-a} pseudo target defaults to
22280VFPv3 with 16 double-precision registers. It supports the following
22281extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
22282@samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
22283@samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
22284@samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
22285the extensions to @option{-march=armv7-a}.
22286
22287@option{-mcpu=generic-@var{arch}} is also permissible, and is
22288equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
22289See @option{-mtune} for more information.
22290
22291@option{-mcpu=native} causes the compiler to auto-detect the CPU
22292of the build computer. At present, this feature is only supported on
22293GNU/Linux, and not all architectures are recognized. If the auto-detect
22294is unsuccessful the option has no effect.
22295
22296@item -mfpu=@var{name}
22297@opindex mfpu
22298This specifies what floating-point hardware (or hardware emulation) is
22299available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
22300@samp{vfpv3},
22301@samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
22302@samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
22303@samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
22304@samp{fpv5-d16}, @samp{fpv5-sp-d16},
22305@samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
22306Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
22307is an alias for @samp{vfpv2}.
22308
22309The setting @samp{auto} is the default and is special. It causes the
22310compiler to select the floating-point and Advanced SIMD instructions
22311based on the settings of @option{-mcpu} and @option{-march}.
22312
22313If the selected floating-point hardware includes the NEON extension
22314(e.g.@: @option{-mfpu=neon}), note that floating-point
22315operations are not generated by GCC's auto-vectorization pass unless
22316@option{-funsafe-math-optimizations} is also specified. This is
22317because NEON hardware does not fully implement the IEEE 754 standard for
22318floating-point arithmetic (in particular denormal values are treated as
22319zero), so the use of NEON instructions may lead to a loss of precision.
22320
22321You 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}).
22322
22323@item -mfp16-format=@var{name}
22324@opindex mfp16-format
22325Specify the format of the @code{__fp16} half-precision floating-point type.
22326Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
22327the default is @samp{none}, in which case the @code{__fp16} type is not
22328defined. @xref{Half-Precision}, for more information.
22329
22330@item -mstructure-size-boundary=@var{n}
22331@opindex mstructure-size-boundary
22332The sizes of all structures and unions are rounded up to a multiple
22333of the number of bits set by this option. Permissible values are 8, 32
22334and 64. The default value varies for different toolchains. For the COFF
22335targeted toolchain the default value is 8. A value of 64 is only allowed
22336if the underlying ABI supports it.
22337
22338Specifying a larger number can produce faster, more efficient code, but
22339can also increase the size of the program. Different values are potentially
22340incompatible. Code compiled with one value cannot necessarily expect to
22341work with code or libraries compiled with another value, if they exchange
22342information using structures or unions.
22343
22344This option is deprecated.
22345
22346@item -mabort-on-noreturn
22347@opindex mabort-on-noreturn
22348Generate a call to the function @code{abort} at the end of a
22349@code{noreturn} function. It is executed if the function tries to
22350return.
22351
22352@item -mlong-calls
22353@itemx -mno-long-calls
22354@opindex mlong-calls
22355@opindex mno-long-calls
22356Tells the compiler to perform function calls by first loading the
22357address of the function into a register and then performing a subroutine
22358call on this register. This switch is needed if the target function
22359lies outside of the 64-megabyte addressing range of the offset-based
22360version of subroutine call instruction.
22361
22362Even if this switch is enabled, not all function calls are turned
22363into long calls. The heuristic is that static functions, functions
22364that have the @code{short_call} attribute, functions that are inside
22365the scope of a @code{#pragma no_long_calls} directive, and functions whose
22366definitions have already been compiled within the current compilation
22367unit are not turned into long calls. The exceptions to this rule are
22368that weak function definitions, functions with the @code{long_call}
22369attribute or the @code{section} attribute, and functions that are within
22370the scope of a @code{#pragma long_calls} directive are always
22371turned into long calls.
22372
22373This feature is not enabled by default. Specifying
22374@option{-mno-long-calls} restores the default behavior, as does
22375placing the function calls within the scope of a @code{#pragma
22376long_calls_off} directive. Note these switches have no effect on how
22377the compiler generates code to handle function calls via function
22378pointers.
22379
22380@item -msingle-pic-base
22381@opindex msingle-pic-base
22382Treat the register used for PIC addressing as read-only, rather than
22383loading it in the prologue for each function. The runtime system is
22384responsible for initializing this register with an appropriate value
22385before execution begins.
22386
22387@item -mpic-register=@var{reg}
22388@opindex mpic-register
22389Specify the register to be used for PIC addressing.
22390For standard PIC base case, the default is any suitable register
22391determined by compiler. For single PIC base case, the default is
22392@samp{R9} if target is EABI based or stack-checking is enabled,
22393otherwise the default is @samp{R10}.
22394
22395@item -mpic-data-is-text-relative
22396@opindex mpic-data-is-text-relative
22397Assume that the displacement between the text and data segments is fixed
22398at static link time. This permits using PC-relative addressing
22399operations to access data known to be in the data segment. For
22400non-VxWorks RTP targets, this option is enabled by default. When
22401disabled on such targets, it will enable @option{-msingle-pic-base} by
22402default.
22403
22404@item -mpoke-function-name
22405@opindex mpoke-function-name
22406Write the name of each function into the text section, directly
22407preceding the function prologue. The generated code is similar to this:
22408
22409@smallexample
22410 t0
22411 .ascii "arm_poke_function_name", 0
22412 .align
22413 t1
22414 .word 0xff000000 + (t1 - t0)
22415 arm_poke_function_name
22416 mov ip, sp
22417 stmfd sp!, @{fp, ip, lr, pc@}
22418 sub fp, ip, #4
22419@end smallexample
22420
22421When performing a stack backtrace, code can inspect the value of
22422@code{pc} stored at @code{fp + 0}. If the trace function then looks at
22423location @code{pc - 12} and the top 8 bits are set, then we know that
22424there is a function name embedded immediately preceding this location
22425and has length @code{((pc[-3]) & 0xff000000)}.
22426
22427@item -mthumb
22428@itemx -marm
22429@opindex marm
22430@opindex mthumb
22431
22432Select between generating code that executes in ARM and Thumb
22433states. The default for most configurations is to generate code
22434that executes in ARM state, but the default can be changed by
22435configuring GCC with the @option{--with-mode=}@var{state}
22436configure option.
22437
22438You can also override the ARM and Thumb mode for each function
22439by using the @code{target("thumb")} and @code{target("arm")} function attributes
22440(@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
22441
22442@item -mflip-thumb
22443@opindex mflip-thumb
22444Switch ARM/Thumb modes on alternating functions.
22445This option is provided for regression testing of mixed Thumb/ARM code
22446generation, and is not intended for ordinary use in compiling code.
22447
22448@item -mtpcs-frame
22449@opindex mtpcs-frame
22450Generate a stack frame that is compliant with the Thumb Procedure Call
22451Standard for all non-leaf functions. (A leaf function is one that does
22452not call any other functions.) The default is @option{-mno-tpcs-frame}.
22453
22454@item -mtpcs-leaf-frame
22455@opindex mtpcs-leaf-frame
22456Generate a stack frame that is compliant with the Thumb Procedure Call
22457Standard for all leaf functions. (A leaf function is one that does
22458not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
22459
22460@item -mcallee-super-interworking
22461@opindex mcallee-super-interworking
22462Gives all externally visible functions in the file being compiled an ARM
22463instruction set header which switches to Thumb mode before executing the
22464rest of the function. This allows these functions to be called from
22465non-interworking code. This option is not valid in AAPCS configurations
22466because interworking is enabled by default.
22467
22468@item -mcaller-super-interworking
22469@opindex mcaller-super-interworking
22470Allows calls via function pointers (including virtual functions) to
22471execute correctly regardless of whether the target code has been
22472compiled for interworking or not. There is a small overhead in the cost
22473of executing a function pointer if this option is enabled. This option
22474is not valid in AAPCS configurations because interworking is enabled
22475by default.
22476
22477@item -mtp=@var{name}
22478@opindex mtp
22479Specify the access model for the thread local storage pointer. The valid
22480models are @samp{soft}, which generates calls to @code{__aeabi_read_tp},
22481@samp{cp15}, which fetches the thread pointer from @code{cp15} directly
22482(supported in the arm6k architecture), and @samp{auto}, which uses the
22483best available method for the selected processor. The default setting is
22484@samp{auto}.
22485
22486@item -mtls-dialect=@var{dialect}
22487@opindex mtls-dialect
22488Specify the dialect to use for accessing thread local storage. Two
22489@var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
22490@samp{gnu} dialect selects the original GNU scheme for supporting
22491local and global dynamic TLS models. The @samp{gnu2} dialect
22492selects the GNU descriptor scheme, which provides better performance
22493for shared libraries. The GNU descriptor scheme is compatible with
22494the original scheme, but does require new assembler, linker and
22495library support. Initial and local exec TLS models are unaffected by
22496this option and always use the original scheme.
22497
22498@item -mword-relocations
22499@opindex mword-relocations
22500Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
22501This is enabled by default on targets (uClinux, SymbianOS) where the runtime
22502loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
22503is specified. This option conflicts with @option{-mslow-flash-data}.
22504
22505@item -mfix-cortex-m3-ldrd
22506@opindex mfix-cortex-m3-ldrd
22507Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
22508with overlapping destination and base registers are used. This option avoids
22509generating these instructions. This option is enabled by default when
22510@option{-mcpu=cortex-m3} is specified.
22511
22512@item -mfix-cortex-a57-aes-1742098
22513@itemx -mno-fix-cortex-a57-aes-1742098
22514@itemx -mfix-cortex-a72-aes-1655431
22515@itemx -mno-fix-cortex-a72-aes-1655431
22516Enable (disable) mitigation for an erratum on Cortex-A57 and
22517Cortex-A72 that affects the AES cryptographic instructions. This
22518option is enabled by default when either @option{-mcpu=cortex-a57} or
22519@option{-mcpu=cortex-a72} is specified.
22520
22521@item -munaligned-access
22522@itemx -mno-unaligned-access
22523@opindex munaligned-access
22524@opindex mno-unaligned-access
22525Enables (or disables) reading and writing of 16- and 32- bit values
22526from addresses that are not 16- or 32- bit aligned. By default
22527unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
22528ARMv8-M Baseline architectures, and enabled for all other
22529architectures. If unaligned access is not enabled then words in packed
22530data structures are accessed a byte at a time.
22531
22532The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
22533generated object file to either true or false, depending upon the
22534setting of this option. If unaligned access is enabled then the
22535preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
22536defined.
22537
22538@item -mneon-for-64bits
22539@opindex mneon-for-64bits
22540This option is deprecated and has no effect.
22541
22542@item -mslow-flash-data
22543@opindex mslow-flash-data
22544Assume loading data from flash is slower than fetching instruction.
22545Therefore literal load is minimized for better performance.
22546This option is only supported when compiling for ARMv7 M-profile and
22547off by default. It conflicts with @option{-mword-relocations}.
22548
22549@item -masm-syntax-unified
22550@opindex masm-syntax-unified
22551Assume inline assembler is using unified asm syntax. The default is
22552currently off which implies divided syntax. This option has no impact
22553on Thumb2. However, this may change in future releases of GCC.
22554Divided syntax should be considered deprecated.
22555
22556@item -mrestrict-it
22557@opindex mrestrict-it
22558Restricts generation of IT blocks to conform to the rules of ARMv8-A.
22559IT blocks can only contain a single 16-bit instruction from a select
22560set of instructions. This option is on by default for ARMv8-A Thumb mode.
22561
22562@item -mprint-tune-info
22563@opindex mprint-tune-info
22564Print CPU tuning information as comment in assembler file. This is
22565an option used only for regression testing of the compiler and not
22566intended for ordinary use in compiling code. This option is disabled
22567by default.
22568
22569@item -mverbose-cost-dump
22570@opindex mverbose-cost-dump
22571Enable verbose cost model dumping in the debug dump files. This option is
22572provided for use in debugging the compiler.
22573
22574@item -mpure-code
22575@opindex mpure-code
22576Do not allow constant data to be placed in code sections.
22577Additionally, when compiling for ELF object format give all text sections the
22578ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
22579is only available when generating non-pic code for M-profile targets.
22580
22581@item -mcmse
22582@opindex mcmse
22583Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
22584Development Tools Engineering Specification", which can be found on
22585@url{https://developer.arm.com/documentation/ecm0359818/latest/}.
22586
22587@item -mfix-cmse-cve-2021-35465
22588@opindex mfix-cmse-cve-2021-35465
22589Mitigate against a potential security issue with the @code{VLLDM} instruction
22590in some M-profile devices when using CMSE (CVE-2021-365465). This option is
22591enabled by default when the option @option{-mcpu=} is used with
ccfd1e7f
SP
22592@code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55}, @code{cortex-m85}
22593or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465} can be used
22594to disable the mitigation.
d77de738
ML
22595
22596@item -mstack-protector-guard=@var{guard}
22597@itemx -mstack-protector-guard-offset=@var{offset}
22598@opindex mstack-protector-guard
22599@opindex mstack-protector-guard-offset
22600Generate stack protection code using canary at @var{guard}. Supported
22601locations are @samp{global} for a global canary or @samp{tls} for a
22602canary accessible via the TLS register. The option
22603@option{-mstack-protector-guard-offset=} is for use with
22604@option{-fstack-protector-guard=tls} and not for use in user-land code.
22605
22606@item -mfdpic
22607@itemx -mno-fdpic
22608@opindex mfdpic
22609@opindex mno-fdpic
22610Select the FDPIC ABI, which uses 64-bit function descriptors to
22611represent pointers to functions. When the compiler is configured for
22612@code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
22613and implies @option{-fPIE} if none of the PIC/PIE-related options is
22614provided. On other targets, it only enables the FDPIC-specific code
22615generation features, and the user should explicitly provide the
22616PIC/PIE-related options as needed.
22617
22618Note that static linking is not supported because it would still
22619involve the dynamic linker when the program self-relocates. If such
22620behavior is acceptable, use -static and -Wl,-dynamic-linker options.
22621
22622The opposite @option{-mno-fdpic} option is useful (and required) to
22623build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
22624toolchain as the one used to build the userland programs.
22625
b457cab6 22626@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]
14fab5fb
AC
22627@opindex mbranch-protection
22628Enable branch protection features (armv8.1-m.main only).
22629@samp{none} generate code without branch protection or return address
22630signing.
22631@samp{standard[+@var{leaf}]} generate code with all branch protection
22632features enabled at their standard level.
22633@samp{pac-ret[+@var{leaf}]} generate code with return address signing
22634set to its standard level, which is to sign all functions that save
22635the return address to memory.
22636@samp{leaf} When return address signing is enabled, also sign leaf
22637functions even if they do not write the return address to memory.
22638+@samp{bti} Add landing-pad instructions at the permitted targets of
22639indirect branch instructions.
22640
22641If the @samp{+pacbti} architecture extension is not enabled, then all
22642branch protection and return address signing operations are
22643constrained to use only the instructions defined in the
22644architectural-NOP space. The generated code will remain
22645backwards-compatible with earlier versions of the architecture, but
22646the additional security can be enabled at run time on processors that
22647support the @samp{PACBTI} extension.
22648
22649Branch target enforcement using BTI can only be enabled at runtime if
22650all code in the application has been compiled with at least
22651@samp{-mbranch-protection=bti}.
22652
22653Any setting other than @samp{none} is supported only on armv8-m.main
22654or later.
22655
22656The default is to generate code without branch protection or return
22657address signing.
22658
d77de738
ML
22659@end table
22660
22661@node AVR Options
22662@subsection AVR Options
22663@cindex AVR Options
22664
22665These options are defined for AVR implementations:
22666
22667@table @gcctabopt
22668@item -mmcu=@var{mcu}
22669@opindex mmcu
22670Specify Atmel AVR instruction set architectures (ISA) or MCU type.
22671
22672The default for this option is@tie{}@samp{avr2}.
22673
22674GCC supports the following AVR devices and ISAs:
22675
22676@include avr-mmcu.texi
22677
22678@item -mabsdata
22679@opindex mabsdata
22680
22681Assume that all data in static storage can be accessed by LDS / STS
22682instructions. This option has only an effect on reduced Tiny devices like
22683ATtiny40. See also the @code{absdata}
22684@ref{AVR Variable Attributes,variable attribute}.
22685
22686@item -maccumulate-args
22687@opindex maccumulate-args
22688Accumulate outgoing function arguments and acquire/release the needed
22689stack space for outgoing function arguments once in function
22690prologue/epilogue. Without this option, outgoing arguments are pushed
22691before calling a function and popped afterwards.
22692
22693Popping the arguments after the function call can be expensive on
22694AVR so that accumulating the stack space might lead to smaller
22695executables because arguments need not be removed from the
22696stack after such a function call.
22697
22698This option can lead to reduced code size for functions that perform
22699several calls to functions that get their arguments on the stack like
22700calls to printf-like functions.
22701
22702@item -mbranch-cost=@var{cost}
22703@opindex mbranch-cost
22704Set the branch costs for conditional branch instructions to
22705@var{cost}. Reasonable values for @var{cost} are small, non-negative
22706integers. The default branch cost is 0.
22707
22708@item -mcall-prologues
22709@opindex mcall-prologues
22710Functions prologues/epilogues are expanded as calls to appropriate
22711subroutines. Code size is smaller.
22712
22713@item -mdouble=@var{bits}
22714@itemx -mlong-double=@var{bits}
22715@opindex mdouble
22716@opindex mlong-double
22717Set the size (in bits) of the @code{double} or @code{long double} type,
22718respectively. Possible values for @var{bits} are 32 and 64.
22719Whether or not a specific value for @var{bits} is allowed depends on
22720the @code{--with-double=} and @code{--with-long-double=}
22721@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
22722and the same applies for the default values of the options.
22723
22724@item -mgas-isr-prologues
22725@opindex mgas-isr-prologues
22726Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
22727instruction supported by GNU Binutils.
22728If this option is on, the feature can still be disabled for individual
22729ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
22730function attribute. This feature is activated per default
22731if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
22732and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
22733
22734@item -mint8
22735@opindex mint8
22736Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
22737@code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
22738and @code{long long} is 4 bytes. Please note that this option does not
22739conform to the C standards, but it results in smaller code
22740size.
22741
22742@item -mmain-is-OS_task
22743@opindex mmain-is-OS_task
22744Do not save registers in @code{main}. The effect is the same like
22745attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
22746to @code{main}. It is activated per default if optimization is on.
22747
22748@item -mn-flash=@var{num}
22749@opindex mn-flash
22750Assume that the flash memory has a size of
22751@var{num} times 64@tie{}KiB.
22752
22753@item -mno-interrupts
22754@opindex mno-interrupts
22755Generated code is not compatible with hardware interrupts.
22756Code size is smaller.
22757
22758@item -mrelax
22759@opindex mrelax
22760Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
22761@code{RCALL} resp.@: @code{RJMP} instruction if applicable.
22762Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
22763the assembler's command line and the @option{--relax} option to the
22764linker's command line.
22765
22766Jump relaxing is performed by the linker because jump offsets are not
22767known before code is located. Therefore, the assembler code generated by the
22768compiler is the same, but the instructions in the executable may
22769differ from instructions in the assembler code.
22770
22771Relaxing must be turned on if linker stubs are needed, see the
22772section on @code{EIND} and linker stubs below.
22773
22774@item -mrmw
22775@opindex mrmw
22776Assume that the device supports the Read-Modify-Write
22777instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
22778
22779@item -mshort-calls
22780@opindex mshort-calls
22781
22782Assume that @code{RJMP} and @code{RCALL} can target the whole
22783program memory.
22784
22785This option is used internally for multilib selection. It is
22786not an optimization option, and you don't need to set it by hand.
22787
22788@item -msp8
22789@opindex msp8
22790Treat the stack pointer register as an 8-bit register,
22791i.e.@: assume the high byte of the stack pointer is zero.
22792In general, you don't need to set this option by hand.
22793
22794This option is used internally by the compiler to select and
22795build multilibs for architectures @code{avr2} and @code{avr25}.
22796These architectures mix devices with and without @code{SPH}.
22797For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25}
22798the compiler driver adds or removes this option from the compiler
22799proper's command line, because the compiler then knows if the device
22800or architecture has an 8-bit stack pointer and thus no @code{SPH}
22801register or not.
22802
22803@item -mstrict-X
22804@opindex mstrict-X
22805Use address register @code{X} in a way proposed by the hardware. This means
22806that @code{X} is only used in indirect, post-increment or
22807pre-decrement addressing.
22808
22809Without this option, the @code{X} register may be used in the same way
22810as @code{Y} or @code{Z} which then is emulated by additional
22811instructions.
22812For example, loading a value with @code{X+const} addressing with a
22813small non-negative @code{const < 64} to a register @var{Rn} is
22814performed as
22815
22816@example
22817adiw r26, const ; X += const
22818ld @var{Rn}, X ; @var{Rn} = *X
22819sbiw r26, const ; X -= const
22820@end example
22821
22822@item -mtiny-stack
22823@opindex mtiny-stack
22824Only change the lower 8@tie{}bits of the stack pointer.
22825
22826@item -mfract-convert-truncate
22827@opindex mfract-convert-truncate
22828Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
22829
22830@item -nodevicelib
22831@opindex nodevicelib
22832Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}.
22833
22834@item -nodevicespecs
22835@opindex nodevicespecs
22836Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
22837command line. The user takes responsibility for supplying the sub-processes
22838like compiler proper, assembler and linker with appropriate command line
22839options. This means that the user has to supply her private device specs
22840file by means of @option{-specs=@var{path-to-specs-file}}. There is no
22841more need for option @option{-mmcu=@var{mcu}}.
22842
22843This option can also serve as a replacement for the older way of
22844specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
22845which contains a folder named @code{device-specs} which contains a specs file named
22846@code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
22847
22848@item -Waddr-space-convert
22849@opindex Waddr-space-convert
22850@opindex Wno-addr-space-convert
22851Warn about conversions between address spaces in the case where the
22852resulting address space is not contained in the incoming address space.
22853
22854@item -Wmisspelled-isr
22855@opindex Wmisspelled-isr
22856@opindex Wno-misspelled-isr
22857Warn if the ISR is misspelled, i.e.@: without __vector prefix.
22858Enabled by default.
22859@end table
22860
22861@subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
22862@cindex @code{EIND}
22863Pointers in the implementation are 16@tie{}bits wide.
22864The address of a function or label is represented as word address so
22865that indirect jumps and calls can target any code address in the
22866range of 64@tie{}Ki words.
22867
22868In order to facilitate indirect jump on devices with more than 128@tie{}Ki
22869bytes of program memory space, there is a special function register called
22870@code{EIND} that serves as most significant part of the target address
22871when @code{EICALL} or @code{EIJMP} instructions are used.
22872
22873Indirect jumps and calls on these devices are handled as follows by
22874the compiler and are subject to some limitations:
22875
22876@itemize @bullet
22877
22878@item
22879The compiler never sets @code{EIND}.
22880
22881@item
22882The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
22883instructions or might read @code{EIND} directly in order to emulate an
22884indirect call/jump by means of a @code{RET} instruction.
22885
22886@item
22887The compiler assumes that @code{EIND} never changes during the startup
22888code or during the application. In particular, @code{EIND} is not
22889saved/restored in function or interrupt service routine
22890prologue/epilogue.
22891
22892@item
22893For indirect calls to functions and computed goto, the linker
22894generates @emph{stubs}. Stubs are jump pads sometimes also called
22895@emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
22896The stub contains a direct jump to the desired address.
22897
22898@item
22899Linker relaxation must be turned on so that the linker generates
22900the stubs correctly in all situations. See the compiler option
22901@option{-mrelax} and the linker option @option{--relax}.
22902There are corner cases where the linker is supposed to generate stubs
22903but aborts without relaxation and without a helpful error message.
22904
22905@item
22906The default linker script is arranged for code with @code{EIND = 0}.
22907If code is supposed to work for a setup with @code{EIND != 0}, a custom
22908linker script has to be used in order to place the sections whose
22909name start with @code{.trampolines} into the segment where @code{EIND}
22910points to.
22911
22912@item
22913The startup code from libgcc never sets @code{EIND}.
22914Notice that startup code is a blend of code from libgcc and AVR-LibC.
22915For the impact of AVR-LibC on @code{EIND}, see the
a65da9be 22916@w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}.
d77de738
ML
22917
22918@item
22919It is legitimate for user-specific startup code to set up @code{EIND}
22920early, for example by means of initialization code located in
22921section @code{.init3}. Such code runs prior to general startup code
22922that initializes RAM and calls constructors, but after the bit
22923of startup code from AVR-LibC that sets @code{EIND} to the segment
22924where the vector table is located.
22925@example
22926#include <avr/io.h>
22927
22928static void
22929__attribute__((section(".init3"),naked,used,no_instrument_function))
22930init3_set_eind (void)
22931@{
22932 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
22933 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
22934@}
22935@end example
22936
22937@noindent
22938The @code{__trampolines_start} symbol is defined in the linker script.
22939
22940@item
22941Stubs are generated automatically by the linker if
22942the following two conditions are met:
22943@itemize @minus
22944
22945@item The address of a label is taken by means of the @code{gs} modifier
22946(short for @emph{generate stubs}) like so:
22947@example
22948LDI r24, lo8(gs(@var{func}))
22949LDI r25, hi8(gs(@var{func}))
22950@end example
22951@item The final location of that label is in a code segment
22952@emph{outside} the segment where the stubs are located.
22953@end itemize
22954
22955@item
22956The compiler emits such @code{gs} modifiers for code labels in the
22957following situations:
22958@itemize @minus
22959@item Taking address of a function or code label.
22960@item Computed goto.
22961@item If prologue-save function is used, see @option{-mcall-prologues}
22962command-line option.
22963@item Switch/case dispatch tables. If you do not want such dispatch
22964tables you can specify the @option{-fno-jump-tables} command-line option.
22965@item C and C++ constructors/destructors called during startup/shutdown.
22966@item If the tools hit a @code{gs()} modifier explained above.
22967@end itemize
22968
22969@item
22970Jumping to non-symbolic addresses like so is @emph{not} supported:
22971
22972@example
22973int main (void)
22974@{
22975 /* Call function at word address 0x2 */
22976 return ((int(*)(void)) 0x2)();
22977@}
22978@end example
22979
22980Instead, a stub has to be set up, i.e.@: the function has to be called
22981through a symbol (@code{func_4} in the example):
22982
22983@example
22984int main (void)
22985@{
22986 extern int func_4 (void);
22987
22988 /* Call function at byte address 0x4 */
22989 return func_4();
22990@}
22991@end example
22992
22993and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
22994Alternatively, @code{func_4} can be defined in the linker script.
22995@end itemize
22996
22997@subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
22998@cindex @code{RAMPD}
22999@cindex @code{RAMPX}
23000@cindex @code{RAMPY}
23001@cindex @code{RAMPZ}
23002Some AVR devices support memories larger than the 64@tie{}KiB range
23003that can be accessed with 16-bit pointers. To access memory locations
23004outside this 64@tie{}KiB range, the content of a @code{RAMP}
23005register is used as high part of the address:
23006The @code{X}, @code{Y}, @code{Z} address register is concatenated
23007with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
23008register, respectively, to get a wide address. Similarly,
23009@code{RAMPD} is used together with direct addressing.
23010
23011@itemize
23012@item
23013The startup code initializes the @code{RAMP} special function
23014registers with zero.
23015
23016@item
23017If a @ref{AVR Named Address Spaces,named address space} other than
23018generic or @code{__flash} is used, then @code{RAMPZ} is set
23019as needed before the operation.
23020
23021@item
23022If the device supports RAM larger than 64@tie{}KiB and the compiler
23023needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
23024is reset to zero after the operation.
23025
23026@item
23027If the device comes with a specific @code{RAMP} register, the ISR
23028prologue/epilogue saves/restores that SFR and initializes it with
23029zero in case the ISR code might (implicitly) use it.
23030
23031@item
23032RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
23033If you use inline assembler to read from locations outside the
2303416-bit address range and change one of the @code{RAMP} registers,
23035you must reset it to zero after the access.
23036
23037@end itemize
23038
23039@subsubsection AVR Built-in Macros
23040
23041GCC defines several built-in macros so that the user code can test
23042for the presence or absence of features. Almost any of the following
23043built-in macros are deduced from device capabilities and thus
23044triggered by the @option{-mmcu=} command-line option.
23045
23046For even more AVR-specific built-in macros see
23047@ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
23048
23049@table @code
23050
23051@item __AVR_ARCH__
23052Build-in macro that resolves to a decimal number that identifies the
23053architecture and depends on the @option{-mmcu=@var{mcu}} option.
23054Possible values are:
23055
23056@code{2}, @code{25}, @code{3}, @code{31}, @code{35},
23057@code{4}, @code{5}, @code{51}, @code{6}
23058
23059for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
23060@code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
23061
23062respectively and
23063
23064@code{100},
23065@code{102}, @code{103}, @code{104},
23066@code{105}, @code{106}, @code{107}
23067
23068for @var{mcu}=@code{avrtiny},
23069@code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
23070@code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
23071If @var{mcu} specifies a device, this built-in macro is set
23072accordingly. For example, with @option{-mmcu=atmega8} the macro is
23073defined to @code{4}.
23074
23075@item __AVR_@var{Device}__
23076Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
23077the device's name. For example, @option{-mmcu=atmega8} defines the
23078built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
23079@code{__AVR_ATtiny261A__}, etc.
23080
23081The built-in macros' names follow
23082the scheme @code{__AVR_@var{Device}__} where @var{Device} is
23083the device name as from the AVR user manual. The difference between
23084@var{Device} in the built-in macro and @var{device} in
23085@option{-mmcu=@var{device}} is that the latter is always lowercase.
23086
23087If @var{device} is not a device but only a core architecture like
23088@samp{avr51}, this macro is not defined.
23089
23090@item __AVR_DEVICE_NAME__
23091Setting @option{-mmcu=@var{device}} defines this built-in macro to
23092the device's name. For example, with @option{-mmcu=atmega8} the macro
23093is defined to @code{atmega8}.
23094
23095If @var{device} is not a device but only a core architecture like
23096@samp{avr51}, this macro is not defined.
23097
23098@item __AVR_XMEGA__
23099The device / architecture belongs to the XMEGA family of devices.
23100
23101@item __AVR_HAVE_ELPM__
23102The device has the @code{ELPM} instruction.
23103
23104@item __AVR_HAVE_ELPMX__
23105The device has the @code{ELPM R@var{n},Z} and @code{ELPM
23106R@var{n},Z+} instructions.
23107
23108@item __AVR_HAVE_MOVW__
23109The device has the @code{MOVW} instruction to perform 16-bit
23110register-register moves.
23111
23112@item __AVR_HAVE_LPMX__
23113The device has the @code{LPM R@var{n},Z} and
23114@code{LPM R@var{n},Z+} instructions.
23115
23116@item __AVR_HAVE_MUL__
23117The device has a hardware multiplier.
23118
23119@item __AVR_HAVE_JMP_CALL__
23120The device has the @code{JMP} and @code{CALL} instructions.
23121This is the case for devices with more than 8@tie{}KiB of program
23122memory.
23123
23124@item __AVR_HAVE_EIJMP_EICALL__
23125@itemx __AVR_3_BYTE_PC__
23126The device has the @code{EIJMP} and @code{EICALL} instructions.
23127This is the case for devices with more than 128@tie{}KiB of program memory.
23128This also means that the program counter
23129(PC) is 3@tie{}bytes wide.
23130
23131@item __AVR_2_BYTE_PC__
23132The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
23133with up to 128@tie{}KiB of program memory.
23134
23135@item __AVR_HAVE_8BIT_SP__
23136@itemx __AVR_HAVE_16BIT_SP__
23137The stack pointer (SP) register is treated as 8-bit respectively
2313816-bit register by the compiler.
23139The definition of these macros is affected by @option{-mtiny-stack}.
23140
23141@item __AVR_HAVE_SPH__
23142@itemx __AVR_SP8__
23143The device has the SPH (high part of stack pointer) special function
23144register or has an 8-bit stack pointer, respectively.
23145The definition of these macros is affected by @option{-mmcu=} and
23146in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
23147by @option{-msp8}.
23148
23149@item __AVR_HAVE_RAMPD__
23150@itemx __AVR_HAVE_RAMPX__
23151@itemx __AVR_HAVE_RAMPY__
23152@itemx __AVR_HAVE_RAMPZ__
23153The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
23154@code{RAMPZ} special function register, respectively.
23155
23156@item __NO_INTERRUPTS__
23157This macro reflects the @option{-mno-interrupts} command-line option.
23158
23159@item __AVR_ERRATA_SKIP__
23160@itemx __AVR_ERRATA_SKIP_JMP_CALL__
23161Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
23162instructions because of a hardware erratum. Skip instructions are
23163@code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
23164The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
23165set.
23166
23167@item __AVR_ISA_RMW__
23168The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
23169
23170@item __AVR_SFR_OFFSET__=@var{offset}
23171Instructions that can address I/O special function registers directly
23172like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
23173address as if addressed by an instruction to access RAM like @code{LD}
23174or @code{STS}. This offset depends on the device architecture and has
23175to be subtracted from the RAM address in order to get the
23176respective I/O@tie{}address.
23177
23178@item __AVR_SHORT_CALLS__
23179The @option{-mshort-calls} command line option is set.
23180
23181@item __AVR_PM_BASE_ADDRESS__=@var{addr}
23182Some devices support reading from flash memory by means of @code{LD*}
23183instructions. The flash memory is seen in the data address space
23184at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
23185is not defined, this feature is not available. If defined,
23186the address space is linear and there is no need to put
23187@code{.rodata} into RAM. This is handled by the default linker
23188description file, and is currently available for
23189@code{avrtiny} and @code{avrxmega3}. Even more convenient,
23190there is no need to use address spaces like @code{__flash} or
23191features like attribute @code{progmem} and @code{pgm_read_*}.
23192
23193@item __WITH_AVRLIBC__
23194The compiler is configured to be used together with AVR-Libc.
23195See the @option{--with-avrlibc} configure option.
23196
23197@item __HAVE_DOUBLE_MULTILIB__
23198Defined if @option{-mdouble=} acts as a multilib option.
23199
23200@item __HAVE_DOUBLE32__
23201@itemx __HAVE_DOUBLE64__
23202Defined if the compiler supports 32-bit double resp. 64-bit double.
23203The actual layout is specified by option @option{-mdouble=}.
23204
23205@item __DEFAULT_DOUBLE__
23206The size in bits of @code{double} if @option{-mdouble=} is not set.
23207To test the layout of @code{double} in a program, use the built-in
23208macro @code{__SIZEOF_DOUBLE__}.
23209
23210@item __HAVE_LONG_DOUBLE32__
23211@itemx __HAVE_LONG_DOUBLE64__
23212@itemx __HAVE_LONG_DOUBLE_MULTILIB__
23213@itemx __DEFAULT_LONG_DOUBLE__
23214Same as above, but for @code{long double} instead of @code{double}.
23215
23216@item __WITH_DOUBLE_COMPARISON__
23217Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
23218@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
23219and is defined to @code{2} or @code{3}.
23220
23221@item __WITH_LIBF7_LIBGCC__
23222@itemx __WITH_LIBF7_MATH__
23223@itemx __WITH_LIBF7_MATH_SYMBOLS__
23224Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
23225@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
23226
23227@end table
23228
23229@node Blackfin Options
23230@subsection Blackfin Options
23231@cindex Blackfin Options
23232
23233@table @gcctabopt
23234@item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
23235@opindex mcpu=
23236Specifies the name of the target Blackfin processor. Currently, @var{cpu}
23237can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
23238@samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
23239@samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
23240@samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
23241@samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
23242@samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
23243@samp{bf561}, @samp{bf592}.
23244
23245The optional @var{sirevision} specifies the silicon revision of the target
23246Blackfin processor. Any workarounds available for the targeted silicon revision
23247are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
23248If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
23249are enabled. The @code{__SILICON_REVISION__} macro is defined to two
23250hexadecimal digits representing the major and minor numbers in the silicon
23251revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
23252is not defined. If @var{sirevision} is @samp{any}, the
23253@code{__SILICON_REVISION__} is defined to be @code{0xffff}.
23254If this optional @var{sirevision} is not used, GCC assumes the latest known
23255silicon revision of the targeted Blackfin processor.
23256
23257GCC defines a preprocessor macro for the specified @var{cpu}.
23258For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
23259provided by libgloss to be linked in if @option{-msim} is not given.
23260
23261Without this option, @samp{bf532} is used as the processor by default.
23262
23263Note that support for @samp{bf561} is incomplete. For @samp{bf561},
23264only the preprocessor macro is defined.
23265
23266@item -msim
23267@opindex msim
23268Specifies that the program will be run on the simulator. This causes
23269the simulator BSP provided by libgloss to be linked in. This option
23270has effect only for @samp{bfin-elf} toolchain.
23271Certain other options, such as @option{-mid-shared-library} and
23272@option{-mfdpic}, imply @option{-msim}.
23273
23274@item -momit-leaf-frame-pointer
23275@opindex momit-leaf-frame-pointer
23276Don't keep the frame pointer in a register for leaf functions. This
23277avoids the instructions to save, set up and restore frame pointers and
23278makes an extra register available in leaf functions.
23279
23280@item -mspecld-anomaly
23281@opindex mspecld-anomaly
23282When enabled, the compiler ensures that the generated code does not
23283contain speculative loads after jump instructions. If this option is used,
23284@code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
23285
23286@item -mno-specld-anomaly
23287@opindex mno-specld-anomaly
23288@opindex mspecld-anomaly
23289Don't generate extra code to prevent speculative loads from occurring.
23290
23291@item -mcsync-anomaly
23292@opindex mcsync-anomaly
23293When enabled, the compiler ensures that the generated code does not
23294contain CSYNC or SSYNC instructions too soon after conditional branches.
23295If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
23296
23297@item -mno-csync-anomaly
23298@opindex mno-csync-anomaly
23299@opindex mcsync-anomaly
23300Don't generate extra code to prevent CSYNC or SSYNC instructions from
23301occurring too soon after a conditional branch.
23302
23303@item -mlow64k
23304@opindex mlow64k
23305When enabled, the compiler is free to take advantage of the knowledge that
23306the entire program fits into the low 64k of memory.
23307
23308@item -mno-low64k
23309@opindex mno-low64k
23310Assume that the program is arbitrarily large. This is the default.
23311
23312@item -mstack-check-l1
23313@opindex mstack-check-l1
23314Do stack checking using information placed into L1 scratchpad memory by the
23315uClinux kernel.
23316
23317@item -mid-shared-library
23318@opindex mid-shared-library
23319Generate code that supports shared libraries via the library ID method.
23320This allows for execute in place and shared libraries in an environment
23321without virtual memory management. This option implies @option{-fPIC}.
23322With a @samp{bfin-elf} target, this option implies @option{-msim}.
23323
23324@item -mno-id-shared-library
23325@opindex mno-id-shared-library
23326@opindex mid-shared-library
23327Generate code that doesn't assume ID-based shared libraries are being used.
23328This is the default.
23329
23330@item -mleaf-id-shared-library
23331@opindex mleaf-id-shared-library
23332Generate code that supports shared libraries via the library ID method,
23333but assumes that this library or executable won't link against any other
23334ID shared libraries. That allows the compiler to use faster code for jumps
23335and calls.
23336
23337@item -mno-leaf-id-shared-library
23338@opindex mno-leaf-id-shared-library
23339@opindex mleaf-id-shared-library
23340Do not assume that the code being compiled won't link against any ID shared
23341libraries. Slower code is generated for jump and call insns.
23342
23343@item -mshared-library-id=n
23344@opindex mshared-library-id
23345Specifies the identification number of the ID-based shared library being
23346compiled. Specifying a value of 0 generates more compact code; specifying
23347other values forces the allocation of that number to the current
23348library but is no more space- or time-efficient than omitting this option.
23349
23350@item -msep-data
23351@opindex msep-data
23352Generate code that allows the data segment to be located in a different
23353area of memory from the text segment. This allows for execute in place in
23354an environment without virtual memory management by eliminating relocations
23355against the text section.
23356
23357@item -mno-sep-data
23358@opindex mno-sep-data
23359@opindex msep-data
23360Generate code that assumes that the data segment follows the text segment.
23361This is the default.
23362
23363@item -mlong-calls
23364@itemx -mno-long-calls
23365@opindex mlong-calls
23366@opindex mno-long-calls
23367Tells the compiler to perform function calls by first loading the
23368address of the function into a register and then performing a subroutine
23369call on this register. This switch is needed if the target function
23370lies outside of the 24-bit addressing range of the offset-based
23371version of subroutine call instruction.
23372
23373This feature is not enabled by default. Specifying
23374@option{-mno-long-calls} restores the default behavior. Note these
23375switches have no effect on how the compiler generates code to handle
23376function calls via function pointers.
23377
23378@item -mfast-fp
23379@opindex mfast-fp
23380Link with the fast floating-point library. This library relaxes some of
23381the IEEE floating-point standard's rules for checking inputs against
23382Not-a-Number (NAN), in the interest of performance.
23383
23384@item -minline-plt
23385@opindex minline-plt
23386Enable inlining of PLT entries in function calls to functions that are
23387not known to bind locally. It has no effect without @option{-mfdpic}.
23388
23389@item -mmulticore
23390@opindex mmulticore
23391Build a standalone application for multicore Blackfin processors.
23392This option causes proper start files and link scripts supporting
23393multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
23394It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
23395
23396This option can be used with @option{-mcorea} or @option{-mcoreb}, which
23397selects the one-application-per-core programming model. Without
23398@option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
23399programming model is used. In this model, the main function of Core B
23400should be named as @code{coreb_main}.
23401
23402If this option is not used, the single-core application programming
23403model is used.
23404
23405@item -mcorea
23406@opindex mcorea
23407Build a standalone application for Core A of BF561 when using
23408the one-application-per-core programming model. Proper start files
23409and link scripts are used to support Core A, and the macro
23410@code{__BFIN_COREA} is defined.
23411This option can only be used in conjunction with @option{-mmulticore}.
23412
23413@item -mcoreb
23414@opindex mcoreb
23415Build a standalone application for Core B of BF561 when using
23416the one-application-per-core programming model. Proper start files
23417and link scripts are used to support Core B, and the macro
23418@code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
23419should be used instead of @code{main}.
23420This option can only be used in conjunction with @option{-mmulticore}.
23421
23422@item -msdram
23423@opindex msdram
23424Build a standalone application for SDRAM. Proper start files and
23425link scripts are used to put the application into SDRAM, and the macro
23426@code{__BFIN_SDRAM} is defined.
23427The loader should initialize SDRAM before loading the application.
23428
23429@item -micplb
23430@opindex micplb
23431Assume that ICPLBs are enabled at run time. This has an effect on certain
23432anomaly workarounds. For Linux targets, the default is to assume ICPLBs
23433are enabled; for standalone applications the default is off.
23434@end table
23435
23436@node C6X Options
23437@subsection C6X Options
23438@cindex C6X Options
23439
23440@table @gcctabopt
23441@item -march=@var{name}
23442@opindex march
23443This specifies the name of the target architecture. GCC uses this
23444name to determine what kind of instructions it can emit when generating
23445assembly code. Permissible names are: @samp{c62x},
23446@samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
23447
23448@item -mbig-endian
23449@opindex mbig-endian
23450Generate code for a big-endian target.
23451
23452@item -mlittle-endian
23453@opindex mlittle-endian
23454Generate code for a little-endian target. This is the default.
23455
23456@item -msim
23457@opindex msim
23458Choose startup files and linker script suitable for the simulator.
23459
23460@item -msdata=default
23461@opindex msdata=default
23462Put small global and static data in the @code{.neardata} section,
23463which is pointed to by register @code{B14}. Put small uninitialized
23464global and static data in the @code{.bss} section, which is adjacent
23465to the @code{.neardata} section. Put small read-only data into the
23466@code{.rodata} section. The corresponding sections used for large
23467pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
23468
23469@item -msdata=all
23470@opindex msdata=all
23471Put all data, not just small objects, into the sections reserved for
23472small data, and use addressing relative to the @code{B14} register to
23473access them.
23474
23475@item -msdata=none
23476@opindex msdata=none
23477Make no use of the sections reserved for small data, and use absolute
23478addresses to access all data. Put all initialized global and static
23479data in the @code{.fardata} section, and all uninitialized data in the
23480@code{.far} section. Put all constant data into the @code{.const}
23481section.
23482@end table
23483
23484@node CRIS Options
23485@subsection CRIS Options
23486@cindex CRIS Options
23487
23488These options are defined specifically for the CRIS ports.
23489
23490@table @gcctabopt
23491@item -march=@var{architecture-type}
23492@itemx -mcpu=@var{architecture-type}
23493@opindex march
23494@opindex mcpu
23495Generate code for the specified architecture. The choices for
23496@var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
23497respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
23498Default is @samp{v0}.
23499
23500@item -mtune=@var{architecture-type}
23501@opindex mtune
23502Tune to @var{architecture-type} everything applicable about the generated
23503code, except for the ABI and the set of available instructions. The
23504choices for @var{architecture-type} are the same as for
23505@option{-march=@var{architecture-type}}.
23506
23507@item -mmax-stack-frame=@var{n}
23508@opindex mmax-stack-frame
23509Warn when the stack frame of a function exceeds @var{n} bytes.
23510
23511@item -metrax4
23512@itemx -metrax100
23513@opindex metrax4
23514@opindex metrax100
23515The options @option{-metrax4} and @option{-metrax100} are synonyms for
23516@option{-march=v3} and @option{-march=v8} respectively.
23517
23518@item -mmul-bug-workaround
23519@itemx -mno-mul-bug-workaround
23520@opindex mmul-bug-workaround
23521@opindex mno-mul-bug-workaround
23522Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
23523models where it applies. This option is disabled by default.
23524
23525@item -mpdebug
23526@opindex mpdebug
23527Enable CRIS-specific verbose debug-related information in the assembly
23528code. This option also has the effect of turning off the @samp{#NO_APP}
23529formatted-code indicator to the assembler at the beginning of the
23530assembly file.
23531
23532@item -mcc-init
23533@opindex mcc-init
23534Do not use condition-code results from previous instruction; always emit
23535compare and test instructions before use of condition codes.
23536
23537@item -mno-side-effects
23538@opindex mno-side-effects
23539@opindex mside-effects
23540Do not emit instructions with side effects in addressing modes other than
23541post-increment.
23542
23543@item -mstack-align
23544@itemx -mno-stack-align
23545@itemx -mdata-align
23546@itemx -mno-data-align
23547@itemx -mconst-align
23548@itemx -mno-const-align
23549@opindex mstack-align
23550@opindex mno-stack-align
23551@opindex mdata-align
23552@opindex mno-data-align
23553@opindex mconst-align
23554@opindex mno-const-align
23555These options (@samp{no-} options) arrange (eliminate arrangements) for the
23556stack frame, individual data and constants to be aligned for the maximum
23557single data access size for the chosen CPU model. The default is to
23558arrange for 32-bit alignment. ABI details such as structure layout are
23559not affected by these options.
23560
23561@item -m32-bit
23562@itemx -m16-bit
23563@itemx -m8-bit
23564@opindex m32-bit
23565@opindex m16-bit
23566@opindex m8-bit
23567Similar to the stack- data- and const-align options above, these options
23568arrange for stack frame, writable data and constants to all be 32-bit,
2356916-bit or 8-bit aligned. The default is 32-bit alignment.
23570
23571@item -mno-prologue-epilogue
23572@itemx -mprologue-epilogue
23573@opindex mno-prologue-epilogue
23574@opindex mprologue-epilogue
23575With @option{-mno-prologue-epilogue}, the normal function prologue and
23576epilogue which set up the stack frame are omitted and no return
23577instructions or return sequences are generated in the code. Use this
23578option only together with visual inspection of the compiled code: no
23579warnings or errors are generated when call-saved registers must be saved,
23580or storage for local variables needs to be allocated.
23581
23582@item -melf
23583@opindex melf
23584Legacy no-op option.
23585
23586@item -sim
23587@opindex sim
23588This option arranges
23589to link with input-output functions from a simulator library. Code,
23590initialized data and zero-initialized data are allocated consecutively.
23591
23592@item -sim2
23593@opindex sim2
23594Like @option{-sim}, but pass linker options to locate initialized data at
235950x40000000 and zero-initialized data at 0x80000000.
23596@end table
23597
23598@node C-SKY Options
23599@subsection C-SKY Options
23600@cindex C-SKY Options
23601
23602GCC supports these options when compiling for C-SKY V2 processors.
23603
23604@table @gcctabopt
23605
23606@item -march=@var{arch}
23607@opindex march=
23608Specify the C-SKY target architecture. Valid values for @var{arch} are:
23609@samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
23610The default is @samp{ck810}.
23611
23612@item -mcpu=@var{cpu}
23613@opindex mcpu=
23614Specify the C-SKY target processor. Valid values for @var{cpu} are:
23615@samp{ck801}, @samp{ck801t},
23616@samp{ck802}, @samp{ck802t}, @samp{ck802j},
23617@samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
23618@samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
23619@samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
23620@samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
23621@samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
23622@samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
23623@samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
23624@samp{ck803eftr1}, @samp{ck803efhtr1},
23625@samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
23626@samp{ck803sef}, @samp{ck803seft},
23627@samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
23628@samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
23629@samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
23630@samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
23631
23632@item -mbig-endian
23633@opindex mbig-endian
23634@itemx -EB
23635@opindex EB
23636@itemx -mlittle-endian
23637@opindex mlittle-endian
23638@itemx -EL
23639@opindex EL
23640
23641Select big- or little-endian code. The default is little-endian.
23642
23643@item -mfloat-abi=@var{name}
23644@opindex mfloat-abi
23645Specifies which floating-point ABI to use. Permissible values
23646are: @samp{soft}, @samp{softfp} and @samp{hard}.
23647
23648Specifying @samp{soft} causes GCC to generate output containing
23649library calls for floating-point operations.
23650@samp{softfp} allows the generation of code using hardware floating-point
23651instructions, but still uses the soft-float calling conventions.
23652@samp{hard} allows generation of floating-point instructions
23653and uses FPU-specific calling conventions.
23654
23655The default depends on the specific target configuration. Note that
23656the hard-float and soft-float ABIs are not link-compatible; you must
23657compile your entire program with the same ABI, and link with a
23658compatible set of libraries.
23659
23660@item -mhard-float
23661@opindex mhard-float
23662@itemx -msoft-float
23663@opindex msoft-float
23664
23665Select hardware or software floating-point implementations.
23666The default is soft float.
23667
23668@item -mdouble-float
23669@itemx -mno-double-float
23670@opindex mdouble-float
23671When @option{-mhard-float} is in effect, enable generation of
23672double-precision float instructions. This is the default except
23673when compiling for CK803.
23674
23675@item -mfdivdu
23676@itemx -mno-fdivdu
23677@opindex mfdivdu
23678When @option{-mhard-float} is in effect, enable generation of
23679@code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
23680This is the default except when compiling for CK803.
23681
23682@item -mfpu=@var{fpu}
23683@opindex mfpu=
23684Select the floating-point processor. This option can only be used with
23685@option{-mhard-float}.
23686Values for @var{fpu} are
23687@samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
23688@samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
23689@samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
23690
23691@item -melrw
23692@itemx -mno-elrw
23693@opindex melrw
23694Enable the extended @code{lrw} instruction. This option defaults to on
23695for CK801 and off otherwise.
23696
23697@item -mistack
23698@itemx -mno-istack
23699@opindex mistack
23700Enable interrupt stack instructions; the default is off.
23701
23702The @option{-mistack} option is required to handle the
23703@code{interrupt} and @code{isr} function attributes
23704(@pxref{C-SKY Function Attributes}).
23705
23706@item -mmp
23707@opindex mmp
23708Enable multiprocessor instructions; the default is off.
23709
23710@item -mcp
23711@opindex mcp
23712Enable coprocessor instructions; the default is off.
23713
23714@item -mcache
23715@opindex mcache
23716Enable coprocessor instructions; the default is off.
23717
23718@item -msecurity
23719@opindex msecurity
23720Enable C-SKY security instructions; the default is off.
23721
23722@item -mtrust
23723@opindex mtrust
23724Enable C-SKY trust instructions; the default is off.
23725
23726@item -mdsp
23727@opindex mdsp
23728@itemx -medsp
23729@opindex medsp
23730@itemx -mvdsp
23731@opindex mvdsp
23732Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
23733All of these options default to off.
23734
23735@item -mdiv
23736@itemx -mno-div
23737@opindex mdiv
23738Generate divide instructions. Default is off.
23739
23740@item -msmart
23741@itemx -mno-smart
23742@opindex msmart
23743Generate code for Smart Mode, using only registers numbered 0-7 to allow
23744use of 16-bit instructions. This option is ignored for CK801 where this
23745is the required behavior, and it defaults to on for CK802.
23746For other targets, the default is off.
23747
23748@item -mhigh-registers
23749@itemx -mno-high-registers
23750@opindex mhigh-registers
23751Generate code using the high registers numbered 16-31. This option
23752is not supported on CK801, CK802, or CK803, and is enabled by default
23753for other processors.
23754
23755@item -manchor
23756@itemx -mno-anchor
23757@opindex manchor
23758Generate code using global anchor symbol addresses.
23759
23760@item -mpushpop
23761@itemx -mno-pushpop
23762@opindex mpushpop
23763Generate code using @code{push} and @code{pop} instructions. This option
23764defaults to on.
23765
23766@item -mmultiple-stld
23767@itemx -mstm
23768@itemx -mno-multiple-stld
23769@itemx -mno-stm
23770@opindex mmultiple-stld
23771Generate code using @code{stm} and @code{ldm} instructions. This option
23772isn't supported on CK801 but is enabled by default on other processors.
23773
23774@item -mconstpool
23775@itemx -mno-constpool
23776@opindex mconstpool
23777Create constant pools in the compiler instead of deferring it to the
23778assembler. This option is the default and required for correct code
23779generation on CK801 and CK802, and is optional on other processors.
23780
23781@item -mstack-size
23782@item -mno-stack-size
23783@opindex mstack-size
23784Emit @code{.stack_size} directives for each function in the assembly
23785output. This option defaults to off.
23786
23787@item -mccrt
23788@itemx -mno-ccrt
23789@opindex mccrt
23790Generate code for the C-SKY compiler runtime instead of libgcc. This
23791option defaults to off.
23792
23793@item -mbranch-cost=@var{n}
23794@opindex mbranch-cost=
23795Set the branch costs to roughly @code{n} instructions. The default is 1.
23796
23797@item -msched-prolog
23798@itemx -mno-sched-prolog
23799@opindex msched-prolog
23800Permit scheduling of function prologue and epilogue sequences. Using
23801this option can result in code that is not compliant with the C-SKY V2 ABI
23802prologue requirements and that cannot be debugged or backtraced.
23803It is disabled by default.
23804
23805@item -msim
23806@opindex msim
23807Links the library libsemi.a which is in compatible with simulator. Applicable
23808to ELF compiler only.
23809
23810@end table
23811
23812@node Darwin Options
23813@subsection Darwin Options
23814@cindex Darwin options
23815
23816These options are defined for all architectures running the Darwin operating
23817system.
23818
23819FSF GCC on Darwin does not create ``fat'' object files; it creates
23820an object file for the single architecture that GCC was built to
23821target. Apple's GCC on Darwin does create ``fat'' files if multiple
23822@option{-arch} options are used; it does so by running the compiler or
23823linker multiple times and joining the results together with
23824@file{lipo}.
23825
23826The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
23827@samp{i686}) is determined by the flags that specify the ISA
23828that GCC is targeting, like @option{-mcpu} or @option{-march}. The
23829@option{-force_cpusubtype_ALL} option can be used to override this.
23830
23831The Darwin tools vary in their behavior when presented with an ISA
23832mismatch. The assembler, @file{as}, only permits instructions to
23833be used that are valid for the subtype of the file it is generating,
23834so you cannot put 64-bit instructions in a @samp{ppc750} object file.
23835The linker for shared libraries, @file{/usr/bin/libtool}, fails
23836and prints an error if asked to create a shared library with a less
23837restrictive subtype than its input files (for instance, trying to put
23838a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
23839for executables, @command{ld}, quietly gives the executable the most
23840restrictive subtype of any of its input files.
23841
23842@table @gcctabopt
23843@item -F@var{dir}
23844@opindex F
23845Add the framework directory @var{dir} to the head of the list of
23846directories to be searched for header files. These directories are
23847interleaved with those specified by @option{-I} options and are
23848scanned in a left-to-right order.
23849
23850A framework directory is a directory with frameworks in it. A
23851framework is a directory with a @file{Headers} and/or
23852@file{PrivateHeaders} directory contained directly in it that ends
23853in @file{.framework}. The name of a framework is the name of this
23854directory excluding the @file{.framework}. Headers associated with
23855the framework are found in one of those two directories, with
23856@file{Headers} being searched first. A subframework is a framework
23857directory that is in a framework's @file{Frameworks} directory.
23858Includes of subframework headers can only appear in a header of a
23859framework that contains the subframework, or in a sibling subframework
23860header. Two subframeworks are siblings if they occur in the same
23861framework. A subframework should not have the same name as a
23862framework; a warning is issued if this is violated. Currently a
23863subframework cannot have subframeworks; in the future, the mechanism
23864may be extended to support this. The standard frameworks can be found
23865in @file{/System/Library/Frameworks} and
23866@file{/Library/Frameworks}. An example include looks like
23867@code{#include <Framework/header.h>}, where @file{Framework} denotes
23868the name of the framework and @file{header.h} is found in the
23869@file{PrivateHeaders} or @file{Headers} directory.
23870
23871@item -iframework@var{dir}
23872@opindex iframework
23873Like @option{-F} except the directory is a treated as a system
23874directory. The main difference between this @option{-iframework} and
23875@option{-F} is that with @option{-iframework} the compiler does not
23876warn about constructs contained within header files found via
23877@var{dir}. This option is valid only for the C family of languages.
23878
23879@item -gused
23880@opindex gused
23881Emit debugging information for symbols that are used. For stabs
23882debugging format, this enables @option{-feliminate-unused-debug-symbols}.
23883This is by default ON@.
23884
23885@item -gfull
23886@opindex gfull
23887Emit debugging information for all symbols and types.
23888
23889@item -mmacosx-version-min=@var{version}
23890The earliest version of MacOS X that this executable will run on
23891is @var{version}. Typical values of @var{version} include @code{10.1},
23892@code{10.2}, and @code{10.3.9}.
23893
23894If the compiler was built to use the system's headers by default,
23895then the default for this option is the system version on which the
23896compiler is running, otherwise the default is to make choices that
23897are compatible with as many systems and code bases as possible.
23898
23899@item -mkernel
23900@opindex mkernel
23901Enable kernel development mode. The @option{-mkernel} option sets
23902@option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
23903@option{-fno-exceptions}, @option{-fno-non-call-exceptions},
23904@option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
23905applicable. This mode also sets @option{-mno-altivec},
23906@option{-msoft-float}, @option{-fno-builtin} and
23907@option{-mlong-branch} for PowerPC targets.
23908
23909@item -mone-byte-bool
23910@opindex mone-byte-bool
23911Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
23912By default @code{sizeof(bool)} is @code{4} when compiling for
23913Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
23914option has no effect on x86.
23915
23916@strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
23917to generate code that is not binary compatible with code generated
23918without that switch. Using this switch may require recompiling all
23919other modules in a program, including system libraries. Use this
23920switch to conform to a non-default data model.
23921
23922@item -mfix-and-continue
23923@itemx -ffix-and-continue
23924@itemx -findirect-data
23925@opindex mfix-and-continue
23926@opindex ffix-and-continue
23927@opindex findirect-data
23928Generate code suitable for fast turnaround development, such as to
23929allow GDB to dynamically load @file{.o} files into already-running
23930programs. @option{-findirect-data} and @option{-ffix-and-continue}
23931are provided for backwards compatibility.
23932
23933@item -all_load
23934@opindex all_load
23935Loads all members of static archive libraries.
23936See man ld(1) for more information.
23937
23938@item -arch_errors_fatal
23939@opindex arch_errors_fatal
23940Cause the errors having to do with files that have the wrong architecture
23941to be fatal.
23942
23943@item -bind_at_load
23944@opindex bind_at_load
23945Causes the output file to be marked such that the dynamic linker will
23946bind all undefined references when the file is loaded or launched.
23947
23948@item -bundle
23949@opindex bundle
23950Produce a Mach-o bundle format file.
23951See man ld(1) for more information.
23952
23953@item -bundle_loader @var{executable}
23954@opindex bundle_loader
23955This option specifies the @var{executable} that will load the build
23956output file being linked. See man ld(1) for more information.
23957
23958@item -dynamiclib
23959@opindex dynamiclib
23960When passed this option, GCC produces a dynamic library instead of
23961an executable when linking, using the Darwin @file{libtool} command.
23962
23963@item -force_cpusubtype_ALL
23964@opindex force_cpusubtype_ALL
23965This causes GCC's output file to have the @samp{ALL} subtype, instead of
23966one controlled by the @option{-mcpu} or @option{-march} option.
23967
23968@item -allowable_client @var{client_name}
23969@itemx -client_name
23970@itemx -compatibility_version
23971@itemx -current_version
23972@itemx -dead_strip
23973@itemx -dependency-file
23974@itemx -dylib_file
23975@itemx -dylinker_install_name
23976@itemx -dynamic
23977@itemx -exported_symbols_list
23978@itemx -filelist
23979@need 800
23980@itemx -flat_namespace
23981@itemx -force_flat_namespace
23982@itemx -headerpad_max_install_names
23983@itemx -image_base
23984@itemx -init
23985@itemx -install_name
23986@itemx -keep_private_externs
23987@itemx -multi_module
23988@itemx -multiply_defined
23989@itemx -multiply_defined_unused
23990@need 800
23991@itemx -noall_load
23992@itemx -no_dead_strip_inits_and_terms
23993@itemx -nofixprebinding
23994@itemx -nomultidefs
23995@itemx -noprebind
23996@itemx -noseglinkedit
23997@itemx -pagezero_size
23998@itemx -prebind
23999@itemx -prebind_all_twolevel_modules
24000@itemx -private_bundle
24001@need 800
24002@itemx -read_only_relocs
24003@itemx -sectalign
24004@itemx -sectobjectsymbols
24005@itemx -whyload
24006@itemx -seg1addr
24007@itemx -sectcreate
24008@itemx -sectobjectsymbols
24009@itemx -sectorder
24010@itemx -segaddr
24011@itemx -segs_read_only_addr
24012@need 800
24013@itemx -segs_read_write_addr
24014@itemx -seg_addr_table
24015@itemx -seg_addr_table_filename
24016@itemx -seglinkedit
24017@itemx -segprot
24018@itemx -segs_read_only_addr
24019@itemx -segs_read_write_addr
24020@itemx -single_module
24021@itemx -static
24022@itemx -sub_library
24023@need 800
24024@itemx -sub_umbrella
24025@itemx -twolevel_namespace
24026@itemx -umbrella
24027@itemx -undefined
24028@itemx -unexported_symbols_list
24029@itemx -weak_reference_mismatches
24030@itemx -whatsloaded
24031@opindex allowable_client
24032@opindex client_name
24033@opindex compatibility_version
24034@opindex current_version
24035@opindex dead_strip
24036@opindex dependency-file
24037@opindex dylib_file
24038@opindex dylinker_install_name
24039@opindex dynamic
24040@opindex exported_symbols_list
24041@opindex filelist
24042@opindex flat_namespace
24043@opindex force_flat_namespace
24044@opindex headerpad_max_install_names
24045@opindex image_base
24046@opindex init
24047@opindex install_name
24048@opindex keep_private_externs
24049@opindex multi_module
24050@opindex multiply_defined
24051@opindex multiply_defined_unused
24052@opindex noall_load
24053@opindex no_dead_strip_inits_and_terms
24054@opindex nofixprebinding
24055@opindex nomultidefs
24056@opindex noprebind
24057@opindex noseglinkedit
24058@opindex pagezero_size
24059@opindex prebind
24060@opindex prebind_all_twolevel_modules
24061@opindex private_bundle
24062@opindex read_only_relocs
24063@opindex sectalign
24064@opindex sectobjectsymbols
24065@opindex whyload
24066@opindex seg1addr
24067@opindex sectcreate
24068@opindex sectobjectsymbols
24069@opindex sectorder
24070@opindex segaddr
24071@opindex segs_read_only_addr
24072@opindex segs_read_write_addr
24073@opindex seg_addr_table
24074@opindex seg_addr_table_filename
24075@opindex seglinkedit
24076@opindex segprot
24077@opindex segs_read_only_addr
24078@opindex segs_read_write_addr
24079@opindex single_module
24080@opindex static
24081@opindex sub_library
24082@opindex sub_umbrella
24083@opindex twolevel_namespace
24084@opindex umbrella
24085@opindex undefined
24086@opindex unexported_symbols_list
24087@opindex weak_reference_mismatches
24088@opindex whatsloaded
24089These options are passed to the Darwin linker. The Darwin linker man page
24090describes them in detail.
24091@end table
24092
24093@node DEC Alpha Options
24094@subsection DEC Alpha Options
24095
24096These @samp{-m} options are defined for the DEC Alpha implementations:
24097
24098@table @gcctabopt
24099@item -mno-soft-float
24100@itemx -msoft-float
24101@opindex mno-soft-float
24102@opindex msoft-float
24103Use (do not use) the hardware floating-point instructions for
24104floating-point operations. When @option{-msoft-float} is specified,
24105functions in @file{libgcc.a} are used to perform floating-point
24106operations. Unless they are replaced by routines that emulate the
24107floating-point operations, or compiled in such a way as to call such
24108emulations routines, these routines issue floating-point
24109operations. If you are compiling for an Alpha without floating-point
24110operations, you must ensure that the library is built so as not to call
24111them.
24112
24113Note that Alpha implementations without floating-point operations are
24114required to have floating-point registers.
24115
24116@item -mfp-reg
24117@itemx -mno-fp-regs
24118@opindex mfp-reg
24119@opindex mno-fp-regs
24120Generate code that uses (does not use) the floating-point register set.
24121@option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
24122register set is not used, floating-point operands are passed in integer
24123registers as if they were integers and floating-point results are passed
24124in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
24125so any function with a floating-point argument or return value called by code
24126compiled with @option{-mno-fp-regs} must also be compiled with that
24127option.
24128
24129A typical use of this option is building a kernel that does not use,
24130and hence need not save and restore, any floating-point registers.
24131
24132@item -mieee
24133@opindex mieee
24134The Alpha architecture implements floating-point hardware optimized for
24135maximum performance. It is mostly compliant with the IEEE floating-point
24136standard. However, for full compliance, software assistance is
24137required. This option generates code fully IEEE-compliant code
24138@emph{except} that the @var{inexact-flag} is not maintained (see below).
24139If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
24140defined during compilation. The resulting code is less efficient but is
24141able to correctly support denormalized numbers and exceptional IEEE
24142values such as not-a-number and plus/minus infinity. Other Alpha
24143compilers call this option @option{-ieee_with_no_inexact}.
24144
24145@item -mieee-with-inexact
24146@opindex mieee-with-inexact
24147This is like @option{-mieee} except the generated code also maintains
24148the IEEE @var{inexact-flag}. Turning on this option causes the
24149generated code to implement fully-compliant IEEE math. In addition to
24150@code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
24151macro. On some Alpha implementations the resulting code may execute
24152significantly slower than the code generated by default. Since there is
24153very little code that depends on the @var{inexact-flag}, you should
24154normally not specify this option. Other Alpha compilers call this
24155option @option{-ieee_with_inexact}.
24156
24157@item -mfp-trap-mode=@var{trap-mode}
24158@opindex mfp-trap-mode
24159This option controls what floating-point related traps are enabled.
24160Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
24161The trap mode can be set to one of four values:
24162
24163@table @samp
24164@item n
24165This is the default (normal) setting. The only traps that are enabled
24166are the ones that cannot be disabled in software (e.g., division by zero
24167trap).
24168
24169@item u
24170In addition to the traps enabled by @samp{n}, underflow traps are enabled
24171as well.
24172
24173@item su
24174Like @samp{u}, but the instructions are marked to be safe for software
24175completion (see Alpha architecture manual for details).
24176
24177@item sui
24178Like @samp{su}, but inexact traps are enabled as well.
24179@end table
24180
24181@item -mfp-rounding-mode=@var{rounding-mode}
24182@opindex mfp-rounding-mode
24183Selects the IEEE rounding mode. Other Alpha compilers call this option
24184@option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
24185of:
24186
24187@table @samp
24188@item n
24189Normal IEEE rounding mode. Floating-point numbers are rounded towards
24190the nearest machine number or towards the even machine number in case
24191of a tie.
24192
24193@item m
24194Round towards minus infinity.
24195
24196@item c
24197Chopped rounding mode. Floating-point numbers are rounded towards zero.
24198
24199@item d
24200Dynamic rounding mode. A field in the floating-point control register
24201(@var{fpcr}, see Alpha architecture reference manual) controls the
24202rounding mode in effect. The C library initializes this register for
24203rounding towards plus infinity. Thus, unless your program modifies the
24204@var{fpcr}, @samp{d} corresponds to round towards plus infinity.
24205@end table
24206
24207@item -mtrap-precision=@var{trap-precision}
24208@opindex mtrap-precision
24209In the Alpha architecture, floating-point traps are imprecise. This
24210means without software assistance it is impossible to recover from a
24211floating trap and program execution normally needs to be terminated.
24212GCC can generate code that can assist operating system trap handlers
24213in determining the exact location that caused a floating-point trap.
24214Depending on the requirements of an application, different levels of
24215precisions can be selected:
24216
24217@table @samp
24218@item p
24219Program precision. This option is the default and means a trap handler
24220can only identify which program caused a floating-point exception.
24221
24222@item f
24223Function precision. The trap handler can determine the function that
24224caused a floating-point exception.
24225
24226@item i
24227Instruction precision. The trap handler can determine the exact
24228instruction that caused a floating-point exception.
24229@end table
24230
24231Other Alpha compilers provide the equivalent options called
24232@option{-scope_safe} and @option{-resumption_safe}.
24233
24234@item -mieee-conformant
24235@opindex mieee-conformant
24236This option marks the generated code as IEEE conformant. You must not
24237use this option unless you also specify @option{-mtrap-precision=i} and either
24238@option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
24239is to emit the line @samp{.eflag 48} in the function prologue of the
24240generated assembly file.
24241
24242@item -mbuild-constants
24243@opindex mbuild-constants
24244Normally GCC examines a 32- or 64-bit integer constant to
24245see if it can construct it from smaller constants in two or three
24246instructions. If it cannot, it outputs the constant as a literal and
24247generates code to load it from the data segment at run time.
24248
24249Use this option to require GCC to construct @emph{all} integer constants
24250using code, even if it takes more instructions (the maximum is six).
24251
24252You typically use this option to build a shared library dynamic
24253loader. Itself a shared library, it must relocate itself in memory
24254before it can find the variables and constants in its own data segment.
24255
24256@item -mbwx
24257@itemx -mno-bwx
24258@itemx -mcix
24259@itemx -mno-cix
24260@itemx -mfix
24261@itemx -mno-fix
24262@itemx -mmax
24263@itemx -mno-max
24264@opindex mbwx
24265@opindex mno-bwx
24266@opindex mcix
24267@opindex mno-cix
24268@opindex mfix
24269@opindex mno-fix
24270@opindex mmax
24271@opindex mno-max
24272Indicate whether GCC should generate code to use the optional BWX,
24273CIX, FIX and MAX instruction sets. The default is to use the instruction
24274sets supported by the CPU type specified via @option{-mcpu=} option or that
24275of the CPU on which GCC was built if none is specified.
24276
24277@item -mfloat-vax
24278@itemx -mfloat-ieee
24279@opindex mfloat-vax
24280@opindex mfloat-ieee
24281Generate code that uses (does not use) VAX F and G floating-point
24282arithmetic instead of IEEE single and double precision.
24283
24284@item -mexplicit-relocs
24285@itemx -mno-explicit-relocs
24286@opindex mexplicit-relocs
24287@opindex mno-explicit-relocs
24288Older Alpha assemblers provided no way to generate symbol relocations
24289except via assembler macros. Use of these macros does not allow
24290optimal instruction scheduling. GNU binutils as of version 2.12
24291supports a new syntax that allows the compiler to explicitly mark
24292which relocations should apply to which instructions. This option
24293is mostly useful for debugging, as GCC detects the capabilities of
24294the assembler when it is built and sets the default accordingly.
24295
24296@item -msmall-data
24297@itemx -mlarge-data
24298@opindex msmall-data
24299@opindex mlarge-data
24300When @option{-mexplicit-relocs} is in effect, static data is
24301accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
24302is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
24303(the @code{.sdata} and @code{.sbss} sections) and are accessed via
2430416-bit relocations off of the @code{$gp} register. This limits the
24305size of the small data area to 64KB, but allows the variables to be
24306directly accessed via a single instruction.
24307
24308The default is @option{-mlarge-data}. With this option the data area
24309is limited to just below 2GB@. Programs that require more than 2GB of
24310data must use @code{malloc} or @code{mmap} to allocate the data in the
24311heap instead of in the program's data segment.
24312
24313When generating code for shared libraries, @option{-fpic} implies
24314@option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
24315
24316@item -msmall-text
24317@itemx -mlarge-text
24318@opindex msmall-text
24319@opindex mlarge-text
24320When @option{-msmall-text} is used, the compiler assumes that the
24321code of the entire program (or shared library) fits in 4MB, and is
24322thus reachable with a branch instruction. When @option{-msmall-data}
24323is used, the compiler can assume that all local symbols share the
24324same @code{$gp} value, and thus reduce the number of instructions
24325required for a function call from 4 to 1.
24326
24327The default is @option{-mlarge-text}.
24328
24329@item -mcpu=@var{cpu_type}
24330@opindex mcpu
24331Set the instruction set and instruction scheduling parameters for
24332machine type @var{cpu_type}. You can specify either the @samp{EV}
24333style name or the corresponding chip number. GCC supports scheduling
24334parameters for the EV4, EV5 and EV6 family of processors and
24335chooses the default values for the instruction set from the processor
24336you specify. If you do not specify a processor type, GCC defaults
24337to the processor on which the compiler was built.
24338
24339Supported values for @var{cpu_type} are
24340
24341@table @samp
24342@item ev4
24343@itemx ev45
24344@itemx 21064
24345Schedules as an EV4 and has no instruction set extensions.
24346
24347@item ev5
24348@itemx 21164
24349Schedules as an EV5 and has no instruction set extensions.
24350
24351@item ev56
24352@itemx 21164a
24353Schedules as an EV5 and supports the BWX extension.
24354
24355@item pca56
24356@itemx 21164pc
24357@itemx 21164PC
24358Schedules as an EV5 and supports the BWX and MAX extensions.
24359
24360@item ev6
24361@itemx 21264
24362Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
24363
24364@item ev67
24365@itemx 21264a
24366Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
24367@end table
24368
24369Native toolchains also support the value @samp{native},
24370which selects the best architecture option for the host processor.
24371@option{-mcpu=native} has no effect if GCC does not recognize
24372the processor.
24373
24374@item -mtune=@var{cpu_type}
24375@opindex mtune
24376Set only the instruction scheduling parameters for machine type
24377@var{cpu_type}. The instruction set is not changed.
24378
24379Native toolchains also support the value @samp{native},
24380which selects the best architecture option for the host processor.
24381@option{-mtune=native} has no effect if GCC does not recognize
24382the processor.
24383
24384@item -mmemory-latency=@var{time}
24385@opindex mmemory-latency
24386Sets the latency the scheduler should assume for typical memory
24387references as seen by the application. This number is highly
24388dependent on the memory access patterns used by the application
24389and the size of the external cache on the machine.
24390
24391Valid options for @var{time} are
24392
24393@table @samp
24394@item @var{number}
24395A decimal number representing clock cycles.
24396
24397@item L1
24398@itemx L2
24399@itemx L3
24400@itemx main
24401The compiler contains estimates of the number of clock cycles for
24402``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
24403(also called Dcache, Scache, and Bcache), as well as to main memory.
24404Note that L3 is only valid for EV5.
24405
24406@end table
24407@end table
24408
24409@node eBPF Options
24410@subsection eBPF Options
24411@cindex eBPF Options
24412
24413@table @gcctabopt
24414@item -mframe-limit=@var{bytes}
24415This specifies the hard limit for frame sizes, in bytes. Currently,
24416the value that can be specified should be less than or equal to
24417@samp{32767}. Defaults to whatever limit is imposed by the version of
24418the Linux kernel targeted.
24419
24420@item -mkernel=@var{version}
24421@opindex mkernel
24422This specifies the minimum version of the kernel that will run the
24423compiled program. GCC uses this version to determine which
24424instructions to use, what kernel helpers to allow, etc. Currently,
24425@var{version} can be one of @samp{4.0}, @samp{4.1}, @samp{4.2},
24426@samp{4.3}, @samp{4.4}, @samp{4.5}, @samp{4.6}, @samp{4.7},
24427@samp{4.8}, @samp{4.9}, @samp{4.10}, @samp{4.11}, @samp{4.12},
24428@samp{4.13}, @samp{4.14}, @samp{4.15}, @samp{4.16}, @samp{4.17},
24429@samp{4.18}, @samp{4.19}, @samp{4.20}, @samp{5.0}, @samp{5.1},
24430@samp{5.2}, @samp{latest} and @samp{native}.
24431
24432@item -mbig-endian
24433@opindex mbig-endian
24434Generate code for a big-endian target.
24435
24436@item -mlittle-endian
24437@opindex mlittle-endian
24438Generate code for a little-endian target. This is the default.
24439
24440@item -mjmpext
24441@opindex mjmpext
24442Enable generation of extra conditional-branch instructions.
24443Enabled for CPU v2 and above.
24444
24445@item -mjmp32
24446@opindex mjmp32
24447Enable 32-bit jump instructions. Enabled for CPU v3 and above.
24448
24449@item -malu32
24450@opindex malu32
24451Enable 32-bit ALU instructions. Enabled for CPU v3 and above.
24452
24453@item -mcpu=@var{version}
24454@opindex mcpu
24455This specifies which version of the eBPF ISA to target. Newer versions
24456may not be supported by all kernels. The default is @samp{v3}.
24457
24458Supported values for @var{version} are:
24459
24460@table @samp
24461@item v1
24462The first stable eBPF ISA with no special features or extensions.
24463
24464@item v2
24465Supports the jump extensions, as in @option{-mjmpext}.
24466
24467@item v3
24468All features of v2, plus:
24469@itemize @minus
24470@item 32-bit jump operations, as in @option{-mjmp32}
24471@item 32-bit ALU operations, as in @option{-malu32}
24472@end itemize
24473
24474@end table
24475
24476@item -mco-re
24477@opindex mco-re
24478Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
24479is implied by @option{-gbtf}.
24480
24481@item -mno-co-re
24482@opindex mno-co-re
24483Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
24484support is enabled by default when generating BTF debug information for
24485the BPF target.
24486
24487@item -mxbpf
24488Generate code for an expanded version of BPF, which relaxes some of
24489the restrictions imposed by the BPF architecture:
24490@itemize @minus
24491@item Save and restore callee-saved registers at function entry and
24492exit, respectively.
24493@end itemize
24494@end table
24495
24496@node FR30 Options
24497@subsection FR30 Options
24498@cindex FR30 Options
24499
24500These options are defined specifically for the FR30 port.
24501
24502@table @gcctabopt
24503
24504@item -msmall-model
24505@opindex msmall-model
24506Use the small address space model. This can produce smaller code, but
24507it does assume that all symbolic values and addresses fit into a
2450820-bit range.
24509
24510@item -mno-lsim
24511@opindex mno-lsim
24512Assume that runtime support has been provided and so there is no need
24513to include the simulator library (@file{libsim.a}) on the linker
24514command line.
24515
24516@end table
24517
24518@node FT32 Options
24519@subsection FT32 Options
24520@cindex FT32 Options
24521
24522These options are defined specifically for the FT32 port.
24523
24524@table @gcctabopt
24525
24526@item -msim
24527@opindex msim
24528Specifies that the program will be run on the simulator. This causes
24529an alternate runtime startup and library to be linked.
24530You must not use this option when generating programs that will run on
24531real hardware; you must provide your own runtime library for whatever
24532I/O functions are needed.
24533
24534@item -mlra
24535@opindex mlra
24536Enable Local Register Allocation. This is still experimental for FT32,
24537so by default the compiler uses standard reload.
24538
24539@item -mnodiv
24540@opindex mnodiv
24541Do not use div and mod instructions.
24542
24543@item -mft32b
24544@opindex mft32b
24545Enable use of the extended instructions of the FT32B processor.
24546
24547@item -mcompress
24548@opindex mcompress
24549Compress all code using the Ft32B code compression scheme.
24550
24551@item -mnopm
24552@opindex mnopm
24553Do not generate code that reads program memory.
24554
24555@end table
24556
24557@node FRV Options
24558@subsection FRV Options
24559@cindex FRV Options
24560
24561@table @gcctabopt
24562@item -mgpr-32
24563@opindex mgpr-32
24564
24565Only use the first 32 general-purpose registers.
24566
24567@item -mgpr-64
24568@opindex mgpr-64
24569
24570Use all 64 general-purpose registers.
24571
24572@item -mfpr-32
24573@opindex mfpr-32
24574
24575Use only the first 32 floating-point registers.
24576
24577@item -mfpr-64
24578@opindex mfpr-64
24579
24580Use all 64 floating-point registers.
24581
24582@item -mhard-float
24583@opindex mhard-float
24584
24585Use hardware instructions for floating-point operations.
24586
24587@item -msoft-float
24588@opindex msoft-float
24589
24590Use library routines for floating-point operations.
24591
24592@item -malloc-cc
24593@opindex malloc-cc
24594
24595Dynamically allocate condition code registers.
24596
24597@item -mfixed-cc
24598@opindex mfixed-cc
24599
24600Do not try to dynamically allocate condition code registers, only
24601use @code{icc0} and @code{fcc0}.
24602
24603@item -mdword
24604@opindex mdword
24605
24606Change ABI to use double word insns.
24607
24608@item -mno-dword
24609@opindex mno-dword
24610@opindex mdword
24611
24612Do not use double word instructions.
24613
24614@item -mdouble
24615@opindex mdouble
24616
24617Use floating-point double instructions.
24618
24619@item -mno-double
24620@opindex mno-double
24621
24622Do not use floating-point double instructions.
24623
24624@item -mmedia
24625@opindex mmedia
24626
24627Use media instructions.
24628
24629@item -mno-media
24630@opindex mno-media
24631
24632Do not use media instructions.
24633
24634@item -mmuladd
24635@opindex mmuladd
24636
24637Use multiply and add/subtract instructions.
24638
24639@item -mno-muladd
24640@opindex mno-muladd
24641
24642Do not use multiply and add/subtract instructions.
24643
24644@item -mfdpic
24645@opindex mfdpic
24646
24647Select the FDPIC ABI, which uses function descriptors to represent
24648pointers to functions. Without any PIC/PIE-related options, it
24649implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
24650assumes GOT entries and small data are within a 12-bit range from the
24651GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
24652are computed with 32 bits.
24653With a @samp{bfin-elf} target, this option implies @option{-msim}.
24654
24655@item -minline-plt
24656@opindex minline-plt
24657
24658Enable inlining of PLT entries in function calls to functions that are
24659not known to bind locally. It has no effect without @option{-mfdpic}.
24660It's enabled by default if optimizing for speed and compiling for
24661shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
24662optimization option such as @option{-O3} or above is present in the
24663command line.
24664
24665@item -mTLS
24666@opindex mTLS
24667
24668Assume a large TLS segment when generating thread-local code.
24669
24670@item -mtls
24671@opindex mtls
24672
24673Do not assume a large TLS segment when generating thread-local code.
24674
24675@item -mgprel-ro
24676@opindex mgprel-ro
24677
24678Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
24679that is known to be in read-only sections. It's enabled by default,
24680except for @option{-fpic} or @option{-fpie}: even though it may help
24681make the global offset table smaller, it trades 1 instruction for 4.
24682With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
24683one of which may be shared by multiple symbols, and it avoids the need
24684for a GOT entry for the referenced symbol, so it's more likely to be a
24685win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
24686
24687@item -multilib-library-pic
24688@opindex multilib-library-pic
24689
24690Link with the (library, not FD) pic libraries. It's implied by
24691@option{-mlibrary-pic}, as well as by @option{-fPIC} and
24692@option{-fpic} without @option{-mfdpic}. You should never have to use
24693it explicitly.
24694
24695@item -mlinked-fp
24696@opindex mlinked-fp
24697
24698Follow the EABI requirement of always creating a frame pointer whenever
24699a stack frame is allocated. This option is enabled by default and can
24700be disabled with @option{-mno-linked-fp}.
24701
24702@item -mlong-calls
24703@opindex mlong-calls
24704
24705Use indirect addressing to call functions outside the current
24706compilation unit. This allows the functions to be placed anywhere
24707within the 32-bit address space.
24708
24709@item -malign-labels
24710@opindex malign-labels
24711
24712Try to align labels to an 8-byte boundary by inserting NOPs into the
24713previous packet. This option only has an effect when VLIW packing
24714is enabled. It doesn't create new packets; it merely adds NOPs to
24715existing ones.
24716
24717@item -mlibrary-pic
24718@opindex mlibrary-pic
24719
24720Generate position-independent EABI code.
24721
24722@item -macc-4
24723@opindex macc-4
24724
24725Use only the first four media accumulator registers.
24726
24727@item -macc-8
24728@opindex macc-8
24729
24730Use all eight media accumulator registers.
24731
24732@item -mpack
24733@opindex mpack
24734
24735Pack VLIW instructions.
24736
24737@item -mno-pack
24738@opindex mno-pack
24739
24740Do not pack VLIW instructions.
24741
24742@item -mno-eflags
24743@opindex mno-eflags
24744
24745Do not mark ABI switches in e_flags.
24746
24747@item -mcond-move
24748@opindex mcond-move
24749
24750Enable the use of conditional-move instructions (default).
24751
24752This switch is mainly for debugging the compiler and will likely be removed
24753in a future version.
24754
24755@item -mno-cond-move
24756@opindex mno-cond-move
24757
24758Disable the use of conditional-move instructions.
24759
24760This switch is mainly for debugging the compiler and will likely be removed
24761in a future version.
24762
24763@item -mscc
24764@opindex mscc
24765
24766Enable the use of conditional set instructions (default).
24767
24768This switch is mainly for debugging the compiler and will likely be removed
24769in a future version.
24770
24771@item -mno-scc
24772@opindex mno-scc
24773
24774Disable the use of conditional set instructions.
24775
24776This switch is mainly for debugging the compiler and will likely be removed
24777in a future version.
24778
24779@item -mcond-exec
24780@opindex mcond-exec
24781
24782Enable the use of conditional execution (default).
24783
24784This switch is mainly for debugging the compiler and will likely be removed
24785in a future version.
24786
24787@item -mno-cond-exec
24788@opindex mno-cond-exec
24789
24790Disable the use of conditional execution.
24791
24792This switch is mainly for debugging the compiler and will likely be removed
24793in a future version.
24794
24795@item -mvliw-branch
24796@opindex mvliw-branch
24797
24798Run a pass to pack branches into VLIW instructions (default).
24799
24800This switch is mainly for debugging the compiler and will likely be removed
24801in a future version.
24802
24803@item -mno-vliw-branch
24804@opindex mno-vliw-branch
24805
24806Do not run a pass to pack branches into VLIW instructions.
24807
24808This switch is mainly for debugging the compiler and will likely be removed
24809in a future version.
24810
24811@item -mmulti-cond-exec
24812@opindex mmulti-cond-exec
24813
24814Enable optimization of @code{&&} and @code{||} in conditional execution
24815(default).
24816
24817This switch is mainly for debugging the compiler and will likely be removed
24818in a future version.
24819
24820@item -mno-multi-cond-exec
24821@opindex mno-multi-cond-exec
24822
24823Disable optimization of @code{&&} and @code{||} in conditional execution.
24824
24825This switch is mainly for debugging the compiler and will likely be removed
24826in a future version.
24827
24828@item -mnested-cond-exec
24829@opindex mnested-cond-exec
24830
24831Enable nested conditional execution optimizations (default).
24832
24833This switch is mainly for debugging the compiler and will likely be removed
24834in a future version.
24835
24836@item -mno-nested-cond-exec
24837@opindex mno-nested-cond-exec
24838
24839Disable nested conditional execution optimizations.
24840
24841This switch is mainly for debugging the compiler and will likely be removed
24842in a future version.
24843
24844@item -moptimize-membar
24845@opindex moptimize-membar
24846
24847This switch removes redundant @code{membar} instructions from the
24848compiler-generated code. It is enabled by default.
24849
24850@item -mno-optimize-membar
24851@opindex mno-optimize-membar
24852@opindex moptimize-membar
24853
24854This switch disables the automatic removal of redundant @code{membar}
24855instructions from the generated code.
24856
24857@item -mtomcat-stats
24858@opindex mtomcat-stats
24859
24860Cause gas to print out tomcat statistics.
24861
24862@item -mcpu=@var{cpu}
24863@opindex mcpu
24864
24865Select the processor type for which to generate code. Possible values are
24866@samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
24867@samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
24868
24869@end table
24870
24871@node GNU/Linux Options
24872@subsection GNU/Linux Options
24873
24874These @samp{-m} options are defined for GNU/Linux targets:
24875
24876@table @gcctabopt
24877@item -mglibc
24878@opindex mglibc
24879Use the GNU C library. This is the default except
24880on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
24881@samp{*-*-linux-*android*} targets.
24882
24883@item -muclibc
24884@opindex muclibc
24885Use uClibc C library. This is the default on
24886@samp{*-*-linux-*uclibc*} targets.
24887
24888@item -mmusl
24889@opindex mmusl
24890Use the musl C library. This is the default on
24891@samp{*-*-linux-*musl*} targets.
24892
24893@item -mbionic
24894@opindex mbionic
24895Use Bionic C library. This is the default on
24896@samp{*-*-linux-*android*} targets.
24897
24898@item -mandroid
24899@opindex mandroid
24900Compile code compatible with Android platform. This is the default on
24901@samp{*-*-linux-*android*} targets.
24902
24903When compiling, this option enables @option{-mbionic}, @option{-fPIC},
24904@option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
24905this option makes the GCC driver pass Android-specific options to the linker.
24906Finally, this option causes the preprocessor macro @code{__ANDROID__}
24907to be defined.
24908
24909@item -tno-android-cc
24910@opindex tno-android-cc
24911Disable compilation effects of @option{-mandroid}, i.e., do not enable
24912@option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
24913@option{-fno-rtti} by default.
24914
24915@item -tno-android-ld
24916@opindex tno-android-ld
24917Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
24918linking options to the linker.
24919
24920@end table
24921
24922@node H8/300 Options
24923@subsection H8/300 Options
24924
24925These @samp{-m} options are defined for the H8/300 implementations:
24926
24927@table @gcctabopt
24928@item -mrelax
24929@opindex mrelax
24930Shorten some address references at link time, when possible; uses the
24931linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
24932ld, Using ld}, for a fuller description.
24933
24934@item -mh
24935@opindex mh
24936Generate code for the H8/300H@.
24937
24938@item -ms
24939@opindex ms
24940Generate code for the H8S@.
24941
24942@item -mn
24943@opindex mn
24944Generate code for the H8S and H8/300H in the normal mode. This switch
24945must be used either with @option{-mh} or @option{-ms}.
24946
24947@item -ms2600
24948@opindex ms2600
24949Generate code for the H8S/2600. This switch must be used with @option{-ms}.
24950
24951@item -mexr
24952@opindex mexr
24953Extended registers are stored on stack before execution of function
24954with monitor attribute. Default option is @option{-mexr}.
24955This option is valid only for H8S targets.
24956
24957@item -mno-exr
24958@opindex mno-exr
24959@opindex mexr
24960Extended registers are not stored on stack before execution of function
24961with monitor attribute. Default option is @option{-mno-exr}.
24962This option is valid only for H8S targets.
24963
24964@item -mint32
24965@opindex mint32
24966Make @code{int} data 32 bits by default.
24967
24968@item -malign-300
24969@opindex malign-300
24970On the H8/300H and H8S, use the same alignment rules as for the H8/300.
24971The default for the H8/300H and H8S is to align longs and floats on
249724-byte boundaries.
24973@option{-malign-300} causes them to be aligned on 2-byte boundaries.
24974This option has no effect on the H8/300.
24975@end table
24976
24977@node HPPA Options
24978@subsection HPPA Options
24979@cindex HPPA Options
24980
24981These @samp{-m} options are defined for the HPPA family of computers:
24982
24983@table @gcctabopt
24984@item -march=@var{architecture-type}
24985@opindex march
24986Generate code for the specified architecture. The choices for
24987@var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
249881.1, and @samp{2.0} for PA 2.0 processors. Refer to
24989@file{/usr/lib/sched.models} on an HP-UX system to determine the proper
24990architecture option for your machine. Code compiled for lower numbered
24991architectures runs on higher numbered architectures, but not the
24992other way around.
24993
24994@item -mpa-risc-1-0
24995@itemx -mpa-risc-1-1
24996@itemx -mpa-risc-2-0
24997@opindex mpa-risc-1-0
24998@opindex mpa-risc-1-1
24999@opindex mpa-risc-2-0
25000Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
25001
cf467fb9
JDA
25002@item -matomic-libcalls
25003@opindex matomic-libcalls
25004@opindex mno-atomic-libcalls
25005Generate libcalls for atomic loads and stores when sync libcalls are disabled.
25006This option is enabled by default. It only affects the generation of
25007atomic libcalls by the HPPA backend.
25008
25009Both the sync and @file{libatomic} libcall implementations use locking.
25010As a result, processor stores are not atomic with respect to other
25011atomic operations. Processor loads up to DImode are atomic with
25012respect to other atomic operations provided they are implemented as
25013a single access.
25014
25015The PA-RISC architecture does not support any atomic operations in
25016hardware except for the @code{ldcw} instruction. Thus, all atomic
25017support is implemented using sync and atomic libcalls. Sync libcall
25018support is in @file{libgcc.a}. Atomic libcall support is in
25019@file{libatomic}.
25020
25021This option generates @code{__atomic_exchange} calls for atomic stores.
25022It also provides special handling for atomic DImode accesses on 32-bit
25023targets.
25024
25025@item -mbig-switch
25026@opindex mbig-switch
25027Does nothing. Preserved for backward compatibility.
25028
d77de738
ML
25029@item -mcaller-copies
25030@opindex mcaller-copies
25031The caller copies function arguments passed by hidden reference. This
25032option should be used with care as it is not compatible with the default
2503332-bit runtime. However, only aggregates larger than eight bytes are
25034passed by hidden reference and the option provides better compatibility
25035with OpenMP.
25036
cf467fb9
JDA
25037@item -mcoherent-ldcw
25038@opindex mcoherent-ldcw
25039Use ldcw/ldcd coherent cache-control hint.
d77de738
ML
25040
25041@item -mdisable-fpregs
25042@opindex mdisable-fpregs
cf467fb9 25043Disable floating-point registers. Equivalent to @code{-msoft-float}.
d77de738
ML
25044
25045@item -mdisable-indexing
25046@opindex mdisable-indexing
25047Prevent the compiler from using indexing address modes. This avoids some
25048rather obscure problems when compiling MIG generated code under MACH@.
25049
d77de738
ML
25050@item -mfast-indirect-calls
25051@opindex mfast-indirect-calls
25052Generate code that assumes calls never cross space boundaries. This
25053allows GCC to emit code that performs faster indirect calls.
25054
25055This option does not work in the presence of shared libraries or nested
25056functions.
25057
25058@item -mfixed-range=@var{register-range}
25059@opindex mfixed-range
25060Generate code treating the given register range as fixed registers.
25061A fixed register is one that the register allocator cannot use. This is
25062useful when compiling kernel code. A register range is specified as
25063two registers separated by a dash. Multiple register ranges can be
25064specified separated by a comma.
25065
d77de738
ML
25066@item -mgas
25067@opindex mgas
25068Enable the use of assembler directives only GAS understands.
25069
d77de738
ML
25070@item -mgnu-ld
25071@opindex mgnu-ld
25072Use options specific to GNU @command{ld}.
25073This passes @option{-shared} to @command{ld} when
25074building a shared library. It is the default when GCC is configured,
25075explicitly or implicitly, with the GNU linker. This option does not
25076affect which @command{ld} is called; it only changes what parameters
25077are passed to that @command{ld}.
25078The @command{ld} that is called is determined by the
25079@option{--with-ld} configure option, GCC's program search path, and
25080finally by the user's @env{PATH}. The linker used by GCC can be printed
25081using @samp{which `gcc -print-prog-name=ld`}. This option is only available
25082on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25083
25084@item -mhp-ld
25085@opindex mhp-ld
25086Use options specific to HP @command{ld}.
25087This passes @option{-b} to @command{ld} when building
25088a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
25089links. It is the default when GCC is configured, explicitly or
25090implicitly, with the HP linker. This option does not affect
25091which @command{ld} is called; it only changes what parameters are passed to that
25092@command{ld}.
25093The @command{ld} that is called is determined by the @option{--with-ld}
25094configure option, GCC's program search path, and finally by the user's
25095@env{PATH}. The linker used by GCC can be printed using @samp{which
25096`gcc -print-prog-name=ld`}. This option is only available on the 64-bit
25097HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25098
cf467fb9
JDA
25099@item -mlinker-opt
25100@opindex mlinker-opt
25101Enable the optimization pass in the HP-UX linker. Note this makes symbolic
25102debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
25103linkers in which they give bogus error messages when linking some programs.
25104
d77de738
ML
25105@item -mlong-calls
25106@opindex mno-long-calls
25107@opindex mlong-calls
25108Generate code that uses long call sequences. This ensures that a call
25109is always able to reach linker generated stubs. The default is to generate
25110long calls only when the distance from the call site to the beginning
25111of the function or translation unit, as the case may be, exceeds a
25112predefined limit set by the branch type being used. The limits for
25113normal calls are 7,600,000 and 240,000 bytes, respectively for the
25114PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
25115240,000 bytes.
25116
25117Distances are measured from the beginning of functions when using the
25118@option{-ffunction-sections} option, or when using the @option{-mgas}
25119and @option{-mno-portable-runtime} options together under HP-UX with
25120the SOM linker.
25121
25122It is normally not desirable to use this option as it degrades
25123performance. However, it may be useful in large applications,
25124particularly when partial linking is used to build the application.
25125
25126The types of long calls used depends on the capabilities of the
25127assembler and linker, and the type of code being generated. The
25128impact on systems that support long absolute calls, and long pic
25129symbol-difference or pc-relative calls should be relatively small.
25130However, an indirect call is used on 32-bit ELF systems in pic code
25131and it is quite long.
25132
cf467fb9
JDA
25133@item -mlong-load-store
25134@opindex mlong-load-store
25135Generate 3-instruction load and store sequences as sometimes required by
25136the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
25137the HP compilers.
25138
25139@item -mjump-in-delay
25140@opindex mjump-in-delay
25141This option is ignored and provided for compatibility purposes only.
25142
25143@item -mno-space-regs
25144@opindex mno-space-regs
25145@opindex mspace-regs
25146Generate code that assumes the target has no space registers. This allows
25147GCC to generate faster indirect calls and use unscaled index address modes.
25148
25149Such code is suitable for level 0 PA systems and kernels.
25150
25151@item -mordered
25152@opindex mordered
25153Assume memory references are ordered and barriers are not needed.
25154
25155@item -mportable-runtime
25156@opindex mportable-runtime
25157Use the portable calling conventions proposed by HP for ELF systems.
25158
25159@item -mschedule=@var{cpu-type}
25160@opindex mschedule
25161Schedule code according to the constraints for the machine type
25162@var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
25163@samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
25164to @file{/usr/lib/sched.models} on an HP-UX system to determine the
25165proper scheduling option for your machine. The default scheduling is
25166@samp{8000}.
25167
25168@item -msio
25169@opindex msio
25170Generate the predefine, @code{_SIO}, for server IO@. The default is
25171@option{-mwsio}. This generates the predefines, @code{__hp9000s700},
25172@code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
25173options are available under HP-UX and HI-UX@.
25174
25175@item -msoft-float
25176@opindex msoft-float
25177Generate output containing library calls for floating point.
25178@strong{Warning:} the requisite libraries are not available for all HPPA
25179targets. Normally the facilities of the machine's usual C compiler are
25180used, but this cannot be done directly in cross-compilation. You must make
25181your own arrangements to provide suitable library functions for
25182cross-compilation.
25183
25184@option{-msoft-float} changes the calling convention in the output file;
25185therefore, it is only useful if you compile @emph{all} of a program with
25186this option. In particular, you need to compile @file{libgcc.a}, the
25187library that comes with GCC, with @option{-msoft-float} in order for
25188this to work.
25189
25190@item -msoft-mult
25191@opindex msoft-mult
25192Use software integer multiplication.
25193
25194This disables the use of the @code{xmpyu} instruction.
25195
d77de738
ML
25196@item -munix=@var{unix-std}
25197@opindex march
25198Generate compiler predefines and select a startfile for the specified
25199UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
25200and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
25201is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
2520211.11 and later. The default values are @samp{93} for HP-UX 10.00,
25203@samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
25204and later.
25205
25206@option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
25207@option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
25208and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
25209@option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
25210@code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
25211@code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
25212
25213It is @emph{important} to note that this option changes the interfaces
25214for various library routines. It also affects the operational behavior
25215of the C library. Thus, @emph{extreme} care is needed in using this
25216option.
25217
25218Library code that is intended to operate with more than one UNIX
25219standard must test, set and restore the variable @code{__xpg4_extended_mask}
25220as appropriate. Most GNU software doesn't provide this capability.
25221
25222@item -nolibdld
25223@opindex nolibdld
25224Suppress the generation of link options to search libdld.sl when the
25225@option{-static} option is specified on HP-UX 10 and later.
25226
25227@item -static
25228@opindex static
25229The HP-UX implementation of setlocale in libc has a dependency on
25230libdld.sl. There isn't an archive version of libdld.sl. Thus,
25231when the @option{-static} option is specified, special link options
25232are needed to resolve this dependency.
25233
25234On HP-UX 10 and later, the GCC driver adds the necessary options to
25235link with libdld.sl when the @option{-static} option is specified.
25236This causes the resulting binary to be dynamic. On the 64-bit port,
25237the linkers generate dynamic binaries by default in any case. The
25238@option{-nolibdld} option can be used to prevent the GCC driver from
25239adding these link options.
25240
25241@item -threads
25242@opindex threads
25243Add support for multithreading with the @dfn{dce thread} library
25244under HP-UX@. This option sets flags for both the preprocessor and
25245linker.
25246@end table
25247
25248@node IA-64 Options
25249@subsection IA-64 Options
25250@cindex IA-64 Options
25251
25252These are the @samp{-m} options defined for the Intel IA-64 architecture.
25253
25254@table @gcctabopt
25255@item -mbig-endian
25256@opindex mbig-endian
25257Generate code for a big-endian target. This is the default for HP-UX@.
25258
25259@item -mlittle-endian
25260@opindex mlittle-endian
25261Generate code for a little-endian target. This is the default for AIX5
25262and GNU/Linux.
25263
25264@item -mgnu-as
25265@itemx -mno-gnu-as
25266@opindex mgnu-as
25267@opindex mno-gnu-as
25268Generate (or don't) code for the GNU assembler. This is the default.
25269@c Also, this is the default if the configure option @option{--with-gnu-as}
25270@c is used.
25271
25272@item -mgnu-ld
25273@itemx -mno-gnu-ld
25274@opindex mgnu-ld
25275@opindex mno-gnu-ld
25276Generate (or don't) code for the GNU linker. This is the default.
25277@c Also, this is the default if the configure option @option{--with-gnu-ld}
25278@c is used.
25279
25280@item -mno-pic
25281@opindex mno-pic
25282Generate code that does not use a global pointer register. The result
25283is not position independent code, and violates the IA-64 ABI@.
25284
25285@item -mvolatile-asm-stop
25286@itemx -mno-volatile-asm-stop
25287@opindex mvolatile-asm-stop
25288@opindex mno-volatile-asm-stop
25289Generate (or don't) a stop bit immediately before and after volatile asm
25290statements.
25291
25292@item -mregister-names
25293@itemx -mno-register-names
25294@opindex mregister-names
25295@opindex mno-register-names
25296Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
25297the stacked registers. This may make assembler output more readable.
25298
25299@item -mno-sdata
25300@itemx -msdata
25301@opindex mno-sdata
25302@opindex msdata
25303Disable (or enable) optimizations that use the small data section. This may
25304be useful for working around optimizer bugs.
25305
25306@item -mconstant-gp
25307@opindex mconstant-gp
25308Generate code that uses a single constant global pointer value. This is
25309useful when compiling kernel code.
25310
25311@item -mauto-pic
25312@opindex mauto-pic
25313Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
25314This is useful when compiling firmware code.
25315
25316@item -minline-float-divide-min-latency
25317@opindex minline-float-divide-min-latency
25318Generate code for inline divides of floating-point values
25319using the minimum latency algorithm.
25320
25321@item -minline-float-divide-max-throughput
25322@opindex minline-float-divide-max-throughput
25323Generate code for inline divides of floating-point values
25324using the maximum throughput algorithm.
25325
25326@item -mno-inline-float-divide
25327@opindex mno-inline-float-divide
25328Do not generate inline code for divides of floating-point values.
25329
25330@item -minline-int-divide-min-latency
25331@opindex minline-int-divide-min-latency
25332Generate code for inline divides of integer values
25333using the minimum latency algorithm.
25334
25335@item -minline-int-divide-max-throughput
25336@opindex minline-int-divide-max-throughput
25337Generate code for inline divides of integer values
25338using the maximum throughput algorithm.
25339
25340@item -mno-inline-int-divide
25341@opindex mno-inline-int-divide
25342@opindex minline-int-divide
25343Do not generate inline code for divides of integer values.
25344
25345@item -minline-sqrt-min-latency
25346@opindex minline-sqrt-min-latency
25347Generate code for inline square roots
25348using the minimum latency algorithm.
25349
25350@item -minline-sqrt-max-throughput
25351@opindex minline-sqrt-max-throughput
25352Generate code for inline square roots
25353using the maximum throughput algorithm.
25354
25355@item -mno-inline-sqrt
25356@opindex mno-inline-sqrt
25357Do not generate inline code for @code{sqrt}.
25358
25359@item -mfused-madd
25360@itemx -mno-fused-madd
25361@opindex mfused-madd
25362@opindex mno-fused-madd
25363Do (don't) generate code that uses the fused multiply/add or multiply/subtract
25364instructions. The default is to use these instructions.
25365
25366@item -mno-dwarf2-asm
25367@itemx -mdwarf2-asm
25368@opindex mno-dwarf2-asm
25369@opindex mdwarf2-asm
25370Don't (or do) generate assembler code for the DWARF line number debugging
25371info. This may be useful when not using the GNU assembler.
25372
25373@item -mearly-stop-bits
25374@itemx -mno-early-stop-bits
25375@opindex mearly-stop-bits
25376@opindex mno-early-stop-bits
25377Allow stop bits to be placed earlier than immediately preceding the
25378instruction that triggered the stop bit. This can improve instruction
25379scheduling, but does not always do so.
25380
25381@item -mfixed-range=@var{register-range}
25382@opindex mfixed-range
25383Generate code treating the given register range as fixed registers.
25384A fixed register is one that the register allocator cannot use. This is
25385useful when compiling kernel code. A register range is specified as
25386two registers separated by a dash. Multiple register ranges can be
25387specified separated by a comma.
25388
25389@item -mtls-size=@var{tls-size}
25390@opindex mtls-size
25391Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
2539264.
25393
25394@item -mtune=@var{cpu-type}
25395@opindex mtune
25396Tune the instruction scheduling for a particular CPU, Valid values are
25397@samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
25398and @samp{mckinley}.
25399
25400@item -milp32
25401@itemx -mlp64
25402@opindex milp32
25403@opindex mlp64
25404Generate code for a 32-bit or 64-bit environment.
25405The 32-bit environment sets int, long and pointer to 32 bits.
25406The 64-bit environment sets int to 32 bits and long and pointer
25407to 64 bits. These are HP-UX specific flags.
25408
25409@item -mno-sched-br-data-spec
25410@itemx -msched-br-data-spec
25411@opindex mno-sched-br-data-spec
25412@opindex msched-br-data-spec
25413(Dis/En)able data speculative scheduling before reload.
25414This results in generation of @code{ld.a} instructions and
25415the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25416The default setting is disabled.
25417
25418@item -msched-ar-data-spec
25419@itemx -mno-sched-ar-data-spec
25420@opindex msched-ar-data-spec
25421@opindex mno-sched-ar-data-spec
25422(En/Dis)able data speculative scheduling after reload.
25423This results in generation of @code{ld.a} instructions and
25424the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25425The default setting is enabled.
25426
25427@item -mno-sched-control-spec
25428@itemx -msched-control-spec
25429@opindex mno-sched-control-spec
25430@opindex msched-control-spec
25431(Dis/En)able control speculative scheduling. This feature is
25432available only during region scheduling (i.e.@: before reload).
25433This results in generation of the @code{ld.s} instructions and
25434the corresponding check instructions @code{chk.s}.
25435The default setting is disabled.
25436
25437@item -msched-br-in-data-spec
25438@itemx -mno-sched-br-in-data-spec
25439@opindex msched-br-in-data-spec
25440@opindex mno-sched-br-in-data-spec
25441(En/Dis)able speculative scheduling of the instructions that
25442are dependent on the data speculative loads before reload.
25443This is effective only with @option{-msched-br-data-spec} enabled.
25444The default setting is enabled.
25445
25446@item -msched-ar-in-data-spec
25447@itemx -mno-sched-ar-in-data-spec
25448@opindex msched-ar-in-data-spec
25449@opindex mno-sched-ar-in-data-spec
25450(En/Dis)able speculative scheduling of the instructions that
25451are dependent on the data speculative loads after reload.
25452This is effective only with @option{-msched-ar-data-spec} enabled.
25453The default setting is enabled.
25454
25455@item -msched-in-control-spec
25456@itemx -mno-sched-in-control-spec
25457@opindex msched-in-control-spec
25458@opindex mno-sched-in-control-spec
25459(En/Dis)able speculative scheduling of the instructions that
25460are dependent on the control speculative loads.
25461This is effective only with @option{-msched-control-spec} enabled.
25462The default setting is enabled.
25463
25464@item -mno-sched-prefer-non-data-spec-insns
25465@itemx -msched-prefer-non-data-spec-insns
25466@opindex mno-sched-prefer-non-data-spec-insns
25467@opindex msched-prefer-non-data-spec-insns
25468If enabled, data-speculative instructions are chosen for schedule
25469only if there are no other choices at the moment. This makes
25470the use of the data speculation much more conservative.
25471The default setting is disabled.
25472
25473@item -mno-sched-prefer-non-control-spec-insns
25474@itemx -msched-prefer-non-control-spec-insns
25475@opindex mno-sched-prefer-non-control-spec-insns
25476@opindex msched-prefer-non-control-spec-insns
25477If enabled, control-speculative instructions are chosen for schedule
25478only if there are no other choices at the moment. This makes
25479the use of the control speculation much more conservative.
25480The default setting is disabled.
25481
25482@item -mno-sched-count-spec-in-critical-path
25483@itemx -msched-count-spec-in-critical-path
25484@opindex mno-sched-count-spec-in-critical-path
25485@opindex msched-count-spec-in-critical-path
25486If enabled, speculative dependencies are considered during
25487computation of the instructions priorities. This makes the use of the
25488speculation a bit more conservative.
25489The default setting is disabled.
25490
25491@item -msched-spec-ldc
25492@opindex msched-spec-ldc
25493Use a simple data speculation check. This option is on by default.
25494
25495@item -msched-control-spec-ldc
25496@opindex msched-spec-ldc
25497Use a simple check for control speculation. This option is on by default.
25498
25499@item -msched-stop-bits-after-every-cycle
25500@opindex msched-stop-bits-after-every-cycle
25501Place a stop bit after every cycle when scheduling. This option is on
25502by default.
25503
25504@item -msched-fp-mem-deps-zero-cost
25505@opindex msched-fp-mem-deps-zero-cost
25506Assume that floating-point stores and loads are not likely to cause a conflict
25507when placed into the same instruction group. This option is disabled by
25508default.
25509
25510@item -msel-sched-dont-check-control-spec
25511@opindex msel-sched-dont-check-control-spec
25512Generate checks for control speculation in selective scheduling.
25513This flag is disabled by default.
25514
25515@item -msched-max-memory-insns=@var{max-insns}
25516@opindex msched-max-memory-insns
25517Limit on the number of memory insns per instruction group, giving lower
25518priority to subsequent memory insns attempting to schedule in the same
25519instruction group. Frequently useful to prevent cache bank conflicts.
25520The default value is 1.
25521
25522@item -msched-max-memory-insns-hard-limit
25523@opindex msched-max-memory-insns-hard-limit
25524Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
25525disallowing more than that number in an instruction group.
25526Otherwise, the limit is ``soft'', meaning that non-memory operations
25527are preferred when the limit is reached, but memory operations may still
25528be scheduled.
25529
25530@end table
25531
25532@node LM32 Options
25533@subsection LM32 Options
25534@cindex LM32 options
25535
25536These @option{-m} options are defined for the LatticeMico32 architecture:
25537
25538@table @gcctabopt
25539@item -mbarrel-shift-enabled
25540@opindex mbarrel-shift-enabled
25541Enable barrel-shift instructions.
25542
25543@item -mdivide-enabled
25544@opindex mdivide-enabled
25545Enable divide and modulus instructions.
25546
25547@item -mmultiply-enabled
25548@opindex multiply-enabled
25549Enable multiply instructions.
25550
25551@item -msign-extend-enabled
25552@opindex msign-extend-enabled
25553Enable sign extend instructions.
25554
25555@item -muser-enabled
25556@opindex muser-enabled
25557Enable user-defined instructions.
25558
25559@end table
25560
25561@node LoongArch Options
25562@subsection LoongArch Options
25563@cindex LoongArch Options
25564
25565These command-line options are defined for LoongArch targets:
25566
25567@table @gcctabopt
25568@item -march=@var{cpu-type}
9c19597c 25569@opindex march
d77de738
ML
25570Generate instructions for the machine type @var{cpu-type}. In contrast to
25571@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
25572for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
25573to generate code that may not run at all on processors other than the one
25574indicated. Specifying @option{-march=@var{cpu-type}} implies
25575@option{-mtune=@var{cpu-type}}, except where noted otherwise.
25576
25577The choices for @var{cpu-type} are:
25578
25579@table @samp
25580@item native
25581This selects the CPU to generate code for at compilation time by determining
25582the processor type of the compiling machine. Using @option{-march=native}
25583enables all instruction subsets supported by the local machine (hence
25584the result might not run on different machines). Using @option{-mtune=native}
25585produces code optimized for the local machine under the constraints
25586of the selected instruction set.
25587@item loongarch64
25588A generic CPU with 64-bit extensions.
25589@item la464
25590LoongArch LA464 CPU with LBT, LSX, LASX, LVZ.
25591@end table
25592
25593@item -mtune=@var{cpu-type}
25594@opindex mtune
25595Optimize the output for the given processor, specified by microarchitecture
25596name.
25597
25598@item -mabi=@var{base-abi-type}
25599@opindex mabi
25600Generate code for the specified calling convention.
25601@var{base-abi-type} can be one of:
25602@table @samp
25603@item lp64d
25604Uses 64-bit general purpose registers and 32/64-bit floating-point
25605registers for parameter passing. Data model is LP64, where @samp{int}
25606is 32 bits, while @samp{long int} and pointers are 64 bits.
25607@item lp64f
25608Uses 64-bit general purpose registers and 32-bit floating-point
25609registers for parameter passing. Data model is LP64, where @samp{int}
25610is 32 bits, while @samp{long int} and pointers are 64 bits.
25611@item lp64s
25612Uses 64-bit general purpose registers and no floating-point
25613registers for parameter passing. Data model is LP64, where @samp{int}
25614is 32 bits, while @samp{long int} and pointers are 64 bits.
25615@end table
25616
25617@item -mfpu=@var{fpu-type}
25618@opindex mfpu
25619Generate code for the specified FPU type, which can be one of:
25620@table @samp
25621@item 64
25622Allow the use of hardware floating-point instructions for 32-bit
25623and 64-bit operations.
25624@item 32
25625Allow the use of hardware floating-point instructions for 32-bit
25626operations.
25627@item none
25628@item 0
25629Prevent the use of hardware floating-point instructions.
25630@end table
25631
25632@item -msoft-float
25633@opindex msoft-float
25634Force @option{-mfpu=none} and prevents the use of floating-point
25635registers for parameter passing. This option may change the target
25636ABI.
25637
25638@item -msingle-float
9c19597c 25639@opindex msingle-float
d77de738
ML
25640Force @option{-mfpu=32} and allow the use of 32-bit floating-point
25641registers for parameter passing. This option may change the target
25642ABI.
25643
25644@item -mdouble-float
9c19597c 25645@opindex mdouble-float
d77de738
ML
25646Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point
25647registers for parameter passing. This option may change the target
25648ABI.
25649
25650@item -mbranch-cost=@var{n}
9c19597c 25651@opindex mbranch-cost
d77de738
ML
25652Set the cost of branches to roughly @var{n} instructions.
25653
25654@item -mcheck-zero-division
25655@itemx -mno-check-zero-divison
9c19597c 25656@opindex mcheck-zero-division
d77de738
ML
25657Trap (do not trap) on integer division by zero. The default is
25658@option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and
25659@option{-mno-check-zero-division} for other optimization levels.
25660
25661@item -mcond-move-int
25662@itemx -mno-cond-move-int
9c19597c 25663@opindex mcond-move-int
d77de738
ML
25664Conditional moves for integral data in general-purpose registers
25665are enabled (disabled). The default is @option{-mcond-move-int}.
25666
25667@item -mcond-move-float
25668@itemx -mno-cond-move-float
9c19597c 25669@opindex mcond-move-float
d77de738
ML
25670Conditional moves for floating-point registers are enabled (disabled).
25671The default is @option{-mcond-move-float}.
25672
25673@item -mmemcpy
25674@itemx -mno-memcpy
9c19597c 25675@opindex mmemcpy
d77de738
ML
25676Force (do not force) the use of @code{memcpy} for non-trivial block moves.
25677The default is @option{-mno-memcpy}, which allows GCC to inline most
25678constant-sized copies. Setting optimization level to @option{-Os} also
25679forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this
25680behavior if explicitly specified, regardless of the order these options on
25681the command line.
25682
25683@item -mstrict-align
25684@itemx -mno-strict-align
9c19597c 25685@opindex mstrict-align
d77de738
ML
25686Avoid or allow generating memory accesses that may not be aligned on a natural
25687object boundary as described in the architecture specification. The default is
25688@option{-mno-strict-align}.
25689
25690@item -msmall-data-limit=@var{number}
9c19597c 25691@opindex msmall-data-limit
d77de738
ML
25692Put global and static data smaller than @var{number} bytes into a special
25693section (on some targets). The default value is 0.
25694
25695@item -mmax-inline-memcpy-size=@var{n}
9c19597c 25696@opindex mmax-inline-memcpy-size
d77de738
ML
25697Inline all block moves (such as calls to @code{memcpy} or structure copies)
25698less than or equal to @var{n} bytes. The default value of @var{n} is 1024.
25699
25700@item -mcmodel=@var{code-model}
25701Set the code model to one of:
25702@table @samp
25703@item tiny-static (Not implemented yet)
25704@item tiny (Not implemented yet)
25705
25706@item normal
25707The text segment must be within 128MB addressing space. The data segment must
25708be within 2GB addressing space.
25709
25710@item medium
25711The text segment and data segment must be within 2GB addressing space.
25712
25713@item large (Not implemented yet)
25714
25715@item extreme
25716This mode does not limit the size of the code segment and data segment.
25717The @option{-mcmodel=extreme} option is incompatible with @option{-fplt} and
25718@option{-mno-explicit-relocs}.
25719@end table
25720The default code model is @code{normal}.
25721
25722@item -mexplicit-relocs
25723@itemx -mno-explicit-relocs
25724@opindex mexplicit-relocs
25725@opindex mno-explicit-relocs
25726Use or do not use assembler relocation operators when dealing with symbolic
25727addresses. The alternative is to use assembler macros instead, which may
25728limit optimization. The default value for the option is determined during
25729GCC build-time by detecting corresponding assembler support:
25730@code{-mexplicit-relocs} if said support is present,
25731@code{-mno-explicit-relocs} otherwise. This option is mostly useful for
25732debugging, or interoperation with assemblers different from the build-time
25733one.
25734
25735@item -mdirect-extern-access
25736@itemx -mno-direct-extern-access
25737@opindex mdirect-extern-access
25738Do not use or use GOT to access external symbols. The default is
25739@option{-mno-direct-extern-access}: GOT is used for external symbols with
25740default visibility, but not used for other external symbols.
25741
25742With @option{-mdirect-extern-access}, GOT is not used and all external
25743symbols are PC-relatively addressed. It is @strong{only} suitable for
25744environments where no dynamic link is performed, like firmwares, OS
25745kernels, executables linked with @option{-static} or @option{-static-pie}.
25746@option{-mdirect-extern-access} is not compatible with @option{-fPIC} or
25747@option{-fpic}.
25748@end table
25749
25750@node M32C Options
25751@subsection M32C Options
25752@cindex M32C options
25753
25754@table @gcctabopt
25755@item -mcpu=@var{name}
25756@opindex mcpu=
25757Select the CPU for which code is generated. @var{name} may be one of
25758@samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
25759/60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
25760the M32C/80 series.
25761
25762@item -msim
25763@opindex msim
25764Specifies that the program will be run on the simulator. This causes
25765an alternate runtime library to be linked in which supports, for
25766example, file I/O@. You must not use this option when generating
25767programs that will run on real hardware; you must provide your own
25768runtime library for whatever I/O functions are needed.
25769
25770@item -memregs=@var{number}
25771@opindex memregs=
25772Specifies the number of memory-based pseudo-registers GCC uses
25773during code generation. These pseudo-registers are used like real
25774registers, so there is a tradeoff between GCC's ability to fit the
25775code into available registers, and the performance penalty of using
25776memory instead of registers. Note that all modules in a program must
25777be compiled with the same value for this option. Because of that, you
25778must not use this option with GCC's default runtime libraries.
25779
25780@end table
25781
25782@node M32R/D Options
25783@subsection M32R/D Options
25784@cindex M32R/D options
25785
25786These @option{-m} options are defined for Renesas M32R/D architectures:
25787
25788@table @gcctabopt
25789@item -m32r2
25790@opindex m32r2
25791Generate code for the M32R/2@.
25792
25793@item -m32rx
25794@opindex m32rx
25795Generate code for the M32R/X@.
25796
25797@item -m32r
25798@opindex m32r
25799Generate code for the M32R@. This is the default.
25800
25801@item -mmodel=small
25802@opindex mmodel=small
25803Assume all objects live in the lower 16MB of memory (so that their addresses
25804can be loaded with the @code{ld24} instruction), and assume all subroutines
25805are reachable with the @code{bl} instruction.
25806This is the default.
25807
25808The addressability of a particular object can be set with the
25809@code{model} attribute.
25810
25811@item -mmodel=medium
25812@opindex mmodel=medium
25813Assume objects may be anywhere in the 32-bit address space (the compiler
25814generates @code{seth/add3} instructions to load their addresses), and
25815assume all subroutines are reachable with the @code{bl} instruction.
25816
25817@item -mmodel=large
25818@opindex mmodel=large
25819Assume objects may be anywhere in the 32-bit address space (the compiler
25820generates @code{seth/add3} instructions to load their addresses), and
25821assume subroutines may not be reachable with the @code{bl} instruction
25822(the compiler generates the much slower @code{seth/add3/jl}
25823instruction sequence).
25824
25825@item -msdata=none
25826@opindex msdata=none
25827Disable use of the small data area. Variables are put into
25828one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
25829@code{section} attribute has been specified).
25830This is the default.
25831
25832The small data area consists of sections @code{.sdata} and @code{.sbss}.
25833Objects may be explicitly put in the small data area with the
25834@code{section} attribute using one of these sections.
25835
25836@item -msdata=sdata
25837@opindex msdata=sdata
25838Put small global and static data in the small data area, but do not
25839generate special code to reference them.
25840
25841@item -msdata=use
25842@opindex msdata=use
25843Put small global and static data in the small data area, and generate
25844special instructions to reference them.
25845
25846@item -G @var{num}
25847@opindex G
25848@cindex smaller data references
25849Put global and static objects less than or equal to @var{num} bytes
25850into the small data or BSS sections instead of the normal data or BSS
25851sections. The default value of @var{num} is 8.
25852The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
25853for this option to have any effect.
25854
25855All modules should be compiled with the same @option{-G @var{num}} value.
25856Compiling with different values of @var{num} may or may not work; if it
25857doesn't the linker gives an error message---incorrect code is not
25858generated.
25859
25860@item -mdebug
25861@opindex mdebug
25862Makes the M32R-specific code in the compiler display some statistics
25863that might help in debugging programs.
25864
25865@item -malign-loops
25866@opindex malign-loops
25867Align all loops to a 32-byte boundary.
25868
25869@item -mno-align-loops
25870@opindex mno-align-loops
25871Do not enforce a 32-byte alignment for loops. This is the default.
25872
25873@item -missue-rate=@var{number}
25874@opindex missue-rate=@var{number}
25875Issue @var{number} instructions per cycle. @var{number} can only be 1
25876or 2.
25877
25878@item -mbranch-cost=@var{number}
25879@opindex mbranch-cost=@var{number}
25880@var{number} can only be 1 or 2. If it is 1 then branches are
25881preferred over conditional code, if it is 2, then the opposite applies.
25882
25883@item -mflush-trap=@var{number}
25884@opindex mflush-trap=@var{number}
25885Specifies the trap number to use to flush the cache. The default is
2588612. Valid numbers are between 0 and 15 inclusive.
25887
25888@item -mno-flush-trap
25889@opindex mno-flush-trap
25890Specifies that the cache cannot be flushed by using a trap.
25891
25892@item -mflush-func=@var{name}
25893@opindex mflush-func=@var{name}
25894Specifies the name of the operating system function to call to flush
25895the cache. The default is @samp{_flush_cache}, but a function call
25896is only used if a trap is not available.
25897
25898@item -mno-flush-func
25899@opindex mno-flush-func
25900Indicates that there is no OS function for flushing the cache.
25901
25902@end table
25903
25904@node M680x0 Options
25905@subsection M680x0 Options
25906@cindex M680x0 options
25907
25908These are the @samp{-m} options defined for M680x0 and ColdFire processors.
25909The default settings depend on which architecture was selected when
25910the compiler was configured; the defaults for the most common choices
25911are given below.
25912
25913@table @gcctabopt
25914@item -march=@var{arch}
25915@opindex march
25916Generate code for a specific M680x0 or ColdFire instruction set
25917architecture. Permissible values of @var{arch} for M680x0
25918architectures are: @samp{68000}, @samp{68010}, @samp{68020},
25919@samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
25920architectures are selected according to Freescale's ISA classification
25921and the permissible values are: @samp{isaa}, @samp{isaaplus},
25922@samp{isab} and @samp{isac}.
25923
25924GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
25925code for a ColdFire target. The @var{arch} in this macro is one of the
25926@option{-march} arguments given above.
25927
25928When used together, @option{-march} and @option{-mtune} select code
25929that runs on a family of similar processors but that is optimized
25930for a particular microarchitecture.
25931
25932@item -mcpu=@var{cpu}
25933@opindex mcpu
25934Generate code for a specific M680x0 or ColdFire processor.
25935The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
25936@samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
25937and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
25938below, which also classifies the CPUs into families:
25939
25940@multitable @columnfractions 0.20 0.80
25941@headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
25942@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}
25943@item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
25944@item @samp{5206e} @tab @samp{5206e}
25945@item @samp{5208} @tab @samp{5207} @samp{5208}
25946@item @samp{5211a} @tab @samp{5210a} @samp{5211a}
25947@item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
25948@item @samp{5216} @tab @samp{5214} @samp{5216}
25949@item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
25950@item @samp{5225} @tab @samp{5224} @samp{5225}
25951@item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
25952@item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
25953@item @samp{5249} @tab @samp{5249}
25954@item @samp{5250} @tab @samp{5250}
25955@item @samp{5271} @tab @samp{5270} @samp{5271}
25956@item @samp{5272} @tab @samp{5272}
25957@item @samp{5275} @tab @samp{5274} @samp{5275}
25958@item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
25959@item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
25960@item @samp{5307} @tab @samp{5307}
25961@item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
25962@item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
25963@item @samp{5407} @tab @samp{5407}
25964@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}
25965@end multitable
25966
25967@option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
25968@var{arch} is compatible with @var{cpu}. Other combinations of
25969@option{-mcpu} and @option{-march} are rejected.
25970
25971GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
25972@var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
25973where the value of @var{family} is given by the table above.
25974
25975@item -mtune=@var{tune}
25976@opindex mtune
25977Tune the code for a particular microarchitecture within the
25978constraints set by @option{-march} and @option{-mcpu}.
25979The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
25980@samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
25981and @samp{cpu32}. The ColdFire microarchitectures
25982are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
25983
25984You can also use @option{-mtune=68020-40} for code that needs
25985to run relatively well on 68020, 68030 and 68040 targets.
25986@option{-mtune=68020-60} is similar but includes 68060 targets
25987as well. These two options select the same tuning decisions as
25988@option{-m68020-40} and @option{-m68020-60} respectively.
25989
25990GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
25991when tuning for 680x0 architecture @var{arch}. It also defines
25992@code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
25993option is used. If GCC is tuning for a range of architectures,
25994as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
25995it defines the macros for every architecture in the range.
25996
25997GCC also defines the macro @code{__m@var{uarch}__} when tuning for
25998ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
25999of the arguments given above.
26000
26001@item -m68000
26002@itemx -mc68000
26003@opindex m68000
26004@opindex mc68000
26005Generate output for a 68000. This is the default
26006when the compiler is configured for 68000-based systems.
26007It is equivalent to @option{-march=68000}.
26008
26009Use this option for microcontrollers with a 68000 or EC000 core,
26010including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
26011
26012@item -m68010
26013@opindex m68010
26014Generate output for a 68010. This is the default
26015when the compiler is configured for 68010-based systems.
26016It is equivalent to @option{-march=68010}.
26017
26018@item -m68020
26019@itemx -mc68020
26020@opindex m68020
26021@opindex mc68020
26022Generate output for a 68020. This is the default
26023when the compiler is configured for 68020-based systems.
26024It is equivalent to @option{-march=68020}.
26025
26026@item -m68030
26027@opindex m68030
26028Generate output for a 68030. This is the default when the compiler is
26029configured for 68030-based systems. It is equivalent to
26030@option{-march=68030}.
26031
26032@item -m68040
26033@opindex m68040
26034Generate output for a 68040. This is the default when the compiler is
26035configured for 68040-based systems. It is equivalent to
26036@option{-march=68040}.
26037
26038This option inhibits the use of 68881/68882 instructions that have to be
26039emulated by software on the 68040. Use this option if your 68040 does not
26040have code to emulate those instructions.
26041
26042@item -m68060
26043@opindex m68060
26044Generate output for a 68060. This is the default when the compiler is
26045configured for 68060-based systems. It is equivalent to
26046@option{-march=68060}.
26047
26048This option inhibits the use of 68020 and 68881/68882 instructions that
26049have to be emulated by software on the 68060. Use this option if your 68060
26050does not have code to emulate those instructions.
26051
26052@item -mcpu32
26053@opindex mcpu32
26054Generate output for a CPU32. This is the default
26055when the compiler is configured for CPU32-based systems.
26056It is equivalent to @option{-march=cpu32}.
26057
26058Use this option for microcontrollers with a
26059CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
2606068336, 68340, 68341, 68349 and 68360.
26061
26062@item -m5200
26063@opindex m5200
26064Generate output for a 520X ColdFire CPU@. This is the default
26065when the compiler is configured for 520X-based systems.
26066It is equivalent to @option{-mcpu=5206}, and is now deprecated
26067in favor of that option.
26068
26069Use this option for microcontroller with a 5200 core, including
26070the MCF5202, MCF5203, MCF5204 and MCF5206.
26071
26072@item -m5206e
26073@opindex m5206e
26074Generate output for a 5206e ColdFire CPU@. The option is now
26075deprecated in favor of the equivalent @option{-mcpu=5206e}.
26076
26077@item -m528x
26078@opindex m528x
26079Generate output for a member of the ColdFire 528X family.
26080The option is now deprecated in favor of the equivalent
26081@option{-mcpu=528x}.
26082
26083@item -m5307
26084@opindex m5307
26085Generate output for a ColdFire 5307 CPU@. The option is now deprecated
26086in favor of the equivalent @option{-mcpu=5307}.
26087
26088@item -m5407
26089@opindex m5407
26090Generate output for a ColdFire 5407 CPU@. The option is now deprecated
26091in favor of the equivalent @option{-mcpu=5407}.
26092
26093@item -mcfv4e
26094@opindex mcfv4e
26095Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
26096This includes use of hardware floating-point instructions.
26097The option is equivalent to @option{-mcpu=547x}, and is now
26098deprecated in favor of that option.
26099
26100@item -m68020-40
26101@opindex m68020-40
26102Generate output for a 68040, without using any of the new instructions.
26103This results in code that can run relatively efficiently on either a
2610468020/68881 or a 68030 or a 68040. The generated code does use the
2610568881 instructions that are emulated on the 68040.
26106
26107The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
26108
26109@item -m68020-60
26110@opindex m68020-60
26111Generate output for a 68060, without using any of the new instructions.
26112This results in code that can run relatively efficiently on either a
2611368020/68881 or a 68030 or a 68040. The generated code does use the
2611468881 instructions that are emulated on the 68060.
26115
26116The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
26117
26118@item -mhard-float
26119@itemx -m68881
26120@opindex mhard-float
26121@opindex m68881
26122Generate floating-point instructions. This is the default for 68020
26123and above, and for ColdFire devices that have an FPU@. It defines the
26124macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
26125on ColdFire targets.
26126
26127@item -msoft-float
26128@opindex msoft-float
26129Do not generate floating-point instructions; use library calls instead.
26130This is the default for 68000, 68010, and 68832 targets. It is also
26131the default for ColdFire devices that have no FPU.
26132
26133@item -mdiv
26134@itemx -mno-div
26135@opindex mdiv
26136@opindex mno-div
26137Generate (do not generate) ColdFire hardware divide and remainder
26138instructions. If @option{-march} is used without @option{-mcpu},
26139the default is ``on'' for ColdFire architectures and ``off'' for M680x0
26140architectures. Otherwise, the default is taken from the target CPU
26141(either the default CPU, or the one specified by @option{-mcpu}). For
26142example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
26143@option{-mcpu=5206e}.
26144
26145GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
26146
26147@item -mshort
26148@opindex mshort
26149Consider type @code{int} to be 16 bits wide, like @code{short int}.
26150Additionally, parameters passed on the stack are also aligned to a
2615116-bit boundary even on targets whose API mandates promotion to 32-bit.
26152
26153@item -mno-short
26154@opindex mno-short
26155Do not consider type @code{int} to be 16 bits wide. This is the default.
26156
26157@item -mnobitfield
26158@itemx -mno-bitfield
26159@opindex mnobitfield
26160@opindex mno-bitfield
26161Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
26162and @option{-m5200} options imply @w{@option{-mnobitfield}}.
26163
26164@item -mbitfield
26165@opindex mbitfield
26166Do use the bit-field instructions. The @option{-m68020} option implies
26167@option{-mbitfield}. This is the default if you use a configuration
26168designed for a 68020.
26169
26170@item -mrtd
26171@opindex mrtd
26172Use a different function-calling convention, in which functions
26173that take a fixed number of arguments return with the @code{rtd}
26174instruction, which pops their arguments while returning. This
26175saves one instruction in the caller since there is no need to pop
26176the arguments there.
26177
26178This calling convention is incompatible with the one normally
26179used on Unix, so you cannot use it if you need to call libraries
26180compiled with the Unix compiler.
26181
26182Also, you must provide function prototypes for all functions that
26183take variable numbers of arguments (including @code{printf});
26184otherwise incorrect code is generated for calls to those
26185functions.
26186
26187In addition, seriously incorrect code results if you call a
26188function with too many arguments. (Normally, extra arguments are
26189harmlessly ignored.)
26190
26191The @code{rtd} instruction is supported by the 68010, 68020, 68030,
2619268040, 68060 and CPU32 processors, but not by the 68000 or 5200.
26193
26194The default is @option{-mno-rtd}.
26195
26196@item -malign-int
26197@itemx -mno-align-int
26198@opindex malign-int
26199@opindex mno-align-int
26200Control whether GCC aligns @code{int}, @code{long}, @code{long long},
26201@code{float}, @code{double}, and @code{long double} variables on a 32-bit
26202boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
26203Aligning variables on 32-bit boundaries produces code that runs somewhat
26204faster on processors with 32-bit busses at the expense of more memory.
26205
26206@strong{Warning:} if you use the @option{-malign-int} switch, GCC
26207aligns structures containing the above types differently than
26208most published application binary interface specifications for the m68k.
26209
26210@opindex mpcrel
26211Use the pc-relative addressing mode of the 68000 directly, instead of
26212using a global offset table. At present, this option implies @option{-fpic},
26213allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
26214not presently supported with @option{-mpcrel}, though this could be supported for
2621568020 and higher processors.
26216
26217@item -mno-strict-align
26218@itemx -mstrict-align
26219@opindex mno-strict-align
26220@opindex mstrict-align
26221Do not (do) assume that unaligned memory references are handled by
26222the system.
26223
26224@item -msep-data
26225Generate code that allows the data segment to be located in a different
26226area of memory from the text segment. This allows for execute-in-place in
26227an environment without virtual memory management. This option implies
26228@option{-fPIC}.
26229
26230@item -mno-sep-data
26231Generate code that assumes that the data segment follows the text segment.
26232This is the default.
26233
26234@item -mid-shared-library
26235Generate code that supports shared libraries via the library ID method.
26236This allows for execute-in-place and shared libraries in an environment
26237without virtual memory management. This option implies @option{-fPIC}.
26238
26239@item -mno-id-shared-library
26240Generate code that doesn't assume ID-based shared libraries are being used.
26241This is the default.
26242
26243@item -mshared-library-id=n
26244Specifies the identification number of the ID-based shared library being
26245compiled. Specifying a value of 0 generates more compact code; specifying
26246other values forces the allocation of that number to the current
26247library, but is no more space- or time-efficient than omitting this option.
26248
26249@item -mxgot
26250@itemx -mno-xgot
26251@opindex mxgot
26252@opindex mno-xgot
26253When generating position-independent code for ColdFire, generate code
26254that works if the GOT has more than 8192 entries. This code is
26255larger and slower than code generated without this option. On M680x0
26256processors, this option is not needed; @option{-fPIC} suffices.
26257
26258GCC normally uses a single instruction to load values from the GOT@.
26259While this is relatively efficient, it only works if the GOT
26260is smaller than about 64k. Anything larger causes the linker
26261to report an error such as:
26262
26263@cindex relocation truncated to fit (ColdFire)
26264@smallexample
26265relocation truncated to fit: R_68K_GOT16O foobar
26266@end smallexample
26267
26268If this happens, you should recompile your code with @option{-mxgot}.
26269It should then work with very large GOTs. However, code generated with
26270@option{-mxgot} is less efficient, since it takes 4 instructions to fetch
26271the value of a global symbol.
26272
26273Note that some linkers, including newer versions of the GNU linker,
26274can create multiple GOTs and sort GOT entries. If you have such a linker,
26275you should only need to use @option{-mxgot} when compiling a single
26276object file that accesses more than 8192 GOT entries. Very few do.
26277
26278These options have no effect unless GCC is generating
26279position-independent code.
26280
26281@item -mlong-jump-table-offsets
26282@opindex mlong-jump-table-offsets
26283Use 32-bit offsets in @code{switch} tables. The default is to use
2628416-bit offsets.
26285
26286@end table
26287
26288@node MCore Options
26289@subsection MCore Options
26290@cindex MCore options
26291
26292These are the @samp{-m} options defined for the Motorola M*Core
26293processors.
26294
26295@table @gcctabopt
26296
26297@item -mhardlit
26298@itemx -mno-hardlit
26299@opindex mhardlit
26300@opindex mno-hardlit
26301Inline constants into the code stream if it can be done in two
26302instructions or less.
26303
26304@item -mdiv
26305@itemx -mno-div
26306@opindex mdiv
26307@opindex mno-div
26308Use the divide instruction. (Enabled by default).
26309
26310@item -mrelax-immediate
26311@itemx -mno-relax-immediate
26312@opindex mrelax-immediate
26313@opindex mno-relax-immediate
26314Allow arbitrary-sized immediates in bit operations.
26315
26316@item -mwide-bitfields
26317@itemx -mno-wide-bitfields
26318@opindex mwide-bitfields
26319@opindex mno-wide-bitfields
26320Always treat bit-fields as @code{int}-sized.
26321
26322@item -m4byte-functions
26323@itemx -mno-4byte-functions
26324@opindex m4byte-functions
26325@opindex mno-4byte-functions
26326Force all functions to be aligned to a 4-byte boundary.
26327
26328@item -mcallgraph-data
26329@itemx -mno-callgraph-data
26330@opindex mcallgraph-data
26331@opindex mno-callgraph-data
26332Emit callgraph information.
26333
26334@item -mslow-bytes
26335@itemx -mno-slow-bytes
26336@opindex mslow-bytes
26337@opindex mno-slow-bytes
26338Prefer word access when reading byte quantities.
26339
26340@item -mlittle-endian
26341@itemx -mbig-endian
26342@opindex mlittle-endian
26343@opindex mbig-endian
26344Generate code for a little-endian target.
26345
26346@item -m210
26347@itemx -m340
26348@opindex m210
26349@opindex m340
26350Generate code for the 210 processor.
26351
26352@item -mno-lsim
26353@opindex mno-lsim
26354Assume that runtime support has been provided and so omit the
26355simulator library (@file{libsim.a)} from the linker command line.
26356
26357@item -mstack-increment=@var{size}
26358@opindex mstack-increment
26359Set the maximum amount for a single stack increment operation. Large
26360values can increase the speed of programs that contain functions
26361that need a large amount of stack space, but they can also trigger a
26362segmentation fault if the stack is extended too much. The default
26363value is 0x1000.
26364
26365@end table
26366
d77de738
ML
26367@node MicroBlaze Options
26368@subsection MicroBlaze Options
26369@cindex MicroBlaze Options
26370
26371@table @gcctabopt
26372
26373@item -msoft-float
26374@opindex msoft-float
26375Use software emulation for floating point (default).
26376
26377@item -mhard-float
26378@opindex mhard-float
26379Use hardware floating-point instructions.
26380
26381@item -mmemcpy
26382@opindex mmemcpy
26383Do not optimize block moves, use @code{memcpy}.
26384
26385@item -mno-clearbss
26386@opindex mno-clearbss
26387This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
26388
26389@item -mcpu=@var{cpu-type}
26390@opindex mcpu=
26391Use features of, and schedule code for, the given CPU.
26392Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
26393where @var{X} is a major version, @var{YY} is the minor version, and
26394@var{Z} is compatibility code. Example values are @samp{v3.00.a},
26395@samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
26396
26397@item -mxl-soft-mul
26398@opindex mxl-soft-mul
26399Use software multiply emulation (default).
26400
26401@item -mxl-soft-div
26402@opindex mxl-soft-div
26403Use software emulation for divides (default).
26404
26405@item -mxl-barrel-shift
26406@opindex mxl-barrel-shift
26407Use the hardware barrel shifter.
26408
26409@item -mxl-pattern-compare
26410@opindex mxl-pattern-compare
26411Use pattern compare instructions.
26412
26413@item -msmall-divides
26414@opindex msmall-divides
26415Use table lookup optimization for small signed integer divisions.
26416
26417@item -mxl-stack-check
26418@opindex mxl-stack-check
26419This option is deprecated. Use @option{-fstack-check} instead.
26420
26421@item -mxl-gp-opt
26422@opindex mxl-gp-opt
26423Use GP-relative @code{.sdata}/@code{.sbss} sections.
26424
26425@item -mxl-multiply-high
26426@opindex mxl-multiply-high
26427Use multiply high instructions for high part of 32x32 multiply.
26428
26429@item -mxl-float-convert
26430@opindex mxl-float-convert
26431Use hardware floating-point conversion instructions.
26432
26433@item -mxl-float-sqrt
26434@opindex mxl-float-sqrt
26435Use hardware floating-point square root instruction.
26436
26437@item -mbig-endian
26438@opindex mbig-endian
26439Generate code for a big-endian target.
26440
26441@item -mlittle-endian
26442@opindex mlittle-endian
26443Generate code for a little-endian target.
26444
26445@item -mxl-reorder
26446@opindex mxl-reorder
26447Use reorder instructions (swap and byte reversed load/store).
26448
26449@item -mxl-mode-@var{app-model}
26450Select application model @var{app-model}. Valid models are
26451@table @samp
26452@item executable
26453normal executable (default), uses startup code @file{crt0.o}.
26454
26455@item xmdstub
26456for use with Xilinx Microprocessor Debugger (XMD) based
26457software intrusive debug agent called xmdstub. This uses startup file
26458@file{crt1.o} and sets the start address of the program to 0x800.
26459
26460@item bootstrap
26461for applications that are loaded using a bootloader.
26462This model uses startup file @file{crt2.o} which does not contain a processor
26463reset vector handler. This is suitable for transferring control on a
26464processor reset to the bootloader rather than the application.
26465
26466@item novectors
26467for applications that do not require any of the
26468MicroBlaze vectors. This option may be useful for applications running
26469within a monitoring application. This model uses @file{crt3.o} as a startup file.
26470@end table
26471
26472Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
26473@option{-mxl-mode-@var{app-model}}.
26474
26475@item -mpic-data-is-text-relative
26476@opindex mpic-data-is-text-relative
26477Assume that the displacement between the text and data segments is fixed
26478at static link time. This allows data to be referenced by offset from start of
26479text address instead of GOT since PC-relative addressing is not supported.
26480
26481@end table
26482
26483@node MIPS Options
26484@subsection MIPS Options
26485@cindex MIPS options
26486
26487@table @gcctabopt
26488
26489@item -EB
26490@opindex EB
26491Generate big-endian code.
26492
26493@item -EL
26494@opindex EL
26495Generate little-endian code. This is the default for @samp{mips*el-*-*}
26496configurations.
26497
26498@item -march=@var{arch}
26499@opindex march
26500Generate code that runs on @var{arch}, which can be the name of a
26501generic MIPS ISA, or the name of a particular processor.
26502The ISA names are:
26503@samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
26504@samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
26505@samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
26506@samp{mips64r5} and @samp{mips64r6}.
26507The processor names are:
26508@samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
26509@samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
26510@samp{5kc}, @samp{5kf},
26511@samp{20kc},
26512@samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
26513@samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
26514@samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
26515@samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
26516@samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
26517@samp{i6400}, @samp{i6500},
26518@samp{interaptiv},
26519@samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
26520@samp{gs464e}, @samp{gs264e},
26521@samp{m4k},
26522@samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
26523@samp{m5100}, @samp{m5101},
26524@samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
26525@samp{orion},
26526@samp{p5600}, @samp{p6600},
26527@samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
26528@samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
26529@samp{r6000}, @samp{r8000},
26530@samp{rm7000}, @samp{rm9000},
26531@samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
26532@samp{sb1},
26533@samp{sr71000},
26534@samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
26535@samp{vr5000}, @samp{vr5400}, @samp{vr5500},
26536@samp{xlr} and @samp{xlp}.
26537The special value @samp{from-abi} selects the
26538most compatible architecture for the selected ABI (that is,
26539@samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
26540
26541The native Linux/GNU toolchain also supports the value @samp{native},
26542which selects the best architecture option for the host processor.
26543@option{-march=native} has no effect if GCC does not recognize
26544the processor.
26545
26546In processor names, a final @samp{000} can be abbreviated as @samp{k}
26547(for example, @option{-march=r2k}). Prefixes are optional, and
26548@samp{vr} may be written @samp{r}.
26549
26550Names of the form @samp{@var{n}f2_1} refer to processors with
26551FPUs clocked at half the rate of the core, names of the form
26552@samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
26553rate as the core, and names of the form @samp{@var{n}f3_2} refer to
26554processors with FPUs clocked a ratio of 3:2 with respect to the core.
26555For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
26556for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
26557accepted as synonyms for @samp{@var{n}f1_1}.
26558
26559GCC defines two macros based on the value of this option. The first
26560is @code{_MIPS_ARCH}, which gives the name of target architecture, as
26561a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
26562where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
26563For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
26564to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
26565
26566Note that the @code{_MIPS_ARCH} macro uses the processor names given
26567above. In other words, it has the full prefix and does not
26568abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
26569the macro names the resolved architecture (either @code{"mips1"} or
26570@code{"mips3"}). It names the default architecture when no
26571@option{-march} option is given.
26572
26573@item -mtune=@var{arch}
26574@opindex mtune
26575Optimize for @var{arch}. Among other things, this option controls
26576the way instructions are scheduled, and the perceived cost of arithmetic
26577operations. The list of @var{arch} values is the same as for
26578@option{-march}.
26579
26580When this option is not used, GCC optimizes for the processor
26581specified by @option{-march}. By using @option{-march} and
26582@option{-mtune} together, it is possible to generate code that
26583runs on a family of processors, but optimize the code for one
26584particular member of that family.
26585
26586@option{-mtune} defines the macros @code{_MIPS_TUNE} and
26587@code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
26588@option{-march} ones described above.
26589
26590@item -mips1
26591@opindex mips1
26592Equivalent to @option{-march=mips1}.
26593
26594@item -mips2
26595@opindex mips2
26596Equivalent to @option{-march=mips2}.
26597
26598@item -mips3
26599@opindex mips3
26600Equivalent to @option{-march=mips3}.
26601
26602@item -mips4
26603@opindex mips4
26604Equivalent to @option{-march=mips4}.
26605
26606@item -mips32
26607@opindex mips32
26608Equivalent to @option{-march=mips32}.
26609
26610@item -mips32r3
26611@opindex mips32r3
26612Equivalent to @option{-march=mips32r3}.
26613
26614@item -mips32r5
26615@opindex mips32r5
26616Equivalent to @option{-march=mips32r5}.
26617
26618@item -mips32r6
26619@opindex mips32r6
26620Equivalent to @option{-march=mips32r6}.
26621
26622@item -mips64
26623@opindex mips64
26624Equivalent to @option{-march=mips64}.
26625
26626@item -mips64r2
26627@opindex mips64r2
26628Equivalent to @option{-march=mips64r2}.
26629
26630@item -mips64r3
26631@opindex mips64r3
26632Equivalent to @option{-march=mips64r3}.
26633
26634@item -mips64r5
26635@opindex mips64r5
26636Equivalent to @option{-march=mips64r5}.
26637
26638@item -mips64r6
26639@opindex mips64r6
26640Equivalent to @option{-march=mips64r6}.
26641
26642@item -mips16
26643@itemx -mno-mips16
26644@opindex mips16
26645@opindex mno-mips16
26646Generate (do not generate) MIPS16 code. If GCC is targeting a
26647MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
26648
26649MIPS16 code generation can also be controlled on a per-function basis
26650by means of @code{mips16} and @code{nomips16} attributes.
26651@xref{Function Attributes}, for more information.
26652
26653@item -mflip-mips16
26654@opindex mflip-mips16
26655Generate MIPS16 code on alternating functions. This option is provided
26656for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
26657not intended for ordinary use in compiling user code.
26658
26659@item -minterlink-compressed
26660@itemx -mno-interlink-compressed
26661@opindex minterlink-compressed
26662@opindex mno-interlink-compressed
26663Require (do not require) that code using the standard (uncompressed) MIPS ISA
26664be link-compatible with MIPS16 and microMIPS code, and vice versa.
26665
26666For example, code using the standard ISA encoding cannot jump directly
26667to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
26668@option{-minterlink-compressed} therefore disables direct jumps unless GCC
26669knows that the target of the jump is not compressed.
26670
26671@item -minterlink-mips16
26672@itemx -mno-interlink-mips16
26673@opindex minterlink-mips16
26674@opindex mno-interlink-mips16
26675Aliases of @option{-minterlink-compressed} and
26676@option{-mno-interlink-compressed}. These options predate the microMIPS ASE
26677and are retained for backwards compatibility.
26678
26679@item -mabi=32
26680@itemx -mabi=o64
26681@itemx -mabi=n32
26682@itemx -mabi=64
26683@itemx -mabi=eabi
26684@opindex mabi=32
26685@opindex mabi=o64
26686@opindex mabi=n32
26687@opindex mabi=64
26688@opindex mabi=eabi
26689Generate code for the given ABI@.
26690
26691Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
26692generates 64-bit code when you select a 64-bit architecture, but you
26693can use @option{-mgp32} to get 32-bit code instead.
26694
26695For information about the O64 ABI, see
26696@uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
26697
26698GCC supports a variant of the o32 ABI in which floating-point registers
26699are 64 rather than 32 bits wide. You can select this combination with
26700@option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
26701and @code{mfhc1} instructions and is therefore only supported for
26702MIPS32R2, MIPS32R3 and MIPS32R5 processors.
26703
26704The register assignments for arguments and return values remain the
26705same, but each scalar value is passed in a single 64-bit register
26706rather than a pair of 32-bit registers. For example, scalar
26707floating-point values are returned in @samp{$f0} only, not a
26708@samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
26709remains the same in that the even-numbered double-precision registers
26710are saved.
26711
26712Two additional variants of the o32 ABI are supported to enable
26713a transition from 32-bit to 64-bit registers. These are FPXX
26714(@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
26715The FPXX extension mandates that all code must execute correctly
26716when run using 32-bit or 64-bit registers. The code can be interlinked
26717with either FP32 or FP64, but not both.
26718The FP64A extension is similar to the FP64 extension but forbids the
26719use of odd-numbered single-precision registers. This can be used
26720in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
26721processors and allows both FP32 and FP64A code to interlink and
26722run in the same process without changing FPU modes.
26723
26724@item -mabicalls
26725@itemx -mno-abicalls
26726@opindex mabicalls
26727@opindex mno-abicalls
26728Generate (do not generate) code that is suitable for SVR4-style
26729dynamic objects. @option{-mabicalls} is the default for SVR4-based
26730systems.
26731
26732@item -mshared
26733@itemx -mno-shared
26734Generate (do not generate) code that is fully position-independent,
26735and that can therefore be linked into shared libraries. This option
26736only affects @option{-mabicalls}.
26737
26738All @option{-mabicalls} code has traditionally been position-independent,
26739regardless of options like @option{-fPIC} and @option{-fpic}. However,
26740as an extension, the GNU toolchain allows executables to use absolute
26741accesses for locally-binding symbols. It can also use shorter GP
26742initialization sequences and generate direct calls to locally-defined
26743functions. This mode is selected by @option{-mno-shared}.
26744
26745@option{-mno-shared} depends on binutils 2.16 or higher and generates
26746objects that can only be linked by the GNU linker. However, the option
26747does not affect the ABI of the final executable; it only affects the ABI
26748of relocatable objects. Using @option{-mno-shared} generally makes
26749executables both smaller and quicker.
26750
26751@option{-mshared} is the default.
26752
26753@item -mplt
26754@itemx -mno-plt
26755@opindex mplt
26756@opindex mno-plt
26757Assume (do not assume) that the static and dynamic linkers
26758support PLTs and copy relocations. This option only affects
26759@option{-mno-shared -mabicalls}. For the n64 ABI, this option
26760has no effect without @option{-msym32}.
26761
26762You can make @option{-mplt} the default by configuring
26763GCC with @option{--with-mips-plt}. The default is
26764@option{-mno-plt} otherwise.
26765
26766@item -mxgot
26767@itemx -mno-xgot
26768@opindex mxgot
26769@opindex mno-xgot
26770Lift (do not lift) the usual restrictions on the size of the global
26771offset table.
26772
26773GCC normally uses a single instruction to load values from the GOT@.
26774While this is relatively efficient, it only works if the GOT
26775is smaller than about 64k. Anything larger causes the linker
26776to report an error such as:
26777
26778@cindex relocation truncated to fit (MIPS)
26779@smallexample
26780relocation truncated to fit: R_MIPS_GOT16 foobar
26781@end smallexample
26782
26783If this happens, you should recompile your code with @option{-mxgot}.
26784This works with very large GOTs, although the code is also
26785less efficient, since it takes three instructions to fetch the
26786value of a global symbol.
26787
26788Note that some linkers can create multiple GOTs. If you have such a
26789linker, you should only need to use @option{-mxgot} when a single object
26790file accesses more than 64k's worth of GOT entries. Very few do.
26791
26792These options have no effect unless GCC is generating position
26793independent code.
26794
26795@item -mgp32
26796@opindex mgp32
26797Assume that general-purpose registers are 32 bits wide.
26798
26799@item -mgp64
26800@opindex mgp64
26801Assume that general-purpose registers are 64 bits wide.
26802
26803@item -mfp32
26804@opindex mfp32
26805Assume that floating-point registers are 32 bits wide.
26806
26807@item -mfp64
26808@opindex mfp64
26809Assume that floating-point registers are 64 bits wide.
26810
26811@item -mfpxx
26812@opindex mfpxx
26813Do not assume the width of floating-point registers.
26814
26815@item -mhard-float
26816@opindex mhard-float
26817Use floating-point coprocessor instructions.
26818
26819@item -msoft-float
26820@opindex msoft-float
26821Do not use floating-point coprocessor instructions. Implement
26822floating-point calculations using library calls instead.
26823
26824@item -mno-float
26825@opindex mno-float
26826Equivalent to @option{-msoft-float}, but additionally asserts that the
26827program being compiled does not perform any floating-point operations.
26828This option is presently supported only by some bare-metal MIPS
26829configurations, where it may select a special set of libraries
26830that lack all floating-point support (including, for example, the
26831floating-point @code{printf} formats).
26832If code compiled with @option{-mno-float} accidentally contains
26833floating-point operations, it is likely to suffer a link-time
26834or run-time failure.
26835
26836@item -msingle-float
26837@opindex msingle-float
26838Assume that the floating-point coprocessor only supports single-precision
26839operations.
26840
26841@item -mdouble-float
26842@opindex mdouble-float
26843Assume that the floating-point coprocessor supports double-precision
26844operations. This is the default.
26845
26846@item -modd-spreg
26847@itemx -mno-odd-spreg
26848@opindex modd-spreg
26849@opindex mno-odd-spreg
26850Enable the use of odd-numbered single-precision floating-point registers
26851for the o32 ABI. This is the default for processors that are known to
26852support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
26853is set by default.
26854
26855@item -mabs=2008
26856@itemx -mabs=legacy
26857@opindex mabs=2008
26858@opindex mabs=legacy
26859These options control the treatment of the special not-a-number (NaN)
26860IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
26861@code{neg.@i{fmt}} machine instructions.
26862
26863By default or when @option{-mabs=legacy} is used the legacy
26864treatment is selected. In this case these instructions are considered
26865arithmetic and avoided where correct operation is required and the
26866input operand might be a NaN. A longer sequence of instructions that
26867manipulate the sign bit of floating-point datum manually is used
26868instead unless the @option{-ffinite-math-only} option has also been
26869specified.
26870
26871The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
26872this case these instructions are considered non-arithmetic and therefore
26873operating correctly in all cases, including in particular where the
26874input operand is a NaN. These instructions are therefore always used
26875for the respective operations.
26876
26877@item -mnan=2008
26878@itemx -mnan=legacy
26879@opindex mnan=2008
26880@opindex mnan=legacy
26881These options control the encoding of the special not-a-number (NaN)
26882IEEE 754 floating-point data.
26883
26884The @option{-mnan=legacy} option selects the legacy encoding. In this
26885case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
26886significand field being 0, whereas signaling NaNs (sNaNs) are denoted
26887by the first bit of their trailing significand field being 1.
26888
26889The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
26890this case qNaNs are denoted by the first bit of their trailing
26891significand field being 1, whereas sNaNs are denoted by the first bit of
26892their trailing significand field being 0.
26893
26894The default is @option{-mnan=legacy} unless GCC has been configured with
26895@option{--with-nan=2008}.
26896
26897@item -mllsc
26898@itemx -mno-llsc
26899@opindex mllsc
26900@opindex mno-llsc
26901Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
26902implement atomic memory built-in functions. When neither option is
26903specified, GCC uses the instructions if the target architecture
26904supports them.
26905
26906@option{-mllsc} is useful if the runtime environment can emulate the
26907instructions and @option{-mno-llsc} can be useful when compiling for
26908nonstandard ISAs. You can make either option the default by
26909configuring GCC with @option{--with-llsc} and @option{--without-llsc}
26910respectively. @option{--with-llsc} is the default for some
26911configurations; see the installation documentation for details.
26912
26913@item -mdsp
26914@itemx -mno-dsp
26915@opindex mdsp
26916@opindex mno-dsp
26917Use (do not use) revision 1 of the MIPS DSP ASE@.
26918@xref{MIPS DSP Built-in Functions}. This option defines the
26919preprocessor macro @code{__mips_dsp}. It also defines
26920@code{__mips_dsp_rev} to 1.
26921
26922@item -mdspr2
26923@itemx -mno-dspr2
26924@opindex mdspr2
26925@opindex mno-dspr2
26926Use (do not use) revision 2 of the MIPS DSP ASE@.
26927@xref{MIPS DSP Built-in Functions}. This option defines the
26928preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
26929It also defines @code{__mips_dsp_rev} to 2.
26930
26931@item -msmartmips
26932@itemx -mno-smartmips
26933@opindex msmartmips
26934@opindex mno-smartmips
26935Use (do not use) the MIPS SmartMIPS ASE.
26936
26937@item -mpaired-single
26938@itemx -mno-paired-single
26939@opindex mpaired-single
26940@opindex mno-paired-single
26941Use (do not use) paired-single floating-point instructions.
26942@xref{MIPS Paired-Single Support}. This option requires
26943hardware floating-point support to be enabled.
26944
26945@item -mdmx
26946@itemx -mno-mdmx
26947@opindex mdmx
26948@opindex mno-mdmx
26949Use (do not use) MIPS Digital Media Extension instructions.
26950This option can only be used when generating 64-bit code and requires
26951hardware floating-point support to be enabled.
26952
26953@item -mips3d
26954@itemx -mno-mips3d
26955@opindex mips3d
26956@opindex mno-mips3d
26957Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
26958The option @option{-mips3d} implies @option{-mpaired-single}.
26959
26960@item -mmicromips
26961@itemx -mno-micromips
26962@opindex mmicromips
26963@opindex mno-mmicromips
26964Generate (do not generate) microMIPS code.
26965
26966MicroMIPS code generation can also be controlled on a per-function basis
26967by means of @code{micromips} and @code{nomicromips} attributes.
26968@xref{Function Attributes}, for more information.
26969
26970@item -mmt
26971@itemx -mno-mt
26972@opindex mmt
26973@opindex mno-mt
26974Use (do not use) MT Multithreading instructions.
26975
26976@item -mmcu
26977@itemx -mno-mcu
26978@opindex mmcu
26979@opindex mno-mcu
26980Use (do not use) the MIPS MCU ASE instructions.
26981
26982@item -meva
26983@itemx -mno-eva
26984@opindex meva
26985@opindex mno-eva
26986Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
26987
26988@item -mvirt
26989@itemx -mno-virt
26990@opindex mvirt
26991@opindex mno-virt
26992Use (do not use) the MIPS Virtualization (VZ) instructions.
26993
26994@item -mxpa
26995@itemx -mno-xpa
26996@opindex mxpa
26997@opindex mno-xpa
26998Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
26999
27000@item -mcrc
27001@itemx -mno-crc
27002@opindex mcrc
27003@opindex mno-crc
27004Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
27005
27006@item -mginv
27007@itemx -mno-ginv
27008@opindex mginv
27009@opindex mno-ginv
27010Use (do not use) the MIPS Global INValidate (GINV) instructions.
27011
27012@item -mloongson-mmi
27013@itemx -mno-loongson-mmi
27014@opindex mloongson-mmi
27015@opindex mno-loongson-mmi
27016Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
27017
27018@item -mloongson-ext
27019@itemx -mno-loongson-ext
27020@opindex mloongson-ext
27021@opindex mno-loongson-ext
27022Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
27023
27024@item -mloongson-ext2
27025@itemx -mno-loongson-ext2
27026@opindex mloongson-ext2
27027@opindex mno-loongson-ext2
27028Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
27029
27030@item -mlong64
27031@opindex mlong64
27032Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
27033an explanation of the default and the way that the pointer size is
27034determined.
27035
27036@item -mlong32
27037@opindex mlong32
27038Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
27039
27040The default size of @code{int}s, @code{long}s and pointers depends on
27041the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
27042uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
2704332-bit @code{long}s. Pointers are the same size as @code{long}s,
27044or the same size as integer registers, whichever is smaller.
27045
27046@item -msym32
27047@itemx -mno-sym32
27048@opindex msym32
27049@opindex mno-sym32
27050Assume (do not assume) that all symbols have 32-bit values, regardless
27051of the selected ABI@. This option is useful in combination with
27052@option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
27053to generate shorter and faster references to symbolic addresses.
27054
27055@item -G @var{num}
27056@opindex G
27057Put definitions of externally-visible data in a small data section
27058if that data is no bigger than @var{num} bytes. GCC can then generate
27059more efficient accesses to the data; see @option{-mgpopt} for details.
27060
27061The default @option{-G} option depends on the configuration.
27062
27063@item -mlocal-sdata
27064@itemx -mno-local-sdata
27065@opindex mlocal-sdata
27066@opindex mno-local-sdata
27067Extend (do not extend) the @option{-G} behavior to local data too,
27068such as to static variables in C@. @option{-mlocal-sdata} is the
27069default for all configurations.
27070
27071If the linker complains that an application is using too much small data,
27072you might want to try rebuilding the less performance-critical parts with
27073@option{-mno-local-sdata}. You might also want to build large
27074libraries with @option{-mno-local-sdata}, so that the libraries leave
27075more room for the main program.
27076
27077@item -mextern-sdata
27078@itemx -mno-extern-sdata
27079@opindex mextern-sdata
27080@opindex mno-extern-sdata
27081Assume (do not assume) that externally-defined data is in
27082a small data section if the size of that data is within the @option{-G} limit.
27083@option{-mextern-sdata} is the default for all configurations.
27084
27085If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
27086@var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
27087that is no bigger than @var{num} bytes, you must make sure that @var{Var}
27088is placed in a small data section. If @var{Var} is defined by another
27089module, you must either compile that module with a high-enough
27090@option{-G} setting or attach a @code{section} attribute to @var{Var}'s
27091definition. If @var{Var} is common, you must link the application
27092with a high-enough @option{-G} setting.
27093
27094The easiest way of satisfying these restrictions is to compile
27095and link every module with the same @option{-G} option. However,
27096you may wish to build a library that supports several different
27097small data limits. You can do this by compiling the library with
27098the highest supported @option{-G} setting and additionally using
27099@option{-mno-extern-sdata} to stop the library from making assumptions
27100about externally-defined data.
27101
27102@item -mgpopt
27103@itemx -mno-gpopt
27104@opindex mgpopt
27105@opindex mno-gpopt
27106Use (do not use) GP-relative accesses for symbols that are known to be
27107in a small data section; see @option{-G}, @option{-mlocal-sdata} and
27108@option{-mextern-sdata}. @option{-mgpopt} is the default for all
27109configurations.
27110
27111@option{-mno-gpopt} is useful for cases where the @code{$gp} register
27112might not hold the value of @code{_gp}. For example, if the code is
27113part of a library that might be used in a boot monitor, programs that
27114call boot monitor routines pass an unknown value in @code{$gp}.
27115(In such situations, the boot monitor itself is usually compiled
27116with @option{-G0}.)
27117
27118@option{-mno-gpopt} implies @option{-mno-local-sdata} and
27119@option{-mno-extern-sdata}.
27120
27121@item -membedded-data
27122@itemx -mno-embedded-data
27123@opindex membedded-data
27124@opindex mno-embedded-data
27125Allocate variables to the read-only data section first if possible, then
27126next in the small data section if possible, otherwise in data. This gives
27127slightly slower code than the default, but reduces the amount of RAM required
27128when executing, and thus may be preferred for some embedded systems.
27129
27130@item -muninit-const-in-rodata
27131@itemx -mno-uninit-const-in-rodata
27132@opindex muninit-const-in-rodata
27133@opindex mno-uninit-const-in-rodata
27134Put uninitialized @code{const} variables in the read-only data section.
27135This option is only meaningful in conjunction with @option{-membedded-data}.
27136
27137@item -mcode-readable=@var{setting}
27138@opindex mcode-readable
27139Specify whether GCC may generate code that reads from executable sections.
27140There are three possible settings:
27141
27142@table @gcctabopt
27143@item -mcode-readable=yes
27144Instructions may freely access executable sections. This is the
27145default setting.
27146
27147@item -mcode-readable=pcrel
27148MIPS16 PC-relative load instructions can access executable sections,
27149but other instructions must not do so. This option is useful on 4KSc
27150and 4KSd processors when the code TLBs have the Read Inhibit bit set.
27151It is also useful on processors that can be configured to have a dual
27152instruction/data SRAM interface and that, like the M4K, automatically
27153redirect PC-relative loads to the instruction RAM.
27154
27155@item -mcode-readable=no
27156Instructions must not access executable sections. This option can be
27157useful on targets that are configured to have a dual instruction/data
27158SRAM interface but that (unlike the M4K) do not automatically redirect
27159PC-relative loads to the instruction RAM.
27160@end table
27161
27162@item -msplit-addresses
27163@itemx -mno-split-addresses
27164@opindex msplit-addresses
27165@opindex mno-split-addresses
27166Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
27167relocation operators. This option has been superseded by
27168@option{-mexplicit-relocs} but is retained for backwards compatibility.
27169
27170@item -mexplicit-relocs
27171@itemx -mno-explicit-relocs
27172@opindex mexplicit-relocs
27173@opindex mno-explicit-relocs
27174Use (do not use) assembler relocation operators when dealing with symbolic
27175addresses. The alternative, selected by @option{-mno-explicit-relocs},
27176is to use assembler macros instead.
27177
27178@option{-mexplicit-relocs} is the default if GCC was configured
27179to use an assembler that supports relocation operators.
27180
27181@item -mcheck-zero-division
27182@itemx -mno-check-zero-division
27183@opindex mcheck-zero-division
27184@opindex mno-check-zero-division
27185Trap (do not trap) on integer division by zero.
27186
27187The default is @option{-mcheck-zero-division}.
27188
27189@item -mdivide-traps
27190@itemx -mdivide-breaks
27191@opindex mdivide-traps
27192@opindex mdivide-breaks
27193MIPS systems check for division by zero by generating either a
27194conditional trap or a break instruction. Using traps results in
27195smaller code, but is only supported on MIPS II and later. Also, some
27196versions of the Linux kernel have a bug that prevents trap from
27197generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
27198allow conditional traps on architectures that support them and
27199@option{-mdivide-breaks} to force the use of breaks.
27200
27201The default is usually @option{-mdivide-traps}, but this can be
27202overridden at configure time using @option{--with-divide=breaks}.
27203Divide-by-zero checks can be completely disabled using
27204@option{-mno-check-zero-division}.
27205
27206@item -mload-store-pairs
27207@itemx -mno-load-store-pairs
27208@opindex mload-store-pairs
27209@opindex mno-load-store-pairs
27210Enable (disable) an optimization that pairs consecutive load or store
27211instructions to enable load/store bonding. This option is enabled by
27212default but only takes effect when the selected architecture is known
27213to support bonding.
27214
27215@item -munaligned-access
27216@itemx -mno-unaligned-access
27217@opindex munaligned-access
27218@opindex mno-unaligned-access
27219Enable (disable) direct unaligned access for MIPS Release 6.
27220MIPSr6 requires load/store unaligned-access support,
27221by hardware or trap&emulate.
27222So @option{-mno-unaligned-access} may be needed by kernel.
27223
27224@item -mmemcpy
27225@itemx -mno-memcpy
27226@opindex mmemcpy
27227@opindex mno-memcpy
27228Force (do not force) the use of @code{memcpy} for non-trivial block
27229moves. The default is @option{-mno-memcpy}, which allows GCC to inline
27230most constant-sized copies.
27231
27232@item -mlong-calls
27233@itemx -mno-long-calls
27234@opindex mlong-calls
27235@opindex mno-long-calls
27236Disable (do not disable) use of the @code{jal} instruction. Calling
27237functions using @code{jal} is more efficient but requires the caller
27238and callee to be in the same 256 megabyte segment.
27239
27240This option has no effect on abicalls code. The default is
27241@option{-mno-long-calls}.
27242
27243@item -mmad
27244@itemx -mno-mad
27245@opindex mmad
27246@opindex mno-mad
27247Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
27248instructions, as provided by the R4650 ISA@.
27249
27250@item -mimadd
27251@itemx -mno-imadd
27252@opindex mimadd
27253@opindex mno-imadd
27254Enable (disable) use of the @code{madd} and @code{msub} integer
27255instructions. The default is @option{-mimadd} on architectures
27256that support @code{madd} and @code{msub} except for the 74k
27257architecture where it was found to generate slower code.
27258
27259@item -mfused-madd
27260@itemx -mno-fused-madd
27261@opindex mfused-madd
27262@opindex mno-fused-madd
27263Enable (disable) use of the floating-point multiply-accumulate
27264instructions, when they are available. The default is
27265@option{-mfused-madd}.
27266
27267On the R8000 CPU when multiply-accumulate instructions are used,
27268the intermediate product is calculated to infinite precision
27269and is not subject to the FCSR Flush to Zero bit. This may be
27270undesirable in some circumstances. On other processors the result
27271is numerically identical to the equivalent computation using
27272separate multiply, add, subtract and negate instructions.
27273
27274@item -nocpp
27275@opindex nocpp
27276Tell the MIPS assembler to not run its preprocessor over user
27277assembler files (with a @samp{.s} suffix) when assembling them.
27278
27279@item -mfix-24k
27280@itemx -mno-fix-24k
27281@opindex mfix-24k
27282@opindex mno-fix-24k
27283Work around the 24K E48 (lost data on stores during refill) errata.
27284The workarounds are implemented by the assembler rather than by GCC@.
27285
27286@item -mfix-r4000
27287@itemx -mno-fix-r4000
27288@opindex mfix-r4000
27289@opindex mno-fix-r4000
27290Work around certain R4000 CPU errata:
27291@itemize @minus
27292@item
27293A double-word or a variable shift may give an incorrect result if executed
27294immediately after starting an integer division.
27295@item
27296A double-word or a variable shift may give an incorrect result if executed
27297while an integer multiplication is in progress.
27298@item
27299An integer division may give an incorrect result if started in a delay slot
27300of a taken branch or a jump.
27301@end itemize
27302
27303@item -mfix-r4400
27304@itemx -mno-fix-r4400
27305@opindex mfix-r4400
27306@opindex mno-fix-r4400
27307Work around certain R4400 CPU errata:
27308@itemize @minus
27309@item
27310A double-word or a variable shift may give an incorrect result if executed
27311immediately after starting an integer division.
27312@end itemize
27313
27314@item -mfix-r10000
27315@itemx -mno-fix-r10000
27316@opindex mfix-r10000
27317@opindex mno-fix-r10000
27318Work around certain R10000 errata:
27319@itemize @minus
27320@item
27321@code{ll}/@code{sc} sequences may not behave atomically on revisions
27322prior to 3.0. They may deadlock on revisions 2.6 and earlier.
27323@end itemize
27324
27325This option can only be used if the target architecture supports
27326branch-likely instructions. @option{-mfix-r10000} is the default when
27327@option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
27328otherwise.
27329
27330@item -mfix-r5900
27331@itemx -mno-fix-r5900
27332@opindex mfix-r5900
27333Do not attempt to schedule the preceding instruction into the delay slot
27334of a branch instruction placed at the end of a short loop of six
27335instructions or fewer and always schedule a @code{nop} instruction there
27336instead. The short loop bug under certain conditions causes loops to
27337execute only once or twice, due to a hardware bug in the R5900 chip. The
27338workaround is implemented by the assembler rather than by GCC@.
27339
27340@item -mfix-rm7000
27341@itemx -mno-fix-rm7000
27342@opindex mfix-rm7000
27343Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
27344workarounds are implemented by the assembler rather than by GCC@.
27345
27346@item -mfix-vr4120
27347@itemx -mno-fix-vr4120
27348@opindex mfix-vr4120
27349Work around certain VR4120 errata:
27350@itemize @minus
27351@item
27352@code{dmultu} does not always produce the correct result.
27353@item
27354@code{div} and @code{ddiv} do not always produce the correct result if one
27355of the operands is negative.
27356@end itemize
27357The workarounds for the division errata rely on special functions in
27358@file{libgcc.a}. At present, these functions are only provided by
27359the @code{mips64vr*-elf} configurations.
27360
27361Other VR4120 errata require a NOP to be inserted between certain pairs of
27362instructions. These errata are handled by the assembler, not by GCC itself.
27363
27364@item -mfix-vr4130
27365@opindex mfix-vr4130
27366Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
27367workarounds are implemented by the assembler rather than by GCC,
27368although GCC avoids using @code{mflo} and @code{mfhi} if the
27369VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
27370instructions are available instead.
27371
27372@item -mfix-sb1
27373@itemx -mno-fix-sb1
27374@opindex mfix-sb1
27375Work around certain SB-1 CPU core errata.
27376(This flag currently works around the SB-1 revision 2
27377``F1'' and ``F2'' floating-point errata.)
27378
27379@item -mr10k-cache-barrier=@var{setting}
27380@opindex mr10k-cache-barrier
27381Specify whether GCC should insert cache barriers to avoid the
27382side effects of speculation on R10K processors.
27383
27384In common with many processors, the R10K tries to predict the outcome
27385of a conditional branch and speculatively executes instructions from
27386the ``taken'' branch. It later aborts these instructions if the
27387predicted outcome is wrong. However, on the R10K, even aborted
27388instructions can have side effects.
27389
27390This problem only affects kernel stores and, depending on the system,
27391kernel loads. As an example, a speculatively-executed store may load
27392the target memory into cache and mark the cache line as dirty, even if
27393the store itself is later aborted. If a DMA operation writes to the
27394same area of memory before the ``dirty'' line is flushed, the cached
27395data overwrites the DMA-ed data. See the R10K processor manual
27396for a full description, including other potential problems.
27397
27398One workaround is to insert cache barrier instructions before every memory
27399access that might be speculatively executed and that might have side
27400effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
27401controls GCC's implementation of this workaround. It assumes that
27402aborted accesses to any byte in the following regions does not have
27403side effects:
27404
27405@enumerate
27406@item
27407the memory occupied by the current function's stack frame;
27408
27409@item
27410the memory occupied by an incoming stack argument;
27411
27412@item
27413the memory occupied by an object with a link-time-constant address.
27414@end enumerate
27415
27416It is the kernel's responsibility to ensure that speculative
27417accesses to these regions are indeed safe.
27418
27419If the input program contains a function declaration such as:
27420
27421@smallexample
27422void foo (void);
27423@end smallexample
27424
27425then the implementation of @code{foo} must allow @code{j foo} and
27426@code{jal foo} to be executed speculatively. GCC honors this
27427restriction for functions it compiles itself. It expects non-GCC
27428functions (such as hand-written assembly code) to do the same.
27429
27430The option has three forms:
27431
27432@table @gcctabopt
27433@item -mr10k-cache-barrier=load-store
27434Insert a cache barrier before a load or store that might be
27435speculatively executed and that might have side effects even
27436if aborted.
27437
27438@item -mr10k-cache-barrier=store
27439Insert a cache barrier before a store that might be speculatively
27440executed and that might have side effects even if aborted.
27441
27442@item -mr10k-cache-barrier=none
27443Disable the insertion of cache barriers. This is the default setting.
27444@end table
27445
27446@item -mflush-func=@var{func}
27447@itemx -mno-flush-func
27448@opindex mflush-func
27449Specifies the function to call to flush the I and D caches, or to not
27450call any such function. If called, the function must take the same
27451arguments as the common @code{_flush_func}, that is, the address of the
27452memory range for which the cache is being flushed, the size of the
27453memory range, and the number 3 (to flush both caches). The default
27454depends on the target GCC was configured for, but commonly is either
27455@code{_flush_func} or @code{__cpu_flush}.
27456
27457@item mbranch-cost=@var{num}
27458@opindex mbranch-cost
27459Set the cost of branches to roughly @var{num} ``simple'' instructions.
27460This cost is only a heuristic and is not guaranteed to produce
27461consistent results across releases. A zero cost redundantly selects
27462the default, which is based on the @option{-mtune} setting.
27463
27464@item -mbranch-likely
27465@itemx -mno-branch-likely
27466@opindex mbranch-likely
27467@opindex mno-branch-likely
27468Enable or disable use of Branch Likely instructions, regardless of the
27469default for the selected architecture. By default, Branch Likely
27470instructions may be generated if they are supported by the selected
27471architecture. An exception is for the MIPS32 and MIPS64 architectures
27472and processors that implement those architectures; for those, Branch
27473Likely instructions are not be generated by default because the MIPS32
27474and MIPS64 architectures specifically deprecate their use.
27475
27476@item -mcompact-branches=never
27477@itemx -mcompact-branches=optimal
27478@itemx -mcompact-branches=always
27479@opindex mcompact-branches=never
27480@opindex mcompact-branches=optimal
27481@opindex mcompact-branches=always
27482These options control which form of branches will be generated. The
27483default is @option{-mcompact-branches=optimal}.
27484
27485The @option{-mcompact-branches=never} option ensures that compact branch
27486instructions will never be generated.
27487
27488The @option{-mcompact-branches=always} option ensures that a compact
27489branch instruction will be generated if available for MIPS Release 6 onwards.
27490If a compact branch instruction is not available (or pre-R6),
27491a delay slot form of the branch will be used instead.
27492
27493If it is used for MIPS16/microMIPS targets, it will be just ignored now.
27494The behaviour for MIPS16/microMIPS may change in future,
27495since they do have some compact branch instructions.
27496
27497The @option{-mcompact-branches=optimal} option will cause a delay slot
27498branch to be used if one is available in the current ISA and the delay
27499slot is successfully filled. If the delay slot is not filled, a compact
27500branch will be chosen if one is available.
27501
27502@item -mfp-exceptions
27503@itemx -mno-fp-exceptions
27504@opindex mfp-exceptions
27505Specifies whether FP exceptions are enabled. This affects how
27506FP instructions are scheduled for some processors.
27507The default is that FP exceptions are
27508enabled.
27509
27510For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
2751164-bit code, then we can use both FP pipes. Otherwise, we can only use one
27512FP pipe.
27513
27514@item -mvr4130-align
27515@itemx -mno-vr4130-align
27516@opindex mvr4130-align
27517The VR4130 pipeline is two-way superscalar, but can only issue two
27518instructions together if the first one is 8-byte aligned. When this
27519option is enabled, GCC aligns pairs of instructions that it
27520thinks should execute in parallel.
27521
27522This option only has an effect when optimizing for the VR4130.
27523It normally makes code faster, but at the expense of making it bigger.
27524It is enabled by default at optimization level @option{-O3}.
27525
27526@item -msynci
27527@itemx -mno-synci
27528@opindex msynci
27529Enable (disable) generation of @code{synci} instructions on
27530architectures that support it. The @code{synci} instructions (if
27531enabled) are generated when @code{__builtin___clear_cache} is
27532compiled.
27533
27534This option defaults to @option{-mno-synci}, but the default can be
27535overridden by configuring GCC with @option{--with-synci}.
27536
27537When compiling code for single processor systems, it is generally safe
27538to use @code{synci}. However, on many multi-core (SMP) systems, it
27539does not invalidate the instruction caches on all cores and may lead
27540to undefined behavior.
27541
27542@item -mrelax-pic-calls
27543@itemx -mno-relax-pic-calls
27544@opindex mrelax-pic-calls
27545Try to turn PIC calls that are normally dispatched via register
27546@code{$25} into direct calls. This is only possible if the linker can
27547resolve the destination at link time and if the destination is within
27548range for a direct call.
27549
27550@option{-mrelax-pic-calls} is the default if GCC was configured to use
27551an assembler and a linker that support the @code{.reloc} assembly
27552directive and @option{-mexplicit-relocs} is in effect. With
27553@option{-mno-explicit-relocs}, this optimization can be performed by the
27554assembler and the linker alone without help from the compiler.
27555
27556@item -mmcount-ra-address
27557@itemx -mno-mcount-ra-address
27558@opindex mmcount-ra-address
27559@opindex mno-mcount-ra-address
27560Emit (do not emit) code that allows @code{_mcount} to modify the
27561calling function's return address. When enabled, this option extends
27562the usual @code{_mcount} interface with a new @var{ra-address}
27563parameter, which has type @code{intptr_t *} and is passed in register
27564@code{$12}. @code{_mcount} can then modify the return address by
27565doing both of the following:
27566@itemize
27567@item
27568Returning the new address in register @code{$31}.
27569@item
27570Storing the new address in @code{*@var{ra-address}},
27571if @var{ra-address} is nonnull.
27572@end itemize
27573
27574The default is @option{-mno-mcount-ra-address}.
27575
27576@item -mframe-header-opt
27577@itemx -mno-frame-header-opt
27578@opindex mframe-header-opt
27579Enable (disable) frame header optimization in the o32 ABI. When using the
27580o32 ABI, calling functions will allocate 16 bytes on the stack for the called
27581function to write out register arguments. When enabled, this optimization
27582will suppress the allocation of the frame header if it can be determined that
27583it is unused.
27584
27585This optimization is off by default at all optimization levels.
27586
27587@item -mlxc1-sxc1
27588@itemx -mno-lxc1-sxc1
27589@opindex mlxc1-sxc1
27590When applicable, enable (disable) the generation of @code{lwxc1},
27591@code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
27592
27593@item -mmadd4
27594@itemx -mno-madd4
27595@opindex mmadd4
27596When applicable, enable (disable) the generation of 4-operand @code{madd.s},
27597@code{madd.d} and related instructions. Enabled by default.
27598
27599@end table
27600
27601@node MMIX Options
27602@subsection MMIX Options
27603@cindex MMIX Options
27604
27605These options are defined for the MMIX:
27606
27607@table @gcctabopt
27608@item -mlibfuncs
27609@itemx -mno-libfuncs
27610@opindex mlibfuncs
27611@opindex mno-libfuncs
27612Specify that intrinsic library functions are being compiled, passing all
27613values in registers, no matter the size.
27614
27615@item -mepsilon
27616@itemx -mno-epsilon
27617@opindex mepsilon
27618@opindex mno-epsilon
27619Generate floating-point comparison instructions that compare with respect
27620to the @code{rE} epsilon register.
27621
27622@item -mabi=mmixware
27623@itemx -mabi=gnu
27624@opindex mabi=mmixware
27625@opindex mabi=gnu
27626Generate code that passes function parameters and return values that (in
27627the called function) are seen as registers @code{$0} and up, as opposed to
27628the GNU ABI which uses global registers @code{$231} and up.
27629
27630@item -mzero-extend
27631@itemx -mno-zero-extend
27632@opindex mzero-extend
27633@opindex mno-zero-extend
27634When reading data from memory in sizes shorter than 64 bits, use (do not
27635use) zero-extending load instructions by default, rather than
27636sign-extending ones.
27637
27638@item -mknuthdiv
27639@itemx -mno-knuthdiv
27640@opindex mknuthdiv
27641@opindex mno-knuthdiv
27642Make the result of a division yielding a remainder have the same sign as
27643the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
27644remainder follows the sign of the dividend. Both methods are
27645arithmetically valid, the latter being almost exclusively used.
27646
27647@item -mtoplevel-symbols
27648@itemx -mno-toplevel-symbols
27649@opindex mtoplevel-symbols
27650@opindex mno-toplevel-symbols
27651Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
27652code can be used with the @code{PREFIX} assembly directive.
27653
27654@item -melf
27655@opindex melf
27656Generate an executable in the ELF format, rather than the default
27657@samp{mmo} format used by the @command{mmix} simulator.
27658
27659@item -mbranch-predict
27660@itemx -mno-branch-predict
27661@opindex mbranch-predict
27662@opindex mno-branch-predict
27663Use (do not use) the probable-branch instructions, when static branch
27664prediction indicates a probable branch.
27665
27666@item -mbase-addresses
27667@itemx -mno-base-addresses
27668@opindex mbase-addresses
27669@opindex mno-base-addresses
27670Generate (do not generate) code that uses @emph{base addresses}. Using a
27671base address automatically generates a request (handled by the assembler
27672and the linker) for a constant to be set up in a global register. The
27673register is used for one or more base address requests within the range 0
27674to 255 from the value held in the register. The generally leads to short
27675and fast code, but the number of different data items that can be
27676addressed is limited. This means that a program that uses lots of static
27677data may require @option{-mno-base-addresses}.
27678
27679@item -msingle-exit
27680@itemx -mno-single-exit
27681@opindex msingle-exit
27682@opindex mno-single-exit
27683Force (do not force) generated code to have a single exit point in each
27684function.
27685@end table
27686
27687@node MN10300 Options
27688@subsection MN10300 Options
27689@cindex MN10300 options
27690
27691These @option{-m} options are defined for Matsushita MN10300 architectures:
27692
27693@table @gcctabopt
27694@item -mmult-bug
27695@opindex mmult-bug
27696Generate code to avoid bugs in the multiply instructions for the MN10300
27697processors. This is the default.
27698
27699@item -mno-mult-bug
27700@opindex mno-mult-bug
27701Do not generate code to avoid bugs in the multiply instructions for the
27702MN10300 processors.
27703
27704@item -mam33
27705@opindex mam33
27706Generate code using features specific to the AM33 processor.
27707
27708@item -mno-am33
27709@opindex mno-am33
27710Do not generate code using features specific to the AM33 processor. This
27711is the default.
27712
27713@item -mam33-2
27714@opindex mam33-2
27715Generate code using features specific to the AM33/2.0 processor.
27716
27717@item -mam34
27718@opindex mam34
27719Generate code using features specific to the AM34 processor.
27720
27721@item -mtune=@var{cpu-type}
27722@opindex mtune
27723Use the timing characteristics of the indicated CPU type when
27724scheduling instructions. This does not change the targeted processor
27725type. The CPU type must be one of @samp{mn10300}, @samp{am33},
27726@samp{am33-2} or @samp{am34}.
27727
27728@item -mreturn-pointer-on-d0
27729@opindex mreturn-pointer-on-d0
27730When generating a function that returns a pointer, return the pointer
27731in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
27732only in @code{a0}, and attempts to call such functions without a prototype
27733result in errors. Note that this option is on by default; use
27734@option{-mno-return-pointer-on-d0} to disable it.
27735
27736@item -mno-crt0
27737@opindex mno-crt0
27738Do not link in the C run-time initialization object file.
27739
27740@item -mrelax
27741@opindex mrelax
27742Indicate to the linker that it should perform a relaxation optimization pass
27743to shorten branches, calls and absolute memory addresses. This option only
27744has an effect when used on the command line for the final link step.
27745
27746This option makes symbolic debugging impossible.
27747
27748@item -mliw
27749@opindex mliw
27750Allow the compiler to generate @emph{Long Instruction Word}
27751instructions if the target is the @samp{AM33} or later. This is the
27752default. This option defines the preprocessor macro @code{__LIW__}.
27753
27754@item -mno-liw
27755@opindex mno-liw
27756Do not allow the compiler to generate @emph{Long Instruction Word}
27757instructions. This option defines the preprocessor macro
27758@code{__NO_LIW__}.
27759
27760@item -msetlb
27761@opindex msetlb
27762Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
27763instructions if the target is the @samp{AM33} or later. This is the
27764default. This option defines the preprocessor macro @code{__SETLB__}.
27765
27766@item -mno-setlb
27767@opindex mno-setlb
27768Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
27769instructions. This option defines the preprocessor macro
27770@code{__NO_SETLB__}.
27771
27772@end table
27773
27774@node Moxie Options
27775@subsection Moxie Options
27776@cindex Moxie Options
27777
27778@table @gcctabopt
27779
27780@item -meb
27781@opindex meb
27782Generate big-endian code. This is the default for @samp{moxie-*-*}
27783configurations.
27784
27785@item -mel
27786@opindex mel
27787Generate little-endian code.
27788
27789@item -mmul.x
27790@opindex mmul.x
27791Generate mul.x and umul.x instructions. This is the default for
27792@samp{moxiebox-*-*} configurations.
27793
27794@item -mno-crt0
27795@opindex mno-crt0
27796Do not link in the C run-time initialization object file.
27797
27798@end table
27799
27800@node MSP430 Options
27801@subsection MSP430 Options
27802@cindex MSP430 Options
27803
27804These options are defined for the MSP430:
27805
27806@table @gcctabopt
27807
27808@item -masm-hex
27809@opindex masm-hex
27810Force assembly output to always use hex constants. Normally such
27811constants are signed decimals, but this option is available for
27812testsuite and/or aesthetic purposes.
27813
27814@item -mmcu=
27815@opindex mmcu=
27816Select the MCU to target. This is used to create a C preprocessor
27817symbol based upon the MCU name, converted to upper case and pre- and
27818post-fixed with @samp{__}. This in turn is used by the
27819@file{msp430.h} header file to select an MCU-specific supplementary
27820header file.
27821
27822The option also sets the ISA to use. If the MCU name is one that is
27823known to only support the 430 ISA then that is selected, otherwise the
27824430X ISA is selected. A generic MCU name of @samp{msp430} can also be
27825used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
27826name selects the 430X ISA.
27827
27828In addition an MCU-specific linker script is added to the linker
27829command line. The script's name is the name of the MCU with
27830@file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
27831command line defines the C preprocessor symbol @code{__XXX__} and
27832cause the linker to search for a script called @file{xxx.ld}.
27833
27834The ISA and hardware multiply supported for the different MCUs is hard-coded
27835into GCC. However, an external @samp{devices.csv} file can be used to
27836extend device support beyond those that have been hard-coded.
27837
27838GCC searches for the @samp{devices.csv} file using the following methods in the
27839given precedence order, where the first method takes precendence over the
27840second which takes precedence over the third.
27841
27842@table @asis
27843@item Include path specified with @code{-I} and @code{-L}
27844@samp{devices.csv} will be searched for in each of the directories specified by
27845include paths and linker library search paths.
27846@item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
27847Define the value of the global environment variable
27848@samp{MSP430_GCC_INCLUDE_DIR}
27849to the full path to the directory containing devices.csv, and GCC will search
27850this directory for devices.csv. If devices.csv is found, this directory will
27851also be registered as an include path, and linker library path. Header files
27852and linker scripts in this directory can therefore be used without manually
27853specifying @code{-I} and @code{-L} on the command line.
27854@item The @samp{msp430-elf@{,bare@}/include/devices} directory
27855Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the
27856toolchain root directory. This directory does not exist in a default
27857installation, but if the user has created it and copied @samp{devices.csv}
27858there, then the MCU data will be read. As above, this directory will
27859also be registered as an include path, and linker library path.
27860
27861@end table
27862If none of the above search methods find @samp{devices.csv}, then the
27863hard-coded MCU data is used.
27864
27865
27866@item -mwarn-mcu
27867@itemx -mno-warn-mcu
27868@opindex mwarn-mcu
27869@opindex mno-warn-mcu
27870This option enables or disables warnings about conflicts between the
27871MCU name specified by the @option{-mmcu} option and the ISA set by the
27872@option{-mcpu} option and/or the hardware multiply support set by the
27873@option{-mhwmult} option. It also toggles warnings about unrecognized
27874MCU names. This option is on by default.
27875
27876@item -mcpu=
27877@opindex mcpu=
27878Specifies the ISA to use. Accepted values are @samp{msp430},
27879@samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
27880@option{-mmcu=} option should be used to select the ISA.
27881
27882@item -msim
27883@opindex msim
27884Link to the simulator runtime libraries and linker script. Overrides
27885any scripts that would be selected by the @option{-mmcu=} option.
27886
27887@item -mlarge
27888@opindex mlarge
27889Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
27890
27891@item -msmall
27892@opindex msmall
27893Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
27894
27895@item -mrelax
27896@opindex mrelax
27897This option is passed to the assembler and linker, and allows the
27898linker to perform certain optimizations that cannot be done until
27899the final link.
27900
27901@item mhwmult=
27902@opindex mhwmult=
27903Describes the type of hardware multiply supported by the target.
27904Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
27905for the original 16-bit-only multiply supported by early MCUs.
27906@samp{32bit} for the 16/32-bit multiply supported by later MCUs and
27907@samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
27908A value of @samp{auto} can also be given. This tells GCC to deduce
27909the hardware multiply support based upon the MCU name provided by the
27910@option{-mmcu} option. If no @option{-mmcu} option is specified or if
27911the MCU name is not recognized then no hardware multiply support is
27912assumed. @code{auto} is the default setting.
27913
27914Hardware multiplies are normally performed by calling a library
27915routine. This saves space in the generated code. When compiling at
27916@option{-O3} or higher however the hardware multiplier is invoked
27917inline. This makes for bigger, but faster code.
27918
27919The hardware multiply routines disable interrupts whilst running and
27920restore the previous interrupt state when they finish. This makes
27921them safe to use inside interrupt handlers as well as in normal code.
27922
27923@item -minrt
27924@opindex minrt
27925Enable the use of a minimum runtime environment - no static
27926initializers or constructors. This is intended for memory-constrained
27927devices. The compiler includes special symbols in some objects
27928that tell the linker and runtime which code fragments are required.
27929
27930@item -mtiny-printf
27931@opindex mtiny-printf
27932Enable reduced code size @code{printf} and @code{puts} library functions.
27933The @samp{tiny} implementations of these functions are not reentrant, so
27934must be used with caution in multi-threaded applications.
27935
27936Support for streams has been removed and the string to be printed will
27937always be sent to stdout via the @code{write} syscall. The string is not
27938buffered before it is sent to write.
27939
27940This option requires Newlib Nano IO, so GCC must be configured with
27941@samp{--enable-newlib-nano-formatted-io}.
27942
27943@item -mmax-inline-shift=
27944@opindex mmax-inline-shift=
27945This option takes an integer between 0 and 64 inclusive, and sets
27946the maximum number of inline shift instructions which should be emitted to
27947perform a shift operation by a constant amount. When this value needs to be
27948exceeded, an mspabi helper function is used instead. The default value is 4.
27949
27950This only affects cases where a shift by multiple positions cannot be
27951completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
27952
27953Shifts of a 32-bit value are at least twice as costly, so the value passed for
27954this option is divided by 2 and the resulting value used instead.
27955
27956@item -mcode-region=
27957@itemx -mdata-region=
27958@opindex mcode-region
27959@opindex mdata-region
27960These options tell the compiler where to place functions and data that
27961do not have one of the @code{lower}, @code{upper}, @code{either} or
27962@code{section} attributes. Possible values are @code{lower},
27963@code{upper}, @code{either} or @code{any}. The first three behave
27964like the corresponding attribute. The fourth possible value -
27965@code{any} - is the default. It leaves placement entirely up to the
27966linker script and how it assigns the standard sections
27967(@code{.text}, @code{.data}, etc) to the memory regions.
27968
27969@item -msilicon-errata=
27970@opindex msilicon-errata
27971This option passes on a request to assembler to enable the fixes for
27972the named silicon errata.
27973
27974@item -msilicon-errata-warn=
27975@opindex msilicon-errata-warn
27976This option passes on a request to the assembler to enable warning
27977messages when a silicon errata might need to be applied.
27978
27979@item -mwarn-devices-csv
27980@itemx -mno-warn-devices-csv
27981@opindex mwarn-devices-csv
27982@opindex mno-warn-devices-csv
27983Warn if @samp{devices.csv} is not found or there are problem parsing it
27984(default: on).
27985
27986@end table
27987
27988@node NDS32 Options
27989@subsection NDS32 Options
27990@cindex NDS32 Options
27991
27992These options are defined for NDS32 implementations:
27993
27994@table @gcctabopt
27995
27996@item -mbig-endian
27997@opindex mbig-endian
27998Generate code in big-endian mode.
27999
28000@item -mlittle-endian
28001@opindex mlittle-endian
28002Generate code in little-endian mode.
28003
28004@item -mreduced-regs
28005@opindex mreduced-regs
28006Use reduced-set registers for register allocation.
28007
28008@item -mfull-regs
28009@opindex mfull-regs
28010Use full-set registers for register allocation.
28011
28012@item -mcmov
28013@opindex mcmov
28014Generate conditional move instructions.
28015
28016@item -mno-cmov
28017@opindex mno-cmov
28018Do not generate conditional move instructions.
28019
28020@item -mext-perf
28021@opindex mext-perf
28022Generate performance extension instructions.
28023
28024@item -mno-ext-perf
28025@opindex mno-ext-perf
28026Do not generate performance extension instructions.
28027
28028@item -mext-perf2
28029@opindex mext-perf2
28030Generate performance extension 2 instructions.
28031
28032@item -mno-ext-perf2
28033@opindex mno-ext-perf2
28034Do not generate performance extension 2 instructions.
28035
28036@item -mext-string
28037@opindex mext-string
28038Generate string extension instructions.
28039
28040@item -mno-ext-string
28041@opindex mno-ext-string
28042Do not generate string extension instructions.
28043
28044@item -mv3push
28045@opindex mv3push
28046Generate v3 push25/pop25 instructions.
28047
28048@item -mno-v3push
28049@opindex mno-v3push
28050Do not generate v3 push25/pop25 instructions.
28051
28052@item -m16-bit
28053@opindex m16-bit
28054Generate 16-bit instructions.
28055
28056@item -mno-16-bit
28057@opindex mno-16-bit
28058Do not generate 16-bit instructions.
28059
28060@item -misr-vector-size=@var{num}
28061@opindex misr-vector-size
28062Specify the size of each interrupt vector, which must be 4 or 16.
28063
28064@item -mcache-block-size=@var{num}
28065@opindex mcache-block-size
28066Specify the size of each cache block,
28067which must be a power of 2 between 4 and 512.
28068
28069@item -march=@var{arch}
28070@opindex march
28071Specify the name of the target architecture.
28072
28073@item -mcmodel=@var{code-model}
28074@opindex mcmodel
28075Set the code model to one of
28076@table @asis
28077@item @samp{small}
28078All the data and read-only data segments must be within 512KB addressing space.
28079The text segment must be within 16MB addressing space.
28080@item @samp{medium}
28081The data segment must be within 512KB while the read-only data segment can be
28082within 4GB addressing space. The text segment should be still within 16MB
28083addressing space.
28084@item @samp{large}
28085All the text and data segments can be within 4GB addressing space.
28086@end table
28087
28088@item -mctor-dtor
28089@opindex mctor-dtor
28090Enable constructor/destructor feature.
28091
28092@item -mrelax
28093@opindex mrelax
28094Guide linker to relax instructions.
28095
28096@end table
28097
28098@node Nios II Options
28099@subsection Nios II Options
28100@cindex Nios II options
28101@cindex Altera Nios II options
28102
28103These are the options defined for the Altera Nios II processor.
28104
28105@table @gcctabopt
28106
28107@item -G @var{num}
28108@opindex G
28109@cindex smaller data references
28110Put global and static objects less than or equal to @var{num} bytes
28111into the small data or BSS sections instead of the normal data or BSS
28112sections. The default value of @var{num} is 8.
28113
28114@item -mgpopt=@var{option}
28115@itemx -mgpopt
28116@itemx -mno-gpopt
28117@opindex mgpopt
28118@opindex mno-gpopt
28119Generate (do not generate) GP-relative accesses. The following
28120@var{option} names are recognized:
28121
28122@table @samp
28123
28124@item none
28125Do not generate GP-relative accesses.
28126
28127@item local
28128Generate GP-relative accesses for small data objects that are not
28129external, weak, or uninitialized common symbols.
28130Also use GP-relative addressing for objects that
28131have been explicitly placed in a small data section via a @code{section}
28132attribute.
28133
28134@item global
28135As for @samp{local}, but also generate GP-relative accesses for
28136small data objects that are external, weak, or common. If you use this option,
28137you must ensure that all parts of your program (including libraries) are
28138compiled with the same @option{-G} setting.
28139
28140@item data
28141Generate GP-relative accesses for all data objects in the program. If you
28142use this option, the entire data and BSS segments
28143of your program must fit in 64K of memory and you must use an appropriate
28144linker script to allocate them within the addressable range of the
28145global pointer.
28146
28147@item all
28148Generate GP-relative addresses for function pointers as well as data
28149pointers. If you use this option, the entire text, data, and BSS segments
28150of your program must fit in 64K of memory and you must use an appropriate
28151linker script to allocate them within the addressable range of the
28152global pointer.
28153
28154@end table
28155
28156@option{-mgpopt} is equivalent to @option{-mgpopt=local}, and
28157@option{-mno-gpopt} is equivalent to @option{-mgpopt=none}.
28158
28159The default is @option{-mgpopt} except when @option{-fpic} or
28160@option{-fPIC} is specified to generate position-independent code.
28161Note that the Nios II ABI does not permit GP-relative accesses from
28162shared libraries.
28163
28164You may need to specify @option{-mno-gpopt} explicitly when building
28165programs that include large amounts of small data, including large
28166GOT data sections. In this case, the 16-bit offset for GP-relative
28167addressing may not be large enough to allow access to the entire
28168small data section.
28169
28170@item -mgprel-sec=@var{regexp}
28171@opindex mgprel-sec
28172This option specifies additional section names that can be accessed via
28173GP-relative addressing. It is most useful in conjunction with
28174@code{section} attributes on variable declarations
28175(@pxref{Common Variable Attributes}) and a custom linker script.
28176The @var{regexp} is a POSIX Extended Regular Expression.
28177
28178This option does not affect the behavior of the @option{-G} option, and
28179the specified sections are in addition to the standard @code{.sdata}
28180and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}.
28181
28182@item -mr0rel-sec=@var{regexp}
28183@opindex mr0rel-sec
28184This option specifies names of sections that can be accessed via a
2818516-bit offset from @code{r0}; that is, in the low 32K or high 32K
28186of the 32-bit address space. It is most useful in conjunction with
28187@code{section} attributes on variable declarations
28188(@pxref{Common Variable Attributes}) and a custom linker script.
28189The @var{regexp} is a POSIX Extended Regular Expression.
28190
28191In contrast to the use of GP-relative addressing for small data,
28192zero-based addressing is never generated by default and there are no
28193conventional section names used in standard linker scripts for sections
28194in the low or high areas of memory.
28195
28196@item -mel
28197@itemx -meb
28198@opindex mel
28199@opindex meb
28200Generate little-endian (default) or big-endian (experimental) code,
28201respectively.
28202
28203@item -march=@var{arch}
28204@opindex march
28205This specifies the name of the target Nios II architecture. GCC uses this
28206name to determine what kind of instructions it can emit when generating
28207assembly code. Permissible names are: @samp{r1}, @samp{r2}.
28208
28209The preprocessor macro @code{__nios2_arch__} is available to programs,
28210with value 1 or 2, indicating the targeted ISA level.
28211
28212@item -mbypass-cache
28213@itemx -mno-bypass-cache
28214@opindex mno-bypass-cache
28215@opindex mbypass-cache
28216Force all load and store instructions to always bypass cache by
28217using I/O variants of the instructions. The default is not to
28218bypass the cache.
28219
28220@item -mno-cache-volatile
28221@itemx -mcache-volatile
28222@opindex mcache-volatile
28223@opindex mno-cache-volatile
28224Volatile memory access bypass the cache using the I/O variants of
28225the load and store instructions. The default is not to bypass the cache.
28226
28227@item -mno-fast-sw-div
28228@itemx -mfast-sw-div
28229@opindex mno-fast-sw-div
28230@opindex mfast-sw-div
28231Do not use table-based fast divide for small numbers. The default
28232is to use the fast divide at @option{-O3} and above.
28233
28234@item -mno-hw-mul
28235@itemx -mhw-mul
28236@itemx -mno-hw-mulx
28237@itemx -mhw-mulx
28238@itemx -mno-hw-div
28239@itemx -mhw-div
28240@opindex mno-hw-mul
28241@opindex mhw-mul
28242@opindex mno-hw-mulx
28243@opindex mhw-mulx
28244@opindex mno-hw-div
28245@opindex mhw-div
28246Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
28247instructions by the compiler. The default is to emit @code{mul}
28248and not emit @code{div} and @code{mulx}.
28249
28250@item -mbmx
28251@itemx -mno-bmx
28252@itemx -mcdx
28253@itemx -mno-cdx
28254Enable or disable generation of Nios II R2 BMX (bit manipulation) and
28255CDX (code density) instructions. Enabling these instructions also
28256requires @option{-march=r2}. Since these instructions are optional
28257extensions to the R2 architecture, the default is not to emit them.
28258
28259@item -mcustom-@var{insn}=@var{N}
28260@itemx -mno-custom-@var{insn}
28261@opindex mcustom-@var{insn}
28262@opindex mno-custom-@var{insn}
28263Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a
28264custom instruction with encoding @var{N} when generating code that uses
28265@var{insn}. For example, @option{-mcustom-fadds=253} generates custom
28266instruction 253 for single-precision floating-point add operations instead
28267of the default behavior of using a library call.
28268
28269The following values of @var{insn} are supported. Except as otherwise
28270noted, floating-point operations are expected to be implemented with
28271normal IEEE 754 semantics and correspond directly to the C operators or the
28272equivalent GCC built-in functions (@pxref{Other Builtins}).
28273
28274Single-precision floating point:
28275@table @asis
28276
28277@item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls}
28278Binary arithmetic operations.
28279
28280@item @samp{fnegs}
28281Unary negation.
28282
28283@item @samp{fabss}
28284Unary absolute value.
28285
28286@item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes}
28287Comparison operations.
28288
28289@item @samp{fmins}, @samp{fmaxs}
28290Floating-point minimum and maximum. These instructions are only
28291generated if @option{-ffinite-math-only} is specified.
28292
28293@item @samp{fsqrts}
28294Unary square root operation.
28295
28296@item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs}
28297Floating-point trigonometric and exponential functions. These instructions
28298are only generated if @option{-funsafe-math-optimizations} is also specified.
28299
28300@end table
28301
28302Double-precision floating point:
28303@table @asis
28304
28305@item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld}
28306Binary arithmetic operations.
28307
28308@item @samp{fnegd}
28309Unary negation.
28310
28311@item @samp{fabsd}
28312Unary absolute value.
28313
28314@item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned}
28315Comparison operations.
28316
28317@item @samp{fmind}, @samp{fmaxd}
28318Double-precision minimum and maximum. These instructions are only
28319generated if @option{-ffinite-math-only} is specified.
28320
28321@item @samp{fsqrtd}
28322Unary square root operation.
28323
28324@item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd}
28325Double-precision trigonometric and exponential functions. These instructions
28326are only generated if @option{-funsafe-math-optimizations} is also specified.
28327
28328@end table
28329
28330Conversions:
28331@table @asis
28332@item @samp{fextsd}
28333Conversion from single precision to double precision.
28334
28335@item @samp{ftruncds}
28336Conversion from double precision to single precision.
28337
28338@item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu}
28339Conversion from floating point to signed or unsigned integer types, with
28340truncation towards zero.
28341
28342@item @samp{round}
28343Conversion from single-precision floating point to signed integer,
28344rounding to the nearest integer and ties away from zero.
28345This corresponds to the @code{__builtin_lroundf} function when
28346@option{-fno-math-errno} is used.
28347
28348@item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud}
28349Conversion from signed or unsigned integer types to floating-point types.
28350
28351@end table
28352
28353In addition, all of the following transfer instructions for internal
28354registers X and Y must be provided to use any of the double-precision
28355floating-point instructions. Custom instructions taking two
28356double-precision source operands expect the first operand in the
2835764-bit register X. The other operand (or only operand of a unary
28358operation) is given to the custom arithmetic instruction with the
28359least significant half in source register @var{src1} and the most
28360significant half in @var{src2}. A custom instruction that returns a
28361double-precision result returns the most significant 32 bits in the
28362destination register and the other half in 32-bit register Y.
28363GCC automatically generates the necessary code sequences to write
28364register X and/or read register Y when double-precision floating-point
28365instructions are used.
28366
28367@table @asis
28368
28369@item @samp{fwrx}
28370Write @var{src1} into the least significant half of X and @var{src2} into
28371the most significant half of X.
28372
28373@item @samp{fwry}
28374Write @var{src1} into Y.
28375
28376@item @samp{frdxhi}, @samp{frdxlo}
28377Read the most or least (respectively) significant half of X and store it in
28378@var{dest}.
28379
28380@item @samp{frdy}
28381Read the value of Y and store it into @var{dest}.
28382@end table
28383
28384Note that you can gain more local control over generation of Nios II custom
28385instructions by using the @code{target("custom-@var{insn}=@var{N}")}
28386and @code{target("no-custom-@var{insn}")} function attributes
28387(@pxref{Function Attributes})
28388or pragmas (@pxref{Function Specific Option Pragmas}).
28389
28390@item -mcustom-fpu-cfg=@var{name}
28391@opindex mcustom-fpu-cfg
28392
28393This option enables a predefined, named set of custom instruction encodings
28394(see @option{-mcustom-@var{insn}} above).
28395Currently, the following sets are defined:
28396
28397@option{-mcustom-fpu-cfg=60-1} is equivalent to:
28398@gccoptlist{-mcustom-fmuls=252 @gol
28399-mcustom-fadds=253 @gol
28400-mcustom-fsubs=254 @gol
28401-fsingle-precision-constant}
28402
28403@option{-mcustom-fpu-cfg=60-2} is equivalent to:
28404@gccoptlist{-mcustom-fmuls=252 @gol
28405-mcustom-fadds=253 @gol
28406-mcustom-fsubs=254 @gol
28407-mcustom-fdivs=255 @gol
28408-fsingle-precision-constant}
28409
28410@option{-mcustom-fpu-cfg=72-3} is equivalent to:
28411@gccoptlist{-mcustom-floatus=243 @gol
28412-mcustom-fixsi=244 @gol
28413-mcustom-floatis=245 @gol
28414-mcustom-fcmpgts=246 @gol
28415-mcustom-fcmples=249 @gol
28416-mcustom-fcmpeqs=250 @gol
28417-mcustom-fcmpnes=251 @gol
28418-mcustom-fmuls=252 @gol
28419-mcustom-fadds=253 @gol
28420-mcustom-fsubs=254 @gol
28421-mcustom-fdivs=255 @gol
28422-fsingle-precision-constant}
28423
28424@option{-mcustom-fpu-cfg=fph2} is equivalent to:
28425@gccoptlist{-mcustom-fabss=224 @gol
28426-mcustom-fnegs=225 @gol
28427-mcustom-fcmpnes=226 @gol
28428-mcustom-fcmpeqs=227 @gol
28429-mcustom-fcmpges=228 @gol
28430-mcustom-fcmpgts=229 @gol
28431-mcustom-fcmples=230 @gol
28432-mcustom-fcmplts=231 @gol
28433-mcustom-fmaxs=232 @gol
28434-mcustom-fmins=233 @gol
28435-mcustom-round=248 @gol
28436-mcustom-fixsi=249 @gol
28437-mcustom-floatis=250 @gol
28438-mcustom-fsqrts=251 @gol
28439-mcustom-fmuls=252 @gol
28440-mcustom-fadds=253 @gol
28441-mcustom-fsubs=254 @gol
28442-mcustom-fdivs=255 @gol}
28443
28444Custom instruction assignments given by individual
28445@option{-mcustom-@var{insn}=} options override those given by
28446@option{-mcustom-fpu-cfg=}, regardless of the
28447order of the options on the command line.
28448
28449Note that you can gain more local control over selection of a FPU
28450configuration by using the @code{target("custom-fpu-cfg=@var{name}")}
28451function attribute (@pxref{Function Attributes})
28452or pragma (@pxref{Function Specific Option Pragmas}).
28453
28454The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point
28455Hardware 2 Component}. Please note that the custom instructions enabled by
28456@option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated
28457if @option{-ffinite-math-only} is specified. The custom instruction enabled by
28458@option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is
28459specified. In contrast to the other configurations,
28460@option{-fsingle-precision-constant} is not set.
28461
28462@end table
28463
28464These additional @samp{-m} options are available for the Altera Nios II
28465ELF (bare-metal) target:
28466
28467@table @gcctabopt
28468
28469@item -mhal
28470@opindex mhal
28471Link with HAL BSP. This suppresses linking with the GCC-provided C runtime
28472startup and termination code, and is typically used in conjunction with
28473@option{-msys-crt0=} to specify the location of the alternate startup code
28474provided by the HAL BSP.
28475
28476@item -msmallc
28477@opindex msmallc
28478Link with a limited version of the C library, @option{-lsmallc}, rather than
28479Newlib.
28480
28481@item -msys-crt0=@var{startfile}
28482@opindex msys-crt0
28483@var{startfile} is the file name of the startfile (crt0) to use
28484when linking. This option is only useful in conjunction with @option{-mhal}.
28485
28486@item -msys-lib=@var{systemlib}
28487@opindex msys-lib
28488@var{systemlib} is the library name of the library that provides
28489low-level system calls required by the C library,
28490e.g.@: @code{read} and @code{write}.
28491This option is typically used to link with a library provided by a HAL BSP.
28492
28493@end table
28494
28495@node Nvidia PTX Options
28496@subsection Nvidia PTX Options
28497@cindex Nvidia PTX options
28498@cindex nvptx options
28499
28500These options are defined for Nvidia PTX:
28501
28502@table @gcctabopt
28503
28504@item -m64
28505@opindex m64
28506Ignored, but preserved for backward compatibility. Only 64-bit ABI is
28507supported.
28508
28509@item -march=@var{architecture-string}
28510@opindex march
28511Generate code for the specified PTX ISA target architecture
28512(e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30},
28513@samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and
28514@samp{sm_80}.
28515The default depends on how the compiler has been configured, see
28516@option{--with-arch}.
28517
28518This option sets the value of the preprocessor macro
28519@code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value
28520@samp{350}.
28521
28522@item -misa=@var{architecture-string}
28523@opindex misa
28524Alias of @option{-march=}.
28525
28526@item -march-map=@var{architecture-string}
28527@opindex march
28528Select the closest available @option{-march=} value that is not more
28529capable. For instance, for @option{-march-map=sm_50} select
28530@option{-march=sm_35}, and for @option{-march-map=sm_53} select
28531@option{-march=sm_53}.
28532
28533@item -mptx=@var{version-string}
28534@opindex mptx
28535Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}).
28536Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and
28537@samp{7.0}. The default PTX ISA version is 6.0, unless a higher
28538version is required for specified PTX ISA target architecture via
28539option @option{-march=}.
28540
28541This option sets the values of the preprocessor macros
28542@code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__};
28543for instance, for @samp{3.1} the macros have the values @samp{3} and
28544@samp{1}, respectively.
28545
28546@item -mmainkernel
28547@opindex mmainkernel
28548Link in code for a __main kernel. This is for stand-alone instead of
28549offloading execution.
28550
28551@item -moptimize
28552@opindex moptimize
28553Apply partitioned execution optimizations. This is the default when any
28554level of optimization is selected.
28555
28556@item -msoft-stack
28557@opindex msoft-stack
28558Generate code that does not use @code{.local} memory
28559directly for stack storage. Instead, a per-warp stack pointer is
28560maintained explicitly. This enables variable-length stack allocation (with
28561variable-length arrays or @code{alloca}), and when global memory is used for
28562underlying storage, makes it possible to access automatic variables from other
28563threads, or with atomic instructions. This code generation variant is used
28564for OpenMP offloading, but the option is exposed on its own for the purpose
28565of testing the compiler; to generate code suitable for linking into programs
28566using OpenMP offloading, use option @option{-mgomp}.
28567
28568@item -muniform-simt
28569@opindex muniform-simt
28570Switch to code generation variant that allows to execute all threads in each
28571warp, while maintaining memory state and side effects as if only one thread
28572in each warp was active outside of OpenMP SIMD regions. All atomic operations
28573and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
28574current lane index equals the master lane index), and the register being
28575assigned is copied via a shuffle instruction from the master lane. Outside of
28576SIMD regions lane 0 is the master; inside, each thread sees itself as the
28577master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
28578all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
28579regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
28580with current lane index to compute the master lane index.
28581
28582@item -mgomp
28583@opindex mgomp
28584Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
28585@option{-muniform-simt} options, and selects corresponding multilib variant.
28586
28587@end table
28588
28589@node OpenRISC Options
28590@subsection OpenRISC Options
28591@cindex OpenRISC Options
28592
28593These options are defined for OpenRISC:
28594
28595@table @gcctabopt
28596
28597@item -mboard=@var{name}
28598@opindex mboard
28599Configure a board specific runtime. This will be passed to the linker for
28600newlib board library linking. The default is @code{or1ksim}.
28601
28602@item -mnewlib
28603@opindex mnewlib
28604This option is ignored; it is for compatibility purposes only. This used to
28605select linker and preprocessor options for use with newlib.
28606
28607@item -msoft-div
28608@itemx -mhard-div
28609@opindex msoft-div
28610@opindex mhard-div
28611Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
28612This default is hardware divide.
28613
28614@item -msoft-mul
28615@itemx -mhard-mul
28616@opindex msoft-mul
28617@opindex mhard-mul
28618Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
28619This default is hardware multiply.
28620
28621@item -msoft-float
28622@itemx -mhard-float
28623@opindex msoft-float
28624@opindex mhard-float
28625Select software or hardware for floating point operations.
28626The default is software.
28627
28628@item -mdouble-float
28629@opindex mdouble-float
28630When @option{-mhard-float} is selected, enables generation of double-precision
28631floating point instructions. By default functions from @file{libgcc} are used
28632to perform double-precision floating point operations.
28633
28634@item -munordered-float
28635@opindex munordered-float
28636When @option{-mhard-float} is selected, enables generation of unordered
28637floating point compare and set flag (@code{lf.sfun*}) instructions. By default
28638functions from @file{libgcc} are used to perform unordered floating point
28639compare and set flag operations.
28640
28641@item -mcmov
28642@opindex mcmov
28643Enable generation of conditional move (@code{l.cmov}) instructions. By
28644default the equivalent will be generated using set and branch.
28645
28646@item -mror
28647@opindex mror
28648Enable generation of rotate right (@code{l.ror}) instructions. By default
28649functions from @file{libgcc} are used to perform rotate right operations.
28650
28651@item -mrori
28652@opindex mrori
28653Enable generation of rotate right with immediate (@code{l.rori}) instructions.
28654By default functions from @file{libgcc} are used to perform rotate right with
28655immediate operations.
28656
28657@item -msext
28658@opindex msext
28659Enable generation of sign extension (@code{l.ext*}) instructions. By default
28660memory loads are used to perform sign extension.
28661
28662@item -msfimm
28663@opindex msfimm
28664Enable generation of compare and set flag with immediate (@code{l.sf*i})
28665instructions. By default extra instructions will be generated to store the
28666immediate to a register first.
28667
28668@item -mshftimm
28669@opindex mshftimm
28670Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
28671@code{l.slli}) instructions. By default extra instructions will be generated
28672to store the immediate to a register first.
28673
28674@item -mcmodel=small
28675@opindex mcmodel=small
28676Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
28677the default model.
28678
28679@item -mcmodel=large
28680@opindex mcmodel=large
28681Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
28682
28683
28684@end table
28685
28686@node PDP-11 Options
28687@subsection PDP-11 Options
28688@cindex PDP-11 Options
28689
28690These options are defined for the PDP-11:
28691
28692@table @gcctabopt
28693@item -mfpu
28694@opindex mfpu
28695Use hardware FPP floating point. This is the default. (FIS floating
28696point on the PDP-11/40 is not supported.) Implies -m45.
28697
28698@item -msoft-float
28699@opindex msoft-float
28700Do not use hardware floating point.
28701
28702@item -mac0
28703@opindex mac0
28704Return floating-point results in ac0 (fr0 in Unix assembler syntax).
28705
28706@item -mno-ac0
28707@opindex mno-ac0
28708Return floating-point results in memory. This is the default.
28709
28710@item -m40
28711@opindex m40
28712Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
28713
28714@item -m45
28715@opindex m45
28716Generate code for a PDP-11/45. This is the default.
28717
28718@item -m10
28719@opindex m10
28720Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
28721
28722@item -mint16
28723@itemx -mno-int32
28724@opindex mint16
28725@opindex mno-int32
28726Use 16-bit @code{int}. This is the default.
28727
28728@item -mint32
28729@itemx -mno-int16
28730@opindex mint32
28731@opindex mno-int16
28732Use 32-bit @code{int}.
28733
28734@item -msplit
28735@opindex msplit
28736Target has split instruction and data space. Implies -m45.
28737
28738@item -munix-asm
28739@opindex munix-asm
28740Use Unix assembler syntax.
28741
28742@item -mdec-asm
28743@opindex mdec-asm
28744Use DEC assembler syntax.
28745
28746@item -mgnu-asm
28747@opindex mgnu-asm
28748Use GNU assembler syntax. This is the default.
28749
28750@item -mlra
28751@opindex mlra
28752Use the new LRA register allocator. By default, the old ``reload''
28753allocator is used.
28754@end table
28755
d77de738
ML
28756@node PowerPC Options
28757@subsection PowerPC Options
28758@cindex PowerPC options
28759
28760These are listed under @xref{RS/6000 and PowerPC Options}.
28761
28762@node PRU Options
28763@subsection PRU Options
28764@cindex PRU Options
28765
28766These command-line options are defined for PRU target:
28767
28768@table @gcctabopt
28769@item -minrt
28770@opindex minrt
28771Link with a minimum runtime environment, with no support for static
28772initializers and constructors. Using this option can significantly reduce
28773the size of the final ELF binary. Beware that the compiler could still
28774generate code with static initializers and constructors. It is up to the
28775programmer to ensure that the source program will not use those features.
28776
28777@item -mmcu=@var{mcu}
28778@opindex mmcu
28779Specify the PRU MCU variant to use. Check Newlib for the exact list of
28780supported MCUs.
28781
28782@item -mno-relax
28783@opindex mno-relax
28784Make GCC pass the @option{--no-relax} command-line option to the linker
28785instead of the @option{--relax} option.
28786
28787@item -mloop
28788@opindex mloop
28789Allow (or do not allow) GCC to use the LOOP instruction.
28790
28791@item -mabi=@var{variant}
28792@opindex mabi
28793Specify the ABI variant to output code for. @option{-mabi=ti} selects the
28794unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
28795more naturally with certain GCC assumptions. These are the differences:
28796
28797@table @samp
28798@item Function Pointer Size
28799TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
28800supports only 32-bit data and code pointers.
28801
28802@item Optional Return Value Pointer
28803Function return values larger than 64 bits are passed by using a hidden
28804pointer as the first argument of the function. TI ABI, though, mandates that
28805the pointer can be NULL in case the caller is not using the returned value.
28806GNU always passes and expects a valid return value pointer.
28807
28808@end table
28809
28810The current @option{-mabi=ti} implementation simply raises a compile error
28811when any of the above code constructs is detected. As a consequence
28812the standard C library cannot be built and it is omitted when linking with
28813@option{-mabi=ti}.
28814
28815Relaxation is a GNU feature and for safety reasons is disabled when using
28816@option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
28817instructions, so the GNU linker cannot adjust them when shortening adjacent
28818LDI32 pseudo instructions.
28819
28820@end table
28821
28822@node RISC-V Options
28823@subsection RISC-V Options
28824@cindex RISC-V Options
28825
28826These command-line options are defined for RISC-V targets:
28827
28828@table @gcctabopt
28829@item -mbranch-cost=@var{n}
28830@opindex mbranch-cost
28831Set the cost of branches to roughly @var{n} instructions.
28832
28833@item -mplt
28834@itemx -mno-plt
28835@opindex plt
28836When generating PIC code, do or don't allow the use of PLTs. Ignored for
28837non-PIC. The default is @option{-mplt}.
28838
28839@item -mabi=@var{ABI-string}
28840@opindex mabi
28841Specify integer and floating-point calling convention. @var{ABI-string}
28842contains two parts: the size of integer types and the registers used for
28843floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
28844@samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
2884532-bit), and that floating-point values up to 64 bits wide are passed in F
28846registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
28847allows the compiler to generate code that uses the F and D extensions but only
28848allows floating-point values up to 32 bits long to be passed in registers; or
28849@samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
28850passed in registers.
28851
28852The default for this argument is system dependent, users who want a specific
28853calling convention should specify one explicitly. The valid calling
28854conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
28855@samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
28856implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
28857invalid because the ABI requires 64-bit values be passed in F registers, but F
28858registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can
28859only be used with the @samp{rv32e} architecture. This ABI is not well
28860specified at present, and is subject to change.
28861
28862@item -mfdiv
28863@itemx -mno-fdiv
28864@opindex mfdiv
28865Do or don't use hardware floating-point divide and square root instructions.
28866This requires the F or D extensions for floating-point registers. The default
28867is to use them if the specified architecture has these instructions.
28868
28869@item -mdiv
28870@itemx -mno-div
28871@opindex mdiv
28872Do or don't use hardware instructions for integer division. This requires the
28873M extension. The default is to use them if the specified architecture has
28874these instructions.
28875
28876@item -misa-spec=@var{ISA-spec-string}
28877@opindex misa-spec
28878Specify the version of the RISC-V Unprivileged (formerly User-Level)
28879ISA specification to produce code conforming to. The possibilities
28880for @var{ISA-spec-string} are:
28881@table @code
28882@item 2.2
28883Produce code conforming to version 2.2.
28884@item 20190608
28885Produce code conforming to version 20190608.
28886@item 20191213
28887Produce code conforming to version 20191213.
28888@end table
28889The default is @option{-misa-spec=20191213} unless GCC has been configured
28890with @option{--with-isa-spec=} specifying a different default version.
28891
28892@item -march=@var{ISA-string}
28893@opindex march
28894Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be
28895lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and
28896@samp{rv32imaf}.
28897
28898When @option{-march=} is not specified, use the setting from @option{-mcpu}.
28899
28900If both @option{-march} and @option{-mcpu=} are not specified, the default for
28901this argument is system dependent, users who want a specific architecture
28902extensions should specify one explicitly.
28903
28904@item -mcpu=@var{processor-string}
28905@opindex mcpu
28906Use architecture of and optimize the output for the given processor, specified
28907by particular CPU name.
28908Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21},
28909@samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76},
28910@samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76},
aa37a91c 28911@samp{sifive-u54}, and @samp{sifive-u74}.
d77de738
ML
28912
28913@item -mtune=@var{processor-string}
28914@opindex mtune
28915Optimize the output for the given processor, specified by microarchitecture or
28916particular CPU name. Permissible values for this option are: @samp{rocket},
28917@samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series},
aa37a91c 28918@samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}.
d77de738
ML
28919
28920When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
28921the default is @samp{rocket} if both are not specified.
28922
28923The @samp{size} choice is not intended for use by end-users. This is used
28924when @option{-Os} is specified. It overrides the instruction cost info
28925provided by @option{-mtune=}, but does not override the pipeline info. This
28926helps reduce code size while still giving good performance.
28927
28928@item -mpreferred-stack-boundary=@var{num}
28929@opindex mpreferred-stack-boundary
28930Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
28931byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
28932the default is 4 (16 bytes or 128-bits).
28933
28934@strong{Warning:} If you use this switch, then you must build all modules with
28935the same value, including any libraries. This includes the system libraries
28936and startup modules.
28937
28938@item -msmall-data-limit=@var{n}
28939@opindex msmall-data-limit
28940Put global and static data smaller than @var{n} bytes into a special section
28941(on some targets).
28942
28943@item -msave-restore
28944@itemx -mno-save-restore
28945@opindex msave-restore
28946Do or don't use smaller but slower prologue and epilogue code that uses
28947library function calls. The default is to use fast inline prologues and
28948epilogues.
28949
28950@item -mshorten-memrefs
28951@itemx -mno-shorten-memrefs
28952@opindex mshorten-memrefs
28953Do or do not attempt to make more use of compressed load/store instructions by
28954replacing a load/store of 'base register + large offset' with a new load/store
28955of 'new base + small offset'. If the new base gets stored in a compressed
28956register, then the new load/store can be compressed. Currently targets 32-bit
28957integer load/stores only.
28958
28959@item -mstrict-align
28960@itemx -mno-strict-align
28961@opindex mstrict-align
28962Do not or do generate unaligned memory accesses. The default is set depending
28963on whether the processor we are optimizing for supports fast unaligned access
28964or not.
28965
28966@item -mcmodel=medlow
28967@opindex mcmodel=medlow
28968Generate code for the medium-low code model. The program and its statically
28969defined symbols must lie within a single 2 GiB address range and must lie
28970between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be
28971statically or dynamically linked. This is the default code model.
28972
28973@item -mcmodel=medany
28974@opindex mcmodel=medany
28975Generate code for the medium-any code model. The program and its statically
28976defined symbols must be within any single 2 GiB address range. Programs can be
28977statically or dynamically linked.
28978
28979The code generated by the medium-any code model is position-independent, but is
28980not guaranteed to function correctly when linked into position-independent
28981executables or libraries.
28982
28983@item -mexplicit-relocs
28984@itemx -mno-exlicit-relocs
28985Use or do not use assembler relocation operators when dealing with symbolic
28986addresses. The alternative is to use assembler macros instead, which may
28987limit optimization.
28988
28989@item -mrelax
28990@itemx -mno-relax
28991@opindex mrelax
28992Take advantage of linker relaxations to reduce the number of instructions
28993required to materialize symbol addresses. The default is to take advantage of
28994linker relaxations.
28995
28996@item -mriscv-attribute
28997@itemx -mno-riscv-attribute
28998@opindex mriscv-attribute
28999Emit (do not emit) RISC-V attribute to record extra information into ELF
29000objects. This feature requires at least binutils 2.32.
29001
29002@item -mcsr-check
29003@itemx -mno-csr-check
29004@opindex mcsr-check
29005Enables or disables the CSR checking.
29006
29007@item -malign-data=@var{type}
29008@opindex malign-data
29009Control how GCC aligns variables and constants of array, structure, or union
29010types. Supported values for @var{type} are @samp{xlen} which uses x register
29011width as the alignment value, and @samp{natural} which uses natural alignment.
29012@samp{xlen} is the default.
29013
29014@item -mbig-endian
29015@opindex mbig-endian
29016Generate big-endian code. This is the default when GCC is configured for a
29017@samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
29018
29019@item -mlittle-endian
29020@opindex mlittle-endian
29021Generate little-endian code. This is the default when GCC is configured for a
29022@samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
29023@samp{riscv32be-*-*} target.
29024
29025@item -mstack-protector-guard=@var{guard}
29026@itemx -mstack-protector-guard-reg=@var{reg}
29027@itemx -mstack-protector-guard-offset=@var{offset}
29028@opindex mstack-protector-guard
29029@opindex mstack-protector-guard-reg
29030@opindex mstack-protector-guard-offset
29031Generate stack protection code using canary at @var{guard}. Supported
29032locations are @samp{global} for a global canary or @samp{tls} for per-thread
29033canary in the TLS block.
29034
29035With the latter choice the options
29036@option{-mstack-protector-guard-reg=@var{reg}} and
29037@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
29038which register to use as base register for reading the canary,
29039and from what offset from that base register. There is no default
29040register or offset as this is entirely for use within the Linux
29041kernel.
29042@end table
29043
29044@node RL78 Options
29045@subsection RL78 Options
29046@cindex RL78 Options
29047
29048@table @gcctabopt
29049
29050@item -msim
29051@opindex msim
29052Links in additional target libraries to support operation within a
29053simulator.
29054
29055@item -mmul=none
29056@itemx -mmul=g10
29057@itemx -mmul=g13
29058@itemx -mmul=g14
29059@itemx -mmul=rl78
29060@opindex mmul
29061Specifies the type of hardware multiplication and division support to
29062be used. The simplest is @code{none}, which uses software for both
29063multiplication and division. This is the default. The @code{g13}
29064value is for the hardware multiply/divide peripheral found on the
29065RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
29066the multiplication and division instructions supported by the RL78/G14
29067(S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
29068the value @code{mg10} is an alias for @code{none}.
29069
29070In addition a C preprocessor macro is defined, based upon the setting
29071of this option. Possible values are: @code{__RL78_MUL_NONE__},
29072@code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
29073
29074@item -mcpu=g10
29075@itemx -mcpu=g13
29076@itemx -mcpu=g14
29077@itemx -mcpu=rl78
29078@opindex mcpu
29079Specifies the RL78 core to target. The default is the G14 core, also
29080known as an S3 core or just RL78. The G13 or S2 core does not have
29081multiply or divide instructions, instead it uses a hardware peripheral
29082for these operations. The G10 or S1 core does not have register
29083banks, so it uses a different calling convention.
29084
29085If this option is set it also selects the type of hardware multiply
29086support to use, unless this is overridden by an explicit
29087@option{-mmul=none} option on the command line. Thus specifying
29088@option{-mcpu=g13} enables the use of the G13 hardware multiply
29089peripheral and specifying @option{-mcpu=g10} disables the use of
29090hardware multiplications altogether.
29091
29092Note, although the RL78/G14 core is the default target, specifying
29093@option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
29094change the behavior of the toolchain since it also enables G14
29095hardware multiply support. If these options are not specified on the
29096command line then software multiplication routines will be used even
29097though the code targets the RL78 core. This is for backwards
29098compatibility with older toolchains which did not have hardware
29099multiply and divide support.
29100
29101In addition a C preprocessor macro is defined, based upon the setting
29102of this option. Possible values are: @code{__RL78_G10__},
29103@code{__RL78_G13__} or @code{__RL78_G14__}.
29104
29105@item -mg10
29106@itemx -mg13
29107@itemx -mg14
29108@itemx -mrl78
29109@opindex mg10
29110@opindex mg13
29111@opindex mg14
29112@opindex mrl78
29113These are aliases for the corresponding @option{-mcpu=} option. They
29114are provided for backwards compatibility.
29115
29116@item -mallregs
29117@opindex mallregs
29118Allow the compiler to use all of the available registers. By default
29119registers @code{r24..r31} are reserved for use in interrupt handlers.
29120With this option enabled these registers can be used in ordinary
29121functions as well.
29122
29123@item -m64bit-doubles
29124@itemx -m32bit-doubles
29125@opindex m64bit-doubles
29126@opindex m32bit-doubles
29127Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
29128or 32 bits (@option{-m32bit-doubles}) in size. The default is
29129@option{-m32bit-doubles}.
29130
29131@item -msave-mduc-in-interrupts
29132@itemx -mno-save-mduc-in-interrupts
29133@opindex msave-mduc-in-interrupts
29134@opindex mno-save-mduc-in-interrupts
29135Specifies that interrupt handler functions should preserve the
29136MDUC registers. This is only necessary if normal code might use
29137the MDUC registers, for example because it performs multiplication
29138and division operations. The default is to ignore the MDUC registers
29139as this makes the interrupt handlers faster. The target option -mg13
29140needs to be passed for this to work as this feature is only available
29141on the G13 target (S2 core). The MDUC registers will only be saved
29142if the interrupt handler performs a multiplication or division
29143operation or it calls another function.
29144
29145@end table
29146
29147@node RS/6000 and PowerPC Options
29148@subsection IBM RS/6000 and PowerPC Options
29149@cindex RS/6000 and PowerPC Options
29150@cindex IBM RS/6000 and PowerPC Options
29151
29152These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
29153@table @gcctabopt
29154@item -mpowerpc-gpopt
29155@itemx -mno-powerpc-gpopt
29156@itemx -mpowerpc-gfxopt
29157@itemx -mno-powerpc-gfxopt
29158@need 800
29159@itemx -mpowerpc64
29160@itemx -mno-powerpc64
29161@itemx -mmfcrf
29162@itemx -mno-mfcrf
29163@itemx -mpopcntb
29164@itemx -mno-popcntb
29165@itemx -mpopcntd
29166@itemx -mno-popcntd
29167@itemx -mfprnd
29168@itemx -mno-fprnd
29169@need 800
29170@itemx -mcmpb
29171@itemx -mno-cmpb
29172@itemx -mhard-dfp
29173@itemx -mno-hard-dfp
29174@opindex mpowerpc-gpopt
29175@opindex mno-powerpc-gpopt
29176@opindex mpowerpc-gfxopt
29177@opindex mno-powerpc-gfxopt
29178@opindex mpowerpc64
29179@opindex mno-powerpc64
29180@opindex mmfcrf
29181@opindex mno-mfcrf
29182@opindex mpopcntb
29183@opindex mno-popcntb
29184@opindex mpopcntd
29185@opindex mno-popcntd
29186@opindex mfprnd
29187@opindex mno-fprnd
29188@opindex mcmpb
29189@opindex mno-cmpb
29190@opindex mhard-dfp
29191@opindex mno-hard-dfp
29192You use these options to specify which instructions are available on the
29193processor you are using. The default value of these options is
29194determined when configuring GCC@. Specifying the
29195@option{-mcpu=@var{cpu_type}} overrides the specification of these
29196options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
29197rather than the options listed above.
29198
29199Specifying @option{-mpowerpc-gpopt} allows
29200GCC to use the optional PowerPC architecture instructions in the
29201General Purpose group, including floating-point square root. Specifying
29202@option{-mpowerpc-gfxopt} allows GCC to
29203use the optional PowerPC architecture instructions in the Graphics
29204group, including floating-point select.
29205
29206The @option{-mmfcrf} option allows GCC to generate the move from
29207condition register field instruction implemented on the POWER4
29208processor and other processors that support the PowerPC V2.01
29209architecture.
29210The @option{-mpopcntb} option allows GCC to generate the popcount and
29211double-precision FP reciprocal estimate instruction implemented on the
29212POWER5 processor and other processors that support the PowerPC V2.02
29213architecture.
29214The @option{-mpopcntd} option allows GCC to generate the popcount
29215instruction implemented on the POWER7 processor and other processors
29216that support the PowerPC V2.06 architecture.
29217The @option{-mfprnd} option allows GCC to generate the FP round to
29218integer instructions implemented on the POWER5+ processor and other
29219processors that support the PowerPC V2.03 architecture.
29220The @option{-mcmpb} option allows GCC to generate the compare bytes
29221instruction implemented on the POWER6 processor and other processors
29222that support the PowerPC V2.05 architecture.
29223The @option{-mhard-dfp} option allows GCC to generate the decimal
29224floating-point instructions implemented on some POWER processors.
29225
29226The @option{-mpowerpc64} option allows GCC to generate the additional
2922764-bit instructions that are found in the full PowerPC64 architecture
29228and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
29229@option{-mno-powerpc64}.
29230
29231@item -mcpu=@var{cpu_type}
29232@opindex mcpu
29233Set architecture type, register usage, and
29234instruction scheduling parameters for machine type @var{cpu_type}.
29235Supported values for @var{cpu_type} are @samp{401}, @samp{403},
29236@samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
29237@samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
29238@samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
29239@samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
29240@samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
29241@samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
29242@samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
29243@samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
29244@samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
29245@samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64},
29246@samp{powerpc64le}, @samp{rs64}, and @samp{native}.
29247
29248@option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
29249@option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
29250endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
29251architecture machine types, with an appropriate, generic processor
29252model assumed for scheduling purposes.
29253
29254Specifying @samp{native} as cpu type detects and selects the
29255architecture option that corresponds to the host processor of the
29256system performing the compilation.
29257@option{-mcpu=native} has no effect if GCC does not recognize the
29258processor.
29259
29260The other options specify a specific processor. Code generated under
29261those options runs best on that processor, and may not run at all on
29262others.
29263
29264The @option{-mcpu} options automatically enable or disable the
29265following options:
29266
29267@gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple @gol
29268-mpopcntb -mpopcntd -mpowerpc64 @gol
29269-mpowerpc-gpopt -mpowerpc-gfxopt @gol
29270-mmulhw -mdlmzb -mmfpgpr -mvsx @gol
29271-mcrypto -mhtm -mpower8-fusion -mpower8-vector @gol
29272-mquad-memory -mquad-memory-atomic -mfloat128 @gol
29273-mfloat128-hardware -mprefixed -mpcrel -mmma @gol
29274-mrop-protect}
29275
29276The particular options set for any particular CPU varies between
29277compiler versions, depending on what setting seems to produce optimal
29278code for that CPU; it doesn't necessarily reflect the actual hardware's
29279capabilities. If you wish to set an individual option to a particular
29280value, you may specify it after the @option{-mcpu} option, like
29281@option{-mcpu=970 -mno-altivec}.
29282
29283On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
29284not enabled or disabled by the @option{-mcpu} option at present because
29285AIX does not have full support for these options. You may still
29286enable or disable them individually if you're sure it'll work in your
29287environment.
29288
29289@item -mtune=@var{cpu_type}
29290@opindex mtune
29291Set the instruction scheduling parameters for machine type
29292@var{cpu_type}, but do not set the architecture type or register usage,
29293as @option{-mcpu=@var{cpu_type}} does. The same
29294values for @var{cpu_type} are used for @option{-mtune} as for
29295@option{-mcpu}. If both are specified, the code generated uses the
29296architecture and registers set by @option{-mcpu}, but the
29297scheduling parameters set by @option{-mtune}.
29298
29299@item -mcmodel=small
29300@opindex mcmodel=small
29301Generate PowerPC64 code for the small model: The TOC is limited to
2930264k.
29303
29304@item -mcmodel=medium
29305@opindex mcmodel=medium
29306Generate PowerPC64 code for the medium model: The TOC and other static
29307data may be up to a total of 4G in size. This is the default for 64-bit
29308Linux.
29309
29310@item -mcmodel=large
29311@opindex mcmodel=large
29312Generate PowerPC64 code for the large model: The TOC may be up to 4G
29313in size. Other data and code is only limited by the 64-bit address
29314space.
29315
29316@item -maltivec
29317@itemx -mno-altivec
29318@opindex maltivec
29319@opindex mno-altivec
29320Generate code that uses (does not use) AltiVec instructions, and also
29321enable the use of built-in functions that allow more direct access to
29322the AltiVec instruction set. You may also need to set
29323@option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
29324enhancements.
29325
29326When @option{-maltivec} is used, the element order for AltiVec intrinsics
29327such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
29328match array element order corresponding to the endianness of the
29329target. That is, element zero identifies the leftmost element in a
29330vector register when targeting a big-endian platform, and identifies
29331the rightmost element in a vector register when targeting a
29332little-endian platform.
29333
29334@item -mvrsave
29335@itemx -mno-vrsave
29336@opindex mvrsave
29337@opindex mno-vrsave
29338Generate VRSAVE instructions when generating AltiVec code.
29339
29340@item -msecure-plt
29341@opindex msecure-plt
29342Generate code that allows @command{ld} and @command{ld.so}
29343to build executables and shared
29344libraries with non-executable @code{.plt} and @code{.got} sections.
29345This is a PowerPC
2934632-bit SYSV ABI option.
29347
29348@item -mbss-plt
29349@opindex mbss-plt
29350Generate code that uses a BSS @code{.plt} section that @command{ld.so}
29351fills in, and
29352requires @code{.plt} and @code{.got}
29353sections that are both writable and executable.
29354This is a PowerPC 32-bit SYSV ABI option.
29355
29356@item -misel
29357@itemx -mno-isel
29358@opindex misel
29359@opindex mno-isel
29360This switch enables or disables the generation of ISEL instructions.
29361
29362@item -mvsx
29363@itemx -mno-vsx
29364@opindex mvsx
29365@opindex mno-vsx
29366Generate code that uses (does not use) vector/scalar (VSX)
29367instructions, and also enable the use of built-in functions that allow
29368more direct access to the VSX instruction set.
29369
29370@item -mcrypto
29371@itemx -mno-crypto
29372@opindex mcrypto
29373@opindex mno-crypto
29374Enable the use (disable) of the built-in functions that allow direct
29375access to the cryptographic instructions that were added in version
293762.07 of the PowerPC ISA.
29377
29378@item -mhtm
29379@itemx -mno-htm
29380@opindex mhtm
29381@opindex mno-htm
29382Enable (disable) the use of the built-in functions that allow direct
29383access to the Hardware Transactional Memory (HTM) instructions that
29384were added in version 2.07 of the PowerPC ISA.
29385
29386@item -mpower8-fusion
29387@itemx -mno-power8-fusion
29388@opindex mpower8-fusion
29389@opindex mno-power8-fusion
29390Generate code that keeps (does not keeps) some integer operations
29391adjacent so that the instructions can be fused together on power8 and
29392later processors.
29393
29394@item -mpower8-vector
29395@itemx -mno-power8-vector
29396@opindex mpower8-vector
29397@opindex mno-power8-vector
29398Generate code that uses (does not use) the vector and scalar
29399instructions that were added in version 2.07 of the PowerPC ISA. Also
29400enable the use of built-in functions that allow more direct access to
29401the vector instructions.
29402
29403@item -mquad-memory
29404@itemx -mno-quad-memory
29405@opindex mquad-memory
29406@opindex mno-quad-memory
29407Generate code that uses (does not use) the non-atomic quad word memory
29408instructions. The @option{-mquad-memory} option requires use of
2940964-bit mode.
29410
29411@item -mquad-memory-atomic
29412@itemx -mno-quad-memory-atomic
29413@opindex mquad-memory-atomic
29414@opindex mno-quad-memory-atomic
29415Generate code that uses (does not use) the atomic quad word memory
29416instructions. The @option{-mquad-memory-atomic} option requires use of
2941764-bit mode.
29418
29419@item -mfloat128
29420@itemx -mno-float128
29421@opindex mfloat128
29422@opindex mno-float128
29423Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
29424and use either software emulation for IEEE 128-bit floating point or
29425hardware instructions.
29426
29427The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
29428128-bit floating point support. The IEEE 128-bit floating point is only
29429supported on Linux.
29430
29431The default for @option{-mfloat128} is enabled on PowerPC Linux
29432systems using the VSX instruction set, and disabled on other systems.
29433
29434If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or
29435@option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating
29436point support will also enable the generation of ISA 3.0 IEEE 128-bit
29437floating point instructions. Otherwise, if you do not specify to
29438generate ISA 3.0 instructions or you are targeting a 32-bit big endian
29439system, IEEE 128-bit floating point will be done with software
29440emulation.
29441
29442@item -mfloat128-hardware
29443@itemx -mno-float128-hardware
29444@opindex mfloat128-hardware
29445@opindex mno-float128-hardware
29446Enable/disable using ISA 3.0 hardware instructions to support the
29447@var{__float128} data type.
29448
29449The default for @option{-mfloat128-hardware} is enabled on PowerPC
29450Linux systems using the ISA 3.0 instruction set, and disabled on other
29451systems.
29452
29453@item -m32
29454@itemx -m64
29455@opindex m32
29456@opindex m64
29457Generate code for 32-bit or 64-bit environments of Darwin and SVR4
29458targets (including GNU/Linux). The 32-bit environment sets int, long
29459and pointer to 32 bits and generates code that runs on any PowerPC
29460variant. The 64-bit environment sets int to 32 bits and long and
29461pointer to 64 bits, and generates code for PowerPC64, as for
29462@option{-mpowerpc64}.
29463
29464@item -mfull-toc
29465@itemx -mno-fp-in-toc
29466@itemx -mno-sum-in-toc
29467@itemx -mminimal-toc
29468@opindex mfull-toc
29469@opindex mno-fp-in-toc
29470@opindex mno-sum-in-toc
29471@opindex mminimal-toc
29472Modify generation of the TOC (Table Of Contents), which is created for
29473every executable file. The @option{-mfull-toc} option is selected by
29474default. In that case, GCC allocates at least one TOC entry for
29475each unique non-automatic variable reference in your program. GCC
29476also places floating-point constants in the TOC@. However, only
2947716,384 entries are available in the TOC@.
29478
29479If you receive a linker error message that saying you have overflowed
29480the available TOC space, you can reduce the amount of TOC space used
29481with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
29482@option{-mno-fp-in-toc} prevents GCC from putting floating-point
29483constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
29484generate code to calculate the sum of an address and a constant at
29485run time instead of putting that sum into the TOC@. You may specify one
29486or both of these options. Each causes GCC to produce very slightly
29487slower and larger code at the expense of conserving TOC space.
29488
29489If you still run out of space in the TOC even when you specify both of
29490these options, specify @option{-mminimal-toc} instead. This option causes
29491GCC to make only one TOC entry for every file. When you specify this
29492option, GCC produces code that is slower and larger but which
29493uses extremely little TOC space. You may wish to use this option
29494only on files that contain less frequently-executed code.
29495
29496@item -maix64
29497@itemx -maix32
29498@opindex maix64
29499@opindex maix32
29500Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
29501@code{long} type, and the infrastructure needed to support them.
29502Specifying @option{-maix64} implies @option{-mpowerpc64},
29503while @option{-maix32} disables the 64-bit ABI and
29504implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
29505
29506@item -mxl-compat
29507@itemx -mno-xl-compat
29508@opindex mxl-compat
29509@opindex mno-xl-compat
29510Produce code that conforms more closely to IBM XL compiler semantics
29511when using AIX-compatible ABI@. Pass floating-point arguments to
29512prototyped functions beyond the register save area (RSA) on the stack
29513in addition to argument FPRs. Do not assume that most significant
29514double in 128-bit long double value is properly rounded when comparing
29515values and converting to double. Use XL symbol names for long double
29516support routines.
29517
29518The AIX calling convention was extended but not initially documented to
29519handle an obscure K&R C case of calling a function that takes the
29520address of its arguments with fewer arguments than declared. IBM XL
29521compilers access floating-point arguments that do not fit in the
29522RSA from the stack when a subroutine is compiled without
29523optimization. Because always storing floating-point arguments on the
29524stack is inefficient and rarely needed, this option is not enabled by
29525default and only is necessary when calling subroutines compiled by IBM
29526XL compilers without optimization.
29527
29528@item -mpe
29529@opindex mpe
29530Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
29531application written to use message passing with special startup code to
29532enable the application to run. The system must have PE installed in the
29533standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
29534must be overridden with the @option{-specs=} option to specify the
29535appropriate directory location. The Parallel Environment does not
29536support threads, so the @option{-mpe} option and the @option{-pthread}
29537option are incompatible.
29538
29539@item -malign-natural
29540@itemx -malign-power
29541@opindex malign-natural
29542@opindex malign-power
29543On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
29544@option{-malign-natural} overrides the ABI-defined alignment of larger
29545types, such as floating-point doubles, on their natural size-based boundary.
29546The option @option{-malign-power} instructs GCC to follow the ABI-specified
29547alignment rules. GCC defaults to the standard alignment defined in the ABI@.
29548
29549On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
29550is not supported.
29551
29552@item -msoft-float
29553@itemx -mhard-float
29554@opindex msoft-float
29555@opindex mhard-float
29556Generate code that does not use (uses) the floating-point register set.
29557Software floating-point emulation is provided if you use the
29558@option{-msoft-float} option, and pass the option to GCC when linking.
29559
29560@item -mmultiple
29561@itemx -mno-multiple
29562@opindex mmultiple
29563@opindex mno-multiple
29564Generate code that uses (does not use) the load multiple word
29565instructions and the store multiple word instructions. These
29566instructions are generated by default on POWER systems, and not
29567generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
29568PowerPC systems, since those instructions do not work when the
29569processor is in little-endian mode. The exceptions are PPC740 and
29570PPC750 which permit these instructions in little-endian mode.
29571
29572@item -mupdate
29573@itemx -mno-update
29574@opindex mupdate
29575@opindex mno-update
29576Generate code that uses (does not use) the load or store instructions
29577that update the base register to the address of the calculated memory
29578location. These instructions are generated by default. If you use
29579@option{-mno-update}, there is a small window between the time that the
29580stack pointer is updated and the address of the previous frame is
29581stored, which means code that walks the stack frame across interrupts or
29582signals may get corrupted data.
29583
29584@item -mavoid-indexed-addresses
29585@itemx -mno-avoid-indexed-addresses
29586@opindex mavoid-indexed-addresses
29587@opindex mno-avoid-indexed-addresses
29588Generate code that tries to avoid (not avoid) the use of indexed load
29589or store instructions. These instructions can incur a performance
29590penalty on Power6 processors in certain situations, such as when
29591stepping through large arrays that cross a 16M boundary. This option
29592is enabled by default when targeting Power6 and disabled otherwise.
29593
29594@item -mfused-madd
29595@itemx -mno-fused-madd
29596@opindex mfused-madd
29597@opindex mno-fused-madd
29598Generate code that uses (does not use) the floating-point multiply and
29599accumulate instructions. These instructions are generated by default
29600if hardware floating point is used. The machine-dependent
29601@option{-mfused-madd} option is now mapped to the machine-independent
29602@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
29603mapped to @option{-ffp-contract=off}.
29604
29605@item -mmulhw
29606@itemx -mno-mulhw
29607@opindex mmulhw
29608@opindex mno-mulhw
29609Generate code that uses (does not use) the half-word multiply and
29610multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
29611These instructions are generated by default when targeting those
29612processors.
29613
29614@item -mdlmzb
29615@itemx -mno-dlmzb
29616@opindex mdlmzb
29617@opindex mno-dlmzb
29618Generate code that uses (does not use) the string-search @samp{dlmzb}
29619instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
29620generated by default when targeting those processors.
29621
29622@item -mno-bit-align
29623@itemx -mbit-align
29624@opindex mno-bit-align
29625@opindex mbit-align
29626On System V.4 and embedded PowerPC systems do not (do) force structures
29627and unions that contain bit-fields to be aligned to the base type of the
29628bit-field.
29629
29630For example, by default a structure containing nothing but 8
29631@code{unsigned} bit-fields of length 1 is aligned to a 4-byte
29632boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
29633the structure is aligned to a 1-byte boundary and is 1 byte in
29634size.
29635
29636@item -mno-strict-align
29637@itemx -mstrict-align
29638@opindex mno-strict-align
29639@opindex mstrict-align
29640On System V.4 and embedded PowerPC systems do not (do) assume that
29641unaligned memory references are handled by the system.
29642
29643@item -mrelocatable
29644@itemx -mno-relocatable
29645@opindex mrelocatable
29646@opindex mno-relocatable
29647Generate code that allows (does not allow) a static executable to be
29648relocated to a different address at run time. A simple embedded
29649PowerPC system loader should relocate the entire contents of
29650@code{.got2} and 4-byte locations listed in the @code{.fixup} section,
29651a table of 32-bit addresses generated by this option. For this to
29652work, all objects linked together must be compiled with
29653@option{-mrelocatable} or @option{-mrelocatable-lib}.
29654@option{-mrelocatable} code aligns the stack to an 8-byte boundary.
29655
29656@item -mrelocatable-lib
29657@itemx -mno-relocatable-lib
29658@opindex mrelocatable-lib
29659@opindex mno-relocatable-lib
29660Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
29661@code{.fixup} section to allow static executables to be relocated at
29662run time, but @option{-mrelocatable-lib} does not use the smaller stack
29663alignment of @option{-mrelocatable}. Objects compiled with
29664@option{-mrelocatable-lib} may be linked with objects compiled with
29665any combination of the @option{-mrelocatable} options.
29666
29667@item -mno-toc
29668@itemx -mtoc
29669@opindex mno-toc
29670@opindex mtoc
29671On System V.4 and embedded PowerPC systems do not (do) assume that
29672register 2 contains a pointer to a global area pointing to the addresses
29673used in the program.
29674
29675@item -mlittle
29676@itemx -mlittle-endian
29677@opindex mlittle
29678@opindex mlittle-endian
29679On System V.4 and embedded PowerPC systems compile code for the
29680processor in little-endian mode. The @option{-mlittle-endian} option is
29681the same as @option{-mlittle}.
29682
29683@item -mbig
29684@itemx -mbig-endian
29685@opindex mbig
29686@opindex mbig-endian
29687On System V.4 and embedded PowerPC systems compile code for the
29688processor in big-endian mode. The @option{-mbig-endian} option is
29689the same as @option{-mbig}.
29690
29691@item -mdynamic-no-pic
29692@opindex mdynamic-no-pic
29693On Darwin and Mac OS X systems, compile code so that it is not
29694relocatable, but that its external references are relocatable. The
29695resulting code is suitable for applications, but not shared
29696libraries.
29697
29698@item -msingle-pic-base
29699@opindex msingle-pic-base
29700Treat the register used for PIC addressing as read-only, rather than
29701loading it in the prologue for each function. The runtime system is
29702responsible for initializing this register with an appropriate value
29703before execution begins.
29704
29705@item -mprioritize-restricted-insns=@var{priority}
29706@opindex mprioritize-restricted-insns
29707This option controls the priority that is assigned to
29708dispatch-slot restricted instructions during the second scheduling
29709pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
29710or @samp{2} to assign no, highest, or second-highest (respectively)
29711priority to dispatch-slot restricted
29712instructions.
29713
29714@item -msched-costly-dep=@var{dependence_type}
29715@opindex msched-costly-dep
29716This option controls which dependences are considered costly
29717by the target during instruction scheduling. The argument
29718@var{dependence_type} takes one of the following values:
29719
29720@table @asis
29721@item @samp{no}
29722No dependence is costly.
29723
29724@item @samp{all}
29725All dependences are costly.
29726
29727@item @samp{true_store_to_load}
29728A true dependence from store to load is costly.
29729
29730@item @samp{store_to_load}
29731Any dependence from store to load is costly.
29732
29733@item @var{number}
29734Any dependence for which the latency is greater than or equal to
29735@var{number} is costly.
29736@end table
29737
29738@item -minsert-sched-nops=@var{scheme}
29739@opindex minsert-sched-nops
29740This option controls which NOP insertion scheme is used during
29741the second scheduling pass. The argument @var{scheme} takes one of the
29742following values:
29743
29744@table @asis
29745@item @samp{no}
29746Don't insert NOPs.
29747
29748@item @samp{pad}
29749Pad with NOPs any dispatch group that has vacant issue slots,
29750according to the scheduler's grouping.
29751
29752@item @samp{regroup_exact}
29753Insert NOPs to force costly dependent insns into
29754separate groups. Insert exactly as many NOPs as needed to force an insn
29755to a new group, according to the estimated processor grouping.
29756
29757@item @var{number}
29758Insert NOPs to force costly dependent insns into
29759separate groups. Insert @var{number} NOPs to force an insn to a new group.
29760@end table
29761
29762@item -mcall-sysv
29763@opindex mcall-sysv
29764On System V.4 and embedded PowerPC systems compile code using calling
29765conventions that adhere to the March 1995 draft of the System V
29766Application Binary Interface, PowerPC processor supplement. This is the
29767default unless you configured GCC using @samp{powerpc-*-eabiaix}.
29768
29769@item -mcall-sysv-eabi
29770@itemx -mcall-eabi
29771@opindex mcall-sysv-eabi
29772@opindex mcall-eabi
29773Specify both @option{-mcall-sysv} and @option{-meabi} options.
29774
29775@item -mcall-sysv-noeabi
29776@opindex mcall-sysv-noeabi
29777Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
29778
29779@item -mcall-aixdesc
d7971cf7 29780@opindex mcall-aixdesc
d77de738
ML
29781On System V.4 and embedded PowerPC systems compile code for the AIX
29782operating system.
29783
29784@item -mcall-linux
29785@opindex mcall-linux
29786On System V.4 and embedded PowerPC systems compile code for the
29787Linux-based GNU system.
29788
29789@item -mcall-freebsd
29790@opindex mcall-freebsd
29791On System V.4 and embedded PowerPC systems compile code for the
29792FreeBSD operating system.
29793
29794@item -mcall-netbsd
29795@opindex mcall-netbsd
29796On System V.4 and embedded PowerPC systems compile code for the
29797NetBSD operating system.
29798
29799@item -mcall-openbsd
d7971cf7 29800@opindex mcall-openbsd
d77de738
ML
29801On System V.4 and embedded PowerPC systems compile code for the
29802OpenBSD operating system.
29803
29804@item -mtraceback=@var{traceback_type}
29805@opindex mtraceback
29806Select the type of traceback table. Valid values for @var{traceback_type}
29807are @samp{full}, @samp{part}, and @samp{no}.
29808
29809@item -maix-struct-return
29810@opindex maix-struct-return
29811Return all structures in memory (as specified by the AIX ABI)@.
29812
29813@item -msvr4-struct-return
29814@opindex msvr4-struct-return
29815Return structures smaller than 8 bytes in registers (as specified by the
29816SVR4 ABI)@.
29817
29818@item -mabi=@var{abi-type}
29819@opindex mabi
29820Extend the current ABI with a particular extension, or remove such extension.
29821Valid values are: @samp{altivec}, @samp{no-altivec},
29822@samp{ibmlongdouble}, @samp{ieeelongdouble},
29823@samp{elfv1}, @samp{elfv2},
29824and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
29825
29826@item -mabi=ibmlongdouble
29827@opindex mabi=ibmlongdouble
29828Change the current ABI to use IBM extended-precision long double.
29829This is not likely to work if your system defaults to using IEEE
29830extended-precision long double. If you change the long double type
29831from IEEE extended-precision, the compiler will issue a warning unless
29832you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
29833to be enabled.
29834
29835@item -mabi=ieeelongdouble
29836@opindex mabi=ieeelongdouble
29837Change the current ABI to use IEEE extended-precision long double.
29838This is not likely to work if your system defaults to using IBM
29839extended-precision long double. If you change the long double type
29840from IBM extended-precision, the compiler will issue a warning unless
29841you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
29842to be enabled.
29843
29844@item -mabi=elfv1
29845@opindex mabi=elfv1
29846Change the current ABI to use the ELFv1 ABI.
29847This is the default ABI for big-endian PowerPC 64-bit Linux.
29848Overriding the default ABI requires special system support and is
29849likely to fail in spectacular ways.
29850
29851@item -mabi=elfv2
29852@opindex mabi=elfv2
29853Change the current ABI to use the ELFv2 ABI.
29854This is the default ABI for little-endian PowerPC 64-bit Linux.
29855Overriding the default ABI requires special system support and is
29856likely to fail in spectacular ways.
29857
29858@item -mgnu-attribute
29859@itemx -mno-gnu-attribute
29860@opindex mgnu-attribute
29861@opindex mno-gnu-attribute
29862Emit .gnu_attribute assembly directives to set tag/value pairs in a
29863.gnu.attributes section that specify ABI variations in function
29864parameters or return values.
29865
29866@item -mprototype
29867@itemx -mno-prototype
29868@opindex mprototype
29869@opindex mno-prototype
29870On System V.4 and embedded PowerPC systems assume that all calls to
29871variable argument functions are properly prototyped. Otherwise, the
29872compiler must insert an instruction before every non-prototyped call to
29873set or clear bit 6 of the condition code register (@code{CR}) to
29874indicate whether floating-point values are passed in the floating-point
29875registers in case the function takes variable arguments. With
29876@option{-mprototype}, only calls to prototyped variable argument functions
29877set or clear the bit.
29878
29879@item -msim
29880@opindex msim
29881On embedded PowerPC systems, assume that the startup module is called
29882@file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
29883@file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
29884configurations.
29885
29886@item -mmvme
29887@opindex mmvme
29888On embedded PowerPC systems, assume that the startup module is called
29889@file{crt0.o} and the standard C libraries are @file{libmvme.a} and
29890@file{libc.a}.
29891
29892@item -mads
29893@opindex mads
29894On embedded PowerPC systems, assume that the startup module is called
29895@file{crt0.o} and the standard C libraries are @file{libads.a} and
29896@file{libc.a}.
29897
29898@item -myellowknife
29899@opindex myellowknife
29900On embedded PowerPC systems, assume that the startup module is called
29901@file{crt0.o} and the standard C libraries are @file{libyk.a} and
29902@file{libc.a}.
29903
29904@item -mvxworks
29905@opindex mvxworks
29906On System V.4 and embedded PowerPC systems, specify that you are
29907compiling for a VxWorks system.
29908
29909@item -memb
29910@opindex memb
29911On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
29912header to indicate that @samp{eabi} extended relocations are used.
29913
29914@item -meabi
29915@itemx -mno-eabi
29916@opindex meabi
29917@opindex mno-eabi
29918On System V.4 and embedded PowerPC systems do (do not) adhere to the
29919Embedded Applications Binary Interface (EABI), which is a set of
29920modifications to the System V.4 specifications. Selecting @option{-meabi}
29921means that the stack is aligned to an 8-byte boundary, a function
29922@code{__eabi} is called from @code{main} to set up the EABI
29923environment, and the @option{-msdata} option can use both @code{r2} and
29924@code{r13} to point to two separate small data areas. Selecting
29925@option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
29926no EABI initialization function is called from @code{main}, and the
29927@option{-msdata} option only uses @code{r13} to point to a single
29928small data area. The @option{-meabi} option is on by default if you
29929configured GCC using one of the @samp{powerpc*-*-eabi*} options.
29930
29931@item -msdata=eabi
29932@opindex msdata=eabi
29933On System V.4 and embedded PowerPC systems, put small initialized
29934@code{const} global and static data in the @code{.sdata2} section, which
29935is pointed to by register @code{r2}. Put small initialized
29936non-@code{const} global and static data in the @code{.sdata} section,
29937which is pointed to by register @code{r13}. Put small uninitialized
29938global and static data in the @code{.sbss} section, which is adjacent to
29939the @code{.sdata} section. The @option{-msdata=eabi} option is
29940incompatible with the @option{-mrelocatable} option. The
29941@option{-msdata=eabi} option also sets the @option{-memb} option.
29942
29943@item -msdata=sysv
29944@opindex msdata=sysv
29945On System V.4 and embedded PowerPC systems, put small global and static
29946data in the @code{.sdata} section, which is pointed to by register
29947@code{r13}. Put small uninitialized global and static data in the
29948@code{.sbss} section, which is adjacent to the @code{.sdata} section.
29949The @option{-msdata=sysv} option is incompatible with the
29950@option{-mrelocatable} option.
29951
29952@item -msdata=default
29953@itemx -msdata
29954@opindex msdata=default
29955@opindex msdata
29956On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
29957compile code the same as @option{-msdata=eabi}, otherwise compile code the
29958same as @option{-msdata=sysv}.
29959
29960@item -msdata=data
29961@opindex msdata=data
29962On System V.4 and embedded PowerPC systems, put small global
29963data in the @code{.sdata} section. Put small uninitialized global
29964data in the @code{.sbss} section. Do not use register @code{r13}
29965to address small data however. This is the default behavior unless
29966other @option{-msdata} options are used.
29967
29968@item -msdata=none
29969@itemx -mno-sdata
29970@opindex msdata=none
29971@opindex mno-sdata
29972On embedded PowerPC systems, put all initialized global and static data
29973in the @code{.data} section, and all uninitialized data in the
29974@code{.bss} section.
29975
29976@item -mreadonly-in-sdata
29977@opindex mreadonly-in-sdata
29978@opindex mno-readonly-in-sdata
29979Put read-only objects in the @code{.sdata} section as well. This is the
29980default.
29981
29982@item -mblock-move-inline-limit=@var{num}
29983@opindex mblock-move-inline-limit
29984Inline all block moves (such as calls to @code{memcpy} or structure
29985copies) less than or equal to @var{num} bytes. The minimum value for
29986@var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
29987targets. The default value is target-specific.
29988
29989@item -mblock-compare-inline-limit=@var{num}
29990@opindex mblock-compare-inline-limit
29991Generate non-looping inline code for all block compares (such as calls
29992to @code{memcmp} or structure compares) less than or equal to @var{num}
29993bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
29994block compare is disabled. The default value is target-specific.
29995
29996@item -mblock-compare-inline-loop-limit=@var{num}
29997@opindex mblock-compare-inline-loop-limit
29998Generate an inline expansion using loop code for all block compares that
29999are less than or equal to @var{num} bytes, but greater than the limit
30000for non-loop inline block compare expansion. If the block length is not
30001constant, at most @var{num} bytes will be compared before @code{memcmp}
30002is called to compare the remainder of the block. The default value is
30003target-specific.
30004
30005@item -mstring-compare-inline-limit=@var{num}
30006@opindex mstring-compare-inline-limit
30007Compare at most @var{num} string bytes with inline code.
30008If the difference or end of string is not found at the
30009end of the inline compare a call to @code{strcmp} or @code{strncmp} will
30010take care of the rest of the comparison. The default is 64 bytes.
30011
30012@item -G @var{num}
30013@opindex G
30014@cindex smaller data references (PowerPC)
30015@cindex .sdata/.sdata2 references (PowerPC)
30016On embedded PowerPC systems, put global and static items less than or
30017equal to @var{num} bytes into the small data or BSS sections instead of
30018the normal data or BSS section. By default, @var{num} is 8. The
30019@option{-G @var{num}} switch is also passed to the linker.
30020All modules should be compiled with the same @option{-G @var{num}} value.
30021
30022@item -mregnames
30023@itemx -mno-regnames
30024@opindex mregnames
30025@opindex mno-regnames
30026On System V.4 and embedded PowerPC systems do (do not) emit register
30027names in the assembly language output using symbolic forms.
30028
30029@item -mlongcall
30030@itemx -mno-longcall
30031@opindex mlongcall
30032@opindex mno-longcall
30033By default assume that all calls are far away so that a longer and more
30034expensive calling sequence is required. This is required for calls
30035farther than 32 megabytes (33,554,432 bytes) from the current location.
30036A short call is generated if the compiler knows
30037the call cannot be that far away. This setting can be overridden by
30038the @code{shortcall} function attribute, or by @code{#pragma
30039longcall(0)}.
30040
30041Some linkers are capable of detecting out-of-range calls and generating
30042glue code on the fly. On these systems, long calls are unnecessary and
30043generate slower code. As of this writing, the AIX linker can do this,
30044as can the GNU linker for PowerPC/64. It is planned to add this feature
30045to the GNU linker for 32-bit PowerPC systems as well.
30046
30047On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
30048GCC can generate long calls using an inline PLT call sequence (see
30049@option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
30050ELFv1 (big-endian) do not support inline PLT calls.
30051
30052On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
30053callee, L42}, plus a @dfn{branch island} (glue code). The two target
30054addresses represent the callee and the branch island. The
30055Darwin/PPC linker prefers the first address and generates a @code{bl
30056callee} if the PPC @code{bl} instruction reaches the callee directly;
30057otherwise, the linker generates @code{bl L42} to call the branch
30058island. The branch island is appended to the body of the
30059calling function; it computes the full 32-bit address of the callee
30060and jumps to it.
30061
30062On Mach-O (Darwin) systems, this option directs the compiler emit to
30063the glue for every direct call, and the Darwin linker decides whether
30064to use or discard it.
30065
30066In the future, GCC may ignore all longcall specifications
30067when the linker is known to generate glue.
30068
30069@item -mpltseq
30070@itemx -mno-pltseq
30071@opindex mpltseq
30072@opindex mno-pltseq
30073Implement (do not implement) -fno-plt and long calls using an inline
30074PLT call sequence that supports lazy linking and long calls to
30075functions in dlopen'd shared libraries. Inline PLT calls are only
30076supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
30077linkers, and are enabled by default if the support is detected when
30078configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
30079configured with @option{--enable-secureplt}. @option{-mpltseq} code
30080and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
30081linked together.
30082
30083@item -mtls-markers
30084@itemx -mno-tls-markers
30085@opindex mtls-markers
30086@opindex mno-tls-markers
30087Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
30088specifying the function argument. The relocation allows the linker to
30089reliably associate function call with argument setup instructions for
30090TLS optimization, which in turn allows GCC to better schedule the
30091sequence.
30092
30093@item -mrecip
30094@itemx -mno-recip
30095@opindex mrecip
30096This option enables use of the reciprocal estimate and
30097reciprocal square root estimate instructions with additional
30098Newton-Raphson steps to increase precision instead of doing a divide or
30099square root and divide for floating-point arguments. You should use
30100the @option{-ffast-math} option when using @option{-mrecip} (or at
30101least @option{-funsafe-math-optimizations},
30102@option{-ffinite-math-only}, @option{-freciprocal-math} and
30103@option{-fno-trapping-math}). Note that while the throughput of the
30104sequence is generally higher than the throughput of the non-reciprocal
30105instruction, the precision of the sequence can be decreased by up to 2
30106ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
30107roots.
30108
30109@item -mrecip=@var{opt}
30110@opindex mrecip=opt
30111This option controls which reciprocal estimate instructions
30112may be used. @var{opt} is a comma-separated list of options, which may
30113be preceded by a @code{!} to invert the option:
30114
30115@table @samp
30116
30117@item all
30118Enable all estimate instructions.
30119
30120@item default
30121Enable the default instructions, equivalent to @option{-mrecip}.
30122
30123@item none
30124Disable all estimate instructions, equivalent to @option{-mno-recip}.
30125
30126@item div
30127Enable the reciprocal approximation instructions for both
30128single and double precision.
30129
30130@item divf
30131Enable the single-precision reciprocal approximation instructions.
30132
30133@item divd
30134Enable the double-precision reciprocal approximation instructions.
30135
30136@item rsqrt
30137Enable the reciprocal square root approximation instructions for both
30138single and double precision.
30139
30140@item rsqrtf
30141Enable the single-precision reciprocal square root approximation instructions.
30142
30143@item rsqrtd
30144Enable the double-precision reciprocal square root approximation instructions.
30145
30146@end table
30147
30148So, for example, @option{-mrecip=all,!rsqrtd} enables
30149all of the reciprocal estimate instructions, except for the
30150@code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
30151which handle the double-precision reciprocal square root calculations.
30152
30153@item -mrecip-precision
30154@itemx -mno-recip-precision
30155@opindex mrecip-precision
30156Assume (do not assume) that the reciprocal estimate instructions
30157provide higher-precision estimates than is mandated by the PowerPC
30158ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
30159@option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
30160The double-precision square root estimate instructions are not generated by
30161default on low-precision machines, since they do not provide an
30162estimate that converges after three steps.
30163
30164@item -mveclibabi=@var{type}
30165@opindex mveclibabi
30166Specifies the ABI type to use for vectorizing intrinsics using an
30167external library. The only type supported at present is @samp{mass},
30168which specifies to use IBM's Mathematical Acceleration Subsystem
30169(MASS) libraries for vectorizing intrinsics using external libraries.
30170GCC currently emits calls to @code{acosd2}, @code{acosf4},
30171@code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
30172@code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
30173@code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
30174@code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
30175@code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
30176@code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
30177@code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
30178@code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
30179@code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
30180@code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
30181@code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
30182@code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
30183@code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
30184for power7. Both @option{-ftree-vectorize} and
30185@option{-funsafe-math-optimizations} must also be enabled. The MASS
30186libraries must be specified at link time.
30187
30188@item -mfriz
30189@itemx -mno-friz
30190@opindex mfriz
30191Generate (do not generate) the @code{friz} instruction when the
30192@option{-funsafe-math-optimizations} option is used to optimize
30193rounding of floating-point values to 64-bit integer and back to floating
30194point. The @code{friz} instruction does not return the same value if
30195the floating-point number is too large to fit in an integer.
30196
30197@item -mpointers-to-nested-functions
30198@itemx -mno-pointers-to-nested-functions
30199@opindex mpointers-to-nested-functions
30200Generate (do not generate) code to load up the static chain register
30201(@code{r11}) when calling through a pointer on AIX and 64-bit Linux
30202systems where a function pointer points to a 3-word descriptor giving
30203the function address, TOC value to be loaded in register @code{r2}, and
30204static chain value to be loaded in register @code{r11}. The
30205@option{-mpointers-to-nested-functions} is on by default. You cannot
30206call through pointers to nested functions or pointers
30207to functions compiled in other languages that use the static chain if
30208you use @option{-mno-pointers-to-nested-functions}.
30209
30210@item -msave-toc-indirect
30211@itemx -mno-save-toc-indirect
30212@opindex msave-toc-indirect
30213Generate (do not generate) code to save the TOC value in the reserved
30214stack location in the function prologue if the function calls through
30215a pointer on AIX and 64-bit Linux systems. If the TOC value is not
30216saved in the prologue, it is saved just before the call through the
30217pointer. The @option{-mno-save-toc-indirect} option is the default.
30218
30219@item -mcompat-align-parm
30220@itemx -mno-compat-align-parm
30221@opindex mcompat-align-parm
30222Generate (do not generate) code to pass structure parameters with a
30223maximum alignment of 64 bits, for compatibility with older versions
30224of GCC.
30225
30226Older versions of GCC (prior to 4.9.0) incorrectly did not align a
30227structure parameter on a 128-bit boundary when that structure contained
30228a member requiring 128-bit alignment. This is corrected in more
30229recent versions of GCC. This option may be used to generate code
30230that is compatible with functions compiled with older versions of
30231GCC.
30232
30233The @option{-mno-compat-align-parm} option is the default.
30234
30235@item -mstack-protector-guard=@var{guard}
30236@itemx -mstack-protector-guard-reg=@var{reg}
30237@itemx -mstack-protector-guard-offset=@var{offset}
30238@itemx -mstack-protector-guard-symbol=@var{symbol}
30239@opindex mstack-protector-guard
30240@opindex mstack-protector-guard-reg
30241@opindex mstack-protector-guard-offset
30242@opindex mstack-protector-guard-symbol
30243Generate stack protection code using canary at @var{guard}. Supported
30244locations are @samp{global} for global canary or @samp{tls} for per-thread
30245canary in the TLS block (the default with GNU libc version 2.4 or later).
30246
30247With the latter choice the options
30248@option{-mstack-protector-guard-reg=@var{reg}} and
30249@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
30250which register to use as base register for reading the canary, and from what
30251offset from that base register. The default for those is as specified in the
30252relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides
30253the offset with a symbol reference to a canary in the TLS block.
30254
30255@item -mpcrel
30256@itemx -mno-pcrel
30257@opindex mpcrel
30258@opindex mno-pcrel
30259Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
30260option requires that the medium code model (@option{-mcmodel=medium})
30261and prefixed addressing (@option{-mprefixed}) options are enabled.
30262
30263@item -mprefixed
30264@itemx -mno-prefixed
30265@opindex mprefixed
30266@opindex mno-prefixed
30267Generate (do not generate) addressing modes using prefixed load and
30268store instructions. The @option{-mprefixed} option requires that
30269the option @option{-mcpu=power10} (or later) is enabled.
30270
30271@item -mmma
30272@itemx -mno-mma
30273@opindex mmma
30274@opindex mno-mma
30275Generate (do not generate) the MMA instructions. The @option{-mma}
30276option requires that the option @option{-mcpu=power10} (or later)
30277is enabled.
30278
30279@item -mrop-protect
30280@itemx -mno-rop-protect
30281@opindex mrop-protect
30282@opindex mno-rop-protect
30283Generate (do not generate) ROP protection instructions when the target
30284processor supports them. Currently this option disables the shrink-wrap
30285optimization (@option{-fshrink-wrap}).
30286
30287@item -mprivileged
30288@itemx -mno-privileged
30289@opindex mprivileged
30290@opindex mno-privileged
30291Generate (do not generate) code that will run in privileged state.
30292
30293@item -mblock-ops-unaligned-vsx
30294@itemx -mno-block-ops-unaligned-vsx
30295@opindex block-ops-unaligned-vsx
30296@opindex no-block-ops-unaligned-vsx
30297Generate (do not generate) unaligned vsx loads and stores for
30298inline expansion of @code{memcpy} and @code{memmove}.
30299
30300@item --param rs6000-vect-unroll-limit=
30301The vectorizer will check with target information to determine whether it
30302would be beneficial to unroll the main vectorized loop and by how much. This
30303parameter sets the upper bound of how much the vectorizer will unroll the main
30304loop. The default value is four.
30305
30306@end table
30307
30308@node RX Options
30309@subsection RX Options
30310@cindex RX Options
30311
30312These command-line options are defined for RX targets:
30313
30314@table @gcctabopt
30315@item -m64bit-doubles
30316@itemx -m32bit-doubles
30317@opindex m64bit-doubles
30318@opindex m32bit-doubles
30319Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
30320or 32 bits (@option{-m32bit-doubles}) in size. The default is
30321@option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
30322works on 32-bit values, which is why the default is
30323@option{-m32bit-doubles}.
30324
30325@item -fpu
30326@itemx -nofpu
30327@opindex fpu
30328@opindex nofpu
30329Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
30330floating-point hardware. The default is enabled for the RX600
30331series and disabled for the RX200 series.
30332
30333Floating-point instructions are only generated for 32-bit floating-point
30334values, however, so the FPU hardware is not used for doubles if the
30335@option{-m64bit-doubles} option is used.
30336
30337@emph{Note} If the @option{-fpu} option is enabled then
30338@option{-funsafe-math-optimizations} is also enabled automatically.
30339This is because the RX FPU instructions are themselves unsafe.
30340
30341@item -mcpu=@var{name}
30342@opindex mcpu
30343Selects the type of RX CPU to be targeted. Currently three types are
30344supported, the generic @samp{RX600} and @samp{RX200} series hardware and
30345the specific @samp{RX610} CPU. The default is @samp{RX600}.
30346
30347The only difference between @samp{RX600} and @samp{RX610} is that the
30348@samp{RX610} does not support the @code{MVTIPL} instruction.
30349
30350The @samp{RX200} series does not have a hardware floating-point unit
30351and so @option{-nofpu} is enabled by default when this type is
30352selected.
30353
30354@item -mbig-endian-data
30355@itemx -mlittle-endian-data
30356@opindex mbig-endian-data
30357@opindex mlittle-endian-data
30358Store data (but not code) in the big-endian format. The default is
30359@option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
30360format.
30361
30362@item -msmall-data-limit=@var{N}
30363@opindex msmall-data-limit
30364Specifies the maximum size in bytes of global and static variables
30365which can be placed into the small data area. Using the small data
30366area can lead to smaller and faster code, but the size of area is
30367limited and it is up to the programmer to ensure that the area does
30368not overflow. Also when the small data area is used one of the RX's
30369registers (usually @code{r13}) is reserved for use pointing to this
30370area, so it is no longer available for use by the compiler. This
30371could result in slower and/or larger code if variables are pushed onto
30372the stack instead of being held in this register.
30373
30374Note, common variables (variables that have not been initialized) and
30375constants are not placed into the small data area as they are assigned
30376to other sections in the output executable.
30377
30378The default value is zero, which disables this feature. Note, this
30379feature is not enabled by default with higher optimization levels
30380(@option{-O2} etc) because of the potentially detrimental effects of
30381reserving a register. It is up to the programmer to experiment and
30382discover whether this feature is of benefit to their program. See the
30383description of the @option{-mpid} option for a description of how the
30384actual register to hold the small data area pointer is chosen.
30385
30386@item -msim
30387@itemx -mno-sim
30388@opindex msim
30389@opindex mno-sim
30390Use the simulator runtime. The default is to use the libgloss
30391board-specific runtime.
30392
30393@item -mas100-syntax
30394@itemx -mno-as100-syntax
30395@opindex mas100-syntax
30396@opindex mno-as100-syntax
30397When generating assembler output use a syntax that is compatible with
30398Renesas's AS100 assembler. This syntax can also be handled by the GAS
30399assembler, but it has some restrictions so it is not generated by default.
30400
30401@item -mmax-constant-size=@var{N}
30402@opindex mmax-constant-size
30403Specifies the maximum size, in bytes, of a constant that can be used as
30404an operand in a RX instruction. Although the RX instruction set does
30405allow constants of up to 4 bytes in length to be used in instructions,
30406a longer value equates to a longer instruction. Thus in some
30407circumstances it can be beneficial to restrict the size of constants
30408that are used in instructions. Constants that are too big are instead
30409placed into a constant pool and referenced via register indirection.
30410
30411The value @var{N} can be between 0 and 4. A value of 0 (the default)
30412or 4 means that constants of any size are allowed.
30413
30414@item -mrelax
30415@opindex mrelax
30416Enable linker relaxation. Linker relaxation is a process whereby the
30417linker attempts to reduce the size of a program by finding shorter
30418versions of various instructions. Disabled by default.
30419
30420@item -mint-register=@var{N}
30421@opindex mint-register
30422Specify the number of registers to reserve for fast interrupt handler
30423functions. The value @var{N} can be between 0 and 4. A value of 1
30424means that register @code{r13} is reserved for the exclusive use
30425of fast interrupt handlers. A value of 2 reserves @code{r13} and
30426@code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
30427@code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
30428A value of 0, the default, does not reserve any registers.
30429
30430@item -msave-acc-in-interrupts
30431@opindex msave-acc-in-interrupts
30432Specifies that interrupt handler functions should preserve the
30433accumulator register. This is only necessary if normal code might use
30434the accumulator register, for example because it performs 64-bit
30435multiplications. The default is to ignore the accumulator as this
30436makes the interrupt handlers faster.
30437
30438@item -mpid
30439@itemx -mno-pid
30440@opindex mpid
30441@opindex mno-pid
30442Enables the generation of position independent data. When enabled any
30443access to constant data is done via an offset from a base address
30444held in a register. This allows the location of constant data to be
30445determined at run time without requiring the executable to be
30446relocated, which is a benefit to embedded applications with tight
30447memory constraints. Data that can be modified is not affected by this
30448option.
30449
30450Note, using this feature reserves a register, usually @code{r13}, for
30451the constant data base address. This can result in slower and/or
30452larger code, especially in complicated functions.
30453
30454The actual register chosen to hold the constant data base address
30455depends upon whether the @option{-msmall-data-limit} and/or the
30456@option{-mint-register} command-line options are enabled. Starting
30457with register @code{r13} and proceeding downwards, registers are
30458allocated first to satisfy the requirements of @option{-mint-register},
30459then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
30460is possible for the small data area register to be @code{r8} if both
30461@option{-mint-register=4} and @option{-mpid} are specified on the
30462command line.
30463
30464By default this feature is not enabled. The default can be restored
30465via the @option{-mno-pid} command-line option.
30466
30467@item -mno-warn-multiple-fast-interrupts
30468@itemx -mwarn-multiple-fast-interrupts
30469@opindex mno-warn-multiple-fast-interrupts
30470@opindex mwarn-multiple-fast-interrupts
30471Prevents GCC from issuing a warning message if it finds more than one
30472fast interrupt handler when it is compiling a file. The default is to
30473issue a warning for each extra fast interrupt handler found, as the RX
30474only supports one such interrupt.
30475
30476@item -mallow-string-insns
30477@itemx -mno-allow-string-insns
30478@opindex mallow-string-insns
30479@opindex mno-allow-string-insns
30480Enables or disables the use of the string manipulation instructions
30481@code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
30482@code{SWHILE} and also the @code{RMPA} instruction. These
30483instructions may prefetch data, which is not safe to do if accessing
30484an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
30485for more information).
30486
30487The default is to allow these instructions, but it is not possible for
30488GCC to reliably detect all circumstances where a string instruction
30489might be used to access an I/O register, so their use cannot be
30490disabled automatically. Instead it is reliant upon the programmer to
30491use the @option{-mno-allow-string-insns} option if their program
30492accesses I/O space.
30493
30494When the instructions are enabled GCC defines the C preprocessor
30495symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
30496symbol @code{__RX_DISALLOW_STRING_INSNS__}.
30497
30498@item -mjsr
30499@itemx -mno-jsr
30500@opindex mjsr
30501@opindex mno-jsr
30502Use only (or not only) @code{JSR} instructions to access functions.
30503This option can be used when code size exceeds the range of @code{BSR}
30504instructions. Note that @option{-mno-jsr} does not mean to not use
30505@code{JSR} but instead means that any type of branch may be used.
30506@end table
30507
30508@emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
30509has special significance to the RX port when used with the
30510@code{interrupt} function attribute. This attribute indicates a
30511function intended to process fast interrupts. GCC ensures
30512that it only uses the registers @code{r10}, @code{r11}, @code{r12}
30513and/or @code{r13} and only provided that the normal use of the
30514corresponding registers have been restricted via the
30515@option{-ffixed-@var{reg}} or @option{-mint-register} command-line
30516options.
30517
30518@node S/390 and zSeries Options
30519@subsection S/390 and zSeries Options
30520@cindex S/390 and zSeries Options
30521
30522These are the @samp{-m} options defined for the S/390 and zSeries architecture.
30523
30524@table @gcctabopt
30525@item -mhard-float
30526@itemx -msoft-float
30527@opindex mhard-float
30528@opindex msoft-float
30529Use (do not use) the hardware floating-point instructions and registers
30530for floating-point operations. When @option{-msoft-float} is specified,
30531functions in @file{libgcc.a} are used to perform floating-point
30532operations. When @option{-mhard-float} is specified, the compiler
30533generates IEEE floating-point instructions. This is the default.
30534
30535@item -mhard-dfp
30536@itemx -mno-hard-dfp
30537@opindex mhard-dfp
30538@opindex mno-hard-dfp
30539Use (do not use) the hardware decimal-floating-point instructions for
30540decimal-floating-point operations. When @option{-mno-hard-dfp} is
30541specified, functions in @file{libgcc.a} are used to perform
30542decimal-floating-point operations. When @option{-mhard-dfp} is
30543specified, the compiler generates decimal-floating-point hardware
30544instructions. This is the default for @option{-march=z9-ec} or higher.
30545
30546@item -mlong-double-64
30547@itemx -mlong-double-128
30548@opindex mlong-double-64
30549@opindex mlong-double-128
30550These switches control the size of @code{long double} type. A size
30551of 64 bits makes the @code{long double} type equivalent to the @code{double}
30552type. This is the default.
30553
30554@item -mbackchain
30555@itemx -mno-backchain
30556@opindex mbackchain
30557@opindex mno-backchain
30558Store (do not store) the address of the caller's frame as backchain pointer
30559into the callee's stack frame.
30560A backchain may be needed to allow debugging using tools that do not understand
30561DWARF call frame information.
30562When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
30563at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
30564the backchain is placed into the topmost word of the 96/160 byte register
30565save area.
30566
30567In general, code compiled with @option{-mbackchain} is call-compatible with
30568code compiled with @option{-mno-backchain}; however, use of the backchain
30569for debugging purposes usually requires that the whole binary is built with
30570@option{-mbackchain}. Note that the combination of @option{-mbackchain},
30571@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30572to build a linux kernel use @option{-msoft-float}.
30573
30574The default is to not maintain the backchain.
30575
30576@item -mpacked-stack
30577@itemx -mno-packed-stack
30578@opindex mpacked-stack
30579@opindex mno-packed-stack
30580Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
30581specified, the compiler uses the all fields of the 96/160 byte register save
30582area only for their default purpose; unused fields still take up stack space.
30583When @option{-mpacked-stack} is specified, register save slots are densely
30584packed at the top of the register save area; unused space is reused for other
30585purposes, allowing for more efficient use of the available stack space.
30586However, when @option{-mbackchain} is also in effect, the topmost word of
30587the save area is always used to store the backchain, and the return address
30588register is always saved two words below the backchain.
30589
30590As long as the stack frame backchain is not used, code generated with
30591@option{-mpacked-stack} is call-compatible with code generated with
30592@option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
30593S/390 or zSeries generated code that uses the stack frame backchain at run
30594time, not just for debugging purposes. Such code is not call-compatible
30595with code compiled with @option{-mpacked-stack}. Also, note that the
30596combination of @option{-mbackchain},
30597@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30598to build a linux kernel use @option{-msoft-float}.
30599
30600The default is to not use the packed stack layout.
30601
30602@item -msmall-exec
30603@itemx -mno-small-exec
30604@opindex msmall-exec
30605@opindex mno-small-exec
30606Generate (or do not generate) code using the @code{bras} instruction
30607to do subroutine calls.
30608This only works reliably if the total executable size does not
30609exceed 64k. The default is to use the @code{basr} instruction instead,
30610which does not have this limitation.
30611
30612@item -m64
30613@itemx -m31
30614@opindex m64
30615@opindex m31
30616When @option{-m31} is specified, generate code compliant to the
30617GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
30618code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
30619particular to generate 64-bit instructions. For the @samp{s390}
30620targets, the default is @option{-m31}, while the @samp{s390x}
30621targets default to @option{-m64}.
30622
30623@item -mzarch
30624@itemx -mesa
30625@opindex mzarch
30626@opindex mesa
30627When @option{-mzarch} is specified, generate code using the
30628instructions available on z/Architecture.
30629When @option{-mesa} is specified, generate code using the
30630instructions available on ESA/390. Note that @option{-mesa} is
30631not possible with @option{-m64}.
30632When generating code compliant to the GNU/Linux for S/390 ABI,
30633the default is @option{-mesa}. When generating code compliant
30634to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
30635
30636@item -mhtm
30637@itemx -mno-htm
30638@opindex mhtm
30639@opindex mno-htm
30640The @option{-mhtm} option enables a set of builtins making use of
30641instructions available with the transactional execution facility
30642introduced with the IBM zEnterprise EC12 machine generation
30643@ref{S/390 System z Built-in Functions}.
30644@option{-mhtm} is enabled by default when using @option{-march=zEC12}.
30645
30646@item -mvx
30647@itemx -mno-vx
30648@opindex mvx
30649@opindex mno-vx
30650When @option{-mvx} is specified, generate code using the instructions
30651available with the vector extension facility introduced with the IBM
30652z13 machine generation.
30653This option changes the ABI for some vector type values with regard to
30654alignment and calling conventions. In case vector type values are
30655being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
30656command will be added to mark the resulting binary with the ABI used.
30657@option{-mvx} is enabled by default when using @option{-march=z13}.
30658
30659@item -mzvector
30660@itemx -mno-zvector
30661@opindex mzvector
30662@opindex mno-zvector
30663The @option{-mzvector} option enables vector language extensions and
30664builtins using instructions available with the vector extension
30665facility introduced with the IBM z13 machine generation.
30666This option adds support for @samp{vector} to be used as a keyword to
30667define vector type variables and arguments. @samp{vector} is only
30668available when GNU extensions are enabled. It will not be expanded
30669when requesting strict standard compliance e.g.@: with @option{-std=c99}.
30670In addition to the GCC low-level builtins @option{-mzvector} enables
30671a set of builtins added for compatibility with AltiVec-style
30672implementations like Power and Cell. In order to make use of these
30673builtins the header file @file{vecintrin.h} needs to be included.
30674@option{-mzvector} is disabled by default.
30675
30676@item -mmvcle
30677@itemx -mno-mvcle
30678@opindex mmvcle
30679@opindex mno-mvcle
30680Generate (or do not generate) code using the @code{mvcle} instruction
30681to perform block moves. When @option{-mno-mvcle} is specified,
30682use a @code{mvc} loop instead. This is the default unless optimizing for
30683size.
30684
30685@item -mdebug
30686@itemx -mno-debug
30687@opindex mdebug
30688@opindex mno-debug
30689Print (or do not print) additional debug information when compiling.
30690The default is to not print debug information.
30691
30692@item -march=@var{cpu-type}
30693@opindex march
30694Generate code that runs on @var{cpu-type}, which is the name of a
30695system representing a certain processor type. Possible values for
30696@var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
30697@samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
30698@samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
30699@samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13},
30700@samp{z16}/@samp{arch14}, and @samp{native}.
30701
30702The default is @option{-march=z900}.
30703
30704Specifying @samp{native} as cpu type can be used to select the best
30705architecture option for the host processor.
30706@option{-march=native} has no effect if GCC does not recognize the
30707processor.
30708
30709@item -mtune=@var{cpu-type}
30710@opindex mtune
30711Tune to @var{cpu-type} everything applicable about the generated code,
30712except for the ABI and the set of available instructions.
30713The list of @var{cpu-type} values is the same as for @option{-march}.
30714The default is the value used for @option{-march}.
30715
30716@item -mtpf-trace
30717@itemx -mno-tpf-trace
30718@opindex mtpf-trace
30719@opindex mno-tpf-trace
30720Generate code that adds (does not add) in TPF OS specific branches to trace
30721routines in the operating system. This option is off by default, even
30722when compiling for the TPF OS@.
30723
30724@item -mtpf-trace-skip
30725@itemx -mno-tpf-trace-skip
30726@opindex mtpf-trace-skip
30727@opindex mno-tpf-trace-skip
30728Generate code that changes (does not change) the default branch
30729targets enabled by @option{-mtpf-trace} to point to specialized trace
30730routines providing the ability of selectively skipping function trace
30731entries for the TPF OS. This option is off by default, even when
30732compiling for the TPF OS and specifying @option{-mtpf-trace}.
30733
30734@item -mfused-madd
30735@itemx -mno-fused-madd
30736@opindex mfused-madd
30737@opindex mno-fused-madd
30738Generate code that uses (does not use) the floating-point multiply and
30739accumulate instructions. These instructions are generated by default if
30740hardware floating point is used.
30741
30742@item -mwarn-framesize=@var{framesize}
30743@opindex mwarn-framesize
30744Emit a warning if the current function exceeds the given frame size. Because
30745this is a compile-time check it doesn't need to be a real problem when the program
30746runs. It is intended to identify functions that most probably cause
30747a stack overflow. It is useful to be used in an environment with limited stack
30748size e.g.@: the linux kernel.
30749
30750@item -mwarn-dynamicstack
30751@opindex mwarn-dynamicstack
30752Emit a warning if the function calls @code{alloca} or uses dynamically-sized
30753arrays. This is generally a bad idea with a limited stack size.
30754
30755@item -mstack-guard=@var{stack-guard}
30756@itemx -mstack-size=@var{stack-size}
30757@opindex mstack-guard
30758@opindex mstack-size
30759If these options are provided the S/390 back end emits additional instructions in
30760the function prologue that trigger a trap if the stack size is @var{stack-guard}
30761bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
30762If the @var{stack-guard} option is omitted the smallest power of 2 larger than
30763the frame size of the compiled function is chosen.
30764These options are intended to be used to help debugging stack overflow problems.
30765The additionally emitted code causes only little overhead and hence can also be
30766used in production-like systems without greater performance degradation. The given
30767values have to be exact powers of 2 and @var{stack-size} has to be greater than
30768@var{stack-guard} without exceeding 64k.
30769In order to be efficient the extra code makes the assumption that the stack starts
30770at an address aligned to the value given by @var{stack-size}.
30771The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
30772
30773@item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
30774@opindex mhotpatch
30775If the hotpatch option is enabled, a ``hot-patching'' function
30776prologue is generated for all functions in the compilation unit.
30777The funtion label is prepended with the given number of two-byte
30778NOP instructions (@var{pre-halfwords}, maximum 1000000). After
30779the label, 2 * @var{post-halfwords} bytes are appended, using the
30780largest NOP like instructions the architecture allows (maximum
307811000000).
30782
30783If both arguments are zero, hotpatching is disabled.
30784
30785This option can be overridden for individual functions with the
30786@code{hotpatch} attribute.
30787@end table
30788
d77de738
ML
30789@node SH Options
30790@subsection SH Options
30791
30792These @samp{-m} options are defined for the SH implementations:
30793
30794@table @gcctabopt
30795@item -m1
30796@opindex m1
30797Generate code for the SH1.
30798
30799@item -m2
30800@opindex m2
30801Generate code for the SH2.
30802
30803@item -m2e
30804Generate code for the SH2e.
30805
30806@item -m2a-nofpu
30807@opindex m2a-nofpu
30808Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
30809that the floating-point unit is not used.
30810
30811@item -m2a-single-only
30812@opindex m2a-single-only
30813Generate code for the SH2a-FPU, in such a way that no double-precision
30814floating-point operations are used.
30815
30816@item -m2a-single
30817@opindex m2a-single
30818Generate code for the SH2a-FPU assuming the floating-point unit is in
30819single-precision mode by default.
30820
30821@item -m2a
30822@opindex m2a
30823Generate code for the SH2a-FPU assuming the floating-point unit is in
30824double-precision mode by default.
30825
30826@item -m3
30827@opindex m3
30828Generate code for the SH3.
30829
30830@item -m3e
30831@opindex m3e
30832Generate code for the SH3e.
30833
30834@item -m4-nofpu
30835@opindex m4-nofpu
30836Generate code for the SH4 without a floating-point unit.
30837
30838@item -m4-single-only
30839@opindex m4-single-only
30840Generate code for the SH4 with a floating-point unit that only
30841supports single-precision arithmetic.
30842
30843@item -m4-single
30844@opindex m4-single
30845Generate code for the SH4 assuming the floating-point unit is in
30846single-precision mode by default.
30847
30848@item -m4
30849@opindex m4
30850Generate code for the SH4.
30851
30852@item -m4-100
30853@opindex m4-100
30854Generate code for SH4-100.
30855
30856@item -m4-100-nofpu
30857@opindex m4-100-nofpu
30858Generate code for SH4-100 in such a way that the
30859floating-point unit is not used.
30860
30861@item -m4-100-single
30862@opindex m4-100-single
30863Generate code for SH4-100 assuming the floating-point unit is in
30864single-precision mode by default.
30865
30866@item -m4-100-single-only
30867@opindex m4-100-single-only
30868Generate code for SH4-100 in such a way that no double-precision
30869floating-point operations are used.
30870
30871@item -m4-200
30872@opindex m4-200
30873Generate code for SH4-200.
30874
30875@item -m4-200-nofpu
30876@opindex m4-200-nofpu
30877Generate code for SH4-200 without in such a way that the
30878floating-point unit is not used.
30879
30880@item -m4-200-single
30881@opindex m4-200-single
30882Generate code for SH4-200 assuming the floating-point unit is in
30883single-precision mode by default.
30884
30885@item -m4-200-single-only
30886@opindex m4-200-single-only
30887Generate code for SH4-200 in such a way that no double-precision
30888floating-point operations are used.
30889
30890@item -m4-300
30891@opindex m4-300
30892Generate code for SH4-300.
30893
30894@item -m4-300-nofpu
30895@opindex m4-300-nofpu
30896Generate code for SH4-300 without in such a way that the
30897floating-point unit is not used.
30898
30899@item -m4-300-single
30900@opindex m4-300-single
30901Generate code for SH4-300 in such a way that no double-precision
30902floating-point operations are used.
30903
30904@item -m4-300-single-only
30905@opindex m4-300-single-only
30906Generate code for SH4-300 in such a way that no double-precision
30907floating-point operations are used.
30908
30909@item -m4-340
30910@opindex m4-340
30911Generate code for SH4-340 (no MMU, no FPU).
30912
30913@item -m4-500
30914@opindex m4-500
30915Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
30916assembler.
30917
30918@item -m4a-nofpu
30919@opindex m4a-nofpu
30920Generate code for the SH4al-dsp, or for a SH4a in such a way that the
30921floating-point unit is not used.
30922
30923@item -m4a-single-only
30924@opindex m4a-single-only
30925Generate code for the SH4a, in such a way that no double-precision
30926floating-point operations are used.
30927
30928@item -m4a-single
30929@opindex m4a-single
30930Generate code for the SH4a assuming the floating-point unit is in
30931single-precision mode by default.
30932
30933@item -m4a
30934@opindex m4a
30935Generate code for the SH4a.
30936
30937@item -m4al
30938@opindex m4al
30939Same as @option{-m4a-nofpu}, except that it implicitly passes
30940@option{-dsp} to the assembler. GCC doesn't generate any DSP
30941instructions at the moment.
30942
30943@item -mb
30944@opindex mb
30945Compile code for the processor in big-endian mode.
30946
30947@item -ml
30948@opindex ml
30949Compile code for the processor in little-endian mode.
30950
30951@item -mdalign
30952@opindex mdalign
30953Align doubles at 64-bit boundaries. Note that this changes the calling
30954conventions, and thus some functions from the standard C library do
30955not work unless you recompile it first with @option{-mdalign}.
30956
30957@item -mrelax
30958@opindex mrelax
30959Shorten some address references at link time, when possible; uses the
30960linker option @option{-relax}.
30961
30962@item -mbigtable
30963@opindex mbigtable
30964Use 32-bit offsets in @code{switch} tables. The default is to use
3096516-bit offsets.
30966
30967@item -mbitops
30968@opindex mbitops
30969Enable the use of bit manipulation instructions on SH2A.
30970
30971@item -mfmovd
30972@opindex mfmovd
30973Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
30974alignment constraints.
30975
30976@item -mrenesas
30977@opindex mrenesas
30978Comply with the calling conventions defined by Renesas.
30979
30980@item -mno-renesas
30981@opindex mno-renesas
30982Comply with the calling conventions defined for GCC before the Renesas
30983conventions were available. This option is the default for all
30984targets of the SH toolchain.
30985
30986@item -mnomacsave
30987@opindex mnomacsave
30988Mark the @code{MAC} register as call-clobbered, even if
30989@option{-mrenesas} is given.
30990
30991@item -mieee
30992@itemx -mno-ieee
30993@opindex mieee
30994@opindex mno-ieee
30995Control the IEEE compliance of floating-point comparisons, which affects the
30996handling of cases where the result of a comparison is unordered. By default
30997@option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
30998enabled @option{-mno-ieee} is implicitly set, which results in faster
30999floating-point greater-equal and less-equal comparisons. The implicit settings
31000can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
31001
31002@item -minline-ic_invalidate
31003@opindex minline-ic_invalidate
31004Inline code to invalidate instruction cache entries after setting up
31005nested function trampolines.
31006This option has no effect if @option{-musermode} is in effect and the selected
31007code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
31008instruction.
31009If the selected code generation option does not allow the use of the @code{icbi}
31010instruction, and @option{-musermode} is not in effect, the inlined code
31011manipulates the instruction cache address array directly with an associative
31012write. This not only requires privileged mode at run time, but it also
31013fails if the cache line had been mapped via the TLB and has become unmapped.
31014
31015@item -misize
31016@opindex misize
31017Dump instruction size and location in the assembly code.
31018
31019@item -mpadstruct
31020@opindex mpadstruct
31021This option is deprecated. It pads structures to multiple of 4 bytes,
31022which is incompatible with the SH ABI@.
31023
31024@item -matomic-model=@var{model}
31025@opindex matomic-model=@var{model}
31026Sets the model of atomic operations and additional parameters as a comma
31027separated list. For details on the atomic built-in functions see
31028@ref{__atomic Builtins}. The following models and parameters are supported:
31029
31030@table @samp
31031
31032@item none
31033Disable compiler generated atomic sequences and emit library calls for atomic
31034operations. This is the default if the target is not @code{sh*-*-linux*}.
31035
31036@item soft-gusa
31037Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
31038built-in functions. The generated atomic sequences require additional support
31039from the interrupt/exception handling code of the system and are only suitable
31040for SH3* and SH4* single-core systems. This option is enabled by default when
31041the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
31042this option also partially utilizes the hardware atomic instructions
31043@code{movli.l} and @code{movco.l} to create more efficient code, unless
31044@samp{strict} is specified.
31045
31046@item soft-tcb
31047Generate software atomic sequences that use a variable in the thread control
31048block. This is a variation of the gUSA sequences which can also be used on
31049SH1* and SH2* targets. The generated atomic sequences require additional
31050support from the interrupt/exception handling code of the system and are only
31051suitable for single-core systems. When using this model, the @samp{gbr-offset=}
31052parameter has to be specified as well.
31053
31054@item soft-imask
31055Generate software atomic sequences that temporarily disable interrupts by
31056setting @code{SR.IMASK = 1111}. This model works only when the program runs
31057in privileged mode and is only suitable for single-core systems. Additional
31058support from the interrupt/exception handling code of the system is not
31059required. This model is enabled by default when the target is
31060@code{sh*-*-linux*} and SH1* or SH2*.
31061
31062@item hard-llcs
31063Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
31064instructions only. This is only available on SH4A and is suitable for
31065multi-core systems. Since the hardware instructions support only 32 bit atomic
31066variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
31067Code compiled with this option is also compatible with other software
31068atomic model interrupt/exception handling systems if executed on an SH4A
31069system. Additional support from the interrupt/exception handling code of the
31070system is not required for this model.
31071
31072@item gbr-offset=
31073This parameter specifies the offset in bytes of the variable in the thread
31074control block structure that should be used by the generated atomic sequences
31075when the @samp{soft-tcb} model has been selected. For other models this
31076parameter is ignored. The specified value must be an integer multiple of four
31077and in the range 0-1020.
31078
31079@item strict
31080This parameter prevents mixed usage of multiple atomic models, even if they
31081are compatible, and makes the compiler generate atomic sequences of the
31082specified model only.
31083
31084@end table
31085
31086@item -mtas
31087@opindex mtas
31088Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
31089Notice that depending on the particular hardware and software configuration
31090this can degrade overall performance due to the operand cache line flushes
31091that are implied by the @code{tas.b} instruction. On multi-core SH4A
31092processors the @code{tas.b} instruction must be used with caution since it
31093can result in data corruption for certain cache configurations.
31094
31095@item -mprefergot
31096@opindex mprefergot
31097When generating position-independent code, emit function calls using
31098the Global Offset Table instead of the Procedure Linkage Table.
31099
31100@item -musermode
31101@itemx -mno-usermode
31102@opindex musermode
31103@opindex mno-usermode
31104Don't allow (allow) the compiler generating privileged mode code. Specifying
31105@option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
31106inlined code would not work in user mode. @option{-musermode} is the default
31107when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
31108@option{-musermode} has no effect, since there is no user mode.
31109
31110@item -multcost=@var{number}
31111@opindex multcost=@var{number}
31112Set the cost to assume for a multiply insn.
31113
31114@item -mdiv=@var{strategy}
31115@opindex mdiv=@var{strategy}
31116Set the division strategy to be used for integer division operations.
31117@var{strategy} can be one of:
31118
31119@table @samp
31120
31121@item call-div1
31122Calls a library function that uses the single-step division instruction
31123@code{div1} to perform the operation. Division by zero calculates an
31124unspecified result and does not trap. This is the default except for SH4,
31125SH2A and SHcompact.
31126
31127@item call-fp
31128Calls a library function that performs the operation in double precision
31129floating point. Division by zero causes a floating-point exception. This is
31130the default for SHcompact with FPU. Specifying this for targets that do not
31131have a double precision FPU defaults to @code{call-div1}.
31132
31133@item call-table
31134Calls a library function that uses a lookup table for small divisors and
31135the @code{div1} instruction with case distinction for larger divisors. Division
31136by zero calculates an unspecified result and does not trap. This is the default
31137for SH4. Specifying this for targets that do not have dynamic shift
31138instructions defaults to @code{call-div1}.
31139
31140@end table
31141
31142When a division strategy has not been specified the default strategy is
31143selected based on the current target. For SH2A the default strategy is to
31144use the @code{divs} and @code{divu} instructions instead of library function
31145calls.
31146
31147@item -maccumulate-outgoing-args
31148@opindex maccumulate-outgoing-args
31149Reserve space once for outgoing arguments in the function prologue rather
31150than around each call. Generally beneficial for performance and size. Also
31151needed for unwinding to avoid changing the stack frame around conditional code.
31152
31153@item -mdivsi3_libfunc=@var{name}
31154@opindex mdivsi3_libfunc=@var{name}
31155Set the name of the library function used for 32-bit signed division to
31156@var{name}.
31157This only affects the name used in the @samp{call} division strategies, and
31158the compiler still expects the same sets of input/output/clobbered registers as
31159if this option were not present.
31160
31161@item -mfixed-range=@var{register-range}
31162@opindex mfixed-range
31163Generate code treating the given register range as fixed registers.
31164A fixed register is one that the register allocator cannot use. This is
31165useful when compiling kernel code. A register range is specified as
31166two registers separated by a dash. Multiple register ranges can be
31167specified separated by a comma.
31168
31169@item -mbranch-cost=@var{num}
31170@opindex mbranch-cost=@var{num}
31171Assume @var{num} to be the cost for a branch instruction. Higher numbers
31172make the compiler try to generate more branch-free code if possible.
31173If not specified the value is selected depending on the processor type that
31174is being compiled for.
31175
31176@item -mzdcbranch
31177@itemx -mno-zdcbranch
31178@opindex mzdcbranch
31179@opindex mno-zdcbranch
31180Assume (do not assume) that zero displacement conditional branch instructions
31181@code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
31182compiler prefers zero displacement branch code sequences. This is
31183enabled by default when generating code for SH4 and SH4A. It can be explicitly
31184disabled by specifying @option{-mno-zdcbranch}.
31185
31186@item -mcbranch-force-delay-slot
31187@opindex mcbranch-force-delay-slot
31188Force the usage of delay slots for conditional branches, which stuffs the delay
31189slot with a @code{nop} if a suitable instruction cannot be found. By default
31190this option is disabled. It can be enabled to work around hardware bugs as
31191found in the original SH7055.
31192
31193@item -mfused-madd
31194@itemx -mno-fused-madd
31195@opindex mfused-madd
31196@opindex mno-fused-madd
31197Generate code that uses (does not use) the floating-point multiply and
31198accumulate instructions. These instructions are generated by default
31199if hardware floating point is used. The machine-dependent
31200@option{-mfused-madd} option is now mapped to the machine-independent
31201@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
31202mapped to @option{-ffp-contract=off}.
31203
31204@item -mfsca
31205@itemx -mno-fsca
31206@opindex mfsca
31207@opindex mno-fsca
31208Allow or disallow the compiler to emit the @code{fsca} instruction for sine
31209and cosine approximations. The option @option{-mfsca} must be used in
31210combination with @option{-funsafe-math-optimizations}. It is enabled by default
31211when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
31212approximations even if @option{-funsafe-math-optimizations} is in effect.
31213
31214@item -mfsrra
31215@itemx -mno-fsrra
31216@opindex mfsrra
31217@opindex mno-fsrra
31218Allow or disallow the compiler to emit the @code{fsrra} instruction for
31219reciprocal square root approximations. The option @option{-mfsrra} must be used
31220in combination with @option{-funsafe-math-optimizations} and
31221@option{-ffinite-math-only}. It is enabled by default when generating code for
31222SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
31223even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
31224in effect.
31225
31226@item -mpretend-cmove
31227@opindex mpretend-cmove
31228Prefer zero-displacement conditional branches for conditional move instruction
31229patterns. This can result in faster code on the SH4 processor.
31230
31231@item -mfdpic
31232@opindex fdpic
31233Generate code using the FDPIC ABI.
31234
31235@end table
31236
31237@node Solaris 2 Options
31238@subsection Solaris 2 Options
31239@cindex Solaris 2 options
31240
31241These @samp{-m} options are supported on Solaris 2:
31242
31243@table @gcctabopt
31244@item -mclear-hwcap
31245@opindex mclear-hwcap
31246@option{-mclear-hwcap} tells the compiler to remove the hardware
31247capabilities generated by the Solaris assembler. This is only necessary
31248when object files use ISA extensions not supported by the current
31249machine, but check at runtime whether or not to use them.
31250
31251@item -mimpure-text
31252@opindex mimpure-text
31253@option{-mimpure-text}, used in addition to @option{-shared}, tells
31254the compiler to not pass @option{-z text} to the linker when linking a
31255shared object. Using this option, you can link position-dependent
31256code into a shared object.
31257
31258@option{-mimpure-text} suppresses the ``relocations remain against
31259allocatable but non-writable sections'' linker error message.
31260However, the necessary relocations trigger copy-on-write, and the
31261shared object is not actually shared across processes. Instead of
31262using @option{-mimpure-text}, you should compile all source code with
31263@option{-fpic} or @option{-fPIC}.
31264
31265@end table
31266
31267These switches are supported in addition to the above on Solaris 2:
31268
31269@table @gcctabopt
31270@item -pthreads
31271@opindex pthreads
31272This is a synonym for @option{-pthread}.
31273@end table
31274
31275@node SPARC Options
31276@subsection SPARC Options
31277@cindex SPARC options
31278
31279These @samp{-m} options are supported on the SPARC:
31280
31281@table @gcctabopt
31282@item -mno-app-regs
31283@itemx -mapp-regs
31284@opindex mno-app-regs
31285@opindex mapp-regs
31286Specify @option{-mapp-regs} to generate output using the global registers
312872 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
31288global register 1, each global register 2 through 4 is then treated as an
31289allocable register that is clobbered by function calls. This is the default.
31290
31291To be fully SVR4 ABI-compliant at the cost of some performance loss,
31292specify @option{-mno-app-regs}. You should compile libraries and system
31293software with this option.
31294
31295@item -mflat
31296@itemx -mno-flat
31297@opindex mflat
31298@opindex mno-flat
31299With @option{-mflat}, the compiler does not generate save/restore instructions
31300and uses a ``flat'' or single register window model. This model is compatible
31301with the regular register window model. The local registers and the input
31302registers (0--5) are still treated as ``call-saved'' registers and are
31303saved on the stack as needed.
31304
31305With @option{-mno-flat} (the default), the compiler generates save/restore
31306instructions (except for leaf functions). This is the normal operating mode.
31307
31308@item -mfpu
31309@itemx -mhard-float
31310@opindex mfpu
31311@opindex mhard-float
31312Generate output containing floating-point instructions. This is the
31313default.
31314
31315@item -mno-fpu
31316@itemx -msoft-float
31317@opindex mno-fpu
31318@opindex msoft-float
31319Generate output containing library calls for floating point.
31320@strong{Warning:} the requisite libraries are not available for all SPARC
31321targets. Normally the facilities of the machine's usual C compiler are
31322used, but this cannot be done directly in cross-compilation. You must make
31323your own arrangements to provide suitable library functions for
31324cross-compilation. The embedded targets @samp{sparc-*-aout} and
31325@samp{sparclite-*-*} do provide software floating-point support.
31326
31327@option{-msoft-float} changes the calling convention in the output file;
31328therefore, it is only useful if you compile @emph{all} of a program with
31329this option. In particular, you need to compile @file{libgcc.a}, the
31330library that comes with GCC, with @option{-msoft-float} in order for
31331this to work.
31332
31333@item -mhard-quad-float
31334@opindex mhard-quad-float
31335Generate output containing quad-word (long double) floating-point
31336instructions.
31337
31338@item -msoft-quad-float
31339@opindex msoft-quad-float
31340Generate output containing library calls for quad-word (long double)
31341floating-point instructions. The functions called are those specified
31342in the SPARC ABI@. This is the default.
31343
31344As of this writing, there are no SPARC implementations that have hardware
31345support for the quad-word floating-point instructions. They all invoke
31346a trap handler for one of these instructions, and then the trap handler
31347emulates the effect of the instruction. Because of the trap handler overhead,
31348this is much slower than calling the ABI library routines. Thus the
31349@option{-msoft-quad-float} option is the default.
31350
31351@item -mno-unaligned-doubles
31352@itemx -munaligned-doubles
31353@opindex mno-unaligned-doubles
31354@opindex munaligned-doubles
31355Assume that doubles have 8-byte alignment. This is the default.
31356
31357With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
31358alignment only if they are contained in another type, or if they have an
31359absolute address. Otherwise, it assumes they have 4-byte alignment.
31360Specifying this option avoids some rare compatibility problems with code
31361generated by other compilers. It is not the default because it results
31362in a performance loss, especially for floating-point code.
31363
31364@item -muser-mode
31365@itemx -mno-user-mode
31366@opindex muser-mode
31367@opindex mno-user-mode
31368Do not generate code that can only run in supervisor mode. This is relevant
31369only for the @code{casa} instruction emitted for the LEON3 processor. This
31370is the default.
31371
31372@item -mfaster-structs
31373@itemx -mno-faster-structs
31374@opindex mfaster-structs
31375@opindex mno-faster-structs
31376With @option{-mfaster-structs}, the compiler assumes that structures
31377should have 8-byte alignment. This enables the use of pairs of
31378@code{ldd} and @code{std} instructions for copies in structure
31379assignment, in place of twice as many @code{ld} and @code{st} pairs.
31380However, the use of this changed alignment directly violates the SPARC
31381ABI@. Thus, it's intended only for use on targets where the developer
31382acknowledges that their resulting code is not directly in line with
31383the rules of the ABI@.
31384
31385@item -mstd-struct-return
31386@itemx -mno-std-struct-return
31387@opindex mstd-struct-return
31388@opindex mno-std-struct-return
31389With @option{-mstd-struct-return}, the compiler generates checking code
31390in functions returning structures or unions to detect size mismatches
31391between the two sides of function calls, as per the 32-bit ABI@.
31392
31393The default is @option{-mno-std-struct-return}. This option has no effect
31394in 64-bit mode.
31395
31396@item -mlra
31397@itemx -mno-lra
31398@opindex mlra
31399@opindex mno-lra
31400Enable Local Register Allocation. This is the default for SPARC since GCC 7
31401so @option{-mno-lra} needs to be passed to get old Reload.
31402
31403@item -mcpu=@var{cpu_type}
31404@opindex mcpu
31405Set the instruction set, register set, and instruction scheduling parameters
31406for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
31407@samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
31408@samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
31409@samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
31410@samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
31411@samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
31412@samp{m8}.
31413
31414Native Solaris and GNU/Linux toolchains also support the value @samp{native},
31415which selects the best architecture option for the host processor.
31416@option{-mcpu=native} has no effect if GCC does not recognize
31417the processor.
31418
31419Default instruction scheduling parameters are used for values that select
31420an architecture and not an implementation. These are @samp{v7}, @samp{v8},
31421@samp{sparclite}, @samp{sparclet}, @samp{v9}.
31422
31423Here is a list of each supported architecture and their supported
31424implementations.
31425
31426@table @asis
31427@item v7
31428cypress, leon3v7
31429
31430@item v8
31431supersparc, hypersparc, leon, leon3, leon5
31432
31433@item sparclite
31434f930, f934, sparclite86x
31435
31436@item sparclet
31437tsc701
31438
31439@item v9
31440ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
31441niagara7, m8
31442@end table
31443
31444By default (unless configured otherwise), GCC generates code for the V7
31445variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
31446additionally optimizes it for the Cypress CY7C602 chip, as used in the
31447SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
31448SPARCStation 1, 2, IPX etc.
31449
31450With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
31451architecture. The only difference from V7 code is that the compiler emits
31452the integer multiply and integer divide instructions which exist in SPARC-V8
31453but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
31454optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
314552000 series.
31456
31457With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
31458the SPARC architecture. This adds the integer multiply, integer divide step
31459and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
31460With @option{-mcpu=f930}, the compiler additionally optimizes it for the
31461Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
31462@option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
31463MB86934 chip, which is the more recent SPARClite with FPU@.
31464
31465With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
31466the SPARC architecture. This adds the integer multiply, multiply/accumulate,
31467integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
31468but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
31469optimizes it for the TEMIC SPARClet chip.
31470
31471With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
31472architecture. This adds 64-bit integer and floating-point move instructions,
314733 additional floating-point condition code registers and conditional move
31474instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
31475optimizes it for the Sun UltraSPARC I/II/IIi chips. With
31476@option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
31477Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
31478@option{-mcpu=niagara}, the compiler additionally optimizes it for
31479Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
31480additionally optimizes it for Sun UltraSPARC T2 chips. With
31481@option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
31482UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
31483additionally optimizes it for Sun UltraSPARC T4 chips. With
31484@option{-mcpu=niagara7}, the compiler additionally optimizes it for
31485Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
31486additionally optimizes it for Oracle M8 chips.
31487
31488@item -mtune=@var{cpu_type}
31489@opindex mtune
31490Set the instruction scheduling parameters for machine type
31491@var{cpu_type}, but do not set the instruction set or register set that the
31492option @option{-mcpu=@var{cpu_type}} does.
31493
31494The same values for @option{-mcpu=@var{cpu_type}} can be used for
31495@option{-mtune=@var{cpu_type}}, but the only useful values are those
31496that select a particular CPU implementation. Those are
31497@samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
31498@samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
31499@samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
31500@samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
31501@samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
31502and GNU/Linux toolchains, @samp{native} can also be used.
31503
31504@item -mv8plus
31505@itemx -mno-v8plus
31506@opindex mv8plus
31507@opindex mno-v8plus
31508With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
31509difference from the V8 ABI is that the global and out registers are
31510considered 64 bits wide. This is enabled by default on Solaris in 32-bit
31511mode for all SPARC-V9 processors.
31512
31513@item -mvis
31514@itemx -mno-vis
31515@opindex mvis
31516@opindex mno-vis
31517With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
31518Visual Instruction Set extensions. The default is @option{-mno-vis}.
31519
31520@item -mvis2
31521@itemx -mno-vis2
31522@opindex mvis2
31523@opindex mno-vis2
31524With @option{-mvis2}, GCC generates code that takes advantage of
31525version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
31526default is @option{-mvis2} when targeting a cpu that supports such
31527instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
31528also sets @option{-mvis}.
31529
31530@item -mvis3
31531@itemx -mno-vis3
31532@opindex mvis3
31533@opindex mno-vis3
31534With @option{-mvis3}, GCC generates code that takes advantage of
31535version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
31536default is @option{-mvis3} when targeting a cpu that supports such
31537instructions, such as niagara-3 and later. Setting @option{-mvis3}
31538also sets @option{-mvis2} and @option{-mvis}.
31539
31540@item -mvis4
31541@itemx -mno-vis4
31542@opindex mvis4
31543@opindex mno-vis4
31544With @option{-mvis4}, GCC generates code that takes advantage of
31545version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
31546default is @option{-mvis4} when targeting a cpu that supports such
31547instructions, such as niagara-7 and later. Setting @option{-mvis4}
31548also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}.
31549
31550@item -mvis4b
31551@itemx -mno-vis4b
31552@opindex mvis4b
31553@opindex mno-vis4b
31554With @option{-mvis4b}, GCC generates code that takes advantage of
31555version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
31556the additional VIS instructions introduced in the Oracle SPARC
31557Architecture 2017. The default is @option{-mvis4b} when targeting a
31558cpu that supports such instructions, such as m8 and later. Setting
31559@option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3},
31560@option{-mvis2} and @option{-mvis}.
31561
31562@item -mcbcond
31563@itemx -mno-cbcond
31564@opindex mcbcond
31565@opindex mno-cbcond
31566With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
31567Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
31568when targeting a CPU that supports such instructions, such as Niagara-4 and
31569later.
31570
31571@item -mfmaf
31572@itemx -mno-fmaf
31573@opindex mfmaf
31574@opindex mno-fmaf
31575With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
31576Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
31577when targeting a CPU that supports such instructions, such as Niagara-3 and
31578later.
31579
31580@item -mfsmuld
31581@itemx -mno-fsmuld
31582@opindex mfsmuld
31583@opindex mno-fsmuld
31584With @option{-mfsmuld}, GCC generates code that takes advantage of the
31585Floating-point Multiply Single to Double (FsMULd) instruction. The default is
31586@option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
31587or V9 with FPU except @option{-mcpu=leon}.
31588
31589@item -mpopc
31590@itemx -mno-popc
31591@opindex mpopc
31592@opindex mno-popc
31593With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
31594Population Count instruction. The default is @option{-mpopc}
31595when targeting a CPU that supports such an instruction, such as Niagara-2 and
31596later.
31597
31598@item -msubxc
31599@itemx -mno-subxc
31600@opindex msubxc
31601@opindex mno-subxc
31602With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
31603Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
31604when targeting a CPU that supports such an instruction, such as Niagara-7 and
31605later.
31606
31607@item -mfix-at697f
31608@opindex mfix-at697f
31609Enable the documented workaround for the single erratum of the Atmel AT697F
31610processor (which corresponds to erratum #13 of the AT697E processor).
31611
31612@item -mfix-ut699
31613@opindex mfix-ut699
31614Enable the documented workarounds for the floating-point errata and the data
31615cache nullify errata of the UT699 processor.
31616
31617@item -mfix-ut700
31618@opindex mfix-ut700
31619Enable the documented workaround for the back-to-back store errata of
31620the UT699E/UT700 processor.
31621
31622@item -mfix-gr712rc
31623@opindex mfix-gr712rc
31624Enable the documented workaround for the back-to-back store errata of
31625the GR712RC processor.
31626@end table
31627
31628These @samp{-m} options are supported in addition to the above
31629on SPARC-V9 processors in 64-bit environments:
31630
31631@table @gcctabopt
31632@item -m32
31633@itemx -m64
31634@opindex m32
31635@opindex m64
31636Generate code for a 32-bit or 64-bit environment.
31637The 32-bit environment sets int, long and pointer to 32 bits.
31638The 64-bit environment sets int to 32 bits and long and pointer
31639to 64 bits.
31640
31641@item -mcmodel=@var{which}
31642@opindex mcmodel
31643Set the code model to one of
31644
31645@table @samp
31646@item medlow
31647The Medium/Low code model: 64-bit addresses, programs
31648must be linked in the low 32 bits of memory. Programs can be statically
31649or dynamically linked.
31650
31651@item medmid
31652The Medium/Middle code model: 64-bit addresses, programs
31653must be linked in the low 44 bits of memory, the text and data segments must
31654be less than 2GB in size and the data segment must be located within 2GB of
31655the text segment.
31656
31657@item medany
31658The Medium/Anywhere code model: 64-bit addresses, programs
31659may be linked anywhere in memory, the text and data segments must be less
31660than 2GB in size and the data segment must be located within 2GB of the
31661text segment.
31662
31663@item embmedany
31664The Medium/Anywhere code model for embedded systems:
3166564-bit addresses, the text and data segments must be less than 2GB in
31666size, both starting anywhere in memory (determined at link time). The
31667global register %g4 points to the base of the data segment. Programs
31668are statically linked and PIC is not supported.
31669@end table
31670
31671@item -mmemory-model=@var{mem-model}
31672@opindex mmemory-model
31673Set the memory model in force on the processor to one of
31674
31675@table @samp
31676@item default
31677The default memory model for the processor and operating system.
31678
31679@item rmo
31680Relaxed Memory Order
31681
31682@item pso
31683Partial Store Order
31684
31685@item tso
31686Total Store Order
31687
31688@item sc
31689Sequential Consistency
31690@end table
31691
31692These memory models are formally defined in Appendix D of the SPARC-V9
31693architecture manual, as set in the processor's @code{PSTATE.MM} field.
31694
31695@item -mstack-bias
31696@itemx -mno-stack-bias
31697@opindex mstack-bias
31698@opindex mno-stack-bias
31699With @option{-mstack-bias}, GCC assumes that the stack pointer, and
31700frame pointer if present, are offset by @minus{}2047 which must be added back
31701when making stack frame references. This is the default in 64-bit mode.
31702Otherwise, assume no such offset is present.
31703@end table
31704
31705@node System V Options
31706@subsection Options for System V
31707
31708These additional options are available on System V Release 4 for
31709compatibility with other compilers on those systems:
31710
31711@table @gcctabopt
31712@item -G
31713@opindex G
31714Create a shared object.
31715It is recommended that @option{-symbolic} or @option{-shared} be used instead.
31716
31717@item -Qy
31718@opindex Qy
31719Identify the versions of each tool used by the compiler, in a
31720@code{.ident} assembler directive in the output.
31721
31722@item -Qn
31723@opindex Qn
31724Refrain from adding @code{.ident} directives to the output file (this is
31725the default).
31726
31727@item -YP,@var{dirs}
31728@opindex YP
31729Search the directories @var{dirs}, and no others, for libraries
31730specified with @option{-l}.
31731
31732@item -Ym,@var{dir}
31733@opindex Ym
31734Look in the directory @var{dir} to find the M4 preprocessor.
31735The assembler uses this option.
31736@c This is supposed to go with a -Yd for predefined M4 macro files, but
31737@c the generic assembler that comes with Solaris takes just -Ym.
31738@end table
31739
31740@node V850 Options
31741@subsection V850 Options
31742@cindex V850 Options
31743
31744These @samp{-m} options are defined for V850 implementations:
31745
31746@table @gcctabopt
31747@item -mlong-calls
31748@itemx -mno-long-calls
31749@opindex mlong-calls
31750@opindex mno-long-calls
31751Treat all calls as being far away (near). If calls are assumed to be
31752far away, the compiler always loads the function's address into a
31753register, and calls indirect through the pointer.
31754
31755@item -mno-ep
31756@itemx -mep
31757@opindex mno-ep
31758@opindex mep
31759Do not optimize (do optimize) basic blocks that use the same index
31760pointer 4 or more times to copy pointer into the @code{ep} register, and
31761use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
31762option is on by default if you optimize.
31763
31764@item -mno-prolog-function
31765@itemx -mprolog-function
31766@opindex mno-prolog-function
31767@opindex mprolog-function
31768Do not use (do use) external functions to save and restore registers
31769at the prologue and epilogue of a function. The external functions
31770are slower, but use less code space if more than one function saves
31771the same number of registers. The @option{-mprolog-function} option
31772is on by default if you optimize.
31773
31774@item -mspace
31775@opindex mspace
31776Try to make the code as small as possible. At present, this just turns
31777on the @option{-mep} and @option{-mprolog-function} options.
31778
31779@item -mtda=@var{n}
31780@opindex mtda
31781Put static or global variables whose size is @var{n} bytes or less into
31782the tiny data area that register @code{ep} points to. The tiny data
31783area can hold up to 256 bytes in total (128 bytes for byte references).
31784
31785@item -msda=@var{n}
31786@opindex msda
31787Put static or global variables whose size is @var{n} bytes or less into
31788the small data area that register @code{gp} points to. The small data
31789area can hold up to 64 kilobytes.
31790
31791@item -mzda=@var{n}
31792@opindex mzda
31793Put static or global variables whose size is @var{n} bytes or less into
31794the first 32 kilobytes of memory.
31795
31796@item -mv850
31797@opindex mv850
31798Specify that the target processor is the V850.
31799
31800@item -mv850e3v5
31801@opindex mv850e3v5
31802Specify that the target processor is the V850E3V5. The preprocessor
31803constant @code{__v850e3v5__} is defined if this option is used.
31804
31805@item -mv850e2v4
31806@opindex mv850e2v4
31807Specify that the target processor is the V850E3V5. This is an alias for
31808the @option{-mv850e3v5} option.
31809
31810@item -mv850e2v3
31811@opindex mv850e2v3
31812Specify that the target processor is the V850E2V3. The preprocessor
31813constant @code{__v850e2v3__} is defined if this option is used.
31814
31815@item -mv850e2
31816@opindex mv850e2
31817Specify that the target processor is the V850E2. The preprocessor
31818constant @code{__v850e2__} is defined if this option is used.
31819
31820@item -mv850e1
31821@opindex mv850e1
31822Specify that the target processor is the V850E1. The preprocessor
31823constants @code{__v850e1__} and @code{__v850e__} are defined if
31824this option is used.
31825
31826@item -mv850es
31827@opindex mv850es
31828Specify that the target processor is the V850ES. This is an alias for
31829the @option{-mv850e1} option.
31830
31831@item -mv850e
31832@opindex mv850e
31833Specify that the target processor is the V850E@. The preprocessor
31834constant @code{__v850e__} is defined if this option is used.
31835
31836If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
31837nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
31838are defined then a default target processor is chosen and the
31839relevant @samp{__v850*__} preprocessor constant is defined.
31840
31841The preprocessor constants @code{__v850} and @code{__v851__} are always
31842defined, regardless of which processor variant is the target.
31843
31844@item -mdisable-callt
31845@itemx -mno-disable-callt
31846@opindex mdisable-callt
31847@opindex mno-disable-callt
31848This option suppresses generation of the @code{CALLT} instruction for the
31849v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
31850architecture.
31851
31852This option is enabled by default when the RH850 ABI is
31853in use (see @option{-mrh850-abi}), and disabled by default when the
31854GCC ABI is in use. If @code{CALLT} instructions are being generated
31855then the C preprocessor symbol @code{__V850_CALLT__} is defined.
31856
31857@item -mrelax
31858@itemx -mno-relax
31859@opindex mrelax
31860@opindex mno-relax
31861Pass on (or do not pass on) the @option{-mrelax} command-line option
31862to the assembler.
31863
31864@item -mlong-jumps
31865@itemx -mno-long-jumps
31866@opindex mlong-jumps
31867@opindex mno-long-jumps
31868Disable (or re-enable) the generation of PC-relative jump instructions.
31869
31870@item -msoft-float
31871@itemx -mhard-float
31872@opindex msoft-float
31873@opindex mhard-float
31874Disable (or re-enable) the generation of hardware floating point
31875instructions. This option is only significant when the target
31876architecture is @samp{V850E2V3} or higher. If hardware floating point
31877instructions are being generated then the C preprocessor symbol
31878@code{__FPU_OK__} is defined, otherwise the symbol
31879@code{__NO_FPU__} is defined.
31880
31881@item -mloop
31882@opindex mloop
31883Enables the use of the e3v5 LOOP instruction. The use of this
31884instruction is not enabled by default when the e3v5 architecture is
31885selected because its use is still experimental.
31886
31887@item -mrh850-abi
31888@itemx -mghs
31889@opindex mrh850-abi
31890@opindex mghs
31891Enables support for the RH850 version of the V850 ABI. This is the
31892default. With this version of the ABI the following rules apply:
31893
31894@itemize
31895@item
31896Integer sized structures and unions are returned via a memory pointer
31897rather than a register.
31898
31899@item
31900Large structures and unions (more than 8 bytes in size) are passed by
31901value.
31902
31903@item
31904Functions are aligned to 16-bit boundaries.
31905
31906@item
31907The @option{-m8byte-align} command-line option is supported.
31908
31909@item
31910The @option{-mdisable-callt} command-line option is enabled by
31911default. The @option{-mno-disable-callt} command-line option is not
31912supported.
31913@end itemize
31914
31915When this version of the ABI is enabled the C preprocessor symbol
31916@code{__V850_RH850_ABI__} is defined.
31917
31918@item -mgcc-abi
31919@opindex mgcc-abi
31920Enables support for the old GCC version of the V850 ABI. With this
31921version of the ABI the following rules apply:
31922
31923@itemize
31924@item
31925Integer sized structures and unions are returned in register @code{r10}.
31926
31927@item
31928Large structures and unions (more than 8 bytes in size) are passed by
31929reference.
31930
31931@item
31932Functions are aligned to 32-bit boundaries, unless optimizing for
31933size.
31934
31935@item
31936The @option{-m8byte-align} command-line option is not supported.
31937
31938@item
31939The @option{-mdisable-callt} command-line option is supported but not
31940enabled by default.
31941@end itemize
31942
31943When this version of the ABI is enabled the C preprocessor symbol
31944@code{__V850_GCC_ABI__} is defined.
31945
31946@item -m8byte-align
31947@itemx -mno-8byte-align
31948@opindex m8byte-align
31949@opindex mno-8byte-align
31950Enables support for @code{double} and @code{long long} types to be
31951aligned on 8-byte boundaries. The default is to restrict the
31952alignment of all objects to at most 4-bytes. When
31953@option{-m8byte-align} is in effect the C preprocessor symbol
31954@code{__V850_8BYTE_ALIGN__} is defined.
31955
31956@item -mbig-switch
31957@opindex mbig-switch
31958Generate code suitable for big switch tables. Use this option only if
31959the assembler/linker complain about out of range branches within a switch
31960table.
31961
31962@item -mapp-regs
31963@opindex mapp-regs
31964This option causes r2 and r5 to be used in the code generated by
31965the compiler. This setting is the default.
31966
31967@item -mno-app-regs
31968@opindex mno-app-regs
31969This option causes r2 and r5 to be treated as fixed registers.
31970
31971@end table
31972
31973@node VAX Options
31974@subsection VAX Options
31975@cindex VAX options
31976
31977These @samp{-m} options are defined for the VAX:
31978
31979@table @gcctabopt
31980@item -munix
31981@opindex munix
31982Do not output certain jump instructions (@code{aobleq} and so on)
31983that the Unix assembler for the VAX cannot handle across long
31984ranges.
31985
31986@item -mgnu
31987@opindex mgnu
31988Do output those jump instructions, on the assumption that the
31989GNU assembler is being used.
31990
31991@item -mg
31992@opindex mg
31993Output code for G-format floating-point numbers instead of D-format.
31994
31995@item -mlra
31996@itemx -mno-lra
31997@opindex mlra
31998@opindex mno-lra
31999Enable Local Register Allocation. This is still experimental for the VAX,
32000so by default the compiler uses standard reload.
32001@end table
32002
32003@node Visium Options
32004@subsection Visium Options
32005@cindex Visium options
32006
32007@table @gcctabopt
32008
32009@item -mdebug
32010@opindex mdebug
32011A program which performs file I/O and is destined to run on an MCM target
32012should be linked with this option. It causes the libraries libc.a and
32013libdebug.a to be linked. The program should be run on the target under
32014the control of the GDB remote debugging stub.
32015
32016@item -msim
32017@opindex msim
32018A program which performs file I/O and is destined to run on the simulator
32019should be linked with option. This causes libraries libc.a and libsim.a to
32020be linked.
32021
32022@item -mfpu
32023@itemx -mhard-float
32024@opindex mfpu
32025@opindex mhard-float
32026Generate code containing floating-point instructions. This is the
32027default.
32028
32029@item -mno-fpu
32030@itemx -msoft-float
32031@opindex mno-fpu
32032@opindex msoft-float
32033Generate code containing library calls for floating-point.
32034
32035@option{-msoft-float} changes the calling convention in the output file;
32036therefore, it is only useful if you compile @emph{all} of a program with
32037this option. In particular, you need to compile @file{libgcc.a}, the
32038library that comes with GCC, with @option{-msoft-float} in order for
32039this to work.
32040
32041@item -mcpu=@var{cpu_type}
32042@opindex mcpu
32043Set the instruction set, register set, and instruction scheduling parameters
32044for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
32045@samp{mcm}, @samp{gr5} and @samp{gr6}.
32046
32047@samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
32048
32049By default (unless configured otherwise), GCC generates code for the GR5
32050variant of the Visium architecture.
32051
32052With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
32053architecture. The only difference from GR5 code is that the compiler will
32054generate block move instructions.
32055
32056@item -mtune=@var{cpu_type}
32057@opindex mtune
32058Set the instruction scheduling parameters for machine type @var{cpu_type},
32059but do not set the instruction set or register set that the option
32060@option{-mcpu=@var{cpu_type}} would.
32061
32062@item -msv-mode
32063@opindex msv-mode
32064Generate code for the supervisor mode, where there are no restrictions on
32065the access to general registers. This is the default.
32066
32067@item -muser-mode
32068@opindex muser-mode
32069Generate code for the user mode, where the access to some general registers
32070is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
32071mode; on the GR6, only registers r29 to r31 are affected.
32072@end table
32073
32074@node VMS Options
32075@subsection VMS Options
32076
32077These @samp{-m} options are defined for the VMS implementations:
32078
32079@table @gcctabopt
32080@item -mvms-return-codes
32081@opindex mvms-return-codes
32082Return VMS condition codes from @code{main}. The default is to return POSIX-style
32083condition (e.g.@: error) codes.
32084
32085@item -mdebug-main=@var{prefix}
32086@opindex mdebug-main=@var{prefix}
32087Flag the first routine whose name starts with @var{prefix} as the main
32088routine for the debugger.
32089
32090@item -mmalloc64
32091@opindex mmalloc64
32092Default to 64-bit memory allocation routines.
32093
32094@item -mpointer-size=@var{size}
32095@opindex mpointer-size=@var{size}
32096Set the default size of pointers. Possible options for @var{size} are
32097@samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
32098for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
32099The later option disables @code{pragma pointer_size}.
32100@end table
32101
32102@node VxWorks Options
32103@subsection VxWorks Options
32104@cindex VxWorks Options
32105
32106The options in this section are defined for all VxWorks targets.
32107Options specific to the target hardware are listed with the other
32108options for that target.
32109
32110@table @gcctabopt
32111@item -mrtp
32112@opindex mrtp
32113GCC can generate code for both VxWorks kernels and real time processes
32114(RTPs). This option switches from the former to the latter. It also
32115defines the preprocessor macro @code{__RTP__}.
32116
32117@item -non-static
32118@opindex non-static
32119Link an RTP executable against shared libraries rather than static
32120libraries. The options @option{-static} and @option{-shared} can
32121also be used for RTPs (@pxref{Link Options}); @option{-static}
32122is the default.
32123
32124@item -Bstatic
32125@itemx -Bdynamic
32126@opindex Bstatic
32127@opindex Bdynamic
32128These options are passed down to the linker. They are defined for
32129compatibility with Diab.
32130
32131@item -Xbind-lazy
32132@opindex Xbind-lazy
32133Enable lazy binding of function calls. This option is equivalent to
32134@option{-Wl,-z,now} and is defined for compatibility with Diab.
32135
32136@item -Xbind-now
32137@opindex Xbind-now
32138Disable lazy binding of function calls. This option is the default and
32139is defined for compatibility with Diab.
32140@end table
32141
32142@node x86 Options
32143@subsection x86 Options
32144@cindex x86 Options
32145
32146These @samp{-m} options are defined for the x86 family of computers.
32147
32148@table @gcctabopt
32149
32150@item -march=@var{cpu-type}
32151@opindex march
32152Generate instructions for the machine type @var{cpu-type}. In contrast to
32153@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
32154for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
32155to generate code that may not run at all on processors other than the one
32156indicated. Specifying @option{-march=@var{cpu-type}} implies
32157@option{-mtune=@var{cpu-type}}, except where noted otherwise.
32158
32159The choices for @var{cpu-type} are:
32160
32161@table @samp
32162@item native
32163This selects the CPU to generate code for at compilation time by determining
32164the processor type of the compiling machine. Using @option{-march=native}
32165enables all instruction subsets supported by the local machine (hence
32166the result might not run on different machines). Using @option{-mtune=native}
32167produces code optimized for the local machine under the constraints
32168of the selected instruction set.
32169
32170@item x86-64
32171A generic CPU with 64-bit extensions.
32172
32173@item x86-64-v2
32174@itemx x86-64-v3
32175@itemx x86-64-v4
32176These choices for @var{cpu-type} select the corresponding
32177micro-architecture level from the x86-64 psABI. On ABIs other than
32178the x86-64 psABI they select the same CPU features as the x86-64 psABI
32179documents for the particular micro-architecture level.
32180
32181Since these @var{cpu-type} values do not have a corresponding
32182@option{-mtune} setting, using @option{-march} with these values enables
32183generic tuning. Specific tuning can be enabled using the
32184@option{-mtune=@var{other-cpu-type}} option with an appropriate
32185@var{other-cpu-type} value.
32186
32187@item i386
32188Original Intel i386 CPU@.
32189
32190@item i486
32191Intel i486 CPU@. (No scheduling is implemented for this chip.)
32192
32193@item i586
32194@itemx pentium
32195Intel Pentium CPU with no MMX support.
32196
32197@item lakemont
32198Intel Lakemont MCU, based on Intel Pentium CPU.
32199
32200@item pentium-mmx
32201Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
32202
32203@item pentiumpro
32204Intel Pentium Pro CPU@.
32205
32206@item i686
32207When used with @option{-march}, the Pentium Pro
32208instruction set is used, so the code runs on all i686 family chips.
32209When used with @option{-mtune}, it has the same meaning as @samp{generic}.
32210
32211@item pentium2
32212Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction
32213set support.
32214
32215@item pentium3
32216@itemx pentium3m
32217Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE
32218instruction set support.
32219
32220@item pentium-m
32221Intel Pentium M; low-power version of Intel Pentium III CPU
32222with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino
32223notebooks.
32224
32225@item pentium4
32226@itemx pentium4m
32227Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support.
32228
32229@item prescott
32230Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR
32231instruction set support.
32232
32233@item nocona
32234Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
32235SSE2, SSE3 and FXSR instruction set support.
32236
32237@item core2
32238Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16,
32239SAHF and FXSR instruction set support.
32240
32241@item nehalem
32242Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32243SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support.
32244
32245@item westmere
32246Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32247SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support.
32248
32249@item sandybridge
32250Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32251SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set
32252support.
32253
32254@item ivybridge
32255Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32256SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND
32257and F16C instruction set support.
32258
32259@item haswell
32260Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32261SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32262F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
32263
32264@item broadwell
32265Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32266SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32267F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW
32268instruction set support.
32269
32270@item skylake
32271Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32272SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32273F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32274CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support.
32275
32276@item bonnell
32277Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
32278instruction set support.
32279
32280@item silvermont
32281Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32282SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND
32283instruction set support.
32284
32285@item goldmont
32286Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32287SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32288RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction
32289set support.
32290
32291@item goldmont-plus
32292Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32293SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES,
32294SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE,
32295RDPID and SGX instruction set support.
32296
32297@item tremont
32298Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32299SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32300RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID,
32301SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
32302support.
32303
32304@item sierraforest
32305Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32306SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32307XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32308MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32309PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32310AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support.
32311
32312@item grandridge
32313Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32314SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32315XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32316MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32317PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32318AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD and RAOINT instruction set
32319support.
32320
32321@item knl
32322Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32323SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32324RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32325AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support.
32326
32327@item knm
32328Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32329SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32330RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32331AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW,
32332AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support.
32333
32334@item skylake-avx512
32335Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32336SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32337RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32338AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW,
32339AVX512DQ and AVX512CD instruction set support.
32340
32341@item cannonlake
32342Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
32343SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
32344FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
32345PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
32346AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set
32347support.
32348
32349@item icelake-client
32350Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32351SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32352RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32353AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32354AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32355, VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32356
32357@item icelake-server
32358Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32359SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32360RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32361AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32362AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32363, VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB
32364instruction set support.
32365
32366@item cascadelake
32367Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32368SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32369F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32370CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32371AVX512CD and AVX512VNNI instruction set support.
32372
32373@item cooperlake
32374Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32375SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32376F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32377CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32378AVX512CD, AVX512VNNI and AVX512BF16 instruction set support.
32379
32380@item tigerlake
32381Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32382SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32383F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32384CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32385PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32386VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB,
32387AVX512VP2INTERSECT and KEYLOCKER instruction set support.
32388
32389@item sapphirerapids
32390Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32391SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32392RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32393AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32394AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32395VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32396MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
29ecb952 32397UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16
d77de738
ML
32398instruction set support.
32399
32400@item alderlake
32401Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32402SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
32403XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B,
32404CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
32405VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set
32406support.
32407
32408@item rocketlake
32409Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3
32410, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32411F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32412CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32413PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32414VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32415
32416@item graniterapids
32417Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32418SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32419RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32420AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32421AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32422VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32423MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG,
29ecb952 32424SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16,
d77de738
ML
32425AVX512BF16, AMX-FP16 and PREFETCHI instruction set support.
32426
32427@item k6
32428AMD K6 CPU with MMX instruction set support.
32429
32430@item k6-2
32431@itemx k6-3
32432Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
32433
32434@item athlon
32435@itemx athlon-tbird
32436AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
32437support.
32438
32439@item athlon-4
32440@itemx athlon-xp
32441@itemx athlon-mp
32442Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
32443instruction set support.
32444
32445@item k8
32446@itemx opteron
32447@itemx athlon64
32448@itemx athlon-fx
32449Processors based on the AMD K8 core with x86-64 instruction set support,
32450including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
32451(This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
32452instruction set extensions.)
32453
32454@item k8-sse3
32455@itemx opteron-sse3
32456@itemx athlon64-sse3
32457Improved versions of AMD K8 cores with SSE3 instruction set support.
32458
32459@item amdfam10
32460@itemx barcelona
32461CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
32462supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
32463instruction set extensions.)
32464
32465@item bdver1
32466CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
32467supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
32468SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
32469
32470@item bdver2
32471AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32472supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
32473SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
32474extensions.)
32475
32476@item bdver3
32477AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32478supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
32479PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
3248064-bit instruction set extensions.)
32481
32482@item bdver4
32483AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32484supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
32485AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
32486SSE4.2, ABM and 64-bit instruction set extensions.)
32487
32488@item znver1
32489AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32490supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
32491SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
32492SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
32493instruction set extensions.)
32494
32495@item znver2
32496AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32497supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32498MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32499SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32500WBNOINVD, and 64-bit instruction set extensions.)
32501
32502@item znver3
32503AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32504supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32505MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32506SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32507WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
32508
32509@item znver4
32510AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32511supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32512MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32513SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32514WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
32515AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
32516AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)
32517
32518@item btver1
32519CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
32520supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
32521instruction set extensions.)
32522
32523@item btver2
32524CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
32525includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
32526SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
32527
32528@item winchip-c6
32529IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
32530set support.
32531
32532@item winchip2
32533IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
32534instruction set support.
32535
32536@item c3
32537VIA C3 CPU with MMX and 3DNow!@: instruction set support.
32538(No scheduling is implemented for this chip.)
32539
32540@item c3-2
32541VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
32542(No scheduling is implemented for this chip.)
32543
32544@item c7
32545VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32546(No scheduling is implemented for this chip.)
32547
32548@item samuel-2
32549VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
32550(No scheduling is implemented for this chip.)
32551
32552@item nehemiah
32553VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
32554(No scheduling is implemented for this chip.)
32555
32556@item esther
32557VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32558(No scheduling is implemented for this chip.)
32559
32560@item eden-x2
32561VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
32562(No scheduling is implemented for this chip.)
32563
32564@item eden-x4
32565VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
32566AVX and AVX2 instruction set support.
32567(No scheduling is implemented for this chip.)
32568
32569@item nano
32570Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32571instruction set support.
32572(No scheduling is implemented for this chip.)
32573
32574@item nano-1000
32575VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32576instruction set support.
32577(No scheduling is implemented for this chip.)
32578
32579@item nano-2000
32580VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32581instruction set support.
32582(No scheduling is implemented for this chip.)
32583
32584@item nano-3000
32585VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32586instruction set support.
32587(No scheduling is implemented for this chip.)
32588
32589@item nano-x2
32590VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32591instruction set support.
32592(No scheduling is implemented for this chip.)
32593
32594@item nano-x4
32595VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32596instruction set support.
32597(No scheduling is implemented for this chip.)
32598
32599@item lujiazui
32600ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
32601SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
32602ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support.
32603
32604@item geode
32605AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
32606@end table
32607
32608@item -mtune=@var{cpu-type}
32609@opindex mtune
32610Tune to @var{cpu-type} everything applicable about the generated code, except
32611for the ABI and the set of available instructions.
32612While picking a specific @var{cpu-type} schedules things appropriately
32613for that particular chip, the compiler does not generate any code that
32614cannot run on the default machine type unless you use a
32615@option{-march=@var{cpu-type}} option.
32616For example, if GCC is configured for i686-pc-linux-gnu
32617then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
32618but still runs on i686 machines.
32619
32620The choices for @var{cpu-type} are the same as for @option{-march}.
32621In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
32622
32623@table @samp
32624@item generic
32625Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
32626If you know the CPU on which your code will run, then you should use
32627the corresponding @option{-mtune} or @option{-march} option instead of
32628@option{-mtune=generic}. But, if you do not know exactly what CPU users
32629of your application will have, then you should use this option.
32630
32631As new processors are deployed in the marketplace, the behavior of this
32632option will change. Therefore, if you upgrade to a newer version of
32633GCC, code generation controlled by this option will change to reflect
32634the processors
32635that are most common at the time that version of GCC is released.
32636
32637There is no @option{-march=generic} option because @option{-march}
32638indicates the instruction set the compiler can use, and there is no
32639generic instruction set applicable to all processors. In contrast,
32640@option{-mtune} indicates the processor (or, in this case, collection of
32641processors) for which the code is optimized.
32642
32643@item intel
32644Produce code optimized for the most current Intel processors, which are
32645Haswell and Silvermont for this version of GCC. If you know the CPU
32646on which your code will run, then you should use the corresponding
32647@option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
32648But, if you want your application performs better on both Haswell and
32649Silvermont, then you should use this option.
32650
32651As new Intel processors are deployed in the marketplace, the behavior of
32652this option will change. Therefore, if you upgrade to a newer version of
32653GCC, code generation controlled by this option will change to reflect
32654the most current Intel processors at the time that version of GCC is
32655released.
32656
32657There is no @option{-march=intel} option because @option{-march} indicates
32658the instruction set the compiler can use, and there is no common
32659instruction set applicable to all processors. In contrast,
32660@option{-mtune} indicates the processor (or, in this case, collection of
32661processors) for which the code is optimized.
32662@end table
32663
32664@item -mcpu=@var{cpu-type}
32665@opindex mcpu
32666A deprecated synonym for @option{-mtune}.
32667
32668@item -mfpmath=@var{unit}
32669@opindex mfpmath
32670Generate floating-point arithmetic for selected unit @var{unit}. The choices
32671for @var{unit} are:
32672
32673@table @samp
32674@item 387
32675Use the standard 387 floating-point coprocessor present on the majority of chips and
32676emulated otherwise. Code compiled with this option runs almost everywhere.
32677The temporary results are computed in 80-bit precision instead of the precision
32678specified by the type, resulting in slightly different results compared to most
32679of other chips. See @option{-ffloat-store} for more detailed description.
32680
32681This is the default choice for non-Darwin x86-32 targets.
32682
32683@item sse
32684Use scalar floating-point instructions present in the SSE instruction set.
32685This instruction set is supported by Pentium III and newer chips,
32686and in the AMD line
32687by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
32688instruction set supports only single-precision arithmetic, thus the double and
32689extended-precision arithmetic are still done using 387. A later version, present
32690only in Pentium 4 and AMD x86-64 chips, supports double-precision
32691arithmetic too.
32692
32693For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
32694or @option{-msse2} switches to enable SSE extensions and make this option
32695effective. For the x86-64 compiler, these extensions are enabled by default.
32696
32697The resulting code should be considerably faster in the majority of cases and avoid
32698the numerical instability problems of 387 code, but may break some existing
32699code that expects temporaries to be 80 bits.
32700
32701This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
32702and the default choice for x86-32 targets with the SSE2 instruction set
32703when @option{-ffast-math} is enabled.
32704
32705@item sse,387
32706@itemx sse+387
32707@itemx both
32708Attempt to utilize both instruction sets at once. This effectively doubles the
32709amount of available registers, and on chips with separate execution units for
32710387 and SSE the execution resources too. Use this option with care, as it is
32711still experimental, because the GCC register allocator does not model separate
32712functional units well, resulting in unstable performance.
32713@end table
32714
32715@item -masm=@var{dialect}
32716@opindex masm=@var{dialect}
32717Output assembly instructions using selected @var{dialect}. Also affects
32718which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
32719extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
32720order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
32721not support @samp{intel}.
32722
32723@item -mieee-fp
32724@itemx -mno-ieee-fp
32725@opindex mieee-fp
32726@opindex mno-ieee-fp
32727Control whether or not the compiler uses IEEE floating-point
32728comparisons. These correctly handle the case where the result of a
32729comparison is unordered.
32730
32731@item -m80387
32732@itemx -mhard-float
30348d30 32733@opindex m80387
d77de738
ML
32734@opindex mhard-float
32735Generate output containing 80387 instructions for floating point.
32736
32737@item -mno-80387
32738@itemx -msoft-float
32739@opindex no-80387
32740@opindex msoft-float
32741Generate output containing library calls for floating point.
32742
32743@strong{Warning:} the requisite libraries are not part of GCC@.
32744Normally the facilities of the machine's usual C compiler are used, but
32745this cannot be done directly in cross-compilation. You must make your
32746own arrangements to provide suitable library functions for
32747cross-compilation.
32748
32749On machines where a function returns floating-point results in the 80387
32750register stack, some floating-point opcodes may be emitted even if
32751@option{-msoft-float} is used.
32752
32753@item -mno-fp-ret-in-387
32754@opindex mno-fp-ret-in-387
32755@opindex mfp-ret-in-387
32756Do not use the FPU registers for return values of functions.
32757
32758The usual calling convention has functions return values of types
32759@code{float} and @code{double} in an FPU register, even if there
32760is no FPU@. The idea is that the operating system should emulate
32761an FPU@.
32762
32763The option @option{-mno-fp-ret-in-387} causes such values to be returned
32764in ordinary CPU registers instead.
32765
32766@item -mno-fancy-math-387
32767@opindex mno-fancy-math-387
32768@opindex mfancy-math-387
32769Some 387 emulators do not support the @code{sin}, @code{cos} and
32770@code{sqrt} instructions for the 387. Specify this option to avoid
32771generating those instructions.
32772This option is overridden when @option{-march}
32773indicates that the target CPU always has an FPU and so the
32774instruction does not need emulation. These
32775instructions are not generated unless you also use the
32776@option{-funsafe-math-optimizations} switch.
32777
32778@item -malign-double
32779@itemx -mno-align-double
32780@opindex malign-double
32781@opindex mno-align-double
32782Control whether GCC aligns @code{double}, @code{long double}, and
32783@code{long long} variables on a two-word boundary or a one-word
32784boundary. Aligning @code{double} variables on a two-word boundary
32785produces code that runs somewhat faster on a Pentium at the
32786expense of more memory.
32787
32788On x86-64, @option{-malign-double} is enabled by default.
32789
32790@strong{Warning:} if you use the @option{-malign-double} switch,
32791structures containing the above types are aligned differently than
32792the published application binary interface specifications for the x86-32
32793and are not binary compatible with structures in code compiled
32794without that switch.
32795
32796@item -m96bit-long-double
32797@itemx -m128bit-long-double
32798@opindex m96bit-long-double
32799@opindex m128bit-long-double
32800These switches control the size of @code{long double} type. The x86-32
32801application binary interface specifies the size to be 96 bits,
32802so @option{-m96bit-long-double} is the default in 32-bit mode.
32803
32804Modern architectures (Pentium and newer) prefer @code{long double}
32805to be aligned to an 8- or 16-byte boundary. In arrays or structures
32806conforming to the ABI, this is not possible. So specifying
32807@option{-m128bit-long-double} aligns @code{long double}
32808to a 16-byte boundary by padding the @code{long double} with an additional
3280932-bit zero.
32810
32811In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
32812its ABI specifies that @code{long double} is aligned on 16-byte boundary.
32813
32814Notice that neither of these options enable any extra precision over the x87
32815standard of 80 bits for a @code{long double}.
32816
32817@strong{Warning:} if you override the default value for your target ABI, this
32818changes the size of
32819structures and arrays containing @code{long double} variables,
32820as well as modifying the function calling convention for functions taking
32821@code{long double}. Hence they are not binary-compatible
32822with code compiled without that switch.
32823
32824@item -mlong-double-64
32825@itemx -mlong-double-80
32826@itemx -mlong-double-128
32827@opindex mlong-double-64
32828@opindex mlong-double-80
32829@opindex mlong-double-128
32830These switches control the size of @code{long double} type. A size
32831of 64 bits makes the @code{long double} type equivalent to the @code{double}
32832type. This is the default for 32-bit Bionic C library. A size
32833of 128 bits makes the @code{long double} type equivalent to the
32834@code{__float128} type. This is the default for 64-bit Bionic C library.
32835
32836@strong{Warning:} if you override the default value for your target ABI, this
32837changes the size of
32838structures and arrays containing @code{long double} variables,
32839as well as modifying the function calling convention for functions taking
32840@code{long double}. Hence they are not binary-compatible
32841with code compiled without that switch.
32842
32843@item -malign-data=@var{type}
32844@opindex malign-data
32845Control how GCC aligns variables. Supported values for @var{type} are
32846@samp{compat} uses increased alignment value compatible uses GCC 4.8
32847and earlier, @samp{abi} uses alignment value as specified by the
32848psABI, and @samp{cacheline} uses increased alignment value to match
32849the cache line size. @samp{compat} is the default.
32850
32851@item -mlarge-data-threshold=@var{threshold}
32852@opindex mlarge-data-threshold
32853When @option{-mcmodel=medium} is specified, data objects larger than
32854@var{threshold} are placed in the large data section. This value must be the
32855same across all objects linked into the binary, and defaults to 65535.
32856
32857@item -mrtd
32858@opindex mrtd
32859Use a different function-calling convention, in which functions that
32860take a fixed number of arguments return with the @code{ret @var{num}}
32861instruction, which pops their arguments while returning. This saves one
32862instruction in the caller since there is no need to pop the arguments
32863there.
32864
32865You can specify that an individual function is called with this calling
32866sequence with the function attribute @code{stdcall}. You can also
32867override the @option{-mrtd} option by using the function attribute
32868@code{cdecl}. @xref{Function Attributes}.
32869
32870@strong{Warning:} this calling convention is incompatible with the one
32871normally used on Unix, so you cannot use it if you need to call
32872libraries compiled with the Unix compiler.
32873
32874Also, you must provide function prototypes for all functions that
32875take variable numbers of arguments (including @code{printf});
32876otherwise incorrect code is generated for calls to those
32877functions.
32878
32879In addition, seriously incorrect code results if you call a
32880function with too many arguments. (Normally, extra arguments are
32881harmlessly ignored.)
32882
32883@item -mregparm=@var{num}
32884@opindex mregparm
32885Control how many registers are used to pass integer arguments. By
32886default, no registers are used to pass arguments, and at most 3
32887registers can be used. You can control this behavior for a specific
32888function by using the function attribute @code{regparm}.
32889@xref{Function Attributes}.
32890
32891@strong{Warning:} if you use this switch, and
32892@var{num} is nonzero, then you must build all modules with the same
32893value, including any libraries. This includes the system libraries and
32894startup modules.
32895
32896@item -msseregparm
32897@opindex msseregparm
32898Use SSE register passing conventions for float and double arguments
32899and return values. You can control this behavior for a specific
32900function by using the function attribute @code{sseregparm}.
32901@xref{Function Attributes}.
32902
32903@strong{Warning:} if you use this switch then you must build all
32904modules with the same value, including any libraries. This includes
32905the system libraries and startup modules.
32906
32907@item -mvect8-ret-in-mem
32908@opindex mvect8-ret-in-mem
32909Return 8-byte vectors in memory instead of MMX registers. This is the
32910default on VxWorks to match the ABI of the Sun Studio compilers until
32911version 12. @emph{Only} use this option if you need to remain
32912compatible with existing code produced by those previous compiler
32913versions or older versions of GCC@.
32914
32915@item -mpc32
32916@itemx -mpc64
32917@itemx -mpc80
32918@opindex mpc32
32919@opindex mpc64
32920@opindex mpc80
32921
32922Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
32923is specified, the significands of results of floating-point operations are
32924rounded to 24 bits (single precision); @option{-mpc64} rounds the
32925significands of results of floating-point operations to 53 bits (double
32926precision) and @option{-mpc80} rounds the significands of results of
32927floating-point operations to 64 bits (extended double precision), which is
32928the default. When this option is used, floating-point operations in higher
32929precisions are not available to the programmer without setting the FPU
32930control word explicitly.
32931
32932Setting the rounding of floating-point operations to less than the default
3293380 bits can speed some programs by 2% or more. Note that some mathematical
32934libraries assume that extended-precision (80-bit) floating-point operations
32935are enabled by default; routines in such libraries could suffer significant
32936loss of accuracy, typically through so-called ``catastrophic cancellation'',
32937when this option is used to set the precision to less than extended precision.
32938
e54375d8 32939@item -mdaz-ftz
32940@opindex mdaz-ftz
32941
32942The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register
32943are used to control floating-point calculations.SSE and AVX instructions
32944including scalar and vector instructions could benefit from enabling the FTZ
32945and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags
32946when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz}
32947will set FTZ/DAZ flags even with @option{-shared}.
32948
d77de738
ML
32949@item -mstackrealign
32950@opindex mstackrealign
32951Realign the stack at entry. On the x86, the @option{-mstackrealign}
32952option generates an alternate prologue and epilogue that realigns the
32953run-time stack if necessary. This supports mixing legacy codes that keep
329544-byte stack alignment with modern codes that keep 16-byte stack alignment for
32955SSE compatibility. See also the attribute @code{force_align_arg_pointer},
32956applicable to individual functions.
32957
32958@item -mpreferred-stack-boundary=@var{num}
32959@opindex mpreferred-stack-boundary
32960Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
32961byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
32962the default is 4 (16 bytes or 128 bits).
32963
32964@strong{Warning:} When generating code for the x86-64 architecture with
32965SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
32966used to keep the stack boundary aligned to 8 byte boundary. Since
32967x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
32968intended to be used in controlled environment where stack space is
32969important limitation. This option leads to wrong code when functions
32970compiled with 16 byte stack alignment (such as functions from a standard
32971library) are called with misaligned stack. In this case, SSE
32972instructions may lead to misaligned memory access traps. In addition,
32973variable arguments are handled incorrectly for 16 byte aligned
32974objects (including x87 long double and __int128), leading to wrong
32975results. You must build all modules with
32976@option{-mpreferred-stack-boundary=3}, including any libraries. This
32977includes the system libraries and startup modules.
32978
32979@item -mincoming-stack-boundary=@var{num}
32980@opindex mincoming-stack-boundary
32981Assume the incoming stack is aligned to a 2 raised to @var{num} byte
32982boundary. If @option{-mincoming-stack-boundary} is not specified,
32983the one specified by @option{-mpreferred-stack-boundary} is used.
32984
32985On Pentium and Pentium Pro, @code{double} and @code{long double} values
32986should be aligned to an 8-byte boundary (see @option{-malign-double}) or
32987suffer significant run time performance penalties. On Pentium III, the
32988Streaming SIMD Extension (SSE) data type @code{__m128} may not work
32989properly if it is not 16-byte aligned.
32990
32991To ensure proper alignment of this values on the stack, the stack boundary
32992must be as aligned as that required by any value stored on the stack.
32993Further, every function must be generated such that it keeps the stack
32994aligned. Thus calling a function compiled with a higher preferred
32995stack boundary from a function compiled with a lower preferred stack
32996boundary most likely misaligns the stack. It is recommended that
32997libraries that use callbacks always use the default setting.
32998
32999This extra alignment does consume extra stack space, and generally
33000increases code size. Code that is sensitive to stack space usage, such
33001as embedded systems and operating system kernels, may want to reduce the
33002preferred alignment to @option{-mpreferred-stack-boundary=2}.
33003
33004@need 200
33005@item -mmmx
33006@opindex mmmx
33007@need 200
33008@itemx -msse
33009@opindex msse
33010@need 200
33011@itemx -msse2
33012@opindex msse2
33013@need 200
33014@itemx -msse3
33015@opindex msse3
33016@need 200
33017@itemx -mssse3
33018@opindex mssse3
33019@need 200
33020@itemx -msse4
33021@opindex msse4
33022@need 200
33023@itemx -msse4a
33024@opindex msse4a
33025@need 200
33026@itemx -msse4.1
33027@opindex msse4.1
33028@need 200
33029@itemx -msse4.2
33030@opindex msse4.2
33031@need 200
33032@itemx -mavx
33033@opindex mavx
33034@need 200
33035@itemx -mavx2
33036@opindex mavx2
33037@need 200
33038@itemx -mavx512f
33039@opindex mavx512f
33040@need 200
33041@itemx -mavx512pf
33042@opindex mavx512pf
33043@need 200
33044@itemx -mavx512er
33045@opindex mavx512er
33046@need 200
33047@itemx -mavx512cd
33048@opindex mavx512cd
33049@need 200
33050@itemx -mavx512vl
33051@opindex mavx512vl
33052@need 200
33053@itemx -mavx512bw
33054@opindex mavx512bw
33055@need 200
33056@itemx -mavx512dq
33057@opindex mavx512dq
33058@need 200
33059@itemx -mavx512ifma
33060@opindex mavx512ifma
33061@need 200
33062@itemx -mavx512vbmi
33063@opindex mavx512vbmi
33064@need 200
33065@itemx -msha
33066@opindex msha
33067@need 200
33068@itemx -maes
33069@opindex maes
33070@need 200
33071@itemx -mpclmul
33072@opindex mpclmul
33073@need 200
33074@itemx -mclflushopt
33075@opindex mclflushopt
33076@need 200
33077@itemx -mclwb
33078@opindex mclwb
33079@need 200
33080@itemx -mfsgsbase
33081@opindex mfsgsbase
33082@need 200
33083@itemx -mptwrite
33084@opindex mptwrite
33085@need 200
33086@itemx -mrdrnd
33087@opindex mrdrnd
33088@need 200
33089@itemx -mf16c
33090@opindex mf16c
33091@need 200
33092@itemx -mfma
33093@opindex mfma
33094@need 200
33095@itemx -mpconfig
33096@opindex mpconfig
33097@need 200
33098@itemx -mwbnoinvd
33099@opindex mwbnoinvd
33100@need 200
33101@itemx -mfma4
33102@opindex mfma4
33103@need 200
33104@itemx -mprfchw
33105@opindex mprfchw
33106@need 200
33107@itemx -mrdpid
33108@opindex mrdpid
33109@need 200
33110@itemx -mprefetchwt1
33111@opindex mprefetchwt1
33112@need 200
33113@itemx -mrdseed
33114@opindex mrdseed
33115@need 200
33116@itemx -msgx
33117@opindex msgx
33118@need 200
33119@itemx -mxop
33120@opindex mxop
33121@need 200
33122@itemx -mlwp
33123@opindex mlwp
33124@need 200
33125@itemx -m3dnow
33126@opindex m3dnow
33127@need 200
33128@itemx -m3dnowa
33129@opindex m3dnowa
33130@need 200
33131@itemx -mpopcnt
33132@opindex mpopcnt
33133@need 200
33134@itemx -mabm
33135@opindex mabm
33136@need 200
33137@itemx -madx
33138@opindex madx
33139@need 200
33140@itemx -mbmi
33141@opindex mbmi
33142@need 200
33143@itemx -mbmi2
33144@opindex mbmi2
33145@need 200
33146@itemx -mlzcnt
33147@opindex mlzcnt
33148@need 200
33149@itemx -mfxsr
33150@opindex mfxsr
33151@need 200
33152@itemx -mxsave
33153@opindex mxsave
33154@need 200
33155@itemx -mxsaveopt
33156@opindex mxsaveopt
33157@need 200
33158@itemx -mxsavec
33159@opindex mxsavec
33160@need 200
33161@itemx -mxsaves
33162@opindex mxsaves
33163@need 200
33164@itemx -mrtm
33165@opindex mrtm
33166@need 200
33167@itemx -mhle
33168@opindex mhle
33169@need 200
33170@itemx -mtbm
33171@opindex mtbm
33172@need 200
33173@itemx -mmwaitx
33174@opindex mmwaitx
33175@need 200
33176@itemx -mclzero
33177@opindex mclzero
33178@need 200
33179@itemx -mpku
33180@opindex mpku
33181@need 200
33182@itemx -mavx512vbmi2
33183@opindex mavx512vbmi2
33184@need 200
33185@itemx -mavx512bf16
33186@opindex mavx512bf16
33187@need 200
33188@itemx -mavx512fp16
33189@opindex mavx512fp16
33190@need 200
33191@itemx -mgfni
33192@opindex mgfni
33193@need 200
33194@itemx -mvaes
33195@opindex mvaes
33196@need 200
33197@itemx -mwaitpkg
33198@opindex mwaitpkg
33199@need 200
33200@itemx -mvpclmulqdq
33201@opindex mvpclmulqdq
33202@need 200
33203@itemx -mavx512bitalg
33204@opindex mavx512bitalg
33205@need 200
33206@itemx -mmovdiri
33207@opindex mmovdiri
33208@need 200
33209@itemx -mmovdir64b
33210@opindex mmovdir64b
33211@need 200
33212@itemx -menqcmd
33213@opindex menqcmd
33214@itemx -muintr
33215@opindex muintr
33216@need 200
33217@itemx -mtsxldtrk
33218@opindex mtsxldtrk
33219@need 200
33220@itemx -mavx512vpopcntdq
33221@opindex mavx512vpopcntdq
33222@need 200
33223@itemx -mavx512vp2intersect
33224@opindex mavx512vp2intersect
33225@need 200
33226@itemx -mavx5124fmaps
33227@opindex mavx5124fmaps
33228@need 200
33229@itemx -mavx512vnni
33230@opindex mavx512vnni
33231@need 200
33232@itemx -mavxvnni
33233@opindex mavxvnni
33234@need 200
33235@itemx -mavx5124vnniw
33236@opindex mavx5124vnniw
33237@need 200
33238@itemx -mcldemote
33239@opindex mcldemote
33240@need 200
33241@itemx -mserialize
33242@opindex mserialize
33243@need 200
33244@itemx -mamx-tile
33245@opindex mamx-tile
33246@need 200
33247@itemx -mamx-int8
33248@opindex mamx-int8
33249@need 200
33250@itemx -mamx-bf16
33251@opindex mamx-bf16
33252@need 200
33253@itemx -mhreset
33254@opindex mhreset
33255@itemx -mkl
33256@opindex mkl
33257@need 200
33258@itemx -mwidekl
33259@opindex mwidekl
33260@need 200
33261@itemx -mavxifma
33262@opindex mavxifma
33263@need 200
33264@itemx -mavxvnniint8
33265@opindex mavxvnniint8
33266@need 200
33267@itemx -mavxneconvert
33268@opindex mavxneconvert
33269@need 200
33270@itemx -mcmpccxadd
33271@opindex mcmpccxadd
33272@need 200
33273@itemx -mamx-fp16
33274@opindex mamx-fp16
33275@need 200
33276@itemx -mprefetchi
33277@opindex mprefetchi
33278@need 200
33279@itemx -mraoint
33280@opindex mraoint
33281These switches enable the use of instructions in the MMX, SSE,
33282SSE2, SSE3, SSSE3, SSE4, SSE4A, SSE4.1, SSE4.2, AVX, AVX2, AVX512F, AVX512PF,
33283AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA,
33284AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
33285WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP,
332863DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE,
33287XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2,
33288GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16,
33289ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE,
29ecb952 33290UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16,
d77de738
ML
33291AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT or
33292CLDEMOTE extended instruction sets. Each has a corresponding @option{-mno-}
33293option to disable use of these instructions.
33294
33295These extensions are also available as built-in functions: see
33296@ref{x86 Built-in Functions}, for details of the functions enabled and
33297disabled by these switches.
33298
33299To generate SSE/SSE2 instructions automatically from floating-point
33300code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
33301
33302GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
33303generates new AVX instructions or AVX equivalence for all SSEx instructions
33304when needed.
33305
33306These options enable GCC to use these extended instructions in
33307generated code, even without @option{-mfpmath=sse}. Applications that
33308perform run-time CPU detection must compile separate files for each
33309supported architecture, using the appropriate flags. In particular,
33310the file containing the CPU detection code should be compiled without
33311these options.
33312
33313@item -mdump-tune-features
33314@opindex mdump-tune-features
33315This option instructs GCC to dump the names of the x86 performance
33316tuning features and default settings. The names can be used in
33317@option{-mtune-ctrl=@var{feature-list}}.
33318
33319@item -mtune-ctrl=@var{feature-list}
33320@opindex mtune-ctrl=@var{feature-list}
33321This option is used to do fine grain control of x86 code generation features.
33322@var{feature-list} is a comma separated list of @var{feature} names. See also
33323@option{-mdump-tune-features}. When specified, the @var{feature} is turned
33324on if it is not preceded with @samp{^}, otherwise, it is turned off.
33325@option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
33326developers. Using it may lead to code paths not covered by testing and can
33327potentially result in compiler ICEs or runtime errors.
33328
33329@item -mno-default
33330@opindex mno-default
33331This option instructs GCC to turn off all tunable features. See also
33332@option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
33333
33334@item -mcld
33335@opindex mcld
33336This option instructs GCC to emit a @code{cld} instruction in the prologue
33337of functions that use string instructions. String instructions depend on
33338the DF flag to select between autoincrement or autodecrement mode. While the
33339ABI specifies the DF flag to be cleared on function entry, some operating
33340systems violate this specification by not clearing the DF flag in their
33341exception dispatchers. The exception handler can be invoked with the DF flag
33342set, which leads to wrong direction mode when string instructions are used.
33343This option can be enabled by default on 32-bit x86 targets by configuring
33344GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
33345instructions can be suppressed with the @option{-mno-cld} compiler option
33346in this case.
33347
33348@item -mvzeroupper
33349@opindex mvzeroupper
33350This option instructs GCC to emit a @code{vzeroupper} instruction
33351before a transfer of control flow out of the function to minimize
33352the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
33353intrinsics.
33354
33355@item -mprefer-avx128
33356@opindex mprefer-avx128
33357This option instructs GCC to use 128-bit AVX instructions instead of
33358256-bit AVX instructions in the auto-vectorizer.
33359
33360@item -mprefer-vector-width=@var{opt}
33361@opindex mprefer-vector-width
33362This option instructs GCC to use @var{opt}-bit vector width in instructions
33363instead of default on the selected platform.
33364
33365@item -mmove-max=@var{bits}
33366@opindex mmove-max
33367This option instructs GCC to set the maximum number of bits can be
33368moved from memory to memory efficiently to @var{bits}. The valid
33369@var{bits} are 128, 256 and 512.
33370
33371@item -mstore-max=@var{bits}
33372@opindex mstore-max
33373This option instructs GCC to set the maximum number of bits can be
33374stored to memory efficiently to @var{bits}. The valid @var{bits} are
33375128, 256 and 512.
33376
33377@table @samp
33378@item none
33379No extra limitations applied to GCC other than defined by the selected platform.
33380
33381@item 128
33382Prefer 128-bit vector width for instructions.
33383
33384@item 256
33385Prefer 256-bit vector width for instructions.
33386
33387@item 512
33388Prefer 512-bit vector width for instructions.
33389@end table
33390
33391@item -mcx16
33392@opindex mcx16
33393This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
33394code to implement compare-and-exchange operations on 16-byte aligned 128-bit
33395objects. This is useful for atomic updates of data structures exceeding one
33396machine word in size. The compiler uses this instruction to implement
33397@ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
33398128-bit integers, a library call is always used.
33399
33400@item -msahf
33401@opindex msahf
33402This option enables generation of @code{SAHF} instructions in 64-bit code.
33403Early Intel Pentium 4 CPUs with Intel 64 support,
33404prior to the introduction of Pentium 4 G1 step in December 2005,
33405lacked the @code{LAHF} and @code{SAHF} instructions
33406which are supported by AMD64.
33407These are load and store instructions, respectively, for certain status flags.
33408In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
33409@code{drem}, and @code{remainder} built-in functions;
33410see @ref{Other Builtins} for details.
33411
33412@item -mmovbe
33413@opindex mmovbe
33414This option enables use of the @code{movbe} instruction to implement
33415@code{__builtin_bswap32} and @code{__builtin_bswap64}.
33416
33417@item -mshstk
33418@opindex mshstk
33419The @option{-mshstk} option enables shadow stack built-in functions
33420from x86 Control-flow Enforcement Technology (CET).
33421
33422@item -mcrc32
33423@opindex mcrc32
33424This option enables built-in functions @code{__builtin_ia32_crc32qi},
33425@code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
33426@code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
33427
33428@item -mmwait
33429@opindex mmwait
33430This option enables built-in functions @code{__builtin_ia32_monitor},
33431and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
33432@code{mwait} machine instructions.
33433
33434@item -mrecip
33435@opindex mrecip
33436This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
33437(and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
33438with an additional Newton-Raphson step
33439to increase precision instead of @code{DIVSS} and @code{SQRTSS}
33440(and their vectorized
33441variants) for single-precision floating-point arguments. These instructions
33442are generated only when @option{-funsafe-math-optimizations} is enabled
33443together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
33444Note that while the throughput of the sequence is higher than the throughput
33445of the non-reciprocal instruction, the precision of the sequence can be
33446decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
33447
33448Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
33449(or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
33450combination), and doesn't need @option{-mrecip}.
33451
33452Also note that GCC emits the above sequence with additional Newton-Raphson step
33453for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
33454already with @option{-ffast-math} (or the above option combination), and
33455doesn't need @option{-mrecip}.
33456
33457@item -mrecip=@var{opt}
33458@opindex mrecip=opt
33459This option controls which reciprocal estimate instructions
33460may be used. @var{opt} is a comma-separated list of options, which may
33461be preceded by a @samp{!} to invert the option:
33462
33463@table @samp
33464@item all
33465Enable all estimate instructions.
33466
33467@item default
33468Enable the default instructions, equivalent to @option{-mrecip}.
33469
33470@item none
33471Disable all estimate instructions, equivalent to @option{-mno-recip}.
33472
33473@item div
33474Enable the approximation for scalar division.
33475
33476@item vec-div
33477Enable the approximation for vectorized division.
33478
33479@item sqrt
33480Enable the approximation for scalar square root.
33481
33482@item vec-sqrt
33483Enable the approximation for vectorized square root.
33484@end table
33485
33486So, for example, @option{-mrecip=all,!sqrt} enables
33487all of the reciprocal approximations, except for square root.
33488
33489@item -mveclibabi=@var{type}
33490@opindex mveclibabi
33491Specifies the ABI type to use for vectorizing intrinsics using an
33492external library. Supported values for @var{type} are @samp{svml}
33493for the Intel short
33494vector math library and @samp{acml} for the AMD math core library.
33495To use this option, both @option{-ftree-vectorize} and
33496@option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
33497ABI-compatible library must be specified at link time.
33498
33499GCC currently emits calls to @code{vmldExp2},
33500@code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2},
33501@code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2},
33502@code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2},
33503@code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2},
33504@code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4},
33505@code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4},
33506@code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4},
33507@code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4},
33508@code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding
33509function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin},
33510@code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
33511@code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
33512@code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
33513@code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
33514when @option{-mveclibabi=acml} is used.
33515
33516@item -mabi=@var{name}
33517@opindex mabi
33518Generate code for the specified calling convention. Permissible values
33519are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
33520@samp{ms} for the Microsoft ABI. The default is to use the Microsoft
33521ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
33522You can control this behavior for specific functions by
33523using the function attributes @code{ms_abi} and @code{sysv_abi}.
33524@xref{Function Attributes}.
33525
33526@item -mforce-indirect-call
33527@opindex mforce-indirect-call
33528Force all calls to functions to be indirect. This is useful
33529when using Intel Processor Trace where it generates more precise timing
33530information for function calls.
33531
33532@item -mmanual-endbr
33533@opindex mmanual-endbr
33534Insert ENDBR instruction at function entry only via the @code{cf_check}
33535function attribute. This is useful when used with the option
33536@option{-fcf-protection=branch} to control ENDBR insertion at the
33537function entry.
33538
33539@item -mcet-switch
33540@opindex mcet-switch
33541By default, CET instrumentation is turned off on switch statements that
33542use a jump table and indirect branch track is disabled. Since jump
33543tables are stored in read-only memory, this does not result in a direct
33544loss of hardening. But if the jump table index is attacker-controlled,
33545the indirect jump may not be constrained by CET. This option turns on
33546CET instrumentation to enable indirect branch track for switch statements
33547with jump tables which leads to the jump targets reachable via any indirect
33548jumps.
33549
33550@item -mcall-ms2sysv-xlogues
33551@opindex mcall-ms2sysv-xlogues
33552@opindex mno-call-ms2sysv-xlogues
33553Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
33554System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
33555default, the code for saving and restoring these registers is emitted inline,
33556resulting in fairly lengthy prologues and epilogues. Using
33557@option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
33558use stubs in the static portion of libgcc to perform these saves and restores,
33559thus reducing function size at the cost of a few extra instructions.
33560
33561@item -mtls-dialect=@var{type}
33562@opindex mtls-dialect
33563Generate code to access thread-local storage using the @samp{gnu} or
33564@samp{gnu2} conventions. @samp{gnu} is the conservative default;
33565@samp{gnu2} is more efficient, but it may add compile- and run-time
33566requirements that cannot be satisfied on all systems.
33567
33568@item -mpush-args
33569@itemx -mno-push-args
33570@opindex mpush-args
33571@opindex mno-push-args
33572Use PUSH operations to store outgoing parameters. This method is shorter
33573and usually equally fast as method using SUB/MOV operations and is enabled
33574by default. In some cases disabling it may improve performance because of
33575improved scheduling and reduced dependencies.
33576
33577@item -maccumulate-outgoing-args
33578@opindex maccumulate-outgoing-args
33579If enabled, the maximum amount of space required for outgoing arguments is
33580computed in the function prologue. This is faster on most modern CPUs
33581because of reduced dependencies, improved scheduling and reduced stack usage
33582when the preferred stack boundary is not equal to 2. The drawback is a notable
33583increase in code size. This switch implies @option{-mno-push-args}.
33584
33585@item -mthreads
33586@opindex mthreads
33587Support thread-safe exception handling on MinGW. Programs that rely
33588on thread-safe exception handling must compile and link all code with the
33589@option{-mthreads} option. When compiling, @option{-mthreads} defines
33590@option{-D_MT}; when linking, it links in a special thread helper library
33591@option{-lmingwthrd} which cleans up per-thread exception-handling data.
33592
33593@item -mms-bitfields
33594@itemx -mno-ms-bitfields
33595@opindex mms-bitfields
33596@opindex mno-ms-bitfields
33597
33598Enable/disable bit-field layout compatible with the native Microsoft
33599Windows compiler.
33600
33601If @code{packed} is used on a structure, or if bit-fields are used,
33602it may be that the Microsoft ABI lays out the structure differently
33603than the way GCC normally does. Particularly when moving packed
33604data between functions compiled with GCC and the native Microsoft compiler
33605(either via function call or as data in a file), it may be necessary to access
33606either format.
33607
33608This option is enabled by default for Microsoft Windows
33609targets. This behavior can also be controlled locally by use of variable
33610or type attributes. For more information, see @ref{x86 Variable Attributes}
33611and @ref{x86 Type Attributes}.
33612
33613The Microsoft structure layout algorithm is fairly simple with the exception
33614of the bit-field packing.
33615The padding and alignment of members of structures and whether a bit-field
33616can straddle a storage-unit boundary are determine by these rules:
33617
33618@enumerate
33619@item Structure members are stored sequentially in the order in which they are
33620declared: the first member has the lowest memory address and the last member
33621the highest.
33622
33623@item Every data object has an alignment requirement. The alignment requirement
33624for all data except structures, unions, and arrays is either the size of the
33625object or the current packing size (specified with either the
33626@code{aligned} attribute or the @code{pack} pragma),
33627whichever is less. For structures, unions, and arrays,
33628the alignment requirement is the largest alignment requirement of its members.
33629Every object is allocated an offset so that:
33630
33631@smallexample
33632offset % alignment_requirement == 0
33633@end smallexample
33634
33635@item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
33636unit if the integral types are the same size and if the next bit-field fits
33637into the current allocation unit without crossing the boundary imposed by the
33638common alignment requirements of the bit-fields.
33639@end enumerate
33640
33641MSVC interprets zero-length bit-fields in the following ways:
33642
33643@enumerate
33644@item If a zero-length bit-field is inserted between two bit-fields that
33645are normally coalesced, the bit-fields are not coalesced.
33646
33647For example:
33648
33649@smallexample
33650struct
33651 @{
33652 unsigned long bf_1 : 12;
33653 unsigned long : 0;
33654 unsigned long bf_2 : 12;
33655 @} t1;
33656@end smallexample
33657
33658@noindent
33659The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
33660zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
33661
33662@item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
33663alignment of the zero-length bit-field is greater than the member that follows it,
33664@code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
33665
33666For example:
33667
33668@smallexample
33669struct
33670 @{
33671 char foo : 4;
33672 short : 0;
33673 char bar;
33674 @} t2;
33675
33676struct
33677 @{
33678 char foo : 4;
33679 short : 0;
33680 double bar;
33681 @} t3;
33682@end smallexample
33683
33684@noindent
33685For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
33686Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
33687bit-field does not affect the alignment of @code{bar} or, as a result, the size
33688of the structure.
33689
33690Taking this into account, it is important to note the following:
33691
33692@enumerate
33693@item If a zero-length bit-field follows a normal bit-field, the type of the
33694zero-length bit-field may affect the alignment of the structure as whole. For
33695example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
33696normal bit-field, and is of type short.
33697
33698@item Even if a zero-length bit-field is not followed by a normal bit-field, it may
33699still affect the alignment of the structure:
33700
33701@smallexample
33702struct
33703 @{
33704 char foo : 6;
33705 long : 0;
33706 @} t4;
33707@end smallexample
33708
33709@noindent
33710Here, @code{t4} takes up 4 bytes.
33711@end enumerate
33712
33713@item Zero-length bit-fields following non-bit-field members are ignored:
33714
33715@smallexample
33716struct
33717 @{
33718 char foo;
33719 long : 0;
33720 char bar;
33721 @} t5;
33722@end smallexample
33723
33724@noindent
33725Here, @code{t5} takes up 2 bytes.
33726@end enumerate
33727
33728
33729@item -mno-align-stringops
33730@opindex mno-align-stringops
33731@opindex malign-stringops
33732Do not align the destination of inlined string operations. This switch reduces
33733code size and improves performance in case the destination is already aligned,
33734but GCC doesn't know about it.
33735
33736@item -minline-all-stringops
33737@opindex minline-all-stringops
33738By default GCC inlines string operations only when the destination is
33739known to be aligned to least a 4-byte boundary.
33740This enables more inlining and increases code
33741size, but may improve performance of code that depends on fast
33742@code{memcpy} and @code{memset} for short lengths.
33743The option enables inline expansion of @code{strlen} for all
33744pointer alignments.
33745
33746@item -minline-stringops-dynamically
33747@opindex minline-stringops-dynamically
33748For string operations of unknown size, use run-time checks with
33749inline code for small blocks and a library call for large blocks.
33750
33751@item -mstringop-strategy=@var{alg}
33752@opindex mstringop-strategy=@var{alg}
33753Override the internal decision heuristic for the particular algorithm to use
33754for inlining string operations. The allowed values for @var{alg} are:
33755
33756@table @samp
33757@item rep_byte
33758@itemx rep_4byte
33759@itemx rep_8byte
33760Expand using i386 @code{rep} prefix of the specified size.
33761
33762@item byte_loop
33763@itemx loop
33764@itemx unrolled_loop
33765Expand into an inline loop.
33766
33767@item libcall
33768Always use a library call.
33769@end table
33770
33771@item -mmemcpy-strategy=@var{strategy}
33772@opindex mmemcpy-strategy=@var{strategy}
33773Override the internal decision heuristic to decide if @code{__builtin_memcpy}
33774should be inlined and what inline algorithm to use when the expected size
33775of the copy operation is known. @var{strategy}
33776is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
33777@var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
33778the max byte size with which inline algorithm @var{alg} is allowed. For the last
33779triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
33780in the list must be specified in increasing order. The minimal byte size for
33781@var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
33782preceding range.
33783
33784@item -mmemset-strategy=@var{strategy}
33785@opindex mmemset-strategy=@var{strategy}
33786The option is similar to @option{-mmemcpy-strategy=} except that it is to control
33787@code{__builtin_memset} expansion.
33788
33789@item -momit-leaf-frame-pointer
33790@opindex momit-leaf-frame-pointer
33791Don't keep the frame pointer in a register for leaf functions. This
33792avoids the instructions to save, set up, and restore frame pointers and
33793makes an extra register available in leaf functions. The option
33794@option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
33795which might make debugging harder.
33796
33797@item -mtls-direct-seg-refs
33798@itemx -mno-tls-direct-seg-refs
33799@opindex mtls-direct-seg-refs
33800Controls whether TLS variables may be accessed with offsets from the
33801TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
33802or whether the thread base pointer must be added. Whether or not this
33803is valid depends on the operating system, and whether it maps the
33804segment to cover the entire TLS area.
33805
33806For systems that use the GNU C Library, the default is on.
33807
33808@item -msse2avx
33809@itemx -mno-sse2avx
33810@opindex msse2avx
33811Specify that the assembler should encode SSE instructions with VEX
33812prefix. The option @option{-mavx} turns this on by default.
33813
33814@item -mfentry
33815@itemx -mno-fentry
33816@opindex mfentry
33817If profiling is active (@option{-pg}), put the profiling
33818counter call before the prologue.
33819Note: On x86 architectures the attribute @code{ms_hook_prologue}
33820isn't possible at the moment for @option{-mfentry} and @option{-pg}.
33821
33822@item -mrecord-mcount
33823@itemx -mno-record-mcount
33824@opindex mrecord-mcount
33825If profiling is active (@option{-pg}), generate a __mcount_loc section
33826that contains pointers to each profiling call. This is useful for
33827automatically patching and out calls.
33828
33829@item -mnop-mcount
33830@itemx -mno-nop-mcount
33831@opindex mnop-mcount
33832If profiling is active (@option{-pg}), generate the calls to
33833the profiling functions as NOPs. This is useful when they
33834should be patched in later dynamically. This is likely only
33835useful together with @option{-mrecord-mcount}.
33836
33837@item -minstrument-return=@var{type}
33838@opindex minstrument-return
33839Instrument function exit in -pg -mfentry instrumented functions with
33840call to specified function. This only instruments true returns ending
33841with ret, but not sibling calls ending with jump. Valid types
33842are @var{none} to not instrument, @var{call} to generate a call to __return__,
33843or @var{nop5} to generate a 5 byte nop.
33844
33845@item -mrecord-return
33846@itemx -mno-record-return
33847@opindex mrecord-return
33848Generate a __return_loc section pointing to all return instrumentation code.
33849
33850@item -mfentry-name=@var{name}
33851@opindex mfentry-name
33852Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
33853
33854@item -mfentry-section=@var{name}
33855@opindex mfentry-section
33856Set name of section to record -mrecord-mcount calls (default __mcount_loc).
33857
33858@item -mskip-rax-setup
33859@itemx -mno-skip-rax-setup
33860@opindex mskip-rax-setup
33861When generating code for the x86-64 architecture with SSE extensions
33862disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
33863register when there are no variable arguments passed in vector registers.
33864
33865@strong{Warning:} Since RAX register is used to avoid unnecessarily
33866saving vector registers on stack when passing variable arguments, the
33867impacts of this option are callees may waste some stack space,
33868misbehave or jump to a random location. GCC 4.4 or newer don't have
33869those issues, regardless the RAX register value.
33870
33871@item -m8bit-idiv
33872@itemx -mno-8bit-idiv
33873@opindex m8bit-idiv
33874On some processors, like Intel Atom, 8-bit unsigned integer divide is
33875much faster than 32-bit/64-bit integer divide. This option generates a
33876run-time check. If both dividend and divisor are within range of 0
33877to 255, 8-bit unsigned integer divide is used instead of
3387832-bit/64-bit integer divide.
33879
33880@item -mavx256-split-unaligned-load
33881@itemx -mavx256-split-unaligned-store
33882@opindex mavx256-split-unaligned-load
33883@opindex mavx256-split-unaligned-store
33884Split 32-byte AVX unaligned load and store.
33885
33886@item -mstack-protector-guard=@var{guard}
33887@itemx -mstack-protector-guard-reg=@var{reg}
33888@itemx -mstack-protector-guard-offset=@var{offset}
33889@opindex mstack-protector-guard
33890@opindex mstack-protector-guard-reg
33891@opindex mstack-protector-guard-offset
33892Generate stack protection code using canary at @var{guard}. Supported
33893locations are @samp{global} for global canary or @samp{tls} for per-thread
33894canary in the TLS block (the default). This option has effect only when
33895@option{-fstack-protector} or @option{-fstack-protector-all} is specified.
33896
33897With the latter choice the options
33898@option{-mstack-protector-guard-reg=@var{reg}} and
33899@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
33900which segment register (@code{%fs} or @code{%gs}) to use as base register
33901for reading the canary, and from what offset from that base register.
33902The default for those is as specified in the relevant ABI.
33903
33904@item -mgeneral-regs-only
33905@opindex mgeneral-regs-only
33906Generate code that uses only the general-purpose registers. This
33907prevents the compiler from using floating-point, vector, mask and bound
33908registers.
33909
33910@item -mrelax-cmpxchg-loop
33911@opindex mrelax-cmpxchg-loop
85966f0d
AM
33912When emitting a compare-and-swap loop for @ref{__sync Builtins}
33913and @ref{__atomic Builtins} lacking a native instruction, optimize
33914for the highly contended case by issuing an atomic load before the
33915@code{CMPXCHG} instruction, and using the @code{PAUSE} instruction
33916to save CPU power when restarting the loop.
d77de738
ML
33917
33918@item -mindirect-branch=@var{choice}
33919@opindex mindirect-branch
33920Convert indirect call and jump with @var{choice}. The default is
33921@samp{keep}, which keeps indirect call and jump unmodified.
33922@samp{thunk} converts indirect call and jump to call and return thunk.
33923@samp{thunk-inline} converts indirect call and jump to inlined call
33924and return thunk. @samp{thunk-extern} converts indirect call and jump
33925to external call and return thunk provided in a separate object file.
33926You can control this behavior for a specific function by using the
33927function attribute @code{indirect_branch}. @xref{Function Attributes}.
33928
33929Note that @option{-mcmodel=large} is incompatible with
33930@option{-mindirect-branch=thunk} and
33931@option{-mindirect-branch=thunk-extern} since the thunk function may
33932not be reachable in the large code model.
33933
33934Note that @option{-mindirect-branch=thunk-extern} is compatible with
33935@option{-fcf-protection=branch} since the external thunk can be made
33936to enable control-flow check.
33937
33938@item -mfunction-return=@var{choice}
33939@opindex mfunction-return
33940Convert function return with @var{choice}. The default is @samp{keep},
33941which keeps function return unmodified. @samp{thunk} converts function
33942return to call and return thunk. @samp{thunk-inline} converts function
33943return to inlined call and return thunk. @samp{thunk-extern} converts
33944function return to external call and return thunk provided in a separate
33945object file. You can control this behavior for a specific function by
33946using the function attribute @code{function_return}.
33947@xref{Function Attributes}.
33948
33949Note that @option{-mindirect-return=thunk-extern} is compatible with
33950@option{-fcf-protection=branch} since the external thunk can be made
33951to enable control-flow check.
33952
33953Note that @option{-mcmodel=large} is incompatible with
33954@option{-mfunction-return=thunk} and
33955@option{-mfunction-return=thunk-extern} since the thunk function may
33956not be reachable in the large code model.
33957
33958
33959@item -mindirect-branch-register
33960@opindex mindirect-branch-register
33961Force indirect call and jump via register.
33962
33963@item -mharden-sls=@var{choice}
33964@opindex mharden-sls
33965Generate code to mitigate against straight line speculation (SLS) with
33966@var{choice}. The default is @samp{none} which disables all SLS
33967hardening. @samp{return} enables SLS hardening for function returns.
33968@samp{indirect-jmp} enables SLS hardening for indirect jumps.
33969@samp{all} enables all SLS hardening.
33970
33971@item -mindirect-branch-cs-prefix
33972@opindex mindirect-branch-cs-prefix
33973Add CS prefix to call and jmp to indirect thunk with branch target in
33974r8-r15 registers so that the call and jmp instruction length is 6 bytes
33975to allow them to be replaced with @samp{lfence; call *%r8-r15} or
33976@samp{lfence; jmp *%r8-r15} at run-time.
33977
33978@end table
33979
33980These @samp{-m} switches are supported in addition to the above
33981on x86-64 processors in 64-bit environments.
33982
33983@table @gcctabopt
33984@item -m32
33985@itemx -m64
33986@itemx -mx32
33987@itemx -m16
33988@itemx -miamcu
33989@opindex m32
33990@opindex m64
33991@opindex mx32
33992@opindex m16
33993@opindex miamcu
33994Generate code for a 16-bit, 32-bit or 64-bit environment.
33995The @option{-m32} option sets @code{int}, @code{long}, and pointer types
33996to 32 bits, and
33997generates code that runs on any i386 system.
33998
33999The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
34000types to 64 bits, and generates code for the x86-64 architecture.
34001For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
34002and @option{-mdynamic-no-pic} options.
34003
34004The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
34005to 32 bits, and
34006generates code for the x86-64 architecture.
34007
34008The @option{-m16} option is the same as @option{-m32}, except for that
34009it outputs the @code{.code16gcc} assembly directive at the beginning of
34010the assembly output so that the binary can run in 16-bit mode.
34011
34012The @option{-miamcu} option generates code which conforms to Intel MCU
34013psABI. It requires the @option{-m32} option to be turned on.
34014
34015@item -mno-red-zone
34016@opindex mno-red-zone
34017@opindex mred-zone
34018Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
34019by the x86-64 ABI; it is a 128-byte area beyond the location of the
34020stack pointer that is not modified by signal or interrupt handlers
34021and therefore can be used for temporary data without adjusting the stack
34022pointer. The flag @option{-mno-red-zone} disables this red zone.
34023
34024@item -mcmodel=small
34025@opindex mcmodel=small
34026Generate code for the small code model: the program and its symbols must
34027be linked in the lower 2 GB of the address space. Pointers are 64 bits.
34028Programs can be statically or dynamically linked. This is the default
34029code model.
34030
34031@item -mcmodel=kernel
34032@opindex mcmodel=kernel
34033Generate code for the kernel code model. The kernel runs in the
34034negative 2 GB of the address space.
34035This model has to be used for Linux kernel code.
34036
34037@item -mcmodel=medium
34038@opindex mcmodel=medium
34039Generate code for the medium model: the program is linked in the lower 2
34040GB of the address space. Small symbols are also placed there. Symbols
34041with sizes larger than @option{-mlarge-data-threshold} are put into
34042large data or BSS sections and can be located above 2GB. Programs can
34043be statically or dynamically linked.
34044
34045@item -mcmodel=large
34046@opindex mcmodel=large
34047Generate code for the large model. This model makes no assumptions
34048about addresses and sizes of sections.
34049
34050@item -maddress-mode=long
34051@opindex maddress-mode=long
34052Generate code for long address mode. This is only supported for 64-bit
34053and x32 environments. It is the default address mode for 64-bit
34054environments.
34055
34056@item -maddress-mode=short
34057@opindex maddress-mode=short
34058Generate code for short address mode. This is only supported for 32-bit
34059and x32 environments. It is the default address mode for 32-bit and
34060x32 environments.
34061
34062@item -mneeded
34063@itemx -mno-needed
34064@opindex mneeded
34065Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
34066indicate the micro-architecture ISA level required to execute the binary.
34067
34068@item -mno-direct-extern-access
34069@opindex mno-direct-extern-access
34070@opindex mdirect-extern-access
34071Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer
34072to access external symbols. With @option{-fpic} or @option{-fPIC},
34073treat access to protected symbols as local symbols. The default is
34074@option{-mdirect-extern-access}.
34075
34076@strong{Warning:} shared libraries compiled with
34077@option{-mno-direct-extern-access} and executable compiled with
34078@option{-mdirect-extern-access} may not be binary compatible if
34079protected symbols are used in shared libraries and executable.
ce51e843
ML
34080
34081@item -munroll-only-small-loops
34082@opindex munroll-only-small-loops
34083@opindex mno-unroll-only-small-loops
34084Controls conservative small loop unrolling. It is default enabled by
34085O2, and unrolls loop with less than 4 insns by 1 time. Explicit
34086-f[no-]unroll-[all-]loops would disable this flag to avoid any
34087unintended unrolling behavior that user does not want.
bb576017 34088
34089@item -mlam=@var{choice}
34090@opindex mlam
34091LAM(linear-address masking) allows special bits in the pointer to be used
34092for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in
34093positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in
34094positions 62:57 can be used for metadata.
d77de738
ML
34095@end table
34096
34097@node x86 Windows Options
34098@subsection x86 Windows Options
34099@cindex x86 Windows Options
34100@cindex Windows Options for x86
34101
34102These additional options are available for Microsoft Windows targets:
34103
34104@table @gcctabopt
34105@item -mconsole
34106@opindex mconsole
34107This option
34108specifies that a console application is to be generated, by
34109instructing the linker to set the PE header subsystem type
34110required for console applications.
34111This option is available for Cygwin and MinGW targets and is
34112enabled by default on those targets.
34113
34114@item -mdll
34115@opindex mdll
34116This option is available for Cygwin and MinGW targets. It
34117specifies that a DLL---a dynamic link library---is to be
34118generated, enabling the selection of the required runtime
34119startup object and entry point.
34120
34121@item -mnop-fun-dllimport
34122@opindex mnop-fun-dllimport
34123This option is available for Cygwin and MinGW targets. It
34124specifies that the @code{dllimport} attribute should be ignored.
34125
34126@item -mthreads
34127@opindex mthreads
34128This option is available for MinGW targets. It specifies
34129that MinGW-specific thread support is to be used.
34130
34131@item -municode
34132@opindex municode
34133This option is available for MinGW-w64 targets. It causes
34134the @code{UNICODE} preprocessor macro to be predefined, and
34135chooses Unicode-capable runtime startup code.
34136
34137@item -mwin32
34138@opindex mwin32
34139This option is available for Cygwin and MinGW targets. It
34140specifies that the typical Microsoft Windows predefined macros are to
34141be set in the pre-processor, but does not influence the choice
34142of runtime library/startup code.
34143
34144@item -mwindows
34145@opindex mwindows
34146This option is available for Cygwin and MinGW targets. It
34147specifies that a GUI application is to be generated by
34148instructing the linker to set the PE header subsystem type
34149appropriately.
34150
34151@item -fno-set-stack-executable
34152@opindex fno-set-stack-executable
34153@opindex fset-stack-executable
34154This option is available for MinGW targets. It specifies that
34155the executable flag for the stack used by nested functions isn't
34156set. This is necessary for binaries running in kernel mode of
34157Microsoft Windows, as there the User32 API, which is used to set executable
34158privileges, isn't available.
34159
34160@item -fwritable-relocated-rdata
34161@opindex fno-writable-relocated-rdata
34162@opindex fwritable-relocated-rdata
34163This option is available for MinGW and Cygwin targets. It specifies
34164that relocated-data in read-only section is put into the @code{.data}
34165section. This is a necessary for older runtimes not supporting
34166modification of @code{.rdata} sections for pseudo-relocation.
34167
34168@item -mpe-aligned-commons
34169@opindex mpe-aligned-commons
34170This option is available for Cygwin and MinGW targets. It
34171specifies that the GNU extension to the PE file format that
34172permits the correct alignment of COMMON variables should be
34173used when generating code. It is enabled by default if
34174GCC detects that the target assembler found during configuration
34175supports the feature.
34176@end table
34177
34178See also under @ref{x86 Options} for standard options.
34179
34180@node Xstormy16 Options
34181@subsection Xstormy16 Options
34182@cindex Xstormy16 Options
34183
34184These options are defined for Xstormy16:
34185
34186@table @gcctabopt
34187@item -msim
34188@opindex msim
34189Choose startup files and linker script suitable for the simulator.
34190@end table
34191
34192@node Xtensa Options
34193@subsection Xtensa Options
34194@cindex Xtensa Options
34195
34196These options are supported for Xtensa targets:
34197
34198@table @gcctabopt
34199@item -mconst16
34200@itemx -mno-const16
34201@opindex mconst16
34202@opindex mno-const16
34203Enable or disable use of @code{CONST16} instructions for loading
34204constant values. The @code{CONST16} instruction is currently not a
34205standard option from Tensilica. When enabled, @code{CONST16}
34206instructions are always used in place of the standard @code{L32R}
34207instructions. The use of @code{CONST16} is enabled by default only if
34208the @code{L32R} instruction is not available.
34209
34210@item -mfused-madd
34211@itemx -mno-fused-madd
34212@opindex mfused-madd
34213@opindex mno-fused-madd
34214Enable or disable use of fused multiply/add and multiply/subtract
34215instructions in the floating-point option. This has no effect if the
34216floating-point option is not also enabled. Disabling fused multiply/add
34217and multiply/subtract instructions forces the compiler to use separate
34218instructions for the multiply and add/subtract operations. This may be
34219desirable in some cases where strict IEEE 754-compliant results are
34220required: the fused multiply add/subtract instructions do not round the
34221intermediate result, thereby producing results with @emph{more} bits of
34222precision than specified by the IEEE standard. Disabling fused multiply
34223add/subtract instructions also ensures that the program output is not
34224sensitive to the compiler's ability to combine multiply and add/subtract
34225operations.
34226
34227@item -mserialize-volatile
34228@itemx -mno-serialize-volatile
34229@opindex mserialize-volatile
34230@opindex mno-serialize-volatile
34231When this option is enabled, GCC inserts @code{MEMW} instructions before
34232@code{volatile} memory references to guarantee sequential consistency.
34233The default is @option{-mserialize-volatile}. Use
34234@option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
34235
34236@item -mforce-no-pic
34237@opindex mforce-no-pic
34238For targets, like GNU/Linux, where all user-mode Xtensa code must be
34239position-independent code (PIC), this option disables PIC for compiling
34240kernel code.
34241
34242@item -mtext-section-literals
34243@itemx -mno-text-section-literals
34244@opindex mtext-section-literals
34245@opindex mno-text-section-literals
34246These options control the treatment of literal pools. The default is
34247@option{-mno-text-section-literals}, which places literals in a separate
34248section in the output file. This allows the literal pool to be placed
34249in a data RAM/ROM, and it also allows the linker to combine literal
34250pools from separate object files to remove redundant literals and
34251improve code size. With @option{-mtext-section-literals}, the literals
34252are interspersed in the text section in order to keep them as close as
34253possible to their references. This may be necessary for large assembly
34254files. Literals for each function are placed right before that function.
34255
34256@item -mauto-litpools
34257@itemx -mno-auto-litpools
34258@opindex mauto-litpools
34259@opindex mno-auto-litpools
34260These options control the treatment of literal pools. The default is
34261@option{-mno-auto-litpools}, which places literals in a separate
34262section in the output file unless @option{-mtext-section-literals} is
34263used. With @option{-mauto-litpools} the literals are interspersed in
34264the text section by the assembler. Compiler does not produce explicit
34265@code{.literal} directives and loads literals into registers with
34266@code{MOVI} instructions instead of @code{L32R} to let the assembler
34267do relaxation and place literals as necessary. This option allows
34268assembler to create several literal pools per function and assemble
34269very big functions, which may not be possible with
34270@option{-mtext-section-literals}.
34271
34272@item -mtarget-align
34273@itemx -mno-target-align
34274@opindex mtarget-align
34275@opindex mno-target-align
34276When this option is enabled, GCC instructs the assembler to
34277automatically align instructions to reduce branch penalties at the
34278expense of some code density. The assembler attempts to widen density
34279instructions to align branch targets and the instructions following call
34280instructions. If there are not enough preceding safe density
34281instructions to align a target, no widening is performed. The
34282default is @option{-mtarget-align}. These options do not affect the
34283treatment of auto-aligned instructions like @code{LOOP}, which the
34284assembler always aligns, either by widening density instructions or
34285by inserting NOP instructions.
34286
34287@item -mlongcalls
34288@itemx -mno-longcalls
34289@opindex mlongcalls
34290@opindex mno-longcalls
34291When this option is enabled, GCC instructs the assembler to translate
34292direct calls to indirect calls unless it can determine that the target
34293of a direct call is in the range allowed by the call instruction. This
34294translation typically occurs for calls to functions in other source
34295files. Specifically, the assembler translates a direct @code{CALL}
34296instruction into an @code{L32R} followed by a @code{CALLX} instruction.
34297The default is @option{-mno-longcalls}. This option should be used in
34298programs where the call target can potentially be out of range. This
34299option is implemented in the assembler, not the compiler, so the
34300assembly code generated by GCC still shows direct call
34301instructions---look at the disassembled object code to see the actual
34302instructions. Note that the assembler uses an indirect call for
34303every cross-file call, not just those that really are out of range.
34304
34305@item -mabi=@var{name}
34306@opindex mabi
34307Generate code for the specified ABI@. Permissible values are: @samp{call0},
34308@samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
34309
34310@item -mabi=call0
34311@opindex mabi=call0
34312When this option is enabled function parameters are passed in registers
34313@code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
34314caller-saved, and register @code{a15} may be used as a frame pointer.
34315When this version of the ABI is enabled the C preprocessor symbol
34316@code{__XTENSA_CALL0_ABI__} is defined.
34317
34318@item -mabi=windowed
34319@opindex mabi=windowed
34320When this option is enabled function parameters are passed in registers
34321@code{a10} through @code{a15}, and called function rotates register window
34322by 8 registers on entry so that its arguments are found in registers
34323@code{a2} through @code{a7}. Register @code{a7} may be used as a frame
34324pointer. Register window is rotated 8 registers back upon return.
34325When this version of the ABI is enabled the C preprocessor symbol
34326@code{__XTENSA_WINDOWED_ABI__} is defined.
34327
34328@item -mextra-l32r-costs=@var{n}
34329@opindex mextra-l32r-costs
34330Specify an extra cost of instruction RAM/ROM access for @code{L32R}
34331instructions, in clock cycles. This affects, when optimizing for speed,
34332whether loading a constant from literal pool using @code{L32R} or
34333synthesizing the constant from a small one with a couple of arithmetic
34334instructions. The default value is 0.
34335@end table
34336
34337@node zSeries Options
34338@subsection zSeries Options
34339@cindex zSeries options
34340
34341These are listed under @xref{S/390 and zSeries Options}.
34342
34343
34344@c man end
34345
34346@node Spec Files
34347@section Specifying Subprocesses and the Switches to Pass to Them
34348@cindex Spec Files
34349
34350@command{gcc} is a driver program. It performs its job by invoking a
34351sequence of other programs to do the work of compiling, assembling and
34352linking. GCC interprets its command-line parameters and uses these to
34353deduce which programs it should invoke, and which command-line options
34354it ought to place on their command lines. This behavior is controlled
34355by @dfn{spec strings}. In most cases there is one spec string for each
34356program that GCC can invoke, but a few programs have multiple spec
34357strings to control their behavior. The spec strings built into GCC can
34358be overridden by using the @option{-specs=} command-line switch to specify
34359a spec file.
34360
34361@dfn{Spec files} are plain-text files that are used to construct spec
34362strings. They consist of a sequence of directives separated by blank
34363lines. The type of directive is determined by the first non-whitespace
34364character on the line, which can be one of the following:
34365
34366@table @code
34367@item %@var{command}
34368Issues a @var{command} to the spec file processor. The commands that can
34369appear here are:
34370
34371@table @code
34372@item %include <@var{file}>
34373@cindex @code{%include}
34374Search for @var{file} and insert its text at the current point in the
34375specs file.
34376
34377@item %include_noerr <@var{file}>
34378@cindex @code{%include_noerr}
34379Just like @samp{%include}, but do not generate an error message if the include
34380file cannot be found.
34381
34382@item %rename @var{old_name} @var{new_name}
34383@cindex @code{%rename}
34384Rename the spec string @var{old_name} to @var{new_name}.
34385
34386@end table
34387
34388@item *[@var{spec_name}]:
34389This tells the compiler to create, override or delete the named spec
34390string. All lines after this directive up to the next directive or
34391blank line are considered to be the text for the spec string. If this
34392results in an empty string then the spec is deleted. (Or, if the
34393spec did not exist, then nothing happens.) Otherwise, if the spec
34394does not currently exist a new spec is created. If the spec does
34395exist then its contents are overridden by the text of this
34396directive, unless the first character of that text is the @samp{+}
34397character, in which case the text is appended to the spec.
34398
34399@item [@var{suffix}]:
34400Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
34401and up to the next directive or blank line are considered to make up the
34402spec string for the indicated suffix. When the compiler encounters an
34403input file with the named suffix, it processes the spec string in
34404order to work out how to compile that file. For example:
34405
34406@smallexample
34407.ZZ:
34408z-compile -input %i
34409@end smallexample
34410
34411This says that any input file whose name ends in @samp{.ZZ} should be
34412passed to the program @samp{z-compile}, which should be invoked with the
34413command-line switch @option{-input} and with the result of performing the
34414@samp{%i} substitution. (See below.)
34415
34416As an alternative to providing a spec string, the text following a
34417suffix directive can be one of the following:
34418
34419@table @code
34420@item @@@var{language}
34421This says that the suffix is an alias for a known @var{language}. This is
34422similar to using the @option{-x} command-line switch to GCC to specify a
34423language explicitly. For example:
34424
34425@smallexample
34426.ZZ:
34427@@c++
34428@end smallexample
34429
34430Says that .ZZ files are, in fact, C++ source files.
34431
34432@item #@var{name}
34433This causes an error messages saying:
34434
34435@smallexample
34436@var{name} compiler not installed on this system.
34437@end smallexample
34438@end table
34439
34440GCC already has an extensive list of suffixes built into it.
34441This directive adds an entry to the end of the list of suffixes, but
34442since the list is searched from the end backwards, it is effectively
34443possible to override earlier entries using this technique.
34444
34445@end table
34446
34447GCC has the following spec strings built into it. Spec files can
34448override these strings or create their own. Note that individual
34449targets can also add their own spec strings to this list.
34450
34451@smallexample
34452asm Options to pass to the assembler
34453asm_final Options to pass to the assembler post-processor
34454cpp Options to pass to the C preprocessor
34455cc1 Options to pass to the C compiler
34456cc1plus Options to pass to the C++ compiler
34457endfile Object files to include at the end of the link
34458link Options to pass to the linker
34459lib Libraries to include on the command line to the linker
34460libgcc Decides which GCC support library to pass to the linker
34461linker Sets the name of the linker
34462predefines Defines to be passed to the C preprocessor
34463signed_char Defines to pass to CPP to say whether @code{char} is signed
34464 by default
34465startfile Object files to include at the start of the link
34466@end smallexample
34467
34468Here is a small example of a spec file:
34469
34470@smallexample
34471%rename lib old_lib
34472
34473*lib:
34474--start-group -lgcc -lc -leval1 --end-group %(old_lib)
34475@end smallexample
34476
34477This example renames the spec called @samp{lib} to @samp{old_lib} and
34478then overrides the previous definition of @samp{lib} with a new one.
34479The new definition adds in some extra command-line options before
34480including the text of the old definition.
34481
34482@dfn{Spec strings} are a list of command-line options to be passed to their
34483corresponding program. In addition, the spec strings can contain
34484@samp{%}-prefixed sequences to substitute variable text or to
34485conditionally insert text into the command line. Using these constructs
34486it is possible to generate quite complex command lines.
34487
34488Here is a table of all defined @samp{%}-sequences for spec
34489strings. Note that spaces are not generated automatically around the
34490results of expanding these sequences. Therefore you can concatenate them
34491together or combine them with constant text in a single argument.
34492
34493@table @code
34494@item %%
34495Substitute one @samp{%} into the program name or argument.
34496
34497@item %"
34498Substitute an empty argument.
34499
34500@item %i
34501Substitute the name of the input file being processed.
34502
34503@item %b
34504Substitute the basename for outputs related with the input file being
34505processed. This is often the substring up to (and not including) the
34506last period and not including the directory but, unless %w is active, it
34507expands to the basename for auxiliary outputs, which may be influenced
34508by an explicit output name, and by various other options that control
34509how auxiliary outputs are named.
34510
34511@item %B
34512This is the same as @samp{%b}, but include the file suffix (text after
34513the last period). Without %w, it expands to the basename for dump
34514outputs.
34515
34516@item %d
34517Marks the argument containing or following the @samp{%d} as a
34518temporary file name, so that that file is deleted if GCC exits
34519successfully. Unlike @samp{%g}, this contributes no text to the
34520argument.
34521
34522@item %g@var{suffix}
34523Substitute a file name that has suffix @var{suffix} and is chosen
34524once per compilation, and mark the argument in the same way as
34525@samp{%d}. To reduce exposure to denial-of-service attacks, the file
34526name is now chosen in a way that is hard to predict even when previously
34527chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
34528might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
34529the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
34530treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
34531was simply substituted with a file name chosen once per compilation,
34532without regard to any appended suffix (which was therefore treated
34533just like ordinary text), making such attacks more likely to succeed.
34534
34535@item %u@var{suffix}
34536Like @samp{%g}, but generates a new temporary file name
34537each time it appears instead of once per compilation.
34538
34539@item %U@var{suffix}
34540Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
34541new one if there is no such last file name. In the absence of any
34542@samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
34543the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
34544involves the generation of two distinct file names, one
34545for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
34546simply substituted with a file name chosen for the previous @samp{%u},
34547without regard to any appended suffix.
34548
34549@item %j@var{suffix}
34550Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
34551writable, and if @option{-save-temps} is not used;
34552otherwise, substitute the name
34553of a temporary file, just like @samp{%u}. This temporary file is not
34554meant for communication between processes, but rather as a junk
34555disposal mechanism.
34556
34557@item %|@var{suffix}
34558@itemx %m@var{suffix}
34559Like @samp{%g}, except if @option{-pipe} is in effect. In that case
34560@samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
34561all. These are the two most common ways to instruct a program that it
34562should read from standard input or write to standard output. If you
34563need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
34564construct: see for example @file{gcc/fortran/lang-specs.h}.
34565
34566@item %.@var{SUFFIX}
34567Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
34568when it is subsequently output with @samp{%*}. @var{SUFFIX} is
34569terminated by the next space or %.
34570
34571@item %w
34572Marks the argument containing or following the @samp{%w} as the
34573designated output file of this compilation. This puts the argument
34574into the sequence of arguments that @samp{%o} substitutes.
34575
34576@item %V
34577Indicates that this compilation produces no output file.
34578
34579@item %o
34580Substitutes the names of all the output files, with spaces
34581automatically placed around them. You should write spaces
34582around the @samp{%o} as well or the results are undefined.
34583@samp{%o} is for use in the specs for running the linker.
34584Input files whose names have no recognized suffix are not compiled
34585at all, but they are included among the output files, so they are
34586linked.
34587
34588@item %O
34589Substitutes the suffix for object files. Note that this is
34590handled specially when it immediately follows @samp{%g, %u, or %U},
34591because of the need for those to form complete file names. The
34592handling is such that @samp{%O} is treated exactly as if it had already
34593been substituted, except that @samp{%g, %u, and %U} do not currently
34594support additional @var{suffix} characters following @samp{%O} as they do
34595following, for example, @samp{.o}.
34596
34597@item %I
34598Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
34599@option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
34600@option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
34601and @option{-imultilib} as necessary.
34602
34603@item %s
34604Current argument is the name of a library or startup file of some sort.
34605Search for that file in a standard list of directories and substitute
34606the full name found. The current working directory is included in the
34607list of directories scanned.
34608
34609@item %T
34610Current argument is the name of a linker script. Search for that file
34611in the current list of directories to scan for libraries. If the file
34612is located insert a @option{--script} option into the command line
34613followed by the full path name found. If the file is not found then
34614generate an error message. Note: the current working directory is not
34615searched.
34616
34617@item %e@var{str}
34618Print @var{str} as an error message. @var{str} is terminated by a newline.
34619Use this when inconsistent options are detected.
34620
34621@item %n@var{str}
34622Print @var{str} as a notice. @var{str} is terminated by a newline.
34623
34624@item %(@var{name})
34625Substitute the contents of spec string @var{name} at this point.
34626
34627@item %x@{@var{option}@}
34628Accumulate an option for @samp{%X}.
34629
34630@item %X
34631Output the accumulated linker options specified by a @samp{%x} spec string.
34632
34633@item %Y
34634Output the accumulated assembler options specified by @option{-Wa}.
34635
34636@item %Z
34637Output the accumulated preprocessor options specified by @option{-Wp}.
34638
34639@item %M
34640Output @code{multilib_os_dir}.
34641
34642@item %R
34643Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
34644
34645@item %a
34646Process the @code{asm} spec. This is used to compute the
34647switches to be passed to the assembler.
34648
34649@item %A
34650Process the @code{asm_final} spec. This is a spec string for
34651passing switches to an assembler post-processor, if such a program is
34652needed.
34653
34654@item %l
34655Process the @code{link} spec. This is the spec for computing the
34656command line passed to the linker. Typically it makes use of the
34657@samp{%L %G %S %D and %E} sequences.
34658
34659@item %D
34660Dump out a @option{-L} option for each directory that GCC believes might
34661contain startup files. If the target supports multilibs then the
34662current multilib directory is prepended to each of these paths.
34663
34664@item %L
34665Process the @code{lib} spec. This is a spec string for deciding which
34666libraries are included on the command line to the linker.
34667
34668@item %G
34669Process the @code{libgcc} spec. This is a spec string for deciding
34670which GCC support library is included on the command line to the linker.
34671
34672@item %S
34673Process the @code{startfile} spec. This is a spec for deciding which
34674object files are the first ones passed to the linker. Typically
34675this might be a file named @file{crt0.o}.
34676
34677@item %E
34678Process the @code{endfile} spec. This is a spec string that specifies
34679the last object files that are passed to the linker.
34680
34681@item %C
34682Process the @code{cpp} spec. This is used to construct the arguments
34683to be passed to the C preprocessor.
34684
34685@item %1
34686Process the @code{cc1} spec. This is used to construct the options to be
34687passed to the actual C compiler (@command{cc1}).
34688
34689@item %2
34690Process the @code{cc1plus} spec. This is used to construct the options to be
34691passed to the actual C++ compiler (@command{cc1plus}).
34692
34693@item %*
34694Substitute the variable part of a matched option. See below.
34695Note that each comma in the substituted string is replaced by
34696a single space.
34697
34698@item %<S
34699Remove all occurrences of @code{-S} from the command line. Note---this
34700command is position dependent. @samp{%} commands in the spec string
34701before this one see @code{-S}, @samp{%} commands in the spec string
34702after this one do not.
34703
34704@item %<S*
34705Similar to @samp{%<S}, but match all switches beginning with @code{-S}.
34706
34707@item %>S
34708Similar to @samp{%<S}, but keep @code{-S} in the GCC command line.
34709
34710@item %:@var{function}(@var{args})
34711Call the named function @var{function}, passing it @var{args}.
34712@var{args} is first processed as a nested spec string, then split
34713into an argument vector in the usual fashion. The function returns
34714a string which is processed as if it had appeared literally as part
34715of the current spec.
34716
34717The following built-in spec functions are provided:
34718
34719@table @code
34720@item @code{getenv}
34721The @code{getenv} spec function takes two arguments: an environment
34722variable name and a string. If the environment variable is not
34723defined, a fatal error is issued. Otherwise, the return value is the
34724value of the environment variable concatenated with the string. For
34725example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
34726
34727@smallexample
34728%:getenv(TOPDIR /include)
34729@end smallexample
34730
34731expands to @file{/path/to/top/include}.
34732
34733@item @code{if-exists}
34734The @code{if-exists} spec function takes one argument, an absolute
34735pathname to a file. If the file exists, @code{if-exists} returns the
34736pathname. Here is a small example of its usage:
34737
34738@smallexample
34739*startfile:
34740crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
34741@end smallexample
34742
34743@item @code{if-exists-else}
34744The @code{if-exists-else} spec function is similar to the @code{if-exists}
34745spec function, except that it takes two arguments. The first argument is
34746an absolute pathname to a file. If the file exists, @code{if-exists-else}
34747returns the pathname. If it does not exist, it returns the second argument.
34748This way, @code{if-exists-else} can be used to select one file or another,
34749based on the existence of the first. Here is a small example of its usage:
34750
34751@smallexample
34752*startfile:
34753crt0%O%s %:if-exists(crti%O%s) \
34754%:if-exists-else(crtbeginT%O%s crtbegin%O%s)
34755@end smallexample
34756
34757@item @code{if-exists-then-else}
34758The @code{if-exists-then-else} spec function takes at least two arguments
34759and an optional third one. The first argument is an absolute pathname to a
34760file. If the file exists, the function returns the second argument.
34761If the file does not exist, the function returns the third argument if there
34762is one, or NULL otherwise. This can be used to expand one text, or optionally
34763another, based on the existence of a file. Here is a small example of its
34764usage:
34765
34766@smallexample
34767-l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
34768@end smallexample
34769
34770@item @code{sanitize}
34771The @code{sanitize} spec function takes no arguments. It returns non-NULL if
34772any address, thread or undefined behavior sanitizers are active.
34773
34774@smallexample
34775%@{%:sanitize(address):-funwind-tables@}
34776@end smallexample
34777
34778@item @code{replace-outfile}
34779The @code{replace-outfile} spec function takes two arguments. It looks for the
34780first argument in the outfiles array and replaces it with the second argument. Here
34781is a small example of its usage:
34782
34783@smallexample
34784%@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
34785@end smallexample
34786
34787@item @code{remove-outfile}
34788The @code{remove-outfile} spec function takes one argument. It looks for the
34789first argument in the outfiles array and removes it. Here is a small example
34790its usage:
34791
34792@smallexample
34793%:remove-outfile(-lm)
34794@end smallexample
34795
34796@item @code{version-compare}
34797The @code{version-compare} spec function takes four or five arguments of the following
34798form:
34799
34800@smallexample
34801<comparison-op> <arg1> [<arg2>] <switch> <result>
34802@end smallexample
34803
34804It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
34805The supported @code{comparison-op} values are:
34806
34807@table @code
34808@item >=
34809True if @code{switch} is a later (or same) version than @code{arg1}
34810
34811@item !>
34812Opposite of @code{>=}
34813
34814@item <
34815True if @code{switch} is an earlier version than @code{arg1}
34816
34817@item !<
34818Opposite of @code{<}
34819
34820@item ><
34821True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
34822
34823@item <>
34824True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
34825@end table
34826
34827If the @code{switch} is not present at all, the condition is false unless the first character
34828of the @code{comparison-op} is @code{!}.
34829
34830@smallexample
34831%:version-compare(>= 10.3 mmacosx-version-min= -lmx)
34832@end smallexample
34833
34834The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
34835passed.
34836
34837@item @code{include}
34838The @code{include} spec function behaves much like @code{%include}, with the advantage
34839that it can be nested inside a spec and thus be conditionalized. It takes one argument,
34840the filename, and looks for it in the startfile path. It always returns NULL.
34841
34842@smallexample
34843%@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
34844@end smallexample
34845
34846@item @code{pass-through-libs}
34847The @code{pass-through-libs} spec function takes any number of arguments. It
34848finds any @option{-l} options and any non-options ending in @file{.a} (which it
34849assumes are the names of linker input library archive files) and returns a
34850result containing all the found arguments each prepended by
34851@option{-plugin-opt=-pass-through=} and joined by spaces. This list is
34852intended to be passed to the LTO linker plugin.
34853
34854@smallexample
34855%:pass-through-libs(%G %L %G)
34856@end smallexample
34857
34858@item @code{print-asm-header}
34859The @code{print-asm-header} function takes no arguments and simply
34860prints a banner like:
34861
34862@smallexample
34863Assembler options
34864=================
34865
34866Use "-Wa,OPTION" to pass "OPTION" to the assembler.
34867@end smallexample
34868
34869It is used to separate compiler options from assembler options
34870in the @option{--target-help} output.
34871
34872@item @code{gt}
34873The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
34874empty string) if the second-to-last argument is greater than the last argument, and NULL
34875otherwise. The following example inserts the @code{link_gomp} spec if the last
34876@option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
34877
34878@smallexample
34879%@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
34880@end smallexample
34881
34882@item @code{debug-level-gt}
34883The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
34884empty string) if @code{debug_info_level} is greater than the specified number, and NULL
34885otherwise.
34886
34887@smallexample
34888%@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
34889@end smallexample
34890@end table
34891
34892@item %@{S@}
34893Substitutes the @code{-S} switch, if that switch is given to GCC@.
34894If that switch is not specified, this substitutes nothing. Note that
34895the leading dash is omitted when specifying this option, and it is
34896automatically inserted if the substitution is performed. Thus the spec
34897string @samp{%@{foo@}} matches the command-line option @option{-foo}
34898and outputs the command-line option @option{-foo}.
34899
34900@item %W@{S@}
34901Like %@{@code{S}@} but mark last argument supplied within as a file to be
34902deleted on failure.
34903
34904@item %@@@{S@}
34905Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes
34906@code{@@FILE} if an @code{@@file} argument has been supplied.
34907
34908@item %@{S*@}
34909Substitutes all the switches specified to GCC whose names start
34910with @code{-S}, but which also take an argument. This is used for
34911switches like @option{-o}, @option{-D}, @option{-I}, etc.
34912GCC considers @option{-o foo} as being
34913one switch whose name starts with @samp{o}. %@{o*@} substitutes this
34914text, including the space. Thus two arguments are generated.
34915
34916@item %@{S*&T*@}
34917Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
34918(the order of @code{S} and @code{T} in the spec is not significant).
34919There can be any number of ampersand-separated variables; for each the
34920wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
34921
34922@item %@{S:X@}
34923Substitutes @code{X}, if the @option{-S} switch is given to GCC@.
34924
34925@item %@{!S:X@}
34926Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@.
34927
34928@item %@{S*:X@}
34929Substitutes @code{X} if one or more switches whose names start with
34930@code{-S} are specified to GCC@. Normally @code{X} is substituted only
34931once, no matter how many such switches appeared. However, if @code{%*}
34932appears somewhere in @code{X}, then @code{X} is substituted once
34933for each matching switch, with the @code{%*} replaced by the part of
34934that switch matching the @code{*}.
34935
34936If @code{%*} appears as the last part of a spec sequence then a space
34937is added after the end of the last substitution. If there is more
34938text in the sequence, however, then a space is not generated. This
34939allows the @code{%*} substitution to be used as part of a larger
34940string. For example, a spec string like this:
34941
34942@smallexample
34943%@{mcu=*:--script=%*/memory.ld@}
34944@end smallexample
34945
34946@noindent
34947when matching an option like @option{-mcu=newchip} produces:
34948
34949@smallexample
34950--script=newchip/memory.ld
34951@end smallexample
34952
34953@item %@{.S:X@}
34954Substitutes @code{X}, if processing a file with suffix @code{S}.
34955
34956@item %@{!.S:X@}
34957Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
34958
34959@item %@{,S:X@}
34960Substitutes @code{X}, if processing a file for language @code{S}.
34961
34962@item %@{!,S:X@}
34963Substitutes @code{X}, if not processing a file for language @code{S}.
34964
34965@item %@{S|P:X@}
34966Substitutes @code{X} if either @code{-S} or @code{-P} is given to
34967GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
34968@code{*} sequences as well, although they have a stronger binding than
34969the @samp{|}. If @code{%*} appears in @code{X}, all of the
34970alternatives must be starred, and only the first matching alternative
34971is substituted.
34972
34973For example, a spec string like this:
34974
34975@smallexample
34976%@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
34977@end smallexample
34978
34979@noindent
34980outputs the following command-line options from the following input
34981command-line options:
34982
34983@smallexample
34984fred.c -foo -baz
34985jim.d -bar -boggle
34986-d fred.c -foo -baz -boggle
34987-d jim.d -bar -baz -boggle
34988@end smallexample
34989
34990@item %@{%:@var{function}(@var{args}):X@}
34991
34992Call function named @var{function} with args @var{args}. If the
34993function returns non-NULL, then @code{X} is substituted, if it returns
34994NULL, it isn't substituted.
34995
34996@item %@{S:X; T:Y; :D@}
34997
34998If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is
34999given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
35000be as many clauses as you need. This may be combined with @code{.},
35001@code{,}, @code{!}, @code{|}, and @code{*} as needed.
35002
35003
35004@end table
35005
35006The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}}
35007or similar construct can use a backslash to ignore the special meaning
35008of the character following it, thus allowing literal matching of a
35009character that is otherwise specially treated. For example,
35010@samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the
35011@option{-std=iso9899:1999} option is given.
35012
35013The conditional text @code{X} in a @samp{%@{S:X@}} or similar
35014construct may contain other nested @samp{%} constructs or spaces, or
35015even newlines. They are processed as usual, as described above.
35016Trailing white space in @code{X} is ignored. White space may also
35017appear anywhere on the left side of the colon in these constructs,
35018except between @code{.} or @code{*} and the corresponding word.
35019
35020The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
35021handled specifically in these constructs. If another value of
35022@option{-O} or the negated form of a @option{-f}, @option{-m}, or
35023@option{-W} switch is found later in the command line, the earlier
35024switch value is ignored, except with @{@code{S}*@} where @code{S} is
35025just one letter, which passes all matching options.
35026
35027The character @samp{|} at the beginning of the predicate text is used to
35028indicate that a command should be piped to the following command, but
35029only if @option{-pipe} is specified.
35030
35031It is built into GCC which switches take arguments and which do not.
35032(You might think it would be useful to generalize this to allow each
35033compiler's spec to say which switches take arguments. But this cannot
35034be done in a consistent fashion. GCC cannot even decide which input
35035files have been specified without knowing which switches take arguments,
35036and it must know which input files to compile in order to tell which
35037compilers to run).
35038
35039GCC also knows implicitly that arguments starting in @option{-l} are to be
35040treated as compiler output files, and passed to the linker in their
35041proper position among the other output files.
35042
35043@node Environment Variables
35044@section Environment Variables Affecting GCC
35045@cindex environment variables
35046
35047@c man begin ENVIRONMENT
35048This section describes several environment variables that affect how GCC
35049operates. Some of them work by specifying directories or prefixes to use
35050when searching for various kinds of files. Some are used to specify other
35051aspects of the compilation environment.
35052
35053Note that you can also specify places to search using options such as
35054@option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
35055take precedence over places specified using environment variables, which
35056in turn take precedence over those specified by the configuration of GCC@.
35057@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
35058GNU Compiler Collection (GCC) Internals}.
35059
35060@table @env
35061@item LANG
35062@itemx LC_CTYPE
35063@c @itemx LC_COLLATE
35064@itemx LC_MESSAGES
35065@c @itemx LC_MONETARY
35066@c @itemx LC_NUMERIC
35067@c @itemx LC_TIME
35068@itemx LC_ALL
35069@findex LANG
35070@findex LC_CTYPE
35071@c @findex LC_COLLATE
35072@findex LC_MESSAGES
35073@c @findex LC_MONETARY
35074@c @findex LC_NUMERIC
35075@c @findex LC_TIME
35076@findex LC_ALL
35077@cindex locale
35078These environment variables control the way that GCC uses
35079localization information which allows GCC to work with different
35080national conventions. GCC inspects the locale categories
35081@env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
35082so. These locale categories can be set to any value supported by your
35083installation. A typical value is @samp{en_GB.UTF-8} for English in the United
35084Kingdom encoded in UTF-8.
35085
35086The @env{LC_CTYPE} environment variable specifies character
35087classification. GCC uses it to determine the character boundaries in
35088a string; this is needed for some multibyte encodings that contain quote
35089and escape characters that are otherwise interpreted as a string
35090end or escape.
35091
35092The @env{LC_MESSAGES} environment variable specifies the language to
35093use in diagnostic messages.
35094
35095If the @env{LC_ALL} environment variable is set, it overrides the value
35096of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
35097and @env{LC_MESSAGES} default to the value of the @env{LANG}
35098environment variable. If none of these variables are set, GCC
35099defaults to traditional C English behavior.
35100
35101@item TMPDIR
35102@findex TMPDIR
35103If @env{TMPDIR} is set, it specifies the directory to use for temporary
35104files. GCC uses temporary files to hold the output of one stage of
35105compilation which is to be used as input to the next stage: for example,
35106the output of the preprocessor, which is the input to the compiler
35107proper.
35108
35109@item GCC_COMPARE_DEBUG
35110@findex GCC_COMPARE_DEBUG
35111Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
35112@option{-fcompare-debug} to the compiler driver. See the documentation
35113of this option for more details.
35114
35115@item GCC_EXEC_PREFIX
35116@findex GCC_EXEC_PREFIX
35117If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
35118names of the subprograms executed by the compiler. No slash is added
35119when this prefix is combined with the name of a subprogram, but you can
35120specify a prefix that ends with a slash if you wish.
35121
35122If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
35123an appropriate prefix to use based on the pathname it is invoked with.
35124
35125If GCC cannot find the subprogram using the specified prefix, it
35126tries looking in the usual places for the subprogram.
35127
35128The default value of @env{GCC_EXEC_PREFIX} is
35129@file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
35130the installed compiler. In many cases @var{prefix} is the value
35131of @code{prefix} when you ran the @file{configure} script.
35132
35133Other prefixes specified with @option{-B} take precedence over this prefix.
35134
35135This prefix is also used for finding files such as @file{crt0.o} that are
35136used for linking.
35137
35138In addition, the prefix is used in an unusual way in finding the
35139directories to search for header files. For each of the standard
35140directories whose name normally begins with @samp{/usr/local/lib/gcc}
35141(more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
35142replacing that beginning with the specified prefix to produce an
35143alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
35144@file{foo/bar} just before it searches the standard directory
35145@file{/usr/local/lib/bar}.
35146If a standard directory begins with the configured
35147@var{prefix} then the value of @var{prefix} is replaced by
35148@env{GCC_EXEC_PREFIX} when looking for header files.
35149
35150@item COMPILER_PATH
35151@findex COMPILER_PATH
35152The value of @env{COMPILER_PATH} is a colon-separated list of
35153directories, much like @env{PATH}. GCC tries the directories thus
35154specified when searching for subprograms, if it cannot find the
35155subprograms using @env{GCC_EXEC_PREFIX}.
35156
35157@item LIBRARY_PATH
35158@findex LIBRARY_PATH
35159The value of @env{LIBRARY_PATH} is a colon-separated list of
35160directories, much like @env{PATH}. When configured as a native compiler,
35161GCC tries the directories thus specified when searching for special
35162linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
35163using GCC also uses these directories when searching for ordinary
35164libraries for the @option{-l} option (but directories specified with
35165@option{-L} come first).
35166
35167@item LANG
35168@findex LANG
35169@cindex locale definition
35170This variable is used to pass locale information to the compiler. One way in
35171which this information is used is to determine the character set to be used
35172when character literals, string literals and comments are parsed in C and C++.
35173When the compiler is configured to allow multibyte characters,
35174the following values for @env{LANG} are recognized:
35175
35176@table @samp
35177@item C-JIS
35178Recognize JIS characters.
35179@item C-SJIS
35180Recognize SJIS characters.
35181@item C-EUCJP
35182Recognize EUCJP characters.
35183@end table
35184
35185If @env{LANG} is not defined, or if it has some other value, then the
35186compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
35187recognize and translate multibyte characters.
35188
35189@item GCC_EXTRA_DIAGNOSTIC_OUTPUT
35190@findex GCC_EXTRA_DIAGNOSTIC_OUTPUT
35191If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
35192then additional text will be emitted to stderr when fix-it hints are
35193emitted. @option{-fdiagnostics-parseable-fixits} and
35194@option{-fno-diagnostics-parseable-fixits} take precedence over this
35195environment variable.
35196
35197@table @samp
35198@item fixits-v1
35199Emit parseable fix-it hints, equivalent to
35200@option{-fdiagnostics-parseable-fixits}. In particular, columns are
35201expressed as a count of bytes, starting at byte 1 for the initial column.
35202
35203@item fixits-v2
35204As @code{fixits-v1}, but columns are expressed as display columns,
35205as per @option{-fdiagnostics-column-unit=display}.
35206@end table
35207
35208@end table
35209
35210@noindent
35211Some additional environment variables affect the behavior of the
35212preprocessor.
35213
35214@include cppenv.texi
35215
35216@c man end
35217
35218@node Precompiled Headers
35219@section Using Precompiled Headers
35220@cindex precompiled headers
35221@cindex speed of compilation
35222
35223Often large projects have many header files that are included in every
35224source file. The time the compiler takes to process these header files
35225over and over again can account for nearly all of the time required to
35226build the project. To make builds faster, GCC allows you to
35227@dfn{precompile} a header file.
35228
35229To create a precompiled header file, simply compile it as you would any
35230other file, if necessary using the @option{-x} option to make the driver
35231treat it as a C or C++ header file. You may want to use a
35232tool like @command{make} to keep the precompiled header up-to-date when
35233the headers it contains change.
35234
35235A precompiled header file is searched for when @code{#include} is
35236seen in the compilation. As it searches for the included file
35237(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
35238compiler looks for a precompiled header in each directory just before it
35239looks for the include file in that directory. The name searched for is
35240the name specified in the @code{#include} with @samp{.gch} appended. If
35241the precompiled header file cannot be used, it is ignored.
35242
35243For instance, if you have @code{#include "all.h"}, and you have
35244@file{all.h.gch} in the same directory as @file{all.h}, then the
35245precompiled header file is used if possible, and the original
35246header is used otherwise.
35247
35248Alternatively, you might decide to put the precompiled header file in a
35249directory and use @option{-I} to ensure that directory is searched
35250before (or instead of) the directory containing the original header.
35251Then, if you want to check that the precompiled header file is always
35252used, you can put a file of the same name as the original header in this
35253directory containing an @code{#error} command.
35254
35255This also works with @option{-include}. So yet another way to use
35256precompiled headers, good for projects not designed with precompiled
35257header files in mind, is to simply take most of the header files used by
35258a project, include them from another header file, precompile that header
35259file, and @option{-include} the precompiled header. If the header files
35260have guards against multiple inclusion, they are skipped because
35261they've already been included (in the precompiled header).
35262
35263If you need to precompile the same header file for different
35264languages, targets, or compiler options, you can instead make a
35265@emph{directory} named like @file{all.h.gch}, and put each precompiled
35266header in the directory, perhaps using @option{-o}. It doesn't matter
35267what you call the files in the directory; every precompiled header in
35268the directory is considered. The first precompiled header
35269encountered in the directory that is valid for this compilation is
35270used; they're searched in no particular order.
35271
35272There are many other possibilities, limited only by your imagination,
35273good sense, and the constraints of your build system.
35274
35275A precompiled header file can be used only when these conditions apply:
35276
35277@itemize
35278@item
35279Only one precompiled header can be used in a particular compilation.
35280
35281@item
35282A precompiled header cannot be used once the first C token is seen. You
35283can have preprocessor directives before a precompiled header; you cannot
35284include a precompiled header from inside another header.
35285
35286@item
35287The precompiled header file must be produced for the same language as
35288the current compilation. You cannot use a C precompiled header for a C++
35289compilation.
35290
35291@item
35292The precompiled header file must have been produced by the same compiler
35293binary as the current compilation is using.
35294
35295@item
35296Any macros defined before the precompiled header is included must
35297either be defined in the same way as when the precompiled header was
35298generated, or must not affect the precompiled header, which usually
35299means that they don't appear in the precompiled header at all.
35300
35301The @option{-D} option is one way to define a macro before a
35302precompiled header is included; using a @code{#define} can also do it.
35303There are also some options that define macros implicitly, like
35304@option{-O} and @option{-Wdeprecated}; the same rule applies to macros
35305defined this way.
35306
35307@item If debugging information is output when using the precompiled
35308header, using @option{-g} or similar, the same kind of debugging information
35309must have been output when building the precompiled header. However,
35310a precompiled header built using @option{-g} can be used in a compilation
35311when no debugging information is being output.
35312
35313@item The same @option{-m} options must generally be used when building
35314and using the precompiled header. @xref{Submodel Options},
35315for any cases where this rule is relaxed.
35316
35317@item Each of the following options must be the same when building and using
35318the precompiled header:
35319
35320@gccoptlist{-fexceptions}
35321
35322@item
35323Some other command-line options starting with @option{-f},
35324@option{-p}, or @option{-O} must be defined in the same way as when
35325the precompiled header was generated. At present, it's not clear
35326which options are safe to change and which are not; the safest choice
35327is to use exactly the same options when generating and using the
35328precompiled header. The following are known to be safe:
35329
35330@gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock @gol
35331-fsched-spec -fsched-spec-load -fsched-spec-load-dangerous @gol
35332-fsched-verbose=@var{number} -fschedule-insns -fvisibility= @gol
35333-pedantic-errors}
35334
35335@item Address space layout randomization (ASLR) can lead to not binary identical
35336PCH files. If you rely on stable PCH file contents disable ASLR when generating
35337PCH files.
35338
35339@end itemize
35340
35341For all of these except the last, the compiler automatically
35342ignores the precompiled header if the conditions aren't met. If you
35343find an option combination that doesn't work and doesn't cause the
35344precompiled header to be ignored, please consider filing a bug report,
35345see @ref{Bugs}.
35346
35347If you do use differing options when generating and using the
35348precompiled header, the actual behavior is a mixture of the
35349behavior for the options. For instance, if you use @option{-g} to
35350generate the precompiled header but not when using it, you may or may
35351not get debugging information for routines in the precompiled header.
35352
35353@node C++ Modules
35354@section C++ Modules
35355@cindex speed of compilation
35356
35357Modules are a C++20 language feature. As the name suggests, they
35358provides a modular compilation system, intending to provide both
35359faster builds and better library isolation. The ``Merging Modules''
35360paper @uref{https://wg21.link/p1103}, provides the easiest to read set
35361of changes to the standard, although it does not capture later
35362changes.
35363
35364@emph{G++'s modules support is not complete.} Other than bugs, the
35365known missing pieces are:
35366
35367@table @emph
35368
35369@item Private Module Fragment
35370The Private Module Fragment is recognized, but an error is emitted.
35371
35372@item Partition definition visibility rules
35373Entities may be defined in implementation partitions, and those
35374definitions are not available outside of the module. This is not
35375implemented, and the definitions are available to extra-module use.
35376
35377@item Textual merging of reachable GM entities
35378Entities may be multiply defined across different header-units.
35379These must be de-duplicated, and this is implemented across imports,
35380or when an import redefines a textually-defined entity. However the
35381reverse is not implemented---textually redefining an entity that has
35382been defined in an imported header-unit. A redefinition error is
35383emitted.
35384
35385@item Translation-Unit local referencing rules
35386Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
35387(@uref{https://wg21.link/p2003}) add limitations on which entities an
35388exported region may reference (for instance, the entities an exported
35389template definition may reference). These are not fully implemented.
35390
35391@item Standard Library Header Units
35392The Standard Library is not provided as importable header units. If
35393you want to import such units, you must explicitly build them first.
35394If you do not do this with care, you may have multiple declarations,
35395which the module machinery must merge---compiler resource usage can be
35396affected by how you partition header files into header units.
35397
35398@end table
35399
35400Modular compilation is @emph{not} enabled with just the
35401@option{-std=c++20} option. You must explicitly enable it with the
35402@option{-fmodules-ts} option. It is independent of the language
35403version selected, although in pre-C++20 versions, it is of course an
35404extension.
35405
35406No new source file suffixes are required or supported. If you wish to
35407use a non-standard suffix (@pxref{Overall Options}), you also need
35408to provide a @option{-x c++} option too.@footnote{Some users like to
35409distinguish module interface files with a new suffix, such as naming
35410the source @code{module.cppm}, which involves
35411teaching all tools about the new suffix. A different scheme, such as
35412naming @code{module-m.cpp} would be less invasive.}
35413
35414Compiling a module interface unit produces an additional output (to
35415the assembly or object file), called a Compiled Module Interface
35416(CMI). This encodes the exported declarations of the module.
35417Importing a module reads in the CMI. The import graph is a Directed
35418Acyclic Graph (DAG). You must build imports before the importer.
35419
35420Header files may themselves be compiled to header units, which are a
35421transitional ability aiming at faster compilation. The
35422@option{-fmodule-header} option is used to enable this, and implies
35423the @option{-fmodules-ts} option. These CMIs are named by the fully
35424resolved underlying header file, and thus may be a complete pathname
35425containing subdirectories. If the header file is found at an absolute
35426pathname, the CMI location is still relative to a CMI root directory.
35427
35428As header files often have no suffix, you commonly have to specify a
35429@option{-x} option to tell the compiler the source is a header file.
35430You may use @option{-x c++-header}, @option{-x c++-user-header} or
35431@option{-x c++-system-header}. When used in conjunction with
35432@option{-fmodules-ts}, these all imply an appropriate
35433@option{-fmodule-header} option. The latter two variants use the
35434user or system include path to search for the file specified. This
35435allows you to, for instance, compile standard library header files as
35436header units, without needing to know exactly where they are
35437installed. Specifying the language as one of these variants also
35438inhibits output of the object file, as header files have no associated
35439object file.
35440
35441The @option{-fmodule-only} option disables generation of the
35442associated object file for compiling a module interface. Only the CMI
35443is generated. This option is implied when using the
35444@option{-fmodule-header} option.
35445
35446The @option{-flang-info-include-translate} and
35447@option{-flang-info-include-translate-not} options notes whether
35448include translation occurs or not. With no argument, the first will
35449note all include translation. The second will note all
35450non-translations of include files not known to intentionally be
35451textual. With an argument, queries about include translation of a
35452header files with that particular trailing pathname are noted. You
35453may repeat this form to cover several different header files. This
35454option may be helpful in determining whether include translation is
35455happening---if it is working correctly, it behaves as if it isn't
35456there at all.
35457
35458The @option{-flang-info-module-cmi} option can be used to determine
35459where the compiler is reading a CMI from. Without the option, the
35460compiler is silent when such a read is successful. This option has an
35461optional argument, which will restrict the notification to just the
35462set of named modules or header units specified.
35463
35464The @option{-Winvalid-imported-macros} option causes all imported macros
35465to be resolved at the end of compilation. Without this, imported
35466macros are only resolved when expanded or (re)defined. This option
35467detects conflicting import definitions for all macros.
35468
35469For details of the @option{-fmodule-mapper} family of options,
35470@pxref{C++ Module Mapper}.
35471
35472@menu
35473* C++ Module Mapper:: Module Mapper
35474* C++ Module Preprocessing:: Module Preprocessing
35475* C++ Compiled Module Interface:: Compiled Module Interface
35476@end menu
35477
35478@node C++ Module Mapper
35479@subsection Module Mapper
35480@cindex C++ Module Mapper
35481
35482A module mapper provides a server or file that the compiler queries to
35483determine the mapping between module names and CMI files. It is also
35484used to build CMIs on demand. @emph{Mapper functionality is in its
35485infancy and is intended for experimentation with build system
35486interactions.}
35487
35488You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
35489option or @env{CXX_MODULE_MAPPER} environment variable. The value may
35490have one of the following forms:
35491
35492@table @gcctabopt
35493
35494@item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
35495An optional hostname and a numeric port number to connect to. If the
35496hostname is omitted, the loopback address is used. If the hostname
35497corresponds to multiple IPV6 addresses, these are tried in turn, until
35498one is successful. If your host lacks IPv6, this form is
35499non-functional. If you must use IPv4 use
35500@option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
35501
35502@item =@var{socket}@r{[}?@var{ident}@r{]}
35503A local domain socket. If your host lacks local domain sockets, this
35504form is non-functional.
35505
35506@item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
35507A program to spawn, and communicate with on its stdin/stdout streams.
35508Your @var{PATH} environment variable is searched for the program.
35509Arguments are separated by space characters, (it is not possible for
35510one of the arguments delivered to the program to contain a space). An
35511exception is if @var{program} begins with @@. In that case
35512@var{program} (sans @@) is looked for in the compiler's internal
35513binary directory. Thus the sample mapper-server can be specified
35514with @code{@@g++-mapper-server}.
35515
35516@item <>@r{[}?@var{ident}@r{]}
35517@item <>@var{inout}@r{[}?@var{ident}@r{]}
35518@item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
35519Named pipes or file descriptors to communicate over. The first form,
35520@option{<>}, communicates over stdin and stdout. The other forms
35521allow you to specify a file descriptor or name a pipe. A numeric value
35522is interpreted as a file descriptor, otherwise named pipe is opened.
35523The second form specifies a bidirectional pipe and the last form
35524allows specifying two independent pipes. Using file descriptors
35525directly in this manner is fragile in general, as it can require the
35526cooperation of intermediate processes. In particular using stdin &
35527stdout is fraught with danger as other compiler options might also
35528cause the compiler to read stdin or write stdout, and it can have
35529unfortunate interactions with signal delivery from the terminal.
35530
35531@item @var{file}@r{[}?@var{ident}@r{]}
35532A mapping file consisting of space-separated module-name, filename
35533pairs, one per line. Only the mappings for the direct imports and any
35534module export name need be provided. If other mappings are provided,
35535they override those stored in any imported CMI files. A repository
35536root may be specified in the mapping file by using @samp{$root} as the
35537module name in the first active line. Use of this option will disable
35538any default module->CMI name mapping.
35539
35540@end table
35541
35542As shown, an optional @var{ident} may suffix the first word of the
35543option, indicated by a @samp{?} prefix. The value is used in the
35544initial handshake with the module server, or to specify a prefix on
35545mapping file lines. In the server case, the main source file name is
35546used if no @var{ident} is specified. In the file case, all non-blank
35547lines are significant, unless a value is specified, in which case only
35548lines beginning with @var{ident} are significant. The @var{ident}
35549must be separated by whitespace from the module name. Be aware that
35550@samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
35551significant to the shell, and therefore may need quoting.
35552
35553The mapper is connected to or loaded lazily, when the first module
35554mapping is required. The networking protocols are only supported on
35555hosts that provide networking. If no mapper is specified a default is
35556provided.
35557
35558A project-specific mapper is expected to be provided by the build
35559system that invokes the compiler. It is not expected that a
35560general-purpose server is provided for all compilations. As such, the
35561server will know the build configuration, the compiler it invoked, and
35562the environment (such as working directory) in which that is
35563operating. As it may parallelize builds, several compilations may
35564connect to the same socket.
35565
35566The default mapper generates CMI files in a @samp{gcm.cache}
35567directory. CMI files have a @samp{.gcm} suffix. The module unit name
35568is used directly to provide the basename. Header units construct a
35569relative path using the underlying header file name. If the path is
35570already relative, a @samp{,} directory is prepended. Internal
35571@samp{..} components are translated to @samp{,,}. No attempt is made
35572to canonicalize these filenames beyond that done by the preprocessor's
35573include search algorithm, as in general it is ambiguous when symbolic
35574links are present.
35575
35576The mapper protocol was published as ``A Module Mapper''
35577@uref{https://wg21.link/p1184}. The implementation is provided by
35578@command{libcody}, @uref{https://github.com/urnathan/libcody},
35579which specifies the canonical protocol definition. A proof of concept
35580server implementation embedded in @command{make} was described in
35581''Make Me A Module'', @uref{https://wg21.link/p1602}.
35582
35583@node C++ Module Preprocessing
35584@subsection Module Preprocessing
35585@cindex C++ Module Preprocessing
35586
35587Modules affect preprocessing because of header units and include
35588translation. Some uses of the preprocessor as a separate step either
35589do not produce a correct output, or require CMIs to be available.
35590
35591Header units import macros. These macros can affect later conditional
35592inclusion, which therefore can cascade to differing import sets. When
35593preprocessing, it is necessary to load the CMI. If a header unit is
35594unavailable, the preprocessor issues a warning and continue (when
35595not just preprocessing, an error is emitted). Detecting such imports
35596requires preprocessor tokenization of the input stream to phase 4
35597(macro expansion).
35598
35599Include translation converts @code{#include}, @code{#include_next} and
35600@code{#import} directives to internal @code{import} declarations.
35601Whether a particular directive is translated is controlled by the
35602module mapper. Header unit names are canonicalized during
35603preprocessing.
35604
35605Dependency information can be emitted for macro import, extending the
35606functionality of @option{-MD} and @option{-MMD} options. Detection of
35607import declarations also requires phase 4 preprocessing, and thus
35608requires full preprocessing (or compilation).
35609
35610The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt
35611preprocessing before phase 4.
35612
35613The @option{-save-temps} option uses @option{-fdirectives-only} for
35614preprocessing, and preserve the macro definitions in the preprocessed
35615output. Usually you also want to use this option when explicitly
35616preprocessing a header-unit, or consuming such preprocessed output:
35617
35618@smallexample
35619g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii
35620g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii
35621@end smallexample
35622
35623@node C++ Compiled Module Interface
35624@subsection Compiled Module Interface
35625@cindex C++ Compiled Module Interface
35626
35627CMIs are an additional artifact when compiling named module
35628interfaces, partitions or header units. These are read when
35629importing. CMI contents are implementation-specific, and in GCC's
35630case tied to the compiler version. Consider them a rebuildable cache
35631artifact, not a distributable object.
35632
35633When creating an output CMI, any missing directory components are
35634created in a manner that is safe for concurrent builds creating
35635multiple, different, CMIs within a common subdirectory tree.
35636
35637CMI contents are written to a temporary file, which is then atomically
35638renamed. Observers either see old contents (if there is an
35639existing file), or complete new contents. They do not observe the
35640CMI during its creation. This is unlike object file writing, which
35641may be observed by an external process.
35642
35643CMIs are read in lazily, if the host OS provides @code{mmap}
35644functionality. Generally blocks are read when name lookup or template
35645instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
35646option may be used.
35647
35648The @option{--param lazy-modules=@var{n}} parameter controls the limit
35649on the number of concurrently open module files during lazy loading.
35650Should more modules be imported, an LRU algorithm is used to determine
35651which files to close---until that file is needed again. This limit
35652may be exceeded with deep module dependency hierarchies. With large
35653code bases there may be more imports than the process limit of file
35654descriptors. By default, the limit is a few less than the per-process
35655file descriptor hard limit, if that is determinable.@footnote{Where
35656applicable the soft limit is incremented as needed towards the hard limit.}
35657
35658GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
35659You may use @command{readelf} to inspect them, although section
35660contents are largely undecipherable. There is a section named
35661@code{.gnu.c++.README}, which contains human-readable text. Other
35662than the first line, each line consists of @code{@var{tag}: @code{value}}
35663tuples.
35664
35665@smallexample
35666> @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
35667
35668String dump of section '.gnu.c++.README':
35669 [ 0] GNU C++ primary module interface
35670 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
35671 [ 6f] version: 2020/11/16-04:54
35672 [ 89] module: foo
35673 [ 95] source: c_b.ii
35674 [ a4] dialect: C++20/coroutines
35675 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
35676 [ ee] repository: gcm.cache
35677 [ 104] buildtime: 2020/11/16 15:03:21 UTC
35678 [ 127] localtime: 2020/11/16 07:03:21 PST
35679 [ 14a] export: foo:part1 foo-part1.gcm
35680@end smallexample
35681
35682Amongst other things, this lists the source that was built, C++
35683dialect used and imports of the module.@footnote{The precise contents
35684of this output may change.} The timestamp is the same value as that
35685provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
35686explicitly specified with the environment variable
35687@code{SOURCE_DATE_EPOCH}. For further details
35688@pxref{Environment Variables}.
35689
35690A set of related CMIs may be copied, provided the relative pathnames
35691are preserved.
35692
35693The @code{.gnu.c++.README} contents do not affect CMI integrity, and
35694it may be removed or altered. The section numbering of the sections
35695whose names do not begin with @code{.gnu.c++.}, or are not the string
35696section is significant and must not be altered.