]>
Commit | Line | Data |
---|---|---|
a945c346 | 1 | @c Copyright (C) 1988-2024 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 | |
4e053a7e | 11 | Copyright @copyright{} 1988-2024 Free Software Foundation, Inc. |
d77de738 ML |
12 | |
13 | Permission is granted to copy, distribute and/or modify this document | |
14 | under the terms of the GNU Free Documentation License, Version 1.3 or | |
15 | any later version published by the Free Software Foundation; with the | |
16 | Invariant Sections being ``GNU General Public License'' and ``Funding | |
17 | Free Software'', the Front-Cover texts being (a) (see below), and with | |
18 | the Back-Cover Texts being (b) (see below). A copy of the license is | |
19 | included 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 | |
35 | gcc [@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 | ||
43 | Only the most useful options are listed here; see below for the | |
44 | remainder. @command{g++} accepts mostly the same options as @command{gcc}. | |
45 | @c man end | |
46 | @c man begin SEEALSO | |
47 | gpl(7), gfdl(7), fsf-funding(7), | |
48 | cpp(1), gcov(1), as(1), ld(1), gdb(1) | |
49 | and 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 | |
53 | For instructions on reporting bugs, see | |
54 | @w{@value{BUGURL}}. | |
55 | @c man end | |
56 | @c man begin AUTHOR | |
57 | See the Info entry for @command{gcc}, or | |
58 | @w{@uref{https://gcc.gnu.org/onlinedocs/gcc/Contributors.html}}, | |
59 | for 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 | |
70 | When you invoke GCC, it normally does preprocessing, compilation, | |
71 | assembly and linking. The ``overall options'' allow you to stop this | |
72 | process at an intermediate stage. For example, the @option{-c} option | |
73 | says not to run the linker. Then the output consists of object files | |
74 | output by the assembler. | |
75 | @xref{Overall Options,,Options Controlling the Kind of Output}. | |
76 | ||
77 | Other options are passed on to one or more stages of processing. Some options | |
78 | control the preprocessor and others the compiler itself. Yet other | |
79 | options control the assembler and linker; most of these are not | |
80 | documented here, since you rarely need to use any of them. | |
81 | ||
82 | @cindex C compilation options | |
83 | Most of the command-line options that you can use with GCC are useful | |
84 | for C programs; when an option is only useful with another language | |
85 | (usually C++), the explanation says so explicitly. If the description | |
86 | for a particular option does not mention a source language, you can use | |
87 | that 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 | |
94 | The 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. | |
97 | When you compile C++ programs, you should invoke GCC as @command{g++} | |
98 | instead. @xref{Invoking G++,,Compiling C++ Programs}, | |
99 | for information about the differences in behavior between @command{gcc} | |
100 | and @command{g++} when compiling C++ programs. | |
101 | ||
102 | @cindex grouping options | |
103 | @cindex options, grouping | |
104 | The @command{gcc} program accepts options and file names as operands. Many | |
105 | options have multi-letter names; therefore multiple single-letter options | |
106 | may @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 | |
111 | You can mix options and other arguments. For the most part, the order | |
112 | you use doesn't matter. Order does matter when you use several | |
113 | options of the same kind; for example, if you specify @option{-L} more | |
114 | than once, the directories are searched in the order specified. Also, | |
115 | the placement of the @option{-l} option is significant. | |
116 | ||
117 | Many 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 | |
120 | these have both positive and negative forms; the negative form of | |
121 | @option{-ffoo} is @option{-fno-foo}. This manual documents | |
122 | only one of these two forms, whichever one is not the default. | |
123 | ||
124 | Some options take one or more arguments typically separated either | |
125 | by a space or by the equals sign (@samp{=}) from the option name. | |
126 | Unless documented otherwise, an argument can be either numeric or | |
127 | a string. Numeric arguments must typically be small unsigned decimal | |
128 | or hexadecimal integers. Hexadecimal arguments must begin with | |
129 | the @samp{0x} prefix. Arguments to options that specify a size | |
130 | threshold of some sort may be arbitrarily large decimal or hexadecimal | |
131 | integers followed by a byte size suffix designating a multiple of bytes | |
132 | such 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 | |
135 | designated by @var{byte-size} in the following text. Refer to the NIST, | |
136 | IEC, and other relevant national and international standards for the full | |
137 | listing 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 | ||
183 | Here is a summary of all the options, grouped by type. Explanations are | |
184 | in the following sections. | |
185 | ||
186 | @table @emph | |
187 | @item Overall Options | |
188 | @xref{Overall Options,,Options Controlling the Kind of Output}. | |
43b72ede AA |
189 | @gccoptlist{-c -S -E -o @var{file} |
190 | -dumpbase @var{dumpbase} -dumpbase-ext @var{auxdropsuf} | |
191 | -dumpdir @var{dumppfx} -x @var{language} | |
192 | -v -### --help@r{[}=@var{class}@r{[},@dots{}@r{]]} --target-help --version | |
193 | -pass-exit-codes -pipe -specs=@var{file} -wrapper | |
194 | @@@var{file} -ffile-prefix-map=@var{old}=@var{new} -fcanon-prefix-map | |
195 | -fplugin=@var{file} -fplugin-arg-@var{name}=@var{arg} | |
d77de738 ML |
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}. | |
43b72ede AA |
200 | @gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename} |
201 | -fno-asm | |
202 | -fno-builtin -fno-builtin-@var{function} -fcond-mismatch | |
203 | -ffreestanding -fgimple -fgnu-tm -fgnu89-inline -fhosted | |
204 | -flax-vector-conversions -fms-extensions | |
205 | -foffload=@var{arg} -foffload-options=@var{arg} | |
206 | -fopenacc -fopenacc-dim=@var{geom} | |
207 | -fopenmp -fopenmp-simd -fopenmp-target-simd-clone@r{[}=@var{device-type}@r{]} | |
208 | -fpermitted-flt-eval-methods=@var{standard} | |
209 | -fplan9-extensions -fsigned-bitfields -funsigned-bitfields | |
eb71695f | 210 | -fsigned-char -funsigned-char -fstrict-flex-arrays[=@var{n}] |
d77de738 ML |
211 | -fsso-struct=@var{endianness}} |
212 | ||
213 | @item C++ Language Options | |
214 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}. | |
43b72ede AA |
215 | @gccoptlist{-fabi-version=@var{n} -fno-access-control |
216 | -faligned-new=@var{n} -fargs-in-order=@var{n} -fchar8_t -fcheck-new | |
217 | -fconstexpr-depth=@var{n} -fconstexpr-cache-depth=@var{n} | |
218 | -fconstexpr-loop-limit=@var{n} -fconstexpr-ops-limit=@var{n} | |
219 | -fno-elide-constructors | |
220 | -fno-enforce-eh-specs | |
221 | -fno-gnu-keywords | |
1f1c4322 | 222 | -fno-immediate-escalation |
43b72ede AA |
223 | -fno-implicit-templates |
224 | -fno-implicit-inline-templates | |
225 | -fno-implement-inlines | |
226 | -fmodule-header@r{[}=@var{kind}@r{]} -fmodule-only -fmodules-ts | |
227 | -fmodule-implicit-inline | |
228 | -fno-module-lazy | |
229 | -fmodule-mapper=@var{specification} | |
230 | -fmodule-version-ignore | |
231 | -fms-extensions | |
232 | -fnew-inheriting-ctors | |
233 | -fnew-ttp-matching | |
234 | -fno-nonansi-builtins -fnothrow-opt -fno-operator-names | |
ef10cb86 | 235 | -fno-optional-diags |
43b72ede AA |
236 | -fno-pretty-templates |
237 | -fno-rtti -fsized-deallocation | |
238 | -ftemplate-backtrace-limit=@var{n} | |
239 | -ftemplate-depth=@var{n} | |
240 | -fno-threadsafe-statics -fuse-cxa-atexit | |
241 | -fno-weak -nostdinc++ | |
242 | -fvisibility-inlines-hidden | |
243 | -fvisibility-ms-compat | |
244 | -fext-numeric-literals | |
245 | -flang-info-include-translate@r{[}=@var{header}@r{]} | |
246 | -flang-info-include-translate-not | |
247 | -flang-info-module-cmi@r{[}=@var{module}@r{]} | |
248 | -stdlib=@var{libstdc++,libc++} | |
249 | -Wabi-tag -Wcatch-value -Wcatch-value=@var{n} | |
250 | -Wno-class-conversion -Wclass-memaccess | |
251 | -Wcomma-subscript -Wconditionally-supported | |
252 | -Wno-conversion-null -Wctad-maybe-unsupported | |
253 | -Wctor-dtor-privacy -Wdangling-reference | |
254 | -Wno-delete-incomplete | |
255 | -Wdelete-non-virtual-dtor -Wno-deprecated-array-compare | |
256 | -Wdeprecated-copy -Wdeprecated-copy-dtor | |
257 | -Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion | |
b106f11d AC |
258 | -Weffc++ -Wno-elaborated-enum-base |
259 | -Wno-exceptions -Wextra-semi -Wno-inaccessible-base | |
43b72ede AA |
260 | -Wno-inherited-variadic-ctor -Wno-init-list-lifetime |
261 | -Winvalid-constexpr -Winvalid-imported-macros | |
262 | -Wno-invalid-offsetof -Wno-literal-suffix | |
263 | -Wmismatched-new-delete -Wmismatched-tags | |
264 | -Wmultiple-inheritance -Wnamespaces -Wnarrowing | |
265 | -Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor | |
266 | -Wpessimizing-move -Wno-placement-new -Wplacement-new=@var{n} | |
267 | -Wrange-loop-construct -Wredundant-move -Wredundant-tags | |
268 | -Wreorder -Wregister | |
269 | -Wstrict-null-sentinel -Wno-subobject-linkage -Wtemplates | |
270 | -Wno-non-template-friend -Wold-style-cast | |
271 | -Woverloaded-virtual -Wno-pmf-conversions -Wself-move -Wsign-promo | |
272 | -Wsized-deallocation -Wsuggest-final-methods | |
273 | -Wsuggest-final-types -Wsuggest-override | |
25bb8a40 | 274 | -Wno-terminate -Wno-vexing-parse -Wvirtual-inheritance |
d77de738 ML |
275 | -Wno-virtual-move-assign -Wvolatile -Wzero-as-null-pointer-constant} |
276 | ||
277 | @item Objective-C and Objective-C++ Language Options | |
278 | @xref{Objective-C and Objective-C++ Dialect Options,,Options Controlling | |
279 | Objective-C and Objective-C++ Dialects}. | |
43b72ede AA |
280 | @gccoptlist{-fconstant-string-class=@var{class-name} |
281 | -fgnu-runtime -fnext-runtime | |
282 | -fno-nil-receivers | |
283 | -fobjc-abi-version=@var{n} | |
284 | -fobjc-call-cxx-cdtors | |
285 | -fobjc-direct-dispatch | |
286 | -fobjc-exceptions | |
287 | -fobjc-gc | |
288 | -fobjc-nilcheck | |
289 | -fobjc-std=objc1 | |
290 | -fno-local-ivars | |
291 | -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]} | |
292 | -freplace-objc-classes | |
293 | -fzero-link | |
294 | -gen-decls | |
295 | -Wassign-intercept -Wno-property-assign-default | |
296 | -Wno-protocol -Wobjc-root-class -Wselector | |
297 | -Wstrict-selector-match | |
d77de738 ML |
298 | -Wundeclared-selector} |
299 | ||
300 | @item Diagnostic Message Formatting Options | |
301 | @xref{Diagnostic Message Formatting Options,,Options to Control Diagnostic Messages Formatting}. | |
43b72ede AA |
302 | @gccoptlist{-fmessage-length=@var{n} |
303 | -fdiagnostics-plain-output | |
304 | -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]} | |
305 | -fdiagnostics-color=@r{[}auto@r{|}never@r{|}always@r{]} | |
306 | -fdiagnostics-urls=@r{[}auto@r{|}never@r{|}always@r{]} | |
307 | -fdiagnostics-format=@r{[}text@r{|}sarif-stderr@r{|}sarif-file@r{|}json@r{|}json-stderr@r{|}json-file@r{]} | |
3bd8241a | 308 | -fno-diagnostics-json-formatting |
43b72ede AA |
309 | -fno-diagnostics-show-option -fno-diagnostics-show-caret |
310 | -fno-diagnostics-show-labels -fno-diagnostics-show-line-numbers | |
311 | -fno-diagnostics-show-cwe | |
312 | -fno-diagnostics-show-rule | |
313 | -fdiagnostics-minimum-margin-width=@var{width} | |
314 | -fdiagnostics-parseable-fixits -fdiagnostics-generate-patch | |
315 | -fdiagnostics-show-template-tree -fno-elide-type | |
316 | -fdiagnostics-path-format=@r{[}none@r{|}separate-events@r{|}inline-events@r{]} | |
317 | -fdiagnostics-show-path-depths | |
318 | -fno-show-column | |
319 | -fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]} | |
320 | -fdiagnostics-column-origin=@var{origin} | |
4f01ae37 DM |
321 | -fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]} |
322 | -fdiagnostics-text-art-charset=@r{[}none@r{|}ascii@r{|}unicode@r{|}emoji@r{]}} | |
d77de738 ML |
323 | |
324 | @item Warning Options | |
325 | @xref{Warning Options,,Options to Request or Suppress Warnings}. | |
43b72ede | 326 | @gccoptlist{-fsyntax-only -fmax-errors=@var{n} -Wpedantic |
ef10cb86 | 327 | -pedantic-errors -fpermissive |
43b72ede AA |
328 | -w -Wextra -Wall -Wabi=@var{n} |
329 | -Waddress -Wno-address-of-packed-member -Waggregate-return | |
e7dd72ae | 330 | -Walloc-size -Walloc-size-larger-than=@var{byte-size} -Walloc-zero |
43b72ede AA |
331 | -Walloca -Walloca-larger-than=@var{byte-size} |
332 | -Wno-aggressive-loop-optimizations | |
333 | -Warith-conversion | |
334 | -Warray-bounds -Warray-bounds=@var{n} -Warray-compare | |
335 | -Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias | |
336 | -Wno-attribute-warning | |
337 | -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]} | |
338 | -Wbool-compare -Wbool-operation | |
339 | -Wno-builtin-declaration-mismatch | |
340 | -Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat | |
fad61bf7 | 341 | -Wc11-c23-compat |
43b72ede AA |
342 | -Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat |
343 | -Wc++20-compat | |
344 | -Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions | |
345 | -Wno-c++20-extensions -Wno-c++23-extensions | |
e7dd72ae | 346 | -Wcalloc-transposed-args |
43b72ede AA |
347 | -Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual |
348 | -Wchar-subscripts | |
349 | -Wclobbered -Wcomment | |
e1f45bea | 350 | -Wcompare-distinct-pointer-types |
43b72ede AA |
351 | -Wno-complain-wrong-lang |
352 | -Wconversion -Wno-coverage-mismatch -Wno-cpp | |
353 | -Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n} | |
354 | -Wdate-time | |
355 | -Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init | |
356 | -Wdisabled-optimization | |
357 | -Wno-discarded-array-qualifiers -Wno-discarded-qualifiers | |
358 | -Wno-div-by-zero -Wdouble-promotion | |
359 | -Wduplicated-branches -Wduplicated-cond | |
360 | -Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion | |
361 | -Wenum-int-mismatch | |
362 | -Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors | |
44e3f39a | 363 | -Wflex-array-member-not-at-end |
43b72ede AA |
364 | -Wfloat-conversion -Wfloat-equal -Wformat -Wformat=2 |
365 | -Wno-format-contains-nul -Wno-format-extra-args | |
366 | -Wformat-nonliteral -Wformat-overflow=@var{n} | |
367 | -Wformat-security -Wformat-signedness -Wformat-truncation=@var{n} | |
368 | -Wformat-y2k -Wframe-address | |
369 | -Wframe-larger-than=@var{byte-size} -Wno-free-nonheap-object | |
370 | -Wno-if-not-aligned -Wno-ignored-attributes | |
24592abd | 371 | -Wignored-qualifiers -Wno-incompatible-pointer-types -Whardened |
43b72ede AA |
372 | -Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=@var{n} |
373 | -Wno-implicit-function-declaration -Wno-implicit-int | |
374 | -Winfinite-recursion | |
375 | -Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context | |
376 | -Wno-int-to-pointer-cast -Wno-invalid-memory-model | |
377 | -Winvalid-pch -Winvalid-utf8 -Wno-unicode -Wjump-misses-init | |
378 | -Wlarger-than=@var{byte-size} -Wlogical-not-parentheses -Wlogical-op | |
379 | -Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized | |
380 | -Wmemset-elt-size -Wmemset-transposed-args | |
381 | -Wmisleading-indentation -Wmissing-attributes -Wmissing-braces | |
382 | -Wmissing-field-initializers -Wmissing-format-attribute | |
383 | -Wmissing-include-dirs -Wmissing-noreturn -Wno-missing-profile | |
384 | -Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare | |
385 | -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} | |
386 | -Wnull-dereference -Wno-odr | |
387 | -Wopenacc-parallelism | |
449b6b81 | 388 | -Wopenmp -Wopenmp-simd |
43b72ede AA |
389 | -Wno-overflow -Woverlength-strings -Wno-override-init-side-effects |
390 | -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded | |
391 | -Wparentheses -Wno-pedantic-ms-format | |
392 | -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast | |
393 | -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls | |
394 | -Wrestrict -Wno-return-local-addr -Wreturn-type | |
395 | -Wno-scalar-storage-order -Wsequence-point | |
396 | -Wshadow -Wshadow=global -Wshadow=local -Wshadow=compatible-local | |
397 | -Wno-shadow-ivar | |
398 | -Wno-shift-count-negative -Wno-shift-count-overflow -Wshift-negative-value | |
399 | -Wno-shift-overflow -Wshift-overflow=@var{n} | |
400 | -Wsign-compare -Wsign-conversion | |
401 | -Wno-sizeof-array-argument | |
402 | -Wsizeof-array-div | |
403 | -Wsizeof-pointer-div -Wsizeof-pointer-memaccess | |
404 | -Wstack-protector -Wstack-usage=@var{byte-size} -Wstrict-aliasing | |
405 | -Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n} | |
406 | -Wstring-compare | |
407 | -Wno-stringop-overflow -Wno-stringop-overread | |
eb71695f | 408 | -Wno-stringop-truncation -Wstrict-flex-arrays |
43b72ede AA |
409 | -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}malloc@r{]} |
410 | -Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum | |
411 | -Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand | |
412 | -Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs | |
9a5e8f9d | 413 | -Wtrivial-auto-var-init -Wno-tsan -Wtype-limits -Wundef |
43b72ede AA |
414 | -Wuninitialized -Wunknown-pragmas |
415 | -Wunsuffixed-float-constants -Wunused | |
416 | -Wunused-but-set-parameter -Wunused-but-set-variable | |
417 | -Wunused-const-variable -Wunused-const-variable=@var{n} | |
418 | -Wunused-function -Wunused-label -Wunused-local-typedefs | |
419 | -Wunused-macros | |
420 | -Wunused-parameter -Wno-unused-result | |
421 | -Wunused-value -Wunused-variable | |
25bb8a40 | 422 | -Wuse-after-free -Wuse-after-free=@var{n} -Wuseless-cast |
43b72ede AA |
423 | -Wno-varargs -Wvariadic-macros |
424 | -Wvector-operation-performance | |
425 | -Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than | |
426 | -Wvolatile-register-var -Wwrite-strings | |
9a5e8f9d | 427 | -Wno-xor-used-as-pow |
d77de738 ML |
428 | -Wzero-length-bounds} |
429 | ||
430 | @item Static Analyzer Options | |
431 | @gccoptlist{ | |
43b72ede AA |
432 | -fanalyzer |
433 | -fanalyzer-call-summaries | |
434 | -fanalyzer-checker=@var{name} | |
435 | -fno-analyzer-feasibility | |
436 | -fanalyzer-fine-grained | |
ce8cdf5b | 437 | -fanalyzer-show-events-in-system-headers |
43b72ede AA |
438 | -fno-analyzer-state-merge |
439 | -fno-analyzer-state-purge | |
440 | -fno-analyzer-suppress-followups | |
441 | -fanalyzer-transitivity | |
442 | -fno-analyzer-undo-inlining | |
443 | -fanalyzer-verbose-edges | |
444 | -fanalyzer-verbose-state-changes | |
445 | -fanalyzer-verbosity=@var{level} | |
446 | -fdump-analyzer | |
447 | -fdump-analyzer-callgraph | |
448 | -fdump-analyzer-exploded-graph | |
449 | -fdump-analyzer-exploded-nodes | |
450 | -fdump-analyzer-exploded-nodes-2 | |
451 | -fdump-analyzer-exploded-nodes-3 | |
452 | -fdump-analyzer-exploded-paths | |
453 | -fdump-analyzer-feasibility | |
841008d3 | 454 | -fdump-analyzer-infinite-loop |
43b72ede AA |
455 | -fdump-analyzer-json |
456 | -fdump-analyzer-state-purge | |
457 | -fdump-analyzer-stderr | |
458 | -fdump-analyzer-supergraph | |
459 | -fdump-analyzer-untracked | |
460 | -Wno-analyzer-double-fclose | |
461 | -Wno-analyzer-double-free | |
462 | -Wno-analyzer-exposure-through-output-file | |
463 | -Wno-analyzer-exposure-through-uninit-copy | |
464 | -Wno-analyzer-fd-access-mode-mismatch | |
465 | -Wno-analyzer-fd-double-close | |
466 | -Wno-analyzer-fd-leak | |
467 | -Wno-analyzer-fd-phase-mismatch | |
468 | -Wno-analyzer-fd-type-mismatch | |
469 | -Wno-analyzer-fd-use-after-close | |
470 | -Wno-analyzer-fd-use-without-check | |
471 | -Wno-analyzer-file-leak | |
472 | -Wno-analyzer-free-of-non-heap | |
473 | -Wno-analyzer-imprecise-fp-arithmetic | |
841008d3 | 474 | -Wno-analyzer-infinite-loop |
43b72ede AA |
475 | -Wno-analyzer-infinite-recursion |
476 | -Wno-analyzer-jump-through-null | |
477 | -Wno-analyzer-malloc-leak | |
478 | -Wno-analyzer-mismatching-deallocation | |
479 | -Wno-analyzer-null-argument | |
480 | -Wno-analyzer-null-dereference | |
481 | -Wno-analyzer-out-of-bounds | |
034d99e8 | 482 | -Wno-analyzer-overlapping-buffers |
43b72ede AA |
483 | -Wno-analyzer-possible-null-argument |
484 | -Wno-analyzer-possible-null-dereference | |
485 | -Wno-analyzer-putenv-of-auto-var | |
486 | -Wno-analyzer-shift-count-negative | |
487 | -Wno-analyzer-shift-count-overflow | |
488 | -Wno-analyzer-stale-setjmp-buffer | |
489 | -Wno-analyzer-tainted-allocation-size | |
490 | -Wno-analyzer-tainted-assertion | |
491 | -Wno-analyzer-tainted-array-index | |
492 | -Wno-analyzer-tainted-divisor | |
493 | -Wno-analyzer-tainted-offset | |
494 | -Wno-analyzer-tainted-size | |
08b7462d | 495 | -Wanalyzer-symbol-too-complex |
43b72ede | 496 | -Wanalyzer-too-complex |
f65f63c4 | 497 | -Wno-analyzer-undefined-behavior-strtok |
43b72ede AA |
498 | -Wno-analyzer-unsafe-call-within-signal-handler |
499 | -Wno-analyzer-use-after-free | |
500 | -Wno-analyzer-use-of-pointer-in-stale-stack-frame | |
501 | -Wno-analyzer-use-of-uninitialized-value | |
502 | -Wno-analyzer-va-arg-type-mismatch | |
503 | -Wno-analyzer-va-list-exhausted | |
504 | -Wno-analyzer-va-list-leak | |
505 | -Wno-analyzer-va-list-use-after-va-end | |
506 | -Wno-analyzer-write-to-const | |
507 | -Wno-analyzer-write-to-string-literal | |
d77de738 ML |
508 | } |
509 | ||
510 | @item C and Objective-C-only Warning Options | |
43b72ede | 511 | @gccoptlist{-Wbad-function-cast -Wmissing-declarations |
ff9efa3f FW |
512 | -Wmissing-parameter-type -Wdeclaration-missing-parameter-type |
513 | -Wmissing-prototypes -Wmissing-variable-declarations | |
ffc74822 | 514 | -Wnested-externs -Wold-style-declaration -Wold-style-definition |
43b72ede | 515 | -Wstrict-prototypes -Wtraditional -Wtraditional-conversion |
d77de738 ML |
516 | -Wdeclaration-after-statement -Wpointer-sign} |
517 | ||
518 | @item Debugging Options | |
519 | @xref{Debugging Options,,Options for Debugging Your Program}. | |
43b72ede AA |
520 | @gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version} |
521 | -gbtf -gctf -gctf@var{level} | |
522 | -ggdb -grecord-gcc-switches -gno-record-gcc-switches | |
523 | -gstrict-dwarf -gno-strict-dwarf | |
524 | -gas-loc-support -gno-as-loc-support | |
525 | -gas-locview-support -gno-as-locview-support | |
3eeb4801 | 526 | -gcodeview |
43b72ede AA |
527 | -gcolumn-info -gno-column-info -gdwarf32 -gdwarf64 |
528 | -gstatement-frontiers -gno-statement-frontiers | |
529 | -gvariable-location-views -gno-variable-location-views | |
530 | -ginternal-reset-location-views -gno-internal-reset-location-views | |
531 | -ginline-points -gno-inline-points | |
532 | -gvms -gz@r{[}=@var{type}@r{]} | |
533 | -gsplit-dwarf -gdescribe-dies -gno-describe-dies | |
534 | -fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section | |
535 | -fno-eliminate-unused-debug-types | |
536 | -femit-struct-debug-baseonly -femit-struct-debug-reduced | |
537 | -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} | |
538 | -fno-eliminate-unused-debug-symbols -femit-class-debug-always | |
539 | -fno-merge-debug-strings -fno-dwarf2-cfi-asm | |
d77de738 ML |
540 | -fvar-tracking -fvar-tracking-assignments} |
541 | ||
542 | @item Optimization Options | |
543 | @xref{Optimize Options,,Options that Control Optimization}. | |
43b72ede AA |
544 | @gccoptlist{-faggressive-loop-optimizations |
545 | -falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
546 | -falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
547 | -falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
548 | -falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
549 | -fno-allocation-dce -fallow-store-data-races | |
550 | -fassociative-math -fauto-profile -fauto-profile[=@var{path}] | |
551 | -fauto-inc-dec -fbranch-probabilities | |
552 | -fcaller-saves | |
553 | -fcombine-stack-adjustments -fconserve-stack | |
04c9cf5c | 554 | -ffold-mem-offsets |
43b72ede AA |
555 | -fcompare-elim -fcprop-registers -fcrossjumping |
556 | -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules | |
557 | -fcx-limited-range | |
558 | -fdata-sections -fdce -fdelayed-branch | |
559 | -fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively | |
560 | -fdevirtualize-at-ltrans -fdse | |
561 | -fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects | |
562 | -ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style} | |
563 | -ffinite-loops | |
564 | -fforward-propagate -ffp-contract=@var{style} -ffunction-sections | |
565 | -fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity | |
566 | -fgcse-sm -fhoist-adjacent-loads -fif-conversion | |
567 | -fif-conversion2 -findirect-inlining | |
1ff6d9f7 | 568 | -finline-stringops[=@var{fn}] |
43b72ede AA |
569 | -finline-functions -finline-functions-called-once -finline-limit=@var{n} |
570 | -finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone | |
571 | -fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const | |
572 | -fipa-reference -fipa-reference-addressable | |
573 | -fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm} | |
574 | -flive-patching=@var{level} | |
575 | -fira-region=@var{region} -fira-hoist-pressure | |
576 | -fira-loop-pressure -fno-ira-share-save-slots | |
577 | -fno-ira-share-spill-slots | |
578 | -fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute | |
579 | -fivopts -fkeep-inline-functions -fkeep-static-functions | |
580 | -fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage | |
581 | -floop-block -floop-interchange -floop-strip-mine | |
582 | -floop-unroll-and-jam -floop-nest-optimize | |
583 | -floop-parallelize-all -flra-remat -flto -flto-compression-level | |
584 | -flto-partition=@var{alg} -fmerge-all-constants | |
585 | -fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves | |
586 | -fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg | |
587 | -fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse | |
588 | -fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole | |
589 | -fno-peephole2 -fno-printf-return-value -fno-sched-interblock | |
590 | -fno-sched-spec -fno-signed-zeros | |
591 | -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss | |
592 | -fomit-frame-pointer -foptimize-sibling-calls | |
593 | -fpartial-inlining -fpeel-loops -fpredictive-commoning | |
594 | -fprefetch-loop-arrays | |
595 | -fprofile-correction | |
596 | -fprofile-use -fprofile-use=@var{path} -fprofile-partial-training | |
597 | -fprofile-values -fprofile-reorder-functions | |
598 | -freciprocal-math -free -frename-registers -freorder-blocks | |
599 | -freorder-blocks-algorithm=@var{algorithm} | |
600 | -freorder-blocks-and-partition -freorder-functions | |
601 | -frerun-cse-after-loop -freschedule-modulo-scheduled-loops | |
602 | -frounding-math -fsave-optimization-record | |
603 | -fsched2-use-superblocks -fsched-pressure | |
604 | -fsched-spec-load -fsched-spec-load-dangerous | |
605 | -fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}] | |
606 | -fsched-group-heuristic -fsched-critical-path-heuristic | |
607 | -fsched-spec-insn-heuristic -fsched-rank-heuristic | |
608 | -fsched-last-insn-heuristic -fsched-dep-count-heuristic | |
609 | -fschedule-fusion | |
610 | -fschedule-insns -fschedule-insns2 -fsection-anchors | |
611 | -fselective-scheduling -fselective-scheduling2 | |
612 | -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops | |
613 | -fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate | |
614 | -fsignaling-nans | |
615 | -fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops | |
616 | -fsplit-paths | |
617 | -fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt | |
618 | -fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing | |
619 | -fthread-jumps -ftracer -ftree-bit-ccp | |
620 | -ftree-builtin-call-dce -ftree-ccp -ftree-ch | |
621 | -ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts | |
622 | -ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting | |
623 | -ftree-loop-if-convert -ftree-loop-im | |
624 | -ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns | |
625 | -ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize | |
626 | -ftree-loop-vectorize | |
627 | -ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta | |
628 | -ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra | |
629 | -ftree-switch-conversion -ftree-tail-merge | |
630 | -ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init | |
631 | -funconstrained-commons -funit-at-a-time -funroll-all-loops | |
632 | -funroll-loops -funsafe-math-optimizations -funswitch-loops | |
633 | -fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt | |
634 | -fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs | |
d77de738 ML |
635 | --param @var{name}=@var{value} |
636 | -O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz} | |
637 | ||
638 | @item Program Instrumentation Options | |
639 | @xref{Instrumentation Options,,Program Instrumentation Options}. | |
43b72ede AA |
640 | @gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage |
641 | -fprofile-abs-path | |
642 | -fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path} | |
643 | -fprofile-info-section -fprofile-info-section=@var{name} | |
644 | -fprofile-note=@var{path} -fprofile-prefix-path=@var{path} | |
645 | -fprofile-update=@var{method} -fprofile-filter-files=@var{regex} | |
646 | -fprofile-exclude-files=@var{regex} | |
647 | -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} | |
648 | -fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} | |
649 | -fsanitize-trap -fsanitize-trap=@var{style} | |
650 | -fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... | |
651 | -fsanitize-undefined-trap-on-error -fbounds-check | |
652 | -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} | |
24592abd | 653 | -fharden-compares -fharden-conditional-branches -fhardened |
551935d1 AO |
654 | -fharden-control-flow-redundancy -fhardcfr-skip-leaf |
655 | -fhardcfr-check-exceptions -fhardcfr-check-returning-calls | |
656 | -fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]} | |
43b72ede AA |
657 | -fstack-protector -fstack-protector-all -fstack-protector-strong |
658 | -fstack-protector-explicit -fstack-check | |
659 | -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} | |
660 | -fno-stack-limit -fsplit-stack | |
f0a90c7d AO |
661 | -fstrub=disable -fstrub=strict -fstrub=relaxed |
662 | -fstrub=all -fstrub=at-calls -fstrub=internal | |
43b72ede AA |
663 | -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} |
664 | -fvtv-counts -fvtv-debug | |
665 | -finstrument-functions -finstrument-functions-once | |
666 | -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} | |
667 | -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{} | |
b42dd137 M |
668 | -fprofile-prefix-map=@var{old}=@var{new} |
669 | -fpatchable-function-entry=@var{N}@r{[},@var{M}@r{]}} | |
d77de738 ML |
670 | |
671 | @item Preprocessor Options | |
672 | @xref{Preprocessor Options,,Options Controlling the Preprocessor}. | |
43b72ede AA |
673 | @gccoptlist{-A@var{question}=@var{answer} |
674 | -A-@var{question}@r{[}=@var{answer}@r{]} | |
675 | -C -CC -D@var{macro}@r{[}=@var{defn}@r{]} | |
676 | -dD -dI -dM -dN -dU | |
677 | -fdebug-cpp -fdirectives-only -fdollars-in-identifiers | |
678 | -fexec-charset=@var{charset} -fextended-identifiers | |
679 | -finput-charset=@var{charset} -flarge-source-files | |
680 | -fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth} | |
681 | -fno-canonical-system-headers -fpch-deps -fpch-preprocess | |
682 | -fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion | |
683 | -fwide-exec-charset=@var{charset} -fworking-directory | |
684 | -H -imacros @var{file} -include @var{file} | |
685 | -M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules | |
686 | -no-integrated-cpp -P -pthread -remap | |
687 | -traditional -traditional-cpp -trigraphs | |
688 | -U@var{macro} -undef | |
d77de738 ML |
689 | -Wp,@var{option} -Xpreprocessor @var{option}} |
690 | ||
691 | @item Assembler Options | |
692 | @xref{Assembler Options,,Passing Options to the Assembler}. | |
693 | @gccoptlist{-Wa,@var{option} -Xassembler @var{option}} | |
694 | ||
695 | @item Linker Options | |
696 | @xref{Link Options,,Options for Linking}. | |
43b72ede AA |
697 | @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} |
698 | -nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++ | |
699 | -e @var{entry} --entry=@var{entry} | |
700 | -pie -pthread -r -rdynamic | |
701 | -s -static -static-pie -static-libgcc -static-libstdc++ | |
702 | -static-libasan -static-libtsan -static-liblsan -static-libubsan | |
703 | -shared -shared-libgcc -symbolic | |
704 | -T @var{script} -Wl,@var{option} -Xlinker @var{option} | |
d77de738 ML |
705 | -u @var{symbol} -z @var{keyword}} |
706 | ||
707 | @item Directory Options | |
708 | @xref{Directory Options,,Options for Directory Search}. | |
43b72ede AA |
709 | @gccoptlist{-B@var{prefix} -I@var{dir} -I- |
710 | -idirafter @var{dir} | |
711 | -imacros @var{file} -imultilib @var{dir} | |
712 | -iplugindir=@var{dir} -iprefix @var{file} | |
713 | -iquote @var{dir} -isysroot @var{dir} -isystem @var{dir} | |
714 | -iwithprefix @var{dir} -iwithprefixbefore @var{dir} | |
715 | -L@var{dir} -no-canonical-prefixes --no-sysroot-suffix | |
d77de738 ML |
716 | -nostdinc -nostdinc++ --sysroot=@var{dir}} |
717 | ||
718 | @item Code Generation Options | |
719 | @xref{Code Gen Options,,Options for Code Generation Conventions}. | |
43b72ede AA |
720 | @gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} |
721 | -ffixed-@var{reg} -fexceptions | |
722 | -fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables | |
723 | -fasynchronous-unwind-tables | |
724 | -fno-gnu-unique | |
725 | -finhibit-size-directive -fcommon -fno-ident | |
726 | -fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt | |
727 | -fno-jump-tables -fno-bit-tests | |
728 | -frecord-gcc-switches | |
729 | -freg-struct-return -fshort-enums -fshort-wchar | |
730 | -fverbose-asm -fpack-struct[=@var{n}] | |
731 | -fleading-underscore -ftls-model=@var{model} | |
732 | -fstack-reuse=@var{reuse_level} | |
28d8c680 AB |
733 | -ftrampolines -ftrampoline-impl=@r{[}stack@r{|}heap@r{]} |
734 | -ftrapv -fwrapv | |
43b72ede | 735 | -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} |
d77de738 ML |
736 | -fstrict-volatile-bitfields -fsync-libcalls} |
737 | ||
738 | @item Developer Options | |
739 | @xref{Developer Options,,GCC Developer Options}. | |
43b72ede | 740 | @gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion |
d77de738 | 741 | -dumpfullversion -fcallgraph-info@r{[}=su,da@r{]} |
43b72ede AA |
742 | -fchecking -fchecking=@var{n} |
743 | -fdbg-cnt-list -fdbg-cnt=@var{counter-value-list} | |
744 | -fdisable-ipa-@var{pass_name} | |
745 | -fdisable-rtl-@var{pass_name} | |
746 | -fdisable-rtl-@var{pass-name}=@var{range-list} | |
747 | -fdisable-tree-@var{pass_name} | |
748 | -fdisable-tree-@var{pass-name}=@var{range-list} | |
749 | -fdump-debug -fdump-earlydebug | |
750 | -fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links | |
751 | -fdump-final-insns@r{[}=@var{file}@r{]} | |
752 | -fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline | |
753 | -fdump-lang-all | |
754 | -fdump-lang-@var{switch} | |
755 | -fdump-lang-@var{switch}-@var{options} | |
756 | -fdump-lang-@var{switch}-@var{options}=@var{filename} | |
757 | -fdump-passes | |
758 | -fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename} | |
759 | -fdump-statistics | |
760 | -fdump-tree-all | |
761 | -fdump-tree-@var{switch} | |
762 | -fdump-tree-@var{switch}-@var{options} | |
763 | -fdump-tree-@var{switch}-@var{options}=@var{filename} | |
764 | -fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second | |
765 | -fenable-@var{kind}-@var{pass} | |
766 | -fenable-@var{kind}-@var{pass}=@var{range-list} | |
767 | -fira-verbose=@var{n} | |
768 | -flto-report -flto-report-wpa -fmem-report-wpa | |
769 | -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report | |
770 | -fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]} | |
771 | -fmultiflags -fprofile-report | |
772 | -frandom-seed=@var{string} -fsched-verbose=@var{n} | |
773 | -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose | |
774 | -fstats -fstack-usage -ftime-report -ftime-report-details | |
775 | -fvar-tracking-assignments-toggle -gtoggle | |
776 | -print-file-name=@var{library} -print-libgcc-file-name | |
777 | -print-multi-directory -print-multi-lib -print-multi-os-directory | |
778 | -print-prog-name=@var{program} -print-search-dirs -Q | |
779 | -print-sysroot -print-sysroot-headers-suffix | |
d77de738 ML |
780 | -save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}} |
781 | ||
782 | @item Machine-Dependent Options | |
783 | @xref{Submodel Options,,Machine-Dependent Options}. | |
784 | @c This list is ordered alphanumerically by subsection name. | |
785 | @c Try and put the significant identifier (CPU or system) first, | |
786 | @c so users have a clue at guessing where the ones they want will be. | |
787 | ||
788 | @emph{AArch64 Options} | |
43b72ede AA |
789 | @gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian |
790 | -mgeneral-regs-only | |
791 | -mcmodel=tiny -mcmodel=small -mcmodel=large | |
792 | -mstrict-align -mno-strict-align | |
793 | -momit-leaf-frame-pointer | |
794 | -mtls-dialect=desc -mtls-dialect=traditional | |
795 | -mtls-size=@var{size} | |
796 | -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 | |
797 | -mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div | |
798 | -mpc-relative-literal-loads | |
799 | -msign-return-address=@var{scope} | |
d77de738 | 800 | -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf} |
43b72ede AA |
801 | +@var{b-key}]|@var{bti} |
802 | -mharden-sls=@var{opts} | |
803 | -march=@var{name} -mcpu=@var{name} -mtune=@var{name} | |
804 | -moverride=@var{string} -mverbose-cost-dump | |
805 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg} | |
806 | -mstack-protector-guard-offset=@var{offset} -mtrack-speculation | |
c0911c6b | 807 | -moutline-atomics -mearly-ldp-fusion -mlate-ldp-fusion} |
d77de738 ML |
808 | |
809 | @emph{Adapteva Epiphany Options} | |
43b72ede AA |
810 | @gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs |
811 | -mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf | |
812 | -msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num} | |
813 | -mround-nearest -mlong-calls -mshort-calls -msmall16 | |
814 | -mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num} | |
d77de738 ML |
815 | -msplit-vecmove-early -m1reg-@var{reg}} |
816 | ||
817 | @emph{AMD GCN Options} | |
818 | @gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}} | |
819 | ||
820 | @emph{ARC Options} | |
43b72ede AA |
821 | @gccoptlist{-mbarrel-shifter -mjli-always |
822 | -mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700 | |
823 | -mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr | |
824 | -mea -mno-mpy -mmul32x16 -mmul64 -matomic | |
825 | -mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap | |
826 | -mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape | |
827 | -mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof | |
828 | -mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved | |
829 | -mrgf-banked-regs -mlpc-width=@var{width} -G @var{num} | |
830 | -mvolatile-cache -mtp-regno=@var{regno} | |
831 | -malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc | |
832 | -mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi | |
833 | -mexpand-adddi -mindexed-loads -mlra -mlra-priority-none | |
834 | -mlra-priority-compact -mlra-priority-noncompact -mmillicode | |
835 | -mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level} | |
836 | -mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame | |
837 | -munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo} | |
d77de738 ML |
838 | -mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index} |
839 | ||
840 | @emph{ARM Options} | |
43b72ede AA |
841 | @gccoptlist{-mapcs-frame -mno-apcs-frame |
842 | -mabi=@var{name} | |
843 | -mapcs-stack-check -mno-apcs-stack-check | |
844 | -mapcs-reentrant -mno-apcs-reentrant | |
845 | -mgeneral-regs-only | |
846 | -msched-prolog -mno-sched-prolog | |
847 | -mlittle-endian -mbig-endian | |
848 | -mbe8 -mbe32 | |
849 | -mfloat-abi=@var{name} | |
d77de738 | 850 | -mfp16-format=@var{name} |
43b72ede AA |
851 | -mthumb-interwork -mno-thumb-interwork |
852 | -mcpu=@var{name} -march=@var{name} -mfpu=@var{name} | |
853 | -mtune=@var{name} -mprint-tune-info | |
854 | -mstructure-size-boundary=@var{n} | |
855 | -mabort-on-noreturn | |
856 | -mlong-calls -mno-long-calls | |
857 | -msingle-pic-base -mno-single-pic-base | |
858 | -mpic-register=@var{reg} | |
859 | -mnop-fun-dllimport | |
860 | -mpoke-function-name | |
861 | -mthumb -marm -mflip-thumb | |
862 | -mtpcs-frame -mtpcs-leaf-frame | |
863 | -mcaller-super-interworking -mcallee-super-interworking | |
864 | -mtp=@var{name} -mtls-dialect=@var{dialect} | |
865 | -mword-relocations | |
866 | -mfix-cortex-m3-ldrd | |
867 | -mfix-cortex-a57-aes-1742098 | |
868 | -mfix-cortex-a72-aes-1655431 | |
869 | -munaligned-access | |
870 | -mneon-for-64bits | |
871 | -mslow-flash-data | |
872 | -masm-syntax-unified | |
873 | -mrestrict-it | |
874 | -mverbose-cost-dump | |
875 | -mpure-code | |
876 | -mcmse | |
877 | -mfix-cmse-cve-2021-35465 | |
878 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset} | |
879 | -mfdpic | |
14fab5fb AC |
880 | -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}] |
881 | [+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]} | |
d77de738 ML |
882 | |
883 | @emph{AVR Options} | |
43b72ede AA |
884 | @gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args |
885 | -mbranch-cost=@var{cost} | |
42503cc2 GJL |
886 | -mcall-prologues -mgas-isr-prologues -mint8 -mflmap |
887 | -mdouble=@var{bits} -mlong-double=@var{bits} | |
43b72ede AA |
888 | -mn_flash=@var{size} -mno-interrupts |
889 | -mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack | |
42503cc2 GJL |
890 | -mrodata-in-ram -mfract-convert-truncate |
891 | -mshort-calls -mskip-bug -nodevicelib -nodevicespecs | |
d77de738 ML |
892 | -Waddr-space-convert -Wmisspelled-isr} |
893 | ||
894 | @emph{Blackfin Options} | |
43b72ede AA |
895 | @gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} |
896 | -msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer | |
897 | -mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly | |
898 | -mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library | |
899 | -mno-id-shared-library -mshared-library-id=@var{n} | |
900 | -mleaf-id-shared-library -mno-leaf-id-shared-library | |
901 | -msep-data -mno-sep-data -mlong-calls -mno-long-calls | |
902 | -mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram | |
d77de738 ML |
903 | -micplb} |
904 | ||
905 | @emph{C6X Options} | |
43b72ede | 906 | @gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu} |
d77de738 ML |
907 | -msim -msdata=@var{sdata-type}} |
908 | ||
909 | @emph{CRIS Options} | |
910 | @gccoptlist{-mcpu=@var{cpu} -march=@var{cpu} | |
43b72ede AA |
911 | -mtune=@var{cpu} -mmax-stack-frame=@var{n} |
912 | -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects | |
913 | -mstack-align -mdata-align -mconst-align | |
914 | -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue | |
915 | -melf -maout -sim -sim2 | |
d77de738 ML |
916 | -mmul-bug-workaround -mno-mul-bug-workaround} |
917 | ||
918 | @emph{C-SKY Options} | |
43b72ede AA |
919 | @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} |
920 | -mbig-endian -EB -mlittle-endian -EL | |
921 | -mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu | |
922 | -mfloat-abi=@var{name} | |
923 | -melrw -mistack -mmp -mcp -mcache -msecurity -mtrust | |
924 | -mdsp -medsp -mvdsp | |
925 | -mdiv -msmart -mhigh-registers -manchor | |
926 | -mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt | |
d77de738 ML |
927 | -mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim} |
928 | ||
929 | @emph{Darwin Options} | |
43b72ede AA |
930 | @gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal |
931 | -arch_only -bind_at_load -bundle -bundle_loader | |
932 | -client_name -compatibility_version -current_version | |
933 | -dead_strip | |
934 | -dependency-file -dylib_file -dylinker_install_name | |
935 | -dynamic -dynamiclib -exported_symbols_list | |
936 | -filelist -flat_namespace -force_cpusubtype_ALL | |
937 | -force_flat_namespace -headerpad_max_install_names | |
938 | -iframework | |
939 | -image_base -init -install_name -keep_private_externs | |
940 | -multi_module -multiply_defined -multiply_defined_unused | |
47b634a3 | 941 | -noall_load -no_dead_strip_inits_and_terms -nodefaultrpaths |
43b72ede AA |
942 | -nofixprebinding -nomultidefs -noprebind -noseglinkedit |
943 | -pagezero_size -prebind -prebind_all_twolevel_modules | |
944 | -private_bundle -read_only_relocs -sectalign | |
945 | -sectobjectsymbols -whyload -seg1addr | |
946 | -sectcreate -sectobjectsymbols -sectorder | |
947 | -segaddr -segs_read_only_addr -segs_read_write_addr | |
948 | -seg_addr_table -seg_addr_table_filename -seglinkedit | |
949 | -segprot -segs_read_only_addr -segs_read_write_addr | |
950 | -single_module -static -sub_library -sub_umbrella | |
951 | -twolevel_namespace -umbrella -undefined | |
952 | -unexported_symbols_list -weak_reference_mismatches | |
953 | -whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version} | |
d77de738 ML |
954 | -mkernel -mone-byte-bool} |
955 | ||
956 | @emph{DEC Alpha Options} | |
43b72ede AA |
957 | @gccoptlist{-mno-fp-regs -msoft-float |
958 | -mieee -mieee-with-inexact -mieee-conformant | |
959 | -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} | |
960 | -mtrap-precision=@var{mode} -mbuild-constants | |
961 | -mcpu=@var{cpu-type} -mtune=@var{cpu-type} | |
962 | -mbwx -mmax -mfix -mcix | |
963 | -mfloat-vax -mfloat-ieee | |
964 | -mexplicit-relocs -msmall-data -mlarge-data | |
965 | -msmall-text -mlarge-text | |
d77de738 ML |
966 | -mmemory-latency=@var{time}} |
967 | ||
968 | @emph{eBPF Options} | |
9cbf4286 | 969 | @gccoptlist{-mbig-endian -mlittle-endian |
77d0f9ec | 970 | -mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re -mjmpext |
14dab1a1 | 971 | -mjmp32 -malu32 -mv3-atomics -mbswap -msdiv -msmov -mcpu=@var{version} |
9cbf4286 | 972 | -masm=@var{dialect}} |
d77de738 ML |
973 | |
974 | @emph{FR30 Options} | |
975 | @gccoptlist{-msmall-model -mno-lsim} | |
976 | ||
977 | @emph{FT32 Options} | |
978 | @gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm} | |
979 | ||
980 | @emph{FRV Options} | |
43b72ede AA |
981 | @gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 |
982 | -mhard-float -msoft-float | |
983 | -malloc-cc -mfixed-cc -mdword -mno-dword | |
984 | -mdouble -mno-double | |
985 | -mmedia -mno-media -mmuladd -mno-muladd | |
986 | -mfdpic -minline-plt -mgprel-ro -multilib-library-pic | |
987 | -mlinked-fp -mlong-calls -malign-labels | |
988 | -mlibrary-pic -macc-4 -macc-8 | |
989 | -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move | |
990 | -moptimize-membar -mno-optimize-membar | |
991 | -mscc -mno-scc -mcond-exec -mno-cond-exec | |
992 | -mvliw-branch -mno-vliw-branch | |
993 | -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec | |
994 | -mno-nested-cond-exec -mtomcat-stats | |
995 | -mTLS -mtls | |
d77de738 ML |
996 | -mcpu=@var{cpu}} |
997 | ||
998 | @emph{GNU/Linux Options} | |
43b72ede | 999 | @gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid |
d77de738 ML |
1000 | -tno-android-cc -tno-android-ld} |
1001 | ||
1002 | @emph{H8/300 Options} | |
1003 | @gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300} | |
1004 | ||
1005 | @emph{HPPA Options} | |
43b72ede AA |
1006 | @gccoptlist{-march=@var{architecture-type} |
1007 | -matomic-libcalls -mbig-switch | |
1008 | -mcaller-copies -mdisable-fpregs -mdisable-indexing | |
1009 | -mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld | |
1010 | -mfixed-range=@var{register-range} | |
1011 | -mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls | |
1012 | -mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs | |
1013 | -mno-disable-indexing -mno-fast-indirect-calls -mno-gas | |
1014 | -mno-jump-in-delay -mno-long-load-store | |
1015 | -mno-portable-runtime -mno-soft-float | |
1016 | -mno-space-regs -msoft-float -mpa-risc-1-0 | |
1017 | -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime | |
1018 | -mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio | |
d77de738 ML |
1019 | -munix=@var{unix-std} -nolibdld -static -threads} |
1020 | ||
1021 | @emph{IA-64 Options} | |
43b72ede AA |
1022 | @gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic |
1023 | -mvolatile-asm-stop -mregister-names -msdata -mno-sdata | |
1024 | -mconstant-gp -mauto-pic -mfused-madd | |
1025 | -minline-float-divide-min-latency | |
1026 | -minline-float-divide-max-throughput | |
1027 | -mno-inline-float-divide | |
1028 | -minline-int-divide-min-latency | |
1029 | -minline-int-divide-max-throughput | |
1030 | -mno-inline-int-divide | |
1031 | -minline-sqrt-min-latency -minline-sqrt-max-throughput | |
1032 | -mno-inline-sqrt | |
1033 | -mdwarf2-asm -mearly-stop-bits | |
1034 | -mfixed-range=@var{register-range} -mtls-size=@var{tls-size} | |
1035 | -mtune=@var{cpu-type} -milp32 -mlp64 | |
1036 | -msched-br-data-spec -msched-ar-data-spec -msched-control-spec | |
1037 | -msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec | |
1038 | -msched-spec-ldc -msched-spec-control-ldc | |
1039 | -msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns | |
1040 | -msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path | |
1041 | -msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost | |
d77de738 ML |
1042 | -msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}} |
1043 | ||
1044 | @emph{LM32 Options} | |
43b72ede | 1045 | @gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled |
d77de738 ML |
1046 | -msign-extend-enabled -muser-enabled} |
1047 | ||
1048 | @emph{LoongArch Options} | |
43b72ede | 1049 | @gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type} |
bb4a8198 YY |
1050 | -mfpu=@var{fpu-type} -msimd=@var{simd-type} |
1051 | -msoft-float -msingle-float -mdouble-float -mlsx -mno-lsx -mlasx -mno-lasx | |
43b72ede AA |
1052 | -mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division |
1053 | -mcond-move-int -mno-cond-move-int | |
1054 | -mcond-move-float -mno-cond-move-float | |
1055 | -memcpy -mno-memcpy -mstrict-align -mno-strict-align | |
1056 | -mmax-inline-memcpy-size=@var{n} | |
e1b1cba1 | 1057 | -mexplicit-relocs=@var{style} -mexplicit-relocs -mno-explicit-relocs |
43b72ede | 1058 | -mdirect-extern-access -mno-direct-extern-access |
fe23a2ff | 1059 | -mcmodel=@var{code-model} -mrelax -mpass-mrelax-to-as} |
9a07bc47 | 1060 | -mrecip -mrecip=@var{opt} |
d77de738 ML |
1061 | |
1062 | @emph{M32R/D Options} | |
43b72ede AA |
1063 | @gccoptlist{-m32r2 -m32rx -m32r |
1064 | -mdebug | |
1065 | -malign-loops -mno-align-loops | |
1066 | -missue-rate=@var{number} | |
1067 | -mbranch-cost=@var{number} | |
1068 | -mmodel=@var{code-size-model-type} | |
1069 | -msdata=@var{sdata-type} | |
1070 | -mno-flush-func -mflush-func=@var{name} | |
1071 | -mno-flush-trap -mflush-trap=@var{number} | |
d77de738 ML |
1072 | -G @var{num}} |
1073 | ||
1074 | @emph{M32C Options} | |
1075 | @gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}} | |
1076 | ||
1077 | @emph{M680x0 Options} | |
43b72ede AA |
1078 | @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune} |
1079 | -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 | |
1080 | -m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407 | |
1081 | -mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020 | |
1082 | -mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort | |
1083 | -mno-short -mhard-float -m68881 -msoft-float -mpcrel | |
1084 | -malign-int -mstrict-align -msep-data -mno-sep-data | |
1085 | -mshared-library-id=n -mid-shared-library -mno-id-shared-library | |
d77de738 ML |
1086 | -mxgot -mno-xgot -mlong-jump-table-offsets} |
1087 | ||
1088 | @emph{MCore Options} | |
43b72ede AA |
1089 | @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates |
1090 | -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields | |
1091 | -m4byte-functions -mno-4byte-functions -mcallgraph-data | |
1092 | -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim | |
d77de738 ML |
1093 | -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment} |
1094 | ||
d77de738 | 1095 | @emph{MicroBlaze Options} |
43b72ede AA |
1096 | @gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu} |
1097 | -mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift | |
1098 | -mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss | |
1099 | -mxl-multiply-high -mxl-float-convert -mxl-float-sqrt | |
1100 | -mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model} | |
d77de738 ML |
1101 | -mpic-data-is-text-relative} |
1102 | ||
1103 | @emph{MIPS Options} | |
43b72ede AA |
1104 | @gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} |
1105 | -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5 | |
1106 | -mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6 | |
1107 | -mips16 -mno-mips16 -mflip-mips16 | |
1108 | -minterlink-compressed -mno-interlink-compressed | |
1109 | -minterlink-mips16 -mno-interlink-mips16 | |
1110 | -mabi=@var{abi} -mabicalls -mno-abicalls | |
1111 | -mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot | |
1112 | -mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float | |
1113 | -mno-float -msingle-float -mdouble-float | |
1114 | -modd-spreg -mno-odd-spreg | |
1115 | -mabs=@var{mode} -mnan=@var{encoding} | |
1116 | -mdsp -mno-dsp -mdspr2 -mno-dspr2 | |
1117 | -mmcu -mmno-mcu | |
1118 | -meva -mno-eva | |
1119 | -mvirt -mno-virt | |
1120 | -mxpa -mno-xpa | |
1121 | -mcrc -mno-crc | |
1122 | -mginv -mno-ginv | |
1123 | -mmicromips -mno-micromips | |
1124 | -mmsa -mno-msa | |
1125 | -mloongson-mmi -mno-loongson-mmi | |
1126 | -mloongson-ext -mno-loongson-ext | |
1127 | -mloongson-ext2 -mno-loongson-ext2 | |
1128 | -mfpu=@var{fpu-type} | |
1129 | -msmartmips -mno-smartmips | |
1130 | -mpaired-single -mno-paired-single -mdmx -mno-mdmx | |
1131 | -mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc | |
1132 | -mlong64 -mlong32 -msym32 -mno-sym32 | |
1133 | -G@var{num} -mlocal-sdata -mno-local-sdata | |
1134 | -mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt | |
1135 | -membedded-data -mno-embedded-data | |
1136 | -muninit-const-in-rodata -mno-uninit-const-in-rodata | |
1137 | -mcode-readable=@var{setting} | |
1138 | -msplit-addresses -mno-split-addresses | |
1139 | -mexplicit-relocs -mno-explicit-relocs | |
1140 | -mcheck-zero-division -mno-check-zero-division | |
1141 | -mdivide-traps -mdivide-breaks | |
1142 | -mload-store-pairs -mno-load-store-pairs | |
1143 | -munaligned-access -mno-unaligned-access | |
1144 | -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls | |
1145 | -mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp | |
1146 | -mfix-24k -mno-fix-24k | |
1147 | -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 | |
1148 | -mfix-r5900 -mno-fix-r5900 | |
1149 | -mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000 | |
1150 | -mfix-vr4120 -mno-fix-vr4120 | |
1151 | -mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1 | |
1152 | -mflush-func=@var{func} -mno-flush-func | |
1153 | -mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely | |
1154 | -mcompact-branches=@var{policy} | |
1155 | -mfp-exceptions -mno-fp-exceptions | |
1156 | -mvr4130-align -mno-vr4130-align -msynci -mno-synci | |
1157 | -mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4 | |
1158 | -mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address | |
d77de738 ML |
1159 | -mframe-header-opt -mno-frame-header-opt} |
1160 | ||
1161 | @emph{MMIX Options} | |
43b72ede AA |
1162 | @gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu |
1163 | -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols | |
1164 | -melf -mbranch-predict -mno-branch-predict -mbase-addresses | |
d77de738 ML |
1165 | -mno-base-addresses -msingle-exit -mno-single-exit} |
1166 | ||
1167 | @emph{MN10300 Options} | |
43b72ede AA |
1168 | @gccoptlist{-mmult-bug -mno-mult-bug |
1169 | -mno-am33 -mam33 -mam33-2 -mam34 | |
1170 | -mtune=@var{cpu-type} | |
1171 | -mreturn-pointer-on-d0 | |
d77de738 ML |
1172 | -mno-crt0 -mrelax -mliw -msetlb} |
1173 | ||
1174 | @emph{Moxie Options} | |
1175 | @gccoptlist{-meb -mel -mmul.x -mno-crt0} | |
1176 | ||
1177 | @emph{MSP430 Options} | |
43b72ede AA |
1178 | @gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax |
1179 | -mwarn-mcu | |
1180 | -mcode-region= -mdata-region= | |
1181 | -msilicon-errata= -msilicon-errata-warn= | |
d77de738 ML |
1182 | -mhwmult= -minrt -mtiny-printf -mmax-inline-shift=} |
1183 | ||
1184 | @emph{NDS32 Options} | |
43b72ede AA |
1185 | @gccoptlist{-mbig-endian -mlittle-endian |
1186 | -mreduced-regs -mfull-regs | |
1187 | -mcmov -mno-cmov | |
1188 | -mext-perf -mno-ext-perf | |
1189 | -mext-perf2 -mno-ext-perf2 | |
1190 | -mext-string -mno-ext-string | |
1191 | -mv3push -mno-v3push | |
1192 | -m16bit -mno-16bit | |
1193 | -misr-vector-size=@var{num} | |
1194 | -mcache-block-size=@var{num} | |
1195 | -march=@var{arch} | |
1196 | -mcmodel=@var{code-model} | |
d77de738 ML |
1197 | -mctor-dtor -mrelax} |
1198 | ||
1199 | @emph{Nios II Options} | |
43b72ede AA |
1200 | @gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt |
1201 | -mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp} | |
1202 | -mel -meb | |
1203 | -mno-bypass-cache -mbypass-cache | |
1204 | -mno-cache-volatile -mcache-volatile | |
1205 | -mno-fast-sw-div -mfast-sw-div | |
1206 | -mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div | |
1207 | -mcustom-@var{insn}=@var{N} -mno-custom-@var{insn} | |
1208 | -mcustom-fpu-cfg=@var{name} | |
1209 | -mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name} | |
d77de738 ML |
1210 | -march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx} |
1211 | ||
1212 | @emph{Nvidia PTX Options} | |
1213 | @gccoptlist{-m64 -mmainkernel -moptimize} | |
1214 | ||
1215 | @emph{OpenRISC Options} | |
43b72ede AA |
1216 | @gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div |
1217 | -msoft-mul -msoft-div | |
1218 | -msoft-float -mhard-float -mdouble-float -munordered-float | |
1219 | -mcmov -mror -mrori -msext -msfimm -mshftimm | |
d77de738 ML |
1220 | -mcmodel=@var{code-model}} |
1221 | ||
1222 | @emph{PDP-11 Options} | |
43b72ede AA |
1223 | @gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 |
1224 | -mint32 -mno-int16 -mint16 -mno-int32 | |
d77de738 ML |
1225 | -msplit -munix-asm -mdec-asm -mgnu-asm -mlra} |
1226 | ||
d77de738 ML |
1227 | @emph{PowerPC Options} |
1228 | See RS/6000 and PowerPC Options. | |
1229 | ||
1230 | @emph{PRU Options} | |
43b72ede | 1231 | @gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop |
f58e6d42 | 1232 | -mabi=@var{variant}} |
d77de738 ML |
1233 | |
1234 | @emph{RISC-V Options} | |
43b72ede AA |
1235 | @gccoptlist{-mbranch-cost=@var{N-instruction} |
1236 | -mplt -mno-plt | |
1237 | -mabi=@var{ABI-string} | |
1238 | -mfdiv -mno-fdiv | |
1239 | -mdiv -mno-div | |
1240 | -misa-spec=@var{ISA-spec-string} | |
1241 | -march=@var{ISA-string} | |
1242 | -mtune=@var{processor-string} | |
1243 | -mpreferred-stack-boundary=@var{num} | |
1244 | -msmall-data-limit=@var{N-bytes} | |
1245 | -msave-restore -mno-save-restore | |
1246 | -mshorten-memrefs -mno-shorten-memrefs | |
1247 | -mstrict-align -mno-strict-align | |
1248 | -mcmodel=medlow -mcmodel=medany | |
1249 | -mexplicit-relocs -mno-explicit-relocs | |
1250 | -mrelax -mno-relax | |
1251 | -mriscv-attribute -mno-riscv-attribute | |
1252 | -malign-data=@var{type} | |
1253 | -mbig-endian -mlittle-endian | |
1254 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} | |
1255 | -mstack-protector-guard-offset=@var{offset} | |
f797260a | 1256 | -mcsr-check -mno-csr-check |
dc95b338 | 1257 | -mmovcc -mno-movcc |
df48285b | 1258 | -minline-atomics -mno-inline-atomics |
949f1ccf CM |
1259 | -minline-strlen -mno-inline-strlen |
1260 | -minline-strcmp -mno-inline-strcmp | |
1261 | -minline-strncmp -mno-inline-strncmp} | |
d77de738 ML |
1262 | |
1263 | @emph{RL78 Options} | |
43b72ede AA |
1264 | @gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs |
1265 | -mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14 | |
d77de738 ML |
1266 | -m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts} |
1267 | ||
1268 | @emph{RS/6000 and PowerPC Options} | |
43b72ede AA |
1269 | @gccoptlist{-mcpu=@var{cpu-type} |
1270 | -mtune=@var{cpu-type} | |
1271 | -mcmodel=@var{code-model} | |
1272 | -mpowerpc64 | |
1273 | -maltivec -mno-altivec | |
1274 | -mpowerpc-gpopt -mno-powerpc-gpopt | |
1275 | -mpowerpc-gfxopt -mno-powerpc-gfxopt | |
1276 | -mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd | |
1277 | -mfprnd -mno-fprnd | |
1278 | -mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp | |
1279 | -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc | |
1280 | -m64 -m32 -mxl-compat -mno-xl-compat -mpe | |
1281 | -malign-power -malign-natural | |
1282 | -msoft-float -mhard-float -mmultiple -mno-multiple | |
1283 | -mupdate -mno-update | |
1284 | -mavoid-indexed-addresses -mno-avoid-indexed-addresses | |
1285 | -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align | |
1286 | -mstrict-align -mno-strict-align -mrelocatable | |
1287 | -mno-relocatable -mrelocatable-lib -mno-relocatable-lib | |
1288 | -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian | |
1289 | -mdynamic-no-pic -mswdiv -msingle-pic-base | |
1290 | -mprioritize-restricted-insns=@var{priority} | |
1291 | -msched-costly-dep=@var{dependence_type} | |
1292 | -minsert-sched-nops=@var{scheme} | |
1293 | -mcall-aixdesc -mcall-eabi -mcall-freebsd | |
1294 | -mcall-linux -mcall-netbsd -mcall-openbsd | |
1295 | -mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi | |
1296 | -mtraceback=@var{traceback_type} | |
1297 | -maix-struct-return -msvr4-struct-return | |
1298 | -mabi=@var{abi-type} -msecure-plt -mbss-plt | |
1299 | -mlongcall -mno-longcall -mpltseq -mno-pltseq | |
1300 | -mblock-move-inline-limit=@var{num} | |
1301 | -mblock-compare-inline-limit=@var{num} | |
1302 | -mblock-compare-inline-loop-limit=@var{num} | |
1303 | -mno-block-ops-unaligned-vsx | |
1304 | -mstring-compare-inline-limit=@var{num} | |
1305 | -misel -mno-isel | |
1306 | -mvrsave -mno-vrsave | |
1307 | -mmulhw -mno-mulhw | |
1308 | -mdlmzb -mno-dlmzb | |
1309 | -mprototype -mno-prototype | |
1310 | -msim -mmvme -mads -myellowknife -memb -msdata | |
1311 | -msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num} | |
1312 | -mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision | |
1313 | -mno-recip-precision | |
1314 | -mveclibabi=@var{type} -mfriz -mno-friz | |
1315 | -mpointers-to-nested-functions -mno-pointers-to-nested-functions | |
1316 | -msave-toc-indirect -mno-save-toc-indirect | |
1317 | -mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector | |
1318 | -mcrypto -mno-crypto -mhtm -mno-htm | |
1319 | -mquad-memory -mno-quad-memory | |
1320 | -mquad-memory-atomic -mno-quad-memory-atomic | |
1321 | -mcompat-align-parm -mno-compat-align-parm | |
1322 | -mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware | |
1323 | -mgnu-attribute -mno-gnu-attribute | |
1324 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} | |
1325 | -mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed | |
1326 | -mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect | |
d77de738 ML |
1327 | -mprivileged -mno-privileged} |
1328 | ||
1329 | @emph{RX Options} | |
43b72ede AA |
1330 | @gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu |
1331 | -mcpu= | |
1332 | -mbig-endian-data -mlittle-endian-data | |
1333 | -msmall-data | |
1334 | -msim -mno-sim | |
1335 | -mas100-syntax -mno-as100-syntax | |
1336 | -mrelax | |
1337 | -mmax-constant-size= | |
1338 | -mint-register= | |
1339 | -mpid | |
1340 | -mallow-string-insns -mno-allow-string-insns | |
1341 | -mjsr | |
1342 | -mno-warn-multiple-fast-interrupts | |
d77de738 ML |
1343 | -msave-acc-in-interrupts} |
1344 | ||
1345 | @emph{S/390 and zSeries Options} | |
43b72ede AA |
1346 | @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} |
1347 | -mhard-float -msoft-float -mhard-dfp -mno-hard-dfp | |
1348 | -mlong-double-64 -mlong-double-128 | |
1349 | -mbackchain -mno-backchain -mpacked-stack -mno-packed-stack | |
1350 | -msmall-exec -mno-small-exec -mmvcle -mno-mvcle | |
1351 | -m64 -m31 -mdebug -mno-debug -mesa -mzarch | |
1352 | -mhtm -mvx -mzvector | |
1353 | -mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip | |
1354 | -mfused-madd -mno-fused-madd | |
1355 | -mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard | |
d77de738 ML |
1356 | -mhotpatch=@var{halfwords},@var{halfwords}} |
1357 | ||
d77de738 | 1358 | @emph{SH Options} |
43b72ede AA |
1359 | @gccoptlist{-m1 -m2 -m2e |
1360 | -m2a-nofpu -m2a-single-only -m2a-single -m2a | |
1361 | -m3 -m3e | |
1362 | -m4-nofpu -m4-single-only -m4-single -m4 | |
1363 | -m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al | |
1364 | -mb -ml -mdalign -mrelax | |
1365 | -mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave | |
1366 | -mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct | |
1367 | -mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy} | |
1368 | -mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} | |
1369 | -maccumulate-outgoing-args | |
1370 | -matomic-model=@var{atomic-model} | |
1371 | -mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch | |
1372 | -mcbranch-force-delay-slot | |
1373 | -mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra | |
d77de738 ML |
1374 | -mpretend-cmove -mtas} |
1375 | ||
1376 | @emph{Solaris 2 Options} | |
43b72ede | 1377 | @gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text |
d77de738 ML |
1378 | -pthreads} |
1379 | ||
1380 | @emph{SPARC Options} | |
43b72ede AA |
1381 | @gccoptlist{-mcpu=@var{cpu-type} |
1382 | -mtune=@var{cpu-type} | |
1383 | -mcmodel=@var{code-model} | |
1384 | -mmemory-model=@var{mem-model} | |
1385 | -m32 -m64 -mapp-regs -mno-app-regs | |
1386 | -mfaster-structs -mno-faster-structs -mflat -mno-flat | |
1387 | -mfpu -mno-fpu -mhard-float -msoft-float | |
1388 | -mhard-quad-float -msoft-quad-float | |
1389 | -mstack-bias -mno-stack-bias | |
1390 | -mstd-struct-return -mno-std-struct-return | |
1391 | -munaligned-doubles -mno-unaligned-doubles | |
1392 | -muser-mode -mno-user-mode | |
1393 | -mv8plus -mno-v8plus -mvis -mno-vis | |
1394 | -mvis2 -mno-vis2 -mvis3 -mno-vis3 | |
1395 | -mvis4 -mno-vis4 -mvis4b -mno-vis4b | |
1396 | -mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld | |
1397 | -mpopc -mno-popc -msubxc -mno-subxc | |
1398 | -mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc | |
d77de738 ML |
1399 | -mlra -mno-lra} |
1400 | ||
1401 | @emph{System V Options} | |
1402 | @gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}} | |
1403 | ||
1404 | @emph{V850 Options} | |
43b72ede AA |
1405 | @gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep |
1406 | -mprolog-function -mno-prolog-function -mspace | |
1407 | -mtda=@var{n} -msda=@var{n} -mzda=@var{n} | |
1408 | -mapp-regs -mno-app-regs | |
1409 | -mdisable-callt -mno-disable-callt | |
1410 | -mv850e2v3 -mv850e2 -mv850e1 -mv850es | |
1411 | -mv850e -mv850 -mv850e3v5 | |
1412 | -mloop | |
1413 | -mrelax | |
1414 | -mlong-jumps | |
1415 | -msoft-float | |
1416 | -mhard-float | |
1417 | -mgcc-abi | |
1418 | -mrh850-abi | |
d77de738 ML |
1419 | -mbig-switch} |
1420 | ||
1421 | @emph{VAX Options} | |
1422 | @gccoptlist{-mg -mgnu -munix -mlra} | |
1423 | ||
1424 | @emph{Visium Options} | |
43b72ede | 1425 | @gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float |
d77de738 ML |
1426 | -mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode} |
1427 | ||
1428 | @emph{VMS Options} | |
43b72ede | 1429 | @gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64 |
d77de738 ML |
1430 | -mpointer-size=@var{size}} |
1431 | ||
1432 | @emph{VxWorks Options} | |
b6f4b000 | 1433 | @gccoptlist{-mrtp -msmp -non-static -Bstatic -Bdynamic |
d77de738 ML |
1434 | -Xbind-lazy -Xbind-now} |
1435 | ||
1436 | @emph{x86 Options} | |
43b72ede AA |
1437 | @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} |
1438 | -mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default | |
1439 | -mfpmath=@var{unit} | |
1440 | -masm=@var{dialect} -mno-fancy-math-387 | |
1441 | -mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float | |
1442 | -mno-wide-multiply -mrtd -malign-double | |
1443 | -mpreferred-stack-boundary=@var{num} | |
1444 | -mincoming-stack-boundary=@var{num} | |
1445 | -mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait | |
1446 | -mrecip -mrecip=@var{opt} | |
1447 | -mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt} | |
ad5b757d | 1448 | -mpartial-vector-fp-math |
43b72ede AA |
1449 | -mmove-max=@var{bits} -mstore-max=@var{bits} |
1450 | -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx | |
1451 | -mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl | |
1452 | -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes | |
1453 | -mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd | |
1454 | -mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves | |
1455 | -msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop | |
1456 | -madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp | |
1457 | -mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg | |
1458 | -mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call | |
1459 | -mavx512vbmi2 -mavx512bf16 -menqcmd | |
1460 | -mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq | |
1461 | -mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid | |
1462 | -mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk | |
1463 | -mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni | |
1464 | -mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16 | |
e686416b | 1465 | -mprefetchi -mraoint -mamx-complex -mavxvnniint16 -msm3 -msha512 -msm4 -mapxf |
49a14ee4 | 1466 | -musermsr -mavx10.1 -mavx10.1-256 -mavx10.1-512 -mevex512 |
43b72ede AA |
1467 | -mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops |
1468 | -minline-stringops-dynamically -mstringop-strategy=@var{alg} | |
1469 | -mkl -mwidekl | |
1470 | -mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy} | |
1471 | -mpush-args -maccumulate-outgoing-args -m128bit-long-double | |
1472 | -m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128 | |
1473 | -mregparm=@var{num} -msseregparm | |
1474 | -mveclibabi=@var{type} -mvect8-ret-in-mem | |
1475 | -mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign | |
1476 | -momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs | |
1477 | -mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} | |
1478 | -m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num} | |
1479 | -msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv | |
1480 | -minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name} | |
1481 | -mavx256-split-unaligned-load -mavx256-split-unaligned-store | |
1482 | -malign-data=@var{type} -mstack-protector-guard=@var{guard} | |
1483 | -mstack-protector-guard-reg=@var{reg} | |
1484 | -mstack-protector-guard-offset=@var{offset} | |
1485 | -mstack-protector-guard-symbol=@var{symbol} | |
1486 | -mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop | |
1487 | -mindirect-branch=@var{choice} -mfunction-return=@var{choice} | |
1488 | -mindirect-branch-register -mharden-sls=@var{choice} | |
1489 | -mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access | |
bb576017 | 1490 | -munroll-only-small-loops -mlam=@var{choice}} |
d77de738 ML |
1491 | |
1492 | @emph{x86 Windows Options} | |
b6c4fcda | 1493 | @gccoptlist{-mconsole -mcrtdll=@var{library} -mdll |
43b72ede | 1494 | -mnop-fun-dllimport -mthread |
d77de738 ML |
1495 | -municode -mwin32 -mwindows -fno-set-stack-executable} |
1496 | ||
1497 | @emph{Xstormy16 Options} | |
1498 | @gccoptlist{-msim} | |
1499 | ||
1500 | @emph{Xtensa Options} | |
43b72ede AA |
1501 | @gccoptlist{-mconst16 -mno-const16 |
1502 | -mfused-madd -mno-fused-madd | |
1503 | -mforce-no-pic | |
1504 | -mserialize-volatile -mno-serialize-volatile | |
1505 | -mtext-section-literals -mno-text-section-literals | |
1506 | -mauto-litpools -mno-auto-litpools | |
1507 | -mtarget-align -mno-target-align | |
1508 | -mlongcalls -mno-longcalls | |
1509 | -mabi=@var{abi-type} | |
675b390e MF |
1510 | -mextra-l32r-costs=@var{cycles} |
1511 | -mstrict-align -mno-strict-align} | |
d77de738 ML |
1512 | |
1513 | @emph{zSeries Options} | |
1514 | See S/390 and zSeries Options. | |
1515 | @end table | |
1516 | ||
1517 | ||
1518 | @node Overall Options | |
1519 | @section Options Controlling the Kind of Output | |
1520 | ||
1521 | Compilation can involve up to four stages: preprocessing, compilation | |
1522 | proper, assembly and linking, always in that order. GCC is capable of | |
1523 | preprocessing and compiling several files either into several | |
1524 | assembler input files, or into one assembler input file; then each | |
1525 | assembler input file produces an object file, and linking combines all | |
1526 | the object files (those newly compiled, and those specified as input) | |
1527 | into an executable file. | |
1528 | ||
1529 | @cindex file name suffix | |
1530 | For any given input file, the file name suffix determines what kind of | |
1531 | compilation is done: | |
1532 | ||
1533 | @table @gcctabopt | |
1534 | @item @var{file}.c | |
1535 | C source code that must be preprocessed. | |
1536 | ||
1537 | @item @var{file}.i | |
1538 | C source code that should not be preprocessed. | |
1539 | ||
1540 | @item @var{file}.ii | |
1541 | C++ source code that should not be preprocessed. | |
1542 | ||
1543 | @item @var{file}.m | |
1544 | Objective-C source code. Note that you must link with the @file{libobjc} | |
1545 | library to make an Objective-C program work. | |
1546 | ||
1547 | @item @var{file}.mi | |
1548 | Objective-C source code that should not be preprocessed. | |
1549 | ||
1550 | @item @var{file}.mm | |
1551 | @itemx @var{file}.M | |
1552 | Objective-C++ source code. Note that you must link with the @file{libobjc} | |
1553 | library to make an Objective-C++ program work. Note that @samp{.M} refers | |
1554 | to a literal capital M@. | |
1555 | ||
1556 | @item @var{file}.mii | |
1557 | Objective-C++ source code that should not be preprocessed. | |
1558 | ||
1559 | @item @var{file}.h | |
1560 | C, C++, Objective-C or Objective-C++ header file to be turned into a | |
1561 | precompiled header (default), or C, C++ header file to be turned into an | |
1562 | Ada spec (via the @option{-fdump-ada-spec} switch). | |
1563 | ||
1564 | @item @var{file}.cc | |
1565 | @itemx @var{file}.cp | |
1566 | @itemx @var{file}.cxx | |
1567 | @itemx @var{file}.cpp | |
1568 | @itemx @var{file}.CPP | |
1569 | @itemx @var{file}.c++ | |
1570 | @itemx @var{file}.C | |
1571 | C++ source code that must be preprocessed. Note that in @samp{.cxx}, | |
1572 | the last two letters must both be literally @samp{x}. Likewise, | |
1573 | @samp{.C} refers to a literal capital C@. | |
1574 | ||
1575 | @item @var{file}.mm | |
1576 | @itemx @var{file}.M | |
1577 | Objective-C++ source code that must be preprocessed. | |
1578 | ||
1579 | @item @var{file}.mii | |
1580 | Objective-C++ source code that should not be preprocessed. | |
1581 | ||
1582 | @item @var{file}.hh | |
1583 | @itemx @var{file}.H | |
1584 | @itemx @var{file}.hp | |
1585 | @itemx @var{file}.hxx | |
1586 | @itemx @var{file}.hpp | |
1587 | @itemx @var{file}.HPP | |
1588 | @itemx @var{file}.h++ | |
1589 | @itemx @var{file}.tcc | |
1590 | C++ header file to be turned into a precompiled header or Ada spec. | |
1591 | ||
1592 | @item @var{file}.f | |
1593 | @itemx @var{file}.for | |
1594 | @itemx @var{file}.ftn | |
ba615557 | 1595 | @itemx @var{file}.fi |
d77de738 ML |
1596 | Fixed form Fortran source code that should not be preprocessed. |
1597 | ||
1598 | @item @var{file}.F | |
1599 | @itemx @var{file}.FOR | |
1600 | @itemx @var{file}.fpp | |
1601 | @itemx @var{file}.FPP | |
1602 | @itemx @var{file}.FTN | |
1603 | Fixed form Fortran source code that must be preprocessed (with the traditional | |
1604 | preprocessor). | |
1605 | ||
1606 | @item @var{file}.f90 | |
1607 | @itemx @var{file}.f95 | |
1608 | @itemx @var{file}.f03 | |
1609 | @itemx @var{file}.f08 | |
ba615557 | 1610 | @itemx @var{file}.fii |
d77de738 ML |
1611 | Free form Fortran source code that should not be preprocessed. |
1612 | ||
1613 | @item @var{file}.F90 | |
1614 | @itemx @var{file}.F95 | |
1615 | @itemx @var{file}.F03 | |
1616 | @itemx @var{file}.F08 | |
1617 | Free form Fortran source code that must be preprocessed (with the | |
1618 | traditional preprocessor). | |
1619 | ||
1620 | @item @var{file}.go | |
1621 | Go source code. | |
1622 | ||
1623 | @item @var{file}.d | |
1624 | D source code. | |
1625 | ||
1626 | @item @var{file}.di | |
1627 | D interface file. | |
1628 | ||
1629 | @item @var{file}.dd | |
1630 | D documentation code (Ddoc). | |
1631 | ||
1632 | @item @var{file}.ads | |
1633 | Ada source code file that contains a library unit declaration (a | |
1634 | declaration of a package, subprogram, or generic, or a generic | |
1635 | instantiation), or a library unit renaming declaration (a package, | |
1636 | generic, or subprogram renaming declaration). Such files are also | |
1637 | called @dfn{specs}. | |
1638 | ||
1639 | @item @var{file}.adb | |
1640 | Ada source code file containing a library unit body (a subprogram or | |
1641 | package body). Such files are also called @dfn{bodies}. | |
1642 | ||
1643 | @c GCC also knows about some suffixes for languages not yet included: | |
1644 | @c Ratfor: | |
1645 | @c @var{file}.r | |
1646 | ||
1647 | @item @var{file}.s | |
1648 | Assembler code. | |
1649 | ||
1650 | @item @var{file}.S | |
1651 | @itemx @var{file}.sx | |
1652 | Assembler code that must be preprocessed. | |
1653 | ||
1654 | @item @var{other} | |
1655 | An object file to be fed straight into linking. | |
1656 | Any file name with no recognized suffix is treated this way. | |
1657 | @end table | |
1658 | ||
1659 | @opindex x | |
1660 | You can specify the input language explicitly with the @option{-x} option: | |
1661 | ||
1662 | @table @gcctabopt | |
1663 | @item -x @var{language} | |
1664 | Specify explicitly the @var{language} for the following input files | |
1665 | (rather than letting the compiler choose a default based on the file | |
1666 | name suffix). This option applies to all following input files until | |
1667 | the next @option{-x} option. Possible values for @var{language} are: | |
1668 | @smallexample | |
1669 | c c-header cpp-output | |
1670 | c++ c++-header c++-system-header c++-user-header c++-cpp-output | |
1671 | objective-c objective-c-header objective-c-cpp-output | |
1672 | objective-c++ objective-c++-header objective-c++-cpp-output | |
1673 | assembler assembler-with-cpp | |
1674 | ada | |
1675 | d | |
1676 | f77 f77-cpp-input f95 f95-cpp-input | |
1677 | go | |
1678 | @end smallexample | |
1679 | ||
1680 | @item -x none | |
1681 | Turn off any specification of a language, so that subsequent files are | |
1682 | handled according to their file name suffixes (as they are if @option{-x} | |
1683 | has not been used at all). | |
1684 | @end table | |
1685 | ||
1686 | If you only want some of the stages of compilation, you can use | |
1687 | @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and | |
1688 | one of the options @option{-c}, @option{-S}, or @option{-E} to say where | |
1689 | @command{gcc} is to stop. Note that some combinations (for example, | |
1690 | @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all. | |
1691 | ||
1692 | @table @gcctabopt | |
d77de738 | 1693 | @opindex c |
ddf6fe37 | 1694 | @item -c |
d77de738 ML |
1695 | Compile or assemble the source files, but do not link. The linking |
1696 | stage simply is not done. The ultimate output is in the form of an | |
1697 | object file for each source file. | |
1698 | ||
1699 | By default, the object file name for a source file is made by replacing | |
1700 | the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}. | |
1701 | ||
1702 | Unrecognized input files, not requiring compilation or assembly, are | |
1703 | ignored. | |
1704 | ||
d77de738 | 1705 | @opindex S |
ddf6fe37 | 1706 | @item -S |
d77de738 ML |
1707 | Stop after the stage of compilation proper; do not assemble. The output |
1708 | is in the form of an assembler code file for each non-assembler input | |
1709 | file specified. | |
1710 | ||
1711 | By default, the assembler file name for a source file is made by | |
1712 | replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}. | |
1713 | ||
1714 | Input files that don't require compilation are ignored. | |
1715 | ||
d77de738 | 1716 | @opindex E |
ddf6fe37 | 1717 | @item -E |
d77de738 ML |
1718 | Stop after the preprocessing stage; do not run the compiler proper. The |
1719 | output is in the form of preprocessed source code, which is sent to the | |
1720 | standard output. | |
1721 | ||
1722 | Input files that don't require preprocessing are ignored. | |
1723 | ||
1724 | @cindex output file option | |
d77de738 | 1725 | @opindex o |
ddf6fe37 | 1726 | @item -o @var{file} |
d77de738 ML |
1727 | Place the primary output in file @var{file}. This applies to whatever |
1728 | sort of output is being produced, whether it be an executable file, an | |
1729 | object file, an assembler file or preprocessed C code. | |
1730 | ||
1731 | If @option{-o} is not specified, the default is to put an executable | |
1732 | file in @file{a.out}, the object file for | |
1733 | @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its | |
1734 | assembler file in @file{@var{source}.s}, a precompiled header file in | |
1735 | @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on | |
1736 | standard output. | |
1737 | ||
1738 | Though @option{-o} names only the primary output, it also affects the | |
1739 | naming of auxiliary and dump outputs. See the examples below. Unless | |
1740 | overridden, both auxiliary outputs and dump outputs are placed in the | |
1741 | same directory as the primary output. In auxiliary outputs, the suffix | |
1742 | of the input file is replaced with that of the auxiliary output file | |
1743 | type; in dump outputs, the suffix of the dump file is appended to the | |
1744 | input file suffix. In compilation commands, the base name of both | |
1745 | auxiliary and dump outputs is that of the primary output; in compile and | |
1746 | link commands, the primary output name, minus the executable suffix, is | |
1747 | combined with the input file name. If both share the same base name, | |
1748 | disregarding the suffix, the result of the combination is that base | |
1749 | name, otherwise, they are concatenated, separated by a dash. | |
1750 | ||
1751 | @smallexample | |
1752 | gcc -c foo.c ... | |
1753 | @end smallexample | |
1754 | ||
1755 | will use @file{foo.o} as the primary output, and place aux outputs and | |
1756 | dumps next to it, e.g., aux file @file{foo.dwo} for | |
1757 | @option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for | |
1758 | @option{-fdump-rtl-final}. | |
1759 | ||
1760 | If a non-linker output file is explicitly specified, aux and dump files | |
1761 | by default take the same base name: | |
1762 | ||
1763 | @smallexample | |
1764 | gcc -c foo.c -o dir/foobar.o ... | |
1765 | @end smallexample | |
1766 | ||
1767 | will name aux outputs @file{dir/foobar.*} and dump outputs | |
1768 | @file{dir/foobar.c.*}. | |
1769 | ||
1770 | A linker output will instead prefix aux and dump outputs: | |
1771 | ||
1772 | @smallexample | |
1773 | gcc foo.c bar.c -o dir/foobar ... | |
1774 | @end smallexample | |
1775 | ||
1776 | will generally name aux outputs @file{dir/foobar-foo.*} and | |
1777 | @file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and | |
1778 | @file{dir/foobar-bar.c.*}. | |
1779 | ||
1780 | The one exception to the above is when the executable shares the base | |
1781 | name with the single input: | |
1782 | ||
1783 | @smallexample | |
1784 | gcc foo.c -o dir/foo ... | |
1785 | @end smallexample | |
1786 | ||
1787 | in which case aux outputs are named @file{dir/foo.*} and dump outputs | |
1788 | named @file{dir/foo.c.*}. | |
1789 | ||
1790 | The location and the names of auxiliary and dump outputs can be adjusted | |
1791 | by the options @option{-dumpbase}, @option{-dumpbase-ext}, | |
1792 | @option{-dumpdir}, @option{-save-temps=cwd}, and | |
1793 | @option{-save-temps=obj}. | |
1794 | ||
1795 | ||
d77de738 | 1796 | @opindex dumpbase |
ddf6fe37 | 1797 | @item -dumpbase @var{dumpbase} |
d77de738 ML |
1798 | This option sets the base name for auxiliary and dump output files. It |
1799 | does not affect the name of the primary output file. Intermediate | |
1800 | outputs, when preserved, are not regarded as primary outputs, but as | |
1801 | auxiliary outputs: | |
1802 | ||
1803 | @smallexample | |
1804 | gcc -save-temps -S foo.c | |
1805 | @end smallexample | |
1806 | ||
1807 | saves the (no longer) temporary preprocessed file in @file{foo.i}, and | |
1808 | then compiles to the (implied) output file @file{foo.s}, whereas: | |
1809 | ||
1810 | @smallexample | |
1811 | gcc -save-temps -dumpbase save-foo -c foo.c | |
1812 | @end smallexample | |
1813 | ||
1814 | preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now | |
1815 | an intermediate, thus auxiliary output), and then assembles to the | |
1816 | (implied) output file @file{foo.o}. | |
1817 | ||
1818 | Absent this option, dump and aux files take their names from the input | |
1819 | file, or from the (non-linker) output file, if one is explicitly | |
1820 | specified: dump output files (e.g. those requested by @option{-fdump-*} | |
1821 | options) with the input name suffix, and aux output files (those | |
1822 | requested by other non-dump options, e.g. @code{-save-temps}, | |
1823 | @code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it. | |
1824 | ||
1825 | Similar suffix differentiation of dump and aux outputs can be attained | |
1826 | for explicitly-given @option{-dumpbase basename.suf} by also specifying | |
1827 | @option{-dumpbase-ext .suf}. | |
1828 | ||
1829 | If @var{dumpbase} is explicitly specified with any directory component, | |
1830 | any @var{dumppfx} specification (e.g. @option{-dumpdir} or | |
1831 | @option{-save-temps=*}) is ignored, and instead of appending to it, | |
1832 | @var{dumpbase} fully overrides it: | |
1833 | ||
1834 | @smallexample | |
1835 | gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \ | |
1836 | -dumpdir pfx- -save-temps=cwd ... | |
1837 | @end smallexample | |
1838 | ||
1839 | creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding | |
1840 | @file{dir/} in @option{-o}, the @file{./} prefix implied by | |
1841 | @option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}. | |
1842 | ||
1843 | When @option{-dumpbase} is specified in a command that compiles multiple | |
1844 | inputs, or that compiles and then links, it may be combined with | |
1845 | @var{dumppfx}, as specified under @option{-dumpdir}. Then, each input | |
1846 | file is compiled using the combined @var{dumppfx}, and default values | |
1847 | for @var{dumpbase} and @var{auxdropsuf} are computed for each input | |
1848 | file: | |
1849 | ||
1850 | @smallexample | |
1851 | gcc foo.c bar.c -c -dumpbase main ... | |
1852 | @end smallexample | |
1853 | ||
1854 | creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids | |
1855 | overwriting the auxiliary and dump outputs by using the @var{dumpbase} | |
1856 | as a prefix, creating auxiliary and dump outputs named @file{main-foo.*} | |
1857 | and @file{main-bar.*}. | |
1858 | ||
1859 | An empty string specified as @var{dumpbase} avoids the influence of the | |
1860 | output basename in the naming of auxiliary and dump outputs during | |
1861 | compilation, computing default values : | |
1862 | ||
1863 | @smallexample | |
1864 | gcc -c foo.c -o dir/foobar.o -dumpbase '' ... | |
1865 | @end smallexample | |
1866 | ||
1867 | will name aux outputs @file{dir/foo.*} and dump outputs | |
1868 | @file{dir/foo.c.*}. Note how their basenames are taken from the input | |
1869 | name, but the directory still defaults to that of the output. | |
1870 | ||
1871 | The empty-string dumpbase does not prevent the use of the output | |
1872 | basename for outputs during linking: | |
1873 | ||
1874 | @smallexample | |
1875 | gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ... | |
1876 | @end smallexample | |
1877 | ||
1878 | The compilation of the source files will name auxiliary outputs | |
1879 | @file{dir/foo.*} and @file{dir/bar.*}, and dump outputs | |
1880 | @file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during | |
1881 | linking will use @file{dir/foobar.} as the prefix for dumps and | |
1882 | auxiliary files. | |
1883 | ||
1884 | ||
d77de738 | 1885 | @opindex dumpbase-ext |
ddf6fe37 | 1886 | @item -dumpbase-ext @var{auxdropsuf} |
d77de738 ML |
1887 | When forming the name of an auxiliary (but not a dump) output file, drop |
1888 | trailing @var{auxdropsuf} from @var{dumpbase} before appending any | |
1889 | suffixes. If not specified, this option defaults to the suffix of a | |
1890 | default @var{dumpbase}, i.e., the suffix of the input file when | |
1891 | @option{-dumpbase} is not present in the command line, or @var{dumpbase} | |
1892 | is combined with @var{dumppfx}. | |
1893 | ||
1894 | @smallexample | |
1895 | gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ... | |
1896 | @end smallexample | |
1897 | ||
1898 | creates @file{dir/foo.o} as the main output, and generates auxiliary | |
1899 | outputs in @file{dir/x-foo.*}, taking the location of the primary | |
1900 | output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump | |
1901 | outputs retain the suffix: @file{dir/x-foo.c.*}. | |
1902 | ||
1903 | This option is disregarded if it does not match the suffix of a | |
1904 | specified @var{dumpbase}, except as an alternative to the executable | |
1905 | suffix when appending the linker output base name to @var{dumppfx}, as | |
1906 | specified below: | |
1907 | ||
1908 | @smallexample | |
1909 | gcc foo.c bar.c -o main.out -dumpbase-ext .out ... | |
1910 | @end smallexample | |
1911 | ||
1912 | creates @file{main.out} as the primary output, and avoids overwriting | |
1913 | the auxiliary and dump outputs by using the executable name minus | |
1914 | @var{auxdropsuf} as a prefix, creating auxiliary outputs named | |
1915 | @file{main-foo.*} and @file{main-bar.*} and dump outputs named | |
1916 | @file{main-foo.c.*} and @file{main-bar.c.*}. | |
1917 | ||
1918 | ||
d77de738 | 1919 | @opindex dumpdir |
ddf6fe37 | 1920 | @item -dumpdir @var{dumppfx} |
d77de738 ML |
1921 | When forming the name of an auxiliary or dump output file, use |
1922 | @var{dumppfx} as a prefix: | |
1923 | ||
1924 | @smallexample | |
1925 | gcc -dumpdir pfx- -c foo.c ... | |
1926 | @end smallexample | |
1927 | ||
1928 | creates @file{foo.o} as the primary output, and auxiliary outputs named | |
1929 | @file{pfx-foo.*}, combining the given @var{dumppfx} with the default | |
1930 | @var{dumpbase} derived from the default primary output, derived in turn | |
1931 | from the input name. Dump outputs also take the input name suffix: | |
1932 | @file{pfx-foo.c.*}. | |
1933 | ||
1934 | If @var{dumppfx} is to be used as a directory name, it must end with a | |
1935 | directory separator: | |
1936 | ||
1937 | @smallexample | |
1938 | gcc -dumpdir dir/ -c foo.c -o obj/bar.o ... | |
1939 | @end smallexample | |
1940 | ||
1941 | creates @file{obj/bar.o} as the primary output, and auxiliary outputs | |
1942 | named @file{dir/bar.*}, combining the given @var{dumppfx} with the | |
1943 | default @var{dumpbase} derived from the primary output name. Dump | |
1944 | outputs also take the input name suffix: @file{dir/bar.c.*}. | |
1945 | ||
1946 | It defaults to the location of the output file, unless the output | |
1947 | file is a special file like @code{/dev/null}. Options | |
1948 | @option{-save-temps=cwd} and @option{-save-temps=obj} override this | |
1949 | default, just like an explicit @option{-dumpdir} option. In case | |
1950 | multiple such options are given, the last one prevails: | |
1951 | ||
1952 | @smallexample | |
1953 | gcc -dumpdir pfx- -c foo.c -save-temps=obj ... | |
1954 | @end smallexample | |
1955 | ||
1956 | outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because | |
1957 | @option{-save-temps=*} overrides the @var{dumppfx} given by the earlier | |
1958 | @option{-dumpdir} option. It does not matter that @option{=obj} is the | |
1959 | default for @option{-save-temps}, nor that the output directory is | |
1960 | implicitly the current directory. Dump outputs are named | |
1961 | @file{foo.c.*}. | |
1962 | ||
1963 | When compiling from multiple input files, if @option{-dumpbase} is | |
1964 | specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash | |
1965 | are appended to (or override, if containing any directory components) an | |
1966 | explicit or defaulted @var{dumppfx}, so that each of the multiple | |
1967 | compilations gets differently-named aux and dump outputs. | |
1968 | ||
1969 | @smallexample | |
1970 | gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ... | |
1971 | @end smallexample | |
1972 | ||
1973 | outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and | |
1974 | @file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}. | |
1975 | Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*} | |
1976 | and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the | |
1977 | single-input compilation: | |
1978 | ||
1979 | @smallexample | |
1980 | gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ... | |
1981 | @end smallexample | |
1982 | ||
1983 | that, applying @option{-dumpbase} to a single source, does not compute | |
1984 | and append a separate @var{dumpbase} per input file. Its auxiliary and | |
1985 | dump outputs go in @file{dir/pfx-main.*}. | |
1986 | ||
1987 | When compiling and then linking from multiple input files, a defaulted | |
1988 | or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}- | |
1989 | transformation above (e.g. the compilation of @file{foo.c} and | |
1990 | @file{bar.c} above, but without @option{-c}). If neither | |
1991 | @option{-dumpdir} nor @option{-dumpbase} are given, the linker output | |
1992 | base name, minus @var{auxdropsuf}, if specified, or the executable | |
1993 | suffix otherwise, plus a dash is appended to the default @var{dumppfx} | |
1994 | instead. Note, however, that unlike earlier cases of linking: | |
1995 | ||
1996 | @smallexample | |
1997 | gcc foo.c bar.c -dumpdir dir/pfx- -o main ... | |
1998 | @end smallexample | |
1999 | ||
2000 | does not append the output name @file{main} to @var{dumppfx}, because | |
2001 | @option{-dumpdir} is explicitly specified. The goal is that the | |
2002 | explicitly-specified @var{dumppfx} may contain the specified output name | |
2003 | as part of the prefix, if desired; only an explicitly-specified | |
2004 | @option{-dumpbase} would be combined with it, in order to avoid simply | |
2005 | discarding a meaningful option. | |
2006 | ||
2007 | When compiling and then linking from a single input file, the linker | |
2008 | output base name will only be appended to the default @var{dumppfx} as | |
2009 | above if it does not share the base name with the single input file | |
2010 | name. This has been covered in single-input linking cases above, but | |
2011 | not with an explicit @option{-dumpdir} that inhibits the combination, | |
2012 | even if overridden by @option{-save-temps=*}: | |
2013 | ||
2014 | @smallexample | |
2015 | gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ... | |
2016 | @end smallexample | |
2017 | ||
2018 | Auxiliary outputs are named @file{foo.*}, and dump outputs | |
2019 | @file{foo.c.*}, in the current working directory as ultimately requested | |
2020 | by @option{-save-temps=cwd}. | |
2021 | ||
2022 | Summing it all up for an intuitive though slightly imprecise data flow: | |
2023 | the primary output name is broken into a directory part and a basename | |
2024 | part; @var{dumppfx} is set to the former, unless overridden by | |
2025 | @option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set | |
2026 | to the latter, unless overriden by @option{-dumpbase}. If there are | |
2027 | multiple inputs or linking, this @var{dumpbase} may be combined with | |
2028 | @var{dumppfx} and taken from each input file. Auxiliary output names | |
2029 | for each input are formed by combining @var{dumppfx}, @var{dumpbase} | |
2030 | minus suffix, and the auxiliary output suffix; dump output names are | |
2031 | only different in that the suffix from @var{dumpbase} is retained. | |
2032 | ||
2033 | When it comes to auxiliary and dump outputs created during LTO | |
2034 | recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as | |
2035 | given or as derived from the linker output name but not from inputs, | |
2036 | even in cases in which this combination would not otherwise be used as | |
2037 | such, is passed down with a trailing period replacing the compiler-added | |
2038 | dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper}; | |
2039 | being involved in linking, this program does not normally get any | |
2040 | @option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them. | |
2041 | ||
2042 | When running sub-compilers, @command{lto-wrapper} appends LTO stage | |
2043 | names to the received @var{dumppfx}, ensures it contains a directory | |
2044 | component so that it overrides any @option{-dumpdir}, and passes that as | |
2045 | @option{-dumpbase} to sub-compilers. | |
2046 | ||
d77de738 | 2047 | @opindex v |
ddf6fe37 | 2048 | @item -v |
d77de738 ML |
2049 | Print (on standard error output) the commands executed to run the stages |
2050 | of compilation. Also print the version number of the compiler driver | |
2051 | program and of the preprocessor and the compiler proper. | |
2052 | ||
d77de738 | 2053 | @opindex ### |
ddf6fe37 | 2054 | @item -### |
d77de738 ML |
2055 | Like @option{-v} except the commands are not executed and arguments |
2056 | are quoted unless they contain only alphanumeric characters or @code{./-_}. | |
2057 | This is useful for shell scripts to capture the driver-generated command lines. | |
2058 | ||
d77de738 | 2059 | @opindex help |
ddf6fe37 | 2060 | @item --help |
d77de738 ML |
2061 | Print (on the standard output) a description of the command-line options |
2062 | understood by @command{gcc}. If the @option{-v} option is also specified | |
2063 | then @option{--help} is also passed on to the various processes | |
2064 | invoked by @command{gcc}, so that they can display the command-line options | |
2065 | they accept. If the @option{-Wextra} option has also been specified | |
2066 | (prior to the @option{--help} option), then command-line options that | |
2067 | have no documentation associated with them are also displayed. | |
2068 | ||
d77de738 | 2069 | @opindex target-help |
ddf6fe37 | 2070 | @item --target-help |
d77de738 ML |
2071 | Print (on the standard output) a description of target-specific command-line |
2072 | options for each tool. For some targets extra target-specific | |
2073 | information may also be printed. | |
2074 | ||
2075 | @item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]} | |
2076 | Print (on the standard output) a description of the command-line | |
2077 | options understood by the compiler that fit into all specified classes | |
2078 | and qualifiers. These are the supported classes: | |
2079 | ||
2080 | @table @asis | |
2081 | @item @samp{optimizers} | |
2082 | Display all of the optimization options supported by the | |
2083 | compiler. | |
2084 | ||
2085 | @item @samp{warnings} | |
2086 | Display all of the options controlling warning messages | |
2087 | produced by the compiler. | |
2088 | ||
2089 | @item @samp{target} | |
2090 | Display target-specific options. Unlike the | |
2091 | @option{--target-help} option however, target-specific options of the | |
2092 | linker and assembler are not displayed. This is because those | |
2093 | tools do not currently support the extended @option{--help=} syntax. | |
2094 | ||
2095 | @item @samp{params} | |
2096 | Display the values recognized by the @option{--param} | |
2097 | option. | |
2098 | ||
2099 | @item @var{language} | |
2100 | Display the options supported for @var{language}, where | |
2101 | @var{language} is the name of one of the languages supported in this | |
2102 | version of GCC@. If an option is supported by all languages, one needs | |
2103 | to select @samp{common} class. | |
2104 | ||
2105 | @item @samp{common} | |
2106 | Display the options that are common to all languages. | |
2107 | @end table | |
2108 | ||
2109 | These are the supported qualifiers: | |
2110 | ||
2111 | @table @asis | |
2112 | @item @samp{undocumented} | |
2113 | Display only those options that are undocumented. | |
2114 | ||
2115 | @item @samp{joined} | |
2116 | Display options taking an argument that appears after an equal | |
2117 | sign in the same continuous piece of text, such as: | |
2118 | @samp{--help=target}. | |
2119 | ||
2120 | @item @samp{separate} | |
2121 | Display options taking an argument that appears as a separate word | |
2122 | following the original option, such as: @samp{-o output-file}. | |
2123 | @end table | |
2124 | ||
2125 | Thus for example to display all the undocumented target-specific | |
2126 | switches supported by the compiler, use: | |
2127 | ||
2128 | @smallexample | |
2129 | --help=target,undocumented | |
2130 | @end smallexample | |
2131 | ||
2132 | The sense of a qualifier can be inverted by prefixing it with the | |
2133 | @samp{^} character, so for example to display all binary warning | |
2134 | options (i.e., ones that are either on or off and that do not take an | |
2135 | argument) that have a description, use: | |
2136 | ||
2137 | @smallexample | |
2138 | --help=warnings,^joined,^undocumented | |
2139 | @end smallexample | |
2140 | ||
2141 | The argument to @option{--help=} should not consist solely of inverted | |
2142 | qualifiers. | |
2143 | ||
2144 | Combining several classes is possible, although this usually | |
2145 | restricts the output so much that there is nothing to display. One | |
2146 | case where it does work, however, is when one of the classes is | |
2147 | @var{target}. For example, to display all the target-specific | |
2148 | optimization options, use: | |
2149 | ||
2150 | @smallexample | |
2151 | --help=target,optimizers | |
2152 | @end smallexample | |
2153 | ||
2154 | The @option{--help=} option can be repeated on the command line. Each | |
2155 | successive use displays its requested class of options, skipping | |
2156 | those that have already been displayed. If @option{--help} is also | |
2157 | specified anywhere on the command line then this takes precedence | |
2158 | over any @option{--help=} option. | |
2159 | ||
2160 | If the @option{-Q} option appears on the command line before the | |
2161 | @option{--help=} option, then the descriptive text displayed by | |
2162 | @option{--help=} is changed. Instead of describing the displayed | |
2163 | options, an indication is given as to whether the option is enabled, | |
2164 | disabled or set to a specific value (assuming that the compiler | |
2165 | knows this at the point where the @option{--help=} option is used). | |
2166 | ||
2167 | Here is a truncated example from the ARM port of @command{gcc}: | |
2168 | ||
2169 | @smallexample | |
2170 | % gcc -Q -mabi=2 --help=target -c | |
2171 | The following options are target specific: | |
2172 | -mabi= 2 | |
2173 | -mabort-on-noreturn [disabled] | |
2174 | -mapcs [disabled] | |
2175 | @end smallexample | |
2176 | ||
2177 | The output is sensitive to the effects of previous command-line | |
2178 | options, so for example it is possible to find out which optimizations | |
2179 | are enabled at @option{-O2} by using: | |
2180 | ||
2181 | @smallexample | |
2182 | -Q -O2 --help=optimizers | |
2183 | @end smallexample | |
2184 | ||
2185 | Alternatively you can discover which binary optimizations are enabled | |
2186 | by @option{-O3} by using: | |
2187 | ||
2188 | @smallexample | |
2189 | gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts | |
2190 | gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts | |
2191 | diff /tmp/O2-opts /tmp/O3-opts | grep enabled | |
2192 | @end smallexample | |
2193 | ||
d77de738 | 2194 | @opindex version |
ddf6fe37 | 2195 | @item --version |
d77de738 ML |
2196 | Display the version number and copyrights of the invoked GCC@. |
2197 | ||
d77de738 | 2198 | @opindex pass-exit-codes |
ddf6fe37 | 2199 | @item -pass-exit-codes |
d77de738 ML |
2200 | Normally the @command{gcc} program exits with the code of 1 if any |
2201 | phase of the compiler returns a non-success return code. If you specify | |
2202 | @option{-pass-exit-codes}, the @command{gcc} program instead returns with | |
2203 | the numerically highest error produced by any phase returning an error | |
2204 | indication. The C, C++, and Fortran front ends return 4 if an internal | |
2205 | compiler error is encountered. | |
2206 | ||
d77de738 | 2207 | @opindex pipe |
ddf6fe37 | 2208 | @item -pipe |
d77de738 ML |
2209 | Use pipes rather than temporary files for communication between the |
2210 | various stages of compilation. This fails to work on some systems where | |
2211 | the assembler is unable to read from a pipe; but the GNU assembler has | |
2212 | no trouble. | |
2213 | ||
d77de738 | 2214 | @opindex specs |
ddf6fe37 | 2215 | @item -specs=@var{file} |
d77de738 ML |
2216 | Process @var{file} after the compiler reads in the standard @file{specs} |
2217 | file, in order to override the defaults which the @command{gcc} driver | |
2218 | program uses when determining what switches to pass to @command{cc1}, | |
2219 | @command{cc1plus}, @command{as}, @command{ld}, etc. More than one | |
2220 | @option{-specs=@var{file}} can be specified on the command line, and they | |
2221 | are processed in order, from left to right. @xref{Spec Files}, for | |
2222 | information about the format of the @var{file}. | |
2223 | ||
d77de738 | 2224 | @opindex wrapper |
ddf6fe37 | 2225 | @item -wrapper |
d77de738 ML |
2226 | Invoke all subcommands under a wrapper program. The name of the |
2227 | wrapper program and its parameters are passed as a comma separated | |
2228 | list. | |
2229 | ||
2230 | @smallexample | |
2231 | gcc -c t.c -wrapper gdb,--args | |
2232 | @end smallexample | |
2233 | ||
2234 | @noindent | |
2235 | This invokes all subprograms of @command{gcc} under | |
2236 | @samp{gdb --args}, thus the invocation of @command{cc1} is | |
2237 | @samp{gdb --args cc1 @dots{}}. | |
2238 | ||
d77de738 | 2239 | @opindex ffile-prefix-map |
ddf6fe37 | 2240 | @item -ffile-prefix-map=@var{old}=@var{new} |
d77de738 ML |
2241 | When compiling files residing in directory @file{@var{old}}, record |
2242 | any references to them in the result of the compilation as if the | |
2243 | files resided in directory @file{@var{new}} instead. Specifying this | |
2244 | option is equivalent to specifying all the individual | |
2245 | @option{-f*-prefix-map} options. This can be used to make reproducible | |
11543b27 | 2246 | builds that are location independent. Directories referenced by |
2eb0191a JJ |
2247 | directives are not affected by these options. See also |
2248 | @option{-fmacro-prefix-map}, @option{-fdebug-prefix-map}, | |
2249 | @option{-fprofile-prefix-map} and @option{-fcanon-prefix-map}. | |
2250 | ||
2eb0191a | 2251 | @opindex fcanon-prefix-map |
e54b01a1 | 2252 | @item -fcanon-prefix-map |
2eb0191a JJ |
2253 | For the @option{-f*-prefix-map} options normally comparison |
2254 | of @file{@var{old}} prefix against the filename that would be normally | |
2255 | referenced in the result of the compilation is done using textual | |
2256 | comparison of the prefixes, or ignoring character case for case insensitive | |
2257 | filesystems and considering slashes and backslashes as equal on DOS based | |
2258 | filesystems. The @option{-fcanon-prefix-map} causes such comparisons | |
2259 | to be done on canonicalized paths of @file{@var{old}} | |
2260 | and the referenced filename. | |
d77de738 | 2261 | |
d77de738 | 2262 | @opindex fplugin |
ddf6fe37 | 2263 | @item -fplugin=@var{name}.so |
d77de738 ML |
2264 | Load the plugin code in file @var{name}.so, assumed to be a |
2265 | shared object to be dlopen'd by the compiler. The base name of | |
2266 | the shared object file is used to identify the plugin for the | |
2267 | purposes of argument parsing (See | |
2268 | @option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below). | |
2269 | Each plugin should define the callback functions specified in the | |
2270 | Plugins API. | |
2271 | ||
d77de738 | 2272 | @opindex fplugin-arg |
ddf6fe37 | 2273 | @item -fplugin-arg-@var{name}-@var{key}=@var{value} |
d77de738 ML |
2274 | Define an argument called @var{key} with a value of @var{value} |
2275 | for the plugin called @var{name}. | |
2276 | ||
d77de738 | 2277 | @opindex fdump-ada-spec |
ddf6fe37 | 2278 | @item -fdump-ada-spec@r{[}-slim@r{]} |
d77de738 ML |
2279 | For C and C++ source and include files, generate corresponding Ada specs. |
2280 | @xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn, | |
2281 | GNAT User's Guide}, which provides detailed documentation on this feature. | |
2282 | ||
d77de738 | 2283 | @opindex fada-spec-parent |
ddf6fe37 | 2284 | @item -fada-spec-parent=@var{unit} |
d77de738 ML |
2285 | In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate |
2286 | Ada specs as child units of parent @var{unit}. | |
2287 | ||
d77de738 | 2288 | @opindex fdump-go-spec |
ddf6fe37 | 2289 | @item -fdump-go-spec=@var{file} |
d77de738 ML |
2290 | For input files in any language, generate corresponding Go |
2291 | declarations in @var{file}. This generates Go @code{const}, | |
2292 | @code{type}, @code{var}, and @code{func} declarations which may be a | |
2293 | useful way to start writing a Go interface to code written in some | |
2294 | other language. | |
2295 | ||
2296 | @include @value{srcdir}/../libiberty/at-file.texi | |
2297 | @end table | |
2298 | ||
2299 | @node Invoking G++ | |
2300 | @section Compiling C++ Programs | |
2301 | ||
2302 | @cindex suffixes for C++ source | |
2303 | @cindex C++ source file suffixes | |
2304 | C++ source files conventionally use one of the suffixes @samp{.C}, | |
2305 | @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or | |
2306 | @samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp}, | |
2307 | @samp{.H}, or (for shared template code) @samp{.tcc}; and | |
2308 | preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes | |
2309 | files with these names and compiles them as C++ programs even if you | |
2310 | call the compiler the same way as for compiling C programs (usually | |
2311 | with the name @command{gcc}). | |
2312 | ||
2313 | @findex g++ | |
2314 | @findex c++ | |
2315 | However, the use of @command{gcc} does not add the C++ library. | |
2316 | @command{g++} is a program that calls GCC and automatically specifies linking | |
2317 | against the C++ library. It treats @samp{.c}, | |
2318 | @samp{.h} and @samp{.i} files as C++ source files instead of C source | |
2319 | files unless @option{-x} is used. This program is also useful when | |
2320 | precompiling a C header file with a @samp{.h} extension for use in C++ | |
2321 | compilations. On many systems, @command{g++} is also installed with | |
2322 | the name @command{c++}. | |
2323 | ||
2324 | @cindex invoking @command{g++} | |
2325 | When you compile C++ programs, you may specify many of the same | |
2326 | command-line options that you use for compiling programs in any | |
2327 | language; or command-line options meaningful for C and related | |
2328 | languages; or options that are meaningful only for C++ programs. | |
2329 | @xref{C Dialect Options,,Options Controlling C Dialect}, for | |
2330 | explanations of options for languages related to C@. | |
2331 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for | |
2332 | explanations of options that are meaningful only for C++ programs. | |
2333 | ||
2334 | @node C Dialect Options | |
2335 | @section Options Controlling C Dialect | |
2336 | @cindex dialect options | |
2337 | @cindex language dialect options | |
2338 | @cindex options, dialect | |
2339 | ||
2340 | The following options control the dialect of C (or languages derived | |
2341 | from C, such as C++, Objective-C and Objective-C++) that the compiler | |
2342 | accepts: | |
2343 | ||
2344 | @table @gcctabopt | |
2345 | @cindex ANSI support | |
2346 | @cindex ISO support | |
d77de738 | 2347 | @opindex ansi |
ddf6fe37 | 2348 | @item -ansi |
d77de738 ML |
2349 | In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is |
2350 | equivalent to @option{-std=c++98}. | |
2351 | ||
2352 | This turns off certain features of GCC that are incompatible with ISO | |
2353 | C90 (when compiling C code), or of standard C++ (when compiling C++ code), | |
2354 | such as the @code{asm} and @code{typeof} keywords, and | |
2355 | predefined macros such as @code{unix} and @code{vax} that identify the | |
2356 | type of system you are using. It also enables the undesirable and | |
2357 | rarely used ISO trigraph feature. For the C compiler, | |
2358 | it disables recognition of C++ style @samp{//} comments as well as | |
2359 | the @code{inline} keyword. | |
2360 | ||
2361 | The alternate keywords @code{__asm__}, @code{__extension__}, | |
2362 | @code{__inline__} and @code{__typeof__} continue to work despite | |
2363 | @option{-ansi}. You would not want to use them in an ISO C program, of | |
2364 | course, but it is useful to put them in header files that might be included | |
2365 | in compilations done with @option{-ansi}. Alternate predefined macros | |
2366 | such as @code{__unix__} and @code{__vax__} are also available, with or | |
2367 | without @option{-ansi}. | |
2368 | ||
2369 | The @option{-ansi} option does not cause non-ISO programs to be | |
2370 | rejected gratuitously. For that, @option{-Wpedantic} is required in | |
2371 | addition to @option{-ansi}. @xref{Warning Options}. | |
2372 | ||
2373 | The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi} | |
2374 | option is used. Some header files may notice this macro and refrain | |
2375 | from declaring certain functions or defining certain macros that the | |
2376 | ISO standard doesn't call for; this is to avoid interfering with any | |
2377 | programs that might use these names for other things. | |
2378 | ||
2379 | Functions that are normally built in but do not have semantics | |
2380 | defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in | |
2381 | functions when @option{-ansi} is used. @xref{Other Builtins,,Other | |
2382 | built-in functions provided by GCC}, for details of the functions | |
2383 | affected. | |
2384 | ||
d77de738 | 2385 | @opindex std |
ddf6fe37 | 2386 | @item -std= |
d77de738 ML |
2387 | Determine the language standard. @xref{Standards,,Language Standards |
2388 | Supported by GCC}, for details of these standard versions. This option | |
2389 | is currently only supported when compiling C or C++. | |
2390 | ||
2391 | The compiler can accept several base standards, such as @samp{c90} or | |
2392 | @samp{c++98}, and GNU dialects of those standards, such as | |
2393 | @samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the | |
2394 | compiler accepts all programs following that standard plus those | |
2395 | using GNU extensions that do not contradict it. For example, | |
2396 | @option{-std=c90} turns off certain features of GCC that are | |
2397 | incompatible with ISO C90, such as the @code{asm} and @code{typeof} | |
2398 | keywords, but not other GNU extensions that do not have a meaning in | |
2399 | ISO C90, such as omitting the middle term of a @code{?:} | |
2400 | expression. On the other hand, when a GNU dialect of a standard is | |
2401 | specified, all features supported by the compiler are enabled, even when | |
2402 | those features change the meaning of the base standard. As a result, some | |
2403 | strict-conforming programs may be rejected. The particular standard | |
2404 | is used by @option{-Wpedantic} to identify which features are GNU | |
2405 | extensions given that version of the standard. For example | |
2406 | @option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//} | |
2407 | comments, while @option{-std=gnu99 -Wpedantic} does not. | |
2408 | ||
2409 | A value for this option must be provided; possible values are | |
2410 | ||
2411 | @table @samp | |
2412 | @item c90 | |
2413 | @itemx c89 | |
2414 | @itemx iso9899:1990 | |
2415 | Support all ISO C90 programs (certain GNU extensions that conflict | |
2416 | with ISO C90 are disabled). Same as @option{-ansi} for C code. | |
2417 | ||
2418 | @item iso9899:199409 | |
2419 | ISO C90 as modified in amendment 1. | |
2420 | ||
2421 | @item c99 | |
2422 | @itemx c9x | |
2423 | @itemx iso9899:1999 | |
2424 | @itemx iso9899:199x | |
2425 | ISO C99. This standard is substantially completely supported, modulo | |
2426 | bugs and floating-point issues | |
2427 | (mainly but not entirely relating to optional C99 features from | |
2428 | Annexes F and G). See | |
2429 | @w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The | |
2430 | names @samp{c9x} and @samp{iso9899:199x} are deprecated. | |
2431 | ||
2432 | @item c11 | |
2433 | @itemx c1x | |
2434 | @itemx iso9899:2011 | |
2435 | ISO C11, the 2011 revision of the ISO C standard. This standard is | |
2436 | substantially completely supported, modulo bugs, floating-point issues | |
2437 | (mainly but not entirely relating to optional C11 features from | |
2438 | Annexes F and G) and the optional Annexes K (Bounds-checking | |
2439 | interfaces) and L (Analyzability). The name @samp{c1x} is deprecated. | |
2440 | ||
2441 | @item c17 | |
2442 | @itemx c18 | |
2443 | @itemx iso9899:2017 | |
2444 | @itemx iso9899:2018 | |
2445 | ISO C17, the 2017 revision of the ISO C standard | |
2446 | (published in 2018). This standard is | |
2447 | same as C11 except for corrections of defects (all of which are also | |
2448 | applied with @option{-std=c11}) and a new value of | |
2449 | @code{__STDC_VERSION__}, and so is supported to the same extent as C11. | |
2450 | ||
fad61bf7 JM |
2451 | @item c23 |
2452 | @itemx c2x | |
2453 | @itemx iso9899:2024 | |
2454 | ISO C23, the 2023 revision of the ISO C standard (expected to be | |
2455 | published in 2024). The support for this version is experimental and | |
2456 | incomplete. The name @samp{c2x} is deprecated. | |
d77de738 ML |
2457 | |
2458 | @item gnu90 | |
2459 | @itemx gnu89 | |
2460 | GNU dialect of ISO C90 (including some C99 features). | |
2461 | ||
2462 | @item gnu99 | |
2463 | @itemx gnu9x | |
2464 | GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated. | |
2465 | ||
2466 | @item gnu11 | |
2467 | @itemx gnu1x | |
2468 | GNU dialect of ISO C11. | |
2469 | The name @samp{gnu1x} is deprecated. | |
2470 | ||
2471 | @item gnu17 | |
2472 | @itemx gnu18 | |
2473 | GNU dialect of ISO C17. This is the default for C code. | |
2474 | ||
fad61bf7 JM |
2475 | @item gnu23 |
2476 | @itemx gnu2x | |
d77de738 ML |
2477 | The next version of the ISO C standard, still under development, plus |
2478 | GNU extensions. The support for this version is experimental and | |
fad61bf7 | 2479 | incomplete. The name @samp{gnu2x} is deprecated. |
d77de738 ML |
2480 | |
2481 | @item c++98 | |
2482 | @itemx c++03 | |
2483 | The 1998 ISO C++ standard plus the 2003 technical corrigendum and some | |
2484 | additional defect reports. Same as @option{-ansi} for C++ code. | |
2485 | ||
2486 | @item gnu++98 | |
2487 | @itemx gnu++03 | |
2488 | GNU dialect of @option{-std=c++98}. | |
2489 | ||
2490 | @item c++11 | |
2491 | @itemx c++0x | |
2492 | The 2011 ISO C++ standard plus amendments. | |
2493 | The name @samp{c++0x} is deprecated. | |
2494 | ||
2495 | @item gnu++11 | |
2496 | @itemx gnu++0x | |
2497 | GNU dialect of @option{-std=c++11}. | |
2498 | The name @samp{gnu++0x} is deprecated. | |
2499 | ||
2500 | @item c++14 | |
2501 | @itemx c++1y | |
2502 | The 2014 ISO C++ standard plus amendments. | |
2503 | The name @samp{c++1y} is deprecated. | |
2504 | ||
2505 | @item gnu++14 | |
2506 | @itemx gnu++1y | |
2507 | GNU dialect of @option{-std=c++14}. | |
2508 | The name @samp{gnu++1y} is deprecated. | |
2509 | ||
2510 | @item c++17 | |
2511 | @itemx c++1z | |
2512 | The 2017 ISO C++ standard plus amendments. | |
2513 | The name @samp{c++1z} is deprecated. | |
2514 | ||
2515 | @item gnu++17 | |
2516 | @itemx gnu++1z | |
2517 | GNU dialect of @option{-std=c++17}. | |
2518 | This is the default for C++ code. | |
2519 | The name @samp{gnu++1z} is deprecated. | |
2520 | ||
2521 | @item c++20 | |
2522 | @itemx c++2a | |
2523 | The 2020 ISO C++ standard plus amendments. | |
2524 | Support is experimental, and could change in incompatible ways in | |
2525 | future releases. | |
2526 | The name @samp{c++2a} is deprecated. | |
2527 | ||
2528 | @item gnu++20 | |
2529 | @itemx gnu++2a | |
2530 | GNU dialect of @option{-std=c++20}. | |
2531 | Support is experimental, and could change in incompatible ways in | |
2532 | future releases. | |
2533 | The name @samp{gnu++2a} is deprecated. | |
2534 | ||
2535 | @item c++2b | |
2536 | @itemx c++23 | |
2537 | The next revision of the ISO C++ standard, planned for | |
2538 | 2023. Support is highly experimental, and will almost certainly | |
2539 | change in incompatible ways in future releases. | |
2540 | ||
2541 | @item gnu++2b | |
2542 | @itemx gnu++23 | |
2543 | GNU dialect of @option{-std=c++2b}. Support is highly experimental, | |
2544 | and will almost certainly change in incompatible ways in future | |
2545 | releases. | |
5388a43f MP |
2546 | |
2547 | @item c++2c | |
2548 | @itemx c++26 | |
2549 | The next revision of the ISO C++ standard, planned for | |
2550 | 2026. Support is highly experimental, and will almost certainly | |
2551 | change in incompatible ways in future releases. | |
2552 | ||
2553 | @item gnu++2c | |
2554 | @itemx gnu++26 | |
2555 | GNU dialect of @option{-std=c++2c}. Support is highly experimental, | |
2556 | and will almost certainly change in incompatible ways in future | |
2557 | releases. | |
d77de738 ML |
2558 | @end table |
2559 | ||
d77de738 | 2560 | @opindex aux-info |
ddf6fe37 | 2561 | @item -aux-info @var{filename} |
d77de738 ML |
2562 | Output to the given filename prototyped declarations for all functions |
2563 | declared and/or defined in a translation unit, including those in header | |
2564 | files. This option is silently ignored in any language other than C@. | |
2565 | ||
2566 | Besides declarations, the file indicates, in comments, the origin of | |
2567 | each declaration (source file and line), whether the declaration was | |
2568 | implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or | |
2569 | @samp{O} for old, respectively, in the first character after the line | |
2570 | number and the colon), and whether it came from a declaration or a | |
2571 | definition (@samp{C} or @samp{F}, respectively, in the following | |
2572 | character). In the case of function definitions, a K&R-style list of | |
2573 | arguments followed by their declarations is also provided, inside | |
2574 | comments, after the declaration. | |
2575 | ||
d77de738 ML |
2576 | @opindex fno-asm |
2577 | @opindex fasm | |
ddf6fe37 | 2578 | @item -fno-asm |
d77de738 ML |
2579 | Do not recognize @code{asm}, @code{inline} or @code{typeof} as a |
2580 | keyword, so that code can use these words as identifiers. You can use | |
2581 | the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__} | |
2582 | instead. In C, @option{-ansi} implies @option{-fno-asm}. | |
2583 | ||
2584 | In C++, @code{inline} is a standard keyword and is not affected by | |
2585 | this switch. You may want to use the @option{-fno-gnu-keywords} flag | |
2586 | instead, which disables @code{typeof} but not @code{asm} and | |
2587 | @code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), | |
2588 | this switch only affects the @code{asm} and @code{typeof} keywords, | |
fad61bf7 JM |
2589 | since @code{inline} is a standard keyword in ISO C99. In C23 mode |
2590 | (@option{-std=c23} or @option{-std=gnu23}), this switch only affects | |
d77de738 | 2591 | the @code{asm} keyword, since @code{typeof} is a standard keyword in |
fad61bf7 | 2592 | ISO C23. |
d77de738 | 2593 | |
d77de738 ML |
2594 | @opindex fno-builtin |
2595 | @opindex fbuiltin | |
f33d7a88 | 2596 | @cindex built-in functions |
ddf6fe37 AA |
2597 | @item -fno-builtin |
2598 | @itemx -fno-builtin-@var{function} | |
d77de738 ML |
2599 | Don't recognize built-in functions that do not begin with |
2600 | @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in | |
2601 | functions provided by GCC}, for details of the functions affected, | |
2602 | including those which are not built-in functions when @option{-ansi} or | |
2603 | @option{-std} options for strict ISO C conformance are used because they | |
2604 | do not have an ISO standard meaning. | |
2605 | ||
2606 | GCC normally generates special code to handle certain built-in functions | |
2607 | more efficiently; for instance, calls to @code{alloca} may become single | |
2608 | instructions which adjust the stack directly, and calls to @code{memcpy} | |
2609 | may become inline copy loops. The resulting code is often both smaller | |
2610 | and faster, but since the function calls no longer appear as such, you | |
2611 | cannot set a breakpoint on those calls, nor can you change the behavior | |
2612 | of the functions by linking with a different library. In addition, | |
2613 | when a function is recognized as a built-in function, GCC may use | |
2614 | information about that function to warn about problems with calls to | |
2615 | that function, or to generate more efficient code, even if the | |
2616 | resulting code still contains calls to that function. For example, | |
2617 | warnings are given with @option{-Wformat} for bad calls to | |
2618 | @code{printf} when @code{printf} is built in and @code{strlen} is | |
2619 | known not to modify global memory. | |
2620 | ||
2621 | With the @option{-fno-builtin-@var{function}} option | |
2622 | only the built-in function @var{function} is | |
2623 | disabled. @var{function} must not begin with @samp{__builtin_}. If a | |
2624 | function is named that is not built-in in this version of GCC, this | |
2625 | option is ignored. There is no corresponding | |
2626 | @option{-fbuiltin-@var{function}} option; if you wish to enable | |
2627 | built-in functions selectively when using @option{-fno-builtin} or | |
2628 | @option{-ffreestanding}, you may define macros such as: | |
2629 | ||
2630 | @smallexample | |
2631 | #define abs(n) __builtin_abs ((n)) | |
2632 | #define strcpy(d, s) __builtin_strcpy ((d), (s)) | |
2633 | @end smallexample | |
2634 | ||
d77de738 | 2635 | @opindex fcond-mismatch |
ddf6fe37 | 2636 | @item -fcond-mismatch |
d77de738 ML |
2637 | Allow conditional expressions with mismatched types in the second and |
2638 | third arguments. The value of such an expression is void. This option | |
2639 | is not supported for C++. | |
2640 | ||
d77de738 ML |
2641 | @opindex ffreestanding |
2642 | @cindex hosted environment | |
f33d7a88 | 2643 | @item -ffreestanding |
d77de738 ML |
2644 | |
2645 | Assert that compilation targets a freestanding environment. This | |
2646 | implies @option{-fno-builtin}. A freestanding environment | |
2647 | is one in which the standard library may not exist, and program startup may | |
2648 | not necessarily be at @code{main}. The most obvious example is an OS kernel. | |
2649 | This is equivalent to @option{-fno-hosted}. | |
2650 | ||
2651 | @xref{Standards,,Language Standards Supported by GCC}, for details of | |
2652 | freestanding and hosted environments. | |
2653 | ||
d77de738 | 2654 | @opindex fgimple |
ddf6fe37 | 2655 | @item -fgimple |
d77de738 ML |
2656 | |
2657 | Enable parsing of function definitions marked with @code{__GIMPLE}. | |
2658 | This is an experimental feature that allows unit testing of GIMPLE | |
2659 | passes. | |
2660 | ||
d77de738 | 2661 | @opindex fgnu-tm |
ddf6fe37 | 2662 | @item -fgnu-tm |
d77de738 ML |
2663 | When the option @option{-fgnu-tm} is specified, the compiler |
2664 | generates code for the Linux variant of Intel's current Transactional | |
2665 | Memory ABI specification document (Revision 1.1, May 6 2009). This is | |
2666 | an experimental feature whose interface may change in future versions | |
2667 | of GCC, as the official specification changes. Please note that not | |
2668 | all architectures are supported for this feature. | |
2669 | ||
2670 | For more information on GCC's support for transactional memory, | |
2671 | @xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU | |
2672 | Transactional Memory Library}. | |
2673 | ||
2674 | Note that the transactional memory feature is not supported with | |
2675 | non-call exceptions (@option{-fnon-call-exceptions}). | |
2676 | ||
d77de738 | 2677 | @opindex fgnu89-inline |
ddf6fe37 | 2678 | @item -fgnu89-inline |
d77de738 ML |
2679 | The option @option{-fgnu89-inline} tells GCC to use the traditional |
2680 | GNU semantics for @code{inline} functions when in C99 mode. | |
2681 | @xref{Inline,,An Inline Function is As Fast As a Macro}. | |
2682 | Using this option is roughly equivalent to adding the | |
2683 | @code{gnu_inline} function attribute to all inline functions | |
2684 | (@pxref{Function Attributes}). | |
2685 | ||
2686 | The option @option{-fno-gnu89-inline} explicitly tells GCC to use the | |
2687 | C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it | |
2688 | specifies the default behavior). | |
2689 | This option is not supported in @option{-std=c90} or | |
2690 | @option{-std=gnu90} mode. | |
2691 | ||
2692 | The preprocessor macros @code{__GNUC_GNU_INLINE__} and | |
2693 | @code{__GNUC_STDC_INLINE__} may be used to check which semantics are | |
2694 | in effect for @code{inline} functions. @xref{Common Predefined | |
2695 | Macros,,,cpp,The C Preprocessor}. | |
2696 | ||
d77de738 ML |
2697 | @opindex fhosted |
2698 | @cindex hosted environment | |
f33d7a88 | 2699 | @item -fhosted |
d77de738 ML |
2700 | |
2701 | Assert that compilation targets a hosted environment. This implies | |
2702 | @option{-fbuiltin}. A hosted environment is one in which the | |
2703 | entire standard library is available, and in which @code{main} has a return | |
2704 | type of @code{int}. Examples are nearly everything except a kernel. | |
2705 | This is equivalent to @option{-fno-freestanding}. | |
2706 | ||
d77de738 | 2707 | @opindex flax-vector-conversions |
ddf6fe37 | 2708 | @item -flax-vector-conversions |
d77de738 ML |
2709 | Allow implicit conversions between vectors with differing numbers of |
2710 | elements and/or incompatible element types. This option should not be | |
2711 | used for new code. | |
2712 | ||
d77de738 | 2713 | @opindex fms-extensions |
ddf6fe37 | 2714 | @item -fms-extensions |
d77de738 ML |
2715 | Accept some non-standard constructs used in Microsoft header files. |
2716 | ||
2717 | In C++ code, this allows member names in structures to be similar | |
2718 | to previous types declarations. | |
2719 | ||
2720 | @smallexample | |
2721 | typedef int UOW; | |
2722 | struct ABC @{ | |
2723 | UOW UOW; | |
2724 | @}; | |
2725 | @end smallexample | |
2726 | ||
2727 | Some cases of unnamed fields in structures and unions are only | |
2728 | accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union | |
2729 | fields within structs/unions}, for details. | |
2730 | ||
2731 | Note that this option is off for all targets except for x86 | |
2732 | targets using ms-abi. | |
2733 | ||
ddf6fe37 | 2734 | @opindex foffload |
d77de738 ML |
2735 | @cindex Offloading targets |
2736 | @cindex OpenACC offloading targets | |
2737 | @cindex OpenMP offloading targets | |
f33d7a88 AA |
2738 | @item -foffload=disable |
2739 | @itemx -foffload=default | |
2740 | @itemx -foffload=@var{target-list} | |
d77de738 ML |
2741 | Specify for which OpenMP and OpenACC offload targets code should be generated. |
2742 | The default behavior, equivalent to @option{-foffload=default}, is to generate | |
2743 | code for all supported offload targets. The @option{-foffload=disable} form | |
2744 | generates code only for the host fallback, while | |
2745 | @option{-foffload=@var{target-list}} generates code only for the specified | |
2746 | comma-separated list of offload targets. | |
2747 | ||
2748 | Offload targets are specified in GCC's internal target-triplet format. You can | |
2749 | run the compiler with @option{-v} to show the list of configured offload targets | |
2750 | under @code{OFFLOAD_TARGET_NAMES}. | |
2751 | ||
ddf6fe37 | 2752 | @opindex foffload-options |
d77de738 ML |
2753 | @cindex Offloading options |
2754 | @cindex OpenACC offloading options | |
2755 | @cindex OpenMP offloading options | |
f33d7a88 AA |
2756 | @item -foffload-options=@var{options} |
2757 | @itemx -foffload-options=@var{target-triplet-list}=@var{options} | |
d77de738 ML |
2758 | |
2759 | With @option{-foffload-options=@var{options}}, GCC passes the specified | |
2760 | @var{options} to the compilers for all enabled offloading targets. You can | |
2761 | specify options that apply only to a specific target or targets by using | |
2762 | the @option{-foffload-options=@var{target-list}=@var{options}} form. The | |
2763 | @var{target-list} is a comma-separated list in the same format as for the | |
2764 | @option{-foffload=} option. | |
2765 | ||
2766 | Typical command lines are | |
2767 | ||
2768 | @smallexample | |
4bcb46b3 | 2769 | -foffload-options='-fno-math-errno -ffinite-math-only' -foffload-options=nvptx-none=-latomic |
e9c1679c | 2770 | -foffload-options=amdgcn-amdhsa=-march=gfx906 |
d77de738 ML |
2771 | @end smallexample |
2772 | ||
d77de738 ML |
2773 | @opindex fopenacc |
2774 | @cindex OpenACC accelerator programming | |
f33d7a88 | 2775 | @item -fopenacc |
643a5223 TB |
2776 | Enable handling of OpenACC directives @samp{#pragma acc} in C/C++ and |
2777 | @samp{!$acc} in free-form Fortran and @samp{!$acc}, @samp{c$acc} and | |
2778 | @samp{*$acc} in fixed-form Fortran. When @option{-fopenacc} is specified, | |
2779 | the compiler generates accelerated code according to the OpenACC Application | |
d77de738 ML |
2780 | Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option |
2781 | implies @option{-pthread}, and thus is only supported on targets that | |
2782 | have support for @option{-pthread}. | |
2783 | ||
d77de738 ML |
2784 | @opindex fopenacc-dim |
2785 | @cindex OpenACC accelerator programming | |
f33d7a88 | 2786 | @item -fopenacc-dim=@var{geom} |
d77de738 ML |
2787 | Specify default compute dimensions for parallel offload regions that do |
2788 | not explicitly specify. The @var{geom} value is a triple of | |
2789 | ':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size | |
2790 | can be omitted, to use a target-specific default value. | |
2791 | ||
d77de738 ML |
2792 | @opindex fopenmp |
2793 | @cindex OpenMP parallel | |
f33d7a88 | 2794 | @item -fopenmp |
75e5a467 | 2795 | Enable handling of OpenMP directives @samp{#pragma omp}, |
643a5223 | 2796 | @samp{[[omp::directive(...)]]}, @samp{[[omp::sequence(...)]]} and |
75e5a467 | 2797 | @samp{[[omp::decl(...)]]} in C/C++ and @samp{!$omp} in Fortran. It |
643a5223 TB |
2798 | additionally enables the conditional compilation sentinel @samp{!$} in |
2799 | Fortran. In fixed source form Fortran, the sentinels can also start with | |
2800 | @samp{c} or @samp{*}. When @option{-fopenmp} is specified, the | |
d77de738 ML |
2801 | compiler generates parallel code according to the OpenMP Application |
2802 | Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option | |
2803 | implies @option{-pthread}, and thus is only supported on targets that | |
2804 | have support for @option{-pthread}. @option{-fopenmp} implies | |
2805 | @option{-fopenmp-simd}. | |
2806 | ||
d77de738 ML |
2807 | @opindex fopenmp-simd |
2808 | @cindex OpenMP SIMD | |
2809 | @cindex SIMD | |
f33d7a88 | 2810 | @item -fopenmp-simd |
d77de738 | 2811 | Enable handling of OpenMP's @code{simd}, @code{declare simd}, |
1fab441d TB |
2812 | @code{declare reduction}, @code{assume}, @code{ordered}, @code{scan} |
2813 | and @code{loop} directive, and of combined or composite directives with | |
75e5a467 | 2814 | @code{simd} as constituent with @code{#pragma omp}, |
1fab441d | 2815 | @code{[[omp::directive(...)]]}, @code{[[omp::sequence(...)]]} and |
75e5a467 | 2816 | @code{[[omp::decl(...)]]} in C/C++ and @code{!$omp} in Fortran. It |
643a5223 TB |
2817 | additionally enables the conditional compilation sentinel @samp{!$} in |
2818 | Fortran. In fixed source form Fortran, the sentinels can also start with | |
2819 | @samp{c} or @samp{*}. Other OpenMP directives are ignored. Unless | |
2820 | @option{-fopenmp} is additionally specified, the @code{loop} region binds | |
2821 | to the current task region, independent of the specified @code{bind} clause. | |
d77de738 | 2822 | |
ddf6fe37 | 2823 | @opindex fopenmp-target-simd-clone |
f33d7a88 | 2824 | @cindex OpenMP target SIMD clone |
309e2d95 SL |
2825 | @item -fopenmp-target-simd-clone |
2826 | @item -fopenmp-target-simd-clone=@var{device-type} | |
309e2d95 SL |
2827 | In addition to generating SIMD clones for functions marked with the |
2828 | @code{declare simd} directive, GCC also generates clones | |
2829 | for functions marked with the OpenMP @code{declare target} directive | |
2830 | that are suitable for vectorization when this option is in effect. The | |
2831 | @var{device-type} may be one of @code{none}, @code{host}, @code{nohost}, | |
2832 | and @code{any}, which correspond to keywords for the @code{device_type} | |
2833 | clause of the @code{declare target} directive; clones are generated for | |
2834 | the intersection of devices specified. | |
2835 | @option{-fopenmp-target-simd-clone} is equivalent to | |
2836 | @option{-fopenmp-target-simd-clone=any} and | |
2837 | @option{-fno-openmp-target-simd-clone} is equivalent to | |
2838 | @option{-fopenmp-target-simd-clone=none}. | |
2839 | ||
2840 | At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this | |
2841 | optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise | |
2842 | it is disabled by default. | |
2843 | ||
d77de738 ML |
2844 | @opindex fpermitted-flt-eval-methods |
2845 | @opindex fpermitted-flt-eval-methods=c11 | |
2846 | @opindex fpermitted-flt-eval-methods=ts-18661-3 | |
ddf6fe37 | 2847 | @item -fpermitted-flt-eval-methods=@var{style} |
d77de738 ML |
2848 | ISO/IEC TS 18661-3 defines new permissible values for |
2849 | @code{FLT_EVAL_METHOD} that indicate that operations and constants with | |
2850 | a semantic type that is an interchange or extended format should be | |
2851 | evaluated to the precision and range of that type. These new values are | |
2852 | a superset of those permitted under C99/C11, which does not specify the | |
2853 | meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code | |
2854 | conforming to C11 may not have been written expecting the possibility of | |
2855 | the new values. | |
2856 | ||
2857 | @option{-fpermitted-flt-eval-methods} specifies whether the compiler | |
2858 | should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11, | |
2859 | or the extended set of values specified in ISO/IEC TS 18661-3. | |
2860 | ||
2861 | @var{style} is either @code{c11} or @code{ts-18661-3} as appropriate. | |
2862 | ||
2863 | The default when in a standards compliant mode (@option{-std=c11} or similar) | |
2864 | is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU | |
2865 | dialect (@option{-std=gnu11} or similar) is | |
2866 | @option{-fpermitted-flt-eval-methods=ts-18661-3}. | |
2867 | ||
024f135a BB |
2868 | @opindex fdeps- |
2869 | The @samp{-fdeps-*} options are used to extract structured dependency | |
2870 | information for a source. This involves determining what resources provided by | |
2871 | other source files will be required to compile the source as well as what | |
2872 | resources are provided by the source. This information can be used to add | |
2873 | required dependencies between compilation rules of dependent sources based on | |
2874 | their contents rather than requiring such information be reflected within the | |
2875 | build tools as well. | |
2876 | ||
2877 | @opindex fdeps-file | |
2878 | @item -fdeps-file=@var{file} | |
2879 | Where to write structured dependency information. | |
2880 | ||
2881 | @opindex fdeps-format | |
2882 | @item -fdeps-format=@var{format} | |
2883 | The format to use for structured dependency information. @samp{p1689r5} is the | |
2884 | only supported format right now. Note that when this argument is specified, the | |
2885 | output of @samp{-MF} is stripped of some information (namely C++ modules) so | |
2886 | that it does not use extended makefile syntax not understood by most tools. | |
2887 | ||
2888 | @opindex fdeps-target | |
2889 | @item -fdeps-target=@var{file} | |
2890 | Analogous to @option{-MT} but for structured dependency information. This | |
2891 | indicates the target which will ultimately need any required resources and | |
2892 | provide any resources extracted from the source that may be required by other | |
2893 | sources. | |
2894 | ||
d77de738 | 2895 | @opindex fplan9-extensions |
ddf6fe37 | 2896 | @item -fplan9-extensions |
d77de738 ML |
2897 | Accept some non-standard constructs used in Plan 9 code. |
2898 | ||
2899 | This enables @option{-fms-extensions}, permits passing pointers to | |
2900 | structures with anonymous fields to functions that expect pointers to | |
2901 | elements of the type of the field, and permits referring to anonymous | |
2902 | fields declared using a typedef. @xref{Unnamed Fields,,Unnamed | |
2903 | struct/union fields within structs/unions}, for details. This is only | |
2904 | supported for C, not C++. | |
2905 | ||
d77de738 ML |
2906 | @opindex fsigned-bitfields |
2907 | @opindex funsigned-bitfields | |
2908 | @opindex fno-signed-bitfields | |
2909 | @opindex fno-unsigned-bitfields | |
ddf6fe37 AA |
2910 | @item -fsigned-bitfields |
2911 | @itemx -funsigned-bitfields | |
2912 | @itemx -fno-signed-bitfields | |
2913 | @itemx -fno-unsigned-bitfields | |
d77de738 ML |
2914 | These options control whether a bit-field is signed or unsigned, when the |
2915 | declaration does not use either @code{signed} or @code{unsigned}. By | |
2916 | default, such a bit-field is signed, because this is consistent: the | |
2917 | basic integer types such as @code{int} are signed types. | |
2918 | ||
d77de738 | 2919 | @opindex fsigned-char |
ddf6fe37 | 2920 | @item -fsigned-char |
d77de738 ML |
2921 | Let the type @code{char} be signed, like @code{signed char}. |
2922 | ||
2923 | Note that this is equivalent to @option{-fno-unsigned-char}, which is | |
2924 | the negative form of @option{-funsigned-char}. Likewise, the option | |
2925 | @option{-fno-signed-char} is equivalent to @option{-funsigned-char}. | |
2926 | ||
d77de738 | 2927 | @opindex funsigned-char |
ddf6fe37 | 2928 | @item -funsigned-char |
d77de738 ML |
2929 | Let the type @code{char} be unsigned, like @code{unsigned char}. |
2930 | ||
2931 | Each kind of machine has a default for what @code{char} should | |
2932 | be. It is either like @code{unsigned char} by default or like | |
2933 | @code{signed char} by default. | |
2934 | ||
2935 | Ideally, a portable program should always use @code{signed char} or | |
2936 | @code{unsigned char} when it depends on the signedness of an object. | |
2937 | But many programs have been written to use plain @code{char} and | |
2938 | expect it to be signed, or expect it to be unsigned, depending on the | |
2939 | machines they were written for. This option, and its inverse, let you | |
2940 | make such a program work with the opposite default. | |
2941 | ||
2942 | The type @code{char} is always a distinct type from each of | |
2943 | @code{signed char} or @code{unsigned char}, even though its behavior | |
2944 | is always just like one of those two. | |
2945 | ||
d77de738 ML |
2946 | @opindex fstrict-flex-arrays |
2947 | @opindex fno-strict-flex-arrays | |
d77de738 | 2948 | @opindex fstrict-flex-arrays=@var{level} |
eb71695f SL |
2949 | @item -fstrict-flex-arrays @r{(C and C++ only)} |
2950 | @itemx -fstrict-flex-arrays=@var{level} @r{(C and C++ only)} | |
d77de738 ML |
2951 | Control when to treat the trailing array of a structure as a flexible array |
2952 | member for the purpose of accessing the elements of such an array. The value | |
2953 | of @var{level} controls the level of strictness. | |
2954 | ||
eb71695f SL |
2955 | @option{-fstrict-flex-arrays} is equivalent to |
2956 | @option{-fstrict-flex-arrays=3}, which is the strictest; all | |
2957 | trailing arrays of structures are treated as flexible array members. | |
2958 | ||
2959 | The negative form @option{-fno-strict-flex-arrays} is equivalent to | |
2960 | @option{-fstrict-flex-arrays=0}, which is the least strict. In this | |
2961 | case a trailing array is treated as a flexible array member only when | |
2962 | it is declared as a flexible array member per C99 standard onwards. | |
2963 | ||
d77de738 ML |
2964 | The possible values of @var{level} are the same as for the |
2965 | @code{strict_flex_array} attribute (@pxref{Variable Attributes}). | |
2966 | ||
2967 | You can control this behavior for a specific trailing array field of a | |
2968 | structure by using the variable attribute @code{strict_flex_array} attribute | |
2969 | (@pxref{Variable Attributes}). | |
2970 | ||
eb71695f SL |
2971 | The @option{-fstrict_flex_arrays} option interacts with the |
2972 | @option{-Wstrict-flex-arrays} option. @xref{Warning Options}, for more | |
2973 | information. | |
2974 | ||
d77de738 | 2975 | @opindex fsso-struct |
ddf6fe37 | 2976 | @item -fsso-struct=@var{endianness} |
d77de738 ML |
2977 | Set the default scalar storage order of structures and unions to the |
2978 | specified endianness. The accepted values are @samp{big-endian}, | |
2979 | @samp{little-endian} and @samp{native} for the native endianness of | |
2980 | the target (the default). This option is not supported for C++. | |
2981 | ||
2982 | @strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate | |
2983 | code that is not binary compatible with code generated without it if the | |
2984 | specified endianness is not the native endianness of the target. | |
2985 | @end table | |
2986 | ||
2987 | @node C++ Dialect Options | |
2988 | @section Options Controlling C++ Dialect | |
2989 | ||
2990 | @cindex compiler options, C++ | |
2991 | @cindex C++ options, command-line | |
2992 | @cindex options, C++ | |
2993 | This section describes the command-line options that are only meaningful | |
2994 | for C++ programs. You can also use most of the GNU compiler options | |
2995 | regardless of what language your program is in. For example, you | |
2996 | might compile a file @file{firstClass.C} like this: | |
2997 | ||
2998 | @smallexample | |
2999 | g++ -g -fstrict-enums -O -c firstClass.C | |
3000 | @end smallexample | |
3001 | ||
3002 | @noindent | |
3003 | In this example, only @option{-fstrict-enums} is an option meant | |
3004 | only for C++ programs; you can use the other options with any | |
3005 | language supported by GCC@. | |
3006 | ||
3007 | Some options for compiling C programs, such as @option{-std}, are also | |
3008 | relevant for C++ programs. | |
3009 | @xref{C Dialect Options,,Options Controlling C Dialect}. | |
3010 | ||
3011 | Here is a list of options that are @emph{only} for compiling C++ programs: | |
3012 | ||
3013 | @table @gcctabopt | |
3014 | ||
d77de738 | 3015 | @opindex fabi-version |
ddf6fe37 | 3016 | @item -fabi-version=@var{n} |
d77de738 ML |
3017 | Use version @var{n} of the C++ ABI@. The default is version 0. |
3018 | ||
3019 | Version 0 refers to the version conforming most closely to | |
3020 | the C++ ABI specification. Therefore, the ABI obtained using version 0 | |
3021 | will change in different versions of G++ as ABI bugs are fixed. | |
3022 | ||
3023 | Version 1 is the version of the C++ ABI that first appeared in G++ 3.2. | |
3024 | ||
3025 | Version 2 is the version of the C++ ABI that first appeared in G++ | |
3026 | 3.4, and was the default through G++ 4.9. | |
3027 | ||
3028 | Version 3 corrects an error in mangling a constant address as a | |
3029 | template argument. | |
3030 | ||
3031 | Version 4, which first appeared in G++ 4.5, implements a standard | |
3032 | mangling for vector types. | |
3033 | ||
3034 | Version 5, which first appeared in G++ 4.6, corrects the mangling of | |
3035 | attribute const/volatile on function pointer types, decltype of a | |
3036 | plain decl, and use of a function parameter in the declaration of | |
3037 | another parameter. | |
3038 | ||
3039 | Version 6, which first appeared in G++ 4.7, corrects the promotion | |
3040 | behavior of C++11 scoped enums and the mangling of template argument | |
3041 | packs, const/static_cast, prefix ++ and --, and a class scope function | |
3042 | used as a template argument. | |
3043 | ||
3044 | Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a | |
3045 | builtin type and corrects the mangling of lambdas in default argument | |
3046 | scope. | |
3047 | ||
3048 | Version 8, which first appeared in G++ 4.9, corrects the substitution | |
3049 | behavior of function types with function-cv-qualifiers. | |
3050 | ||
3051 | Version 9, which first appeared in G++ 5.2, corrects the alignment of | |
3052 | @code{nullptr_t}. | |
3053 | ||
3054 | Version 10, which first appeared in G++ 6.1, adds mangling of | |
3055 | attributes that affect type identity, such as ia32 calling convention | |
3056 | attributes (e.g.@: @samp{stdcall}). | |
3057 | ||
3058 | Version 11, which first appeared in G++ 7, corrects the mangling of | |
3059 | sizeof... expressions and operator names. For multiple entities with | |
3060 | the same name within a function, that are declared in different scopes, | |
3061 | the mangling now changes starting with the twelfth occurrence. It also | |
3062 | implies @option{-fnew-inheriting-ctors}. | |
3063 | ||
3064 | Version 12, which first appeared in G++ 8, corrects the calling | |
3065 | conventions for empty classes on the x86_64 target and for classes | |
3066 | with only deleted copy/move constructors. It accidentally changes the | |
3067 | calling convention for classes with a deleted copy constructor and a | |
3068 | trivial move constructor. | |
3069 | ||
3070 | Version 13, which first appeared in G++ 8.2, fixes the accidental | |
3071 | change in version 12. | |
3072 | ||
3073 | Version 14, which first appeared in G++ 10, corrects the mangling of | |
3074 | the nullptr expression. | |
3075 | ||
3076 | Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI | |
3077 | tag regression. | |
3078 | ||
3079 | Version 16, which first appeared in G++ 11, changes the mangling of | |
3080 | @code{__alignof__} to be distinct from that of @code{alignof}, and | |
3081 | dependent operator names. | |
3082 | ||
3083 | Version 17, which first appeared in G++ 12, fixes layout of classes | |
3084 | that inherit from aggregate classes with default member initializers | |
3085 | in C++14 and up. | |
3086 | ||
3087 | Version 18, which first appeard in G++ 13, fixes manglings of lambdas | |
3088 | that have additional context. | |
3089 | ||
cd37325b JJ |
3090 | Version 19, which first appeard in G++ 14, fixes manglings of structured |
3091 | bindings to include ABI tags. | |
3092 | ||
d77de738 ML |
3093 | See also @option{-Wabi}. |
3094 | ||
d77de738 | 3095 | @opindex fabi-compat-version |
ddf6fe37 | 3096 | @item -fabi-compat-version=@var{n} |
d77de738 ML |
3097 | On targets that support strong aliases, G++ |
3098 | works around mangling changes by creating an alias with the correct | |
3099 | mangled name when defining a symbol with an incorrect mangled name. | |
3100 | This switch specifies which ABI version to use for the alias. | |
3101 | ||
3102 | With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2 | |
3103 | compatibility). If another ABI version is explicitly selected, this | |
3104 | defaults to 0. For compatibility with GCC versions 3.2 through 4.9, | |
3105 | use @option{-fabi-compat-version=2}. | |
3106 | ||
3107 | If this option is not provided but @option{-Wabi=@var{n}} is, that | |
3108 | version is used for compatibility aliases. If this option is provided | |
3109 | along with @option{-Wabi} (without the version), the version from this | |
3110 | option is used for the warning. | |
3111 | ||
d77de738 ML |
3112 | @opindex fno-access-control |
3113 | @opindex faccess-control | |
ddf6fe37 | 3114 | @item -fno-access-control |
d77de738 ML |
3115 | Turn off all access checking. This switch is mainly useful for working |
3116 | around bugs in the access control code. | |
3117 | ||
d77de738 | 3118 | @opindex faligned-new |
ddf6fe37 | 3119 | @item -faligned-new |
d77de738 ML |
3120 | Enable support for C++17 @code{new} of types that require more |
3121 | alignment than @code{void* ::operator new(std::size_t)} provides. A | |
3122 | numeric argument such as @code{-faligned-new=32} can be used to | |
3123 | specify how much alignment (in bytes) is provided by that function, | |
3124 | but few users will need to override the default of | |
3125 | @code{alignof(std::max_align_t)}. | |
3126 | ||
3127 | This flag is enabled by default for @option{-std=c++17}. | |
3128 | ||
d77de738 ML |
3129 | @opindex fchar8_t |
3130 | @opindex fno-char8_t | |
ddf6fe37 AA |
3131 | @item -fchar8_t |
3132 | @itemx -fno-char8_t | |
d77de738 ML |
3133 | Enable support for @code{char8_t} as adopted for C++20. This includes |
3134 | the addition of a new @code{char8_t} fundamental type, changes to the | |
3135 | types of UTF-8 string and character literals, new signatures for | |
3136 | user-defined literals, associated standard library updates, and new | |
3137 | @code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros. | |
3138 | ||
3139 | This option enables functions to be overloaded for ordinary and UTF-8 | |
3140 | strings: | |
3141 | ||
3142 | @smallexample | |
3143 | int f(const char *); // #1 | |
3144 | int f(const char8_t *); // #2 | |
3145 | int v1 = f("text"); // Calls #1 | |
3146 | int v2 = f(u8"text"); // Calls #2 | |
3147 | @end smallexample | |
3148 | ||
3149 | @noindent | |
3150 | and introduces new signatures for user-defined literals: | |
3151 | ||
3152 | @smallexample | |
3153 | int operator""_udl1(char8_t); | |
3154 | int v3 = u8'x'_udl1; | |
3155 | int operator""_udl2(const char8_t*, std::size_t); | |
3156 | int v4 = u8"text"_udl2; | |
3157 | template<typename T, T...> int operator""_udl3(); | |
3158 | int v5 = u8"text"_udl3; | |
3159 | @end smallexample | |
3160 | ||
3161 | @noindent | |
3162 | The change to the types of UTF-8 string and character literals introduces | |
3163 | incompatibilities with ISO C++11 and later standards. For example, the | |
3164 | following code is well-formed under ISO C++11, but is ill-formed when | |
3165 | @option{-fchar8_t} is specified. | |
3166 | ||
3167 | @smallexample | |
d77de738 ML |
3168 | const char *cp = u8"xx";// error: invalid conversion from |
3169 | // `const char8_t*' to `const char*' | |
3170 | int f(const char*); | |
3171 | auto v = f(u8"xx"); // error: invalid conversion from | |
3172 | // `const char8_t*' to `const char*' | |
3173 | std::string s@{u8"xx"@}; // error: no matching function for call to | |
3174 | // `std::basic_string<char>::basic_string()' | |
3175 | using namespace std::literals; | |
3176 | s = u8"xx"s; // error: conversion from | |
3177 | // `basic_string<char8_t>' to non-scalar | |
3178 | // type `basic_string<char>' requested | |
3179 | @end smallexample | |
3180 | ||
d77de738 | 3181 | @opindex fcheck-new |
ddf6fe37 | 3182 | @item -fcheck-new |
d77de738 ML |
3183 | Check that the pointer returned by @code{operator new} is non-null |
3184 | before attempting to modify the storage allocated. This check is | |
3185 | normally unnecessary because the C++ standard specifies that | |
3186 | @code{operator new} only returns @code{0} if it is declared | |
3187 | @code{throw()}, in which case the compiler always checks the | |
3188 | return value even without this option. In all other cases, when | |
3189 | @code{operator new} has a non-empty exception specification, memory | |
3190 | exhaustion is signalled by throwing @code{std::bad_alloc}. See also | |
3191 | @samp{new (nothrow)}. | |
3192 | ||
d77de738 ML |
3193 | @opindex fconcepts |
3194 | @opindex fconcepts-ts | |
ddf6fe37 AA |
3195 | @item -fconcepts |
3196 | @itemx -fconcepts-ts | |
d77de738 ML |
3197 | Enable support for the C++ Concepts feature for constraining template |
3198 | arguments. With @option{-std=c++20} and above, Concepts are part of | |
3199 | the language standard, so @option{-fconcepts} defaults to on. | |
3200 | ||
3201 | Some constructs that were allowed by the earlier C++ Extensions for | |
3202 | Concepts Technical Specification, ISO 19217 (2015), but didn't make it | |
3203 | into the standard, can additionally be enabled by | |
3204 | @option{-fconcepts-ts}. | |
3205 | ||
d77de738 | 3206 | @opindex fconstexpr-depth |
ddf6fe37 | 3207 | @item -fconstexpr-depth=@var{n} |
d77de738 ML |
3208 | Set the maximum nested evaluation depth for C++11 constexpr functions |
3209 | to @var{n}. A limit is needed to detect endless recursion during | |
3210 | constant expression evaluation. The minimum specified by the standard | |
3211 | is 512. | |
3212 | ||
d77de738 | 3213 | @opindex fconstexpr-cache-depth |
ddf6fe37 | 3214 | @item -fconstexpr-cache-depth=@var{n} |
d77de738 ML |
3215 | Set the maximum level of nested evaluation depth for C++11 constexpr |
3216 | functions that will be cached to @var{n}. This is a heuristic that | |
3217 | trades off compilation speed (when the cache avoids repeated | |
3218 | calculations) against memory consumption (when the cache grows very | |
3219 | large from highly recursive evaluations). The default is 8. Very few | |
3220 | users are likely to want to adjust it, but if your code does heavy | |
3221 | constexpr calculations you might want to experiment to find which | |
3222 | value works best for you. | |
3223 | ||
d77de738 | 3224 | @opindex fconstexpr-fp-except |
ddf6fe37 | 3225 | @item -fconstexpr-fp-except |
d77de738 ML |
3226 | Annex F of the C standard specifies that IEC559 floating point |
3227 | exceptions encountered at compile time should not stop compilation. | |
3228 | C++ compilers have historically not followed this guidance, instead | |
3229 | treating floating point division by zero as non-constant even though | |
3230 | it has a well defined value. This flag tells the compiler to give | |
3231 | Annex F priority over other rules saying that a particular operation | |
3232 | is undefined. | |
3233 | ||
3234 | @smallexample | |
3235 | constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except | |
3236 | @end smallexample | |
3237 | ||
d77de738 | 3238 | @opindex fconstexpr-loop-limit |
ddf6fe37 | 3239 | @item -fconstexpr-loop-limit=@var{n} |
d77de738 ML |
3240 | Set the maximum number of iterations for a loop in C++14 constexpr functions |
3241 | to @var{n}. A limit is needed to detect infinite loops during | |
3242 | constant expression evaluation. The default is 262144 (1<<18). | |
3243 | ||
d77de738 | 3244 | @opindex fconstexpr-ops-limit |
ddf6fe37 | 3245 | @item -fconstexpr-ops-limit=@var{n} |
d77de738 ML |
3246 | Set the maximum number of operations during a single constexpr evaluation. |
3247 | Even when number of iterations of a single loop is limited with the above limit, | |
3248 | if there are several nested loops and each of them has many iterations but still | |
3249 | smaller than the above limit, or if in a body of some loop or even outside | |
3250 | of a loop too many expressions need to be evaluated, the resulting constexpr | |
3251 | evaluation might take too long. | |
3252 | The default is 33554432 (1<<25). | |
3253 | ||
2efb237f | 3254 | @opindex fcontracts |
ddf6fe37 | 3255 | @item -fcontracts |
2efb237f JCI |
3256 | Enable experimental support for the C++ Contracts feature, as briefly |
3257 | added to and then removed from the C++20 working paper (N4820). The | |
3258 | implementation also includes proposed enhancements from papers P1290, | |
3259 | P1332, and P1429. This functionality is intended mostly for those | |
3260 | interested in experimentation towards refining the feature to get it | |
3261 | into shape for a future C++ standard. | |
3262 | ||
3263 | On violation of a checked contract, the violation handler is called. | |
3264 | Users can replace the violation handler by defining | |
3265 | @smallexample | |
4ace81b6 SL |
3266 | void |
3267 | handle_contract_violation (const std::experimental::contract_violation&); | |
2efb237f JCI |
3268 | @end smallexample |
3269 | ||
3270 | There are different sets of additional flags that can be used together | |
3271 | to specify which contracts will be checked and how, for N4820 | |
3272 | contracts, P1332 contracts, or P1429 contracts; these sets cannot be | |
3273 | used together. | |
3274 | ||
3275 | @table @gcctabopt | |
2efb237f | 3276 | @opindex fcontract-mode |
ddf6fe37 | 3277 | @item -fcontract-mode=[on|off] |
2efb237f JCI |
3278 | Control whether any contracts have any semantics at all. Defaults to on. |
3279 | ||
2efb237f | 3280 | @opindex fcontract-assumption-mode |
ddf6fe37 | 3281 | @item -fcontract-assumption-mode=[on|off] |
2efb237f JCI |
3282 | [N4820] Control whether contracts with level @samp{axiom} |
3283 | should have the assume semantic. Defaults to on. | |
3284 | ||
2efb237f | 3285 | @opindex fcontract-build-level |
ddf6fe37 | 3286 | @item -fcontract-build-level=[off|default|audit] |
2efb237f JCI |
3287 | [N4820] Specify which level of contracts to generate checks |
3288 | for. Defaults to @samp{default}. | |
3289 | ||
2efb237f | 3290 | @opindex fcontract-continuation-mode |
ddf6fe37 | 3291 | @item -fcontract-continuation-mode=[on|off] |
2efb237f JCI |
3292 | [N4820] Control whether to allow the program to continue executing |
3293 | after a contract violation. That is, do checked contracts have the | |
3294 | @samp{maybe} semantic described below rather than the @samp{never} | |
3295 | semantic. Defaults to off. | |
3296 | ||
2efb237f | 3297 | @opindex fcontract-role |
ddf6fe37 | 3298 | @item -fcontract-role=<name>:<default>,<audit>,<axiom> |
2efb237f JCI |
3299 | [P1332] Specify the concrete semantics for each contract level |
3300 | of a particular contract role. | |
3301 | ||
3302 | @item -fcontract-semantic=[default|audit|axiom]:<semantic> | |
3303 | [P1429] Specify the concrete semantic for a particular | |
3304 | contract level. | |
3305 | ||
2efb237f | 3306 | @opindex fcontract-strict-declarations |
ddf6fe37 | 3307 | @item -fcontract-strict-declarations=[on|off] |
2efb237f JCI |
3308 | Control whether to reject adding contracts to a function after its |
3309 | first declaration. Defaults to off. | |
3310 | @end table | |
3311 | ||
3312 | The possible concrete semantics for that can be specified with | |
3313 | @samp{-fcontract-role} or @samp{-fcontract-semantic} are: | |
3314 | ||
3315 | @table @code | |
3316 | @item ignore | |
3317 | This contract has no effect. | |
3318 | ||
3319 | @item assume | |
3320 | This contract is treated like C++23 @code{[[assume]]}. | |
3321 | ||
3322 | @item check_never_continue | |
3323 | @itemx never | |
3324 | @itemx abort | |
3325 | This contract is checked. If it fails, the violation handler is | |
3326 | called. If the handler returns, @code{std::terminate} is called. | |
3327 | ||
3328 | @item check_maybe_continue | |
3329 | @itemx maybe | |
3330 | This contract is checked. If it fails, the violation handler is | |
3331 | called. If the handler returns, execution continues normally. | |
3332 | @end table | |
3333 | ||
d77de738 | 3334 | @opindex fcoroutines |
ddf6fe37 | 3335 | @item -fcoroutines |
d77de738 ML |
3336 | Enable support for the C++ coroutines extension (experimental). |
3337 | ||
d6840b31 PP |
3338 | @opindex fdiagnostics-all-candidates |
3339 | @item -fdiagnostics-all-candidates | |
3340 | Permit the C++ front end to note all candidates during overload resolution | |
3341 | failure, including when a deleted function is selected. | |
3342 | ||
d77de738 ML |
3343 | @opindex fno-elide-constructors |
3344 | @opindex felide-constructors | |
ddf6fe37 | 3345 | @item -fno-elide-constructors |
d77de738 ML |
3346 | The C++ standard allows an implementation to omit creating a temporary |
3347 | that is only used to initialize another object of the same type. | |
3348 | Specifying this option disables that optimization, and forces G++ to | |
3349 | call the copy constructor in all cases. This option also causes G++ | |
3350 | to call trivial member functions which otherwise would be expanded inline. | |
3351 | ||
3352 | In C++17, the compiler is required to omit these temporaries, but this | |
3353 | option still affects trivial member functions. | |
3354 | ||
d77de738 ML |
3355 | @opindex fno-enforce-eh-specs |
3356 | @opindex fenforce-eh-specs | |
ddf6fe37 | 3357 | @item -fno-enforce-eh-specs |
d77de738 ML |
3358 | Don't generate code to check for violation of exception specifications |
3359 | at run time. This option violates the C++ standard, but may be useful | |
3360 | for reducing code size in production builds, much like defining | |
3361 | @code{NDEBUG}. This does not give user code permission to throw | |
3362 | exceptions in violation of the exception specifications; the compiler | |
3363 | still optimizes based on the specifications, so throwing an | |
3364 | unexpected exception results in undefined behavior at run time. | |
3365 | ||
d77de738 ML |
3366 | @opindex fextern-tls-init |
3367 | @opindex fno-extern-tls-init | |
ddf6fe37 AA |
3368 | @item -fextern-tls-init |
3369 | @itemx -fno-extern-tls-init | |
d77de738 ML |
3370 | The C++11 and OpenMP standards allow @code{thread_local} and |
3371 | @code{threadprivate} variables to have dynamic (runtime) | |
3372 | initialization. To support this, any use of such a variable goes | |
3373 | through a wrapper function that performs any necessary initialization. | |
3374 | When the use and definition of the variable are in the same | |
3375 | translation unit, this overhead can be optimized away, but when the | |
3376 | use is in a different translation unit there is significant overhead | |
3377 | even if the variable doesn't actually need dynamic initialization. If | |
3378 | the programmer can be sure that no use of the variable in a | |
3379 | non-defining TU needs to trigger dynamic initialization (either | |
3380 | because the variable is statically initialized, or a use of the | |
3381 | variable in the defining TU will be executed before any uses in | |
3382 | another TU), they can avoid this overhead with the | |
3383 | @option{-fno-extern-tls-init} option. | |
3384 | ||
3385 | On targets that support symbol aliases, the default is | |
3386 | @option{-fextern-tls-init}. On targets that do not support symbol | |
3387 | aliases, the default is @option{-fno-extern-tls-init}. | |
3388 | ||
d77de738 ML |
3389 | @opindex ffold-simple-inlines |
3390 | @opindex fno-fold-simple-inlines | |
ddf6fe37 AA |
3391 | @item -ffold-simple-inlines |
3392 | @itemx -fno-fold-simple-inlines | |
d77de738 ML |
3393 | Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward}, |
3394 | @code{std::addressof} and @code{std::as_const}. In contrast to inlining, this | |
3395 | means no debug information will be generated for such calls. Since these | |
3396 | functions are rarely interesting to debug, this flag is enabled by default | |
3397 | unless @option{-fno-inline} is active. | |
3398 | ||
d77de738 ML |
3399 | @opindex fno-gnu-keywords |
3400 | @opindex fgnu-keywords | |
ddf6fe37 | 3401 | @item -fno-gnu-keywords |
d77de738 ML |
3402 | Do not recognize @code{typeof} as a keyword, so that code can use this |
3403 | word as an identifier. You can use the keyword @code{__typeof__} instead. | |
3404 | This option is implied by the strict ISO C++ dialects: @option{-ansi}, | |
3405 | @option{-std=c++98}, @option{-std=c++11}, etc. | |
3406 | ||
1f1c4322 MP |
3407 | @opindex fno-immediate-escalation |
3408 | @opindex fimmediate-escalation | |
3409 | @item -fno-immediate-escalation | |
3410 | Do not enable immediate function escalation whereby certain functions | |
3411 | can be promoted to consteval, as specified in P2564R3. For example: | |
3412 | ||
3413 | @example | |
3414 | consteval int id(int i) @{ return i; @} | |
3415 | ||
3416 | constexpr int f(auto t) | |
3417 | @{ | |
3418 | return t + id(t); // id causes f<int> to be promoted to consteval | |
3419 | @} | |
3420 | ||
3421 | void g(int i) | |
3422 | @{ | |
3423 | f (3); | |
3424 | @} | |
3425 | @end example | |
3426 | ||
3427 | compiles in C++20: @code{f} is an immediate-escalating function (due to | |
3428 | the @code{auto} it is a function template and is declared @code{constexpr}) | |
3429 | and @code{id(t)} is an immediate-escalating expression, so @code{f} is | |
3430 | promoted to @code{consteval}. Consequently, the call to @code{id(t)} | |
3431 | is in an immediate context, so doesn't have to produce a constant (that | |
3432 | is the mechanism allowing consteval function composition). However, | |
3433 | with @option{-fno-immediate-escalation}, @code{f} is not promoted to | |
3434 | @code{consteval}, and since the call to consteval function @code{id(t)} | |
3435 | is not a constant expression, the compiler rejects the code. | |
3436 | ||
3437 | This option is turned on by default; it is only effective in C++20 mode | |
3438 | or later. | |
3439 | ||
d77de738 | 3440 | @opindex fimplicit-constexpr |
ddf6fe37 | 3441 | @item -fimplicit-constexpr |
d77de738 ML |
3442 | Make inline functions implicitly constexpr, if they satisfy the |
3443 | requirements for a constexpr function. This option can be used in | |
3444 | C++14 mode or later. This can result in initialization changing from | |
3445 | dynamic to static and other optimizations. | |
3446 | ||
d77de738 ML |
3447 | @opindex fno-implicit-templates |
3448 | @opindex fimplicit-templates | |
ddf6fe37 | 3449 | @item -fno-implicit-templates |
d77de738 ML |
3450 | Never emit code for non-inline templates that are instantiated |
3451 | implicitly (i.e.@: by use); only emit code for explicit instantiations. | |
3452 | If you use this option, you must take care to structure your code to | |
3453 | include all the necessary explicit instantiations to avoid getting | |
3454 | undefined symbols at link time. | |
3455 | @xref{Template Instantiation}, for more information. | |
3456 | ||
d77de738 ML |
3457 | @opindex fno-implicit-inline-templates |
3458 | @opindex fimplicit-inline-templates | |
ddf6fe37 | 3459 | @item -fno-implicit-inline-templates |
d77de738 ML |
3460 | Don't emit code for implicit instantiations of inline templates, either. |
3461 | The default is to handle inlines differently so that compiles with and | |
3462 | without optimization need the same set of explicit instantiations. | |
3463 | ||
d77de738 ML |
3464 | @opindex fno-implement-inlines |
3465 | @opindex fimplement-inlines | |
ddf6fe37 | 3466 | @item -fno-implement-inlines |
d77de738 ML |
3467 | To save space, do not emit out-of-line copies of inline functions |
3468 | controlled by @code{#pragma implementation}. This causes linker | |
3469 | errors if these functions are not inlined everywhere they are called. | |
3470 | ||
d77de738 ML |
3471 | @opindex fmodules-ts |
3472 | @opindex fno-modules-ts | |
ddf6fe37 AA |
3473 | @item -fmodules-ts |
3474 | @itemx -fno-modules-ts | |
d77de738 ML |
3475 | Enable support for C++20 modules (@pxref{C++ Modules}). The |
3476 | @option{-fno-modules-ts} is usually not needed, as that is the | |
3477 | default. Even though this is a C++20 feature, it is not currently | |
3478 | implicitly enabled by selecting that standard version. | |
3479 | ||
ddf6fe37 | 3480 | @opindex fmodule-header |
d77de738 ML |
3481 | @item -fmodule-header |
3482 | @itemx -fmodule-header=user | |
3483 | @itemx -fmodule-header=system | |
d77de738 ML |
3484 | Compile a header file to create an importable header unit. |
3485 | ||
d77de738 | 3486 | @opindex fmodule-implicit-inline |
ddf6fe37 | 3487 | @item -fmodule-implicit-inline |
d77de738 ML |
3488 | Member functions defined in their class definitions are not implicitly |
3489 | inline for modular code. This is different to traditional C++ | |
3490 | behavior, for good reasons. However, it may result in a difficulty | |
3491 | during code porting. This option makes such function definitions | |
3492 | implicitly inline. It does however generate an ABI incompatibility, | |
3493 | so you must use it everywhere or nowhere. (Such definitions outside | |
3494 | of a named module remain implicitly inline, regardless.) | |
3495 | ||
d77de738 ML |
3496 | @opindex fno-module-lazy |
3497 | @opindex fmodule-lazy | |
ddf6fe37 | 3498 | @item -fno-module-lazy |
d77de738 ML |
3499 | Disable lazy module importing and module mapper creation. |
3500 | ||
f33d7a88 AA |
3501 | @vindex CXX_MODULE_MAPPER @r{environment variable} |
3502 | @opindex fmodule-mapper | |
d77de738 ML |
3503 | @item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]} |
3504 | @itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...} | |
3505 | @itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]} | |
3506 | @itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]} | |
3507 | @itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]} | |
3508 | @itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]} | |
d77de738 ML |
3509 | An oracle to query for module name to filename mappings. If |
3510 | unspecified the @env{CXX_MODULE_MAPPER} environment variable is used, | |
3511 | and if that is unset, an in-process default is provided. | |
3512 | ||
d77de738 | 3513 | @opindex fmodule-only |
ddf6fe37 | 3514 | @item -fmodule-only |
d77de738 ML |
3515 | Only emit the Compiled Module Interface, inhibiting any object file. |
3516 | ||
d77de738 | 3517 | @opindex fms-extensions |
ddf6fe37 | 3518 | @item -fms-extensions |
d77de738 ML |
3519 | Disable Wpedantic warnings about constructs used in MFC, such as implicit |
3520 | int and getting a pointer to member function via non-standard syntax. | |
3521 | ||
d77de738 | 3522 | @opindex fnew-inheriting-ctors |
ddf6fe37 | 3523 | @item -fnew-inheriting-ctors |
d77de738 ML |
3524 | Enable the P0136 adjustment to the semantics of C++11 constructor |
3525 | inheritance. This is part of C++17 but also considered to be a Defect | |
3526 | Report against C++11 and C++14. This flag is enabled by default | |
3527 | unless @option{-fabi-version=10} or lower is specified. | |
3528 | ||
d77de738 | 3529 | @opindex fnew-ttp-matching |
ddf6fe37 | 3530 | @item -fnew-ttp-matching |
d77de738 ML |
3531 | Enable the P0522 resolution to Core issue 150, template template |
3532 | parameters and default arguments: this allows a template with default | |
3533 | template arguments as an argument for a template template parameter | |
3534 | with fewer template parameters. This flag is enabled by default for | |
3535 | @option{-std=c++17}. | |
3536 | ||
d77de738 ML |
3537 | @opindex fno-nonansi-builtins |
3538 | @opindex fnonansi-builtins | |
ddf6fe37 | 3539 | @item -fno-nonansi-builtins |
d77de738 ML |
3540 | Disable built-in declarations of functions that are not mandated by |
3541 | ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit}, | |
3542 | @code{index}, @code{bzero}, @code{conjf}, and other related functions. | |
3543 | ||
d77de738 | 3544 | @opindex fnothrow-opt |
ddf6fe37 | 3545 | @item -fnothrow-opt |
d77de738 ML |
3546 | Treat a @code{throw()} exception specification as if it were a |
3547 | @code{noexcept} specification to reduce or eliminate the text size | |
3548 | overhead relative to a function with no exception specification. If | |
3549 | the function has local variables of types with non-trivial | |
3550 | destructors, the exception specification actually makes the | |
3551 | function smaller because the EH cleanups for those variables can be | |
3552 | optimized away. The semantic effect is that an exception thrown out of | |
3553 | a function with such an exception specification results in a call | |
3554 | to @code{terminate} rather than @code{unexpected}. | |
3555 | ||
d77de738 ML |
3556 | @opindex fno-operator-names |
3557 | @opindex foperator-names | |
ddf6fe37 | 3558 | @item -fno-operator-names |
d77de738 ML |
3559 | Do not treat the operator name keywords @code{and}, @code{bitand}, |
3560 | @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as | |
3561 | synonyms as keywords. | |
3562 | ||
d77de738 ML |
3563 | @opindex fno-optional-diags |
3564 | @opindex foptional-diags | |
ddf6fe37 | 3565 | @item -fno-optional-diags |
d77de738 ML |
3566 | Disable diagnostics that the standard says a compiler does not need to |
3567 | issue. Currently, the only such diagnostic issued by G++ is the one for | |
3568 | a name having multiple meanings within a class. | |
3569 | ||
d77de738 ML |
3570 | @opindex fno-pretty-templates |
3571 | @opindex fpretty-templates | |
ddf6fe37 | 3572 | @item -fno-pretty-templates |
d77de738 ML |
3573 | When an error message refers to a specialization of a function |
3574 | template, the compiler normally prints the signature of the | |
3575 | template followed by the template arguments and any typedefs or | |
3576 | typenames in the signature (e.g.@: @code{void f(T) [with T = int]} | |
3577 | rather than @code{void f(int)}) so that it's clear which template is | |
3578 | involved. When an error message refers to a specialization of a class | |
3579 | template, the compiler omits any template arguments that match | |
3580 | the default template arguments for that template. If either of these | |
3581 | behaviors make it harder to understand the error message rather than | |
3582 | easier, you can use @option{-fno-pretty-templates} to disable them. | |
3583 | ||
d77de738 ML |
3584 | @opindex fno-rtti |
3585 | @opindex frtti | |
ddf6fe37 | 3586 | @item -fno-rtti |
d77de738 ML |
3587 | Disable generation of information about every class with virtual |
3588 | functions for use by the C++ run-time type identification features | |
3589 | (@code{dynamic_cast} and @code{typeid}). If you don't use those parts | |
3590 | of the language, you can save some space by using this flag. Note that | |
3591 | exception handling uses the same information, but G++ generates it as | |
3592 | needed. The @code{dynamic_cast} operator can still be used for casts that | |
3593 | do not require run-time type information, i.e.@: casts to @code{void *} or to | |
3594 | unambiguous base classes. | |
3595 | ||
3596 | Mixing code compiled with @option{-frtti} with that compiled with | |
3597 | @option{-fno-rtti} may not work. For example, programs may | |
3598 | fail to link if a class compiled with @option{-fno-rtti} is used as a base | |
3599 | for a class compiled with @option{-frtti}. | |
3600 | ||
d77de738 | 3601 | @opindex fsized-deallocation |
ddf6fe37 | 3602 | @item -fsized-deallocation |
d77de738 ML |
3603 | Enable the built-in global declarations |
3604 | @smallexample | |
3605 | void operator delete (void *, std::size_t) noexcept; | |
3606 | void operator delete[] (void *, std::size_t) noexcept; | |
3607 | @end smallexample | |
3608 | as introduced in C++14. This is useful for user-defined replacement | |
3609 | deallocation functions that, for example, use the size of the object | |
3610 | to make deallocation faster. Enabled by default under | |
3611 | @option{-std=c++14} and above. The flag @option{-Wsized-deallocation} | |
3612 | warns about places that might want to add a definition. | |
3613 | ||
d77de738 | 3614 | @opindex fstrict-enums |
ddf6fe37 | 3615 | @item -fstrict-enums |
d77de738 ML |
3616 | Allow the compiler to optimize using the assumption that a value of |
3617 | enumerated type can only be one of the values of the enumeration (as | |
3618 | defined in the C++ standard; basically, a value that can be | |
3619 | represented in the minimum number of bits needed to represent all the | |
3620 | enumerators). This assumption may not be valid if the program uses a | |
3621 | cast to convert an arbitrary integer value to the enumerated type. | |
d8a656d5 JW |
3622 | This option has no effect for an enumeration type with a fixed underlying |
3623 | type. | |
d77de738 | 3624 | |
d77de738 | 3625 | @opindex fstrong-eval-order |
ddf6fe37 | 3626 | @item -fstrong-eval-order |
d77de738 ML |
3627 | Evaluate member access, array subscripting, and shift expressions in |
3628 | left-to-right order, and evaluate assignment in right-to-left order, | |
3629 | as adopted for C++17. Enabled by default with @option{-std=c++17}. | |
3630 | @option{-fstrong-eval-order=some} enables just the ordering of member | |
3631 | access and shift expressions, and is the default without | |
3632 | @option{-std=c++17}. | |
3633 | ||
d77de738 | 3634 | @opindex ftemplate-backtrace-limit |
ddf6fe37 | 3635 | @item -ftemplate-backtrace-limit=@var{n} |
d77de738 ML |
3636 | Set the maximum number of template instantiation notes for a single |
3637 | warning or error to @var{n}. The default value is 10. | |
3638 | ||
d77de738 | 3639 | @opindex ftemplate-depth |
ddf6fe37 | 3640 | @item -ftemplate-depth=@var{n} |
d77de738 ML |
3641 | Set the maximum instantiation depth for template classes to @var{n}. |
3642 | A limit on the template instantiation depth is needed to detect | |
3643 | endless recursions during template class instantiation. ANSI/ISO C++ | |
3644 | conforming programs must not rely on a maximum depth greater than 17 | |
3645 | (changed to 1024 in C++11). The default value is 900, as the compiler | |
3646 | can run out of stack space before hitting 1024 in some situations. | |
3647 | ||
d77de738 ML |
3648 | @opindex fno-threadsafe-statics |
3649 | @opindex fthreadsafe-statics | |
ddf6fe37 | 3650 | @item -fno-threadsafe-statics |
d77de738 ML |
3651 | Do not emit the extra code to use the routines specified in the C++ |
3652 | ABI for thread-safe initialization of local statics. You can use this | |
3653 | option to reduce code size slightly in code that doesn't need to be | |
3654 | thread-safe. | |
3655 | ||
d77de738 | 3656 | @opindex fuse-cxa-atexit |
ddf6fe37 | 3657 | @item -fuse-cxa-atexit |
d77de738 ML |
3658 | Register destructors for objects with static storage duration with the |
3659 | @code{__cxa_atexit} function rather than the @code{atexit} function. | |
3660 | This option is required for fully standards-compliant handling of static | |
3661 | destructors, but only works if your C library supports | |
3662 | @code{__cxa_atexit}. | |
3663 | ||
d77de738 ML |
3664 | @opindex fno-use-cxa-get-exception-ptr |
3665 | @opindex fuse-cxa-get-exception-ptr | |
ddf6fe37 | 3666 | @item -fno-use-cxa-get-exception-ptr |
d77de738 ML |
3667 | Don't use the @code{__cxa_get_exception_ptr} runtime routine. This |
3668 | causes @code{std::uncaught_exception} to be incorrect, but is necessary | |
3669 | if the runtime routine is not available. | |
3670 | ||
d77de738 | 3671 | @opindex fvisibility-inlines-hidden |
ddf6fe37 | 3672 | @item -fvisibility-inlines-hidden |
d77de738 ML |
3673 | This switch declares that the user does not attempt to compare |
3674 | pointers to inline functions or methods where the addresses of the two functions | |
3675 | are taken in different shared objects. | |
3676 | ||
3677 | The effect of this is that GCC may, effectively, mark inline methods with | |
3678 | @code{__attribute__ ((visibility ("hidden")))} so that they do not | |
3679 | appear in the export table of a DSO and do not require a PLT indirection | |
3680 | when used within the DSO@. Enabling this option can have a dramatic effect | |
3681 | on load and link times of a DSO as it massively reduces the size of the | |
3682 | dynamic export table when the library makes heavy use of templates. | |
3683 | ||
3684 | The behavior of this switch is not quite the same as marking the | |
3685 | methods as hidden directly, because it does not affect static variables | |
3686 | local to the function or cause the compiler to deduce that | |
3687 | the function is defined in only one shared object. | |
3688 | ||
3689 | You may mark a method as having a visibility explicitly to negate the | |
3690 | effect of the switch for that method. For example, if you do want to | |
3691 | compare pointers to a particular inline method, you might mark it as | |
3692 | having default visibility. Marking the enclosing class with explicit | |
3693 | visibility has no effect. | |
3694 | ||
3695 | Explicitly instantiated inline methods are unaffected by this option | |
3696 | as their linkage might otherwise cross a shared library boundary. | |
3697 | @xref{Template Instantiation}. | |
3698 | ||
d77de738 | 3699 | @opindex fvisibility-ms-compat |
ddf6fe37 | 3700 | @item -fvisibility-ms-compat |
d77de738 ML |
3701 | This flag attempts to use visibility settings to make GCC's C++ |
3702 | linkage model compatible with that of Microsoft Visual Studio. | |
3703 | ||
3704 | The flag makes these changes to GCC's linkage model: | |
3705 | ||
3706 | @enumerate | |
3707 | @item | |
3708 | It sets the default visibility to @code{hidden}, like | |
3709 | @option{-fvisibility=hidden}. | |
3710 | ||
3711 | @item | |
3712 | Types, but not their members, are not hidden by default. | |
3713 | ||
3714 | @item | |
3715 | The One Definition Rule is relaxed for types without explicit | |
3716 | visibility specifications that are defined in more than one | |
3717 | shared object: those declarations are permitted if they are | |
3718 | permitted when this option is not used. | |
3719 | @end enumerate | |
3720 | ||
3721 | In new code it is better to use @option{-fvisibility=hidden} and | |
3722 | export those classes that are intended to be externally visible. | |
3723 | Unfortunately it is possible for code to rely, perhaps accidentally, | |
3724 | on the Visual Studio behavior. | |
3725 | ||
3726 | Among the consequences of these changes are that static data members | |
3727 | of the same type with the same name but defined in different shared | |
3728 | objects are different, so changing one does not change the other; | |
3729 | and that pointers to function members defined in different shared | |
3730 | objects may not compare equal. When this flag is given, it is a | |
3731 | violation of the ODR to define types with the same name differently. | |
3732 | ||
d77de738 ML |
3733 | @opindex fno-weak |
3734 | @opindex fweak | |
ddf6fe37 | 3735 | @item -fno-weak |
d77de738 ML |
3736 | Do not use weak symbol support, even if it is provided by the linker. |
3737 | By default, G++ uses weak symbols if they are available. This | |
3738 | option exists only for testing, and should not be used by end-users; | |
3739 | it results in inferior code and has no benefits. This option may | |
3740 | be removed in a future release of G++. | |
3741 | ||
d77de738 ML |
3742 | @opindex fext-numeric-literals |
3743 | @opindex fno-ext-numeric-literals | |
ddf6fe37 | 3744 | @item -fext-numeric-literals @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3745 | Accept imaginary, fixed-point, or machine-defined |
3746 | literal number suffixes as GNU extensions. | |
3747 | When this option is turned off these suffixes are treated | |
3748 | as C++11 user-defined literal numeric suffixes. | |
3749 | This is on by default for all pre-C++11 dialects and all GNU dialects: | |
3750 | @option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11}, | |
3751 | @option{-std=gnu++14}. | |
3752 | This option is off by default | |
3753 | for ISO C++11 onwards (@option{-std=c++11}, ...). | |
3754 | ||
d77de738 | 3755 | @opindex nostdinc++ |
ddf6fe37 | 3756 | @item -nostdinc++ |
d77de738 ML |
3757 | Do not search for header files in the standard directories specific to |
3758 | C++, but do still search the other standard directories. (This option | |
3759 | is used when building the C++ library.) | |
3760 | ||
ddf6fe37 AA |
3761 | @opindex flang-info-include-translate |
3762 | @opindex flang-info-include-translate-not | |
d77de738 ML |
3763 | @item -flang-info-include-translate |
3764 | @itemx -flang-info-include-translate-not | |
3765 | @itemx -flang-info-include-translate=@var{header} | |
d77de738 ML |
3766 | Inform of include translation events. The first will note accepted |
3767 | include translations, the second will note declined include | |
3768 | translations. The @var{header} form will inform of include | |
3769 | translations relating to that specific header. If @var{header} is of | |
3770 | the form @code{"user"} or @code{<system>} it will be resolved to a | |
3771 | specific user or system header using the include path. | |
3772 | ||
ddf6fe37 | 3773 | @opindex flang-info-module-cmi |
d77de738 ML |
3774 | @item -flang-info-module-cmi |
3775 | @itemx -flang-info-module-cmi=@var{module} | |
d77de738 ML |
3776 | Inform of Compiled Module Interface pathnames. The first will note |
3777 | all read CMI pathnames. The @var{module} form will not reading a | |
3778 | specific module's CMI. @var{module} may be a named module or a | |
3779 | header-unit (the latter indicated by either being a pathname containing | |
3780 | directory separators or enclosed in @code{<>} or @code{""}). | |
3781 | ||
d77de738 | 3782 | @opindex stdlib |
ddf6fe37 | 3783 | @item -stdlib=@var{libstdc++,libc++} |
d77de738 ML |
3784 | When G++ is configured to support this option, it allows specification of |
3785 | alternate C++ runtime libraries. Two options are available: @var{libstdc++} | |
3786 | (the default, native C++ runtime for G++) and @var{libc++} which is the | |
3787 | C++ runtime installed on some operating systems (e.g. Darwin versions from | |
3788 | Darwin11 onwards). The option switches G++ to use the headers from the | |
3789 | specified library and to emit @code{-lstdc++} or @code{-lc++} respectively, | |
3790 | when a C++ runtime is required for linking. | |
3791 | @end table | |
3792 | ||
3793 | In addition, these warning options have meanings only for C++ programs: | |
3794 | ||
3795 | @table @gcctabopt | |
d77de738 | 3796 | @opindex Wabi-tag |
ddf6fe37 | 3797 | @item -Wabi-tag @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3798 | Warn when a type with an ABI tag is used in a context that does not |
3799 | have that ABI tag. See @ref{C++ Attributes} for more information | |
3800 | about ABI tags. | |
3801 | ||
d77de738 ML |
3802 | @opindex Wcomma-subscript |
3803 | @opindex Wno-comma-subscript | |
ddf6fe37 | 3804 | @item -Wcomma-subscript @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3805 | Warn about uses of a comma expression within a subscripting expression. |
3806 | This usage was deprecated in C++20 and is going to be removed in C++23. | |
3807 | However, a comma expression wrapped in @code{( )} is not deprecated. Example: | |
3808 | ||
3809 | @smallexample | |
3810 | @group | |
3811 | void f(int *a, int b, int c) @{ | |
3812 | a[b,c]; // deprecated in C++20, invalid in C++23 | |
3813 | a[(b,c)]; // OK | |
3814 | @} | |
3815 | @end group | |
3816 | @end smallexample | |
3817 | ||
3818 | In C++23 it is valid to have comma separated expressions in a subscript | |
3819 | when an overloaded subscript operator is found and supports the right | |
3820 | number and types of arguments. G++ will accept the formerly valid syntax | |
3821 | for code that is not valid in C++23 but used to be valid but deprecated | |
3822 | in C++20 with a pedantic warning that can be disabled with | |
3823 | @option{-Wno-comma-subscript}. | |
3824 | ||
3825 | Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated}, | |
3826 | and with @option{-std=c++23} regardless of @option{-Wno-deprecated}. | |
3827 | ||
5fccebdb JM |
3828 | This warning is upgraded to an error by @option{-pedantic-errors} in |
3829 | C++23 mode or later. | |
3830 | ||
d77de738 ML |
3831 | @opindex Wctad-maybe-unsupported |
3832 | @opindex Wno-ctad-maybe-unsupported | |
ddf6fe37 | 3833 | @item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3834 | Warn when performing class template argument deduction (CTAD) on a type with |
3835 | no explicitly written deduction guides. This warning will point out cases | |
3836 | where CTAD succeeded only because the compiler synthesized the implicit | |
3837 | deduction guides, which might not be what the programmer intended. Certain | |
3838 | style guides allow CTAD only on types that specifically "opt-in"; i.e., on | |
3839 | types that are designed to support CTAD. This warning can be suppressed with | |
3840 | the following pattern: | |
3841 | ||
3842 | @smallexample | |
3843 | struct allow_ctad_t; // any name works | |
3844 | template <typename T> struct S @{ | |
3845 | S(T) @{ @} | |
3846 | @}; | |
4ace81b6 SL |
3847 | // Guide with incomplete parameter type will never be considered. |
3848 | S(allow_ctad_t) -> S<void>; | |
d77de738 ML |
3849 | @end smallexample |
3850 | ||
d77de738 ML |
3851 | @opindex Wctor-dtor-privacy |
3852 | @opindex Wno-ctor-dtor-privacy | |
ddf6fe37 | 3853 | @item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3854 | Warn when a class seems unusable because all the constructors or |
3855 | destructors in that class are private, and it has neither friends nor | |
3856 | public static member functions. Also warn if there are no non-private | |
3857 | methods, and there's at least one private member function that isn't | |
3858 | a constructor or destructor. | |
3859 | ||
d77de738 ML |
3860 | @opindex Wdangling-reference |
3861 | @opindex Wno-dangling-reference | |
ddf6fe37 | 3862 | @item -Wdangling-reference @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3863 | Warn when a reference is bound to a temporary whose lifetime has ended. |
3864 | For example: | |
3865 | ||
3866 | @smallexample | |
3867 | int n = 1; | |
3868 | const int& r = std::max(n - 1, n + 1); // r is dangling | |
3869 | @end smallexample | |
3870 | ||
3871 | In the example above, two temporaries are created, one for each | |
3872 | argument, and a reference to one of the temporaries is returned. | |
3873 | However, both temporaries are destroyed at the end of the full | |
3874 | expression, so the reference @code{r} is dangling. This warning | |
3875 | also detects dangling references in member initializer lists: | |
3876 | ||
3877 | @smallexample | |
3878 | const int& f(const int& i) @{ return i; @} | |
3879 | struct S @{ | |
3880 | const int &r; // r is dangling | |
3881 | S() : r(f(10)) @{ @} | |
3882 | @}; | |
3883 | @end smallexample | |
3884 | ||
3885 | Member functions are checked as well, but only their object argument: | |
3886 | ||
3887 | @smallexample | |
3888 | struct S @{ | |
3889 | const S& self () @{ return *this; @} | |
3890 | @}; | |
3891 | const S& s = S().self(); // s is dangling | |
3892 | @end smallexample | |
3893 | ||
3894 | Certain functions are safe in this respect, for example @code{std::use_facet}: | |
3895 | they take and return a reference, but they don't return one of its arguments, | |
3896 | which can fool the warning. Such functions can be excluded from the warning | |
3897 | by wrapping them in a @code{#pragma}: | |
3898 | ||
3899 | @smallexample | |
3900 | #pragma GCC diagnostic push | |
3901 | #pragma GCC diagnostic ignored "-Wdangling-reference" | |
3902 | const T& foo (const T&) @{ @dots{} @} | |
3903 | #pragma GCC diagnostic pop | |
3904 | @end smallexample | |
3905 | ||
ce51e843 ML |
3906 | @option{-Wdangling-reference} also warns about code like |
3907 | ||
3908 | @smallexample | |
3909 | auto p = std::minmax(1, 2); | |
3910 | @end smallexample | |
3911 | ||
3912 | where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and | |
3913 | both references dangle after the end of the full expression that contains | |
3914 | the call to @code{std::minmax}. | |
3915 | ||
d77de738 ML |
3916 | This warning is enabled by @option{-Wall}. |
3917 | ||
d77de738 ML |
3918 | @opindex Wdelete-non-virtual-dtor |
3919 | @opindex Wno-delete-non-virtual-dtor | |
ddf6fe37 | 3920 | @item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3921 | Warn when @code{delete} is used to destroy an instance of a class that |
3922 | has virtual functions and non-virtual destructor. It is unsafe to delete | |
3923 | an instance of a derived class through a pointer to a base class if the | |
3924 | base class does not have a virtual destructor. This warning is enabled | |
3925 | by @option{-Wall}. | |
3926 | ||
d77de738 ML |
3927 | @opindex Wdeprecated-copy |
3928 | @opindex Wno-deprecated-copy | |
ddf6fe37 | 3929 | @item -Wdeprecated-copy @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3930 | Warn that the implicit declaration of a copy constructor or copy |
3931 | assignment operator is deprecated if the class has a user-provided | |
3932 | copy constructor or copy assignment operator, in C++11 and up. This | |
3933 | warning is enabled by @option{-Wextra}. With | |
3934 | @option{-Wdeprecated-copy-dtor}, also deprecate if the class has a | |
3935 | user-provided destructor. | |
3936 | ||
d77de738 ML |
3937 | @opindex Wdeprecated-enum-enum-conversion |
3938 | @opindex Wno-deprecated-enum-enum-conversion | |
ddf6fe37 | 3939 | @item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3940 | Disable the warning about the case when the usual arithmetic conversions |
3941 | are applied on operands where one is of enumeration type and the other is | |
3942 | of a different enumeration type. This conversion was deprecated in C++20. | |
3943 | For example: | |
3944 | ||
3945 | @smallexample | |
3946 | enum E1 @{ e @}; | |
3947 | enum E2 @{ f @}; | |
3948 | int k = f - e; | |
3949 | @end smallexample | |
3950 | ||
3951 | @option{-Wdeprecated-enum-enum-conversion} is enabled by default with | |
3952 | @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled | |
3953 | by @option{-Wenum-conversion}. | |
3954 | ||
d77de738 ML |
3955 | @opindex Wdeprecated-enum-float-conversion |
3956 | @opindex Wno-deprecated-enum-float-conversion | |
ddf6fe37 | 3957 | @item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3958 | Disable the warning about the case when the usual arithmetic conversions |
3959 | are applied on operands where one is of enumeration type and the other is | |
3960 | of a floating-point type. This conversion was deprecated in C++20. For | |
3961 | example: | |
3962 | ||
3963 | @smallexample | |
3964 | enum E1 @{ e @}; | |
3965 | enum E2 @{ f @}; | |
3966 | bool b = e <= 3.7; | |
3967 | @end smallexample | |
3968 | ||
3969 | @option{-Wdeprecated-enum-float-conversion} is enabled by default with | |
3970 | @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled | |
3971 | by @option{-Wenum-conversion}. | |
3972 | ||
b106f11d AC |
3973 | @opindex Welaborated-enum-base |
3974 | @opindex Wno-elaborated-enum-base | |
3975 | @item -Wno-elaborated-enum-base | |
3976 | For C++11 and above, warn if an (invalid) additional enum-base is used | |
3977 | in an elaborated-type-specifier. That is, if an enum with given | |
3978 | underlying type and no enumerator list is used in a declaration other | |
3979 | than just a standalone declaration of the enum. Enabled by default. This | |
3980 | warning is upgraded to an error with -pedantic-errors. | |
3981 | ||
d77de738 ML |
3982 | @opindex Winit-list-lifetime |
3983 | @opindex Wno-init-list-lifetime | |
ddf6fe37 | 3984 | @item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3985 | Do not warn about uses of @code{std::initializer_list} that are likely |
3986 | to result in dangling pointers. Since the underlying array for an | |
3987 | @code{initializer_list} is handled like a normal C++ temporary object, | |
3988 | it is easy to inadvertently keep a pointer to the array past the end | |
3989 | of the array's lifetime. For example: | |
3990 | ||
3991 | @itemize @bullet | |
3992 | @item | |
3993 | If a function returns a temporary @code{initializer_list}, or a local | |
3994 | @code{initializer_list} variable, the array's lifetime ends at the end | |
3995 | of the return statement, so the value returned has a dangling pointer. | |
3996 | ||
3997 | @item | |
3998 | If a new-expression creates an @code{initializer_list}, the array only | |
3999 | lives until the end of the enclosing full-expression, so the | |
4000 | @code{initializer_list} in the heap has a dangling pointer. | |
4001 | ||
4002 | @item | |
4003 | When an @code{initializer_list} variable is assigned from a | |
4004 | brace-enclosed initializer list, the temporary array created for the | |
4005 | right side of the assignment only lives until the end of the | |
4006 | full-expression, so at the next statement the @code{initializer_list} | |
4007 | variable has a dangling pointer. | |
4008 | ||
4009 | @smallexample | |
4010 | // li's initial underlying array lives as long as li | |
4011 | std::initializer_list<int> li = @{ 1,2,3 @}; | |
4012 | // assignment changes li to point to a temporary array | |
4013 | li = @{ 4, 5 @}; | |
4014 | // now the temporary is gone and li has a dangling pointer | |
4015 | int i = li.begin()[0] // undefined behavior | |
4016 | @end smallexample | |
4017 | ||
4018 | @item | |
4019 | When a list constructor stores the @code{begin} pointer from the | |
4020 | @code{initializer_list} argument, this doesn't extend the lifetime of | |
4021 | the array, so if a class variable is constructed from a temporary | |
4022 | @code{initializer_list}, the pointer is left dangling by the end of | |
4023 | the variable declaration statement. | |
4024 | ||
4025 | @end itemize | |
4026 | ||
c85f8dbb MP |
4027 | @opindex Winvalid-constexpr |
4028 | @opindex Wno-invalid-constexpr | |
ddf6fe37 | 4029 | @item -Winvalid-constexpr |
c85f8dbb MP |
4030 | |
4031 | Warn when a function never produces a constant expression. In C++20 | |
4032 | and earlier, for every @code{constexpr} function and function template, | |
4033 | there must be at least one set of function arguments in at least one | |
4034 | instantiation such that an invocation of the function or constructor | |
4035 | could be an evaluated subexpression of a core constant expression. | |
4036 | C++23 removed this restriction, so it's possible to have a function | |
4037 | or a function template marked @code{constexpr} for which no invocation | |
4038 | satisfies the requirements of a core constant expression. | |
4039 | ||
4040 | This warning is enabled as a pedantic warning by default in C++20 and | |
4041 | earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in | |
4042 | which case it will be an ordinary warning. For example: | |
4043 | ||
4044 | @smallexample | |
4045 | void f (int& i); | |
4046 | constexpr void | |
4047 | g (int& i) | |
4048 | @{ | |
4ace81b6 SL |
4049 | // Warns by default in C++20, in C++23 only with -Winvalid-constexpr. |
4050 | f(i); | |
c85f8dbb MP |
4051 | @} |
4052 | @end smallexample | |
4053 | ||
d77de738 ML |
4054 | @opindex Winvalid-imported-macros |
4055 | @opindex Wno-invalid-imported-macros | |
ddf6fe37 | 4056 | @item -Winvalid-imported-macros |
d77de738 ML |
4057 | Verify all imported macro definitions are valid at the end of |
4058 | compilation. This is not enabled by default, as it requires | |
4059 | additional processing to determine. It may be useful when preparing | |
4060 | sets of header-units to ensure consistent macros. | |
4061 | ||
d77de738 ML |
4062 | @opindex Wliteral-suffix |
4063 | @opindex Wno-literal-suffix | |
ddf6fe37 | 4064 | @item -Wno-literal-suffix @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4065 | Do not warn when a string or character literal is followed by a |
4066 | ud-suffix which does not begin with an underscore. As a conforming | |
4067 | extension, GCC treats such suffixes as separate preprocessing tokens | |
4068 | in order to maintain backwards compatibility with code that uses | |
4069 | formatting macros from @code{<inttypes.h>}. For example: | |
4070 | ||
4071 | @smallexample | |
4072 | #define __STDC_FORMAT_MACROS | |
4073 | #include <inttypes.h> | |
4074 | #include <stdio.h> | |
4075 | ||
4076 | int main() @{ | |
4077 | int64_t i64 = 123; | |
4078 | printf("My int64: %" PRId64"\n", i64); | |
4079 | @} | |
4080 | @end smallexample | |
4081 | ||
4082 | In this case, @code{PRId64} is treated as a separate preprocessing token. | |
4083 | ||
4084 | This option also controls warnings when a user-defined literal | |
4085 | operator is declared with a literal suffix identifier that doesn't | |
4086 | begin with an underscore. Literal suffix identifiers that don't begin | |
4087 | with an underscore are reserved for future standardization. | |
4088 | ||
4089 | These warnings are enabled by default. | |
4090 | ||
d77de738 ML |
4091 | @opindex Wnarrowing |
4092 | @opindex Wno-narrowing | |
ddf6fe37 | 4093 | @item -Wno-narrowing @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4094 | For C++11 and later standards, narrowing conversions are diagnosed by default, |
4095 | as required by the standard. A narrowing conversion from a constant produces | |
4096 | an error, and a narrowing conversion from a non-constant produces a warning, | |
4097 | but @option{-Wno-narrowing} suppresses the diagnostic. | |
4098 | Note that this does not affect the meaning of well-formed code; | |
4099 | narrowing conversions are still considered ill-formed in SFINAE contexts. | |
4100 | ||
4101 | With @option{-Wnarrowing} in C++98, warn when a narrowing | |
4102 | conversion prohibited by C++11 occurs within | |
4103 | @samp{@{ @}}, e.g. | |
4104 | ||
4105 | @smallexample | |
4106 | int i = @{ 2.2 @}; // error: narrowing from double to int | |
4107 | @end smallexample | |
4108 | ||
4109 | This flag is included in @option{-Wall} and @option{-Wc++11-compat}. | |
4110 | ||
d77de738 ML |
4111 | @opindex Wnoexcept |
4112 | @opindex Wno-noexcept | |
ddf6fe37 | 4113 | @item -Wnoexcept @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4114 | Warn when a noexcept-expression evaluates to false because of a call |
4115 | to a function that does not have a non-throwing exception | |
4116 | specification (i.e. @code{throw()} or @code{noexcept}) but is known by | |
4117 | the compiler to never throw an exception. | |
4118 | ||
d77de738 ML |
4119 | @opindex Wnoexcept-type |
4120 | @opindex Wno-noexcept-type | |
ddf6fe37 | 4121 | @item -Wnoexcept-type @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4122 | Warn if the C++17 feature making @code{noexcept} part of a function |
4123 | type changes the mangled name of a symbol relative to C++14. Enabled | |
4124 | by @option{-Wabi} and @option{-Wc++17-compat}. | |
4125 | ||
4126 | As an example: | |
4127 | ||
4128 | @smallexample | |
4129 | template <class T> void f(T t) @{ t(); @}; | |
4130 | void g() noexcept; | |
4131 | void h() @{ f(g); @} | |
4132 | @end smallexample | |
4133 | ||
4134 | @noindent | |
4135 | In C++14, @code{f} calls @code{f<void(*)()>}, but in | |
4136 | C++17 it calls @code{f<void(*)()noexcept>}. | |
4137 | ||
d77de738 ML |
4138 | @opindex Wclass-memaccess |
4139 | @opindex Wno-class-memaccess | |
ddf6fe37 | 4140 | @item -Wclass-memaccess @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4141 | Warn when the destination of a call to a raw memory function such as |
4142 | @code{memset} or @code{memcpy} is an object of class type, and when writing | |
4143 | into such an object might bypass the class non-trivial or deleted constructor | |
4144 | or copy assignment, violate const-correctness or encapsulation, or corrupt | |
4145 | virtual table pointers. Modifying the representation of such objects may | |
4146 | violate invariants maintained by member functions of the class. For example, | |
4147 | the call to @code{memset} below is undefined because it modifies a non-trivial | |
4148 | class object and is, therefore, diagnosed. The safe way to either initialize | |
4149 | or clear the storage of objects of such types is by using the appropriate | |
4150 | constructor or assignment operator, if one is available. | |
4151 | @smallexample | |
4152 | std::string str = "abc"; | |
4153 | memset (&str, 0, sizeof str); | |
4154 | @end smallexample | |
4155 | The @option{-Wclass-memaccess} option is enabled by @option{-Wall}. | |
4156 | Explicitly casting the pointer to the class object to @code{void *} or | |
4157 | to a type that can be safely accessed by the raw memory function suppresses | |
4158 | the warning. | |
4159 | ||
d77de738 ML |
4160 | @opindex Wnon-virtual-dtor |
4161 | @opindex Wno-non-virtual-dtor | |
ddf6fe37 | 4162 | @item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4163 | Warn when a class has virtual functions and an accessible non-virtual |
4164 | destructor itself or in an accessible polymorphic base class, in which | |
4165 | case it is possible but unsafe to delete an instance of a derived | |
4166 | class through a pointer to the class itself or base class. This | |
4167 | warning is automatically enabled if @option{-Weffc++} is specified. | |
51f28e3a JW |
4168 | The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall}) |
4169 | should be preferred because it warns about the unsafe cases without false | |
4170 | positives. | |
d77de738 | 4171 | |
d77de738 ML |
4172 | @opindex Wregister |
4173 | @opindex Wno-register | |
ddf6fe37 | 4174 | @item -Wregister @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4175 | Warn on uses of the @code{register} storage class specifier, except |
4176 | when it is part of the GNU @ref{Explicit Register Variables} extension. | |
4177 | The use of the @code{register} keyword as storage class specifier has | |
4178 | been deprecated in C++11 and removed in C++17. | |
4179 | Enabled by default with @option{-std=c++17}. | |
4180 | ||
d77de738 ML |
4181 | @opindex Wreorder |
4182 | @opindex Wno-reorder | |
4183 | @cindex reordering, warning | |
4184 | @cindex warning for reordering of member initializers | |
f33d7a88 | 4185 | @item -Wreorder @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4186 | Warn when the order of member initializers given in the code does not |
4187 | match the order in which they must be executed. For instance: | |
4188 | ||
4189 | @smallexample | |
4190 | struct A @{ | |
4191 | int i; | |
4192 | int j; | |
4193 | A(): j (0), i (1) @{ @} | |
4194 | @}; | |
4195 | @end smallexample | |
4196 | ||
4197 | @noindent | |
4198 | The compiler rearranges the member initializers for @code{i} | |
4199 | and @code{j} to match the declaration order of the members, emitting | |
4200 | a warning to that effect. This warning is enabled by @option{-Wall}. | |
4201 | ||
d77de738 ML |
4202 | @opindex Wpessimizing-move |
4203 | @opindex Wno-pessimizing-move | |
ddf6fe37 | 4204 | @item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4205 | This warning warns when a call to @code{std::move} prevents copy |
4206 | elision. A typical scenario when copy elision can occur is when returning in | |
4207 | a function with a class return type, when the expression being returned is the | |
4208 | name of a non-volatile automatic object, and is not a function parameter, and | |
4209 | has the same type as the function return type. | |
4210 | ||
4211 | @smallexample | |
4212 | struct T @{ | |
4213 | @dots{} | |
4214 | @}; | |
4215 | T fn() | |
4216 | @{ | |
4217 | T t; | |
4218 | @dots{} | |
4219 | return std::move (t); | |
4220 | @} | |
4221 | @end smallexample | |
4222 | ||
4223 | But in this example, the @code{std::move} call prevents copy elision. | |
4224 | ||
4225 | This warning is enabled by @option{-Wall}. | |
4226 | ||
d77de738 ML |
4227 | @opindex Wredundant-move |
4228 | @opindex Wno-redundant-move | |
ddf6fe37 | 4229 | @item -Wno-redundant-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4230 | This warning warns about redundant calls to @code{std::move}; that is, when |
4231 | a move operation would have been performed even without the @code{std::move} | |
4232 | call. This happens because the compiler is forced to treat the object as if | |
4233 | it were an rvalue in certain situations such as returning a local variable, | |
4234 | where copy elision isn't applicable. Consider: | |
4235 | ||
4236 | @smallexample | |
4237 | struct T @{ | |
4238 | @dots{} | |
4239 | @}; | |
4240 | T fn(T t) | |
4241 | @{ | |
4242 | @dots{} | |
4243 | return std::move (t); | |
4244 | @} | |
4245 | @end smallexample | |
4246 | ||
4247 | Here, the @code{std::move} call is redundant. Because G++ implements Core | |
4248 | Issue 1579, another example is: | |
4249 | ||
4250 | @smallexample | |
4251 | struct T @{ // convertible to U | |
4252 | @dots{} | |
4253 | @}; | |
4254 | struct U @{ | |
4255 | @dots{} | |
4256 | @}; | |
4257 | U fn() | |
4258 | @{ | |
4259 | T t; | |
4260 | @dots{} | |
4261 | return std::move (t); | |
4262 | @} | |
4263 | @end smallexample | |
4264 | In this example, copy elision isn't applicable because the type of the | |
4265 | expression being returned and the function return type differ, yet G++ | |
4266 | treats the return value as if it were designated by an rvalue. | |
4267 | ||
4268 | This warning is enabled by @option{-Wextra}. | |
4269 | ||
d77de738 ML |
4270 | @opindex Wrange-loop-construct |
4271 | @opindex Wno-range-loop-construct | |
ddf6fe37 | 4272 | @item -Wrange-loop-construct @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4273 | This warning warns when a C++ range-based for-loop is creating an unnecessary |
4274 | copy. This can happen when the range declaration is not a reference, but | |
4275 | probably should be. For example: | |
4276 | ||
4277 | @smallexample | |
4278 | struct S @{ char arr[128]; @}; | |
4279 | void fn () @{ | |
4280 | S arr[5]; | |
4281 | for (const auto x : arr) @{ @dots{} @} | |
4282 | @} | |
4283 | @end smallexample | |
4284 | ||
4285 | It does not warn when the type being copied is a trivially-copyable type whose | |
4286 | size is less than 64 bytes. | |
4287 | ||
4288 | This warning also warns when a loop variable in a range-based for-loop is | |
4289 | initialized with a value of a different type resulting in a copy. For example: | |
4290 | ||
4291 | @smallexample | |
4292 | void fn() @{ | |
4293 | int arr[10]; | |
4294 | for (const double &x : arr) @{ @dots{} @} | |
4295 | @} | |
4296 | @end smallexample | |
4297 | ||
4298 | In the example above, in every iteration of the loop a temporary value of | |
4299 | type @code{double} is created and destroyed, to which the reference | |
4300 | @code{const double &} is bound. | |
4301 | ||
4302 | This warning is enabled by @option{-Wall}. | |
4303 | ||
d77de738 ML |
4304 | @opindex Wredundant-tags |
4305 | @opindex Wno-redundant-tags | |
ddf6fe37 | 4306 | @item -Wredundant-tags @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4307 | Warn about redundant class-key and enum-key in references to class types |
4308 | and enumerated types in contexts where the key can be eliminated without | |
4309 | causing an ambiguity. For example: | |
4310 | ||
4311 | @smallexample | |
4312 | struct foo; | |
4313 | struct foo *p; // warn that keyword struct can be eliminated | |
4314 | @end smallexample | |
4315 | ||
4316 | @noindent | |
4317 | On the other hand, in this example there is no warning: | |
4318 | ||
4319 | @smallexample | |
4320 | struct foo; | |
4321 | void foo (); // "hides" struct foo | |
4322 | void bar (struct foo&); // no warning, keyword struct is necessary | |
4323 | @end smallexample | |
4324 | ||
d77de738 ML |
4325 | @opindex Wsubobject-linkage |
4326 | @opindex Wno-subobject-linkage | |
ddf6fe37 | 4327 | @item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4328 | Do not warn |
4329 | if a class type has a base or a field whose type uses the anonymous | |
4330 | namespace or depends on a type with no linkage. If a type A depends on | |
4331 | a type B with no or internal linkage, defining it in multiple | |
4332 | translation units would be an ODR violation because the meaning of B | |
4333 | is different in each translation unit. If A only appears in a single | |
4334 | translation unit, the best way to silence the warning is to give it | |
4335 | internal linkage by putting it in an anonymous namespace as well. The | |
4336 | compiler doesn't give this warning for types defined in the main .C | |
4337 | file, as those are unlikely to have multiple definitions. | |
4338 | @option{-Wsubobject-linkage} is enabled by default. | |
4339 | ||
d77de738 ML |
4340 | @opindex Weffc++ |
4341 | @opindex Wno-effc++ | |
ddf6fe37 | 4342 | @item -Weffc++ @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4343 | Warn about violations of the following style guidelines from Scott Meyers' |
4344 | @cite{Effective C++} series of books: | |
4345 | ||
4346 | @itemize @bullet | |
4347 | @item | |
4348 | Define a copy constructor and an assignment operator for classes | |
4349 | with dynamically-allocated memory. | |
4350 | ||
4351 | @item | |
4352 | Prefer initialization to assignment in constructors. | |
4353 | ||
4354 | @item | |
4355 | Have @code{operator=} return a reference to @code{*this}. | |
4356 | ||
4357 | @item | |
4358 | Don't try to return a reference when you must return an object. | |
4359 | ||
4360 | @item | |
4361 | Distinguish between prefix and postfix forms of increment and | |
4362 | decrement operators. | |
4363 | ||
4364 | @item | |
4365 | Never overload @code{&&}, @code{||}, or @code{,}. | |
4366 | ||
4367 | @end itemize | |
4368 | ||
4369 | This option also enables @option{-Wnon-virtual-dtor}, which is also | |
4370 | one of the effective C++ recommendations. However, the check is | |
4371 | extended to warn about the lack of virtual destructor in accessible | |
4372 | non-polymorphic bases classes too. | |
4373 | ||
4374 | When selecting this option, be aware that the standard library | |
4375 | headers do not obey all of these guidelines; use @samp{grep -v} | |
4376 | to filter out those warnings. | |
4377 | ||
d77de738 ML |
4378 | @opindex Wexceptions |
4379 | @opindex Wno-exceptions | |
ddf6fe37 | 4380 | @item -Wno-exceptions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4381 | Disable the warning about the case when an exception handler is shadowed by |
4382 | another handler, which can point out a wrong ordering of exception handlers. | |
4383 | ||
d77de738 ML |
4384 | @opindex Wstrict-null-sentinel |
4385 | @opindex Wno-strict-null-sentinel | |
ddf6fe37 | 4386 | @item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4387 | Warn about the use of an uncasted @code{NULL} as sentinel. When |
4388 | compiling only with GCC this is a valid sentinel, as @code{NULL} is defined | |
4389 | to @code{__null}. Although it is a null pointer constant rather than a | |
4390 | null pointer, it is guaranteed to be of the same size as a pointer. | |
4391 | But this use is not portable across different compilers. | |
4392 | ||
d77de738 ML |
4393 | @opindex Wno-non-template-friend |
4394 | @opindex Wnon-template-friend | |
ddf6fe37 | 4395 | @item -Wno-non-template-friend @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4396 | Disable warnings when non-template friend functions are declared |
4397 | within a template. In very old versions of GCC that predate implementation | |
4398 | of the ISO standard, declarations such as | |
4399 | @samp{friend int foo(int)}, where the name of the friend is an unqualified-id, | |
4400 | could be interpreted as a particular specialization of a template | |
4401 | function; the warning exists to diagnose compatibility problems, | |
4402 | and is enabled by default. | |
4403 | ||
d77de738 ML |
4404 | @opindex Wold-style-cast |
4405 | @opindex Wno-old-style-cast | |
ddf6fe37 | 4406 | @item -Wold-style-cast @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4407 | Warn if an old-style (C-style) cast to a non-void type is used within |
4408 | a C++ program. The new-style casts (@code{dynamic_cast}, | |
4409 | @code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are | |
4410 | less vulnerable to unintended effects and much easier to search for. | |
4411 | ||
d77de738 ML |
4412 | @opindex Woverloaded-virtual |
4413 | @opindex Wno-overloaded-virtual | |
4414 | @cindex overloaded virtual function, warning | |
4415 | @cindex warning for overloaded virtual function | |
f33d7a88 AA |
4416 | @item -Woverloaded-virtual @r{(C++ and Objective-C++ only)} |
4417 | @itemx -Woverloaded-virtual=@var{n} | |
d77de738 ML |
4418 | Warn when a function declaration hides virtual functions from a |
4419 | base class. For example, in: | |
4420 | ||
4421 | @smallexample | |
4422 | struct A @{ | |
4423 | virtual void f(); | |
4424 | @}; | |
4425 | ||
4426 | struct B: public A @{ | |
4427 | void f(int); // does not override | |
4428 | @}; | |
4429 | @end smallexample | |
4430 | ||
4431 | the @code{A} class version of @code{f} is hidden in @code{B}, and code | |
4432 | like: | |
4433 | ||
4434 | @smallexample | |
4435 | B* b; | |
4436 | b->f(); | |
4437 | @end smallexample | |
4438 | ||
4439 | @noindent | |
4440 | fails to compile. | |
4441 | ||
d82490d5 JW |
4442 | In cases where the different signatures are not an accident, the |
4443 | simplest solution is to add a using-declaration to the derived class | |
4444 | to un-hide the base function, e.g. add @code{using A::f;} to @code{B}. | |
4445 | ||
d77de738 ML |
4446 | The optional level suffix controls the behavior when all the |
4447 | declarations in the derived class override virtual functions in the | |
4448 | base class, even if not all of the base functions are overridden: | |
4449 | ||
4450 | @smallexample | |
4451 | struct C @{ | |
4452 | virtual void f(); | |
4453 | virtual void f(int); | |
4454 | @}; | |
4455 | ||
4456 | struct D: public C @{ | |
4457 | void f(int); // does override | |
4458 | @} | |
4459 | @end smallexample | |
4460 | ||
4461 | This pattern is less likely to be a mistake; if D is only used | |
4462 | virtually, the user might have decided that the base class semantics | |
4463 | for some of the overloads are fine. | |
4464 | ||
4465 | At level 1, this case does not warn; at level 2, it does. | |
4466 | @option{-Woverloaded-virtual} by itself selects level 2. Level 1 is | |
4467 | included in @option{-Wall}. | |
4468 | ||
d77de738 ML |
4469 | @opindex Wno-pmf-conversions |
4470 | @opindex Wpmf-conversions | |
ddf6fe37 | 4471 | @item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4472 | Disable the diagnostic for converting a bound pointer to member function |
4473 | to a plain pointer. | |
4474 | ||
d77de738 ML |
4475 | @opindex Wsign-promo |
4476 | @opindex Wno-sign-promo | |
ddf6fe37 | 4477 | @item -Wsign-promo @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4478 | Warn when overload resolution chooses a promotion from unsigned or |
4479 | enumerated type to a signed type, over a conversion to an unsigned type of | |
4480 | the same size. Previous versions of G++ tried to preserve | |
4481 | unsignedness, but the standard mandates the current behavior. | |
4482 | ||
d77de738 ML |
4483 | @opindex Wtemplates |
4484 | @opindex Wno-templates | |
ddf6fe37 | 4485 | @item -Wtemplates @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4486 | Warn when a primary template declaration is encountered. Some coding |
4487 | rules disallow templates, and this may be used to enforce that rule. | |
4488 | The warning is inactive inside a system header file, such as the STL, so | |
4489 | one can still use the STL. One may also instantiate or specialize | |
4490 | templates. | |
4491 | ||
d77de738 ML |
4492 | @opindex Wmismatched-new-delete |
4493 | @opindex Wno-mismatched-new-delete | |
ddf6fe37 | 4494 | @item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4495 | Warn for mismatches between calls to @code{operator new} or @code{operator |
4496 | delete} and the corresponding call to the allocation or deallocation function. | |
4497 | This includes invocations of C++ @code{operator delete} with pointers | |
4498 | returned from either mismatched forms of @code{operator new}, or from other | |
4499 | functions that allocate objects for which the @code{operator delete} isn't | |
4500 | a suitable deallocator, as well as calls to other deallocation functions | |
4501 | with pointers returned from @code{operator new} for which the deallocation | |
4502 | function isn't suitable. | |
4503 | ||
4504 | For example, the @code{delete} expression in the function below is diagnosed | |
4505 | because it doesn't match the array form of the @code{new} expression | |
4506 | the pointer argument was returned from. Similarly, the call to @code{free} | |
4507 | is also diagnosed. | |
4508 | ||
4509 | @smallexample | |
4510 | void f () | |
4511 | @{ | |
4512 | int *a = new int[n]; | |
4513 | delete a; // warning: mismatch in array forms of expressions | |
4514 | ||
4515 | char *p = new char[n]; | |
4516 | free (p); // warning: mismatch between new and free | |
4517 | @} | |
4518 | @end smallexample | |
4519 | ||
4520 | The related option @option{-Wmismatched-dealloc} diagnoses mismatches | |
4521 | involving allocation and deallocation functions other than @code{operator | |
4522 | new} and @code{operator delete}. | |
4523 | ||
4524 | @option{-Wmismatched-new-delete} is included in @option{-Wall}. | |
4525 | ||
d77de738 ML |
4526 | @opindex Wmismatched-tags |
4527 | @opindex Wno-mismatched-tags | |
ddf6fe37 | 4528 | @item -Wmismatched-tags @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4529 | Warn for declarations of structs, classes, and class templates and their |
4530 | specializations with a class-key that does not match either the definition | |
4531 | or the first declaration if no definition is provided. | |
4532 | ||
4533 | For example, the declaration of @code{struct Object} in the argument list | |
4534 | of @code{draw} triggers the warning. To avoid it, either remove the redundant | |
4535 | class-key @code{struct} or replace it with @code{class} to match its definition. | |
4536 | @smallexample | |
4537 | class Object @{ | |
4538 | public: | |
4539 | virtual ~Object () = 0; | |
4540 | @}; | |
4541 | void draw (struct Object*); | |
4542 | @end smallexample | |
4543 | ||
4544 | It is not wrong to declare a class with the class-key @code{struct} as | |
4545 | the example above shows. The @option{-Wmismatched-tags} option is intended | |
4546 | to help achieve a consistent style of class declarations. In code that is | |
4547 | intended to be portable to Windows-based compilers the warning helps prevent | |
4548 | unresolved references due to the difference in the mangling of symbols | |
4549 | declared with different class-keys. The option can be used either on its | |
4550 | own or in conjunction with @option{-Wredundant-tags}. | |
4551 | ||
d77de738 ML |
4552 | @opindex Wmultiple-inheritance |
4553 | @opindex Wno-multiple-inheritance | |
ddf6fe37 | 4554 | @item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4555 | Warn when a class is defined with multiple direct base classes. Some |
4556 | coding rules disallow multiple inheritance, and this may be used to | |
4557 | enforce that rule. The warning is inactive inside a system header file, | |
4558 | such as the STL, so one can still use the STL. One may also define | |
4559 | classes that indirectly use multiple inheritance. | |
4560 | ||
d77de738 ML |
4561 | @opindex Wvirtual-inheritance |
4562 | @opindex Wno-virtual-inheritance | |
ddf6fe37 | 4563 | @item -Wvirtual-inheritance |
d77de738 ML |
4564 | Warn when a class is defined with a virtual direct base class. Some |
4565 | coding rules disallow multiple inheritance, and this may be used to | |
4566 | enforce that rule. The warning is inactive inside a system header file, | |
4567 | such as the STL, so one can still use the STL. One may also define | |
4568 | classes that indirectly use virtual inheritance. | |
4569 | ||
d77de738 ML |
4570 | @opindex Wvirtual-move-assign |
4571 | @opindex Wno-virtual-move-assign | |
ddf6fe37 | 4572 | @item -Wno-virtual-move-assign |
d77de738 ML |
4573 | Suppress warnings about inheriting from a virtual base with a |
4574 | non-trivial C++11 move assignment operator. This is dangerous because | |
4575 | if the virtual base is reachable along more than one path, it is | |
4576 | moved multiple times, which can mean both objects end up in the | |
4577 | moved-from state. If the move assignment operator is written to avoid | |
4578 | moving from a moved-from object, this warning can be disabled. | |
4579 | ||
d77de738 ML |
4580 | @opindex Wnamespaces |
4581 | @opindex Wno-namespaces | |
ddf6fe37 | 4582 | @item -Wnamespaces |
d77de738 ML |
4583 | Warn when a namespace definition is opened. Some coding rules disallow |
4584 | namespaces, and this may be used to enforce that rule. The warning is | |
4585 | inactive inside a system header file, such as the STL, so one can still | |
4586 | use the STL. One may also use using directives and qualified names. | |
4587 | ||
d77de738 ML |
4588 | @opindex Wterminate |
4589 | @opindex Wno-terminate | |
ddf6fe37 | 4590 | @item -Wno-terminate @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4591 | Disable the warning about a throw-expression that will immediately |
4592 | result in a call to @code{terminate}. | |
4593 | ||
d77de738 ML |
4594 | @opindex Wvexing-parse |
4595 | @opindex Wno-vexing-parse | |
ddf6fe37 | 4596 | @item -Wno-vexing-parse @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4597 | Warn about the most vexing parse syntactic ambiguity. This warns about |
4598 | the cases when a declaration looks like a variable definition, but the | |
4599 | C++ language requires it to be interpreted as a function declaration. | |
4600 | For instance: | |
4601 | ||
4602 | @smallexample | |
4603 | void f(double a) @{ | |
4604 | int i(); // extern int i (void); | |
4605 | int n(int(a)); // extern int n (int); | |
4606 | @} | |
4607 | @end smallexample | |
4608 | ||
4609 | Another example: | |
4610 | ||
4611 | @smallexample | |
4612 | struct S @{ S(int); @}; | |
4613 | void f(double a) @{ | |
4614 | S x(int(a)); // extern struct S x (int); | |
4615 | S y(int()); // extern struct S y (int (*) (void)); | |
4616 | S z(); // extern struct S z (void); | |
4617 | @} | |
4618 | @end smallexample | |
4619 | ||
4620 | The warning will suggest options how to deal with such an ambiguity; e.g., | |
4621 | it can suggest removing the parentheses or using braces instead. | |
4622 | ||
4623 | This warning is enabled by default. | |
4624 | ||
d77de738 ML |
4625 | @opindex Wno-class-conversion |
4626 | @opindex Wclass-conversion | |
ddf6fe37 | 4627 | @item -Wno-class-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4628 | Do not warn when a conversion function converts an |
4629 | object to the same type, to a base class of that type, or to void; such | |
4630 | a conversion function will never be called. | |
4631 | ||
d77de738 ML |
4632 | @opindex Wvolatile |
4633 | @opindex Wno-volatile | |
ddf6fe37 | 4634 | @item -Wvolatile @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4635 | Warn about deprecated uses of the @code{volatile} qualifier. This includes |
4636 | postfix and prefix @code{++} and @code{--} expressions of | |
4637 | @code{volatile}-qualified types, using simple assignments where the left | |
4638 | operand is a @code{volatile}-qualified non-class type for their value, | |
4639 | compound assignments where the left operand is a @code{volatile}-qualified | |
4640 | non-class type, @code{volatile}-qualified function return type, | |
4641 | @code{volatile}-qualified parameter type, and structured bindings of a | |
4642 | @code{volatile}-qualified type. This usage was deprecated in C++20. | |
4643 | ||
4644 | Enabled by default with @option{-std=c++20}. | |
4645 | ||
d77de738 ML |
4646 | @opindex Wzero-as-null-pointer-constant |
4647 | @opindex Wno-zero-as-null-pointer-constant | |
ddf6fe37 | 4648 | @item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4649 | Warn when a literal @samp{0} is used as null pointer constant. This can |
4650 | be useful to facilitate the conversion to @code{nullptr} in C++11. | |
4651 | ||
d77de738 ML |
4652 | @opindex Waligned-new |
4653 | @opindex Wno-aligned-new | |
ddf6fe37 | 4654 | @item -Waligned-new |
d77de738 ML |
4655 | Warn about a new-expression of a type that requires greater alignment |
4656 | than the @code{alignof(std::max_align_t)} but uses an allocation | |
4657 | function without an explicit alignment parameter. This option is | |
4658 | enabled by @option{-Wall}. | |
4659 | ||
4660 | Normally this only warns about global allocation functions, but | |
4661 | @option{-Waligned-new=all} also warns about class member allocation | |
4662 | functions. | |
4663 | ||
d77de738 ML |
4664 | @opindex Wplacement-new |
4665 | @opindex Wno-placement-new | |
ddf6fe37 AA |
4666 | @item -Wno-placement-new |
4667 | @itemx -Wplacement-new=@var{n} | |
d77de738 ML |
4668 | Warn about placement new expressions with undefined behavior, such as |
4669 | constructing an object in a buffer that is smaller than the type of | |
4670 | the object. For example, the placement new expression below is diagnosed | |
4671 | because it attempts to construct an array of 64 integers in a buffer only | |
4672 | 64 bytes large. | |
4673 | @smallexample | |
4674 | char buf [64]; | |
4675 | new (buf) int[64]; | |
4676 | @end smallexample | |
4677 | This warning is enabled by default. | |
4678 | ||
4679 | @table @gcctabopt | |
4680 | @item -Wplacement-new=1 | |
4681 | This is the default warning level of @option{-Wplacement-new}. At this | |
4682 | level the warning is not issued for some strictly undefined constructs that | |
4683 | GCC allows as extensions for compatibility with legacy code. For example, | |
4684 | the following @code{new} expression is not diagnosed at this level even | |
4685 | though it has undefined behavior according to the C++ standard because | |
4686 | it writes past the end of the one-element array. | |
4687 | @smallexample | |
4688 | struct S @{ int n, a[1]; @}; | |
4689 | S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]); | |
4690 | new (s->a)int [32](); | |
4691 | @end smallexample | |
4692 | ||
4693 | @item -Wplacement-new=2 | |
4694 | At this level, in addition to diagnosing all the same constructs as at level | |
4695 | 1, a diagnostic is also issued for placement new expressions that construct | |
4696 | an object in the last member of structure whose type is an array of a single | |
4697 | element and whose size is less than the size of the object being constructed. | |
4698 | While the previous example would be diagnosed, the following construct makes | |
4699 | use of the flexible member array extension to avoid the warning at level 2. | |
4700 | @smallexample | |
4701 | struct S @{ int n, a[]; @}; | |
4702 | S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]); | |
4703 | new (s->a)int [32](); | |
4704 | @end smallexample | |
4705 | ||
4706 | @end table | |
4707 | ||
d77de738 ML |
4708 | @opindex Wcatch-value |
4709 | @opindex Wno-catch-value | |
ddf6fe37 AA |
4710 | @item -Wcatch-value |
4711 | @itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)} | |
d77de738 ML |
4712 | Warn about catch handlers that do not catch via reference. |
4713 | With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short) | |
4714 | warn about polymorphic class types that are caught by value. | |
4715 | With @option{-Wcatch-value=2} warn about all class types that are caught | |
4716 | by value. With @option{-Wcatch-value=3} warn about all types that are | |
4717 | not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}. | |
4718 | ||
d77de738 ML |
4719 | @opindex Wconditionally-supported |
4720 | @opindex Wno-conditionally-supported | |
ddf6fe37 | 4721 | @item -Wconditionally-supported @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4722 | Warn for conditionally-supported (C++11 [intro.defs]) constructs. |
4723 | ||
d77de738 ML |
4724 | @opindex Wdelete-incomplete |
4725 | @opindex Wno-delete-incomplete | |
ddf6fe37 | 4726 | @item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4727 | Do not warn when deleting a pointer to incomplete type, which may cause |
4728 | undefined behavior at runtime. This warning is enabled by default. | |
4729 | ||
d77de738 ML |
4730 | @opindex Wextra-semi |
4731 | @opindex Wno-extra-semi | |
ddf6fe37 | 4732 | @item -Wextra-semi @r{(C++, Objective-C++ only)} |
d77de738 ML |
4733 | Warn about redundant semicolons after in-class function definitions. |
4734 | ||
d77de738 ML |
4735 | @opindex Winaccessible-base |
4736 | @opindex Wno-inaccessible-base | |
ddf6fe37 | 4737 | @item -Wno-inaccessible-base @r{(C++, Objective-C++ only)} |
d77de738 ML |
4738 | This option controls warnings |
4739 | when a base class is inaccessible in a class derived from it due to | |
4740 | ambiguity. The warning is enabled by default. | |
4741 | Note that the warning for ambiguous virtual | |
4742 | bases is enabled by the @option{-Wextra} option. | |
4743 | @smallexample | |
4744 | @group | |
4745 | struct A @{ int a; @}; | |
4746 | ||
4747 | struct B : A @{ @}; | |
4748 | ||
4749 | struct C : B, A @{ @}; | |
4750 | @end group | |
4751 | @end smallexample | |
4752 | ||
d77de738 ML |
4753 | @opindex Winherited-variadic-ctor |
4754 | @opindex Wno-inherited-variadic-ctor | |
ddf6fe37 | 4755 | @item -Wno-inherited-variadic-ctor |
d77de738 ML |
4756 | Suppress warnings about use of C++11 inheriting constructors when the |
4757 | base class inherited from has a C variadic constructor; the warning is | |
4758 | on by default because the ellipsis is not inherited. | |
4759 | ||
d77de738 ML |
4760 | @opindex Wno-invalid-offsetof |
4761 | @opindex Winvalid-offsetof | |
ddf6fe37 | 4762 | @item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4763 | Suppress warnings from applying the @code{offsetof} macro to a non-POD |
4764 | type. According to the 2014 ISO C++ standard, applying @code{offsetof} | |
4765 | to a non-standard-layout type is undefined. In existing C++ implementations, | |
4766 | however, @code{offsetof} typically gives meaningful results. | |
4767 | This flag is for users who are aware that they are | |
4768 | writing nonportable code and who have deliberately chosen to ignore the | |
4769 | warning about it. | |
4770 | ||
4771 | The restrictions on @code{offsetof} may be relaxed in a future version | |
4772 | of the C++ standard. | |
4773 | ||
d77de738 ML |
4774 | @opindex Wsized-deallocation |
4775 | @opindex Wno-sized-deallocation | |
ddf6fe37 | 4776 | @item -Wsized-deallocation @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4777 | Warn about a definition of an unsized deallocation function |
4778 | @smallexample | |
4779 | void operator delete (void *) noexcept; | |
4780 | void operator delete[] (void *) noexcept; | |
4781 | @end smallexample | |
4782 | without a definition of the corresponding sized deallocation function | |
4783 | @smallexample | |
4784 | void operator delete (void *, std::size_t) noexcept; | |
4785 | void operator delete[] (void *, std::size_t) noexcept; | |
4786 | @end smallexample | |
4787 | or vice versa. Enabled by @option{-Wextra} along with | |
4788 | @option{-fsized-deallocation}. | |
4789 | ||
d77de738 ML |
4790 | @opindex Wno-suggest-final-types |
4791 | @opindex Wsuggest-final-types | |
ddf6fe37 | 4792 | @item -Wsuggest-final-types |
d77de738 ML |
4793 | Warn about types with virtual methods where code quality would be improved |
4794 | if the type were declared with the C++11 @code{final} specifier, | |
4795 | or, if possible, | |
4796 | declared in an anonymous namespace. This allows GCC to more aggressively | |
4797 | devirtualize the polymorphic calls. This warning is more effective with | |
4798 | link-time optimization, | |
4799 | where the information about the class hierarchy graph is | |
4800 | more complete. | |
4801 | ||
d77de738 ML |
4802 | @opindex Wno-suggest-final-methods |
4803 | @opindex Wsuggest-final-methods | |
ddf6fe37 | 4804 | @item -Wsuggest-final-methods |
d77de738 ML |
4805 | Warn about virtual methods where code quality would be improved if the method |
4806 | were declared with the C++11 @code{final} specifier, | |
4807 | or, if possible, its type were | |
4808 | declared in an anonymous namespace or with the @code{final} specifier. | |
4809 | This warning is | |
4810 | more effective with link-time optimization, where the information about the | |
4811 | class hierarchy graph is more complete. It is recommended to first consider | |
4812 | suggestions of @option{-Wsuggest-final-types} and then rebuild with new | |
4813 | annotations. | |
4814 | ||
d77de738 ML |
4815 | @opindex Wsuggest-override |
4816 | @opindex Wno-suggest-override | |
ddf6fe37 | 4817 | @item -Wsuggest-override |
d77de738 ML |
4818 | Warn about overriding virtual functions that are not marked with the |
4819 | @code{override} keyword. | |
4820 | ||
d77de738 ML |
4821 | @opindex Wconversion-null |
4822 | @opindex Wno-conversion-null | |
ddf6fe37 | 4823 | @item -Wno-conversion-null @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4824 | Do not warn for conversions between @code{NULL} and non-pointer |
4825 | types. @option{-Wconversion-null} is enabled by default. | |
4826 | ||
4827 | @end table | |
4828 | ||
4829 | @node Objective-C and Objective-C++ Dialect Options | |
4830 | @section Options Controlling Objective-C and Objective-C++ Dialects | |
4831 | ||
4832 | @cindex compiler options, Objective-C and Objective-C++ | |
4833 | @cindex Objective-C and Objective-C++ options, command-line | |
4834 | @cindex options, Objective-C and Objective-C++ | |
4835 | (NOTE: This manual does not describe the Objective-C and Objective-C++ | |
4836 | languages themselves. @xref{Standards,,Language Standards | |
4837 | Supported by GCC}, for references.) | |
4838 | ||
4839 | This section describes the command-line options that are only meaningful | |
4840 | for Objective-C and Objective-C++ programs. You can also use most of | |
4841 | the language-independent GNU compiler options. | |
4842 | For example, you might compile a file @file{some_class.m} like this: | |
4843 | ||
4844 | @smallexample | |
4845 | gcc -g -fgnu-runtime -O -c some_class.m | |
4846 | @end smallexample | |
4847 | ||
4848 | @noindent | |
4849 | In this example, @option{-fgnu-runtime} is an option meant only for | |
4850 | Objective-C and Objective-C++ programs; you can use the other options with | |
4851 | any language supported by GCC@. | |
4852 | ||
4853 | Note that since Objective-C is an extension of the C language, Objective-C | |
4854 | compilations may also use options specific to the C front-end (e.g., | |
4855 | @option{-Wtraditional}). Similarly, Objective-C++ compilations may use | |
4856 | C++-specific options (e.g., @option{-Wabi}). | |
4857 | ||
4858 | Here is a list of options that are @emph{only} for compiling Objective-C | |
4859 | and Objective-C++ programs: | |
4860 | ||
4861 | @table @gcctabopt | |
d77de738 | 4862 | @opindex fconstant-string-class |
ddf6fe37 | 4863 | @item -fconstant-string-class=@var{class-name} |
d77de738 ML |
4864 | Use @var{class-name} as the name of the class to instantiate for each |
4865 | literal string specified with the syntax @code{@@"@dots{}"}. The default | |
4866 | class name is @code{NXConstantString} if the GNU runtime is being used, and | |
cdd4b3c0 | 4867 | @code{NSConstantString} if the NeXT runtime is being used (see below). On |
a335cf24 | 4868 | Darwin / macOS platforms, the @option{-fconstant-cfstrings} option, if |
cdd4b3c0 IS |
4869 | also present, overrides the @option{-fconstant-string-class} setting and cause |
4870 | @code{@@"@dots{}"} literals to be laid out as constant CoreFoundation strings. | |
4871 | Note that @option{-fconstant-cfstrings} is an alias for the target-specific | |
4872 | @option{-mconstant-cfstrings} equivalent. | |
d77de738 | 4873 | |
d77de738 | 4874 | @opindex fgnu-runtime |
ddf6fe37 | 4875 | @item -fgnu-runtime |
d77de738 ML |
4876 | Generate object code compatible with the standard GNU Objective-C |
4877 | runtime. This is the default for most types of systems. | |
4878 | ||
d77de738 | 4879 | @opindex fnext-runtime |
ddf6fe37 | 4880 | @item -fnext-runtime |
d77de738 | 4881 | Generate output compatible with the NeXT runtime. This is the default |
a335cf24 | 4882 | for NeXT-based systems, including Darwin / macOS. The macro |
d77de738 ML |
4883 | @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is |
4884 | used. | |
4885 | ||
d77de738 ML |
4886 | @opindex fno-nil-receivers |
4887 | @opindex fnil-receivers | |
ddf6fe37 | 4888 | @item -fno-nil-receivers |
d77de738 ML |
4889 | Assume that all Objective-C message dispatches (@code{[receiver |
4890 | message:arg]}) in this translation unit ensure that the receiver is | |
4891 | not @code{nil}. This allows for more efficient entry points in the | |
4892 | runtime to be used. This option is only available in conjunction with | |
4893 | the NeXT runtime and ABI version 0 or 1. | |
4894 | ||
d77de738 | 4895 | @opindex fobjc-abi-version |
ddf6fe37 | 4896 | @item -fobjc-abi-version=@var{n} |
d77de738 ML |
4897 | Use version @var{n} of the Objective-C ABI for the selected runtime. |
4898 | This option is currently supported only for the NeXT runtime. In that | |
4899 | case, Version 0 is the traditional (32-bit) ABI without support for | |
4900 | properties and other Objective-C 2.0 additions. Version 1 is the | |
4901 | traditional (32-bit) ABI with support for properties and other | |
4902 | Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If | |
4903 | nothing is specified, the default is Version 0 on 32-bit target | |
4904 | machines, and Version 2 on 64-bit target machines. | |
4905 | ||
d77de738 | 4906 | @opindex fobjc-call-cxx-cdtors |
ddf6fe37 | 4907 | @item -fobjc-call-cxx-cdtors |
d77de738 ML |
4908 | For each Objective-C class, check if any of its instance variables is a |
4909 | C++ object with a non-trivial default constructor. If so, synthesize a | |
4910 | special @code{- (id) .cxx_construct} instance method which runs | |
4911 | non-trivial default constructors on any such instance variables, in order, | |
4912 | and then return @code{self}. Similarly, check if any instance variable | |
4913 | is a C++ object with a non-trivial destructor, and if so, synthesize a | |
4914 | special @code{- (void) .cxx_destruct} method which runs | |
4915 | all such default destructors, in reverse order. | |
4916 | ||
4917 | The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct} | |
4918 | methods thusly generated only operate on instance variables | |
4919 | declared in the current Objective-C class, and not those inherited | |
4920 | from superclasses. It is the responsibility of the Objective-C | |
4921 | runtime to invoke all such methods in an object's inheritance | |
4922 | hierarchy. The @code{- (id) .cxx_construct} methods are invoked | |
4923 | by the runtime immediately after a new object instance is allocated; | |
4924 | the @code{- (void) .cxx_destruct} methods are invoked immediately | |
4925 | before the runtime deallocates an object instance. | |
4926 | ||
4927 | As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has | |
4928 | support for invoking the @code{- (id) .cxx_construct} and | |
4929 | @code{- (void) .cxx_destruct} methods. | |
4930 | ||
d77de738 | 4931 | @opindex fobjc-direct-dispatch |
ddf6fe37 | 4932 | @item -fobjc-direct-dispatch |
d77de738 ML |
4933 | Allow fast jumps to the message dispatcher. On Darwin this is |
4934 | accomplished via the comm page. | |
4935 | ||
d77de738 | 4936 | @opindex fobjc-exceptions |
ddf6fe37 | 4937 | @item -fobjc-exceptions |
d77de738 ML |
4938 | Enable syntactic support for structured exception handling in |
4939 | Objective-C, similar to what is offered by C++. This option | |
4940 | is required to use the Objective-C keywords @code{@@try}, | |
4941 | @code{@@throw}, @code{@@catch}, @code{@@finally} and | |
4942 | @code{@@synchronized}. This option is available with both the GNU | |
4943 | runtime and the NeXT runtime (but not available in conjunction with | |
4944 | the NeXT runtime on Mac OS X 10.2 and earlier). | |
4945 | ||
d77de738 | 4946 | @opindex fobjc-gc |
ddf6fe37 | 4947 | @item -fobjc-gc |
d77de738 ML |
4948 | Enable garbage collection (GC) in Objective-C and Objective-C++ |
4949 | programs. This option is only available with the NeXT runtime; the | |
4950 | GNU runtime has a different garbage collection implementation that | |
4951 | does not require special compiler flags. | |
4952 | ||
d77de738 | 4953 | @opindex fobjc-nilcheck |
ddf6fe37 | 4954 | @item -fobjc-nilcheck |
d77de738 ML |
4955 | For the NeXT runtime with version 2 of the ABI, check for a nil |
4956 | receiver in method invocations before doing the actual method call. | |
4957 | This is the default and can be disabled using | |
4958 | @option{-fno-objc-nilcheck}. Class methods and super calls are never | |
4959 | checked for nil in this way no matter what this flag is set to. | |
4960 | Currently this flag does nothing when the GNU runtime, or an older | |
4961 | version of the NeXT runtime ABI, is used. | |
4962 | ||
d77de738 | 4963 | @opindex fobjc-std |
ddf6fe37 | 4964 | @item -fobjc-std=objc1 |
d77de738 ML |
4965 | Conform to the language syntax of Objective-C 1.0, the language |
4966 | recognized by GCC 4.0. This only affects the Objective-C additions to | |
4967 | the C/C++ language; it does not affect conformance to C/C++ standards, | |
4968 | which is controlled by the separate C/C++ dialect option flags. When | |
4969 | this option is used with the Objective-C or Objective-C++ compiler, | |
4970 | any Objective-C syntax that is not recognized by GCC 4.0 is rejected. | |
4971 | This is useful if you need to make sure that your Objective-C code can | |
4972 | be compiled with older versions of GCC@. | |
4973 | ||
d77de738 | 4974 | @opindex freplace-objc-classes |
ddf6fe37 | 4975 | @item -freplace-objc-classes |
d77de738 ML |
4976 | Emit a special marker instructing @command{ld(1)} not to statically link in |
4977 | the resulting object file, and allow @command{dyld(1)} to load it in at | |
4978 | run time instead. This is used in conjunction with the Fix-and-Continue | |
4979 | debugging mode, where the object file in question may be recompiled and | |
4980 | dynamically reloaded in the course of program execution, without the need | |
4981 | to restart the program itself. Currently, Fix-and-Continue functionality | |
4982 | is only available in conjunction with the NeXT runtime on Mac OS X 10.3 | |
4983 | and later. | |
4984 | ||
d77de738 | 4985 | @opindex fzero-link |
ddf6fe37 | 4986 | @item -fzero-link |
d77de738 ML |
4987 | When compiling for the NeXT runtime, the compiler ordinarily replaces calls |
4988 | to @code{objc_getClass("@dots{}")} (when the name of the class is known at | |
4989 | compile time) with static class references that get initialized at load time, | |
4990 | which improves run-time performance. Specifying the @option{-fzero-link} flag | |
4991 | suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")} | |
4992 | to be retained. This is useful in Zero-Link debugging mode, since it allows | |
4993 | for individual class implementations to be modified during program execution. | |
4994 | The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")} | |
4995 | regardless of command-line options. | |
4996 | ||
d77de738 ML |
4997 | @opindex fno-local-ivars |
4998 | @opindex flocal-ivars | |
ddf6fe37 | 4999 | @item -fno-local-ivars |
d77de738 ML |
5000 | By default instance variables in Objective-C can be accessed as if |
5001 | they were local variables from within the methods of the class they're | |
5002 | declared in. This can lead to shadowing between instance variables | |
5003 | and other variables declared either locally inside a class method or | |
5004 | globally with the same name. Specifying the @option{-fno-local-ivars} | |
5005 | flag disables this behavior thus avoiding variable shadowing issues. | |
5006 | ||
d77de738 | 5007 | @opindex fivar-visibility |
ddf6fe37 | 5008 | @item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]} |
d77de738 ML |
5009 | Set the default instance variable visibility to the specified option |
5010 | so that instance variables declared outside the scope of any access | |
5011 | modifier directives default to the specified visibility. | |
5012 | ||
d77de738 | 5013 | @opindex gen-decls |
ddf6fe37 | 5014 | @item -gen-decls |
d77de738 ML |
5015 | Dump interface declarations for all classes seen in the source file to a |
5016 | file named @file{@var{sourcename}.decl}. | |
5017 | ||
d77de738 ML |
5018 | @opindex Wassign-intercept |
5019 | @opindex Wno-assign-intercept | |
ddf6fe37 | 5020 | @item -Wassign-intercept @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5021 | Warn whenever an Objective-C assignment is being intercepted by the |
5022 | garbage collector. | |
5023 | ||
d77de738 ML |
5024 | @opindex Wproperty-assign-default |
5025 | @opindex Wno-property-assign-default | |
ddf6fe37 | 5026 | @item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5027 | Do not warn if a property for an Objective-C object has no assign |
5028 | semantics specified. | |
5029 | ||
d77de738 ML |
5030 | @opindex Wno-protocol |
5031 | @opindex Wprotocol | |
ddf6fe37 | 5032 | @item -Wno-protocol @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5033 | If a class is declared to implement a protocol, a warning is issued for |
5034 | every method in the protocol that is not implemented by the class. The | |
5035 | default behavior is to issue a warning for every method not explicitly | |
5036 | implemented in the class, even if a method implementation is inherited | |
5037 | from the superclass. If you use the @option{-Wno-protocol} option, then | |
5038 | methods inherited from the superclass are considered to be implemented, | |
5039 | and no warning is issued for them. | |
5040 | ||
d77de738 | 5041 | @opindex Wobjc-root-class |
ddf6fe37 | 5042 | @item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5043 | Warn if a class interface lacks a superclass. Most classes will inherit |
5044 | from @code{NSObject} (or @code{Object}) for example. When declaring | |
5045 | classes intended to be root classes, the warning can be suppressed by | |
5046 | marking their interfaces with @code{__attribute__((objc_root_class))}. | |
5047 | ||
d77de738 ML |
5048 | @opindex Wselector |
5049 | @opindex Wno-selector | |
ddf6fe37 | 5050 | @item -Wselector @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5051 | Warn if multiple methods of different types for the same selector are |
5052 | found during compilation. The check is performed on the list of methods | |
5053 | in the final stage of compilation. Additionally, a check is performed | |
5054 | for each selector appearing in a @code{@@selector(@dots{})} | |
5055 | expression, and a corresponding method for that selector has been found | |
5056 | during compilation. Because these checks scan the method table only at | |
5057 | the end of compilation, these warnings are not produced if the final | |
5058 | stage of compilation is not reached, for example because an error is | |
5059 | found during compilation, or because the @option{-fsyntax-only} option is | |
5060 | being used. | |
5061 | ||
d77de738 ML |
5062 | @opindex Wstrict-selector-match |
5063 | @opindex Wno-strict-selector-match | |
ddf6fe37 | 5064 | @item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5065 | Warn if multiple methods with differing argument and/or return types are |
5066 | found for a given selector when attempting to send a message using this | |
5067 | selector to a receiver of type @code{id} or @code{Class}. When this flag | |
5068 | is off (which is the default behavior), the compiler omits such warnings | |
5069 | if any differences found are confined to types that share the same size | |
5070 | and alignment. | |
5071 | ||
d77de738 ML |
5072 | @opindex Wundeclared-selector |
5073 | @opindex Wno-undeclared-selector | |
ddf6fe37 | 5074 | @item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5075 | Warn if a @code{@@selector(@dots{})} expression referring to an |
5076 | undeclared selector is found. A selector is considered undeclared if no | |
5077 | method with that name has been declared before the | |
5078 | @code{@@selector(@dots{})} expression, either explicitly in an | |
5079 | @code{@@interface} or @code{@@protocol} declaration, or implicitly in | |
5080 | an @code{@@implementation} section. This option always performs its | |
5081 | checks as soon as a @code{@@selector(@dots{})} expression is found, | |
5082 | while @option{-Wselector} only performs its checks in the final stage of | |
5083 | compilation. This also enforces the coding style convention | |
5084 | that methods and selectors must be declared before being used. | |
5085 | ||
d77de738 | 5086 | @opindex print-objc-runtime-info |
ddf6fe37 | 5087 | @item -print-objc-runtime-info |
d77de738 ML |
5088 | Generate C header describing the largest structure that is passed by |
5089 | value, if any. | |
5090 | ||
5091 | @end table | |
5092 | ||
5093 | @node Diagnostic Message Formatting Options | |
5094 | @section Options to Control Diagnostic Messages Formatting | |
5095 | @cindex options to control diagnostics formatting | |
5096 | @cindex diagnostic messages | |
5097 | @cindex message formatting | |
5098 | ||
5099 | Traditionally, diagnostic messages have been formatted irrespective of | |
5100 | the output device's aspect (e.g.@: its width, @dots{}). You can use the | |
5101 | options described below | |
5102 | to control the formatting algorithm for diagnostic messages, | |
5103 | e.g.@: how many characters per line, how often source location | |
5104 | information should be reported. Note that some language front ends may not | |
5105 | honor these options. | |
5106 | ||
5107 | @table @gcctabopt | |
d77de738 | 5108 | @opindex fmessage-length |
ddf6fe37 | 5109 | @item -fmessage-length=@var{n} |
d77de738 ML |
5110 | Try to format error messages so that they fit on lines of about |
5111 | @var{n} characters. If @var{n} is zero, then no line-wrapping is | |
5112 | done; each error message appears on a single line. This is the | |
5113 | default for all front ends. | |
5114 | ||
5115 | Note - this option also affects the display of the @samp{#error} and | |
5116 | @samp{#warning} pre-processor directives, and the @samp{deprecated} | |
5117 | function/type/variable attribute. It does not however affect the | |
5118 | @samp{pragma GCC warning} and @samp{pragma GCC error} pragmas. | |
5119 | ||
5120 | @item -fdiagnostics-plain-output | |
5121 | This option requests that diagnostic output look as plain as possible, which | |
5122 | may be useful when running @command{dejagnu} or other utilities that need to | |
5123 | parse diagnostics output and prefer that it remain more stable over time. | |
5124 | @option{-fdiagnostics-plain-output} is currently equivalent to the following | |
5125 | options: | |
43b72ede AA |
5126 | @gccoptlist{-fno-diagnostics-show-caret |
5127 | -fno-diagnostics-show-line-numbers | |
5128 | -fdiagnostics-color=never | |
5129 | -fdiagnostics-urls=never | |
4f01ae37 DM |
5130 | -fdiagnostics-path-format=separate-events |
5131 | -fdiagnostics-text-art-charset=none} | |
d77de738 ML |
5132 | In the future, if GCC changes the default appearance of its diagnostics, the |
5133 | corresponding option to disable the new behavior will be added to this list. | |
5134 | ||
d77de738 | 5135 | @opindex fdiagnostics-show-location |
ddf6fe37 | 5136 | @item -fdiagnostics-show-location=once |
d77de738 ML |
5137 | Only meaningful in line-wrapping mode. Instructs the diagnostic messages |
5138 | reporter to emit source location information @emph{once}; that is, in | |
5139 | case the message is too long to fit on a single physical line and has to | |
5140 | be wrapped, the source location won't be emitted (as prefix) again, | |
5141 | over and over, in subsequent continuation lines. This is the default | |
5142 | behavior. | |
5143 | ||
5144 | @item -fdiagnostics-show-location=every-line | |
5145 | Only meaningful in line-wrapping mode. Instructs the diagnostic | |
5146 | messages reporter to emit the same source location information (as | |
5147 | prefix) for physical lines that result from the process of breaking | |
5148 | a message which is too long to fit on a single line. | |
5149 | ||
ddf6fe37 | 5150 | @opindex fdiagnostics-color |
d77de738 ML |
5151 | @cindex highlight, color |
5152 | @vindex GCC_COLORS @r{environment variable} | |
f33d7a88 AA |
5153 | @item -fdiagnostics-color[=@var{WHEN}] |
5154 | @itemx -fno-diagnostics-color | |
d77de738 ML |
5155 | Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always}, |
5156 | or @samp{auto}. The default depends on how the compiler has been configured, | |
5157 | it can be any of the above @var{WHEN} options or also @samp{never} | |
5158 | if @env{GCC_COLORS} environment variable isn't present in the environment, | |
5159 | and @samp{auto} otherwise. | |
5160 | @samp{auto} makes GCC use color only when the standard error is a terminal, | |
5161 | and when not executing in an emacs shell. | |
5162 | The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are | |
5163 | aliases for @option{-fdiagnostics-color=always} and | |
5164 | @option{-fdiagnostics-color=never}, respectively. | |
5165 | ||
5166 | The colors are defined by the environment variable @env{GCC_COLORS}. | |
5167 | Its value is a colon-separated list of capabilities and Select Graphic | |
5168 | Rendition (SGR) substrings. SGR commands are interpreted by the | |
5169 | terminal or terminal emulator. (See the section in the documentation | |
5170 | of your text terminal for permitted values and their meanings as | |
5171 | character attributes.) These substring values are integers in decimal | |
5172 | representation and can be concatenated with semicolons. | |
5173 | Common values to concatenate include | |
5174 | @samp{1} for bold, | |
5175 | @samp{4} for underline, | |
5176 | @samp{5} for blink, | |
5177 | @samp{7} for inverse, | |
5178 | @samp{39} for default foreground color, | |
5179 | @samp{30} to @samp{37} for foreground colors, | |
5180 | @samp{90} to @samp{97} for 16-color mode foreground colors, | |
5181 | @samp{38;5;0} to @samp{38;5;255} | |
5182 | for 88-color and 256-color modes foreground colors, | |
5183 | @samp{49} for default background color, | |
5184 | @samp{40} to @samp{47} for background colors, | |
5185 | @samp{100} to @samp{107} for 16-color mode background colors, | |
5186 | and @samp{48;5;0} to @samp{48;5;255} | |
5187 | for 88-color and 256-color modes background colors. | |
5188 | ||
5189 | The default @env{GCC_COLORS} is | |
5190 | @smallexample | |
5191 | error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\ | |
5192 | quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\ | |
5193 | diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\ | |
5194 | type-diff=01;32:fnname=01;32:targs=35 | |
5195 | @end smallexample | |
5196 | @noindent | |
5197 | where @samp{01;31} is bold red, @samp{01;35} is bold magenta, | |
5198 | @samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue, | |
5199 | @samp{01} is bold, and @samp{31} is red. | |
5200 | Setting @env{GCC_COLORS} to the empty string disables colors. | |
5201 | Supported capabilities are as follows. | |
5202 | ||
5203 | @table @code | |
d77de738 | 5204 | @vindex error GCC_COLORS @r{capability} |
f33d7a88 | 5205 | @item error= |
d77de738 ML |
5206 | SGR substring for error: markers. |
5207 | ||
d77de738 | 5208 | @vindex warning GCC_COLORS @r{capability} |
f33d7a88 | 5209 | @item warning= |
d77de738 ML |
5210 | SGR substring for warning: markers. |
5211 | ||
d77de738 | 5212 | @vindex note GCC_COLORS @r{capability} |
f33d7a88 | 5213 | @item note= |
d77de738 ML |
5214 | SGR substring for note: markers. |
5215 | ||
d77de738 | 5216 | @vindex path GCC_COLORS @r{capability} |
f33d7a88 | 5217 | @item path= |
d77de738 ML |
5218 | SGR substring for colorizing paths of control-flow events as printed |
5219 | via @option{-fdiagnostics-path-format=}, such as the identifiers of | |
5220 | individual events and lines indicating interprocedural calls and returns. | |
5221 | ||
d77de738 | 5222 | @vindex range1 GCC_COLORS @r{capability} |
f33d7a88 | 5223 | @item range1= |
d77de738 ML |
5224 | SGR substring for first additional range. |
5225 | ||
d77de738 | 5226 | @vindex range2 GCC_COLORS @r{capability} |
f33d7a88 | 5227 | @item range2= |
d77de738 ML |
5228 | SGR substring for second additional range. |
5229 | ||
d77de738 | 5230 | @vindex locus GCC_COLORS @r{capability} |
f33d7a88 | 5231 | @item locus= |
d77de738 ML |
5232 | SGR substring for location information, @samp{file:line} or |
5233 | @samp{file:line:column} etc. | |
5234 | ||
d77de738 | 5235 | @vindex quote GCC_COLORS @r{capability} |
f33d7a88 | 5236 | @item quote= |
d77de738 ML |
5237 | SGR substring for information printed within quotes. |
5238 | ||
d77de738 | 5239 | @vindex fnname GCC_COLORS @r{capability} |
f33d7a88 | 5240 | @item fnname= |
d77de738 ML |
5241 | SGR substring for names of C++ functions. |
5242 | ||
d77de738 | 5243 | @vindex targs GCC_COLORS @r{capability} |
f33d7a88 | 5244 | @item targs= |
d77de738 ML |
5245 | SGR substring for C++ function template parameter bindings. |
5246 | ||
d77de738 | 5247 | @vindex fixit-insert GCC_COLORS @r{capability} |
f33d7a88 | 5248 | @item fixit-insert= |
d77de738 ML |
5249 | SGR substring for fix-it hints suggesting text to |
5250 | be inserted or replaced. | |
5251 | ||
d77de738 | 5252 | @vindex fixit-delete GCC_COLORS @r{capability} |
f33d7a88 | 5253 | @item fixit-delete= |
d77de738 ML |
5254 | SGR substring for fix-it hints suggesting text to |
5255 | be deleted. | |
5256 | ||
d77de738 | 5257 | @vindex diff-filename GCC_COLORS @r{capability} |
f33d7a88 | 5258 | @item diff-filename= |
d77de738 ML |
5259 | SGR substring for filename headers within generated patches. |
5260 | ||
d77de738 | 5261 | @vindex diff-hunk GCC_COLORS @r{capability} |
f33d7a88 | 5262 | @item diff-hunk= |
d77de738 ML |
5263 | SGR substring for the starts of hunks within generated patches. |
5264 | ||
d77de738 | 5265 | @vindex diff-delete GCC_COLORS @r{capability} |
f33d7a88 | 5266 | @item diff-delete= |
d77de738 ML |
5267 | SGR substring for deleted lines within generated patches. |
5268 | ||
d77de738 | 5269 | @vindex diff-insert GCC_COLORS @r{capability} |
f33d7a88 | 5270 | @item diff-insert= |
d77de738 ML |
5271 | SGR substring for inserted lines within generated patches. |
5272 | ||
d77de738 | 5273 | @vindex type-diff GCC_COLORS @r{capability} |
f33d7a88 | 5274 | @item type-diff= |
d77de738 ML |
5275 | SGR substring for highlighting mismatching types within template |
5276 | arguments in the C++ frontend. | |
5277 | @end table | |
5278 | ||
d77de738 ML |
5279 | @opindex fdiagnostics-urls |
5280 | @cindex urls | |
5281 | @vindex GCC_URLS @r{environment variable} | |
5282 | @vindex TERM_URLS @r{environment variable} | |
f33d7a88 | 5283 | @item -fdiagnostics-urls[=@var{WHEN}] |
d77de738 ML |
5284 | Use escape sequences to embed URLs in diagnostics. For example, when |
5285 | @option{-fdiagnostics-show-option} emits text showing the command-line | |
5286 | option controlling a diagnostic, embed a URL for documentation of that | |
5287 | option. | |
5288 | ||
5289 | @var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}. | |
5290 | @samp{auto} makes GCC use URL escape sequences only when the standard error | |
5291 | is a terminal, and when not executing in an emacs shell or any graphical | |
5292 | terminal which is known to be incompatible with this feature, see below. | |
5293 | ||
5294 | The default depends on how the compiler has been configured. | |
5295 | It can be any of the above @var{WHEN} options. | |
5296 | ||
5297 | GCC can also be configured (via the | |
5298 | @option{--with-diagnostics-urls=auto-if-env} configure-time option) | |
5299 | so that the default is affected by environment variables. | |
5300 | Under such a configuration, GCC defaults to using @samp{auto} | |
5301 | if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are | |
5302 | present and non-empty in the environment of the compiler, or @samp{never} | |
5303 | if neither are. | |
5304 | ||
5305 | However, even with @option{-fdiagnostics-urls=always} the behavior is | |
5306 | dependent on those environment variables: | |
5307 | If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in | |
5308 | diagnostics. If set to @samp{st}, URLs use ST escape sequences. | |
5309 | If set to @samp{bel}, the default, URLs use BEL escape sequences. | |
5310 | Any other non-empty value enables the feature. | |
5311 | If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback. | |
5312 | Note: ST is an ANSI escape sequence, string terminator @samp{ESC \}, | |
5313 | BEL is an ASCII character, CTRL-G that usually sounds like a beep. | |
5314 | ||
5315 | At this time GCC tries to detect also a few terminals that are known to | |
5316 | not implement the URL feature, and have bugs or at least had bugs in | |
5317 | some versions that are still in use, where the URL escapes are likely | |
5318 | to misbehave, i.e. print garbage on the screen. | |
5319 | That list is currently xfce4-terminal, certain known to be buggy | |
5320 | gnome-terminal versions, the linux console, and mingw. | |
5321 | This check can be skipped with the @option{-fdiagnostics-urls=always}. | |
5322 | ||
d77de738 ML |
5323 | @opindex fno-diagnostics-show-option |
5324 | @opindex fdiagnostics-show-option | |
ddf6fe37 | 5325 | @item -fno-diagnostics-show-option |
d77de738 ML |
5326 | By default, each diagnostic emitted includes text indicating the |
5327 | command-line option that directly controls the diagnostic (if such an | |
5328 | option is known to the diagnostic machinery). Specifying the | |
5329 | @option{-fno-diagnostics-show-option} flag suppresses that behavior. | |
5330 | ||
d77de738 ML |
5331 | @opindex fno-diagnostics-show-caret |
5332 | @opindex fdiagnostics-show-caret | |
ddf6fe37 | 5333 | @item -fno-diagnostics-show-caret |
d77de738 ML |
5334 | By default, each diagnostic emitted includes the original source line |
5335 | and a caret @samp{^} indicating the column. This option suppresses this | |
5336 | information. The source line is truncated to @var{n} characters, if | |
5337 | the @option{-fmessage-length=n} option is given. When the output is done | |
5338 | to the terminal, the width is limited to the width given by the | |
5339 | @env{COLUMNS} environment variable or, if not set, to the terminal width. | |
5340 | ||
d77de738 ML |
5341 | @opindex fno-diagnostics-show-labels |
5342 | @opindex fdiagnostics-show-labels | |
ddf6fe37 | 5343 | @item -fno-diagnostics-show-labels |
d77de738 ML |
5344 | By default, when printing source code (via @option{-fdiagnostics-show-caret}), |
5345 | diagnostics can label ranges of source code with pertinent information, such | |
5346 | as the types of expressions: | |
5347 | ||
5348 | @smallexample | |
5349 | printf ("foo %s bar", long_i + long_j); | |
5350 | ~^ ~~~~~~~~~~~~~~~ | |
5351 | | | | |
5352 | char * long int | |
5353 | @end smallexample | |
5354 | ||
5355 | This option suppresses the printing of these labels (in the example above, | |
5356 | the vertical bars and the ``char *'' and ``long int'' text). | |
5357 | ||
d77de738 ML |
5358 | @opindex fno-diagnostics-show-cwe |
5359 | @opindex fdiagnostics-show-cwe | |
ddf6fe37 | 5360 | @item -fno-diagnostics-show-cwe |
d77de738 ML |
5361 | Diagnostic messages can optionally have an associated |
5362 | @uref{https://cwe.mitre.org/index.html, CWE} identifier. | |
5363 | GCC itself only provides such metadata for some of the @option{-fanalyzer} | |
5364 | diagnostics. GCC plugins may also provide diagnostics with such metadata. | |
5365 | By default, if this information is present, it will be printed with | |
5366 | the diagnostic. This option suppresses the printing of this metadata. | |
5367 | ||
d77de738 ML |
5368 | @opindex fno-diagnostics-show-rules |
5369 | @opindex fdiagnostics-show-rules | |
ddf6fe37 | 5370 | @item -fno-diagnostics-show-rules |
d77de738 ML |
5371 | Diagnostic messages can optionally have rules associated with them, such |
5372 | as from a coding standard, or a specification. | |
5373 | GCC itself does not do this for any of its diagnostics, but plugins may do so. | |
5374 | By default, if this information is present, it will be printed with | |
5375 | the diagnostic. This option suppresses the printing of this metadata. | |
5376 | ||
d77de738 ML |
5377 | @opindex fno-diagnostics-show-line-numbers |
5378 | @opindex fdiagnostics-show-line-numbers | |
ddf6fe37 | 5379 | @item -fno-diagnostics-show-line-numbers |
d77de738 ML |
5380 | By default, when printing source code (via @option{-fdiagnostics-show-caret}), |
5381 | a left margin is printed, showing line numbers. This option suppresses this | |
5382 | left margin. | |
5383 | ||
d77de738 | 5384 | @opindex fdiagnostics-minimum-margin-width |
ddf6fe37 | 5385 | @item -fdiagnostics-minimum-margin-width=@var{width} |
d77de738 ML |
5386 | This option controls the minimum width of the left margin printed by |
5387 | @option{-fdiagnostics-show-line-numbers}. It defaults to 6. | |
5388 | ||
d77de738 | 5389 | @opindex fdiagnostics-parseable-fixits |
ddf6fe37 | 5390 | @item -fdiagnostics-parseable-fixits |
d77de738 ML |
5391 | Emit fix-it hints in a machine-parseable format, suitable for consumption |
5392 | by IDEs. For each fix-it, a line will be printed after the relevant | |
5393 | diagnostic, starting with the string ``fix-it:''. For example: | |
5394 | ||
5395 | @smallexample | |
5396 | fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all" | |
5397 | @end smallexample | |
5398 | ||
5399 | The location is expressed as a half-open range, expressed as a count of | |
5400 | bytes, starting at byte 1 for the initial column. In the above example, | |
5401 | bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the | |
5402 | given string: | |
5403 | ||
5404 | @smallexample | |
5405 | 00000000011111111112222222222 | |
5406 | 12345678901234567890123456789 | |
5407 | gtk_widget_showall (dlg); | |
5408 | ^^^^^^^^^^^^^^^^^^ | |
5409 | gtk_widget_show_all | |
5410 | @end smallexample | |
5411 | ||
5412 | The filename and replacement string escape backslash as ``\\", tab as ``\t'', | |
5413 | newline as ``\n'', double quotes as ``\"'', non-printable characters as octal | |
5414 | (e.g. vertical tab as ``\013''). | |
5415 | ||
5416 | An empty replacement string indicates that the given range is to be removed. | |
5417 | An empty range (e.g. ``45:3-45:3'') indicates that the string is to | |
5418 | be inserted at the given position. | |
5419 | ||
d77de738 | 5420 | @opindex fdiagnostics-generate-patch |
ddf6fe37 | 5421 | @item -fdiagnostics-generate-patch |
d77de738 ML |
5422 | Print fix-it hints to stderr in unified diff format, after any diagnostics |
5423 | are printed. For example: | |
5424 | ||
5425 | @smallexample | |
5426 | --- test.c | |
5427 | +++ test.c | |
5428 | @@ -42,5 +42,5 @@ | |
5429 | ||
5430 | void show_cb(GtkDialog *dlg) | |
5431 | @{ | |
5432 | - gtk_widget_showall(dlg); | |
5433 | + gtk_widget_show_all(dlg); | |
5434 | @} | |
5435 | ||
5436 | @end smallexample | |
5437 | ||
5438 | The diff may or may not be colorized, following the same rules | |
5439 | as for diagnostics (see @option{-fdiagnostics-color}). | |
5440 | ||
d77de738 | 5441 | @opindex fdiagnostics-show-template-tree |
ddf6fe37 | 5442 | @item -fdiagnostics-show-template-tree |
d77de738 ML |
5443 | |
5444 | In the C++ frontend, when printing diagnostics showing mismatching | |
5445 | template types, such as: | |
5446 | ||
5447 | @smallexample | |
5448 | could not convert 'std::map<int, std::vector<double> >()' | |
5449 | from 'map<[...],vector<double>>' to 'map<[...],vector<float>> | |
5450 | @end smallexample | |
5451 | ||
5452 | the @option{-fdiagnostics-show-template-tree} flag enables printing a | |
5453 | tree-like structure showing the common and differing parts of the types, | |
5454 | such as: | |
5455 | ||
5456 | @smallexample | |
5457 | map< | |
5458 | [...], | |
5459 | vector< | |
5460 | [double != float]>> | |
5461 | @end smallexample | |
5462 | ||
5463 | The parts that differ are highlighted with color (``double'' and | |
5464 | ``float'' in this case). | |
5465 | ||
d77de738 ML |
5466 | @opindex fno-elide-type |
5467 | @opindex felide-type | |
ddf6fe37 | 5468 | @item -fno-elide-type |
d77de738 ML |
5469 | By default when the C++ frontend prints diagnostics showing mismatching |
5470 | template types, common parts of the types are printed as ``[...]'' to | |
5471 | simplify the error message. For example: | |
5472 | ||
5473 | @smallexample | |
5474 | could not convert 'std::map<int, std::vector<double> >()' | |
5475 | from 'map<[...],vector<double>>' to 'map<[...],vector<float>> | |
5476 | @end smallexample | |
5477 | ||
5478 | Specifying the @option{-fno-elide-type} flag suppresses that behavior. | |
5479 | This flag also affects the output of the | |
5480 | @option{-fdiagnostics-show-template-tree} flag. | |
5481 | ||
d77de738 | 5482 | @opindex fdiagnostics-path-format |
ddf6fe37 | 5483 | @item -fdiagnostics-path-format=@var{KIND} |
d77de738 ML |
5484 | Specify how to print paths of control-flow events for diagnostics that |
5485 | have such a path associated with them. | |
5486 | ||
5487 | @var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events}, | |
5488 | the default. | |
5489 | ||
5490 | @samp{none} means to not print diagnostic paths. | |
5491 | ||
5492 | @samp{separate-events} means to print a separate ``note'' diagnostic for | |
5493 | each event within the diagnostic. For example: | |
5494 | ||
5495 | @smallexample | |
5496 | test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter | |
5497 | test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL | |
5498 | test.c:27:3: note: (2) when 'i < count' | |
5499 | test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1 | |
5500 | @end smallexample | |
5501 | ||
5502 | @samp{inline-events} means to print the events ``inline'' within the source | |
5503 | code. This view attempts to consolidate the events into runs of | |
5504 | sufficiently-close events, printing them as labelled ranges within the source. | |
5505 | ||
5506 | For example, the same events as above might be printed as: | |
5507 | ||
5508 | @smallexample | |
5509 | 'test': events 1-3 | |
5510 | | | |
5511 | | 25 | list = PyList_New(0); | |
5512 | | | ^~~~~~~~~~~~~ | |
5513 | | | | | |
5514 | | | (1) when 'PyList_New' fails, returning NULL | |
5515 | | 26 | | |
5516 | | 27 | for (i = 0; i < count; i++) @{ | |
5517 | | | ~~~ | |
5518 | | | | | |
5519 | | | (2) when 'i < count' | |
5520 | | 28 | item = PyLong_FromLong(random()); | |
5521 | | 29 | PyList_Append(list, item); | |
5522 | | | ~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5523 | | | | | |
5524 | | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1 | |
5525 | | | |
5526 | @end smallexample | |
5527 | ||
5528 | Interprocedural control flow is shown by grouping the events by stack frame, | |
5529 | and using indentation to show how stack frames are nested, pushed, and popped. | |
5530 | ||
5531 | For example: | |
5532 | ||
5533 | @smallexample | |
5534 | 'test': events 1-2 | |
5535 | | | |
5536 | | 133 | @{ | |
5537 | | | ^ | |
5538 | | | | | |
5539 | | | (1) entering 'test' | |
5540 | | 134 | boxed_int *obj = make_boxed_int (i); | |
5541 | | | ~~~~~~~~~~~~~~~~~~ | |
5542 | | | | | |
5543 | | | (2) calling 'make_boxed_int' | |
5544 | | | |
5545 | +--> 'make_boxed_int': events 3-4 | |
5546 | | | |
5547 | | 120 | @{ | |
5548 | | | ^ | |
5549 | | | | | |
5550 | | | (3) entering 'make_boxed_int' | |
5551 | | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int)); | |
5552 | | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5553 | | | | | |
5554 | | | (4) calling 'wrapped_malloc' | |
5555 | | | |
5556 | +--> 'wrapped_malloc': events 5-6 | |
5557 | | | |
5558 | | 7 | @{ | |
5559 | | | ^ | |
5560 | | | | | |
5561 | | | (5) entering 'wrapped_malloc' | |
5562 | | 8 | return malloc (size); | |
5563 | | | ~~~~~~~~~~~~~ | |
5564 | | | | | |
5565 | | | (6) calling 'malloc' | |
5566 | | | |
5567 | <-------------+ | |
5568 | | | |
5569 | 'test': event 7 | |
5570 | | | |
5571 | | 138 | free_boxed_int (obj); | |
5572 | | | ^~~~~~~~~~~~~~~~~~~~ | |
5573 | | | | | |
5574 | | | (7) calling 'free_boxed_int' | |
5575 | | | |
5576 | (etc) | |
5577 | @end smallexample | |
5578 | ||
d77de738 | 5579 | @opindex fdiagnostics-show-path-depths |
ddf6fe37 | 5580 | @item -fdiagnostics-show-path-depths |
d77de738 ML |
5581 | This option provides additional information when printing control-flow paths |
5582 | associated with a diagnostic. | |
5583 | ||
5584 | If this is option is provided then the stack depth will be printed for | |
5585 | each run of events within @option{-fdiagnostics-path-format=inline-events}. | |
5586 | If provided with @option{-fdiagnostics-path-format=separate-events}, then | |
5587 | the stack depth and function declaration will be appended when printing | |
5588 | each event. | |
5589 | ||
5590 | This is intended for use by GCC developers and plugin developers when | |
5591 | debugging diagnostics that report interprocedural control flow. | |
5592 | ||
d77de738 ML |
5593 | @opindex fno-show-column |
5594 | @opindex fshow-column | |
ddf6fe37 | 5595 | @item -fno-show-column |
d77de738 ML |
5596 | Do not print column numbers in diagnostics. This may be necessary if |
5597 | diagnostics are being scanned by a program that does not understand the | |
5598 | column numbers, such as @command{dejagnu}. | |
5599 | ||
d77de738 | 5600 | @opindex fdiagnostics-column-unit |
ddf6fe37 | 5601 | @item -fdiagnostics-column-unit=@var{UNIT} |
d77de738 ML |
5602 | Select the units for the column number. This affects traditional diagnostics |
5603 | (in the absence of @option{-fno-show-column}), as well as JSON format | |
5604 | diagnostics if requested. | |
5605 | ||
5606 | The default @var{UNIT}, @samp{display}, considers the number of display | |
5607 | columns occupied by each character. This may be larger than the number | |
5608 | of bytes required to encode the character, in the case of tab | |
5609 | characters, or it may be smaller, in the case of multibyte characters. | |
5610 | For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one | |
5611 | display column, and its UTF-8 encoding requires two bytes; the character | |
5612 | ``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and | |
5613 | its UTF-8 encoding requires four bytes. | |
5614 | ||
5615 | Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte | |
5616 | count in all cases, as was traditionally output by GCC prior to version 11.1.0. | |
5617 | ||
d77de738 | 5618 | @opindex fdiagnostics-column-origin |
ddf6fe37 | 5619 | @item -fdiagnostics-column-origin=@var{ORIGIN} |
d77de738 ML |
5620 | Select the origin for column numbers, i.e. the column number assigned to the |
5621 | first column. The default value of 1 corresponds to traditional GCC | |
5622 | behavior and to the GNU style guide. Some utilities may perform better with an | |
5623 | origin of 0; any non-negative value may be specified. | |
5624 | ||
d77de738 | 5625 | @opindex fdiagnostics-escape-format |
ddf6fe37 | 5626 | @item -fdiagnostics-escape-format=@var{FORMAT} |
d77de738 ML |
5627 | When GCC prints pertinent source lines for a diagnostic it normally attempts |
5628 | to print the source bytes directly. However, some diagnostics relate to encoding | |
5629 | issues in the source file, such as malformed UTF-8, or issues with Unicode | |
5630 | normalization. These diagnostics are flagged so that GCC will escape bytes | |
5631 | that are not printable ASCII when printing their pertinent source lines. | |
5632 | ||
5633 | This option controls how such bytes should be escaped. | |
5634 | ||
5635 | The default @var{FORMAT}, @samp{unicode} displays Unicode characters that | |
5636 | are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not | |
5637 | correspond to a Unicode character validly-encoded in UTF-8-encoded will be | |
5638 | displayed as hexadecimal in the form @samp{<XX>}. | |
5639 | ||
5640 | For example, a source line containing the string @samp{before} followed by the | |
5641 | Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding | |
5642 | 0xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by | |
5643 | the string @samp{after} will be printed for such a diagnostic as: | |
5644 | ||
5645 | @smallexample | |
5646 | before<U+03C0><BF>after | |
5647 | @end smallexample | |
5648 | ||
5649 | Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes | |
5650 | in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII | |
5651 | Unicode characters. For the example above, the following will be printed: | |
5652 | ||
5653 | @smallexample | |
5654 | before<CF><80><BF>after | |
5655 | @end smallexample | |
5656 | ||
4f01ae37 DM |
5657 | @opindex fdiagnostics-text-art-charset |
5658 | @item -fdiagnostics-text-art-charset=@var{CHARSET} | |
5659 | Some diagnostics can contain ``text art'' diagrams: visualizations created | |
5660 | from text, intended to be viewed in a monospaced font. | |
5661 | ||
5662 | This option selects which characters should be used for printing such | |
5663 | diagrams, if any. @var{CHARSET} is @samp{none}, @samp{ascii}, @samp{unicode}, | |
5664 | or @samp{emoji}. | |
5665 | ||
5666 | The @samp{none} value suppresses the printing of such diagrams. | |
5667 | The @samp{ascii} value will ensure that such diagrams are pure ASCII | |
5668 | (``ASCII art''). The @samp{unicode} value will allow for conservative use of | |
5669 | unicode drawing characters (such as box-drawing characters). The @samp{emoji} | |
5670 | value further adds the possibility of emoji in the output (such as emitting | |
5671 | U+26A0 WARNING SIGN followed by U+FE0F VARIATION SELECTOR-16 to select the | |
5672 | emoji variant of the character). | |
5673 | ||
04013e44 DM |
5674 | The default is @samp{emoji}, except when the environment variable @env{LANG} |
5675 | is set to @samp{C}, in which case the default is @samp{ascii}. | |
4f01ae37 | 5676 | |
d77de738 | 5677 | @opindex fdiagnostics-format |
ddf6fe37 | 5678 | @item -fdiagnostics-format=@var{FORMAT} |
d77de738 ML |
5679 | Select a different format for printing diagnostics. |
5680 | @var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file}, | |
5681 | @samp{json}, @samp{json-stderr}, or @samp{json-file}. | |
5682 | ||
5683 | The default is @samp{text}. | |
5684 | ||
5685 | The @samp{sarif-stderr} and @samp{sarif-file} formats both emit | |
5686 | diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file | |
5687 | named @file{@var{source}.sarif}, respectively. | |
5688 | ||
5689 | The @samp{json} format is a synonym for @samp{json-stderr}. | |
5690 | The @samp{json-stderr} and @samp{json-file} formats are identical, apart from | |
5691 | where the JSON is emitted to - with the former, the JSON is emitted to stderr, | |
5692 | whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}. | |
5693 | ||
5694 | The emitted JSON consists of a top-level JSON array containing JSON objects | |
3bd8241a | 5695 | representing the diagnostics. |
d77de738 ML |
5696 | |
5697 | Diagnostics can have child diagnostics. For example, this error and note: | |
5698 | ||
5699 | @smallexample | |
5700 | misleading-indentation.c:15:3: warning: this 'if' clause does not | |
5701 | guard... [-Wmisleading-indentation] | |
5702 | 15 | if (flag) | |
5703 | | ^~ | |
5704 | misleading-indentation.c:17:5: note: ...this statement, but the latter | |
5705 | is misleadingly indented as if it were guarded by the 'if' | |
5706 | 17 | y = 2; | |
5707 | | ^ | |
5708 | @end smallexample | |
5709 | ||
5710 | @noindent | |
5711 | might be printed in JSON form (after formatting) like this: | |
5712 | ||
5713 | @smallexample | |
5714 | [ | |
5715 | @{ | |
5716 | "kind": "warning", | |
5717 | "locations": [ | |
5718 | @{ | |
5719 | "caret": @{ | |
5720 | "display-column": 3, | |
5721 | "byte-column": 3, | |
5722 | "column": 3, | |
5723 | "file": "misleading-indentation.c", | |
5724 | "line": 15 | |
5725 | @}, | |
5726 | "finish": @{ | |
5727 | "display-column": 4, | |
5728 | "byte-column": 4, | |
5729 | "column": 4, | |
5730 | "file": "misleading-indentation.c", | |
5731 | "line": 15 | |
5732 | @} | |
5733 | @} | |
5734 | ], | |
5735 | "message": "this \u2018if\u2019 clause does not guard...", | |
5736 | "option": "-Wmisleading-indentation", | |
5737 | "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation", | |
5738 | "children": [ | |
5739 | @{ | |
5740 | "kind": "note", | |
5741 | "locations": [ | |
5742 | @{ | |
5743 | "caret": @{ | |
5744 | "display-column": 5, | |
5745 | "byte-column": 5, | |
5746 | "column": 5, | |
5747 | "file": "misleading-indentation.c", | |
5748 | "line": 17 | |
5749 | @} | |
5750 | @} | |
5751 | ], | |
5752 | "escape-source": false, | |
5753 | "message": "...this statement, but the latter is @dots{}" | |
5754 | @} | |
5755 | ] | |
5756 | "escape-source": false, | |
5757 | "column-origin": 1, | |
5758 | @} | |
5759 | ] | |
5760 | @end smallexample | |
5761 | ||
5762 | @noindent | |
5763 | where the @code{note} is a child of the @code{warning}. | |
5764 | ||
5765 | A diagnostic has a @code{kind}. If this is @code{warning}, then there is | |
5766 | an @code{option} key describing the command-line option controlling the | |
5767 | warning. | |
5768 | ||
5769 | A diagnostic can contain zero or more locations. Each location has an | |
5770 | optional @code{label} string and up to three positions within it: a | |
5771 | @code{caret} position and optional @code{start} and @code{finish} positions. | |
5772 | A position is described by a @code{file} name, a @code{line} number, and | |
5773 | three numbers indicating a column position: | |
5774 | @itemize @bullet | |
5775 | ||
5776 | @item | |
5777 | @code{display-column} counts display columns, accounting for tabs and | |
5778 | multibyte characters. | |
5779 | ||
5780 | @item | |
5781 | @code{byte-column} counts raw bytes. | |
5782 | ||
5783 | @item | |
5784 | @code{column} is equal to one of | |
5785 | the previous two, as dictated by the @option{-fdiagnostics-column-unit} | |
5786 | option. | |
5787 | ||
5788 | @end itemize | |
5789 | All three columns are relative to the origin specified by | |
5790 | @option{-fdiagnostics-column-origin}, which is typically equal to 1 but may | |
5791 | be set, for instance, to 0 for compatibility with other utilities that | |
5792 | number columns from 0. The column origin is recorded in the JSON output in | |
5793 | the @code{column-origin} tag. In the remaining examples below, the extra | |
5794 | column number outputs have been omitted for brevity. | |
5795 | ||
5796 | For example, this error: | |
5797 | ||
5798 | @smallexample | |
5799 | bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka | |
5800 | 'struct s'@} and 'T' @{aka 'struct t'@}) | |
5801 | 64 | return callee_4a () + callee_4b (); | |
5802 | | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ | |
5803 | | | | | |
5804 | | | T @{aka struct t@} | |
5805 | | S @{aka struct s@} | |
5806 | @end smallexample | |
5807 | ||
5808 | @noindent | |
5809 | has three locations. Its primary location is at the ``+'' token at column | |
5810 | 23. It has two secondary locations, describing the left and right-hand sides | |
5811 | of the expression, which have labels. It might be printed in JSON form as: | |
5812 | ||
5813 | @smallexample | |
5814 | @{ | |
5815 | "children": [], | |
5816 | "kind": "error", | |
5817 | "locations": [ | |
5818 | @{ | |
5819 | "caret": @{ | |
5820 | "column": 23, "file": "bad-binary-ops.c", "line": 64 | |
5821 | @} | |
5822 | @}, | |
5823 | @{ | |
5824 | "caret": @{ | |
5825 | "column": 10, "file": "bad-binary-ops.c", "line": 64 | |
5826 | @}, | |
5827 | "finish": @{ | |
5828 | "column": 21, "file": "bad-binary-ops.c", "line": 64 | |
5829 | @}, | |
5830 | "label": "S @{aka struct s@}" | |
5831 | @}, | |
5832 | @{ | |
5833 | "caret": @{ | |
5834 | "column": 25, "file": "bad-binary-ops.c", "line": 64 | |
5835 | @}, | |
5836 | "finish": @{ | |
5837 | "column": 36, "file": "bad-binary-ops.c", "line": 64 | |
5838 | @}, | |
5839 | "label": "T @{aka struct t@}" | |
5840 | @} | |
5841 | ], | |
5842 | "escape-source": false, | |
5843 | "message": "invalid operands to binary + @dots{}" | |
5844 | @} | |
5845 | @end smallexample | |
5846 | ||
5847 | If a diagnostic contains fix-it hints, it has a @code{fixits} array, | |
5848 | consisting of half-open intervals, similar to the output of | |
5849 | @option{-fdiagnostics-parseable-fixits}. For example, this diagnostic | |
5850 | with a replacement fix-it hint: | |
5851 | ||
5852 | @smallexample | |
5853 | demo.c:8:15: error: 'struct s' has no member named 'colour'; did you | |
5854 | mean 'color'? | |
5855 | 8 | return ptr->colour; | |
5856 | | ^~~~~~ | |
5857 | | color | |
5858 | @end smallexample | |
5859 | ||
5860 | @noindent | |
5861 | might be printed in JSON form as: | |
5862 | ||
5863 | @smallexample | |
5864 | @{ | |
5865 | "children": [], | |
5866 | "fixits": [ | |
5867 | @{ | |
5868 | "next": @{ | |
5869 | "column": 21, | |
5870 | "file": "demo.c", | |
5871 | "line": 8 | |
5872 | @}, | |
5873 | "start": @{ | |
5874 | "column": 15, | |
5875 | "file": "demo.c", | |
5876 | "line": 8 | |
5877 | @}, | |
5878 | "string": "color" | |
5879 | @} | |
5880 | ], | |
5881 | "kind": "error", | |
5882 | "locations": [ | |
5883 | @{ | |
5884 | "caret": @{ | |
5885 | "column": 15, | |
5886 | "file": "demo.c", | |
5887 | "line": 8 | |
5888 | @}, | |
5889 | "finish": @{ | |
5890 | "column": 20, | |
5891 | "file": "demo.c", | |
5892 | "line": 8 | |
5893 | @} | |
5894 | @} | |
5895 | ], | |
5896 | "escape-source": false, | |
5897 | "message": "\u2018struct s\u2019 has no member named @dots{}" | |
5898 | @} | |
5899 | @end smallexample | |
5900 | ||
5901 | @noindent | |
5902 | where the fix-it hint suggests replacing the text from @code{start} up | |
5903 | to but not including @code{next} with @code{string}'s value. Deletions | |
5904 | are expressed via an empty value for @code{string}, insertions by | |
5905 | having @code{start} equal @code{next}. | |
5906 | ||
5907 | If the diagnostic has a path of control-flow events associated with it, | |
5908 | it has a @code{path} array of objects representing the events. Each | |
5909 | event object has a @code{description} string, a @code{location} object, | |
5910 | along with a @code{function} string and a @code{depth} number for | |
5911 | representing interprocedural paths. The @code{function} represents the | |
5912 | current function at that event, and the @code{depth} represents the | |
5913 | stack depth relative to some baseline: the higher, the more frames are | |
5914 | within the stack. | |
5915 | ||
5916 | For example, the intraprocedural example shown for | |
5917 | @option{-fdiagnostics-path-format=} might have this JSON for its path: | |
5918 | ||
5919 | @smallexample | |
5920 | "path": [ | |
5921 | @{ | |
5922 | "depth": 0, | |
5923 | "description": "when 'PyList_New' fails, returning NULL", | |
5924 | "function": "test", | |
5925 | "location": @{ | |
5926 | "column": 10, | |
5927 | "file": "test.c", | |
5928 | "line": 25 | |
5929 | @} | |
5930 | @}, | |
5931 | @{ | |
5932 | "depth": 0, | |
5933 | "description": "when 'i < count'", | |
5934 | "function": "test", | |
5935 | "location": @{ | |
5936 | "column": 3, | |
5937 | "file": "test.c", | |
5938 | "line": 27 | |
5939 | @} | |
5940 | @}, | |
5941 | @{ | |
5942 | "depth": 0, | |
5943 | "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1", | |
5944 | "function": "test", | |
5945 | "location": @{ | |
5946 | "column": 5, | |
5947 | "file": "test.c", | |
5948 | "line": 29 | |
5949 | @} | |
5950 | @} | |
5951 | ] | |
5952 | @end smallexample | |
5953 | ||
5954 | Diagnostics have a boolean attribute @code{escape-source}, hinting whether | |
5955 | non-ASCII bytes should be escaped when printing the pertinent lines of | |
5956 | source code (@code{true} for diagnostics involving source encoding issues). | |
5957 | ||
3bd8241a DM |
5958 | @opindex fno-diagnostics-json-formatting |
5959 | @opindex fdiagnostics-json-formatting | |
5960 | @item -fno-diagnostics-json-formatting | |
5961 | By default, when JSON is emitted for diagnostics (via | |
5962 | @option{-fdiagnostics-format=sarif-stderr}, | |
5963 | @option{-fdiagnostics-format=sarif-file}, | |
5964 | @option{-fdiagnostics-format=json}, | |
5965 | @option{-fdiagnostics-format=json-stderr}, | |
5966 | @option{-fdiagnostics-format=json-file}), | |
5967 | GCC will add newlines and indentation to visually emphasize the | |
5968 | hierarchical structure of the JSON. | |
5969 | ||
5970 | Use @option{-fno-diagnostics-json-formatting} to suppress this whitespace. | |
5971 | It must be passed before the option it is to affect. | |
5972 | ||
5973 | This is intended for compatibility with tools that do not expect the output | |
5974 | to contain newlines, such as that emitted by older GCC releases. | |
5975 | ||
d77de738 ML |
5976 | @end table |
5977 | ||
5978 | @node Warning Options | |
5979 | @section Options to Request or Suppress Warnings | |
5980 | @cindex options to control warnings | |
5981 | @cindex warning messages | |
5982 | @cindex messages, warning | |
5983 | @cindex suppressing warnings | |
5984 | ||
5985 | Warnings are diagnostic messages that report constructions that | |
5986 | are not inherently erroneous but that are risky or suggest there | |
5987 | may have been an error. | |
5988 | ||
5989 | The following language-independent options do not enable specific | |
5990 | warnings but control the kinds of diagnostics produced by GCC@. | |
5991 | ||
5992 | @table @gcctabopt | |
5993 | @cindex syntax checking | |
d77de738 | 5994 | @opindex fsyntax-only |
ddf6fe37 | 5995 | @item -fsyntax-only |
d77de738 ML |
5996 | Check the code for syntax errors, but don't do anything beyond that. |
5997 | ||
d77de738 | 5998 | @opindex fmax-errors |
ddf6fe37 | 5999 | @item -fmax-errors=@var{n} |
d77de738 ML |
6000 | Limits the maximum number of error messages to @var{n}, at which point |
6001 | GCC bails out rather than attempting to continue processing the source | |
6002 | code. If @var{n} is 0 (the default), there is no limit on the number | |
6003 | of error messages produced. If @option{-Wfatal-errors} is also | |
6004 | specified, then @option{-Wfatal-errors} takes precedence over this | |
6005 | option. | |
6006 | ||
d77de738 | 6007 | @opindex w |
ddf6fe37 | 6008 | @item -w |
d77de738 ML |
6009 | Inhibit all warning messages. |
6010 | ||
d77de738 ML |
6011 | @opindex Werror |
6012 | @opindex Wno-error | |
ddf6fe37 | 6013 | @item -Werror |
d77de738 ML |
6014 | Make all warnings into errors. |
6015 | ||
d77de738 ML |
6016 | @opindex Werror= |
6017 | @opindex Wno-error= | |
ddf6fe37 | 6018 | @item -Werror= |
d77de738 ML |
6019 | Make the specified warning into an error. The specifier for a warning |
6020 | is appended; for example @option{-Werror=switch} turns the warnings | |
6021 | controlled by @option{-Wswitch} into errors. This switch takes a | |
6022 | negative form, to be used to negate @option{-Werror} for specific | |
6023 | warnings; for example @option{-Wno-error=switch} makes | |
6024 | @option{-Wswitch} warnings not be errors, even when @option{-Werror} | |
6025 | is in effect. | |
6026 | ||
6027 | The warning message for each controllable warning includes the | |
6028 | option that controls the warning. That option can then be used with | |
6029 | @option{-Werror=} and @option{-Wno-error=} as described above. | |
6030 | (Printing of the option in the warning message can be disabled using the | |
6031 | @option{-fno-diagnostics-show-option} flag.) | |
6032 | ||
6033 | Note that specifying @option{-Werror=}@var{foo} automatically implies | |
6034 | @option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not | |
6035 | imply anything. | |
6036 | ||
d77de738 ML |
6037 | @opindex Wfatal-errors |
6038 | @opindex Wno-fatal-errors | |
ddf6fe37 | 6039 | @item -Wfatal-errors |
d77de738 ML |
6040 | This option causes the compiler to abort compilation on the first error |
6041 | occurred rather than trying to keep going and printing further error | |
6042 | messages. | |
6043 | ||
6044 | @end table | |
6045 | ||
6046 | You can request many specific warnings with options beginning with | |
6047 | @samp{-W}, for example @option{-Wimplicit} to request warnings on | |
6048 | implicit declarations. Each of these specific warning options also | |
6049 | has a negative form beginning @samp{-Wno-} to turn off warnings; for | |
6050 | example, @option{-Wno-implicit}. This manual lists only one of the | |
6051 | two forms, whichever is not the default. For further | |
6052 | language-specific options also refer to @ref{C++ Dialect Options} and | |
6053 | @ref{Objective-C and Objective-C++ Dialect Options}. | |
6054 | Additional warnings can be produced by enabling the static analyzer; | |
6055 | @xref{Static Analyzer Options}. | |
6056 | ||
6057 | Some options, such as @option{-Wall} and @option{-Wextra}, turn on other | |
6058 | options, such as @option{-Wunused}, which may turn on further options, | |
6059 | such as @option{-Wunused-value}. The combined effect of positive and | |
6060 | negative forms is that more specific options have priority over less | |
6061 | specific ones, independently of their position in the command-line. For | |
6062 | options of the same specificity, the last one takes effect. Options | |
6063 | enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect | |
6064 | as if they appeared at the end of the command-line. | |
6065 | ||
6066 | When an unrecognized warning option is requested (e.g., | |
6067 | @option{-Wunknown-warning}), GCC emits a diagnostic stating | |
6068 | that the option is not recognized. However, if the @option{-Wno-} form | |
6069 | is used, the behavior is slightly different: no diagnostic is | |
6070 | produced for @option{-Wno-unknown-warning} unless other diagnostics | |
6071 | are being produced. This allows the use of new @option{-Wno-} options | |
6072 | with old compilers, but if something goes wrong, the compiler | |
6073 | warns that an unrecognized option is present. | |
6074 | ||
6075 | The effectiveness of some warnings depends on optimizations also being | |
6076 | enabled. For example @option{-Wsuggest-final-types} is more effective | |
6077 | with link-time optimization and some instances of other warnings may | |
6078 | not be issued at all unless optimization is enabled. While optimization | |
6079 | in general improves the efficacy of control and data flow sensitive | |
6080 | warnings, in some cases it may also cause false positives. | |
6081 | ||
6082 | @table @gcctabopt | |
d77de738 ML |
6083 | @opindex pedantic |
6084 | @opindex Wpedantic | |
6085 | @opindex Wno-pedantic | |
ddf6fe37 AA |
6086 | @item -Wpedantic |
6087 | @itemx -pedantic | |
d77de738 | 6088 | Issue all the warnings demanded by strict ISO C and ISO C++; |
5fccebdb JM |
6089 | diagnose all programs that use forbidden extensions, and some other |
6090 | programs that do not follow ISO C and ISO C++. This follows the version | |
6091 | of the ISO C or C++ standard specified by any @option{-std} option used. | |
d77de738 ML |
6092 | |
6093 | Valid ISO C and ISO C++ programs should compile properly with or without | |
6094 | this option (though a rare few require @option{-ansi} or a | |
5fccebdb | 6095 | @option{-std} option specifying the version of the standard)@. However, |
d77de738 | 6096 | without this option, certain GNU extensions and traditional C and C++ |
5fccebdb JM |
6097 | features are supported as well. With this option, they are diagnosed |
6098 | (or rejected with @option{-pedantic-errors}). | |
d77de738 ML |
6099 | |
6100 | @option{-Wpedantic} does not cause warning messages for use of the | |
6101 | alternate keywords whose names begin and end with @samp{__}. This alternate | |
6102 | format can also be used to disable warnings for non-ISO @samp{__intN} types, | |
6103 | i.e. @samp{__intN__}. | |
6104 | Pedantic warnings are also disabled in the expression that follows | |
6105 | @code{__extension__}. However, only system header files should use | |
6106 | these escape routes; application programs should avoid them. | |
6107 | @xref{Alternate Keywords}. | |
6108 | ||
5fccebdb JM |
6109 | Some warnings about non-conforming programs are controlled by options |
6110 | other than @option{-Wpedantic}; in many cases they are implied by | |
6111 | @option{-Wpedantic} but can be disabled separately by their specific | |
6112 | option, e.g. @option{-Wpedantic -Wno-pointer-sign}. | |
d77de738 ML |
6113 | |
6114 | Where the standard specified with @option{-std} represents a GNU | |
6115 | extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a | |
6116 | corresponding @dfn{base standard}, the version of ISO C on which the GNU | |
6117 | extended dialect is based. Warnings from @option{-Wpedantic} are given | |
6118 | where they are required by the base standard. (It does not make sense | |
6119 | for such warnings to be given only for features not in the specified GNU | |
6120 | C dialect, since by definition the GNU dialects of C include all | |
6121 | features the compiler supports with the given option, and there would be | |
6122 | nothing to warn about.) | |
6123 | ||
d77de738 | 6124 | @opindex pedantic-errors |
ddf6fe37 | 6125 | @item -pedantic-errors |
d77de738 ML |
6126 | Give an error whenever the @dfn{base standard} (see @option{-Wpedantic}) |
6127 | requires a diagnostic, in some cases where there is undefined behavior | |
6128 | at compile-time and in some other cases that do not prevent compilation | |
6129 | of programs that are valid according to the standard. This is not | |
5fccebdb JM |
6130 | equivalent to @option{-Werror=pedantic}: the latter option is unlikely to be |
6131 | useful, as it only makes errors of the diagnostics that are controlled by | |
6132 | @option{-Wpedantic}, whereas this option also affects required diagnostics that | |
6133 | are always enabled or controlled by options other than @option{-Wpedantic}. | |
6134 | ||
6135 | If you want the required diagnostics that are warnings by default to | |
6136 | be errors instead, but don't also want to enable the @option{-Wpedantic} | |
6137 | diagnostics, you can specify @option{-pedantic-errors -Wno-pedantic} | |
6138 | (or @option{-pedantic-errors -Wno-error=pedantic} to enable them but | |
6139 | only as warnings). | |
6140 | ||
6141 | Some required diagnostics are errors by default, but can be reduced to | |
6142 | warnings using @option{-fpermissive} or their specific warning option, | |
6143 | e.g. @option{-Wno-error=narrowing}. | |
6144 | ||
6145 | Some diagnostics for non-ISO practices are controlled by specific | |
6146 | warning options other than @option{-Wpedantic}, but are also made | |
6147 | errors by @option{-pedantic-errors}. For instance: | |
6148 | ||
6149 | @gccoptlist{ | |
6150 | -Wattributes @r{(for standard attributes)} | |
6151 | -Wchanges-meaning @r{(C++)} | |
6152 | -Wcomma-subscript @r{(C++23 or later)} | |
6153 | -Wdeclaration-after-statement @r{(C90 or earlier)} | |
b106f11d | 6154 | -Welaborated-enum-base @r{(C++11 or later)} |
5fccebdb JM |
6155 | -Wimplicit-int @r{(C99 or later)} |
6156 | -Wimplicit-function-declaration @r{(C99 or later)} | |
6157 | -Wincompatible-pointer-types | |
6158 | -Wint-conversion | |
6159 | -Wlong-long @r{(C90 or earlier)} | |
6160 | -Wmain | |
6161 | -Wnarrowing @r{(C++11 or later)} | |
6162 | -Wpointer-arith | |
6163 | -Wpointer-sign | |
6164 | -Wincompatible-pointer-types | |
6165 | -Wregister @r{(C++17 or later)} | |
6166 | -Wvla @r{(C90 or earlier)} | |
6167 | -Wwrite-strings @r{(C++11 or later)} | |
6168 | } | |
d77de738 | 6169 | |
ef10cb86 JM |
6170 | @opindex fpermissive |
6171 | @item -fpermissive | |
6172 | Downgrade some required diagnostics about nonconformant code from | |
6173 | errors to warnings. Thus, using @option{-fpermissive} allows some | |
6174 | nonconforming code to compile. Some C++ diagnostics are controlled | |
da4315f5 FW |
6175 | only by this flag, but it also downgrades some C and C++ diagnostics |
6176 | that have their own flag: | |
ef10cb86 JM |
6177 | |
6178 | @gccoptlist{ | |
ff9efa3f | 6179 | -Wdeclaration-missing-parameter-type @r{(C and Objective-C only)} |
55e94561 | 6180 | -Wimplicit-function-declaration @r{(C and Objective-C only)} |
4ee2aca7 | 6181 | -Wimplicit-int @r{(C and Objective-C only)} |
9715c545 | 6182 | -Wincompatible-pointer-types @r{(C and Objective-C only)} |
2c3db94d | 6183 | -Wint-conversion @r{(C and Objective-C only)} |
fa99f7d1 | 6184 | -Wnarrowing @r{(C++ and Objective-C++ only)} |
4ecfa6c4 | 6185 | -Wreturn-mismatch @r{(C and Objective-C only)} |
ef10cb86 JM |
6186 | } |
6187 | ||
da4315f5 FW |
6188 | The @option{-fpermissive} option is the default for historic C language |
6189 | modes (@option{-std=c89}, @option{-std=gnu89}, @option{-std=c90}, | |
6190 | @option{-std=gnu90}). | |
6191 | ||
d77de738 ML |
6192 | @opindex Wall |
6193 | @opindex Wno-all | |
ddf6fe37 | 6194 | @item -Wall |
d77de738 ML |
6195 | This enables all the warnings about constructions that some users |
6196 | consider questionable, and that are easy to avoid (or modify to | |
6197 | prevent the warning), even in conjunction with macros. This also | |
6198 | enables some language-specific warnings described in @ref{C++ Dialect | |
6199 | Options} and @ref{Objective-C and Objective-C++ Dialect Options}. | |
6200 | ||
6201 | @option{-Wall} turns on the following warning flags: | |
6202 | ||
43b72ede AA |
6203 | @gccoptlist{-Waddress |
6204 | -Warray-bounds=1 @r{(only with} @option{-O2}@r{)} | |
6205 | -Warray-compare | |
6206 | -Warray-parameter=2 @r{(C and Objective-C only)} | |
6207 | -Wbool-compare | |
6208 | -Wbool-operation | |
6209 | -Wc++11-compat -Wc++14-compat | |
6210 | -Wcatch-value @r{(C++ and Objective-C++ only)} | |
6211 | -Wchar-subscripts | |
6212 | -Wcomment | |
6213 | -Wdangling-pointer=2 | |
6214 | -Wduplicate-decl-specifier @r{(C and Objective-C only)} | |
6215 | -Wenum-compare @r{(in C/ObjC; this is on by default in C++)} | |
6216 | -Wenum-int-mismatch @r{(C and Objective-C only)} | |
6217 | -Wformat | |
6218 | -Wformat-overflow | |
6219 | -Wformat-truncation | |
6220 | -Wint-in-bool-context | |
6221 | -Wimplicit @r{(C and Objective-C only)} | |
6222 | -Wimplicit-int @r{(C and Objective-C only)} | |
6223 | -Wimplicit-function-declaration @r{(C and Objective-C only)} | |
6224 | -Winit-self @r{(only for C++)} | |
6225 | -Wlogical-not-parentheses | |
6226 | -Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} | |
6227 | -Wmaybe-uninitialized | |
6228 | -Wmemset-elt-size | |
6229 | -Wmemset-transposed-args | |
6230 | -Wmisleading-indentation @r{(only for C/C++)} | |
6231 | -Wmismatched-dealloc | |
6232 | -Wmismatched-new-delete @r{(only for C/C++)} | |
6233 | -Wmissing-attributes | |
6234 | -Wmissing-braces @r{(only for C/ObjC)} | |
6235 | -Wmultistatement-macros | |
6236 | -Wnarrowing @r{(only for C++)} | |
6237 | -Wnonnull | |
6238 | -Wnonnull-compare | |
6239 | -Wopenmp-simd | |
6240 | -Wparentheses | |
6241 | -Wpessimizing-move @r{(only for C++)} | |
6242 | -Wpointer-sign | |
6243 | -Wrange-loop-construct @r{(only for C++)} | |
6244 | -Wreorder | |
6245 | -Wrestrict | |
6246 | -Wreturn-type | |
6247 | -Wself-move @r{(only for C++)} | |
6248 | -Wsequence-point | |
6249 | -Wsign-compare @r{(only in C++)} | |
6250 | -Wsizeof-array-div | |
6251 | -Wsizeof-pointer-div | |
6252 | -Wsizeof-pointer-memaccess | |
6253 | -Wstrict-aliasing | |
6254 | -Wstrict-overflow=1 | |
6255 | -Wswitch | |
6256 | -Wtautological-compare | |
6257 | -Wtrigraphs | |
6258 | -Wuninitialized | |
6259 | -Wunknown-pragmas | |
6260 | -Wunused-function | |
6261 | -Wunused-label | |
6262 | -Wunused-value | |
6263 | -Wunused-variable | |
6264 | -Wuse-after-free=2 | |
6265 | -Wvla-parameter @r{(C and Objective-C only)} | |
6266 | -Wvolatile-register-var | |
d77de738 ML |
6267 | -Wzero-length-bounds} |
6268 | ||
6269 | Note that some warning flags are not implied by @option{-Wall}. Some of | |
6270 | them warn about constructions that users generally do not consider | |
6271 | questionable, but which occasionally you might wish to check for; | |
6272 | others warn about constructions that are necessary or hard to avoid in | |
6273 | some cases, and there is no simple way to modify the code to suppress | |
6274 | the warning. Some of them are enabled by @option{-Wextra} but many of | |
6275 | them must be enabled individually. | |
6276 | ||
d77de738 ML |
6277 | @opindex W |
6278 | @opindex Wextra | |
6279 | @opindex Wno-extra | |
ddf6fe37 | 6280 | @item -Wextra |
d77de738 ML |
6281 | This enables some extra warning flags that are not enabled by |
6282 | @option{-Wall}. (This option used to be called @option{-W}. The older | |
6283 | name is still supported, but the newer name is more descriptive.) | |
6284 | ||
43b72ede AA |
6285 | @gccoptlist{-Wclobbered |
6286 | -Wcast-function-type | |
6287 | -Wdeprecated-copy @r{(C++ only)} | |
6288 | -Wempty-body | |
6289 | -Wenum-conversion @r{(C only)} | |
6290 | -Wignored-qualifiers | |
6291 | -Wimplicit-fallthrough=3 | |
6292 | -Wmissing-field-initializers | |
6293 | -Wmissing-parameter-type @r{(C only)} | |
6294 | -Wold-style-declaration @r{(C only)} | |
6295 | -Woverride-init | |
6296 | -Wsign-compare @r{(C only)} | |
6297 | -Wstring-compare | |
6298 | -Wredundant-move @r{(only for C++)} | |
6299 | -Wtype-limits | |
6300 | -Wuninitialized | |
6301 | -Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)} | |
6302 | -Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)} | |
d77de738 ML |
6303 | -Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}} |
6304 | ||
6305 | ||
6306 | The option @option{-Wextra} also prints warning messages for the | |
6307 | following cases: | |
6308 | ||
6309 | @itemize @bullet | |
6310 | ||
6311 | @item | |
6312 | A pointer is compared against integer zero with @code{<}, @code{<=}, | |
6313 | @code{>}, or @code{>=}. | |
6314 | ||
6315 | @item | |
6316 | (C++ only) An enumerator and a non-enumerator both appear in a | |
6317 | conditional expression. | |
6318 | ||
6319 | @item | |
6320 | (C++ only) Ambiguous virtual bases. | |
6321 | ||
6322 | @item | |
6323 | (C++ only) Subscripting an array that has been declared @code{register}. | |
6324 | ||
6325 | @item | |
6326 | (C++ only) Taking the address of a variable that has been declared | |
6327 | @code{register}. | |
6328 | ||
6329 | @item | |
6330 | (C++ only) A base class is not initialized in the copy constructor | |
6331 | of a derived class. | |
6332 | ||
6333 | @end itemize | |
6334 | ||
d77de738 ML |
6335 | @opindex Wabi |
6336 | @opindex Wno-abi | |
ddf6fe37 | 6337 | @item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)} |
d77de738 ML |
6338 | |
6339 | Warn about code affected by ABI changes. This includes code that may | |
6340 | not be compatible with the vendor-neutral C++ ABI as well as the psABI | |
6341 | for the particular target. | |
6342 | ||
6343 | Since G++ now defaults to updating the ABI with each major release, | |
6344 | normally @option{-Wabi} warns only about C++ ABI compatibility | |
6345 | problems if there is a check added later in a release series for an | |
6346 | ABI issue discovered since the initial release. @option{-Wabi} warns | |
6347 | about more things if an older ABI version is selected (with | |
6348 | @option{-fabi-version=@var{n}}). | |
6349 | ||
6350 | @option{-Wabi} can also be used with an explicit version number to | |
6351 | warn about C++ ABI compatibility with a particular @option{-fabi-version} | |
6352 | level, e.g.@: @option{-Wabi=2} to warn about changes relative to | |
6353 | @option{-fabi-version=2}. | |
6354 | ||
6355 | If an explicit version number is provided and | |
6356 | @option{-fabi-compat-version} is not specified, the version number | |
6357 | from this option is used for compatibility aliases. If no explicit | |
6358 | version number is provided with this option, but | |
6359 | @option{-fabi-compat-version} is specified, that version number is | |
6360 | used for C++ ABI warnings. | |
6361 | ||
6362 | Although an effort has been made to warn about | |
6363 | all such cases, there are probably some cases that are not warned about, | |
6364 | even though G++ is generating incompatible code. There may also be | |
6365 | cases where warnings are emitted even though the code that is generated | |
6366 | is compatible. | |
6367 | ||
6368 | You should rewrite your code to avoid these warnings if you are | |
6369 | concerned about the fact that code generated by G++ may not be binary | |
6370 | compatible with code generated by other compilers. | |
6371 | ||
6372 | Known incompatibilities in @option{-fabi-version=2} (which was the | |
6373 | default from GCC 3.4 to 4.9) include: | |
6374 | ||
6375 | @itemize @bullet | |
6376 | ||
6377 | @item | |
6378 | A template with a non-type template parameter of reference type was | |
6379 | mangled incorrectly: | |
6380 | @smallexample | |
6381 | extern int N; | |
6382 | template <int &> struct S @{@}; | |
6383 | void n (S<N>) @{2@} | |
6384 | @end smallexample | |
6385 | ||
6386 | This was fixed in @option{-fabi-version=3}. | |
6387 | ||
6388 | @item | |
6389 | SIMD vector types declared using @code{__attribute ((vector_size))} were | |
6390 | mangled in a non-standard way that does not allow for overloading of | |
6391 | functions taking vectors of different sizes. | |
6392 | ||
6393 | The mangling was changed in @option{-fabi-version=4}. | |
6394 | ||
6395 | @item | |
6396 | @code{__attribute ((const))} and @code{noreturn} were mangled as type | |
6397 | qualifiers, and @code{decltype} of a plain declaration was folded away. | |
6398 | ||
6399 | These mangling issues were fixed in @option{-fabi-version=5}. | |
6400 | ||
6401 | @item | |
6402 | Scoped enumerators passed as arguments to a variadic function are | |
6403 | promoted like unscoped enumerators, causing @code{va_arg} to complain. | |
6404 | On most targets this does not actually affect the parameter passing | |
6405 | ABI, as there is no way to pass an argument smaller than @code{int}. | |
6406 | ||
6407 | Also, the ABI changed the mangling of template argument packs, | |
6408 | @code{const_cast}, @code{static_cast}, prefix increment/decrement, and | |
6409 | a class scope function used as a template argument. | |
6410 | ||
6411 | These issues were corrected in @option{-fabi-version=6}. | |
6412 | ||
6413 | @item | |
6414 | Lambdas in default argument scope were mangled incorrectly, and the | |
6415 | ABI changed the mangling of @code{nullptr_t}. | |
6416 | ||
6417 | These issues were corrected in @option{-fabi-version=7}. | |
6418 | ||
6419 | @item | |
6420 | When mangling a function type with function-cv-qualifiers, the | |
6421 | un-qualified function type was incorrectly treated as a substitution | |
6422 | candidate. | |
6423 | ||
6424 | This was fixed in @option{-fabi-version=8}, the default for GCC 5.1. | |
6425 | ||
6426 | @item | |
6427 | @code{decltype(nullptr)} incorrectly had an alignment of 1, leading to | |
6428 | unaligned accesses. Note that this did not affect the ABI of a | |
6429 | function with a @code{nullptr_t} parameter, as parameters have a | |
6430 | minimum alignment. | |
6431 | ||
6432 | This was fixed in @option{-fabi-version=9}, the default for GCC 5.2. | |
6433 | ||
6434 | @item | |
6435 | Target-specific attributes that affect the identity of a type, such as | |
6436 | ia32 calling conventions on a function type (stdcall, regparm, etc.), | |
6437 | did not affect the mangled name, leading to name collisions when | |
6438 | function pointers were used as template arguments. | |
6439 | ||
6440 | This was fixed in @option{-fabi-version=10}, the default for GCC 6.1. | |
6441 | ||
6442 | @end itemize | |
6443 | ||
6444 | This option also enables warnings about psABI-related changes. | |
6445 | The known psABI changes at this point include: | |
6446 | ||
6447 | @itemize @bullet | |
6448 | ||
6449 | @item | |
6450 | For SysV/x86-64, unions with @code{long double} members are | |
6451 | passed in memory as specified in psABI. Prior to GCC 4.4, this was not | |
6452 | the case. For example: | |
6453 | ||
6454 | @smallexample | |
6455 | union U @{ | |
6456 | long double ld; | |
6457 | int i; | |
6458 | @}; | |
6459 | @end smallexample | |
6460 | ||
6461 | @noindent | |
6462 | @code{union U} is now always passed in memory. | |
6463 | ||
6464 | @end itemize | |
6465 | ||
e2f939d3 JM |
6466 | @item -Wno-changes-meaning @r{(C++ and Objective-C++ only)} |
6467 | C++ requires that unqualified uses of a name within a class have the | |
6468 | same meaning in the complete scope of the class, so declaring the name | |
6469 | after using it is ill-formed: | |
6470 | @smallexample | |
6471 | struct A; | |
6472 | struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning | |
6473 | struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning | |
6474 | @end smallexample | |
6475 | By default, the B1 case is only a warning because the two declarations | |
6476 | have the same type, while the B2 case is an error. Both diagnostics | |
6477 | can be disabled with @option{-Wno-changes-meaning}. Alternately, the | |
6478 | error case can be reduced to a warning with | |
6479 | @option{-Wno-error=changes-meaning} or @option{-fpermissive}. | |
6480 | ||
6481 | Both diagnostics are also suppressed by @option{-fms-extensions}. | |
6482 | ||
d77de738 ML |
6483 | @opindex Wchar-subscripts |
6484 | @opindex Wno-char-subscripts | |
ddf6fe37 | 6485 | @item -Wchar-subscripts |
d77de738 ML |
6486 | Warn if an array subscript has type @code{char}. This is a common cause |
6487 | of error, as programmers often forget that this type is signed on some | |
6488 | machines. | |
6489 | This warning is enabled by @option{-Wall}. | |
6490 | ||
d77de738 ML |
6491 | @opindex Wno-coverage-mismatch |
6492 | @opindex Wcoverage-mismatch | |
ddf6fe37 | 6493 | @item -Wno-coverage-mismatch |
d77de738 ML |
6494 | Warn if feedback profiles do not match when using the |
6495 | @option{-fprofile-use} option. | |
6496 | If a source file is changed between compiling with @option{-fprofile-generate} | |
6497 | and with @option{-fprofile-use}, the files with the profile feedback can fail | |
6498 | to match the source file and GCC cannot use the profile feedback | |
6499 | information. By default, this warning is enabled and is treated as an | |
6500 | error. @option{-Wno-coverage-mismatch} can be used to disable the | |
6501 | warning or @option{-Wno-error=coverage-mismatch} can be used to | |
6502 | disable the error. Disabling the error for this warning can result in | |
6503 | poorly optimized code and is useful only in the | |
6504 | case of very minor changes such as bug fixes to an existing code-base. | |
6505 | Completely disabling the warning is not recommended. | |
6506 | ||
d77de738 ML |
6507 | @opindex Wno-coverage-invalid-line-number |
6508 | @opindex Wcoverage-invalid-line-number | |
ddf6fe37 | 6509 | @item -Wno-coverage-invalid-line-number |
d77de738 ML |
6510 | Warn in case a function ends earlier than it begins due |
6511 | to an invalid linenum macros. The warning is emitted only | |
6512 | with @option{--coverage} enabled. | |
6513 | ||
6514 | By default, this warning is enabled and is treated as an | |
6515 | error. @option{-Wno-coverage-invalid-line-number} can be used to disable the | |
6516 | warning or @option{-Wno-error=coverage-invalid-line-number} can be used to | |
6517 | disable the error. | |
6518 | ||
d77de738 ML |
6519 | @opindex Wno-cpp |
6520 | @opindex Wcpp | |
ddf6fe37 | 6521 | @item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)} |
d77de738 ML |
6522 | Suppress warning messages emitted by @code{#warning} directives. |
6523 | ||
d77de738 ML |
6524 | @opindex Wdouble-promotion |
6525 | @opindex Wno-double-promotion | |
ddf6fe37 | 6526 | @item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
6527 | Give a warning when a value of type @code{float} is implicitly |
6528 | promoted to @code{double}. CPUs with a 32-bit ``single-precision'' | |
6529 | floating-point unit implement @code{float} in hardware, but emulate | |
6530 | @code{double} in software. On such a machine, doing computations | |
6531 | using @code{double} values is much more expensive because of the | |
6532 | overhead required for software emulation. | |
6533 | ||
6534 | It is easy to accidentally do computations with @code{double} because | |
6535 | floating-point literals are implicitly of type @code{double}. For | |
6536 | example, in: | |
6537 | @smallexample | |
6538 | @group | |
6539 | float area(float radius) | |
6540 | @{ | |
6541 | return 3.14159 * radius * radius; | |
6542 | @} | |
6543 | @end group | |
6544 | @end smallexample | |
6545 | the compiler performs the entire computation with @code{double} | |
6546 | because the floating-point literal is a @code{double}. | |
6547 | ||
d77de738 ML |
6548 | @opindex Wduplicate-decl-specifier |
6549 | @opindex Wno-duplicate-decl-specifier | |
ddf6fe37 | 6550 | @item -Wduplicate-decl-specifier @r{(C and Objective-C only)} |
d77de738 ML |
6551 | Warn if a declaration has duplicate @code{const}, @code{volatile}, |
6552 | @code{restrict} or @code{_Atomic} specifier. This warning is enabled by | |
6553 | @option{-Wall}. | |
6554 | ||
d77de738 ML |
6555 | @opindex Wformat |
6556 | @opindex Wno-format | |
6557 | @opindex ffreestanding | |
6558 | @opindex fno-builtin | |
6559 | @opindex Wformat= | |
ddf6fe37 AA |
6560 | @item -Wformat |
6561 | @itemx -Wformat=@var{n} | |
d77de738 ML |
6562 | Check calls to @code{printf} and @code{scanf}, etc., to make sure that |
6563 | the arguments supplied have types appropriate to the format string | |
6564 | specified, and that the conversions specified in the format string make | |
6565 | sense. This includes standard functions, and others specified by format | |
6566 | attributes (@pxref{Function Attributes}), in the @code{printf}, | |
6567 | @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension, | |
6568 | not in the C standard) families (or other target-specific families). | |
6569 | Which functions are checked without format attributes having been | |
6570 | specified depends on the standard version selected, and such checks of | |
6571 | functions without the attribute specified are disabled by | |
6572 | @option{-ffreestanding} or @option{-fno-builtin}. | |
6573 | ||
6574 | The formats are checked against the format features supported by GNU | |
6575 | libc version 2.2. These include all ISO C90 and C99 features, as well | |
6576 | as features from the Single Unix Specification and some BSD and GNU | |
6577 | extensions. Other library implementations may not support all these | |
6578 | features; GCC does not support warning about features that go beyond a | |
6579 | particular library's limitations. However, if @option{-Wpedantic} is used | |
6580 | with @option{-Wformat}, warnings are given about format features not | |
6581 | in the selected standard version (but not for @code{strfmon} formats, | |
6582 | since those are not in any version of the C standard). @xref{C Dialect | |
6583 | Options,,Options Controlling C Dialect}. | |
6584 | ||
6585 | @table @gcctabopt | |
d77de738 ML |
6586 | @opindex Wformat |
6587 | @opindex Wformat=1 | |
ddf6fe37 AA |
6588 | @item -Wformat=1 |
6589 | @itemx -Wformat | |
d77de738 ML |
6590 | Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and |
6591 | @option{-Wno-format} is equivalent to @option{-Wformat=0}. Since | |
6592 | @option{-Wformat} also checks for null format arguments for several | |
6593 | functions, @option{-Wformat} also implies @option{-Wnonnull}. Some | |
6594 | aspects of this level of format checking can be disabled by the | |
6595 | options: @option{-Wno-format-contains-nul}, | |
6596 | @option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}. | |
6597 | @option{-Wformat} is enabled by @option{-Wall}. | |
6598 | ||
d77de738 | 6599 | @opindex Wformat=2 |
ddf6fe37 | 6600 | @item -Wformat=2 |
d77de738 ML |
6601 | Enable @option{-Wformat} plus additional format checks. Currently |
6602 | equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security | |
6603 | -Wformat-y2k}. | |
6604 | @end table | |
6605 | ||
d77de738 ML |
6606 | @opindex Wno-format-contains-nul |
6607 | @opindex Wformat-contains-nul | |
ddf6fe37 | 6608 | @item -Wno-format-contains-nul |
d77de738 ML |
6609 | If @option{-Wformat} is specified, do not warn about format strings that |
6610 | contain NUL bytes. | |
6611 | ||
d77de738 ML |
6612 | @opindex Wno-format-extra-args |
6613 | @opindex Wformat-extra-args | |
ddf6fe37 | 6614 | @item -Wno-format-extra-args |
d77de738 ML |
6615 | If @option{-Wformat} is specified, do not warn about excess arguments to a |
6616 | @code{printf} or @code{scanf} format function. The C standard specifies | |
6617 | that such arguments are ignored. | |
6618 | ||
6619 | Where the unused arguments lie between used arguments that are | |
6620 | specified with @samp{$} operand number specifications, normally | |
6621 | warnings are still given, since the implementation could not know what | |
6622 | type to pass to @code{va_arg} to skip the unused arguments. However, | |
6623 | in the case of @code{scanf} formats, this option suppresses the | |
6624 | warning if the unused arguments are all pointers, since the Single | |
6625 | Unix Specification says that such unused arguments are allowed. | |
6626 | ||
d77de738 ML |
6627 | @opindex Wformat-overflow |
6628 | @opindex Wno-format-overflow | |
ddf6fe37 AA |
6629 | @item -Wformat-overflow |
6630 | @itemx -Wformat-overflow=@var{level} | |
d77de738 ML |
6631 | Warn about calls to formatted input/output functions such as @code{sprintf} |
6632 | and @code{vsprintf} that might overflow the destination buffer. When the | |
6633 | exact number of bytes written by a format directive cannot be determined | |
6634 | at compile-time it is estimated based on heuristics that depend on the | |
6635 | @var{level} argument and on optimization. While enabling optimization | |
6636 | will in most cases improve the accuracy of the warning, it may also | |
6637 | result in false positives. | |
6638 | ||
6639 | @table @gcctabopt | |
d77de738 ML |
6640 | @opindex Wformat-overflow |
6641 | @opindex Wno-format-overflow | |
ddf6fe37 AA |
6642 | @item -Wformat-overflow |
6643 | @itemx -Wformat-overflow=1 | |
d77de738 ML |
6644 | Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat} |
6645 | employs a conservative approach that warns only about calls that most | |
6646 | likely overflow the buffer. At this level, numeric arguments to format | |
6647 | directives with unknown values are assumed to have the value of one, and | |
6648 | strings of unknown length to be empty. Numeric arguments that are known | |
6649 | to be bounded to a subrange of their type, or string arguments whose output | |
6650 | is bounded either by their directive's precision or by a finite set of | |
6651 | string literals, are assumed to take on the value within the range that | |
6652 | results in the most bytes on output. For example, the call to @code{sprintf} | |
6653 | below is diagnosed because even with both @var{a} and @var{b} equal to zero, | |
6654 | the terminating NUL character (@code{'\0'}) appended by the function | |
6655 | to the destination buffer will be written past its end. Increasing | |
6656 | the size of the buffer by a single byte is sufficient to avoid the | |
6657 | warning, though it may not be sufficient to avoid the overflow. | |
6658 | ||
6659 | @smallexample | |
6660 | void f (int a, int b) | |
6661 | @{ | |
6662 | char buf [13]; | |
6663 | sprintf (buf, "a = %i, b = %i\n", a, b); | |
6664 | @} | |
6665 | @end smallexample | |
6666 | ||
6667 | @item -Wformat-overflow=2 | |
6668 | Level @var{2} warns also about calls that might overflow the destination | |
6669 | buffer given an argument of sufficient length or magnitude. At level | |
6670 | @var{2}, unknown numeric arguments are assumed to have the minimum | |
6671 | representable value for signed types with a precision greater than 1, and | |
6672 | the maximum representable value otherwise. Unknown string arguments whose | |
6673 | length cannot be assumed to be bounded either by the directive's precision, | |
6674 | or by a finite set of string literals they may evaluate to, or the character | |
6675 | array they may point to, are assumed to be 1 character long. | |
6676 | ||
6677 | At level @var{2}, the call in the example above is again diagnosed, but | |
6678 | this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first | |
6679 | @code{%i} directive will write some of its digits beyond the end of | |
6680 | the destination buffer. To make the call safe regardless of the values | |
6681 | of the two variables, the size of the destination buffer must be increased | |
6682 | to at least 34 bytes. GCC includes the minimum size of the buffer in | |
6683 | an informational note following the warning. | |
6684 | ||
6685 | An alternative to increasing the size of the destination buffer is to | |
6686 | constrain the range of formatted values. The maximum length of string | |
6687 | arguments can be bounded by specifying the precision in the format | |
6688 | directive. When numeric arguments of format directives can be assumed | |
6689 | to be bounded by less than the precision of their type, choosing | |
6690 | an appropriate length modifier to the format specifier will reduce | |
6691 | the required buffer size. For example, if @var{a} and @var{b} in the | |
6692 | example above can be assumed to be within the precision of | |
6693 | the @code{short int} type then using either the @code{%hi} format | |
6694 | directive or casting the argument to @code{short} reduces the maximum | |
6695 | required size of the buffer to 24 bytes. | |
6696 | ||
6697 | @smallexample | |
6698 | void f (int a, int b) | |
6699 | @{ | |
6700 | char buf [23]; | |
6701 | sprintf (buf, "a = %hi, b = %i\n", a, (short)b); | |
6702 | @} | |
6703 | @end smallexample | |
6704 | @end table | |
6705 | ||
d77de738 ML |
6706 | @opindex Wno-format-zero-length |
6707 | @opindex Wformat-zero-length | |
ddf6fe37 | 6708 | @item -Wno-format-zero-length |
d77de738 ML |
6709 | If @option{-Wformat} is specified, do not warn about zero-length formats. |
6710 | The C standard specifies that zero-length formats are allowed. | |
6711 | ||
d77de738 ML |
6712 | @opindex Wformat-nonliteral |
6713 | @opindex Wno-format-nonliteral | |
ddf6fe37 | 6714 | @item -Wformat-nonliteral |
d77de738 ML |
6715 | If @option{-Wformat} is specified, also warn if the format string is not a |
6716 | string literal and so cannot be checked, unless the format function | |
6717 | takes its format arguments as a @code{va_list}. | |
6718 | ||
d77de738 ML |
6719 | @opindex Wformat-security |
6720 | @opindex Wno-format-security | |
ddf6fe37 | 6721 | @item -Wformat-security |
d77de738 ML |
6722 | If @option{-Wformat} is specified, also warn about uses of format |
6723 | functions that represent possible security problems. At present, this | |
6724 | warns about calls to @code{printf} and @code{scanf} functions where the | |
6725 | format string is not a string literal and there are no format arguments, | |
6726 | as in @code{printf (foo);}. This may be a security hole if the format | |
6727 | string came from untrusted input and contains @samp{%n}. (This is | |
6728 | currently a subset of what @option{-Wformat-nonliteral} warns about, but | |
6729 | in future warnings may be added to @option{-Wformat-security} that are not | |
6730 | included in @option{-Wformat-nonliteral}.) | |
6731 | ||
d77de738 ML |
6732 | @opindex Wformat-signedness |
6733 | @opindex Wno-format-signedness | |
ddf6fe37 | 6734 | @item -Wformat-signedness |
d77de738 ML |
6735 | If @option{-Wformat} is specified, also warn if the format string |
6736 | requires an unsigned argument and the argument is signed and vice versa. | |
6737 | ||
d77de738 ML |
6738 | @opindex Wformat-truncation |
6739 | @opindex Wno-format-truncation | |
ddf6fe37 AA |
6740 | @item -Wformat-truncation |
6741 | @itemx -Wformat-truncation=@var{level} | |
d77de738 ML |
6742 | Warn about calls to formatted input/output functions such as @code{snprintf} |
6743 | and @code{vsnprintf} that might result in output truncation. When the exact | |
6744 | number of bytes written by a format directive cannot be determined at | |
6745 | compile-time it is estimated based on heuristics that depend on | |
6746 | the @var{level} argument and on optimization. While enabling optimization | |
6747 | will in most cases improve the accuracy of the warning, it may also result | |
6748 | in false positives. Except as noted otherwise, the option uses the same | |
6749 | logic @option{-Wformat-overflow}. | |
6750 | ||
6751 | @table @gcctabopt | |
d77de738 ML |
6752 | @opindex Wformat-truncation |
6753 | @opindex Wno-format-truncation | |
ddf6fe37 AA |
6754 | @item -Wformat-truncation |
6755 | @itemx -Wformat-truncation=1 | |
d77de738 ML |
6756 | Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat} |
6757 | employs a conservative approach that warns only about calls to bounded | |
6758 | functions whose return value is unused and that will most likely result | |
6759 | in output truncation. | |
6760 | ||
6761 | @item -Wformat-truncation=2 | |
6762 | Level @var{2} warns also about calls to bounded functions whose return | |
6763 | value is used and that might result in truncation given an argument of | |
6764 | sufficient length or magnitude. | |
6765 | @end table | |
6766 | ||
d77de738 ML |
6767 | @opindex Wformat-y2k |
6768 | @opindex Wno-format-y2k | |
ddf6fe37 | 6769 | @item -Wformat-y2k |
d77de738 ML |
6770 | If @option{-Wformat} is specified, also warn about @code{strftime} |
6771 | formats that may yield only a two-digit year. | |
6772 | ||
d77de738 ML |
6773 | @opindex Wnonnull |
6774 | @opindex Wno-nonnull | |
ddf6fe37 | 6775 | @item -Wnonnull |
d77de738 ML |
6776 | Warn about passing a null pointer for arguments marked as |
6777 | requiring a non-null value by the @code{nonnull} function attribute. | |
6778 | ||
6779 | @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It | |
6780 | can be disabled with the @option{-Wno-nonnull} option. | |
6781 | ||
d77de738 ML |
6782 | @opindex Wnonnull-compare |
6783 | @opindex Wno-nonnull-compare | |
ddf6fe37 | 6784 | @item -Wnonnull-compare |
d77de738 ML |
6785 | Warn when comparing an argument marked with the @code{nonnull} |
6786 | function attribute against null inside the function. | |
6787 | ||
6788 | @option{-Wnonnull-compare} is included in @option{-Wall}. It | |
6789 | can be disabled with the @option{-Wno-nonnull-compare} option. | |
6790 | ||
d77de738 ML |
6791 | @opindex Wnull-dereference |
6792 | @opindex Wno-null-dereference | |
ddf6fe37 | 6793 | @item -Wnull-dereference |
d77de738 ML |
6794 | Warn if the compiler detects paths that trigger erroneous or |
6795 | undefined behavior due to dereferencing a null pointer. This option | |
6796 | is only active when @option{-fdelete-null-pointer-checks} is active, | |
6797 | which is enabled by optimizations in most targets. The precision of | |
6798 | the warnings depends on the optimization options used. | |
6799 | ||
2ae5384d JM |
6800 | @opindex Wnrvo |
6801 | @opindex Wno-nrvo | |
6802 | @item -Wnrvo @r{(C++ and Objective-C++ only)} | |
6803 | Warn if the compiler does not elide the copy from a local variable to | |
6804 | the return value of a function in a context where it is allowed by | |
6805 | [class.copy.elision]. This elision is commonly known as the Named | |
6806 | Return Value Optimization. For instance, in the example below the | |
72cfa0f7 | 6807 | compiler cannot elide copies from both v1 and v2, so it elides neither. |
2ae5384d JM |
6808 | |
6809 | @smallexample | |
6810 | std::vector<int> f() | |
6811 | @{ | |
6812 | std::vector<int> v1, v2; | |
6813 | // ... | |
6814 | if (cond) return v1; | |
6815 | else return v2; // warning: not eliding copy | |
6816 | @} | |
6817 | @end smallexample | |
6818 | ||
d77de738 ML |
6819 | @opindex Winfinite-recursion |
6820 | @opindex Wno-infinite-recursion | |
ddf6fe37 | 6821 | @item -Winfinite-recursion |
d77de738 ML |
6822 | Warn about infinitely recursive calls. The warning is effective at all |
6823 | optimization levels but requires optimization in order to detect infinite | |
6824 | recursion in calls between two or more functions. | |
6825 | @option{-Winfinite-recursion} is included in @option{-Wall}. | |
6826 | ||
ce51e843 ML |
6827 | Compare with @option{-Wanalyzer-infinite-recursion} which provides a |
6828 | similar diagnostic, but is implemented in a different way (as part of | |
6829 | @option{-fanalyzer}). | |
6830 | ||
d77de738 ML |
6831 | @opindex Winit-self |
6832 | @opindex Wno-init-self | |
ddf6fe37 | 6833 | @item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
6834 | Warn about uninitialized variables that are initialized with themselves. |
6835 | Note this option can only be used with the @option{-Wuninitialized} option. | |
6836 | ||
6837 | For example, GCC warns about @code{i} being uninitialized in the | |
6838 | following snippet only when @option{-Winit-self} has been specified: | |
6839 | @smallexample | |
6840 | @group | |
6841 | int f() | |
6842 | @{ | |
6843 | int i = i; | |
6844 | return i; | |
6845 | @} | |
6846 | @end group | |
6847 | @end smallexample | |
6848 | ||
6849 | This warning is enabled by @option{-Wall} in C++. | |
6850 | ||
d77de738 ML |
6851 | @opindex Wimplicit-int |
6852 | @opindex Wno-implicit-int | |
ddf6fe37 | 6853 | @item -Wno-implicit-int @r{(C and Objective-C only)} |
d77de738 | 6854 | This option controls warnings when a declaration does not specify a type. |
4ee2aca7 FW |
6855 | This warning is enabled by default, as an error, in C99 and later |
6856 | dialects of C, and also by @option{-Wall}. The error can be downgraded | |
6857 | to a warning using @option{-fpermissive} (along with certain other | |
6858 | errors), or for this error alone, with @option{-Wno-error=implicit-int}. | |
d77de738 | 6859 | |
5fccebdb JM |
6860 | This warning is upgraded to an error by @option{-pedantic-errors}. |
6861 | ||
d77de738 ML |
6862 | @opindex Wimplicit-function-declaration |
6863 | @opindex Wno-implicit-function-declaration | |
ddf6fe37 | 6864 | @item -Wno-implicit-function-declaration @r{(C and Objective-C only)} |
d77de738 | 6865 | This option controls warnings when a function is used before being declared. |
55e94561 FW |
6866 | This warning is enabled by default, as an error, in C99 and later |
6867 | dialects of C, and also by @option{-Wall}. The error can be downgraded | |
6868 | to a warning using @option{-fpermissive} (along with certain other | |
6869 | errors), or for this error alone, with | |
6870 | @option{-Wno-error=implicit-function-declaration}. | |
5fccebdb JM |
6871 | |
6872 | This warning is upgraded to an error by @option{-pedantic-errors}. | |
d77de738 | 6873 | |
d77de738 ML |
6874 | @opindex Wimplicit |
6875 | @opindex Wno-implicit | |
ddf6fe37 | 6876 | @item -Wimplicit @r{(C and Objective-C only)} |
d77de738 ML |
6877 | Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}. |
6878 | This warning is enabled by @option{-Wall}. | |
6879 | ||
24592abd MP |
6880 | @opindex Whardened |
6881 | @opindex Wno-hardened | |
6882 | @item -Whardened | |
6883 | Warn when @option{-fhardened} did not enable an option from its set (for | |
6884 | which see @option{-fhardened}). For instance, using @option{-fhardened} | |
6885 | and @option{-fstack-protector} at the same time on the command line causes | |
6886 | @option{-Whardened} to warn because @option{-fstack-protector-strong} is | |
6887 | not enabled by @option{-fhardened}. | |
6888 | ||
6889 | This warning is enabled by default and has effect only when @option{-fhardened} | |
6890 | is enabled. | |
6891 | ||
d77de738 ML |
6892 | @opindex Wimplicit-fallthrough |
6893 | @opindex Wno-implicit-fallthrough | |
ddf6fe37 | 6894 | @item -Wimplicit-fallthrough |
d77de738 ML |
6895 | @option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3} |
6896 | and @option{-Wno-implicit-fallthrough} is the same as | |
6897 | @option{-Wimplicit-fallthrough=0}. | |
6898 | ||
d77de738 | 6899 | @opindex Wimplicit-fallthrough= |
ddf6fe37 | 6900 | @item -Wimplicit-fallthrough=@var{n} |
d77de738 ML |
6901 | Warn when a switch case falls through. For example: |
6902 | ||
6903 | @smallexample | |
6904 | @group | |
6905 | switch (cond) | |
6906 | @{ | |
6907 | case 1: | |
6908 | a = 1; | |
6909 | break; | |
6910 | case 2: | |
6911 | a = 2; | |
6912 | case 3: | |
6913 | a = 3; | |
6914 | break; | |
6915 | @} | |
6916 | @end group | |
6917 | @end smallexample | |
6918 | ||
6919 | This warning does not warn when the last statement of a case cannot | |
6920 | fall through, e.g. when there is a return statement or a call to function | |
6921 | declared with the noreturn attribute. @option{-Wimplicit-fallthrough=} | |
6922 | also takes into account control flow statements, such as ifs, and only | |
6923 | warns when appropriate. E.g.@: | |
6924 | ||
6925 | @smallexample | |
6926 | @group | |
6927 | switch (cond) | |
6928 | @{ | |
6929 | case 1: | |
6930 | if (i > 3) @{ | |
6931 | bar (5); | |
6932 | break; | |
6933 | @} else if (i < 1) @{ | |
6934 | bar (0); | |
6935 | @} else | |
6936 | return; | |
6937 | default: | |
6938 | @dots{} | |
6939 | @} | |
6940 | @end group | |
6941 | @end smallexample | |
6942 | ||
6943 | Since there are occasions where a switch case fall through is desirable, | |
6944 | GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is | |
6945 | to be used along with a null statement to suppress this warning that | |
6946 | would normally occur: | |
6947 | ||
6948 | @smallexample | |
6949 | @group | |
6950 | switch (cond) | |
6951 | @{ | |
6952 | case 1: | |
6953 | bar (0); | |
6954 | __attribute__ ((fallthrough)); | |
6955 | default: | |
6956 | @dots{} | |
6957 | @} | |
6958 | @end group | |
6959 | @end smallexample | |
6960 | ||
6961 | C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough} | |
6962 | warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11 | |
6963 | or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension. | |
6964 | Instead of these attributes, it is also possible to add a fallthrough comment | |
6965 | to silence the warning. The whole body of the C or C++ style comment should | |
6966 | match the given regular expressions listed below. The option argument @var{n} | |
6967 | specifies what kind of comments are accepted: | |
6968 | ||
6969 | @itemize @bullet | |
6970 | ||
6971 | @item @option{-Wimplicit-fallthrough=0} disables the warning altogether. | |
6972 | ||
6973 | @item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular | |
6974 | expression, any comment is used as fallthrough comment. | |
6975 | ||
6976 | @item @option{-Wimplicit-fallthrough=2} case insensitively matches | |
6977 | @code{.*falls?[ \t-]*thr(ough|u).*} regular expression. | |
6978 | ||
6979 | @item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the | |
6980 | following regular expressions: | |
6981 | ||
6982 | @itemize @bullet | |
6983 | ||
6984 | @item @code{-fallthrough} | |
6985 | ||
6986 | @item @code{@@fallthrough@@} | |
6987 | ||
6988 | @item @code{lint -fallthrough[ \t]*} | |
6989 | ||
6990 | @item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?} | |
6991 | ||
6992 | @item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?} | |
6993 | ||
6994 | @item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?} | |
6995 | ||
6996 | @end itemize | |
6997 | ||
6998 | @item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the | |
6999 | following regular expressions: | |
7000 | ||
7001 | @itemize @bullet | |
7002 | ||
7003 | @item @code{-fallthrough} | |
7004 | ||
7005 | @item @code{@@fallthrough@@} | |
7006 | ||
7007 | @item @code{lint -fallthrough[ \t]*} | |
7008 | ||
7009 | @item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*} | |
7010 | ||
7011 | @end itemize | |
7012 | ||
7013 | @item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as | |
7014 | fallthrough comments, only attributes disable the warning. | |
7015 | ||
7016 | @end itemize | |
7017 | ||
7018 | The comment needs to be followed after optional whitespace and other comments | |
7019 | by @code{case} or @code{default} keywords or by a user label that precedes some | |
7020 | @code{case} or @code{default} label. | |
7021 | ||
7022 | @smallexample | |
7023 | @group | |
7024 | switch (cond) | |
7025 | @{ | |
7026 | case 1: | |
7027 | bar (0); | |
7028 | /* FALLTHRU */ | |
7029 | default: | |
7030 | @dots{} | |
7031 | @} | |
7032 | @end group | |
7033 | @end smallexample | |
7034 | ||
7035 | The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}. | |
7036 | ||
d77de738 ML |
7037 | @opindex Wif-not-aligned |
7038 | @opindex Wno-if-not-aligned | |
ddf6fe37 | 7039 | @item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
7040 | Control if warnings triggered by the @code{warn_if_not_aligned} attribute |
7041 | should be issued. These warnings are enabled by default. | |
7042 | ||
d77de738 ML |
7043 | @opindex Wignored-qualifiers |
7044 | @opindex Wno-ignored-qualifiers | |
ddf6fe37 | 7045 | @item -Wignored-qualifiers @r{(C and C++ only)} |
d77de738 ML |
7046 | Warn if the return type of a function has a type qualifier |
7047 | such as @code{const}. For ISO C such a type qualifier has no effect, | |
7048 | since the value returned by a function is not an lvalue. | |
7049 | For C++, the warning is only emitted for scalar types or @code{void}. | |
7050 | ISO C prohibits qualified @code{void} return types on function | |
7051 | definitions, so such return types always receive a warning | |
7052 | even without this option. | |
7053 | ||
7054 | This warning is also enabled by @option{-Wextra}. | |
7055 | ||
d77de738 ML |
7056 | @opindex Wignored-attributes |
7057 | @opindex Wno-ignored-attributes | |
ddf6fe37 | 7058 | @item -Wno-ignored-attributes @r{(C and C++ only)} |
d77de738 ML |
7059 | This option controls warnings when an attribute is ignored. |
7060 | This is different from the | |
7061 | @option{-Wattributes} option in that it warns whenever the compiler decides | |
7062 | to drop an attribute, not that the attribute is either unknown, used in a | |
7063 | wrong place, etc. This warning is enabled by default. | |
7064 | ||
d77de738 ML |
7065 | @opindex Wmain |
7066 | @opindex Wno-main | |
ddf6fe37 | 7067 | @item -Wmain |
d77de738 ML |
7068 | Warn if the type of @code{main} is suspicious. @code{main} should be |
7069 | a function with external linkage, returning int, taking either zero | |
7070 | arguments, two, or three arguments of appropriate types. This warning | |
7071 | is enabled by default in C++ and is enabled by either @option{-Wall} | |
7072 | or @option{-Wpedantic}. | |
7073 | ||
5fccebdb JM |
7074 | This warning is upgraded to an error by @option{-pedantic-errors}. |
7075 | ||
d77de738 ML |
7076 | @opindex Wmisleading-indentation |
7077 | @opindex Wno-misleading-indentation | |
ddf6fe37 | 7078 | @item -Wmisleading-indentation @r{(C and C++ only)} |
d77de738 ML |
7079 | Warn when the indentation of the code does not reflect the block structure. |
7080 | Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and | |
7081 | @code{for} clauses with a guarded statement that does not use braces, | |
7082 | followed by an unguarded statement with the same indentation. | |
7083 | ||
7084 | In the following example, the call to ``bar'' is misleadingly indented as | |
7085 | if it were guarded by the ``if'' conditional. | |
7086 | ||
7087 | @smallexample | |
7088 | if (some_condition ()) | |
7089 | foo (); | |
7090 | bar (); /* Gotcha: this is not guarded by the "if". */ | |
7091 | @end smallexample | |
7092 | ||
7093 | In the case of mixed tabs and spaces, the warning uses the | |
7094 | @option{-ftabstop=} option to determine if the statements line up | |
7095 | (defaulting to 8). | |
7096 | ||
7097 | The warning is not issued for code involving multiline preprocessor logic | |
7098 | such as the following example. | |
7099 | ||
7100 | @smallexample | |
7101 | if (flagA) | |
7102 | foo (0); | |
7103 | #if SOME_CONDITION_THAT_DOES_NOT_HOLD | |
7104 | if (flagB) | |
7105 | #endif | |
7106 | foo (1); | |
7107 | @end smallexample | |
7108 | ||
7109 | The warning is not issued after a @code{#line} directive, since this | |
7110 | typically indicates autogenerated code, and no assumptions can be made | |
7111 | about the layout of the file that the directive references. | |
7112 | ||
7113 | This warning is enabled by @option{-Wall} in C and C++. | |
7114 | ||
d77de738 ML |
7115 | @opindex Wmissing-attributes |
7116 | @opindex Wno-missing-attributes | |
ddf6fe37 | 7117 | @item -Wmissing-attributes |
d77de738 ML |
7118 | Warn when a declaration of a function is missing one or more attributes |
7119 | that a related function is declared with and whose absence may adversely | |
7120 | affect the correctness or efficiency of generated code. For example, | |
7121 | the warning is issued for declarations of aliases that use attributes | |
7122 | to specify less restrictive requirements than those of their targets. | |
7123 | This typically represents a potential optimization opportunity. | |
7124 | By contrast, the @option{-Wattribute-alias=2} option controls warnings | |
7125 | issued when the alias is more restrictive than the target, which could | |
7126 | lead to incorrect code generation. | |
7127 | Attributes considered include @code{alloc_align}, @code{alloc_size}, | |
7128 | @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc}, | |
7129 | @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure}, | |
7130 | @code{returns_nonnull}, and @code{returns_twice}. | |
7131 | ||
7132 | In C++, the warning is issued when an explicit specialization of a primary | |
7133 | template declared with attribute @code{alloc_align}, @code{alloc_size}, | |
7134 | @code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc}, | |
7135 | or @code{nonnull} is declared without it. Attributes @code{deprecated}, | |
7136 | @code{error}, and @code{warning} suppress the warning. | |
7137 | (@pxref{Function Attributes}). | |
7138 | ||
7139 | You can use the @code{copy} attribute to apply the same | |
7140 | set of attributes to a declaration as that on another declaration without | |
7141 | explicitly enumerating the attributes. This attribute can be applied | |
7142 | to declarations of functions (@pxref{Common Function Attributes}), | |
7143 | variables (@pxref{Common Variable Attributes}), or types | |
7144 | (@pxref{Common Type Attributes}). | |
7145 | ||
7146 | @option{-Wmissing-attributes} is enabled by @option{-Wall}. | |
7147 | ||
7148 | For example, since the declaration of the primary function template | |
7149 | below makes use of both attribute @code{malloc} and @code{alloc_size} | |
7150 | the declaration of the explicit specialization of the template is | |
7151 | diagnosed because it is missing one of the attributes. | |
7152 | ||
7153 | @smallexample | |
7154 | template <class T> | |
7155 | T* __attribute__ ((malloc, alloc_size (1))) | |
7156 | allocate (size_t); | |
7157 | ||
7158 | template <> | |
7159 | void* __attribute__ ((malloc)) // missing alloc_size | |
7160 | allocate<void> (size_t); | |
7161 | @end smallexample | |
7162 | ||
d77de738 ML |
7163 | @opindex Wmissing-braces |
7164 | @opindex Wno-missing-braces | |
ddf6fe37 | 7165 | @item -Wmissing-braces |
d77de738 ML |
7166 | Warn if an aggregate or union initializer is not fully bracketed. In |
7167 | the following example, the initializer for @code{a} is not fully | |
7168 | bracketed, but that for @code{b} is fully bracketed. | |
7169 | ||
7170 | @smallexample | |
7171 | int a[2][2] = @{ 0, 1, 2, 3 @}; | |
7172 | int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @}; | |
7173 | @end smallexample | |
7174 | ||
7175 | This warning is enabled by @option{-Wall}. | |
7176 | ||
d77de738 ML |
7177 | @opindex Wmissing-include-dirs |
7178 | @opindex Wno-missing-include-dirs | |
ddf6fe37 | 7179 | @item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)} |
72cfa0f7 | 7180 | Warn if a user-supplied include directory does not exist. This option is disabled |
d77de738 ML |
7181 | by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially |
7182 | enabled by default by warning for -I and -J, only. | |
7183 | ||
d77de738 ML |
7184 | @opindex Wmissing-profile |
7185 | @opindex Wno-missing-profile | |
ddf6fe37 | 7186 | @item -Wno-missing-profile |
d77de738 ML |
7187 | This option controls warnings if feedback profiles are missing when using the |
7188 | @option{-fprofile-use} option. | |
7189 | This option diagnoses those cases where a new function or a new file is added | |
7190 | between compiling with @option{-fprofile-generate} and with | |
7191 | @option{-fprofile-use}, without regenerating the profiles. | |
7192 | In these cases, the profile feedback data files do not contain any | |
7193 | profile feedback information for | |
7194 | the newly added function or file respectively. Also, in the case when profile | |
7195 | count data (.gcda) files are removed, GCC cannot use any profile feedback | |
7196 | information. In all these cases, warnings are issued to inform you that a | |
7197 | profile generation step is due. | |
7198 | Ignoring the warning can result in poorly optimized code. | |
7199 | @option{-Wno-missing-profile} can be used to | |
7200 | disable the warning, but this is not recommended and should be done only | |
7201 | when non-existent profile data is justified. | |
7202 | ||
d77de738 ML |
7203 | @opindex Wmismatched-dealloc |
7204 | @opindex Wno-mismatched-dealloc | |
ddf6fe37 | 7205 | @item -Wmismatched-dealloc |
d77de738 ML |
7206 | |
7207 | Warn for calls to deallocation functions with pointer arguments returned | |
7208 | from from allocations functions for which the former isn't a suitable | |
7209 | deallocator. A pair of functions can be associated as matching allocators | |
7210 | and deallocators by use of attribute @code{malloc}. Unless disabled by | |
7211 | the @option{-fno-builtin} option the standard functions @code{calloc}, | |
7212 | @code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding | |
7213 | forms of C++ @code{operator new} and @code{operator delete} are implicitly | |
7214 | associated as matching allocators and deallocators. In the following | |
7215 | example @code{mydealloc} is the deallocator for pointers returned from | |
7216 | @code{myalloc}. | |
7217 | ||
7218 | @smallexample | |
7219 | void mydealloc (void*); | |
7220 | ||
7221 | __attribute__ ((malloc (mydealloc, 1))) void* | |
7222 | myalloc (size_t); | |
7223 | ||
7224 | void f (void) | |
7225 | @{ | |
7226 | void *p = myalloc (32); | |
7227 | // @dots{}use p@dots{} | |
7228 | free (p); // warning: not a matching deallocator for myalloc | |
7229 | mydealloc (p); // ok | |
7230 | @} | |
7231 | @end smallexample | |
7232 | ||
7233 | In C++, the related option @option{-Wmismatched-new-delete} diagnoses | |
7234 | mismatches involving either @code{operator new} or @code{operator delete}. | |
7235 | ||
7236 | Option @option{-Wmismatched-dealloc} is included in @option{-Wall}. | |
7237 | ||
d77de738 ML |
7238 | @opindex Wmultistatement-macros |
7239 | @opindex Wno-multistatement-macros | |
ddf6fe37 | 7240 | @item -Wmultistatement-macros |
d77de738 ML |
7241 | Warn about unsafe multiple statement macros that appear to be guarded |
7242 | by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or | |
7243 | @code{while}, in which only the first statement is actually guarded after | |
7244 | the macro is expanded. | |
7245 | ||
7246 | For example: | |
7247 | ||
7248 | @smallexample | |
7249 | #define DOIT x++; y++ | |
7250 | if (c) | |
7251 | DOIT; | |
7252 | @end smallexample | |
7253 | ||
7254 | will increment @code{y} unconditionally, not just when @code{c} holds. | |
7255 | The can usually be fixed by wrapping the macro in a do-while loop: | |
7256 | @smallexample | |
7257 | #define DOIT do @{ x++; y++; @} while (0) | |
7258 | if (c) | |
7259 | DOIT; | |
7260 | @end smallexample | |
7261 | ||
7262 | This warning is enabled by @option{-Wall} in C and C++. | |
7263 | ||
d77de738 ML |
7264 | @opindex Wparentheses |
7265 | @opindex Wno-parentheses | |
ddf6fe37 | 7266 | @item -Wparentheses |
d77de738 ML |
7267 | Warn if parentheses are omitted in certain contexts, such |
7268 | as when there is an assignment in a context where a truth value | |
7269 | is expected, or when operators are nested whose precedence people | |
7270 | often get confused about. | |
7271 | ||
7272 | Also warn if a comparison like @code{x<=y<=z} appears; this is | |
7273 | equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different | |
7274 | interpretation from that of ordinary mathematical notation. | |
7275 | ||
7276 | Also warn for dangerous uses of the GNU extension to | |
7277 | @code{?:} with omitted middle operand. When the condition | |
7278 | in the @code{?}: operator is a boolean expression, the omitted value is | |
7279 | always 1. Often programmers expect it to be a value computed | |
7280 | inside the conditional expression instead. | |
7281 | ||
7282 | For C++ this also warns for some cases of unnecessary parentheses in | |
7283 | declarations, which can indicate an attempt at a function call instead | |
7284 | of a declaration: | |
7285 | @smallexample | |
7286 | @{ | |
7287 | // Declares a local variable called mymutex. | |
7288 | std::unique_lock<std::mutex> (mymutex); | |
7289 | // User meant std::unique_lock<std::mutex> lock (mymutex); | |
7290 | @} | |
7291 | @end smallexample | |
7292 | ||
7293 | This warning is enabled by @option{-Wall}. | |
7294 | ||
d77de738 ML |
7295 | @opindex Wself-move |
7296 | @opindex Wno-self-move | |
ddf6fe37 | 7297 | @item -Wno-self-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
7298 | This warning warns when a value is moved to itself with @code{std::move}. |
7299 | Such a @code{std::move} typically has no effect. | |
7300 | ||
7301 | @smallexample | |
7302 | struct T @{ | |
7303 | @dots{} | |
7304 | @}; | |
7305 | void fn() | |
7306 | @{ | |
7307 | T t; | |
7308 | @dots{} | |
7309 | t = std::move (t); | |
7310 | @} | |
7311 | @end smallexample | |
7312 | ||
7313 | This warning is enabled by @option{-Wall}. | |
7314 | ||
d77de738 ML |
7315 | @opindex Wsequence-point |
7316 | @opindex Wno-sequence-point | |
ddf6fe37 | 7317 | @item -Wsequence-point |
d77de738 ML |
7318 | Warn about code that may have undefined semantics because of violations |
7319 | of sequence point rules in the C and C++ standards. | |
7320 | ||
7321 | The C and C++ standards define the order in which expressions in a C/C++ | |
7322 | program are evaluated in terms of @dfn{sequence points}, which represent | |
7323 | a partial ordering between the execution of parts of the program: those | |
7324 | executed before the sequence point, and those executed after it. These | |
7325 | occur after the evaluation of a full expression (one which is not part | |
7326 | of a larger expression), after the evaluation of the first operand of a | |
7327 | @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a | |
7328 | function is called (but after the evaluation of its arguments and the | |
7329 | expression denoting the called function), and in certain other places. | |
7330 | Other than as expressed by the sequence point rules, the order of | |
7331 | evaluation of subexpressions of an expression is not specified. All | |
7332 | these rules describe only a partial order rather than a total order, | |
7333 | since, for example, if two functions are called within one expression | |
7334 | with no sequence point between them, the order in which the functions | |
7335 | are called is not specified. However, the standards committee have | |
7336 | ruled that function calls do not overlap. | |
7337 | ||
7338 | It is not specified when between sequence points modifications to the | |
7339 | values of objects take effect. Programs whose behavior depends on this | |
7340 | have undefined behavior; the C and C++ standards specify that ``Between | |
7341 | the previous and next sequence point an object shall have its stored | |
7342 | value modified at most once by the evaluation of an expression. | |
7343 | Furthermore, the prior value shall be read only to determine the value | |
7344 | to be stored.''. If a program breaks these rules, the results on any | |
7345 | particular implementation are entirely unpredictable. | |
7346 | ||
7347 | Examples of code with undefined behavior are @code{a = a++;}, @code{a[n] | |
7348 | = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not | |
7349 | diagnosed by this option, and it may give an occasional false positive | |
7350 | result, but in general it has been found fairly effective at detecting | |
7351 | this sort of problem in programs. | |
7352 | ||
7353 | The C++17 standard will define the order of evaluation of operands in | |
7354 | more cases: in particular it requires that the right-hand side of an | |
7355 | assignment be evaluated before the left-hand side, so the above | |
7356 | examples are no longer undefined. But this option will still warn | |
7357 | about them, to help people avoid writing code that is undefined in C | |
7358 | and earlier revisions of C++. | |
7359 | ||
7360 | The standard is worded confusingly, therefore there is some debate | |
7361 | over the precise meaning of the sequence point rules in subtle cases. | |
7362 | Links to discussions of the problem, including proposed formal | |
7363 | definitions, may be found on the GCC readings page, at | |
7364 | @uref{https://gcc.gnu.org/@/readings.html}. | |
7365 | ||
7366 | This warning is enabled by @option{-Wall} for C and C++. | |
7367 | ||
d77de738 ML |
7368 | @opindex Wno-return-local-addr |
7369 | @opindex Wreturn-local-addr | |
ddf6fe37 | 7370 | @item -Wno-return-local-addr |
d77de738 ML |
7371 | Do not warn about returning a pointer (or in C++, a reference) to a |
7372 | variable that goes out of scope after the function returns. | |
7373 | ||
6e312b2b FW |
7374 | @opindex Wreturn-mismatch |
7375 | @opindex Wno-return-mismatch | |
7376 | @item -Wreturn-mismatch | |
7377 | Warn about return statements without an expressions in functions which | |
7378 | do not return @code{void}. Also warn about a @code{return} statement | |
7379 | with an expression in a function whose return type is @code{void}, | |
7380 | unless the expression type is also @code{void}. As a GNU extension, the | |
7381 | latter case is accepted without a warning unless @option{-Wpedantic} is | |
7382 | used. | |
7383 | ||
7384 | Attempting to use the return value of a non-@code{void} function other | |
7385 | than @code{main} that flows off the end by reaching the closing curly | |
7386 | brace that terminates the function is undefined. | |
7387 | ||
4ecfa6c4 FW |
7388 | This warning is specific to C and enabled by default. In C99 and later |
7389 | language dialects, it is treated as an error. It can be downgraded | |
7390 | to a warning using @option{-fpermissive} (along with other warnings), | |
7391 | or for just this warning, with @option{-Wno-error=return-mismatch}. | |
6e312b2b | 7392 | |
d77de738 ML |
7393 | @opindex Wreturn-type |
7394 | @opindex Wno-return-type | |
ddf6fe37 | 7395 | @item -Wreturn-type |
6e312b2b FW |
7396 | Warn whenever a function is defined with a return type that defaults to |
7397 | @code{int} (unless @option{-Wimplicit-int} is active, which takes | |
7398 | precedence). Also warn if execution may reach the end of the function | |
7399 | body, or if the function does not contain any return statement at all. | |
7400 | ||
7401 | Attempting to use the return value of a non-@code{void} function other | |
7402 | than @code{main} that flows off the end by reaching the closing curly | |
7403 | brace that terminates the function is undefined. | |
d77de738 ML |
7404 | |
7405 | Unlike in C, in C++, flowing off the end of a non-@code{void} function other | |
7406 | than @code{main} results in undefined behavior even when the value of | |
7407 | the function is not used. | |
7408 | ||
7409 | This warning is enabled by default in C++ and by @option{-Wall} otherwise. | |
7410 | ||
d77de738 ML |
7411 | @opindex Wshift-count-negative |
7412 | @opindex Wno-shift-count-negative | |
ddf6fe37 | 7413 | @item -Wno-shift-count-negative |
d77de738 ML |
7414 | Controls warnings if a shift count is negative. |
7415 | This warning is enabled by default. | |
7416 | ||
d77de738 ML |
7417 | @opindex Wshift-count-overflow |
7418 | @opindex Wno-shift-count-overflow | |
ddf6fe37 | 7419 | @item -Wno-shift-count-overflow |
d77de738 ML |
7420 | Controls warnings if a shift count is greater than or equal to the bit width |
7421 | of the type. This warning is enabled by default. | |
7422 | ||
d77de738 ML |
7423 | @opindex Wshift-negative-value |
7424 | @opindex Wno-shift-negative-value | |
ddf6fe37 | 7425 | @item -Wshift-negative-value |
d77de738 ML |
7426 | Warn if left shifting a negative value. This warning is enabled by |
7427 | @option{-Wextra} in C99 (and newer) and C++11 to C++17 modes. | |
7428 | ||
d77de738 ML |
7429 | @opindex Wshift-overflow |
7430 | @opindex Wno-shift-overflow | |
ddf6fe37 AA |
7431 | @item -Wno-shift-overflow |
7432 | @itemx -Wshift-overflow=@var{n} | |
d77de738 ML |
7433 | These options control warnings about left shift overflows. |
7434 | ||
7435 | @table @gcctabopt | |
7436 | @item -Wshift-overflow=1 | |
7437 | This is the warning level of @option{-Wshift-overflow} and is enabled | |
7438 | by default in C99 and C++11 modes (and newer). This warning level does | |
7439 | not warn about left-shifting 1 into the sign bit. (However, in C, such | |
7440 | an overflow is still rejected in contexts where an integer constant expression | |
7441 | is required.) No warning is emitted in C++20 mode (and newer), as signed left | |
7442 | shifts always wrap. | |
7443 | ||
7444 | @item -Wshift-overflow=2 | |
7445 | This warning level also warns about left-shifting 1 into the sign bit, | |
7446 | unless C++14 mode (or newer) is active. | |
7447 | @end table | |
7448 | ||
d77de738 ML |
7449 | @opindex Wswitch |
7450 | @opindex Wno-switch | |
ddf6fe37 | 7451 | @item -Wswitch |
d77de738 ML |
7452 | Warn whenever a @code{switch} statement has an index of enumerated type |
7453 | and lacks a @code{case} for one or more of the named codes of that | |
7454 | enumeration. (The presence of a @code{default} label prevents this | |
7455 | warning.) @code{case} labels outside the enumeration range also | |
7456 | provoke warnings when this option is used (even if there is a | |
7457 | @code{default} label). | |
7458 | This warning is enabled by @option{-Wall}. | |
7459 | ||
d77de738 ML |
7460 | @opindex Wswitch-default |
7461 | @opindex Wno-switch-default | |
ddf6fe37 | 7462 | @item -Wswitch-default |
d77de738 ML |
7463 | Warn whenever a @code{switch} statement does not have a @code{default} |
7464 | case. | |
7465 | ||
d77de738 ML |
7466 | @opindex Wswitch-enum |
7467 | @opindex Wno-switch-enum | |
ddf6fe37 | 7468 | @item -Wswitch-enum |
d77de738 ML |
7469 | Warn whenever a @code{switch} statement has an index of enumerated type |
7470 | and lacks a @code{case} for one or more of the named codes of that | |
7471 | enumeration. @code{case} labels outside the enumeration range also | |
7472 | provoke warnings when this option is used. The only difference | |
7473 | between @option{-Wswitch} and this option is that this option gives a | |
7474 | warning about an omitted enumeration code even if there is a | |
7475 | @code{default} label. | |
7476 | ||
d77de738 ML |
7477 | @opindex Wswitch-bool |
7478 | @opindex Wno-switch-bool | |
ddf6fe37 | 7479 | @item -Wno-switch-bool |
d77de738 ML |
7480 | Do not warn when a @code{switch} statement has an index of boolean type |
7481 | and the case values are outside the range of a boolean type. | |
7482 | It is possible to suppress this warning by casting the controlling | |
7483 | expression to a type other than @code{bool}. For example: | |
7484 | @smallexample | |
7485 | @group | |
7486 | switch ((int) (a == 4)) | |
7487 | @{ | |
7488 | @dots{} | |
7489 | @} | |
7490 | @end group | |
7491 | @end smallexample | |
7492 | This warning is enabled by default for C and C++ programs. | |
7493 | ||
d77de738 ML |
7494 | @opindex Wswitch-outside-range |
7495 | @opindex Wno-switch-outside-range | |
ddf6fe37 | 7496 | @item -Wno-switch-outside-range |
d77de738 ML |
7497 | This option controls warnings when a @code{switch} case has a value |
7498 | that is outside of its | |
7499 | respective type range. This warning is enabled by default for | |
7500 | C and C++ programs. | |
7501 | ||
d77de738 ML |
7502 | @opindex Wswitch-unreachable |
7503 | @opindex Wno-switch-unreachable | |
ddf6fe37 | 7504 | @item -Wno-switch-unreachable |
d77de738 ML |
7505 | Do not warn when a @code{switch} statement contains statements between the |
7506 | controlling expression and the first case label, which will never be | |
7507 | executed. For example: | |
7508 | @smallexample | |
7509 | @group | |
7510 | switch (cond) | |
7511 | @{ | |
7512 | i = 15; | |
7513 | @dots{} | |
7514 | case 5: | |
7515 | @dots{} | |
7516 | @} | |
7517 | @end group | |
7518 | @end smallexample | |
7519 | @option{-Wswitch-unreachable} does not warn if the statement between the | |
7520 | controlling expression and the first case label is just a declaration: | |
7521 | @smallexample | |
7522 | @group | |
7523 | switch (cond) | |
7524 | @{ | |
7525 | int i; | |
7526 | @dots{} | |
7527 | case 5: | |
7528 | i = 5; | |
7529 | @dots{} | |
7530 | @} | |
7531 | @end group | |
7532 | @end smallexample | |
7533 | This warning is enabled by default for C and C++ programs. | |
7534 | ||
d77de738 ML |
7535 | @opindex Wsync-nand |
7536 | @opindex Wno-sync-nand | |
ddf6fe37 | 7537 | @item -Wsync-nand @r{(C and C++ only)} |
d77de738 ML |
7538 | Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch} |
7539 | built-in functions are used. These functions changed semantics in GCC 4.4. | |
7540 | ||
d77de738 ML |
7541 | @opindex Wtrivial-auto-var-init |
7542 | @opindex Wno-trivial-auto-var-init | |
ddf6fe37 | 7543 | @item -Wtrivial-auto-var-init |
d77de738 ML |
7544 | Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic |
7545 | variable. A common situation is an automatic variable that is declared | |
7546 | between the controlling expression and the first case label of a @code{switch} | |
7547 | statement. | |
7548 | ||
d77de738 ML |
7549 | @opindex Wunused-but-set-parameter |
7550 | @opindex Wno-unused-but-set-parameter | |
ddf6fe37 | 7551 | @item -Wunused-but-set-parameter |
d77de738 ML |
7552 | Warn whenever a function parameter is assigned to, but otherwise unused |
7553 | (aside from its declaration). | |
7554 | ||
7555 | To suppress this warning use the @code{unused} attribute | |
7556 | (@pxref{Variable Attributes}). | |
7557 | ||
7558 | This warning is also enabled by @option{-Wunused} together with | |
7559 | @option{-Wextra}. | |
7560 | ||
d77de738 ML |
7561 | @opindex Wunused-but-set-variable |
7562 | @opindex Wno-unused-but-set-variable | |
ddf6fe37 | 7563 | @item -Wunused-but-set-variable |
d77de738 ML |
7564 | Warn whenever a local variable is assigned to, but otherwise unused |
7565 | (aside from its declaration). | |
7566 | This warning is enabled by @option{-Wall}. | |
7567 | ||
7568 | To suppress this warning use the @code{unused} attribute | |
7569 | (@pxref{Variable Attributes}). | |
7570 | ||
7571 | This warning is also enabled by @option{-Wunused}, which is enabled | |
7572 | by @option{-Wall}. | |
7573 | ||
d77de738 ML |
7574 | @opindex Wunused-function |
7575 | @opindex Wno-unused-function | |
ddf6fe37 | 7576 | @item -Wunused-function |
d77de738 ML |
7577 | Warn whenever a static function is declared but not defined or a |
7578 | non-inline static function is unused. | |
7579 | This warning is enabled by @option{-Wall}. | |
7580 | ||
d77de738 ML |
7581 | @opindex Wunused-label |
7582 | @opindex Wno-unused-label | |
ddf6fe37 | 7583 | @item -Wunused-label |
d77de738 ML |
7584 | Warn whenever a label is declared but not used. |
7585 | This warning is enabled by @option{-Wall}. | |
7586 | ||
7587 | To suppress this warning use the @code{unused} attribute | |
7588 | (@pxref{Variable Attributes}). | |
7589 | ||
d77de738 ML |
7590 | @opindex Wunused-local-typedefs |
7591 | @opindex Wno-unused-local-typedefs | |
ddf6fe37 | 7592 | @item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)} |
d77de738 ML |
7593 | Warn when a typedef locally defined in a function is not used. |
7594 | This warning is enabled by @option{-Wall}. | |
7595 | ||
d77de738 ML |
7596 | @opindex Wunused-parameter |
7597 | @opindex Wno-unused-parameter | |
ddf6fe37 | 7598 | @item -Wunused-parameter |
d77de738 ML |
7599 | Warn whenever a function parameter is unused aside from its declaration. |
7600 | ||
7601 | To suppress this warning use the @code{unused} attribute | |
7602 | (@pxref{Variable Attributes}). | |
7603 | ||
d77de738 ML |
7604 | @opindex Wunused-result |
7605 | @opindex Wno-unused-result | |
ddf6fe37 | 7606 | @item -Wno-unused-result |
d77de738 ML |
7607 | Do not warn if a caller of a function marked with attribute |
7608 | @code{warn_unused_result} (@pxref{Function Attributes}) does not use | |
7609 | its return value. The default is @option{-Wunused-result}. | |
7610 | ||
d77de738 ML |
7611 | @opindex Wunused-variable |
7612 | @opindex Wno-unused-variable | |
ddf6fe37 | 7613 | @item -Wunused-variable |
d77de738 ML |
7614 | Warn whenever a local or static variable is unused aside from its |
7615 | declaration. This option implies @option{-Wunused-const-variable=1} for C, | |
7616 | but not for C++. This warning is enabled by @option{-Wall}. | |
7617 | ||
7618 | To suppress this warning use the @code{unused} attribute | |
7619 | (@pxref{Variable Attributes}). | |
7620 | ||
d77de738 ML |
7621 | @opindex Wunused-const-variable |
7622 | @opindex Wno-unused-const-variable | |
ddf6fe37 AA |
7623 | @item -Wunused-const-variable |
7624 | @itemx -Wunused-const-variable=@var{n} | |
d77de738 ML |
7625 | Warn whenever a constant static variable is unused aside from its declaration. |
7626 | @option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable} | |
7627 | for C, but not for C++. In C this declares variable storage, but in C++ this | |
7628 | is not an error since const variables take the place of @code{#define}s. | |
7629 | ||
7630 | To suppress this warning use the @code{unused} attribute | |
7631 | (@pxref{Variable Attributes}). | |
7632 | ||
7633 | @table @gcctabopt | |
7634 | @item -Wunused-const-variable=1 | |
7635 | This is the warning level that is enabled by @option{-Wunused-variable} for | |
7636 | C. It warns only about unused static const variables defined in the main | |
7637 | compilation unit, but not about static const variables declared in any | |
7638 | header included. | |
7639 | ||
7640 | @item -Wunused-const-variable=2 | |
7641 | This warning level also warns for unused constant static variables in | |
7642 | headers (excluding system headers). This is the warning level of | |
7643 | @option{-Wunused-const-variable} and must be explicitly requested since | |
7644 | in C++ this isn't an error and in C it might be harder to clean up all | |
7645 | headers included. | |
7646 | @end table | |
7647 | ||
d77de738 ML |
7648 | @opindex Wunused-value |
7649 | @opindex Wno-unused-value | |
ddf6fe37 | 7650 | @item -Wunused-value |
d77de738 ML |
7651 | Warn whenever a statement computes a result that is explicitly not |
7652 | used. To suppress this warning cast the unused expression to | |
7653 | @code{void}. This includes an expression-statement or the left-hand | |
7654 | side of a comma expression that contains no side effects. For example, | |
7655 | an expression such as @code{x[i,j]} causes a warning, while | |
7656 | @code{x[(void)i,j]} does not. | |
7657 | ||
7658 | This warning is enabled by @option{-Wall}. | |
7659 | ||
d77de738 ML |
7660 | @opindex Wunused |
7661 | @opindex Wno-unused | |
ddf6fe37 | 7662 | @item -Wunused |
d77de738 ML |
7663 | All the above @option{-Wunused} options combined. |
7664 | ||
7665 | In order to get a warning about an unused function parameter, you must | |
7666 | either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies | |
7667 | @option{-Wunused}), or separately specify @option{-Wunused-parameter}. | |
7668 | ||
25bb8a40 SL |
7669 | @opindex Wuse-after-free |
7670 | @opindex Wno-use-after-free | |
7671 | @item -Wuse-after-free @r{(C, Objective-C, C++ and Objective-C++ only)} | |
7672 | @itemx -Wuse-after-free=@var{n} | |
7673 | Warn about uses of pointers to dynamically allocated objects that have | |
7674 | been rendered indeterminate by a call to a deallocation function. | |
7675 | The warning is enabled at all optimization levels but may yield different | |
7676 | results with optimization than without. | |
7677 | ||
7678 | @table @gcctabopt | |
7679 | @item -Wuse-after-free=1 | |
7680 | At level 1 the warning attempts to diagnose only unconditional uses | |
7681 | of pointers made indeterminate by a deallocation call or a successful | |
7682 | call to @code{realloc}, regardless of whether or not the call resulted | |
7683 | in an actual reallocation of memory. This includes double-@code{free} | |
7684 | calls as well as uses in arithmetic and relational expressions. Although | |
7685 | undefined, uses of indeterminate pointers in equality (or inequality) | |
7686 | expressions are not diagnosed at this level. | |
7687 | @item -Wuse-after-free=2 | |
7688 | At level 2, in addition to unconditional uses, the warning also diagnoses | |
7689 | conditional uses of pointers made indeterminate by a deallocation call. | |
7690 | As at level 2, uses in equality (or inequality) expressions are not | |
7691 | diagnosed. For example, the second call to @code{free} in the following | |
7692 | function is diagnosed at this level: | |
7693 | @smallexample | |
7694 | struct A @{ int refcount; void *data; @}; | |
7695 | ||
7696 | void release (struct A *p) | |
7697 | @{ | |
7698 | int refcount = --p->refcount; | |
7699 | free (p); | |
7700 | if (refcount == 0) | |
7701 | free (p->data); // warning: p may be used after free | |
7702 | @} | |
7703 | @end smallexample | |
7704 | @item -Wuse-after-free=3 | |
7705 | At level 3, the warning also diagnoses uses of indeterminate pointers in | |
7706 | equality expressions. All uses of indeterminate pointers are undefined | |
7707 | but equality tests sometimes appear after calls to @code{realloc} as | |
7708 | an attempt to determine whether the call resulted in relocating the object | |
7709 | to a different address. They are diagnosed at a separate level to aid | |
7710 | gradually transitioning legacy code to safe alternatives. For example, | |
7711 | the equality test in the function below is diagnosed at this level: | |
7712 | @smallexample | |
7713 | void adjust_pointers (int**, int); | |
7714 | ||
7715 | void grow (int **p, int n) | |
7716 | @{ | |
7717 | int **q = (int**)realloc (p, n *= 2); | |
7718 | if (q == p) | |
7719 | return; | |
7720 | adjust_pointers ((int**)q, n); | |
7721 | @} | |
7722 | @end smallexample | |
7723 | To avoid the warning at this level, store offsets into allocated memory | |
7724 | instead of pointers. This approach obviates needing to adjust the stored | |
7725 | pointers after reallocation. | |
7726 | @end table | |
7727 | ||
7728 | @option{-Wuse-after-free=2} is included in @option{-Wall}. | |
7729 | ||
7730 | @opindex Wuseless-cast | |
7731 | @opindex Wno-useless-cast | |
7732 | @item -Wuseless-cast @r{(C, Objective-C, C++ and Objective-C++ only)} | |
7733 | Warn when an expression is cast to its own type. This warning does not | |
7734 | occur when a class object is converted to a non-reference type as that | |
7735 | is a way to create a temporary: | |
7736 | ||
7737 | @smallexample | |
7738 | struct S @{ @}; | |
7739 | void g (S&&); | |
7740 | void f (S&& arg) | |
7741 | @{ | |
7742 | g (S(arg)); // make arg prvalue so that it can bind to S&& | |
7743 | @} | |
7744 | @end smallexample | |
7745 | ||
d77de738 ML |
7746 | @opindex Wuninitialized |
7747 | @opindex Wno-uninitialized | |
ddf6fe37 | 7748 | @item -Wuninitialized |
d77de738 ML |
7749 | Warn if an object with automatic or allocated storage duration is used |
7750 | without having been initialized. In C++, also warn if a non-static | |
7751 | reference or non-static @code{const} member appears in a class without | |
7752 | constructors. | |
7753 | ||
7754 | In addition, passing a pointer (or in C++, a reference) to an uninitialized | |
7755 | object to a @code{const}-qualified argument of a built-in function known to | |
7756 | read the object is also diagnosed by this warning. | |
7757 | (@option{-Wmaybe-uninitialized} is issued for ordinary functions.) | |
7758 | ||
7759 | If you want to warn about code that uses the uninitialized value of the | |
7760 | variable in its own initializer, use the @option{-Winit-self} option. | |
7761 | ||
7762 | These warnings occur for individual uninitialized elements of | |
7763 | structure, union or array variables as well as for variables that are | |
7764 | uninitialized as a whole. They do not occur for variables or elements | |
7765 | declared @code{volatile}. Because these warnings depend on | |
7766 | optimization, the exact variables or elements for which there are | |
7767 | warnings depend on the precise optimization options and version of GCC | |
7768 | used. | |
7769 | ||
7770 | Note that there may be no warning about a variable that is used only | |
7771 | to compute a value that itself is never used, because such | |
7772 | computations may be deleted by data flow analysis before the warnings | |
7773 | are printed. | |
7774 | ||
7775 | In C++, this warning also warns about using uninitialized objects in | |
7776 | member-initializer-lists. For example, GCC warns about @code{b} being | |
7777 | uninitialized in the following snippet: | |
7778 | ||
7779 | @smallexample | |
7780 | struct A @{ | |
7781 | int a; | |
7782 | int b; | |
7783 | A() : a(b) @{ @} | |
7784 | @}; | |
7785 | @end smallexample | |
7786 | ||
d77de738 ML |
7787 | @opindex Winvalid-memory-model |
7788 | @opindex Wno-invalid-memory-model | |
ddf6fe37 | 7789 | @item -Wno-invalid-memory-model |
d77de738 ML |
7790 | This option controls warnings |
7791 | for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins}, | |
7792 | and the C11 atomic generic functions with a memory consistency argument | |
7793 | that is either invalid for the operation or outside the range of values | |
7794 | of the @code{memory_order} enumeration. For example, since the | |
7795 | @code{__atomic_store} and @code{__atomic_store_n} built-ins are only | |
7796 | defined for the relaxed, release, and sequentially consistent memory | |
7797 | orders the following code is diagnosed: | |
7798 | ||
7799 | @smallexample | |
7800 | void store (int *i) | |
7801 | @{ | |
7802 | __atomic_store_n (i, 0, memory_order_consume); | |
7803 | @} | |
7804 | @end smallexample | |
7805 | ||
7806 | @option{-Winvalid-memory-model} is enabled by default. | |
7807 | ||
d77de738 ML |
7808 | @opindex Wmaybe-uninitialized |
7809 | @opindex Wno-maybe-uninitialized | |
ddf6fe37 | 7810 | @item -Wmaybe-uninitialized |
d77de738 ML |
7811 | For an object with automatic or allocated storage duration, if there exists |
7812 | a path from the function entry to a use of the object that is initialized, | |
7813 | but there exist some other paths for which the object is not initialized, | |
7814 | the compiler emits a warning if it cannot prove the uninitialized paths | |
7815 | are not executed at run time. | |
7816 | ||
7817 | In addition, passing a pointer (or in C++, a reference) to an uninitialized | |
7818 | object to a @code{const}-qualified function argument is also diagnosed by | |
7819 | this warning. (@option{-Wuninitialized} is issued for built-in functions | |
7820 | known to read the object.) Annotating the function with attribute | |
7821 | @code{access (none)} indicates that the argument isn't used to access | |
7822 | the object and avoids the warning (@pxref{Common Function Attributes}). | |
7823 | ||
7824 | These warnings are only possible in optimizing compilation, because otherwise | |
7825 | GCC does not keep track of the state of variables. | |
7826 | ||
7827 | These warnings are made optional because GCC may not be able to determine when | |
7828 | the code is correct in spite of appearing to have an error. Here is one | |
7829 | example of how this can happen: | |
7830 | ||
7831 | @smallexample | |
7832 | @group | |
7833 | @{ | |
7834 | int x; | |
7835 | switch (y) | |
7836 | @{ | |
7837 | case 1: x = 1; | |
7838 | break; | |
7839 | case 2: x = 4; | |
7840 | break; | |
7841 | case 3: x = 5; | |
7842 | @} | |
7843 | foo (x); | |
7844 | @} | |
7845 | @end group | |
7846 | @end smallexample | |
7847 | ||
7848 | @noindent | |
7849 | If the value of @code{y} is always 1, 2 or 3, then @code{x} is | |
7850 | always initialized, but GCC doesn't know this. To suppress the | |
7851 | warning, you need to provide a default case with assert(0) or | |
7852 | similar code. | |
7853 | ||
7854 | @cindex @code{longjmp} warnings | |
7855 | This option also warns when a non-volatile automatic variable might be | |
7856 | changed by a call to @code{longjmp}. | |
7857 | The compiler sees only the calls to @code{setjmp}. It cannot know | |
7858 | where @code{longjmp} will be called; in fact, a signal handler could | |
7859 | call it at any point in the code. As a result, you may get a warning | |
7860 | even when there is in fact no problem because @code{longjmp} cannot | |
7861 | in fact be called at the place that would cause a problem. | |
7862 | ||
7863 | Some spurious warnings can be avoided if you declare all the functions | |
7864 | you use that never return as @code{noreturn}. @xref{Function | |
7865 | Attributes}. | |
7866 | ||
7867 | This warning is enabled by @option{-Wall} or @option{-Wextra}. | |
7868 | ||
d77de738 ML |
7869 | @opindex Wunknown-pragmas |
7870 | @opindex Wno-unknown-pragmas | |
7871 | @cindex warning for unknown pragmas | |
7872 | @cindex unknown pragmas, warning | |
7873 | @cindex pragmas, warning of unknown | |
f33d7a88 | 7874 | @item -Wunknown-pragmas |
d77de738 ML |
7875 | Warn when a @code{#pragma} directive is encountered that is not understood by |
7876 | GCC@. If this command-line option is used, warnings are even issued | |
7877 | for unknown pragmas in system header files. This is not the case if | |
7878 | the warnings are only enabled by the @option{-Wall} command-line option. | |
7879 | ||
d77de738 ML |
7880 | @opindex Wno-pragmas |
7881 | @opindex Wpragmas | |
ddf6fe37 | 7882 | @item -Wno-pragmas |
d77de738 ML |
7883 | Do not warn about misuses of pragmas, such as incorrect parameters, |
7884 | invalid syntax, or conflicts between pragmas. See also | |
7885 | @option{-Wunknown-pragmas}. | |
7886 | ||
d77de738 ML |
7887 | @opindex Wno-prio-ctor-dtor |
7888 | @opindex Wprio-ctor-dtor | |
ddf6fe37 | 7889 | @item -Wno-prio-ctor-dtor |
d77de738 ML |
7890 | Do not warn if a priority from 0 to 100 is used for constructor or destructor. |
7891 | The use of constructor and destructor attributes allow you to assign a | |
7892 | priority to the constructor/destructor to control its order of execution | |
7893 | before @code{main} is called or after it returns. The priority values must be | |
7894 | greater than 100 as the compiler reserves priority values between 0--100 for | |
7895 | the implementation. | |
7896 | ||
d77de738 ML |
7897 | @opindex Wstrict-aliasing |
7898 | @opindex Wno-strict-aliasing | |
ddf6fe37 | 7899 | @item -Wstrict-aliasing |
d77de738 ML |
7900 | This option is only active when @option{-fstrict-aliasing} is active. |
7901 | It warns about code that might break the strict aliasing rules that the | |
7902 | compiler is using for optimization. The warning does not catch all | |
7903 | cases, but does attempt to catch the more common pitfalls. It is | |
7904 | included in @option{-Wall}. | |
7905 | It is equivalent to @option{-Wstrict-aliasing=3} | |
7906 | ||
d77de738 | 7907 | @opindex Wstrict-aliasing=n |
ddf6fe37 | 7908 | @item -Wstrict-aliasing=n |
d77de738 ML |
7909 | This option is only active when @option{-fstrict-aliasing} is active. |
7910 | It warns about code that might break the strict aliasing rules that the | |
7911 | compiler is using for optimization. | |
7912 | Higher levels correspond to higher accuracy (fewer false positives). | |
7913 | Higher levels also correspond to more effort, similar to the way @option{-O} | |
7914 | works. | |
7915 | @option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}. | |
7916 | ||
7917 | Level 1: Most aggressive, quick, least accurate. | |
7918 | Possibly useful when higher levels | |
7919 | do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few | |
7920 | false negatives. However, it has many false positives. | |
7921 | Warns for all pointer conversions between possibly incompatible types, | |
7922 | even if never dereferenced. Runs in the front end only. | |
7923 | ||
7924 | Level 2: Aggressive, quick, not too precise. | |
7925 | May still have many false positives (not as many as level 1 though), | |
7926 | and few false negatives (but possibly more than level 1). | |
7927 | Unlike level 1, it only warns when an address is taken. Warns about | |
7928 | incomplete types. Runs in the front end only. | |
7929 | ||
7930 | Level 3 (default for @option{-Wstrict-aliasing}): | |
7931 | Should have very few false positives and few false | |
7932 | negatives. Slightly slower than levels 1 or 2 when optimization is enabled. | |
7933 | Takes care of the common pun+dereference pattern in the front end: | |
7934 | @code{*(int*)&some_float}. | |
7935 | If optimization is enabled, it also runs in the back end, where it deals | |
7936 | with multiple statement cases using flow-sensitive points-to information. | |
7937 | Only warns when the converted pointer is dereferenced. | |
7938 | Does not warn about incomplete types. | |
7939 | ||
d77de738 ML |
7940 | @opindex Wstrict-overflow |
7941 | @opindex Wno-strict-overflow | |
ddf6fe37 AA |
7942 | @item -Wstrict-overflow |
7943 | @itemx -Wstrict-overflow=@var{n} | |
d77de738 ML |
7944 | This option is only active when signed overflow is undefined. |
7945 | It warns about cases where the compiler optimizes based on the | |
7946 | assumption that signed overflow does not occur. Note that it does not | |
7947 | warn about all cases where the code might overflow: it only warns | |
7948 | about cases where the compiler implements some optimization. Thus | |
7949 | this warning depends on the optimization level. | |
7950 | ||
7951 | An optimization that assumes that signed overflow does not occur is | |
7952 | perfectly safe if the values of the variables involved are such that | |
7953 | overflow never does, in fact, occur. Therefore this warning can | |
7954 | easily give a false positive: a warning about code that is not | |
7955 | actually a problem. To help focus on important issues, several | |
7956 | warning levels are defined. No warnings are issued for the use of | |
7957 | undefined signed overflow when estimating how many iterations a loop | |
7958 | requires, in particular when determining whether a loop will be | |
7959 | executed at all. | |
7960 | ||
7961 | @table @gcctabopt | |
7962 | @item -Wstrict-overflow=1 | |
7963 | Warn about cases that are both questionable and easy to avoid. For | |
7964 | example the compiler simplifies | |
7965 | @code{x + 1 > x} to @code{1}. This level of | |
7966 | @option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels | |
7967 | are not, and must be explicitly requested. | |
7968 | ||
7969 | @item -Wstrict-overflow=2 | |
7970 | Also warn about other cases where a comparison is simplified to a | |
7971 | constant. For example: @code{abs (x) >= 0}. This can only be | |
7972 | simplified when signed integer overflow is undefined, because | |
7973 | @code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than | |
7974 | zero. @option{-Wstrict-overflow} (with no level) is the same as | |
7975 | @option{-Wstrict-overflow=2}. | |
7976 | ||
7977 | @item -Wstrict-overflow=3 | |
7978 | Also warn about other cases where a comparison is simplified. For | |
7979 | example: @code{x + 1 > 1} is simplified to @code{x > 0}. | |
7980 | ||
7981 | @item -Wstrict-overflow=4 | |
7982 | Also warn about other simplifications not covered by the above cases. | |
7983 | For example: @code{(x * 10) / 5} is simplified to @code{x * 2}. | |
7984 | ||
7985 | @item -Wstrict-overflow=5 | |
7986 | Also warn about cases where the compiler reduces the magnitude of a | |
7987 | constant involved in a comparison. For example: @code{x + 2 > y} is | |
7988 | simplified to @code{x + 1 >= y}. This is reported only at the | |
7989 | highest warning level because this simplification applies to many | |
7990 | comparisons, so this warning level gives a very large number of | |
7991 | false positives. | |
7992 | @end table | |
7993 | ||
d77de738 ML |
7994 | @opindex Wstring-compare |
7995 | @opindex Wno-string-compare | |
ddf6fe37 | 7996 | @item -Wstring-compare |
d77de738 ML |
7997 | Warn for calls to @code{strcmp} and @code{strncmp} whose result is |
7998 | determined to be either zero or non-zero in tests for such equality | |
7999 | owing to the length of one argument being greater than the size of | |
8000 | the array the other argument is stored in (or the bound in the case | |
8001 | of @code{strncmp}). Such calls could be mistakes. For example, | |
8002 | the call to @code{strcmp} below is diagnosed because its result is | |
8003 | necessarily non-zero irrespective of the contents of the array @code{a}. | |
8004 | ||
8005 | @smallexample | |
8006 | extern char a[4]; | |
8007 | void f (char *d) | |
8008 | @{ | |
8009 | strcpy (d, "string"); | |
8010 | @dots{} | |
8011 | if (0 == strcmp (a, d)) // cannot be true | |
8012 | puts ("a and d are the same"); | |
8013 | @} | |
8014 | @end smallexample | |
8015 | ||
8016 | @option{-Wstring-compare} is enabled by @option{-Wextra}. | |
8017 | ||
ddf6fe37 AA |
8018 | @opindex Wstringop-overflow |
8019 | @opindex Wno-stringop-overflow | |
d77de738 ML |
8020 | @item -Wno-stringop-overflow |
8021 | @item -Wstringop-overflow | |
8022 | @itemx -Wstringop-overflow=@var{type} | |
d77de738 ML |
8023 | Warn for calls to string manipulation functions such as @code{memcpy} and |
8024 | @code{strcpy} that are determined to overflow the destination buffer. The | |
8025 | optional argument is one greater than the type of Object Size Checking to | |
8026 | perform to determine the size of the destination. @xref{Object Size Checking}. | |
8027 | The argument is meaningful only for functions that operate on character arrays | |
8028 | but not for raw memory functions like @code{memcpy} which always make use | |
8029 | of Object Size type-0. The option also warns for calls that specify a size | |
8030 | in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes. | |
8031 | The option produces the best results with optimization enabled but can detect | |
8032 | a small subset of simple buffer overflows even without optimization in | |
8033 | calls to the GCC built-in functions like @code{__builtin_memcpy} that | |
8034 | correspond to the standard functions. In any case, the option warns about | |
8035 | just a subset of buffer overflows detected by the corresponding overflow | |
8036 | checking built-ins. For example, the option issues a warning for | |
8037 | the @code{strcpy} call below because it copies at least 5 characters | |
8038 | (the string @code{"blue"} including the terminating NUL) into the buffer | |
8039 | of size 4. | |
8040 | ||
8041 | @smallexample | |
8042 | enum Color @{ blue, purple, yellow @}; | |
8043 | const char* f (enum Color clr) | |
8044 | @{ | |
8045 | static char buf [4]; | |
8046 | const char *str; | |
8047 | switch (clr) | |
8048 | @{ | |
8049 | case blue: str = "blue"; break; | |
8050 | case purple: str = "purple"; break; | |
8051 | case yellow: str = "yellow"; break; | |
8052 | @} | |
8053 | ||
8054 | return strcpy (buf, str); // warning here | |
8055 | @} | |
8056 | @end smallexample | |
8057 | ||
8058 | Option @option{-Wstringop-overflow=2} is enabled by default. | |
8059 | ||
8060 | @table @gcctabopt | |
d77de738 ML |
8061 | @opindex Wstringop-overflow |
8062 | @opindex Wno-stringop-overflow | |
ddf6fe37 AA |
8063 | @item -Wstringop-overflow |
8064 | @itemx -Wstringop-overflow=1 | |
d77de738 ML |
8065 | The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking |
8066 | to determine the sizes of destination objects. At this setting the option | |
8067 | does not warn for writes past the end of subobjects of larger objects accessed | |
8068 | by pointers unless the size of the largest surrounding object is known. When | |
8069 | the destination may be one of several objects it is assumed to be the largest | |
8070 | one of them. On Linux systems, when optimization is enabled at this setting | |
8071 | the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro | |
8072 | is defined to a non-zero value. | |
8073 | ||
8074 | @item -Wstringop-overflow=2 | |
8075 | The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking | |
8076 | to determine the sizes of destination objects. At this setting the option | |
8077 | warns about overflows when writing to members of the largest complete | |
8078 | objects whose exact size is known. However, it does not warn for excessive | |
8079 | writes to the same members of unknown objects referenced by pointers since | |
8080 | they may point to arrays containing unknown numbers of elements. This is | |
8081 | the default setting of the option. | |
8082 | ||
8083 | @item -Wstringop-overflow=3 | |
8084 | The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking | |
8085 | to determine the sizes of destination objects. At this setting the option | |
8086 | warns about overflowing the smallest object or data member. This is the | |
8087 | most restrictive setting of the option that may result in warnings for safe | |
8088 | code. | |
8089 | ||
8090 | @item -Wstringop-overflow=4 | |
8091 | The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking | |
8092 | to determine the sizes of destination objects. At this setting the option | |
8093 | warns about overflowing any data members, and when the destination is | |
8094 | one of several objects it uses the size of the largest of them to decide | |
8095 | whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this | |
8096 | setting of the option may result in warnings for benign code. | |
8097 | @end table | |
8098 | ||
d77de738 ML |
8099 | @opindex Wstringop-overread |
8100 | @opindex Wno-stringop-overread | |
ddf6fe37 | 8101 | @item -Wno-stringop-overread |
d77de738 ML |
8102 | Warn for calls to string manipulation functions such as @code{memchr}, or |
8103 | @code{strcpy} that are determined to read past the end of the source | |
8104 | sequence. | |
8105 | ||
8106 | Option @option{-Wstringop-overread} is enabled by default. | |
8107 | ||
d77de738 ML |
8108 | @opindex Wstringop-truncation |
8109 | @opindex Wno-stringop-truncation | |
ddf6fe37 | 8110 | @item -Wno-stringop-truncation |
d77de738 ML |
8111 | Do not warn for calls to bounded string manipulation functions |
8112 | such as @code{strncat}, | |
8113 | @code{strncpy}, and @code{stpncpy} that may either truncate the copied string | |
8114 | or leave the destination unchanged. | |
8115 | ||
8116 | In the following example, the call to @code{strncat} specifies a bound that | |
8117 | is less than the length of the source string. As a result, the copy of | |
8118 | the source will be truncated and so the call is diagnosed. To avoid the | |
8119 | warning use @code{bufsize - strlen (buf) - 1)} as the bound. | |
8120 | ||
8121 | @smallexample | |
8122 | void append (char *buf, size_t bufsize) | |
8123 | @{ | |
8124 | strncat (buf, ".txt", 3); | |
8125 | @} | |
8126 | @end smallexample | |
8127 | ||
8128 | As another example, the following call to @code{strncpy} results in copying | |
8129 | to @code{d} just the characters preceding the terminating NUL, without | |
8130 | appending the NUL to the end. Assuming the result of @code{strncpy} is | |
8131 | necessarily a NUL-terminated string is a common mistake, and so the call | |
8132 | is diagnosed. To avoid the warning when the result is not expected to be | |
8133 | NUL-terminated, call @code{memcpy} instead. | |
8134 | ||
8135 | @smallexample | |
8136 | void copy (char *d, const char *s) | |
8137 | @{ | |
8138 | strncpy (d, s, strlen (s)); | |
8139 | @} | |
8140 | @end smallexample | |
8141 | ||
8142 | In the following example, the call to @code{strncpy} specifies the size | |
8143 | of the destination buffer as the bound. If the length of the source | |
8144 | string is equal to or greater than this size the result of the copy will | |
8145 | not be NUL-terminated. Therefore, the call is also diagnosed. To avoid | |
8146 | the warning, specify @code{sizeof buf - 1} as the bound and set the last | |
8147 | element of the buffer to @code{NUL}. | |
8148 | ||
8149 | @smallexample | |
8150 | void copy (const char *s) | |
8151 | @{ | |
8152 | char buf[80]; | |
8153 | strncpy (buf, s, sizeof buf); | |
8154 | @dots{} | |
8155 | @} | |
8156 | @end smallexample | |
8157 | ||
8158 | In situations where a character array is intended to store a sequence | |
8159 | of bytes with no terminating @code{NUL} such an array may be annotated | |
8160 | with attribute @code{nonstring} to avoid this warning. Such arrays, | |
8161 | however, are not suitable arguments to functions that expect | |
8162 | @code{NUL}-terminated strings. To help detect accidental misuses of | |
8163 | such arrays GCC issues warnings unless it can prove that the use is | |
8164 | safe. @xref{Common Variable Attributes}. | |
8165 | ||
2a27ae32 QZ |
8166 | @opindex Wstrict-flex-arrays |
8167 | @opindex Wno-strict-flex-arrays | |
eb71695f SL |
8168 | @item -Wstrict-flex-arrays @r{(C and C++ only)} |
8169 | Warn about improper usages of flexible array members | |
2a27ae32 QZ |
8170 | according to the @var{level} of the @code{strict_flex_array (@var{level})} |
8171 | attribute attached to the trailing array field of a structure if it's | |
8172 | available, otherwise according to the @var{level} of the option | |
eb71695f SL |
8173 | @option{-fstrict-flex-arrays=@var{level}}. @xref{Common Variable Attributes}, |
8174 | for more information about the attribute, and @ref{C Dialect Options} for | |
8175 | more information about the option. @code{-Wstrict-flex-arrays} | |
8176 | is effective only when @var{level} is greater than 0. | |
2a27ae32 | 8177 | |
eb71695f | 8178 | When @var{level}=1, warnings are issued for a trailing array reference |
2a27ae32 QZ |
8179 | of a structure that have 2 or more elements if the trailing array is referenced |
8180 | as a flexible array member. | |
8181 | ||
eb71695f | 8182 | When @var{level}=2, in addition to @var{level}=1, additional warnings are |
2a27ae32 QZ |
8183 | issued for a trailing one-element array reference of a structure |
8184 | if the array is referenced as a flexible array member. | |
8185 | ||
eb71695f | 8186 | When @var{level}=3, in addition to @var{level}=2, additional warnings are |
2a27ae32 QZ |
8187 | issued for a trailing zero-length array reference of a structure |
8188 | if the array is referenced as a flexible array member. | |
8189 | ||
eb71695f SL |
8190 | This option is more effective when @option{-ftree-vrp} is active (the |
8191 | default for @option{-O2} and above) but some warnings may be diagnosed | |
8192 | even without optimization. | |
2a27ae32 | 8193 | |
d77de738 ML |
8194 | @opindex Wsuggest-attribute= |
8195 | @opindex Wno-suggest-attribute= | |
53ba8d66 | 8196 | @item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}returns_nonnull@r{|} |
d77de738 ML |
8197 | Warn for cases where adding an attribute may be beneficial. The |
8198 | attributes currently supported are listed below. | |
8199 | ||
8200 | @table @gcctabopt | |
d77de738 ML |
8201 | @opindex Wsuggest-attribute=pure |
8202 | @opindex Wno-suggest-attribute=pure | |
8203 | @opindex Wsuggest-attribute=const | |
8204 | @opindex Wno-suggest-attribute=const | |
8205 | @opindex Wsuggest-attribute=noreturn | |
8206 | @opindex Wno-suggest-attribute=noreturn | |
8207 | @opindex Wmissing-noreturn | |
8208 | @opindex Wno-missing-noreturn | |
8209 | @opindex Wsuggest-attribute=malloc | |
8210 | @opindex Wno-suggest-attribute=malloc | |
ddf6fe37 AA |
8211 | @item -Wsuggest-attribute=pure |
8212 | @itemx -Wsuggest-attribute=const | |
8213 | @itemx -Wsuggest-attribute=noreturn | |
8214 | @itemx -Wmissing-noreturn | |
8215 | @itemx -Wsuggest-attribute=malloc | |
53ba8d66 JH |
8216 | @itemx -Wsuggest-attribute=returns_nonnull |
8217 | @itemx -Wno-suggest-attribute=returns_nonnull | |
d77de738 ML |
8218 | |
8219 | Warn about functions that might be candidates for attributes | |
53ba8d66 | 8220 | @code{pure}, @code{const}, @code{noreturn}, @code{malloc} or @code{returns_nonnull}. The compiler |
d77de738 ML |
8221 | only warns for functions visible in other compilation units or (in the case of |
8222 | @code{pure} and @code{const}) if it cannot prove that the function returns | |
8223 | normally. A function returns normally if it doesn't contain an infinite loop or | |
8224 | return abnormally by throwing, calling @code{abort} or trapping. This analysis | |
8225 | requires option @option{-fipa-pure-const}, which is enabled by default at | |
8226 | @option{-O} and higher. Higher optimization levels improve the accuracy | |
8227 | of the analysis. | |
8228 | ||
d77de738 ML |
8229 | @opindex Wsuggest-attribute=format |
8230 | @opindex Wmissing-format-attribute | |
8231 | @opindex Wno-suggest-attribute=format | |
8232 | @opindex Wno-missing-format-attribute | |
8233 | @opindex Wformat | |
8234 | @opindex Wno-format | |
ddf6fe37 AA |
8235 | @item -Wsuggest-attribute=format |
8236 | @itemx -Wmissing-format-attribute | |
d77de738 ML |
8237 | |
8238 | Warn about function pointers that might be candidates for @code{format} | |
8239 | attributes. Note these are only possible candidates, not absolute ones. | |
8240 | GCC guesses that function pointers with @code{format} attributes that | |
8241 | are used in assignment, initialization, parameter passing or return | |
8242 | statements should have a corresponding @code{format} attribute in the | |
8243 | resulting type. I.e.@: the left-hand side of the assignment or | |
8244 | initialization, the type of the parameter variable, or the return type | |
8245 | of the containing function respectively should also have a @code{format} | |
8246 | attribute to avoid the warning. | |
8247 | ||
8248 | GCC also warns about function definitions that might be | |
8249 | candidates for @code{format} attributes. Again, these are only | |
8250 | possible candidates. GCC guesses that @code{format} attributes | |
8251 | might be appropriate for any function that calls a function like | |
8252 | @code{vprintf} or @code{vscanf}, but this might not always be the | |
8253 | case, and some functions for which @code{format} attributes are | |
8254 | appropriate may not be detected. | |
8255 | ||
d77de738 ML |
8256 | @opindex Wsuggest-attribute=cold |
8257 | @opindex Wno-suggest-attribute=cold | |
ddf6fe37 | 8258 | @item -Wsuggest-attribute=cold |
d77de738 ML |
8259 | |
8260 | Warn about functions that might be candidates for @code{cold} attribute. This | |
8261 | is based on static detection and generally only warns about functions which | |
8262 | always leads to a call to another @code{cold} function such as wrappers of | |
8263 | C++ @code{throw} or fatal error reporting functions leading to @code{abort}. | |
8264 | @end table | |
8265 | ||
d880e093 MU |
8266 | @opindex Wno-alloc-size |
8267 | @opindex Walloc-size | |
8268 | @item -Walloc-size | |
8269 | Warn about calls to allocation functions decorated with attribute | |
8270 | @code{alloc_size} that specify insufficient size for the target type of | |
8271 | the pointer the result is assigned to, including those to the built-in | |
8272 | forms of the functions @code{aligned_alloc}, @code{alloca}, | |
e7dd72ae | 8273 | @code{calloc}, @code{malloc}, and @code{realloc}. |
d880e093 | 8274 | |
d77de738 ML |
8275 | @opindex Wno-alloc-zero |
8276 | @opindex Walloc-zero | |
ddf6fe37 | 8277 | @item -Walloc-zero |
d77de738 ML |
8278 | Warn about calls to allocation functions decorated with attribute |
8279 | @code{alloc_size} that specify zero bytes, including those to the built-in | |
8280 | forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc}, | |
8281 | @code{malloc}, and @code{realloc}. Because the behavior of these functions | |
8282 | when called with a zero size differs among implementations (and in the case | |
8283 | of @code{realloc} has been deprecated) relying on it may result in subtle | |
8284 | portability bugs and should be avoided. | |
8285 | ||
e7dd72ae JJ |
8286 | @opindex Wcalloc-transposed-args |
8287 | @opindex Wno-calloc-transposed-args | |
8288 | @item -Wcalloc-transposed-args | |
8289 | Warn about calls to allocation functions decorated with attribute | |
8290 | @code{alloc_size} with two arguments, which use @code{sizeof} operator | |
8291 | as the earlier size argument and don't use it as the later size argument. | |
8292 | This is a coding style warning. The first argument to @code{calloc} is | |
8293 | documented to be number of elements in array, while the second argument | |
8294 | is size of each element, so @code{calloc (@var{n}, sizeof (int))} is preferred | |
8295 | over @code{calloc (sizeof (int), @var{n})}. If @code{sizeof} in the earlier | |
8296 | argument and not the latter is intentional, the warning can be suppressed | |
8297 | by using @code{calloc (sizeof (struct @var{S}) + 0, n)} or | |
8298 | @code{calloc (1 * sizeof (struct @var{S}), 4)} or using @code{sizeof} in the | |
8299 | later argument as well. | |
8300 | ||
d77de738 ML |
8301 | @opindex Walloc-size-larger-than= |
8302 | @opindex Wno-alloc-size-larger-than | |
ddf6fe37 | 8303 | @item -Walloc-size-larger-than=@var{byte-size} |
d77de738 ML |
8304 | Warn about calls to functions decorated with attribute @code{alloc_size} |
8305 | that attempt to allocate objects larger than the specified number of bytes, | |
8306 | or where the result of the size computation in an integer type with infinite | |
8307 | precision would exceed the value of @samp{PTRDIFF_MAX} on the target. | |
8308 | @option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8309 | Warnings controlled by the option can be disabled either by specifying | |
8310 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8311 | @option{-Wno-alloc-size-larger-than}. | |
8312 | @xref{Function Attributes}. | |
8313 | ||
d77de738 | 8314 | @opindex Wno-alloc-size-larger-than |
ddf6fe37 | 8315 | @item -Wno-alloc-size-larger-than |
d77de738 ML |
8316 | Disable @option{-Walloc-size-larger-than=} warnings. The option is |
8317 | equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or | |
8318 | larger. | |
8319 | ||
d77de738 ML |
8320 | @opindex Wno-alloca |
8321 | @opindex Walloca | |
ddf6fe37 | 8322 | @item -Walloca |
d77de738 ML |
8323 | This option warns on all uses of @code{alloca} in the source. |
8324 | ||
d77de738 ML |
8325 | @opindex Walloca-larger-than= |
8326 | @opindex Wno-alloca-larger-than | |
ddf6fe37 | 8327 | @item -Walloca-larger-than=@var{byte-size} |
d77de738 ML |
8328 | This option warns on calls to @code{alloca} with an integer argument whose |
8329 | value is either zero, or that is not bounded by a controlling predicate | |
8330 | that limits its value to at most @var{byte-size}. It also warns for calls | |
8331 | to @code{alloca} where the bound value is unknown. Arguments of non-integer | |
8332 | types are considered unbounded even if they appear to be constrained to | |
8333 | the expected range. | |
8334 | ||
8335 | For example, a bounded case of @code{alloca} could be: | |
8336 | ||
8337 | @smallexample | |
8338 | void func (size_t n) | |
8339 | @{ | |
8340 | void *p; | |
8341 | if (n <= 1000) | |
8342 | p = alloca (n); | |
8343 | else | |
8344 | p = malloc (n); | |
8345 | f (p); | |
8346 | @} | |
8347 | @end smallexample | |
8348 | ||
8349 | In the above example, passing @code{-Walloca-larger-than=1000} would not | |
8350 | issue a warning because the call to @code{alloca} is known to be at most | |
8351 | 1000 bytes. However, if @code{-Walloca-larger-than=500} were passed, | |
8352 | the compiler would emit a warning. | |
8353 | ||
8354 | Unbounded uses, on the other hand, are uses of @code{alloca} with no | |
8355 | controlling predicate constraining its integer argument. For example: | |
8356 | ||
8357 | @smallexample | |
8358 | void func () | |
8359 | @{ | |
8360 | void *p = alloca (n); | |
8361 | f (p); | |
8362 | @} | |
8363 | @end smallexample | |
8364 | ||
8365 | If @code{-Walloca-larger-than=500} were passed, the above would trigger | |
8366 | a warning, but this time because of the lack of bounds checking. | |
8367 | ||
8368 | Note, that even seemingly correct code involving signed integers could | |
8369 | cause a warning: | |
8370 | ||
8371 | @smallexample | |
8372 | void func (signed int n) | |
8373 | @{ | |
8374 | if (n < 500) | |
8375 | @{ | |
8376 | p = alloca (n); | |
8377 | f (p); | |
8378 | @} | |
8379 | @} | |
8380 | @end smallexample | |
8381 | ||
8382 | In the above example, @var{n} could be negative, causing a larger than | |
8383 | expected argument to be implicitly cast into the @code{alloca} call. | |
8384 | ||
8385 | This option also warns when @code{alloca} is used in a loop. | |
8386 | ||
8387 | @option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default | |
8388 | but is usually only effective when @option{-ftree-vrp} is active (default | |
8389 | for @option{-O2} and above). | |
8390 | ||
8391 | See also @option{-Wvla-larger-than=}@samp{byte-size}. | |
8392 | ||
d77de738 | 8393 | @opindex Wno-alloca-larger-than |
ddf6fe37 | 8394 | @item -Wno-alloca-larger-than |
d77de738 ML |
8395 | Disable @option{-Walloca-larger-than=} warnings. The option is |
8396 | equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger. | |
8397 | ||
d77de738 ML |
8398 | @opindex Warith-conversion |
8399 | @opindex Wno-arith-conversion | |
ddf6fe37 | 8400 | @item -Warith-conversion |
d77de738 ML |
8401 | Do warn about implicit conversions from arithmetic operations even |
8402 | when conversion of the operands to the same type cannot change their | |
8403 | values. This affects warnings from @option{-Wconversion}, | |
8404 | @option{-Wfloat-conversion}, and @option{-Wsign-conversion}. | |
8405 | ||
8406 | @smallexample | |
8407 | @group | |
8408 | void f (char c, int i) | |
8409 | @{ | |
8410 | c = c + i; // warns with @option{-Wconversion} | |
8411 | c = c + 1; // only warns with @option{-Warith-conversion} | |
8412 | @} | |
8413 | @end group | |
8414 | @end smallexample | |
8415 | ||
d77de738 ML |
8416 | @opindex Wno-array-bounds |
8417 | @opindex Warray-bounds | |
ddf6fe37 AA |
8418 | @item -Warray-bounds |
8419 | @itemx -Warray-bounds=@var{n} | |
d77de738 ML |
8420 | Warn about out of bounds subscripts or offsets into arrays. This warning |
8421 | is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp} | |
8422 | is active (the default for @option{-O2} and above) but a subset of instances | |
8423 | are issued even without optimization. | |
8424 | ||
710c9676 QZ |
8425 | By default, the trailing array of a structure will be treated as a flexible |
8426 | array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}} | |
8427 | if it is declared as either a flexible array member per C99 standard onwards | |
8428 | (@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element | |
8429 | array (@samp{[1]}). As a result, out of bounds subscripts or offsets into | |
8430 | zero-length arrays or one-element arrays are not warned by default. | |
8431 | ||
8432 | You can add the option @option{-fstrict-flex-arrays} or | |
8433 | @option{-fstrict-flex-arrays=@var{level}} to control how this | |
8434 | option treat trailing array of a structure as a flexible array member: | |
8435 | ||
8436 | when @var{level}<=1, no change to the default behavior. | |
8437 | ||
8438 | when @var{level}=2, additional warnings will be issued for out of bounds | |
8439 | subscripts or offsets into one-element arrays; | |
8440 | ||
8441 | when @var{level}=3, in addition to @var{level}=2, additional warnings will be | |
8442 | issued for out of bounds subscripts or offsets into zero-length arrays. | |
8443 | ||
d77de738 ML |
8444 | @table @gcctabopt |
8445 | @item -Warray-bounds=1 | |
8446 | This is the default warning level of @option{-Warray-bounds} and is enabled | |
8447 | by @option{-Wall}; higher levels are not, and must be explicitly requested. | |
8448 | ||
8449 | @item -Warray-bounds=2 | |
710c9676 QZ |
8450 | This warning level also warns about the intermediate results of pointer |
8451 | arithmetic that may yield out of bounds values. This warning level may | |
8452 | give a larger number of false positives and is deactivated by default. | |
d77de738 ML |
8453 | @end table |
8454 | ||
d77de738 ML |
8455 | @opindex Warray-compare |
8456 | @opindex Wno-array-compare | |
ddf6fe37 | 8457 | @item -Warray-compare |
d77de738 ML |
8458 | Warn about equality and relational comparisons between two operands of array |
8459 | type. This comparison was deprecated in C++20. For example: | |
8460 | ||
8461 | @smallexample | |
8462 | int arr1[5]; | |
8463 | int arr2[5]; | |
8464 | bool same = arr1 == arr2; | |
8465 | @end smallexample | |
8466 | ||
8467 | @option{-Warray-compare} is enabled by @option{-Wall}. | |
8468 | ||
ddf6fe37 | 8469 | @opindex Wno-array-parameter |
d77de738 ML |
8470 | @item -Warray-parameter |
8471 | @itemx -Warray-parameter=@var{n} | |
d77de738 ML |
8472 | Warn about redeclarations of functions involving arguments of array or |
8473 | pointer types of inconsistent kinds or forms, and enable the detection | |
8474 | of out-of-bounds accesses to such parameters by warnings such as | |
8475 | @option{-Warray-bounds}. | |
8476 | ||
8477 | If the first function declaration uses the array form the bound specified | |
8478 | in the array is assumed to be the minimum number of elements expected to | |
8479 | be provided in calls to the function and the maximum number of elements | |
8480 | accessed by it. Failing to provide arguments of sufficient size or accessing | |
8481 | more than the maximum number of elements may be diagnosed by warnings such | |
8482 | as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies | |
8483 | involving array parameters declared using the @code{T[static N]} form. | |
8484 | ||
8485 | For example, the warning triggers for the following redeclarations because | |
8486 | the first one allows an array of any size to be passed to @code{f} while | |
8487 | the second one with the keyword @code{static} specifies that the array | |
8488 | argument must have at least four elements. | |
8489 | ||
8490 | @smallexample | |
8491 | void f (int[static 4]); | |
8492 | void f (int[]); // warning (inconsistent array form) | |
8493 | ||
8494 | void g (void) | |
8495 | @{ | |
8496 | int *p = (int *)malloc (4); | |
8497 | f (p); // warning (array too small) | |
8498 | @dots{} | |
8499 | @} | |
8500 | @end smallexample | |
8501 | ||
8502 | At level 2 the warning also triggers for redeclarations involving any other | |
8503 | inconsistency in array or pointer argument forms denoting array sizes. | |
8504 | Pointers and arrays of unspecified bound are considered equivalent and do | |
8505 | not trigger a warning. | |
8506 | ||
8507 | @smallexample | |
8508 | void g (int*); | |
8509 | void g (int[]); // no warning | |
8510 | void g (int[8]); // warning (inconsistent array bound) | |
8511 | @end smallexample | |
8512 | ||
8513 | @option{-Warray-parameter=2} is included in @option{-Wall}. The | |
8514 | @option{-Wvla-parameter} option triggers warnings for similar inconsistencies | |
8515 | involving Variable Length Array arguments. | |
8516 | ||
d77de738 ML |
8517 | @opindex Wattribute-alias |
8518 | @opindex Wno-attribute-alias | |
ddf6fe37 AA |
8519 | @item -Wattribute-alias=@var{n} |
8520 | @itemx -Wno-attribute-alias | |
d77de738 ML |
8521 | Warn about declarations using the @code{alias} and similar attributes whose |
8522 | target is incompatible with the type of the alias. | |
8523 | @xref{Function Attributes,,Declaring Attributes of Functions}. | |
8524 | ||
8525 | @table @gcctabopt | |
8526 | @item -Wattribute-alias=1 | |
8527 | The default warning level of the @option{-Wattribute-alias} option diagnoses | |
8528 | incompatibilities between the type of the alias declaration and that of its | |
8529 | target. Such incompatibilities are typically indicative of bugs. | |
8530 | ||
8531 | @item -Wattribute-alias=2 | |
8532 | ||
8533 | At this level @option{-Wattribute-alias} also diagnoses cases where | |
8534 | the attributes of the alias declaration are more restrictive than the | |
8535 | attributes applied to its target. These mismatches can potentially | |
8536 | result in incorrect code generation. In other cases they may be | |
8537 | benign and could be resolved simply by adding the missing attribute to | |
8538 | the target. For comparison, see the @option{-Wmissing-attributes} | |
8539 | option, which controls diagnostics when the alias declaration is less | |
8540 | restrictive than the target, rather than more restrictive. | |
8541 | ||
8542 | Attributes considered include @code{alloc_align}, @code{alloc_size}, | |
8543 | @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc}, | |
8544 | @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure}, | |
8545 | @code{returns_nonnull}, and @code{returns_twice}. | |
8546 | @end table | |
8547 | ||
8548 | @option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}. | |
8549 | This is the default. You can disable these warnings with either | |
8550 | @option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}. | |
8551 | ||
d77de738 ML |
8552 | @opindex Wbidi-chars= |
8553 | @opindex Wbidi-chars | |
8554 | @opindex Wno-bidi-chars | |
ddf6fe37 | 8555 | @item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]} |
d77de738 ML |
8556 | Warn about possibly misleading UTF-8 bidirectional control characters in |
8557 | comments, string literals, character constants, and identifiers. Such | |
8558 | characters can change left-to-right writing direction into right-to-left | |
8559 | (and vice versa), which can cause confusion between the logical order and | |
8560 | visual order. This may be dangerous; for instance, it may seem that a piece | |
8561 | of code is not commented out, whereas it in fact is. | |
8562 | ||
8563 | There are three levels of warning supported by GCC@. The default is | |
8564 | @option{-Wbidi-chars=unpaired}, which warns about improperly terminated | |
8565 | bidi contexts. @option{-Wbidi-chars=none} turns the warning off. | |
8566 | @option{-Wbidi-chars=any} warns about any use of bidirectional control | |
8567 | characters. | |
8568 | ||
8569 | By default, this warning does not warn about UCNs. It is, however, possible | |
8570 | to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or | |
8571 | @option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid, | |
8572 | and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous | |
8573 | @option{-Wbidi-chars=any} was specified. | |
8574 | ||
d77de738 ML |
8575 | @opindex Wno-bool-compare |
8576 | @opindex Wbool-compare | |
ddf6fe37 | 8577 | @item -Wbool-compare |
d77de738 ML |
8578 | Warn about boolean expression compared with an integer value different from |
8579 | @code{true}/@code{false}. For instance, the following comparison is | |
8580 | always false: | |
8581 | @smallexample | |
8582 | int n = 5; | |
8583 | @dots{} | |
8584 | if ((n > 1) == 2) @{ @dots{} @} | |
8585 | @end smallexample | |
8586 | This warning is enabled by @option{-Wall}. | |
8587 | ||
d77de738 ML |
8588 | @opindex Wno-bool-operation |
8589 | @opindex Wbool-operation | |
ddf6fe37 | 8590 | @item -Wbool-operation |
d77de738 ML |
8591 | Warn about suspicious operations on expressions of a boolean type. For |
8592 | instance, bitwise negation of a boolean is very likely a bug in the program. | |
8593 | For C, this warning also warns about incrementing or decrementing a boolean, | |
8594 | which rarely makes sense. (In C++, decrementing a boolean is always invalid. | |
8595 | Incrementing a boolean is invalid in C++17, and deprecated otherwise.) | |
8596 | ||
8597 | This warning is enabled by @option{-Wall}. | |
8598 | ||
d77de738 ML |
8599 | @opindex Wno-duplicated-branches |
8600 | @opindex Wduplicated-branches | |
ddf6fe37 | 8601 | @item -Wduplicated-branches |
d77de738 ML |
8602 | Warn when an if-else has identical branches. This warning detects cases like |
8603 | @smallexample | |
8604 | if (p != NULL) | |
8605 | return 0; | |
8606 | else | |
8607 | return 0; | |
8608 | @end smallexample | |
8609 | It doesn't warn when both branches contain just a null statement. This warning | |
8610 | also warn for conditional operators: | |
8611 | @smallexample | |
8612 | int i = x ? *p : *p; | |
8613 | @end smallexample | |
8614 | ||
d77de738 ML |
8615 | @opindex Wno-duplicated-cond |
8616 | @opindex Wduplicated-cond | |
ddf6fe37 | 8617 | @item -Wduplicated-cond |
d77de738 ML |
8618 | Warn about duplicated conditions in an if-else-if chain. For instance, |
8619 | warn for the following code: | |
8620 | @smallexample | |
8621 | if (p->q != NULL) @{ @dots{} @} | |
8622 | else if (p->q != NULL) @{ @dots{} @} | |
8623 | @end smallexample | |
8624 | ||
d77de738 ML |
8625 | @opindex Wno-frame-address |
8626 | @opindex Wframe-address | |
ddf6fe37 | 8627 | @item -Wframe-address |
d77de738 ML |
8628 | Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address} |
8629 | is called with an argument greater than 0. Such calls may return indeterminate | |
8630 | values or crash the program. The warning is included in @option{-Wall}. | |
8631 | ||
d77de738 ML |
8632 | @opindex Wno-discarded-qualifiers |
8633 | @opindex Wdiscarded-qualifiers | |
ddf6fe37 | 8634 | @item -Wno-discarded-qualifiers @r{(C and Objective-C only)} |
d77de738 ML |
8635 | Do not warn if type qualifiers on pointers are being discarded. |
8636 | Typically, the compiler warns if a @code{const char *} variable is | |
8637 | passed to a function that takes a @code{char *} parameter. This option | |
8638 | can be used to suppress such a warning. | |
8639 | ||
d77de738 ML |
8640 | @opindex Wno-discarded-array-qualifiers |
8641 | @opindex Wdiscarded-array-qualifiers | |
ddf6fe37 | 8642 | @item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)} |
d77de738 ML |
8643 | Do not warn if type qualifiers on arrays which are pointer targets |
8644 | are being discarded. Typically, the compiler warns if a | |
8645 | @code{const int (*)[]} variable is passed to a function that | |
8646 | takes a @code{int (*)[]} parameter. This option can be used to | |
8647 | suppress such a warning. | |
8648 | ||
d77de738 ML |
8649 | @opindex Wno-incompatible-pointer-types |
8650 | @opindex Wincompatible-pointer-types | |
ddf6fe37 | 8651 | @item -Wno-incompatible-pointer-types @r{(C and Objective-C only)} |
d77de738 ML |
8652 | Do not warn when there is a conversion between pointers that have incompatible |
8653 | types. This warning is for cases not covered by @option{-Wno-pointer-sign}, | |
8654 | which warns for pointer argument passing or assignment with different | |
8655 | signedness. | |
8656 | ||
9715c545 FW |
8657 | By default, in C99 and later dialects of C, GCC treats this issue as an |
8658 | error. The error can be downgraded to a warning using | |
8659 | @option{-fpermissive} (along with certain other errors), or for this | |
8660 | error alone, with @option{-Wno-error=incompatible-pointer-types}. | |
8661 | ||
5fccebdb JM |
8662 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8663 | ||
d77de738 ML |
8664 | @opindex Wno-int-conversion |
8665 | @opindex Wint-conversion | |
ddf6fe37 | 8666 | @item -Wno-int-conversion @r{(C and Objective-C only)} |
d77de738 ML |
8667 | Do not warn about incompatible integer to pointer and pointer to integer |
8668 | conversions. This warning is about implicit conversions; for explicit | |
8669 | conversions the warnings @option{-Wno-int-to-pointer-cast} and | |
8670 | @option{-Wno-pointer-to-int-cast} may be used. | |
8671 | ||
2c3db94d FW |
8672 | By default, in C99 and later dialects of C, GCC treats this issue as an |
8673 | error. The error can be downgraded to a warning using | |
8674 | @option{-fpermissive} (along with certain other errors), or for this | |
8675 | error alone, with @option{-Wno-error=int-conversion}. | |
8676 | ||
5fccebdb JM |
8677 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8678 | ||
d77de738 ML |
8679 | @opindex Wzero-length-bounds |
8680 | @opindex Wzero-length-bounds | |
ddf6fe37 | 8681 | @item -Wzero-length-bounds |
d77de738 ML |
8682 | Warn about accesses to elements of zero-length array members that might |
8683 | overlap other members of the same object. Declaring interior zero-length | |
8e9c65d3 | 8684 | arrays is discouraged because accesses to them are undefined. |
d77de738 ML |
8685 | @xref{Zero Length}. |
8686 | ||
8687 | For example, the first two stores in function @code{bad} are diagnosed | |
8688 | because the array elements overlap the subsequent members @code{b} and | |
8689 | @code{c}. The third store is diagnosed by @option{-Warray-bounds} | |
8690 | because it is beyond the bounds of the enclosing object. | |
8691 | ||
8692 | @smallexample | |
8693 | struct X @{ int a[0]; int b, c; @}; | |
8694 | struct X x; | |
8695 | ||
8696 | void bad (void) | |
8697 | @{ | |
8698 | x.a[0] = 0; // -Wzero-length-bounds | |
8699 | x.a[1] = 1; // -Wzero-length-bounds | |
8700 | x.a[2] = 2; // -Warray-bounds | |
8701 | @} | |
8702 | @end smallexample | |
8703 | ||
8704 | Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}. | |
8705 | ||
d77de738 ML |
8706 | @opindex Wno-div-by-zero |
8707 | @opindex Wdiv-by-zero | |
ddf6fe37 | 8708 | @item -Wno-div-by-zero |
d77de738 ML |
8709 | Do not warn about compile-time integer division by zero. Floating-point |
8710 | division by zero is not warned about, as it can be a legitimate way of | |
8711 | obtaining infinities and NaNs. | |
8712 | ||
d77de738 ML |
8713 | @opindex Wsystem-headers |
8714 | @opindex Wno-system-headers | |
8715 | @cindex warnings from system headers | |
8716 | @cindex system headers, warnings from | |
f33d7a88 | 8717 | @item -Wsystem-headers |
d77de738 ML |
8718 | Print warning messages for constructs found in system header files. |
8719 | Warnings from system headers are normally suppressed, on the assumption | |
8720 | that they usually do not indicate real problems and would only make the | |
8721 | compiler output harder to read. Using this command-line option tells | |
8722 | GCC to emit warnings from system headers as if they occurred in user | |
8723 | code. However, note that using @option{-Wall} in conjunction with this | |
8724 | option does @emph{not} warn about unknown pragmas in system | |
8725 | headers---for that, @option{-Wunknown-pragmas} must also be used. | |
8726 | ||
d77de738 ML |
8727 | @opindex Wtautological-compare |
8728 | @opindex Wno-tautological-compare | |
ddf6fe37 | 8729 | @item -Wtautological-compare |
d77de738 ML |
8730 | Warn if a self-comparison always evaluates to true or false. This |
8731 | warning detects various mistakes such as: | |
8732 | @smallexample | |
8733 | int i = 1; | |
8734 | @dots{} | |
8735 | if (i > i) @{ @dots{} @} | |
8736 | @end smallexample | |
8737 | ||
8738 | This warning also warns about bitwise comparisons that always evaluate | |
8739 | to true or false, for instance: | |
8740 | @smallexample | |
8741 | if ((a & 16) == 10) @{ @dots{} @} | |
8742 | @end smallexample | |
8743 | will always be false. | |
8744 | ||
8745 | This warning is enabled by @option{-Wall}. | |
8746 | ||
d77de738 ML |
8747 | @opindex Wtrampolines |
8748 | @opindex Wno-trampolines | |
ddf6fe37 | 8749 | @item -Wtrampolines |
d77de738 ML |
8750 | Warn about trampolines generated for pointers to nested functions. |
8751 | A trampoline is a small piece of data or code that is created at run | |
8752 | time on the stack when the address of a nested function is taken, and is | |
8753 | used to call the nested function indirectly. For some targets, it is | |
8754 | made up of data only and thus requires no special treatment. But, for | |
8755 | most targets, it is made up of code and thus requires the stack to be | |
8756 | made executable in order for the program to work properly. | |
8757 | ||
d77de738 ML |
8758 | @opindex Wfloat-equal |
8759 | @opindex Wno-float-equal | |
ddf6fe37 | 8760 | @item -Wfloat-equal |
d77de738 ML |
8761 | Warn if floating-point values are used in equality comparisons. |
8762 | ||
8763 | The idea behind this is that sometimes it is convenient (for the | |
8764 | programmer) to consider floating-point values as approximations to | |
8765 | infinitely precise real numbers. If you are doing this, then you need | |
8766 | to compute (by analyzing the code, or in some other way) the maximum or | |
8767 | likely maximum error that the computation introduces, and allow for it | |
8768 | when performing comparisons (and when producing output, but that's a | |
8769 | different problem). In particular, instead of testing for equality, you | |
8770 | should check to see whether the two values have ranges that overlap; and | |
8771 | this is done with the relational operators, so equality comparisons are | |
8772 | probably mistaken. | |
8773 | ||
d77de738 ML |
8774 | @opindex Wtraditional |
8775 | @opindex Wno-traditional | |
ddf6fe37 | 8776 | @item -Wtraditional @r{(C and Objective-C only)} |
d77de738 ML |
8777 | Warn about certain constructs that behave differently in traditional and |
8778 | ISO C@. Also warn about ISO C constructs that have no traditional C | |
8779 | equivalent, and/or problematic constructs that should be avoided. | |
8780 | ||
8781 | @itemize @bullet | |
8782 | @item | |
8783 | Macro parameters that appear within string literals in the macro body. | |
8784 | In traditional C macro replacement takes place within string literals, | |
8785 | but in ISO C it does not. | |
8786 | ||
8787 | @item | |
8788 | In traditional C, some preprocessor directives did not exist. | |
8789 | Traditional preprocessors only considered a line to be a directive | |
8790 | if the @samp{#} appeared in column 1 on the line. Therefore | |
8791 | @option{-Wtraditional} warns about directives that traditional C | |
8792 | understands but ignores because the @samp{#} does not appear as the | |
8793 | first character on the line. It also suggests you hide directives like | |
8794 | @code{#pragma} not understood by traditional C by indenting them. Some | |
8795 | traditional implementations do not recognize @code{#elif}, so this option | |
8796 | suggests avoiding it altogether. | |
8797 | ||
8798 | @item | |
8799 | A function-like macro that appears without arguments. | |
8800 | ||
8801 | @item | |
8802 | The unary plus operator. | |
8803 | ||
8804 | @item | |
8805 | The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point | |
8806 | constant suffixes. (Traditional C does support the @samp{L} suffix on integer | |
8807 | constants.) Note, these suffixes appear in macros defined in the system | |
8808 | headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}. | |
8809 | Use of these macros in user code might normally lead to spurious | |
8810 | warnings, however GCC's integrated preprocessor has enough context to | |
8811 | avoid warning in these cases. | |
8812 | ||
8813 | @item | |
8814 | A function declared external in one block and then used after the end of | |
8815 | the block. | |
8816 | ||
8817 | @item | |
8818 | A @code{switch} statement has an operand of type @code{long}. | |
8819 | ||
8820 | @item | |
8821 | A non-@code{static} function declaration follows a @code{static} one. | |
8822 | This construct is not accepted by some traditional C compilers. | |
8823 | ||
8824 | @item | |
8825 | The ISO type of an integer constant has a different width or | |
8826 | signedness from its traditional type. This warning is only issued if | |
8827 | the base of the constant is ten. I.e.@: hexadecimal or octal values, which | |
8828 | typically represent bit patterns, are not warned about. | |
8829 | ||
8830 | @item | |
8831 | Usage of ISO string concatenation is detected. | |
8832 | ||
8833 | @item | |
8834 | Initialization of automatic aggregates. | |
8835 | ||
8836 | @item | |
8837 | Identifier conflicts with labels. Traditional C lacks a separate | |
8838 | namespace for labels. | |
8839 | ||
8840 | @item | |
8841 | Initialization of unions. If the initializer is zero, the warning is | |
8842 | omitted. This is done under the assumption that the zero initializer in | |
8843 | user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing | |
8844 | initializer warnings and relies on default initialization to zero in the | |
8845 | traditional C case. | |
8846 | ||
8847 | @item | |
8848 | Conversions by prototypes between fixed/floating-point values and vice | |
8849 | versa. The absence of these prototypes when compiling with traditional | |
8850 | C causes serious problems. This is a subset of the possible | |
8851 | conversion warnings; for the full set use @option{-Wtraditional-conversion}. | |
8852 | ||
8853 | @item | |
8854 | Use of ISO C style function definitions. This warning intentionally is | |
8855 | @emph{not} issued for prototype declarations or variadic functions | |
8856 | because these ISO C features appear in your code when using | |
8857 | libiberty's traditional C compatibility macros, @code{PARAMS} and | |
8858 | @code{VPARAMS}. This warning is also bypassed for nested functions | |
8859 | because that feature is already a GCC extension and thus not relevant to | |
8860 | traditional C compatibility. | |
8861 | @end itemize | |
8862 | ||
d77de738 ML |
8863 | @opindex Wtraditional-conversion |
8864 | @opindex Wno-traditional-conversion | |
ddf6fe37 | 8865 | @item -Wtraditional-conversion @r{(C and Objective-C only)} |
d77de738 ML |
8866 | Warn if a prototype causes a type conversion that is different from what |
8867 | would happen to the same argument in the absence of a prototype. This | |
8868 | includes conversions of fixed point to floating and vice versa, and | |
8869 | conversions changing the width or signedness of a fixed-point argument | |
8870 | except when the same as the default promotion. | |
8871 | ||
d77de738 ML |
8872 | @opindex Wdeclaration-after-statement |
8873 | @opindex Wno-declaration-after-statement | |
ddf6fe37 | 8874 | @item -Wdeclaration-after-statement @r{(C and Objective-C only)} |
d77de738 ML |
8875 | Warn when a declaration is found after a statement in a block. This |
8876 | construct, known from C++, was introduced with ISO C99 and is by default | |
8877 | allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}. | |
8878 | ||
5fccebdb JM |
8879 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8880 | ||
d77de738 ML |
8881 | @opindex Wshadow |
8882 | @opindex Wno-shadow | |
ddf6fe37 | 8883 | @item -Wshadow |
d77de738 ML |
8884 | Warn whenever a local variable or type declaration shadows another |
8885 | variable, parameter, type, class member (in C++), or instance variable | |
8886 | (in Objective-C) or whenever a built-in function is shadowed. Note | |
8887 | that in C++, the compiler warns if a local variable shadows an | |
8888 | explicit typedef, but not if it shadows a struct/class/enum. | |
8889 | If this warning is enabled, it includes also all instances of | |
8890 | local shadowing. This means that @option{-Wno-shadow=local} | |
8891 | and @option{-Wno-shadow=compatible-local} are ignored when | |
8892 | @option{-Wshadow} is used. | |
8893 | Same as @option{-Wshadow=global}. | |
8894 | ||
d77de738 ML |
8895 | @opindex Wno-shadow-ivar |
8896 | @opindex Wshadow-ivar | |
ddf6fe37 | 8897 | @item -Wno-shadow-ivar @r{(Objective-C only)} |
d77de738 ML |
8898 | Do not warn whenever a local variable shadows an instance variable in an |
8899 | Objective-C method. | |
8900 | ||
d77de738 | 8901 | @opindex Wshadow=global |
ddf6fe37 | 8902 | @item -Wshadow=global |
d77de738 ML |
8903 | Warn for any shadowing. |
8904 | Same as @option{-Wshadow}. | |
8905 | ||
d77de738 | 8906 | @opindex Wshadow=local |
ddf6fe37 | 8907 | @item -Wshadow=local |
d77de738 ML |
8908 | Warn when a local variable shadows another local variable or parameter. |
8909 | ||
d77de738 | 8910 | @opindex Wshadow=compatible-local |
ddf6fe37 | 8911 | @item -Wshadow=compatible-local |
d77de738 ML |
8912 | Warn when a local variable shadows another local variable or parameter |
8913 | whose type is compatible with that of the shadowing variable. In C++, | |
8914 | type compatibility here means the type of the shadowing variable can be | |
8915 | converted to that of the shadowed variable. The creation of this flag | |
8916 | (in addition to @option{-Wshadow=local}) is based on the idea that when | |
8917 | a local variable shadows another one of incompatible type, it is most | |
8918 | likely intentional, not a bug or typo, as shown in the following example: | |
8919 | ||
8920 | @smallexample | |
8921 | @group | |
8922 | for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i) | |
8923 | @{ | |
8924 | for (int i = 0; i < N; ++i) | |
8925 | @{ | |
8926 | ... | |
8927 | @} | |
8928 | ... | |
8929 | @} | |
8930 | @end group | |
8931 | @end smallexample | |
8932 | ||
8933 | Since the two variable @code{i} in the example above have incompatible types, | |
8934 | enabling only @option{-Wshadow=compatible-local} does not emit a warning. | |
8935 | Because their types are incompatible, if a programmer accidentally uses one | |
8936 | in place of the other, type checking is expected to catch that and emit an | |
8937 | error or warning. Use of this flag instead of @option{-Wshadow=local} can | |
8938 | possibly reduce the number of warnings triggered by intentional shadowing. | |
8939 | Note that this also means that shadowing @code{const char *i} by | |
8940 | @code{char *i} does not emit a warning. | |
8941 | ||
8942 | This warning is also enabled by @option{-Wshadow=local}. | |
8943 | ||
d77de738 ML |
8944 | @opindex Wlarger-than= |
8945 | @opindex Wlarger-than-@var{byte-size} | |
ddf6fe37 | 8946 | @item -Wlarger-than=@var{byte-size} |
d77de738 ML |
8947 | Warn whenever an object is defined whose size exceeds @var{byte-size}. |
8948 | @option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8949 | Warnings controlled by the option can be disabled either by specifying | |
8950 | @var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}. | |
8951 | ||
8952 | Also warn for calls to bounded functions such as @code{memchr} or | |
8953 | @code{strnlen} that specify a bound greater than the largest possible | |
8954 | object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings | |
8955 | can only be disabled by @option{-Wno-larger-than}. | |
8956 | ||
d77de738 | 8957 | @opindex Wno-larger-than |
ddf6fe37 | 8958 | @item -Wno-larger-than |
d77de738 ML |
8959 | Disable @option{-Wlarger-than=} warnings. The option is equivalent |
8960 | to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger. | |
8961 | ||
d77de738 ML |
8962 | @opindex Wframe-larger-than= |
8963 | @opindex Wno-frame-larger-than | |
ddf6fe37 | 8964 | @item -Wframe-larger-than=@var{byte-size} |
d77de738 ML |
8965 | Warn if the size of a function frame exceeds @var{byte-size}. |
8966 | The computation done to determine the stack frame size is approximate | |
8967 | and not conservative. | |
8968 | The actual requirements may be somewhat greater than @var{byte-size} | |
8969 | even if you do not get a warning. In addition, any space allocated | |
8970 | via @code{alloca}, variable-length arrays, or related constructs | |
8971 | is not included by the compiler when determining | |
8972 | whether or not to issue a warning. | |
8973 | @option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8974 | Warnings controlled by the option can be disabled either by specifying | |
8975 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8976 | @option{-Wno-frame-larger-than}. | |
8977 | ||
d77de738 | 8978 | @opindex Wno-frame-larger-than |
ddf6fe37 | 8979 | @item -Wno-frame-larger-than |
d77de738 ML |
8980 | Disable @option{-Wframe-larger-than=} warnings. The option is equivalent |
8981 | to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger. | |
8982 | ||
d77de738 ML |
8983 | @opindex Wfree-nonheap-object |
8984 | @opindex Wno-free-nonheap-object | |
ddf6fe37 | 8985 | @item -Wfree-nonheap-object |
d77de738 ML |
8986 | Warn when attempting to deallocate an object that was either not allocated |
8987 | on the heap, or by using a pointer that was not returned from a prior call | |
8988 | to the corresponding allocation function. For example, because the call | |
8989 | to @code{stpcpy} returns a pointer to the terminating nul character and | |
8990 | not to the beginning of the object, the call to @code{free} below is | |
8991 | diagnosed. | |
8992 | ||
8993 | @smallexample | |
8994 | void f (char *p) | |
8995 | @{ | |
8996 | p = stpcpy (p, "abc"); | |
8997 | // ... | |
8998 | free (p); // warning | |
8999 | @} | |
9000 | @end smallexample | |
9001 | ||
9002 | @option{-Wfree-nonheap-object} is included in @option{-Wall}. | |
9003 | ||
d77de738 ML |
9004 | @opindex Wstack-usage |
9005 | @opindex Wno-stack-usage | |
ddf6fe37 | 9006 | @item -Wstack-usage=@var{byte-size} |
d77de738 ML |
9007 | Warn if the stack usage of a function might exceed @var{byte-size}. |
9008 | The computation done to determine the stack usage is conservative. | |
9009 | Any space allocated via @code{alloca}, variable-length arrays, or related | |
9010 | constructs is included by the compiler when determining whether or not to | |
9011 | issue a warning. | |
9012 | ||
9013 | The message is in keeping with the output of @option{-fstack-usage}. | |
9014 | ||
9015 | @itemize | |
9016 | @item | |
9017 | If the stack usage is fully static but exceeds the specified amount, it's: | |
9018 | ||
9019 | @smallexample | |
9020 | warning: stack usage is 1120 bytes | |
9021 | @end smallexample | |
9022 | @item | |
9023 | If the stack usage is (partly) dynamic but bounded, it's: | |
9024 | ||
9025 | @smallexample | |
9026 | warning: stack usage might be 1648 bytes | |
9027 | @end smallexample | |
9028 | @item | |
9029 | If the stack usage is (partly) dynamic and not bounded, it's: | |
9030 | ||
9031 | @smallexample | |
9032 | warning: stack usage might be unbounded | |
9033 | @end smallexample | |
9034 | @end itemize | |
9035 | ||
9036 | @option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default. | |
9037 | Warnings controlled by the option can be disabled either by specifying | |
9038 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
9039 | @option{-Wno-stack-usage}. | |
9040 | ||
d77de738 | 9041 | @opindex Wno-stack-usage |
ddf6fe37 | 9042 | @item -Wno-stack-usage |
d77de738 ML |
9043 | Disable @option{-Wstack-usage=} warnings. The option is equivalent |
9044 | to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger. | |
9045 | ||
d77de738 ML |
9046 | @opindex Wunsafe-loop-optimizations |
9047 | @opindex Wno-unsafe-loop-optimizations | |
ddf6fe37 | 9048 | @item -Wunsafe-loop-optimizations |
d77de738 ML |
9049 | Warn if the loop cannot be optimized because the compiler cannot |
9050 | assume anything on the bounds of the loop indices. With | |
9051 | @option{-funsafe-loop-optimizations} warn if the compiler makes | |
9052 | such assumptions. | |
9053 | ||
d77de738 ML |
9054 | @opindex Wno-pedantic-ms-format |
9055 | @opindex Wpedantic-ms-format | |
ddf6fe37 | 9056 | @item -Wno-pedantic-ms-format @r{(MinGW targets only)} |
d77de738 ML |
9057 | When used in combination with @option{-Wformat} |
9058 | and @option{-pedantic} without GNU extensions, this option | |
9059 | disables the warnings about non-ISO @code{printf} / @code{scanf} format | |
9060 | width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets, | |
9061 | which depend on the MS runtime. | |
9062 | ||
d77de738 ML |
9063 | @opindex Wpointer-arith |
9064 | @opindex Wno-pointer-arith | |
ddf6fe37 | 9065 | @item -Wpointer-arith |
d77de738 ML |
9066 | Warn about anything that depends on the ``size of'' a function type or |
9067 | of @code{void}. GNU C assigns these types a size of 1, for | |
9068 | convenience in calculations with @code{void *} pointers and pointers | |
9069 | to functions. In C++, warn also when an arithmetic operation involves | |
9070 | @code{NULL}. This warning is also enabled by @option{-Wpedantic}. | |
9071 | ||
5fccebdb JM |
9072 | This warning is upgraded to an error by @option{-pedantic-errors}. |
9073 | ||
d77de738 ML |
9074 | @opindex Wpointer-compare |
9075 | @opindex Wno-pointer-compare | |
ddf6fe37 | 9076 | @item -Wno-pointer-compare |
d77de738 ML |
9077 | Do not warn if a pointer is compared with a zero character constant. |
9078 | This usually | |
9079 | means that the pointer was meant to be dereferenced. For example: | |
9080 | ||
9081 | @smallexample | |
9082 | const char *p = foo (); | |
9083 | if (p == '\0') | |
9084 | return 42; | |
9085 | @end smallexample | |
9086 | ||
9087 | Note that the code above is invalid in C++11. | |
9088 | ||
9089 | This warning is enabled by default. | |
9090 | ||
d77de738 ML |
9091 | @opindex Wtsan |
9092 | @opindex Wno-tsan | |
9a5e8f9d SL |
9093 | @item -Wno-tsan |
9094 | ||
9095 | Disable warnings about unsupported features in ThreadSanitizer. | |
d77de738 ML |
9096 | |
9097 | ThreadSanitizer does not support @code{std::atomic_thread_fence} and | |
9098 | can report false positives. | |
9099 | ||
d77de738 ML |
9100 | @opindex Wtype-limits |
9101 | @opindex Wno-type-limits | |
ddf6fe37 | 9102 | @item -Wtype-limits |
d77de738 ML |
9103 | Warn if a comparison is always true or always false due to the limited |
9104 | range of the data type, but do not warn for constant expressions. For | |
9105 | example, warn if an unsigned variable is compared against zero with | |
9106 | @code{<} or @code{>=}. This warning is also enabled by | |
9107 | @option{-Wextra}. | |
9108 | ||
d77de738 ML |
9109 | @opindex Wabsolute-value |
9110 | @opindex Wno-absolute-value | |
ddf6fe37 | 9111 | @item -Wabsolute-value @r{(C and Objective-C only)} |
d77de738 ML |
9112 | Warn for calls to standard functions that compute the absolute value |
9113 | of an argument when a more appropriate standard function is available. | |
9114 | For example, calling @code{abs(3.14)} triggers the warning because the | |
9115 | appropriate function to call to compute the absolute value of a double | |
9116 | argument is @code{fabs}. The option also triggers warnings when the | |
9117 | argument in a call to such a function has an unsigned type. This | |
9118 | warning can be suppressed with an explicit type cast and it is also | |
9119 | enabled by @option{-Wextra}. | |
9120 | ||
9121 | @include cppwarnopts.texi | |
9122 | ||
d77de738 ML |
9123 | @opindex Wbad-function-cast |
9124 | @opindex Wno-bad-function-cast | |
ddf6fe37 | 9125 | @item -Wbad-function-cast @r{(C and Objective-C only)} |
d77de738 ML |
9126 | Warn when a function call is cast to a non-matching type. |
9127 | For example, warn if a call to a function returning an integer type | |
9128 | is cast to a pointer type. | |
9129 | ||
d77de738 ML |
9130 | @opindex Wc90-c99-compat |
9131 | @opindex Wno-c90-c99-compat | |
ddf6fe37 | 9132 | @item -Wc90-c99-compat @r{(C and Objective-C only)} |
d77de738 ML |
9133 | Warn about features not present in ISO C90, but present in ISO C99. |
9134 | For instance, warn about use of variable length arrays, @code{long long} | |
9135 | type, @code{bool} type, compound literals, designated initializers, and so | |
9136 | on. This option is independent of the standards mode. Warnings are disabled | |
9137 | in the expression that follows @code{__extension__}. | |
9138 | ||
d77de738 ML |
9139 | @opindex Wc99-c11-compat |
9140 | @opindex Wno-c99-c11-compat | |
ddf6fe37 | 9141 | @item -Wc99-c11-compat @r{(C and Objective-C only)} |
d77de738 ML |
9142 | Warn about features not present in ISO C99, but present in ISO C11. |
9143 | For instance, warn about use of anonymous structures and unions, | |
9144 | @code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier, | |
9145 | @code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword, | |
9146 | and so on. This option is independent of the standards mode. Warnings are | |
9147 | disabled in the expression that follows @code{__extension__}. | |
9148 | ||
fad61bf7 JM |
9149 | @opindex Wc11-c23-compat |
9150 | @opindex Wno-c11-c23-compat | |
9151 | @item -Wc11-c23-compat @r{(C and Objective-C only)} | |
9152 | @itemx -Wc11-c2x-compat @r{(C and Objective-C only)} | |
9153 | Warn about features not present in ISO C11, but present in ISO C23. | |
d77de738 ML |
9154 | For instance, warn about omitting the string in @code{_Static_assert}, |
9155 | use of @samp{[[]]} syntax for attributes, use of decimal | |
9156 | floating-point types, and so on. This option is independent of the | |
9157 | standards mode. Warnings are disabled in the expression that follows | |
fad61bf7 JM |
9158 | @code{__extension__}. The name @option{-Wc11-c2x-compat} is |
9159 | deprecated. | |
d77de738 | 9160 | |
fad61bf7 | 9161 | When not compiling in C23 mode, these warnings are upgraded to errors |
5fccebdb JM |
9162 | by @option{-pedantic-errors}. |
9163 | ||
d77de738 ML |
9164 | @opindex Wc++-compat |
9165 | @opindex Wno-c++-compat | |
ddf6fe37 | 9166 | @item -Wc++-compat @r{(C and Objective-C only)} |
d77de738 ML |
9167 | Warn about ISO C constructs that are outside of the common subset of |
9168 | ISO C and ISO C++, e.g.@: request for implicit conversion from | |
9169 | @code{void *} to a pointer to non-@code{void} type. | |
9170 | ||
d77de738 ML |
9171 | @opindex Wc++11-compat |
9172 | @opindex Wno-c++11-compat | |
ddf6fe37 | 9173 | @item -Wc++11-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9174 | Warn about C++ constructs whose meaning differs between ISO C++ 1998 |
9175 | and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords | |
9176 | in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is | |
9177 | enabled by @option{-Wall}. | |
9178 | ||
d77de738 ML |
9179 | @opindex Wc++14-compat |
9180 | @opindex Wno-c++14-compat | |
ddf6fe37 | 9181 | @item -Wc++14-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9182 | Warn about C++ constructs whose meaning differs between ISO C++ 2011 |
9183 | and ISO C++ 2014. This warning is enabled by @option{-Wall}. | |
9184 | ||
d77de738 ML |
9185 | @opindex Wc++17-compat |
9186 | @opindex Wno-c++17-compat | |
ddf6fe37 | 9187 | @item -Wc++17-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9188 | Warn about C++ constructs whose meaning differs between ISO C++ 2014 |
9189 | and ISO C++ 2017. This warning is enabled by @option{-Wall}. | |
9190 | ||
d77de738 ML |
9191 | @opindex Wc++20-compat |
9192 | @opindex Wno-c++20-compat | |
ddf6fe37 | 9193 | @item -Wc++20-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9194 | Warn about C++ constructs whose meaning differs between ISO C++ 2017 |
9195 | and ISO C++ 2020. This warning is enabled by @option{-Wall}. | |
9196 | ||
d77de738 ML |
9197 | @opindex Wc++11-extensions |
9198 | @opindex Wno-c++11-extensions | |
ddf6fe37 | 9199 | @item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9200 | Do not warn about C++11 constructs in code being compiled using |
9201 | an older C++ standard. Even without this option, some C++11 constructs | |
9202 | will only be diagnosed if @option{-Wpedantic} is used. | |
9203 | ||
d77de738 ML |
9204 | @opindex Wc++14-extensions |
9205 | @opindex Wno-c++14-extensions | |
ddf6fe37 | 9206 | @item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9207 | Do not warn about C++14 constructs in code being compiled using |
9208 | an older C++ standard. Even without this option, some C++14 constructs | |
9209 | will only be diagnosed if @option{-Wpedantic} is used. | |
9210 | ||
d77de738 ML |
9211 | @opindex Wc++17-extensions |
9212 | @opindex Wno-c++17-extensions | |
ddf6fe37 | 9213 | @item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9214 | Do not warn about C++17 constructs in code being compiled using |
9215 | an older C++ standard. Even without this option, some C++17 constructs | |
9216 | will only be diagnosed if @option{-Wpedantic} is used. | |
9217 | ||
d77de738 ML |
9218 | @opindex Wc++20-extensions |
9219 | @opindex Wno-c++20-extensions | |
ddf6fe37 | 9220 | @item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9221 | Do not warn about C++20 constructs in code being compiled using |
9222 | an older C++ standard. Even without this option, some C++20 constructs | |
9223 | will only be diagnosed if @option{-Wpedantic} is used. | |
9224 | ||
d77de738 ML |
9225 | @opindex Wc++23-extensions |
9226 | @opindex Wno-c++23-extensions | |
ddf6fe37 | 9227 | @item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9228 | Do not warn about C++23 constructs in code being compiled using |
9229 | an older C++ standard. Even without this option, some C++23 constructs | |
9230 | will only be diagnosed if @option{-Wpedantic} is used. | |
9231 | ||
6ce95218 JJ |
9232 | @opindex Wc++26-extensions |
9233 | @opindex Wno-c++26-extensions | |
9234 | @item -Wno-c++26-extensions @r{(C++ and Objective-C++ only)} | |
9235 | Do not warn about C++26 constructs in code being compiled using | |
9236 | an older C++ standard. Even without this option, some C++26 constructs | |
9237 | will only be diagnosed if @option{-Wpedantic} is used. | |
9238 | ||
d77de738 ML |
9239 | @opindex Wcast-qual |
9240 | @opindex Wno-cast-qual | |
ddf6fe37 | 9241 | @item -Wcast-qual |
d77de738 ML |
9242 | Warn whenever a pointer is cast so as to remove a type qualifier from |
9243 | the target type. For example, warn if a @code{const char *} is cast | |
9244 | to an ordinary @code{char *}. | |
9245 | ||
9246 | Also warn when making a cast that introduces a type qualifier in an | |
9247 | unsafe way. For example, casting @code{char **} to @code{const char **} | |
9248 | is unsafe, as in this example: | |
9249 | ||
9250 | @smallexample | |
9251 | /* p is char ** value. */ | |
9252 | const char **q = (const char **) p; | |
9253 | /* Assignment of readonly string to const char * is OK. */ | |
9254 | *q = "string"; | |
9255 | /* Now char** pointer points to read-only memory. */ | |
9256 | **p = 'b'; | |
9257 | @end smallexample | |
9258 | ||
d77de738 ML |
9259 | @opindex Wcast-align |
9260 | @opindex Wno-cast-align | |
ddf6fe37 | 9261 | @item -Wcast-align |
d77de738 ML |
9262 | Warn whenever a pointer is cast such that the required alignment of the |
9263 | target is increased. For example, warn if a @code{char *} is cast to | |
9264 | an @code{int *} on machines where integers can only be accessed at | |
9265 | two- or four-byte boundaries. | |
9266 | ||
d77de738 | 9267 | @opindex Wcast-align=strict |
ddf6fe37 | 9268 | @item -Wcast-align=strict |
d77de738 ML |
9269 | Warn whenever a pointer is cast such that the required alignment of the |
9270 | target is increased. For example, warn if a @code{char *} is cast to | |
9271 | an @code{int *} regardless of the target machine. | |
9272 | ||
d77de738 ML |
9273 | @opindex Wcast-function-type |
9274 | @opindex Wno-cast-function-type | |
ddf6fe37 | 9275 | @item -Wcast-function-type |
d77de738 ML |
9276 | Warn when a function pointer is cast to an incompatible function pointer. |
9277 | In a cast involving function types with a variable argument list only | |
9278 | the types of initial arguments that are provided are considered. | |
9279 | Any parameter of pointer-type matches any other pointer-type. Any benign | |
9280 | differences in integral types are ignored, like @code{int} vs.@: @code{long} | |
9281 | on ILP32 targets. Likewise type qualifiers are ignored. The function | |
9282 | type @code{void (*) (void)} is special and matches everything, which can | |
9283 | be used to suppress this warning. | |
9284 | In a cast involving pointer to member types this warning warns whenever | |
9285 | the type cast is changing the pointer to member type. | |
9286 | This warning is enabled by @option{-Wextra}. | |
9287 | ||
d77de738 ML |
9288 | @opindex Wwrite-strings |
9289 | @opindex Wno-write-strings | |
ddf6fe37 | 9290 | @item -Wwrite-strings |
d77de738 ML |
9291 | When compiling C, give string constants the type @code{const |
9292 | char[@var{length}]} so that copying the address of one into a | |
9293 | non-@code{const} @code{char *} pointer produces a warning. These | |
9294 | warnings help you find at compile time code that can try to write | |
9295 | into a string constant, but only if you have been very careful about | |
9296 | using @code{const} in declarations and prototypes. Otherwise, it is | |
9297 | just a nuisance. This is why we did not make @option{-Wall} request | |
9298 | these warnings. | |
9299 | ||
9300 | When compiling C++, warn about the deprecated conversion from string | |
9301 | literals to @code{char *}. This warning is enabled by default for C++ | |
9302 | programs. | |
9303 | ||
5fccebdb JM |
9304 | This warning is upgraded to an error by @option{-pedantic-errors} in |
9305 | C++11 mode or later. | |
9306 | ||
d77de738 ML |
9307 | @opindex Wclobbered |
9308 | @opindex Wno-clobbered | |
f33d7a88 | 9309 | @item -Wclobbered |
d77de738 ML |
9310 | Warn for variables that might be changed by @code{longjmp} or |
9311 | @code{vfork}. This warning is also enabled by @option{-Wextra}. | |
9312 | ||
320dc51c TS |
9313 | @opindex Wcomplain-wrong-lang |
9314 | @opindex Wno-complain-wrong-lang | |
f33d7a88 | 9315 | @item -Wno-complain-wrong-lang |
320dc51c TS |
9316 | By default, language front ends complain when a command-line option is |
9317 | valid, but not applicable to that front end. | |
9318 | This may be disabled with @option{-Wno-complain-wrong-lang}, | |
9319 | which is mostly useful when invoking a single compiler driver for | |
9320 | multiple source files written in different languages, for example: | |
9321 | ||
9322 | @smallexample | |
9323 | $ g++ -fno-rtti a.cc b.f90 | |
9324 | @end smallexample | |
9325 | ||
9326 | The driver @file{g++} invokes the C++ front end to compile @file{a.cc} | |
9327 | and the Fortran front end to compile @file{b.f90}. | |
9328 | The latter front end diagnoses | |
9329 | @samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran}, | |
9330 | which may be disabled with @option{-Wno-complain-wrong-lang}. | |
9331 | ||
e1f45bea JM |
9332 | @opindex Wcompare-distinct-pointer-types |
9333 | @item -Wcompare-distinct-pointer-types @r{(C and Objective-C only)} | |
9334 | Warn if pointers of distinct types are compared without a cast. This | |
9335 | warning is enabled by default. | |
9336 | ||
d77de738 ML |
9337 | @opindex Wconversion |
9338 | @opindex Wno-conversion | |
f33d7a88 | 9339 | @item -Wconversion |
d77de738 ML |
9340 | Warn for implicit conversions that may alter a value. This includes |
9341 | conversions between real and integer, like @code{abs (x)} when | |
9342 | @code{x} is @code{double}; conversions between signed and unsigned, | |
9343 | like @code{unsigned ui = -1}; and conversions to smaller types, like | |
9344 | @code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs | |
9345 | ((int) x)} and @code{ui = (unsigned) -1}, or if the value is not | |
9346 | changed by the conversion like in @code{abs (2.0)}. Warnings about | |
9347 | conversions between signed and unsigned integers can be disabled by | |
9348 | using @option{-Wno-sign-conversion}. | |
9349 | ||
9350 | For C++, also warn for confusing overload resolution for user-defined | |
9351 | conversions; and conversions that never use a type conversion | |
9352 | operator: conversions to @code{void}, the same type, a base class or a | |
9353 | reference to them. Warnings about conversions between signed and | |
9354 | unsigned integers are disabled by default in C++ unless | |
9355 | @option{-Wsign-conversion} is explicitly enabled. | |
9356 | ||
9357 | Warnings about conversion from arithmetic on a small type back to that | |
9358 | type are only given with @option{-Warith-conversion}. | |
9359 | ||
d77de738 ML |
9360 | @opindex Wdangling-else |
9361 | @opindex Wno-dangling-else | |
ddf6fe37 | 9362 | @item -Wdangling-else |
d77de738 ML |
9363 | Warn about constructions where there may be confusion to which |
9364 | @code{if} statement an @code{else} branch belongs. Here is an example of | |
9365 | such a case: | |
9366 | ||
9367 | @smallexample | |
9368 | @group | |
9369 | @{ | |
9370 | if (a) | |
9371 | if (b) | |
9372 | foo (); | |
9373 | else | |
9374 | bar (); | |
9375 | @} | |
9376 | @end group | |
9377 | @end smallexample | |
9378 | ||
9379 | In C/C++, every @code{else} branch belongs to the innermost possible | |
9380 | @code{if} statement, which in this example is @code{if (b)}. This is | |
9381 | often not what the programmer expected, as illustrated in the above | |
9382 | example by indentation the programmer chose. When there is the | |
9383 | potential for this confusion, GCC issues a warning when this flag | |
9384 | is specified. To eliminate the warning, add explicit braces around | |
9385 | the innermost @code{if} statement so there is no way the @code{else} | |
9386 | can belong to the enclosing @code{if}. The resulting code | |
9387 | looks like this: | |
9388 | ||
9389 | @smallexample | |
9390 | @group | |
9391 | @{ | |
9392 | if (a) | |
9393 | @{ | |
9394 | if (b) | |
9395 | foo (); | |
9396 | else | |
9397 | bar (); | |
9398 | @} | |
9399 | @} | |
9400 | @end group | |
9401 | @end smallexample | |
9402 | ||
9403 | This warning is enabled by @option{-Wparentheses}. | |
9404 | ||
d77de738 ML |
9405 | @opindex Wdangling-pointer |
9406 | @opindex Wno-dangling-pointer | |
ddf6fe37 AA |
9407 | @item -Wdangling-pointer |
9408 | @itemx -Wdangling-pointer=@var{n} | |
d77de738 ML |
9409 | Warn about uses of pointers (or C++ references) to objects with automatic |
9410 | storage duration after their lifetime has ended. This includes local | |
9411 | variables declared in nested blocks, compound literals and other unnamed | |
9412 | temporary objects. In addition, warn about storing the address of such | |
9413 | objects in escaped pointers. The warning is enabled at all optimization | |
9414 | levels but may yield different results with optimization than without. | |
9415 | ||
9416 | @table @gcctabopt | |
9417 | @item -Wdangling-pointer=1 | |
9418 | At level 1 the warning diagnoses only unconditional uses of dangling pointers. | |
9419 | For example | |
9420 | @smallexample | |
9421 | int f (int c1, int c2, x) | |
9422 | @{ | |
9423 | char *p = strchr ((char[])@{ c1, c2 @}, c3); | |
4ace81b6 SL |
9424 | // warning: dangling pointer to a compound literal |
9425 | return p ? *p : 'x'; | |
d77de738 ML |
9426 | @} |
9427 | @end smallexample | |
9428 | In the following function the store of the address of the local variable | |
9429 | @code{x} in the escaped pointer @code{*p} also triggers the warning. | |
9430 | @smallexample | |
9431 | void g (int **p) | |
9432 | @{ | |
9433 | int x = 7; | |
4ace81b6 SL |
9434 | // warning: storing the address of a local variable in *p |
9435 | *p = &x; | |
d77de738 ML |
9436 | @} |
9437 | @end smallexample | |
9438 | ||
9439 | @item -Wdangling-pointer=2 | |
9440 | At level 2, in addition to unconditional uses the warning also diagnoses | |
9441 | conditional uses of dangling pointers. | |
9442 | ||
9443 | For example, because the array @var{a} in the following function is out of | |
9444 | scope when the pointer @var{s} that was set to point is used, the warning | |
9445 | triggers at this level. | |
9446 | ||
9447 | @smallexample | |
9448 | void f (char *s) | |
9449 | @{ | |
9450 | if (!s) | |
9451 | @{ | |
9452 | char a[12] = "tmpname"; | |
9453 | s = a; | |
9454 | @} | |
4ace81b6 SL |
9455 | // warning: dangling pointer to a may be used |
9456 | strcat (s, ".tmp"); | |
d77de738 ML |
9457 | ... |
9458 | @} | |
9459 | @end smallexample | |
9460 | @end table | |
9461 | ||
9462 | @option{-Wdangling-pointer=2} is included in @option{-Wall}. | |
9463 | ||
d77de738 ML |
9464 | @opindex Wdate-time |
9465 | @opindex Wno-date-time | |
ddf6fe37 | 9466 | @item -Wdate-time |
d77de738 ML |
9467 | Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__} |
9468 | are encountered as they might prevent bit-wise-identical reproducible | |
9469 | compilations. | |
9470 | ||
d77de738 ML |
9471 | @opindex Wempty-body |
9472 | @opindex Wno-empty-body | |
ddf6fe37 | 9473 | @item -Wempty-body |
d77de738 ML |
9474 | Warn if an empty body occurs in an @code{if}, @code{else} or @code{do |
9475 | while} statement. This warning is also enabled by @option{-Wextra}. | |
9476 | ||
d77de738 ML |
9477 | @opindex Wendif-labels |
9478 | @opindex Wno-endif-labels | |
ddf6fe37 | 9479 | @item -Wno-endif-labels |
d77de738 ML |
9480 | Do not warn about stray tokens after @code{#else} and @code{#endif}. |
9481 | ||
d77de738 ML |
9482 | @opindex Wenum-compare |
9483 | @opindex Wno-enum-compare | |
ddf6fe37 | 9484 | @item -Wenum-compare |
d77de738 ML |
9485 | Warn about a comparison between values of different enumerated types. |
9486 | In C++ enumerated type mismatches in conditional expressions are also | |
9487 | diagnosed and the warning is enabled by default. In C this warning is | |
9488 | enabled by @option{-Wall}. | |
9489 | ||
d77de738 ML |
9490 | @opindex Wenum-conversion |
9491 | @opindex Wno-enum-conversion | |
ddf6fe37 | 9492 | @item -Wenum-conversion |
d77de738 ML |
9493 | Warn when a value of enumerated type is implicitly converted to a |
9494 | different enumerated type. This warning is enabled by @option{-Wextra} | |
9495 | in C@. | |
9496 | ||
d77de738 ML |
9497 | @opindex Wenum-int-mismatch |
9498 | @opindex Wno-enum-int-mismatch | |
ddf6fe37 | 9499 | @item -Wenum-int-mismatch @r{(C and Objective-C only)} |
d77de738 ML |
9500 | Warn about mismatches between an enumerated type and an integer type in |
9501 | declarations. For example: | |
9502 | ||
9503 | @smallexample | |
9504 | enum E @{ l = -1, z = 0, g = 1 @}; | |
9505 | int foo(void); | |
9506 | enum E foo(void); | |
9507 | @end smallexample | |
9508 | ||
9509 | In C, an enumerated type is compatible with @code{char}, a signed | |
9510 | integer type, or an unsigned integer type. However, since the choice | |
9511 | of the underlying type of an enumerated type is implementation-defined, | |
9512 | such mismatches may cause portability issues. In C++, such mismatches | |
9513 | are an error. In C, this warning is enabled by @option{-Wall} and | |
9514 | @option{-Wc++-compat}. | |
9515 | ||
d77de738 ML |
9516 | @opindex Wjump-misses-init |
9517 | @opindex Wno-jump-misses-init | |
ddf6fe37 | 9518 | @item -Wjump-misses-init @r{(C, Objective-C only)} |
d77de738 ML |
9519 | Warn if a @code{goto} statement or a @code{switch} statement jumps |
9520 | forward across the initialization of a variable, or jumps backward to a | |
9521 | label after the variable has been initialized. This only warns about | |
9522 | variables that are initialized when they are declared. This warning is | |
9523 | only supported for C and Objective-C; in C++ this sort of branch is an | |
9524 | error in any case. | |
9525 | ||
9526 | @option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It | |
9527 | can be disabled with the @option{-Wno-jump-misses-init} option. | |
9528 | ||
d77de738 ML |
9529 | @opindex Wsign-compare |
9530 | @opindex Wno-sign-compare | |
9531 | @cindex warning for comparison of signed and unsigned values | |
9532 | @cindex comparison of signed and unsigned values, warning | |
9533 | @cindex signed and unsigned values, comparison warning | |
f33d7a88 | 9534 | @item -Wsign-compare |
d77de738 ML |
9535 | Warn when a comparison between signed and unsigned values could produce |
9536 | an incorrect result when the signed value is converted to unsigned. | |
9537 | In C++, this warning is also enabled by @option{-Wall}. In C, it is | |
9538 | also enabled by @option{-Wextra}. | |
9539 | ||
d77de738 ML |
9540 | @opindex Wsign-conversion |
9541 | @opindex Wno-sign-conversion | |
ddf6fe37 | 9542 | @item -Wsign-conversion |
d77de738 ML |
9543 | Warn for implicit conversions that may change the sign of an integer |
9544 | value, like assigning a signed integer expression to an unsigned | |
9545 | integer variable. An explicit cast silences the warning. In C, this | |
9546 | option is enabled also by @option{-Wconversion}. | |
9547 | ||
44e3f39a QZ |
9548 | @opindex Wflex-array-member-not-at-end |
9549 | @opindex Wno-flex-array-member-not-at-end | |
9550 | @item -Wflex-array-member-not-at-end @r{(C and C++ only)} | |
9551 | Warn when a structure containing a C99 flexible array member as the last | |
9552 | field is not at the end of another structure. | |
9553 | This warning warns e.g. about | |
9554 | ||
9555 | @smallexample | |
9556 | struct flex @{ int length; char data[]; @}; | |
9557 | struct mid_flex @{ int m; struct flex flex_data; int n; @}; | |
9558 | @end smallexample | |
9559 | ||
d77de738 ML |
9560 | @opindex Wfloat-conversion |
9561 | @opindex Wno-float-conversion | |
ddf6fe37 | 9562 | @item -Wfloat-conversion |
d77de738 ML |
9563 | Warn for implicit conversions that reduce the precision of a real value. |
9564 | This includes conversions from real to integer, and from higher precision | |
9565 | real to lower precision real values. This option is also enabled by | |
9566 | @option{-Wconversion}. | |
9567 | ||
d77de738 ML |
9568 | @opindex Wno-scalar-storage-order |
9569 | @opindex Wscalar-storage-order | |
ddf6fe37 | 9570 | @item -Wno-scalar-storage-order |
d77de738 ML |
9571 | Do not warn on suspicious constructs involving reverse scalar storage order. |
9572 | ||
d77de738 ML |
9573 | @opindex Wsizeof-array-div |
9574 | @opindex Wno-sizeof-array-div | |
ddf6fe37 | 9575 | @item -Wsizeof-array-div |
d77de738 ML |
9576 | Warn about divisions of two sizeof operators when the first one is applied |
9577 | to an array and the divisor does not equal the size of the array element. | |
9578 | In such a case, the computation will not yield the number of elements in the | |
9579 | array, which is likely what the user intended. This warning warns e.g. about | |
9580 | @smallexample | |
9581 | int fn () | |
9582 | @{ | |
9583 | int arr[10]; | |
9584 | return sizeof (arr) / sizeof (short); | |
9585 | @} | |
9586 | @end smallexample | |
9587 | ||
9588 | This warning is enabled by @option{-Wall}. | |
9589 | ||
d77de738 ML |
9590 | @opindex Wsizeof-pointer-div |
9591 | @opindex Wno-sizeof-pointer-div | |
ddf6fe37 | 9592 | @item -Wsizeof-pointer-div |
d77de738 ML |
9593 | Warn for suspicious divisions of two sizeof expressions that divide |
9594 | the pointer size by the element size, which is the usual way to compute | |
9595 | the array size but won't work out correctly with pointers. This warning | |
9596 | warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is | |
9597 | not an array, but a pointer. This warning is enabled by @option{-Wall}. | |
9598 | ||
d77de738 ML |
9599 | @opindex Wsizeof-pointer-memaccess |
9600 | @opindex Wno-sizeof-pointer-memaccess | |
ddf6fe37 | 9601 | @item -Wsizeof-pointer-memaccess |
d77de738 ML |
9602 | Warn for suspicious length parameters to certain string and memory built-in |
9603 | functions if the argument uses @code{sizeof}. This warning triggers for | |
9604 | example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not | |
9605 | an array, but a pointer, and suggests a possible fix, or about | |
9606 | @code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess} | |
9607 | also warns about calls to bounded string copy functions like @code{strncat} | |
9608 | or @code{strncpy} that specify as the bound a @code{sizeof} expression of | |
9609 | the source array. For example, in the following function the call to | |
9610 | @code{strncat} specifies the size of the source string as the bound. That | |
9611 | is almost certainly a mistake and so the call is diagnosed. | |
9612 | @smallexample | |
9613 | void make_file (const char *name) | |
9614 | @{ | |
9615 | char path[PATH_MAX]; | |
9616 | strncpy (path, name, sizeof path - 1); | |
9617 | strncat (path, ".text", sizeof ".text"); | |
9618 | @dots{} | |
9619 | @} | |
9620 | @end smallexample | |
9621 | ||
9622 | The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}. | |
9623 | ||
d77de738 ML |
9624 | @opindex Wsizeof-array-argument |
9625 | @opindex Wno-sizeof-array-argument | |
ddf6fe37 | 9626 | @item -Wno-sizeof-array-argument |
d77de738 ML |
9627 | Do not warn when the @code{sizeof} operator is applied to a parameter that is |
9628 | declared as an array in a function definition. This warning is enabled by | |
9629 | default for C and C++ programs. | |
9630 | ||
d77de738 ML |
9631 | @opindex Wmemset-elt-size |
9632 | @opindex Wno-memset-elt-size | |
ddf6fe37 | 9633 | @item -Wmemset-elt-size |
d77de738 ML |
9634 | Warn for suspicious calls to the @code{memset} built-in function, if the |
9635 | first argument references an array, and the third argument is a number | |
9636 | equal to the number of elements, but not equal to the size of the array | |
9637 | in memory. This indicates that the user has omitted a multiplication by | |
9638 | the element size. This warning is enabled by @option{-Wall}. | |
9639 | ||
d77de738 ML |
9640 | @opindex Wmemset-transposed-args |
9641 | @opindex Wno-memset-transposed-args | |
ddf6fe37 | 9642 | @item -Wmemset-transposed-args |
d77de738 ML |
9643 | Warn for suspicious calls to the @code{memset} built-in function where |
9644 | the second argument is not zero and the third argument is zero. For | |
9645 | example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because | |
9646 | @code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic | |
9647 | is only emitted if the third argument is a literal zero. Otherwise, if | |
9648 | it is an expression that is folded to zero, or a cast of zero to some | |
9649 | type, it is far less likely that the arguments have been mistakenly | |
9650 | transposed and no warning is emitted. This warning is enabled | |
9651 | by @option{-Wall}. | |
9652 | ||
d77de738 ML |
9653 | @opindex Waddress |
9654 | @opindex Wno-address | |
ddf6fe37 | 9655 | @item -Waddress |
d77de738 ML |
9656 | Warn about suspicious uses of address expressions. These include comparing |
9657 | the address of a function or a declared object to the null pointer constant | |
9658 | such as in | |
9659 | @smallexample | |
9660 | void f (void); | |
9661 | void g (void) | |
9662 | @{ | |
9663 | if (!f) // warning: expression evaluates to false | |
9664 | abort (); | |
9665 | @} | |
9666 | @end smallexample | |
9667 | comparisons of a pointer to a string literal, such as in | |
9668 | @smallexample | |
9669 | void f (const char *x) | |
9670 | @{ | |
9671 | if (x == "abc") // warning: expression evaluates to false | |
9672 | puts ("equal"); | |
9673 | @} | |
9674 | @end smallexample | |
9675 | and tests of the results of pointer addition or subtraction for equality | |
9676 | to null, such as in | |
9677 | @smallexample | |
9678 | void f (const int *p, int i) | |
9679 | @{ | |
9680 | return p + i == NULL; | |
9681 | @} | |
9682 | @end smallexample | |
9683 | Such uses typically indicate a programmer error: the address of most | |
9684 | functions and objects necessarily evaluates to true (the exception are | |
9685 | weak symbols), so their use in a conditional might indicate missing | |
9686 | parentheses in a function call or a missing dereference in an array | |
9687 | expression. The subset of the warning for object pointers can be | |
9688 | suppressed by casting the pointer operand to an integer type such | |
9689 | as @code{intptr_t} or @code{uintptr_t}. | |
9690 | Comparisons against string literals result in unspecified behavior | |
9691 | and are not portable, and suggest the intent was to call @code{strcmp}. | |
9692 | The warning is suppressed if the suspicious expression is the result | |
9693 | of macro expansion. | |
9694 | @option{-Waddress} warning is enabled by @option{-Wall}. | |
9695 | ||
d77de738 ML |
9696 | @opindex Waddress-of-packed-member |
9697 | @opindex Wno-address-of-packed-member | |
ddf6fe37 | 9698 | @item -Wno-address-of-packed-member |
d77de738 ML |
9699 | Do not warn when the address of packed member of struct or union is taken, |
9700 | which usually results in an unaligned pointer value. This is | |
9701 | enabled by default. | |
9702 | ||
d77de738 ML |
9703 | @opindex Wlogical-op |
9704 | @opindex Wno-logical-op | |
ddf6fe37 | 9705 | @item -Wlogical-op |
d77de738 ML |
9706 | Warn about suspicious uses of logical operators in expressions. |
9707 | This includes using logical operators in contexts where a | |
9708 | bit-wise operator is likely to be expected. Also warns when | |
9709 | the operands of a logical operator are the same: | |
9710 | @smallexample | |
9711 | extern int a; | |
9712 | if (a < 0 && a < 0) @{ @dots{} @} | |
9713 | @end smallexample | |
9714 | ||
d77de738 ML |
9715 | @opindex Wlogical-not-parentheses |
9716 | @opindex Wno-logical-not-parentheses | |
ddf6fe37 | 9717 | @item -Wlogical-not-parentheses |
d77de738 ML |
9718 | Warn about logical not used on the left hand side operand of a comparison. |
9719 | This option does not warn if the right operand is considered to be a boolean | |
9720 | expression. Its purpose is to detect suspicious code like the following: | |
9721 | @smallexample | |
9722 | int a; | |
9723 | @dots{} | |
9724 | if (!a > 1) @{ @dots{} @} | |
9725 | @end smallexample | |
9726 | ||
9727 | It is possible to suppress the warning by wrapping the LHS into | |
9728 | parentheses: | |
9729 | @smallexample | |
9730 | if ((!a) > 1) @{ @dots{} @} | |
9731 | @end smallexample | |
9732 | ||
9733 | This warning is enabled by @option{-Wall}. | |
9734 | ||
d77de738 ML |
9735 | @opindex Waggregate-return |
9736 | @opindex Wno-aggregate-return | |
ddf6fe37 | 9737 | @item -Waggregate-return |
d77de738 ML |
9738 | Warn if any functions that return structures or unions are defined or |
9739 | called. (In languages where you can return an array, this also elicits | |
9740 | a warning.) | |
9741 | ||
d77de738 ML |
9742 | @opindex Wno-aggressive-loop-optimizations |
9743 | @opindex Waggressive-loop-optimizations | |
ddf6fe37 | 9744 | @item -Wno-aggressive-loop-optimizations |
d77de738 ML |
9745 | Warn if in a loop with constant number of iterations the compiler detects |
9746 | undefined behavior in some statement during one or more of the iterations. | |
9747 | ||
d77de738 ML |
9748 | @opindex Wno-attributes |
9749 | @opindex Wattributes | |
ddf6fe37 | 9750 | @item -Wno-attributes |
d77de738 ML |
9751 | Do not warn if an unexpected @code{__attribute__} is used, such as |
9752 | unrecognized attributes, function attributes applied to variables, | |
9753 | etc. This does not stop errors for incorrect use of supported | |
9754 | attributes. | |
9755 | ||
5fccebdb JM |
9756 | Warnings about ill-formed uses of standard attributes are upgraded to |
9757 | errors by @option{-pedantic-errors}. | |
9758 | ||
d77de738 | 9759 | Additionally, using @option{-Wno-attributes=}, it is possible to suppress |
094a609c | 9760 | warnings about unknown scoped attributes (in C++11 and C23). For example, |
d77de738 ML |
9761 | @option{-Wno-attributes=vendor::attr} disables warning about the following |
9762 | declaration: | |
9763 | ||
9764 | @smallexample | |
9765 | [[vendor::attr]] void f(); | |
9766 | @end smallexample | |
9767 | ||
9768 | It is also possible to disable warning about all attributes in a namespace | |
9769 | using @option{-Wno-attributes=vendor::} which prevents warning about both | |
9770 | of these declarations: | |
9771 | ||
9772 | @smallexample | |
9773 | [[vendor::safe]] void f(); | |
9774 | [[vendor::unsafe]] void f2(); | |
9775 | @end smallexample | |
9776 | ||
9777 | Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}. | |
9778 | ||
d77de738 ML |
9779 | @opindex Wno-builtin-declaration-mismatch |
9780 | @opindex Wbuiltin-declaration-mismatch | |
ddf6fe37 | 9781 | @item -Wno-builtin-declaration-mismatch |
d77de738 ML |
9782 | Warn if a built-in function is declared with an incompatible signature |
9783 | or as a non-function, or when a built-in function declared with a type | |
9784 | that does not include a prototype is called with arguments whose promoted | |
9785 | types do not match those expected by the function. When @option{-Wextra} | |
9786 | is specified, also warn when a built-in function that takes arguments is | |
9787 | declared without a prototype. The @option{-Wbuiltin-declaration-mismatch} | |
9788 | warning is enabled by default. To avoid the warning include the appropriate | |
9789 | header to bring the prototypes of built-in functions into scope. | |
9790 | ||
9791 | For example, the call to @code{memset} below is diagnosed by the warning | |
9792 | because the function expects a value of type @code{size_t} as its argument | |
9793 | but the type of @code{32} is @code{int}. With @option{-Wextra}, | |
9794 | the declaration of the function is diagnosed as well. | |
9795 | @smallexample | |
9796 | extern void* memset (); | |
9797 | void f (void *d) | |
9798 | @{ | |
9799 | memset (d, '\0', 32); | |
9800 | @} | |
9801 | @end smallexample | |
9802 | ||
d77de738 ML |
9803 | @opindex Wno-builtin-macro-redefined |
9804 | @opindex Wbuiltin-macro-redefined | |
ddf6fe37 | 9805 | @item -Wno-builtin-macro-redefined |
d77de738 ML |
9806 | Do not warn if certain built-in macros are redefined. This suppresses |
9807 | warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__}, | |
9808 | @code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}. | |
9809 | ||
d77de738 ML |
9810 | @opindex Wstrict-prototypes |
9811 | @opindex Wno-strict-prototypes | |
ddf6fe37 | 9812 | @item -Wstrict-prototypes @r{(C and Objective-C only)} |
d77de738 ML |
9813 | Warn if a function is declared or defined without specifying the |
9814 | argument types. (An old-style function definition is permitted without | |
9815 | a warning if preceded by a declaration that specifies the argument | |
9816 | types.) | |
9817 | ||
d77de738 ML |
9818 | @opindex Wold-style-declaration |
9819 | @opindex Wno-old-style-declaration | |
ddf6fe37 | 9820 | @item -Wold-style-declaration @r{(C and Objective-C only)} |
d77de738 ML |
9821 | Warn for obsolescent usages, according to the C Standard, in a |
9822 | declaration. For example, warn if storage-class specifiers like | |
9823 | @code{static} are not the first things in a declaration. This warning | |
9824 | is also enabled by @option{-Wextra}. | |
9825 | ||
d77de738 ML |
9826 | @opindex Wold-style-definition |
9827 | @opindex Wno-old-style-definition | |
ddf6fe37 | 9828 | @item -Wold-style-definition @r{(C and Objective-C only)} |
d77de738 ML |
9829 | Warn if an old-style function definition is used. A warning is given |
9830 | even if there is a previous prototype. A definition using @samp{()} | |
094a609c | 9831 | is not considered an old-style definition in C23 mode, because it is |
d77de738 ML |
9832 | equivalent to @samp{(void)} in that case, but is considered an |
9833 | old-style definition for older standards. | |
9834 | ||
d77de738 ML |
9835 | @opindex Wmissing-parameter-type |
9836 | @opindex Wno-missing-parameter-type | |
ddf6fe37 | 9837 | @item -Wmissing-parameter-type @r{(C and Objective-C only)} |
d77de738 ML |
9838 | A function parameter is declared without a type specifier in K&R-style |
9839 | functions: | |
9840 | ||
9841 | @smallexample | |
9842 | void foo(bar) @{ @} | |
9843 | @end smallexample | |
9844 | ||
9845 | This warning is also enabled by @option{-Wextra}. | |
9846 | ||
ff9efa3f FW |
9847 | @opindex Wno-declaration-missing-parameter-type |
9848 | @opindex Wdeclaration-missing-parameter-type | |
9849 | @item -Wno-declaration-missing-parameter-type @r{(C and Objective-C only)} | |
9850 | Do not warn if a function declaration contains a parameter name without | |
9851 | a type. Such function declarations do not provide a function prototype | |
9852 | and prevent most type checking in function calls. | |
9853 | ||
9854 | This warning is enabled by default. In C99 and later dialects of C, it | |
9855 | is treated as an error. The error can be downgraded to a warning using | |
9856 | @option{-fpermissive} (along with certain other errors), or for this | |
9857 | error alone, with @option{-Wno-error=declaration-missing-parameter-type}. | |
9858 | ||
9859 | This warning is upgraded to an error by @option{-pedantic-errors}. | |
9860 | ||
d77de738 ML |
9861 | @opindex Wmissing-prototypes |
9862 | @opindex Wno-missing-prototypes | |
ddf6fe37 | 9863 | @item -Wmissing-prototypes @r{(C and Objective-C only)} |
d77de738 ML |
9864 | Warn if a global function is defined without a previous prototype |
9865 | declaration. This warning is issued even if the definition itself | |
9866 | provides a prototype. Use this option to detect global functions | |
9867 | that do not have a matching prototype declaration in a header file. | |
9868 | This option is not valid for C++ because all function declarations | |
9869 | provide prototypes and a non-matching declaration declares an | |
9870 | overload rather than conflict with an earlier declaration. | |
9871 | Use @option{-Wmissing-declarations} to detect missing declarations in C++. | |
9872 | ||
ffc74822 HM |
9873 | @opindex Wmissing-variable-declarations |
9874 | @opindex Wno-missing-variable-declarations | |
9875 | @item -Wmissing-variable-declarations @r{(C and Objective-C only)} | |
9876 | Warn if a global variable is defined without a previous declaration. | |
9877 | Use this option to detect global variables that do not have a matching | |
9878 | extern declaration in a header file. | |
9879 | ||
d77de738 ML |
9880 | @opindex Wmissing-declarations |
9881 | @opindex Wno-missing-declarations | |
ddf6fe37 | 9882 | @item -Wmissing-declarations |
d77de738 ML |
9883 | Warn if a global function is defined without a previous declaration. |
9884 | Do so even if the definition itself provides a prototype. | |
9885 | Use this option to detect global functions that are not declared in | |
9886 | header files. In C, no warnings are issued for functions with previous | |
9887 | non-prototype declarations; use @option{-Wmissing-prototypes} to detect | |
9888 | missing prototypes. In C++, no warnings are issued for function templates, | |
9889 | or for inline functions, or for functions in anonymous namespaces. | |
9890 | ||
d77de738 ML |
9891 | @opindex Wmissing-field-initializers |
9892 | @opindex Wno-missing-field-initializers | |
9893 | @opindex W | |
9894 | @opindex Wextra | |
9895 | @opindex Wno-extra | |
ddf6fe37 | 9896 | @item -Wmissing-field-initializers |
d77de738 ML |
9897 | Warn if a structure's initializer has some fields missing. For |
9898 | example, the following code causes such a warning, because | |
9899 | @code{x.h} is implicitly zero: | |
9900 | ||
9901 | @smallexample | |
9902 | struct s @{ int f, g, h; @}; | |
9903 | struct s x = @{ 3, 4 @}; | |
9904 | @end smallexample | |
9905 | ||
0f8f1dee MP |
9906 | @c It's unclear if this behavior is desirable. See PR39589 and PR96868. |
9907 | In C this option does not warn about designated initializers, so the | |
9908 | following modification does not trigger a warning: | |
d77de738 ML |
9909 | |
9910 | @smallexample | |
9911 | struct s @{ int f, g, h; @}; | |
9912 | struct s x = @{ .f = 3, .g = 4 @}; | |
9913 | @end smallexample | |
9914 | ||
9915 | In C this option does not warn about the universal zero initializer | |
9916 | @samp{@{ 0 @}}: | |
9917 | ||
9918 | @smallexample | |
9919 | struct s @{ int f, g, h; @}; | |
9920 | struct s x = @{ 0 @}; | |
9921 | @end smallexample | |
9922 | ||
9923 | Likewise, in C++ this option does not warn about the empty @{ @} | |
9924 | initializer, for example: | |
9925 | ||
9926 | @smallexample | |
9927 | struct s @{ int f, g, h; @}; | |
9928 | s x = @{ @}; | |
9929 | @end smallexample | |
9930 | ||
9931 | This warning is included in @option{-Wextra}. To get other @option{-Wextra} | |
9932 | warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}. | |
9933 | ||
d77de738 ML |
9934 | @opindex Wmissing-requires |
9935 | @opindex Wno-missing-requires | |
ddf6fe37 | 9936 | @item -Wno-missing-requires |
d77de738 ML |
9937 | |
9938 | By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement: | |
9939 | ||
9940 | @smallexample | |
9941 | bool satisfied = requires @{ C<T> @}; | |
9942 | @end smallexample | |
9943 | ||
9944 | Here @samp{satisfied} will be true if @samp{C<T>} is a valid | |
9945 | expression, which it is for all T. Presumably the user meant to write | |
9946 | ||
9947 | @smallexample | |
9948 | bool satisfied = requires @{ requires C<T> @}; | |
9949 | @end smallexample | |
9950 | ||
9951 | so @samp{satisfied} is only true if concept @samp{C} is satisfied for | |
9952 | type @samp{T}. | |
9953 | ||
9954 | This warning can be disabled with @option{-Wno-missing-requires}. | |
9955 | ||
d77de738 ML |
9956 | @opindex Wmissing-template-keyword |
9957 | @opindex Wno-missing-template-keyword | |
ddf6fe37 | 9958 | @item -Wno-missing-template-keyword |
d77de738 ML |
9959 | |
9960 | The member access tokens ., -> and :: must be followed by the @code{template} | |
9961 | keyword if the parent object is dependent and the member being named is a | |
9962 | template. | |
9963 | ||
9964 | @smallexample | |
9965 | template <class X> | |
9966 | void DoStuff (X x) | |
9967 | @{ | |
9968 | x.template DoSomeOtherStuff<X>(); // Good. | |
9969 | x.DoMoreStuff<X>(); // Warning, x is dependent. | |
9970 | @} | |
9971 | @end smallexample | |
9972 | ||
9973 | In rare cases it is possible to get false positives. To silence this, wrap | |
9974 | the expression in parentheses. For example, the following is treated as a | |
9975 | template, even where m and N are integers: | |
9976 | ||
9977 | @smallexample | |
9978 | void NotATemplate (my_class t) | |
9979 | @{ | |
9980 | int N = 5; | |
9981 | ||
9982 | bool test = t.m < N > (0); // Treated as a template. | |
9983 | test = (t.m < N) > (0); // Same meaning, but not treated as a template. | |
9984 | @} | |
9985 | @end smallexample | |
9986 | ||
9987 | This warning can be disabled with @option{-Wno-missing-template-keyword}. | |
9988 | ||
d77de738 ML |
9989 | @opindex Wno-multichar |
9990 | @opindex Wmultichar | |
ddf6fe37 | 9991 | @item -Wno-multichar |
d77de738 ML |
9992 | Do not warn if a multicharacter constant (@samp{'FOOF'}) is used. |
9993 | Usually they indicate a typo in the user's code, as they have | |
9994 | implementation-defined values, and should not be used in portable code. | |
9995 | ||
d77de738 ML |
9996 | @opindex Wnormalized= |
9997 | @opindex Wnormalized | |
9998 | @opindex Wno-normalized | |
9999 | @cindex NFC | |
10000 | @cindex NFKC | |
10001 | @cindex character set, input normalization | |
f33d7a88 | 10002 | @item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} |
d77de738 ML |
10003 | In ISO C and ISO C++, two identifiers are different if they are |
10004 | different sequences of characters. However, sometimes when characters | |
10005 | outside the basic ASCII character set are used, you can have two | |
10006 | different character sequences that look the same. To avoid confusion, | |
10007 | the ISO 10646 standard sets out some @dfn{normalization rules} which | |
10008 | when applied ensure that two sequences that look the same are turned into | |
10009 | the same sequence. GCC can warn you if you are using identifiers that | |
10010 | have not been normalized; this option controls that warning. | |
10011 | ||
10012 | There are four levels of warning supported by GCC@. The default is | |
10013 | @option{-Wnormalized=nfc}, which warns about any identifier that is | |
10014 | not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the | |
10015 | recommended form for most uses. It is equivalent to | |
10016 | @option{-Wnormalized}. | |
10017 | ||
10018 | Unfortunately, there are some characters allowed in identifiers by | |
10019 | ISO C and ISO C++ that, when turned into NFC, are not allowed in | |
10020 | identifiers. That is, there's no way to use these symbols in portable | |
10021 | ISO C or C++ and have all your identifiers in NFC@. | |
10022 | @option{-Wnormalized=id} suppresses the warning for these characters. | |
10023 | It is hoped that future versions of the standards involved will correct | |
10024 | this, which is why this option is not the default. | |
10025 | ||
10026 | You can switch the warning off for all characters by writing | |
10027 | @option{-Wnormalized=none} or @option{-Wno-normalized}. You should | |
10028 | only do this if you are using some other normalization scheme (like | |
10029 | ``D''), because otherwise you can easily create bugs that are | |
10030 | literally impossible to see. | |
10031 | ||
10032 | Some characters in ISO 10646 have distinct meanings but look identical | |
10033 | in some fonts or display methodologies, especially once formatting has | |
10034 | been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL | |
10035 | LETTER N'', displays just like a regular @code{n} that has been | |
10036 | placed in a superscript. ISO 10646 defines the @dfn{NFKC} | |
10037 | normalization scheme to convert all these into a standard form as | |
10038 | well, and GCC warns if your code is not in NFKC if you use | |
10039 | @option{-Wnormalized=nfkc}. This warning is comparable to warning | |
10040 | about every identifier that contains the letter O because it might be | |
10041 | confused with the digit 0, and so is not the default, but may be | |
10042 | useful as a local coding convention if the programming environment | |
10043 | cannot be fixed to display these characters distinctly. | |
10044 | ||
d77de738 ML |
10045 | @opindex Wno-attribute-warning |
10046 | @opindex Wattribute-warning | |
ddf6fe37 | 10047 | @item -Wno-attribute-warning |
d77de738 ML |
10048 | Do not warn about usage of functions (@pxref{Function Attributes}) |
10049 | declared with @code{warning} attribute. By default, this warning is | |
10050 | enabled. @option{-Wno-attribute-warning} can be used to disable the | |
10051 | warning or @option{-Wno-error=attribute-warning} can be used to | |
10052 | disable the error when compiled with @option{-Werror} flag. | |
10053 | ||
d77de738 ML |
10054 | @opindex Wno-deprecated |
10055 | @opindex Wdeprecated | |
ddf6fe37 | 10056 | @item -Wno-deprecated |
d77de738 ML |
10057 | Do not warn about usage of deprecated features. @xref{Deprecated Features}. |
10058 | ||
d77de738 ML |
10059 | @opindex Wno-deprecated-declarations |
10060 | @opindex Wdeprecated-declarations | |
ddf6fe37 | 10061 | @item -Wno-deprecated-declarations |
d77de738 ML |
10062 | Do not warn about uses of functions (@pxref{Function Attributes}), |
10063 | variables (@pxref{Variable Attributes}), and types (@pxref{Type | |
10064 | Attributes}) marked as deprecated by using the @code{deprecated} | |
10065 | attribute. | |
10066 | ||
d77de738 ML |
10067 | @opindex Wno-overflow |
10068 | @opindex Woverflow | |
ddf6fe37 | 10069 | @item -Wno-overflow |
d77de738 ML |
10070 | Do not warn about compile-time overflow in constant expressions. |
10071 | ||
d77de738 ML |
10072 | @opindex Wno-odr |
10073 | @opindex Wodr | |
ddf6fe37 | 10074 | @item -Wno-odr |
d77de738 ML |
10075 | Warn about One Definition Rule violations during link-time optimization. |
10076 | Enabled by default. | |
10077 | ||
d77de738 ML |
10078 | @opindex Wopenacc-parallelism |
10079 | @opindex Wno-openacc-parallelism | |
10080 | @cindex OpenACC accelerator programming | |
f33d7a88 | 10081 | @item -Wopenacc-parallelism |
d77de738 ML |
10082 | Warn about potentially suboptimal choices related to OpenACC parallelism. |
10083 | ||
449b6b81 TB |
10084 | @opindex Wopenmp |
10085 | @opindex Wno-openmp | |
10086 | @item -Wno-openmp | |
10087 | Warn about suspicious OpenMP code. | |
10088 | ||
d77de738 ML |
10089 | @opindex Wopenmp-simd |
10090 | @opindex Wno-openmp-simd | |
ddf6fe37 | 10091 | @item -Wopenmp-simd |
d77de738 ML |
10092 | Warn if the vectorizer cost model overrides the OpenMP |
10093 | simd directive set by user. The @option{-fsimd-cost-model=unlimited} | |
10094 | option can be used to relax the cost model. | |
10095 | ||
d77de738 ML |
10096 | @opindex Woverride-init |
10097 | @opindex Wno-override-init | |
10098 | @opindex W | |
10099 | @opindex Wextra | |
10100 | @opindex Wno-extra | |
ddf6fe37 | 10101 | @item -Woverride-init @r{(C and Objective-C only)} |
d77de738 ML |
10102 | Warn if an initialized field without side effects is overridden when |
10103 | using designated initializers (@pxref{Designated Inits, , Designated | |
10104 | Initializers}). | |
10105 | ||
10106 | This warning is included in @option{-Wextra}. To get other | |
10107 | @option{-Wextra} warnings without this one, use @option{-Wextra | |
10108 | -Wno-override-init}. | |
10109 | ||
d77de738 ML |
10110 | @opindex Woverride-init-side-effects |
10111 | @opindex Wno-override-init-side-effects | |
ddf6fe37 | 10112 | @item -Wno-override-init-side-effects @r{(C and Objective-C only)} |
d77de738 ML |
10113 | Do not warn if an initialized field with side effects is overridden when |
10114 | using designated initializers (@pxref{Designated Inits, , Designated | |
10115 | Initializers}). This warning is enabled by default. | |
10116 | ||
d77de738 ML |
10117 | @opindex Wpacked |
10118 | @opindex Wno-packed | |
ddf6fe37 | 10119 | @item -Wpacked |
d77de738 ML |
10120 | Warn if a structure is given the packed attribute, but the packed |
10121 | attribute has no effect on the layout or size of the structure. | |
10122 | Such structures may be mis-aligned for little benefit. For | |
10123 | instance, in this code, the variable @code{f.x} in @code{struct bar} | |
10124 | is misaligned even though @code{struct bar} does not itself | |
10125 | have the packed attribute: | |
10126 | ||
10127 | @smallexample | |
10128 | @group | |
10129 | struct foo @{ | |
10130 | int x; | |
10131 | char a, b, c, d; | |
10132 | @} __attribute__((packed)); | |
10133 | struct bar @{ | |
10134 | char z; | |
10135 | struct foo f; | |
10136 | @}; | |
10137 | @end group | |
10138 | @end smallexample | |
10139 | ||
d77de738 ML |
10140 | @opindex Wpacked-bitfield-compat |
10141 | @opindex Wno-packed-bitfield-compat | |
ddf6fe37 | 10142 | @item -Wnopacked-bitfield-compat |
d77de738 ML |
10143 | The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute |
10144 | on bit-fields of type @code{char}. This was fixed in GCC 4.4 but | |
10145 | the change can lead to differences in the structure layout. GCC | |
10146 | informs you when the offset of such a field has changed in GCC 4.4. | |
10147 | For example there is no longer a 4-bit padding between field @code{a} | |
10148 | and @code{b} in this structure: | |
10149 | ||
10150 | @smallexample | |
10151 | struct foo | |
10152 | @{ | |
10153 | char a:4; | |
10154 | char b:8; | |
10155 | @} __attribute__ ((packed)); | |
10156 | @end smallexample | |
10157 | ||
10158 | This warning is enabled by default. Use | |
10159 | @option{-Wno-packed-bitfield-compat} to disable this warning. | |
10160 | ||
d77de738 ML |
10161 | @opindex Wpacked-not-aligned |
10162 | @opindex Wno-packed-not-aligned | |
ddf6fe37 | 10163 | @item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
10164 | Warn if a structure field with explicitly specified alignment in a |
10165 | packed struct or union is misaligned. For example, a warning will | |
10166 | be issued on @code{struct S}, like, @code{warning: alignment 1 of | |
10167 | 'struct S' is less than 8}, in this code: | |
10168 | ||
10169 | @smallexample | |
10170 | @group | |
10171 | struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @}; | |
10172 | struct __attribute__ ((packed)) S @{ | |
10173 | struct S8 s8; | |
10174 | @}; | |
10175 | @end group | |
10176 | @end smallexample | |
10177 | ||
10178 | This warning is enabled by @option{-Wall}. | |
10179 | ||
d77de738 ML |
10180 | @opindex Wpadded |
10181 | @opindex Wno-padded | |
ddf6fe37 | 10182 | @item -Wpadded |
d77de738 ML |
10183 | Warn if padding is included in a structure, either to align an element |
10184 | of the structure or to align the whole structure. Sometimes when this | |
10185 | happens it is possible to rearrange the fields of the structure to | |
10186 | reduce the padding and so make the structure smaller. | |
10187 | ||
d77de738 ML |
10188 | @opindex Wredundant-decls |
10189 | @opindex Wno-redundant-decls | |
ddf6fe37 | 10190 | @item -Wredundant-decls |
d77de738 ML |
10191 | Warn if anything is declared more than once in the same scope, even in |
10192 | cases where multiple declaration is valid and changes nothing. | |
10193 | ||
d77de738 ML |
10194 | @opindex Wrestrict |
10195 | @opindex Wno-restrict | |
ddf6fe37 | 10196 | @item -Wrestrict |
d77de738 ML |
10197 | Warn when an object referenced by a @code{restrict}-qualified parameter |
10198 | (or, in C++, a @code{__restrict}-qualified parameter) is aliased by another | |
10199 | argument, or when copies between such objects overlap. For example, | |
10200 | the call to the @code{strcpy} function below attempts to truncate the string | |
10201 | by replacing its initial characters with the last four. However, because | |
10202 | the call writes the terminating NUL into @code{a[4]}, the copies overlap and | |
10203 | the call is diagnosed. | |
10204 | ||
10205 | @smallexample | |
10206 | void foo (void) | |
10207 | @{ | |
10208 | char a[] = "abcd1234"; | |
10209 | strcpy (a, a + 4); | |
10210 | @dots{} | |
10211 | @} | |
10212 | @end smallexample | |
10213 | The @option{-Wrestrict} option detects some instances of simple overlap | |
10214 | even without optimization but works best at @option{-O2} and above. It | |
10215 | is included in @option{-Wall}. | |
10216 | ||
d77de738 ML |
10217 | @opindex Wnested-externs |
10218 | @opindex Wno-nested-externs | |
ddf6fe37 | 10219 | @item -Wnested-externs @r{(C and Objective-C only)} |
d77de738 ML |
10220 | Warn if an @code{extern} declaration is encountered within a function. |
10221 | ||
d77de738 ML |
10222 | @opindex Winline |
10223 | @opindex Wno-inline | |
ddf6fe37 | 10224 | @item -Winline |
d77de738 ML |
10225 | Warn if a function that is declared as inline cannot be inlined. |
10226 | Even with this option, the compiler does not warn about failures to | |
10227 | inline functions declared in system headers. | |
10228 | ||
10229 | The compiler uses a variety of heuristics to determine whether or not | |
10230 | to inline a function. For example, the compiler takes into account | |
10231 | the size of the function being inlined and the amount of inlining | |
10232 | that has already been done in the current function. Therefore, | |
10233 | seemingly insignificant changes in the source program can cause the | |
10234 | warnings produced by @option{-Winline} to appear or disappear. | |
10235 | ||
d77de738 | 10236 | @opindex Winterference-size |
ddf6fe37 | 10237 | @item -Winterference-size |
d77de738 ML |
10238 | Warn about use of C++17 @code{std::hardware_destructive_interference_size} |
10239 | without specifying its value with @option{--param destructive-interference-size}. | |
10240 | Also warn about questionable values for that option. | |
10241 | ||
10242 | This variable is intended to be used for controlling class layout, to | |
10243 | avoid false sharing in concurrent code: | |
10244 | ||
10245 | @smallexample | |
10246 | struct independent_fields @{ | |
4ace81b6 SL |
10247 | alignas(std::hardware_destructive_interference_size) |
10248 | std::atomic<int> one; | |
10249 | alignas(std::hardware_destructive_interference_size) | |
10250 | std::atomic<int> two; | |
d77de738 ML |
10251 | @}; |
10252 | @end smallexample | |
10253 | ||
10254 | Here @samp{one} and @samp{two} are intended to be far enough apart | |
10255 | that stores to one won't require accesses to the other to reload the | |
10256 | cache line. | |
10257 | ||
10258 | By default, @option{--param destructive-interference-size} and | |
10259 | @option{--param constructive-interference-size} are set based on the | |
10260 | current @option{-mtune} option, typically to the L1 cache line size | |
10261 | for the particular target CPU, sometimes to a range if tuning for a | |
10262 | generic target. So all translation units that depend on ABI | |
10263 | compatibility for the use of these variables must be compiled with | |
10264 | the same @option{-mtune} (or @option{-mcpu}). | |
10265 | ||
10266 | If ABI stability is important, such as if the use is in a header for a | |
10267 | library, you should probably not use the hardware interference size | |
10268 | variables at all. Alternatively, you can force a particular value | |
10269 | with @option{--param}. | |
10270 | ||
10271 | If you are confident that your use of the variable does not affect ABI | |
10272 | outside a single build of your project, you can turn off the warning | |
10273 | with @option{-Wno-interference-size}. | |
10274 | ||
d77de738 ML |
10275 | @opindex Wint-in-bool-context |
10276 | @opindex Wno-int-in-bool-context | |
ddf6fe37 | 10277 | @item -Wint-in-bool-context |
d77de738 ML |
10278 | Warn for suspicious use of integer values where boolean values are expected, |
10279 | such as conditional expressions (?:) using non-boolean integer constants in | |
10280 | boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed | |
10281 | integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise | |
10282 | for all kinds of multiplications regardless of the data type. | |
10283 | This warning is enabled by @option{-Wall}. | |
10284 | ||
d77de738 ML |
10285 | @opindex Wno-int-to-pointer-cast |
10286 | @opindex Wint-to-pointer-cast | |
ddf6fe37 | 10287 | @item -Wno-int-to-pointer-cast |
d77de738 ML |
10288 | Suppress warnings from casts to pointer type of an integer of a |
10289 | different size. In C++, casting to a pointer type of smaller size is | |
10290 | an error. @option{Wint-to-pointer-cast} is enabled by default. | |
10291 | ||
10292 | ||
d77de738 ML |
10293 | @opindex Wno-pointer-to-int-cast |
10294 | @opindex Wpointer-to-int-cast | |
ddf6fe37 | 10295 | @item -Wno-pointer-to-int-cast @r{(C and Objective-C only)} |
d77de738 ML |
10296 | Suppress warnings from casts from a pointer to an integer type of a |
10297 | different size. | |
10298 | ||
d77de738 ML |
10299 | @opindex Winvalid-pch |
10300 | @opindex Wno-invalid-pch | |
ddf6fe37 | 10301 | @item -Winvalid-pch |
d77de738 ML |
10302 | Warn if a precompiled header (@pxref{Precompiled Headers}) is found in |
10303 | the search path but cannot be used. | |
10304 | ||
d77de738 ML |
10305 | @opindex Winvalid-utf8 |
10306 | @opindex Wno-invalid-utf8 | |
ddf6fe37 | 10307 | @item -Winvalid-utf8 |
d77de738 ML |
10308 | Warn if an invalid UTF-8 character is found. |
10309 | This warning is on by default for C++23 if @option{-finput-charset=UTF-8} | |
10310 | is used and turned into error with @option{-pedantic-errors}. | |
10311 | ||
d77de738 ML |
10312 | @opindex Wunicode |
10313 | @opindex Wno-unicode | |
ddf6fe37 | 10314 | @item -Wno-unicode |
d77de738 ML |
10315 | Don't diagnose invalid forms of delimited or named escape sequences which are |
10316 | treated as separate tokens. @option{Wunicode} is enabled by default. | |
10317 | ||
d77de738 ML |
10318 | @opindex Wlong-long |
10319 | @opindex Wno-long-long | |
ddf6fe37 | 10320 | @item -Wlong-long |
d77de738 ML |
10321 | Warn if @code{long long} type is used. This is enabled by either |
10322 | @option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98 | |
10323 | modes. To inhibit the warning messages, use @option{-Wno-long-long}. | |
10324 | ||
5fccebdb JM |
10325 | This warning is upgraded to an error by @option{-pedantic-errors}. |
10326 | ||
d77de738 ML |
10327 | @opindex Wvariadic-macros |
10328 | @opindex Wno-variadic-macros | |
ddf6fe37 | 10329 | @item -Wvariadic-macros |
d77de738 ML |
10330 | Warn if variadic macros are used in ISO C90 mode, or if the GNU |
10331 | alternate syntax is used in ISO C99 mode. This is enabled by either | |
10332 | @option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning | |
10333 | messages, use @option{-Wno-variadic-macros}. | |
10334 | ||
d77de738 ML |
10335 | @opindex Wvarargs |
10336 | @opindex Wno-varargs | |
ddf6fe37 | 10337 | @item -Wno-varargs |
d77de738 ML |
10338 | Do not warn upon questionable usage of the macros used to handle variable |
10339 | arguments like @code{va_start}. These warnings are enabled by default. | |
10340 | ||
d77de738 ML |
10341 | @opindex Wvector-operation-performance |
10342 | @opindex Wno-vector-operation-performance | |
ddf6fe37 | 10343 | @item -Wvector-operation-performance |
d77de738 ML |
10344 | Warn if vector operation is not implemented via SIMD capabilities of the |
10345 | architecture. Mainly useful for the performance tuning. | |
10346 | Vector operation can be implemented @code{piecewise}, which means that the | |
10347 | scalar operation is performed on every vector element; | |
10348 | @code{in parallel}, which means that the vector operation is implemented | |
10349 | using scalars of wider type, which normally is more performance efficient; | |
10350 | and @code{as a single scalar}, which means that vector fits into a | |
10351 | scalar type. | |
10352 | ||
d77de738 ML |
10353 | @opindex Wvla |
10354 | @opindex Wno-vla | |
ddf6fe37 | 10355 | @item -Wvla |
d77de738 ML |
10356 | Warn if a variable-length array is used in the code. |
10357 | @option{-Wno-vla} prevents the @option{-Wpedantic} warning of | |
10358 | the variable-length array. | |
10359 | ||
5fccebdb JM |
10360 | This warning is upgraded to an error by @option{-pedantic-errors}. |
10361 | ||
d77de738 ML |
10362 | @opindex Wvla-larger-than= |
10363 | @opindex Wno-vla-larger-than | |
ddf6fe37 | 10364 | @item -Wvla-larger-than=@var{byte-size} |
d77de738 ML |
10365 | If this option is used, the compiler warns for declarations of |
10366 | variable-length arrays whose size is either unbounded, or bounded | |
10367 | by an argument that allows the array size to exceed @var{byte-size} | |
10368 | bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size} | |
10369 | works, but with variable-length arrays. | |
10370 | ||
10371 | Note that GCC may optimize small variable-length arrays of a known | |
10372 | value into plain arrays, so this warning may not get triggered for | |
10373 | such arrays. | |
10374 | ||
10375 | @option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but | |
10376 | is typically only effective when @option{-ftree-vrp} is active (default | |
10377 | for @option{-O2} and above). | |
10378 | ||
10379 | See also @option{-Walloca-larger-than=@var{byte-size}}. | |
10380 | ||
d77de738 | 10381 | @opindex Wno-vla-larger-than |
ddf6fe37 | 10382 | @item -Wno-vla-larger-than |
d77de738 ML |
10383 | Disable @option{-Wvla-larger-than=} warnings. The option is equivalent |
10384 | to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger. | |
10385 | ||
d77de738 | 10386 | @opindex Wno-vla-parameter |
ddf6fe37 | 10387 | @item -Wvla-parameter |
d77de738 ML |
10388 | Warn about redeclarations of functions involving arguments of Variable |
10389 | Length Array types of inconsistent kinds or forms, and enable the detection | |
10390 | of out-of-bounds accesses to such parameters by warnings such as | |
10391 | @option{-Warray-bounds}. | |
10392 | ||
10393 | If the first function declaration uses the VLA form the bound specified | |
10394 | in the array is assumed to be the minimum number of elements expected to | |
10395 | be provided in calls to the function and the maximum number of elements | |
10396 | accessed by it. Failing to provide arguments of sufficient size or | |
10397 | accessing more than the maximum number of elements may be diagnosed. | |
10398 | ||
10399 | For example, the warning triggers for the following redeclarations because | |
10400 | the first one allows an array of any size to be passed to @code{f} while | |
10401 | the second one specifies that the array argument must have at least @code{n} | |
10402 | elements. In addition, calling @code{f} with the associated VLA bound | |
10403 | parameter in excess of the actual VLA bound triggers a warning as well. | |
10404 | ||
10405 | @smallexample | |
10406 | void f (int n, int[n]); | |
4ace81b6 SL |
10407 | // warning: argument 2 previously declared as a VLA |
10408 | void f (int, int[]); | |
d77de738 ML |
10409 | |
10410 | void g (int n) | |
10411 | @{ | |
10412 | if (n > 4) | |
10413 | return; | |
10414 | int a[n]; | |
4ace81b6 SL |
10415 | // warning: access to a by f may be out of bounds |
10416 | f (sizeof a, a); | |
d77de738 ML |
10417 | @dots{} |
10418 | @} | |
10419 | ||
10420 | @end smallexample | |
10421 | ||
10422 | @option{-Wvla-parameter} is included in @option{-Wall}. The | |
10423 | @option{-Warray-parameter} option triggers warnings for similar problems | |
10424 | involving ordinary array arguments. | |
10425 | ||
d77de738 ML |
10426 | @opindex Wvolatile-register-var |
10427 | @opindex Wno-volatile-register-var | |
ddf6fe37 | 10428 | @item -Wvolatile-register-var |
d77de738 ML |
10429 | Warn if a register variable is declared volatile. The volatile |
10430 | modifier does not inhibit all optimizations that may eliminate reads | |
10431 | and/or writes to register variables. This warning is enabled by | |
10432 | @option{-Wall}. | |
10433 | ||
d77de738 ML |
10434 | @opindex Wxor-used-as-pow |
10435 | @opindex Wno-xor-used-as-pow | |
9a5e8f9d SL |
10436 | @item -Wno-xor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)} |
10437 | Disable warnings about uses of @code{^}, the exclusive or operator, | |
10438 | where it appears the code meant exponentiation. | |
10439 | Specifically, the warning occurs when the | |
d77de738 ML |
10440 | left-hand side is the decimal constant 2 or 10 and the right-hand side |
10441 | is also a decimal constant. | |
10442 | ||
10443 | In C and C++, @code{^} means exclusive or, whereas in some other languages | |
10444 | (e.g. TeX and some versions of BASIC) it means exponentiation. | |
10445 | ||
9a5e8f9d SL |
10446 | This warning can be silenced by converting one of the operands to |
10447 | hexadecimal as well as by compiling with @option{-Wno-xor-used-as-pow}. | |
d77de738 | 10448 | |
d77de738 ML |
10449 | @opindex Wdisabled-optimization |
10450 | @opindex Wno-disabled-optimization | |
ddf6fe37 | 10451 | @item -Wdisabled-optimization |
d77de738 ML |
10452 | Warn if a requested optimization pass is disabled. This warning does |
10453 | not generally indicate that there is anything wrong with your code; it | |
10454 | merely indicates that GCC's optimizers are unable to handle the code | |
10455 | effectively. Often, the problem is that your code is too big or too | |
10456 | complex; GCC refuses to optimize programs when the optimization | |
10457 | itself is likely to take inordinate amounts of time. | |
10458 | ||
d77de738 ML |
10459 | @opindex Wpointer-sign |
10460 | @opindex Wno-pointer-sign | |
ddf6fe37 | 10461 | @item -Wpointer-sign @r{(C and Objective-C only)} |
d77de738 ML |
10462 | Warn for pointer argument passing or assignment with different signedness. |
10463 | This option is only supported for C and Objective-C@. It is implied by | |
10464 | @option{-Wall} and by @option{-Wpedantic}, which can be disabled with | |
10465 | @option{-Wno-pointer-sign}. | |
10466 | ||
5fccebdb JM |
10467 | This warning is upgraded to an error by @option{-pedantic-errors}. |
10468 | ||
d77de738 ML |
10469 | @opindex Wstack-protector |
10470 | @opindex Wno-stack-protector | |
ddf6fe37 | 10471 | @item -Wstack-protector |
d77de738 ML |
10472 | This option is only active when @option{-fstack-protector} is active. It |
10473 | warns about functions that are not protected against stack smashing. | |
10474 | ||
d77de738 ML |
10475 | @opindex Woverlength-strings |
10476 | @opindex Wno-overlength-strings | |
ddf6fe37 | 10477 | @item -Woverlength-strings |
d77de738 ML |
10478 | Warn about string constants that are longer than the ``minimum |
10479 | maximum'' length specified in the C standard. Modern compilers | |
10480 | generally allow string constants that are much longer than the | |
10481 | standard's minimum limit, but very portable programs should avoid | |
10482 | using longer strings. | |
10483 | ||
10484 | The limit applies @emph{after} string constant concatenation, and does | |
10485 | not count the trailing NUL@. In C90, the limit was 509 characters; in | |
10486 | C99, it was raised to 4095. C++98 does not specify a normative | |
10487 | minimum maximum, so we do not diagnose overlength strings in C++@. | |
10488 | ||
10489 | This option is implied by @option{-Wpedantic}, and can be disabled with | |
10490 | @option{-Wno-overlength-strings}. | |
10491 | ||
d77de738 ML |
10492 | @opindex Wunsuffixed-float-constants |
10493 | @opindex Wno-unsuffixed-float-constants | |
ddf6fe37 | 10494 | @item -Wunsuffixed-float-constants @r{(C and Objective-C only)} |
d77de738 ML |
10495 | |
10496 | Issue a warning for any floating constant that does not have | |
10497 | a suffix. When used together with @option{-Wsystem-headers} it | |
10498 | warns about such constants in system header files. This can be useful | |
10499 | when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma | |
10500 | from the decimal floating-point extension to C99. | |
10501 | ||
d77de738 ML |
10502 | @opindex Wlto-type-mismatch |
10503 | @opindex Wno-lto-type-mismatch | |
ddf6fe37 | 10504 | @item -Wno-lto-type-mismatch |
d77de738 ML |
10505 | |
10506 | During the link-time optimization, do not warn about type mismatches in | |
10507 | global declarations from different compilation units. | |
10508 | Requires @option{-flto} to be enabled. Enabled by default. | |
10509 | ||
d77de738 ML |
10510 | @opindex Wdesignated-init |
10511 | @opindex Wno-designated-init | |
ddf6fe37 | 10512 | @item -Wno-designated-init @r{(C and Objective-C only)} |
d77de738 ML |
10513 | Suppress warnings when a positional initializer is used to initialize |
10514 | a structure that has been marked with the @code{designated_init} | |
10515 | attribute. | |
10516 | ||
10517 | @end table | |
10518 | ||
10519 | @node Static Analyzer Options | |
10520 | @section Options That Control Static Analysis | |
10521 | ||
10522 | @table @gcctabopt | |
d77de738 ML |
10523 | @opindex analyzer |
10524 | @opindex fanalyzer | |
10525 | @opindex fno-analyzer | |
ddf6fe37 | 10526 | @item -fanalyzer |
d77de738 ML |
10527 | This option enables an static analysis of program flow which looks |
10528 | for ``interesting'' interprocedural paths through the | |
10529 | code, and issues warnings for problems found on them. | |
10530 | ||
10531 | This analysis is much more expensive than other GCC warnings. | |
10532 | ||
a90316c6 DM |
10533 | In technical terms, it performs coverage-guided symbolic execution of |
10534 | the code being compiled. It is neither sound nor complete: it can | |
10535 | have false positives and false negatives. It is a bug-finding tool, | |
10536 | rather than a tool for proving program correctness. | |
10537 | ||
10538 | The analyzer is only suitable for use on C code in this release. | |
10539 | ||
d77de738 ML |
10540 | Enabling this option effectively enables the following warnings: |
10541 | ||
43b72ede AA |
10542 | @gccoptlist{ |
10543 | -Wanalyzer-allocation-size | |
10544 | -Wanalyzer-deref-before-check | |
10545 | -Wanalyzer-double-fclose | |
10546 | -Wanalyzer-double-free | |
10547 | -Wanalyzer-exposure-through-output-file | |
10548 | -Wanalyzer-exposure-through-uninit-copy | |
10549 | -Wanalyzer-fd-access-mode-mismatch | |
10550 | -Wanalyzer-fd-double-close | |
10551 | -Wanalyzer-fd-leak | |
10552 | -Wanalyzer-fd-phase-mismatch | |
10553 | -Wanalyzer-fd-type-mismatch | |
10554 | -Wanalyzer-fd-use-after-close | |
10555 | -Wanalyzer-fd-use-without-check | |
10556 | -Wanalyzer-file-leak | |
10557 | -Wanalyzer-free-of-non-heap | |
10558 | -Wanalyzer-imprecise-fp-arithmetic | |
841008d3 | 10559 | -Wanalyzer-infinite-loop |
43b72ede AA |
10560 | -Wanalyzer-infinite-recursion |
10561 | -Wanalyzer-jump-through-null | |
10562 | -Wanalyzer-malloc-leak | |
10563 | -Wanalyzer-mismatching-deallocation | |
10564 | -Wanalyzer-null-argument | |
10565 | -Wanalyzer-null-dereference | |
10566 | -Wanalyzer-out-of-bounds | |
034d99e8 | 10567 | -Wanalyzer-overlapping-buffers |
43b72ede AA |
10568 | -Wanalyzer-possible-null-argument |
10569 | -Wanalyzer-possible-null-dereference | |
10570 | -Wanalyzer-putenv-of-auto-var | |
10571 | -Wanalyzer-shift-count-negative | |
10572 | -Wanalyzer-shift-count-overflow | |
10573 | -Wanalyzer-stale-setjmp-buffer | |
cfaaa8b1 DM |
10574 | -Wanalyzer-tainted-allocation-size |
10575 | -Wanalyzer-tainted-array-index | |
10576 | -Wanalyzer-tainted-assertion | |
10577 | -Wanalyzer-tainted-divisor | |
10578 | -Wanalyzer-tainted-offset | |
10579 | -Wanalyzer-tainted-size | |
f65f63c4 | 10580 | -Wanalyzer-undefined-behavior-strtok |
43b72ede AA |
10581 | -Wanalyzer-unsafe-call-within-signal-handler |
10582 | -Wanalyzer-use-after-free | |
10583 | -Wanalyzer-use-of-pointer-in-stale-stack-frame | |
10584 | -Wanalyzer-use-of-uninitialized-value | |
10585 | -Wanalyzer-va-arg-type-mismatch | |
10586 | -Wanalyzer-va-list-exhausted | |
10587 | -Wanalyzer-va-list-leak | |
10588 | -Wanalyzer-va-list-use-after-va-end | |
10589 | -Wanalyzer-write-to-const | |
10590 | -Wanalyzer-write-to-string-literal | |
d77de738 | 10591 | } |
d77de738 ML |
10592 | |
10593 | This option is only available if GCC was configured with analyzer | |
10594 | support enabled. | |
10595 | ||
08b7462d DM |
10596 | @opindex Wanalyzer-symbol-too-complex |
10597 | @opindex Wno-analyzer-symbol-too-complex | |
10598 | @item -Wanalyzer-symbol-too-complex | |
10599 | If @option{-fanalyzer} is enabled, the analyzer uses various heuristics | |
10600 | to attempt to track the state of memory, but these can be defeated by | |
10601 | sufficiently complicated code. | |
10602 | ||
10603 | By default, the analysis silently stops tracking values of expressions | |
10604 | if they exceed the threshold defined by | |
10605 | @option{--param analyzer-max-svalue-depth=@var{value}}, and falls back | |
10606 | to an imprecise representation for such expressions. | |
10607 | The @option{-Wanalyzer-symbol-too-complex} option warns if this occurs. | |
10608 | ||
d77de738 ML |
10609 | @opindex Wanalyzer-too-complex |
10610 | @opindex Wno-analyzer-too-complex | |
ddf6fe37 | 10611 | @item -Wanalyzer-too-complex |
d77de738 ML |
10612 | If @option{-fanalyzer} is enabled, the analyzer uses various heuristics |
10613 | to attempt to explore the control flow and data flow in the program, | |
10614 | but these can be defeated by sufficiently complicated code. | |
10615 | ||
10616 | By default, the analysis silently stops if the code is too | |
10617 | complicated for the analyzer to fully explore and it reaches an internal | |
10618 | limit. The @option{-Wanalyzer-too-complex} option warns if this occurs. | |
10619 | ||
d77de738 ML |
10620 | @opindex Wanalyzer-allocation-size |
10621 | @opindex Wno-analyzer-allocation-size | |
ddf6fe37 | 10622 | @item -Wno-analyzer-allocation-size |
4ace81b6 SL |
10623 | This warning requires @option{-fanalyzer}, which enables it; |
10624 | to disable it, use @option{-Wno-analyzer-allocation-size}. | |
d77de738 ML |
10625 | |
10626 | This diagnostic warns for paths through the code in which a pointer to | |
10627 | a buffer is assigned to point at a buffer with a size that is not a | |
10628 | multiple of @code{sizeof (*pointer)}. | |
10629 | ||
10630 | See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}. | |
10631 | ||
ce51e843 ML |
10632 | @opindex Wanalyzer-deref-before-check |
10633 | @opindex Wno-analyzer-deref-before-check | |
ddf6fe37 | 10634 | @item -Wno-analyzer-deref-before-check |
ce51e843 ML |
10635 | This warning requires @option{-fanalyzer}, which enables it; use |
10636 | @option{-Wno-analyzer-deref-before-check} | |
10637 | to disable it. | |
10638 | ||
10639 | This diagnostic warns for paths through the code in which a pointer | |
10640 | is checked for @code{NULL} *after* it has already been | |
10641 | dereferenced, suggesting that the pointer could have been NULL. | |
10642 | Such cases suggest that the check for NULL is either redundant, | |
10643 | or that it needs to be moved to before the pointer is dereferenced. | |
10644 | ||
10645 | This diagnostic also considers values passed to a function argument | |
10646 | marked with @code{__attribute__((nonnull))} as requiring a non-NULL | |
10647 | value, and thus will complain if such values are checked for @code{NULL} | |
10648 | after returning from such a function call. | |
10649 | ||
10650 | This diagnostic is unlikely to be reported when any level of optimization | |
10651 | is enabled, as GCC's optimization logic will typically consider such | |
10652 | checks for NULL as being redundant, and optimize them away before the | |
10653 | analyzer "sees" them. Hence optimization should be disabled when | |
10654 | attempting to trigger this diagnostic. | |
10655 | ||
d77de738 ML |
10656 | @opindex Wanalyzer-double-fclose |
10657 | @opindex Wno-analyzer-double-fclose | |
ddf6fe37 | 10658 | @item -Wno-analyzer-double-fclose |
d77de738 ML |
10659 | This warning requires @option{-fanalyzer}, which enables it; use |
10660 | @option{-Wno-analyzer-double-fclose} to disable it. | |
10661 | ||
10662 | This diagnostic warns for paths through the code in which a @code{FILE *} | |
10663 | can have @code{fclose} called on it more than once. | |
10664 | ||
10665 | See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}. | |
10666 | ||
d77de738 ML |
10667 | @opindex Wanalyzer-double-free |
10668 | @opindex Wno-analyzer-double-free | |
ddf6fe37 | 10669 | @item -Wno-analyzer-double-free |
d77de738 ML |
10670 | This warning requires @option{-fanalyzer}, which enables it; use |
10671 | @option{-Wno-analyzer-double-free} to disable it. | |
10672 | ||
10673 | This diagnostic warns for paths through the code in which a pointer | |
10674 | can have a deallocator called on it more than once, either @code{free}, | |
10675 | or a deallocator referenced by attribute @code{malloc}. | |
10676 | ||
10677 | See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}. | |
10678 | ||
d77de738 ML |
10679 | @opindex Wanalyzer-exposure-through-output-file |
10680 | @opindex Wno-analyzer-exposure-through-output-file | |
ddf6fe37 | 10681 | @item -Wno-analyzer-exposure-through-output-file |
d77de738 ML |
10682 | This warning requires @option{-fanalyzer}, which enables it; use |
10683 | @option{-Wno-analyzer-exposure-through-output-file} | |
10684 | to disable it. | |
10685 | ||
10686 | This diagnostic warns for paths through the code in which a | |
10687 | security-sensitive value is written to an output file | |
10688 | (such as writing a password to a log file). | |
10689 | ||
10690 | See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}. | |
10691 | ||
d77de738 ML |
10692 | @opindex Wanalyzer-exposure-through-uninit-copy |
10693 | @opindex Wno-analyzer-exposure-through-uninit-copy | |
ddf6fe37 | 10694 | @item -Wanalyzer-exposure-through-uninit-copy |
d77de738 ML |
10695 | This warning requires both @option{-fanalyzer} and the use of a plugin |
10696 | to specify a function that copies across a ``trust boundary''. Use | |
10697 | @option{-Wno-analyzer-exposure-through-uninit-copy} to disable it. | |
10698 | ||
10699 | This diagnostic warns for ``infoleaks'' - paths through the code in which | |
10700 | uninitialized values are copied across a security boundary | |
10701 | (such as code within an OS kernel that copies a partially-initialized | |
10702 | struct on the stack to user space). | |
10703 | ||
10704 | See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}. | |
10705 | ||
d77de738 ML |
10706 | @opindex Wanalyzer-fd-access-mode-mismatch |
10707 | @opindex Wno-analyzer-fd-access-mode-mismatch | |
ddf6fe37 | 10708 | @item -Wno-analyzer-fd-access-mode-mismatch |
d77de738 ML |
10709 | This warning requires @option{-fanalyzer}, which enables it; use |
10710 | @option{-Wno-analyzer-fd-access-mode-mismatch} | |
10711 | to disable it. | |
10712 | ||
10713 | This diagnostic warns for paths through code in which a | |
10714 | @code{read} on a write-only file descriptor is attempted, or vice versa. | |
10715 | ||
10716 | This diagnostic also warns for code paths in a which a function with attribute | |
10717 | @code{fd_arg_read (N)} is called with a file descriptor opened with | |
10718 | @code{O_WRONLY} at referenced argument @code{N} or a function with attribute | |
10719 | @code{fd_arg_write (N)} is called with a file descriptor opened with | |
10720 | @code{O_RDONLY} at referenced argument @var{N}. | |
10721 | ||
d77de738 ML |
10722 | @opindex Wanalyzer-fd-double-close |
10723 | @opindex Wno-analyzer-fd-double-close | |
ddf6fe37 | 10724 | @item -Wno-analyzer-fd-double-close |
d77de738 ML |
10725 | This warning requires @option{-fanalyzer}, which enables it; use |
10726 | @option{-Wno-analyzer-fd-double-close} | |
10727 | to disable it. | |
10728 | ||
10729 | This diagnostic warns for paths through code in which a | |
10730 | file descriptor can be closed more than once. | |
10731 | ||
10732 | See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}. | |
10733 | ||
d77de738 ML |
10734 | @opindex Wanalyzer-fd-leak |
10735 | @opindex Wno-analyzer-fd-leak | |
ddf6fe37 | 10736 | @item -Wno-analyzer-fd-leak |
d77de738 ML |
10737 | This warning requires @option{-fanalyzer}, which enables it; use |
10738 | @option{-Wno-analyzer-fd-leak} | |
10739 | to disable it. | |
10740 | ||
10741 | This diagnostic warns for paths through code in which an | |
10742 | open file descriptor is leaked. | |
10743 | ||
10744 | See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}. | |
10745 | ||
86a90006 DM |
10746 | @opindex Wanalyzer-fd-phase-mismatch |
10747 | @opindex Wno-analyzer-fd-phase-mismatch | |
ddf6fe37 | 10748 | @item -Wno-analyzer-fd-phase-mismatch |
86a90006 DM |
10749 | This warning requires @option{-fanalyzer}, which enables it; use |
10750 | @option{-Wno-analyzer-fd-phase-mismatch} | |
10751 | to disable it. | |
10752 | ||
10753 | This diagnostic warns for paths through code in which an operation is | |
10754 | attempted in the wrong phase of a file descriptor's lifetime. | |
10755 | For example, it will warn on attempts to call @code{accept} on a stream | |
10756 | socket that has not yet had @code{listen} successfully called on it. | |
10757 | ||
10758 | See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}. | |
10759 | ||
86a90006 DM |
10760 | @opindex Wanalyzer-fd-type-mismatch |
10761 | @opindex Wno-analyzer-fd-type-mismatch | |
ddf6fe37 | 10762 | @item -Wno-analyzer-fd-type-mismatch |
86a90006 DM |
10763 | This warning requires @option{-fanalyzer}, which enables it; use |
10764 | @option{-Wno-analyzer-fd-type-mismatch} | |
10765 | to disable it. | |
10766 | ||
10767 | This diagnostic warns for paths through code in which an | |
10768 | operation is attempted on the wrong type of file descriptor. | |
10769 | For example, it will warn on attempts to use socket operations | |
10770 | on a file descriptor obtained via @code{open}, or when attempting | |
10771 | to use a stream socket operation on a datagram socket. | |
10772 | ||
d77de738 ML |
10773 | @opindex Wanalyzer-fd-use-after-close |
10774 | @opindex Wno-analyzer-fd-use-after-close | |
ddf6fe37 | 10775 | @item -Wno-analyzer-fd-use-after-close |
d77de738 ML |
10776 | This warning requires @option{-fanalyzer}, which enables it; use |
10777 | @option{-Wno-analyzer-fd-use-after-close} | |
10778 | to disable it. | |
10779 | ||
10780 | This diagnostic warns for paths through code in which a | |
10781 | read or write is called on a closed file descriptor. | |
10782 | ||
10783 | This diagnostic also warns for paths through code in which | |
10784 | a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)} | |
10785 | or @code{fd_arg_write (N)} is called with a closed file descriptor at | |
10786 | referenced argument @code{N}. | |
10787 | ||
d77de738 ML |
10788 | @opindex Wanalyzer-fd-use-without-check |
10789 | @opindex Wno-analyzer-fd-use-without-check | |
ddf6fe37 | 10790 | @item -Wno-analyzer-fd-use-without-check |
d77de738 ML |
10791 | This warning requires @option{-fanalyzer}, which enables it; use |
10792 | @option{-Wno-analyzer-fd-use-without-check} | |
10793 | to disable it. | |
10794 | ||
10795 | This diagnostic warns for paths through code in which a | |
10796 | file descriptor is used without being checked for validity. | |
10797 | ||
10798 | This diagnostic also warns for paths through code in which | |
10799 | a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)} | |
10800 | or @code{fd_arg_write (N)} is called with a file descriptor, at referenced | |
10801 | argument @code{N}, without being checked for validity. | |
10802 | ||
d77de738 ML |
10803 | @opindex Wanalyzer-file-leak |
10804 | @opindex Wno-analyzer-file-leak | |
ddf6fe37 | 10805 | @item -Wno-analyzer-file-leak |
d77de738 ML |
10806 | This warning requires @option{-fanalyzer}, which enables it; use |
10807 | @option{-Wno-analyzer-file-leak} | |
10808 | to disable it. | |
10809 | ||
10810 | This diagnostic warns for paths through the code in which a | |
10811 | @code{<stdio.h>} @code{FILE *} stream object is leaked. | |
10812 | ||
10813 | See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}. | |
10814 | ||
d77de738 ML |
10815 | @opindex Wanalyzer-free-of-non-heap |
10816 | @opindex Wno-analyzer-free-of-non-heap | |
ddf6fe37 | 10817 | @item -Wno-analyzer-free-of-non-heap |
d77de738 ML |
10818 | This warning requires @option{-fanalyzer}, which enables it; use |
10819 | @option{-Wno-analyzer-free-of-non-heap} | |
10820 | to disable it. | |
10821 | ||
10822 | This diagnostic warns for paths through the code in which @code{free} | |
10823 | is called on a non-heap pointer (e.g. an on-stack buffer, or a global). | |
10824 | ||
10825 | See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}. | |
10826 | ||
d77de738 ML |
10827 | @opindex Wanalyzer-imprecise-fp-arithmetic |
10828 | @opindex Wno-analyzer-imprecise-fp-arithmetic | |
ddf6fe37 | 10829 | @item -Wno-analyzer-imprecise-fp-arithmetic |
d77de738 ML |
10830 | This warning requires @option{-fanalyzer}, which enables it; use |
10831 | @option{-Wno-analyzer-imprecise-fp-arithmetic} | |
10832 | to disable it. | |
10833 | ||
10834 | This diagnostic warns for paths through the code in which floating-point | |
10835 | arithmetic is used in locations where precise computation is needed. This | |
10836 | diagnostic only warns on use of floating-point operands inside the | |
10837 | calculation of an allocation size at the moment. | |
10838 | ||
841008d3 DM |
10839 | @opindex Wanalyzer-infinite-loop |
10840 | @opindex Wno-analyzer-infinite-loop | |
10841 | @item -Wno-analyzer-infinite-loop | |
10842 | This warning requires @option{-fanalyzer}, which enables it; use | |
10843 | @option{-Wno-analyzer-infinite-loop} to disable it. | |
10844 | ||
10845 | This diagnostics warns for paths through the code which appear to | |
10846 | lead to an infinite loop. | |
10847 | ||
10848 | Specifically, the analyzer will issue this warning when it "sees" a loop | |
10849 | in which: | |
10850 | @itemize @bullet | |
10851 | @item | |
10852 | no externally-visible work could be being done within the loop | |
10853 | @item | |
10854 | there is no way to escape from the loop | |
10855 | @item | |
10856 | the analyzer is sufficiently confident about the program state | |
10857 | throughout the loop to know that the above are true | |
10858 | @end itemize | |
10859 | ||
10860 | One way for this warning to be emitted is when there is an execution | |
10861 | path through a loop for which taking the path on one iteration implies | |
10862 | that the same path will be taken on all subsequent iterations. | |
10863 | ||
10864 | For example, consider: | |
10865 | ||
10866 | @smallexample | |
10867 | while (1) | |
10868 | @{ | |
10869 | char opcode = *cpu_state.pc; | |
10870 | switch (opcode) | |
10871 | @{ | |
10872 | case OPCODE_FOO: | |
10873 | handle_opcode_foo (&cpu_state); | |
10874 | break; | |
10875 | case OPCODE_BAR: | |
10876 | handle_opcode_bar (&cpu_state); | |
10877 | break; | |
10878 | @} | |
10879 | @} | |
10880 | @end smallexample | |
10881 | ||
10882 | The analyzer will complain for the above case because if @code{opcode} | |
10883 | ever matches none of the cases, the @code{switch} will follow the | |
10884 | implicit @code{default} case, making the body of the loop be a ``no-op'' | |
10885 | with @code{cpu_state.pc} unchanged, and thus using the same value of | |
10886 | @code{opcode} on all subseqent iterations, leading to an infinite loop. | |
10887 | ||
10888 | See @uref{https://cwe.mitre.org/data/definitions/835.html, CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')}. | |
10889 | ||
ce51e843 ML |
10890 | @opindex Wanalyzer-infinite-recursion |
10891 | @opindex Wno-analyzer-infinite-recursion | |
ddf6fe37 | 10892 | @item -Wno-analyzer-infinite-recursion |
ce51e843 ML |
10893 | This warning requires @option{-fanalyzer}, which enables it; use |
10894 | @option{-Wno-analyzer-infinite-recursion} to disable it. | |
10895 | ||
10896 | This diagnostics warns for paths through the code which appear to | |
10897 | lead to infinite recursion. | |
10898 | ||
10899 | Specifically, when the analyzer "sees" a recursive call, it will compare | |
10900 | the state of memory at the entry to the new frame with that at the entry | |
10901 | to the previous frame of that function on the stack. The warning is | |
10902 | issued if nothing in memory appears to be changing; any changes observed | |
10903 | to parameters or globals are assumed to lead to termination of the | |
10904 | recursion and thus suppress the warning. | |
10905 | ||
10906 | This diagnostic is likely to miss cases of infinite recursion that | |
10907 | are convered to iteration by the optimizer before the analyzer "sees" | |
10908 | them. Hence optimization should be disabled when attempting to trigger | |
10909 | this diagnostic. | |
10910 | ||
10911 | Compare with @option{-Winfinite-recursion}, which provides a similar | |
10912 | diagnostic, but is implemented in a different way. | |
10913 | ||
841008d3 DM |
10914 | See @uref{https://cwe.mitre.org/data/definitions/674.html, CWE-674: Uncontrolled Recursion}. |
10915 | ||
d77de738 ML |
10916 | @opindex Wanalyzer-jump-through-null |
10917 | @opindex Wno-analyzer-jump-through-null | |
ddf6fe37 | 10918 | @item -Wno-analyzer-jump-through-null |
d77de738 ML |
10919 | This warning requires @option{-fanalyzer}, which enables it; use |
10920 | @option{-Wno-analyzer-jump-through-null} | |
10921 | to disable it. | |
10922 | ||
10923 | This diagnostic warns for paths through the code in which a @code{NULL} | |
10924 | function pointer is called. | |
10925 | ||
d77de738 ML |
10926 | @opindex Wanalyzer-malloc-leak |
10927 | @opindex Wno-analyzer-malloc-leak | |
ddf6fe37 | 10928 | @item -Wno-analyzer-malloc-leak |
d77de738 ML |
10929 | This warning requires @option{-fanalyzer}, which enables it; use |
10930 | @option{-Wno-analyzer-malloc-leak} | |
10931 | to disable it. | |
10932 | ||
10933 | This diagnostic warns for paths through the code in which a | |
10934 | pointer allocated via an allocator is leaked: either @code{malloc}, | |
10935 | or a function marked with attribute @code{malloc}. | |
10936 | ||
10937 | See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}. | |
10938 | ||
d77de738 ML |
10939 | @opindex Wanalyzer-mismatching-deallocation |
10940 | @opindex Wno-analyzer-mismatching-deallocation | |
ddf6fe37 | 10941 | @item -Wno-analyzer-mismatching-deallocation |
d77de738 ML |
10942 | This warning requires @option{-fanalyzer}, which enables it; use |
10943 | @option{-Wno-analyzer-mismatching-deallocation} | |
10944 | to disable it. | |
10945 | ||
10946 | This diagnostic warns for paths through the code in which the | |
10947 | wrong deallocation function is called on a pointer value, based on | |
10948 | which function was used to allocate the pointer value. The diagnostic | |
10949 | will warn about mismatches between @code{free}, scalar @code{delete} | |
10950 | and vector @code{delete[]}, and those marked as allocator/deallocator | |
10951 | pairs using attribute @code{malloc}. | |
10952 | ||
10953 | See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}. | |
10954 | ||
d77de738 ML |
10955 | @opindex Wanalyzer-out-of-bounds |
10956 | @opindex Wno-analyzer-out-of-bounds | |
ddf6fe37 | 10957 | @item -Wno-analyzer-out-of-bounds |
4ace81b6 | 10958 | This warning requires @option{-fanalyzer}, which enables it; use |
d77de738 ML |
10959 | @option{-Wno-analyzer-out-of-bounds} to disable it. |
10960 | ||
4ace81b6 | 10961 | This diagnostic warns for paths through the code in which a buffer is |
d77de738 ML |
10962 | definitely read or written out-of-bounds. The diagnostic applies for |
10963 | cases where the analyzer is able to determine a constant offset and for | |
10964 | accesses past the end of a buffer, also a constant capacity. Further, | |
10965 | the diagnostic does limited checking for accesses past the end when the | |
10966 | offset as well as the capacity is symbolic. | |
10967 | ||
10968 | See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}. | |
10969 | ||
0e466e97 DM |
10970 | For cases where the analyzer is able, it will emit a text art diagram |
10971 | visualizing the spatial relationship between the memory region that the | |
10972 | analyzer predicts would be accessed, versus the range of memory that is | |
10973 | valid to access: whether they overlap, are touching, are close or far | |
10974 | apart; which one is before or after in memory, the relative sizes | |
10975 | involved, the direction of the access (read vs write), and, in some | |
10976 | cases, the values of data involved. This diagram can be suppressed | |
10977 | using @option{-fdiagnostics-text-art-charset=none}. | |
10978 | ||
034d99e8 DM |
10979 | @opindex Wanalyzer-overlapping-buffers |
10980 | @opindex Wno-analyzer-overlapping-buffers | |
10981 | @item -Wno-analyzer-overlapping-buffers | |
10982 | This warning requires @option{-fanalyzer}, which enables it; use | |
10983 | @option{-Wno-analyzer-overlapping-buffers} to disable it. | |
10984 | ||
10985 | This diagnostic warns for paths through the code in which overlapping | |
10986 | buffers are passed to an API for which the behavior on such buffers | |
10987 | is undefined. | |
10988 | ||
10989 | Specifically, the diagnostic occurs on calls to the following functions | |
10990 | @itemize @bullet | |
10991 | @item @code{memcpy} | |
10992 | @item @code{strcat} | |
10993 | @item @code{strcpy} | |
10994 | @end itemize | |
10995 | for cases where the buffers are known to overlap. | |
10996 | ||
d77de738 ML |
10997 | @opindex Wanalyzer-possible-null-argument |
10998 | @opindex Wno-analyzer-possible-null-argument | |
ddf6fe37 | 10999 | @item -Wno-analyzer-possible-null-argument |
d77de738 ML |
11000 | This warning requires @option{-fanalyzer}, which enables it; use |
11001 | @option{-Wno-analyzer-possible-null-argument} to disable it. | |
11002 | ||
11003 | This diagnostic warns for paths through the code in which a | |
11004 | possibly-NULL value is passed to a function argument marked | |
11005 | with @code{__attribute__((nonnull))} as requiring a non-NULL | |
11006 | value. | |
11007 | ||
11008 | See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}. | |
11009 | ||
d77de738 ML |
11010 | @opindex Wanalyzer-possible-null-dereference |
11011 | @opindex Wno-analyzer-possible-null-dereference | |
ddf6fe37 | 11012 | @item -Wno-analyzer-possible-null-dereference |
d77de738 ML |
11013 | This warning requires @option{-fanalyzer}, which enables it; use |
11014 | @option{-Wno-analyzer-possible-null-dereference} to disable it. | |
11015 | ||
11016 | This diagnostic warns for paths through the code in which a | |
11017 | possibly-NULL value is dereferenced. | |
11018 | ||
11019 | See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}. | |
11020 | ||
d77de738 ML |
11021 | @opindex Wanalyzer-null-argument |
11022 | @opindex Wno-analyzer-null-argument | |
ddf6fe37 | 11023 | @item -Wno-analyzer-null-argument |
d77de738 ML |
11024 | This warning requires @option{-fanalyzer}, which enables it; use |
11025 | @option{-Wno-analyzer-null-argument} to disable it. | |
11026 | ||
11027 | This diagnostic warns for paths through the code in which a | |
11028 | value known to be NULL is passed to a function argument marked | |
11029 | with @code{__attribute__((nonnull))} as requiring a non-NULL | |
11030 | value. | |
11031 | ||
11032 | See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}. | |
11033 | ||
d77de738 ML |
11034 | @opindex Wanalyzer-null-dereference |
11035 | @opindex Wno-analyzer-null-dereference | |
ddf6fe37 | 11036 | @item -Wno-analyzer-null-dereference |
d77de738 ML |
11037 | This warning requires @option{-fanalyzer}, which enables it; use |
11038 | @option{-Wno-analyzer-null-dereference} to disable it. | |
11039 | ||
11040 | This diagnostic warns for paths through the code in which a | |
11041 | value known to be NULL is dereferenced. | |
11042 | ||
11043 | See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}. | |
11044 | ||
d77de738 ML |
11045 | @opindex Wanalyzer-putenv-of-auto-var |
11046 | @opindex Wno-analyzer-putenv-of-auto-var | |
ddf6fe37 | 11047 | @item -Wno-analyzer-putenv-of-auto-var |
d77de738 ML |
11048 | This warning requires @option{-fanalyzer}, which enables it; use |
11049 | @option{-Wno-analyzer-putenv-of-auto-var} to disable it. | |
11050 | ||
11051 | This diagnostic warns for paths through the code in which a | |
11052 | call to @code{putenv} is passed a pointer to an automatic variable | |
11053 | or an on-stack buffer. | |
11054 | ||
11055 | See @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}. | |
11056 | ||
d77de738 ML |
11057 | @opindex Wanalyzer-shift-count-negative |
11058 | @opindex Wno-analyzer-shift-count-negative | |
ddf6fe37 | 11059 | @item -Wno-analyzer-shift-count-negative |
d77de738 ML |
11060 | This warning requires @option{-fanalyzer}, which enables it; use |
11061 | @option{-Wno-analyzer-shift-count-negative} to disable it. | |
11062 | ||
11063 | This diagnostic warns for paths through the code in which a | |
11064 | shift is attempted with a negative count. It is analogous to | |
11065 | the @option{-Wshift-count-negative} diagnostic implemented in | |
11066 | the C/C++ front ends, but is implemented based on analyzing | |
11067 | interprocedural paths, rather than merely parsing the syntax tree. | |
11068 | However, the analyzer does not prioritize detection of such paths, so | |
11069 | false negatives are more likely relative to other warnings. | |
11070 | ||
d77de738 ML |
11071 | @opindex Wanalyzer-shift-count-overflow |
11072 | @opindex Wno-analyzer-shift-count-overflow | |
ddf6fe37 | 11073 | @item -Wno-analyzer-shift-count-overflow |
d77de738 ML |
11074 | This warning requires @option{-fanalyzer}, which enables it; use |
11075 | @option{-Wno-analyzer-shift-count-overflow} to disable it. | |
11076 | ||
11077 | This diagnostic warns for paths through the code in which a | |
11078 | shift is attempted with a count greater than or equal to the | |
11079 | precision of the operand's type. It is analogous to | |
11080 | the @option{-Wshift-count-overflow} diagnostic implemented in | |
11081 | the C/C++ front ends, but is implemented based on analyzing | |
11082 | interprocedural paths, rather than merely parsing the syntax tree. | |
11083 | However, the analyzer does not prioritize detection of such paths, so | |
11084 | false negatives are more likely relative to other warnings. | |
11085 | ||
d77de738 ML |
11086 | @opindex Wanalyzer-stale-setjmp-buffer |
11087 | @opindex Wno-analyzer-stale-setjmp-buffer | |
ddf6fe37 | 11088 | @item -Wno-analyzer-stale-setjmp-buffer |
d77de738 ML |
11089 | This warning requires @option{-fanalyzer}, which enables it; use |
11090 | @option{-Wno-analyzer-stale-setjmp-buffer} to disable it. | |
11091 | ||
11092 | This diagnostic warns for paths through the code in which | |
11093 | @code{longjmp} is called to rewind to a @code{jmp_buf} relating | |
11094 | to a @code{setjmp} call in a function that has returned. | |
11095 | ||
11096 | When @code{setjmp} is called on a @code{jmp_buf} to record a rewind | |
11097 | location, it records the stack frame. The stack frame becomes invalid | |
11098 | when the function containing the @code{setjmp} call returns. Attempting | |
11099 | to rewind to it via @code{longjmp} would reference a stack frame that | |
11100 | no longer exists, and likely lead to a crash (or worse). | |
11101 | ||
d77de738 ML |
11102 | @opindex Wanalyzer-tainted-allocation-size |
11103 | @opindex Wno-analyzer-tainted-allocation-size | |
ddf6fe37 | 11104 | @item -Wno-analyzer-tainted-allocation-size |
cfaaa8b1 | 11105 | This warning requires @option{-fanalyzer} which enables it; |
d77de738 ML |
11106 | use @option{-Wno-analyzer-tainted-allocation-size} to disable it. |
11107 | ||
11108 | This diagnostic warns for paths through the code in which a value | |
11109 | that could be under an attacker's control is used as the size | |
11110 | of an allocation without being sanitized, so that an attacker could | |
11111 | inject an excessively large allocation and potentially cause a denial | |
11112 | of service attack. | |
11113 | ||
11114 | See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}. | |
11115 | ||
ce51e843 ML |
11116 | @opindex Wanalyzer-tainted-assertion |
11117 | @opindex Wno-analyzer-tainted-assertion | |
ddf6fe37 | 11118 | @item -Wno-analyzer-tainted-assertion |
ce51e843 | 11119 | |
cfaaa8b1 | 11120 | This warning requires @option{-fanalyzer} which enables it; |
ce51e843 ML |
11121 | use @option{-Wno-analyzer-tainted-assertion} to disable it. |
11122 | ||
11123 | This diagnostic warns for paths through the code in which a value | |
11124 | that could be under an attacker's control is used as part of a | |
11125 | condition without being first sanitized, and that condition guards a | |
11126 | call to a function marked with attribute @code{noreturn} | |
11127 | (such as the function @code{__builtin_unreachable}). Such functions | |
11128 | typically indicate abnormal termination of the program, such as for | |
11129 | assertion failure handlers. For example: | |
11130 | ||
11131 | @smallexample | |
11132 | assert (some_tainted_value < SOME_LIMIT); | |
11133 | @end smallexample | |
11134 | ||
11135 | In such cases: | |
11136 | ||
11137 | @itemize | |
11138 | @item | |
11139 | when assertion-checking is enabled: an attacker could trigger | |
11140 | a denial of service by injecting an assertion failure | |
11141 | ||
11142 | @item | |
11143 | when assertion-checking is disabled, such as by defining @code{NDEBUG}, | |
11144 | an attacker could inject data that subverts the process, since it | |
11145 | presumably violates a precondition that is being assumed by the code. | |
11146 | ||
11147 | @end itemize | |
11148 | ||
11149 | Note that when assertion-checking is disabled, the assertions are | |
11150 | typically removed by the preprocessor before the analyzer has a chance | |
11151 | to "see" them, so this diagnostic can only generate warnings on builds | |
11152 | in which assertion-checking is enabled. | |
11153 | ||
11154 | For the purpose of this warning, any function marked with attribute | |
11155 | @code{noreturn} is considered as a possible assertion failure | |
11156 | handler, including @code{__builtin_unreachable}. Note that these functions | |
11157 | are sometimes removed by the optimizer before the analyzer "sees" them. | |
11158 | Hence optimization should be disabled when attempting to trigger this | |
11159 | diagnostic. | |
11160 | ||
11161 | See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}. | |
11162 | ||
11163 | The warning can also report problematic constructions such as | |
11164 | ||
11165 | @smallexample | |
11166 | switch (some_tainted_value) @{ | |
11167 | case 0: | |
11168 | /* [...etc; various valid cases omitted...] */ | |
11169 | break; | |
11170 | ||
11171 | default: | |
11172 | __builtin_unreachable (); /* BUG: attacker can trigger this */ | |
11173 | @} | |
11174 | @end smallexample | |
11175 | ||
11176 | despite the above not being an assertion failure, strictly speaking. | |
11177 | ||
d77de738 ML |
11178 | @opindex Wanalyzer-tainted-array-index |
11179 | @opindex Wno-analyzer-tainted-array-index | |
ddf6fe37 | 11180 | @item -Wno-analyzer-tainted-array-index |
cfaaa8b1 | 11181 | This warning requires @option{-fanalyzer} which enables it; |
d77de738 ML |
11182 | use @option{-Wno-analyzer-tainted-array-index} to disable it. |
11183 | ||
11184 | This diagnostic warns for paths through the code in which a value | |
11185 | that could be under an attacker's control is used as the index | |
11186 | of an array access without being sanitized, so that an attacker | |
11187 | could inject an out-of-bounds access. | |
11188 | ||
11189 | See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. | |
11190 | ||
d77de738 ML |
11191 | @opindex Wanalyzer-tainted-divisor |
11192 | @opindex Wno-analyzer-tainted-divisor | |
ddf6fe37 | 11193 | @item -Wno-analyzer-tainted-divisor |
cfaaa8b1 | 11194 | This warning requires @option{-fanalyzer} which enables it; |
d77de738 ML |
11195 | use @option{-Wno-analyzer-tainted-divisor} to disable it. |
11196 | ||
11197 | This diagnostic warns for paths through the code in which a value | |
11198 | that could be under an attacker's control is used as the divisor | |
11199 | in a division or modulus operation without being sanitized, so that | |
11200 | an attacker could inject a division-by-zero. | |
11201 | ||
11202 | See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}. | |
11203 | ||
d77de738 ML |
11204 | @opindex Wanalyzer-tainted-offset |
11205 | @opindex Wno-analyzer-tainted-offset | |
ddf6fe37 | 11206 | @item -Wno-analyzer-tainted-offset |
cfaaa8b1 | 11207 | This warning requires @option{-fanalyzer} which enables it; |
d77de738 ML |
11208 | use @option{-Wno-analyzer-tainted-offset} to disable it. |
11209 | ||
11210 | This diagnostic warns for paths through the code in which a value | |
11211 | that could be under an attacker's control is used as a pointer offset | |
11212 | without being sanitized, so that an attacker could inject an out-of-bounds | |
11213 | access. | |
11214 | ||
11215 | See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}. | |
11216 | ||
d77de738 ML |
11217 | @opindex Wanalyzer-tainted-size |
11218 | @opindex Wno-analyzer-tainted-size | |
ddf6fe37 | 11219 | @item -Wno-analyzer-tainted-size |
cfaaa8b1 | 11220 | This warning requires @option{-fanalyzer} which enables it; |
d77de738 ML |
11221 | use @option{-Wno-analyzer-tainted-size} to disable it. |
11222 | ||
11223 | This diagnostic warns for paths through the code in which a value | |
11224 | that could be under an attacker's control is used as the size of | |
11225 | an operation such as @code{memset} without being sanitized, so that an | |
11226 | attacker could inject an out-of-bounds access. | |
11227 | ||
11228 | See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. | |
11229 | ||
f65f63c4 DM |
11230 | @opindex Wanalyzer-undefined-behavior-strtok |
11231 | @opindex Wno-analyzer-undefined-behavior-strtok | |
11232 | @item -Wno-analyzer-undefined-behavior-strtok | |
11233 | This warning requires @option{-fanalyzer}, which enables it; use | |
11234 | @option{-Wno-analyzer-undefined-behavior-strtok} to disable it. | |
11235 | ||
11236 | This diagnostic warns for paths through the code in which a | |
11237 | call is made to @code{strtok} with undefined behavior. | |
11238 | ||
11239 | Specifically, passing NULL as the first parameter for the initial | |
11240 | call to @code{strtok} within a process has undefined behavior. | |
11241 | ||
d77de738 ML |
11242 | @opindex Wanalyzer-unsafe-call-within-signal-handler |
11243 | @opindex Wno-analyzer-unsafe-call-within-signal-handler | |
ddf6fe37 | 11244 | @item -Wno-analyzer-unsafe-call-within-signal-handler |
d77de738 ML |
11245 | This warning requires @option{-fanalyzer}, which enables it; use |
11246 | @option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it. | |
11247 | ||
11248 | This diagnostic warns for paths through the code in which a | |
11249 | function known to be async-signal-unsafe (such as @code{fprintf}) is | |
11250 | called from a signal handler. | |
11251 | ||
11252 | See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}. | |
11253 | ||
d77de738 ML |
11254 | @opindex Wanalyzer-use-after-free |
11255 | @opindex Wno-analyzer-use-after-free | |
ddf6fe37 | 11256 | @item -Wno-analyzer-use-after-free |
d77de738 ML |
11257 | This warning requires @option{-fanalyzer}, which enables it; use |
11258 | @option{-Wno-analyzer-use-after-free} to disable it. | |
11259 | ||
11260 | This diagnostic warns for paths through the code in which a | |
11261 | pointer is used after a deallocator is called on it: either @code{free}, | |
11262 | or a deallocator referenced by attribute @code{malloc}. | |
11263 | ||
11264 | See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}. | |
11265 | ||
d77de738 ML |
11266 | @opindex Wanalyzer-use-of-pointer-in-stale-stack-frame |
11267 | @opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame | |
ddf6fe37 | 11268 | @item -Wno-analyzer-use-of-pointer-in-stale-stack-frame |
d77de738 ML |
11269 | This warning requires @option{-fanalyzer}, which enables it; use |
11270 | @option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame} | |
11271 | to disable it. | |
11272 | ||
11273 | This diagnostic warns for paths through the code in which a pointer | |
11274 | is dereferenced that points to a variable in a stale stack frame. | |
11275 | ||
d77de738 ML |
11276 | @opindex Wanalyzer-va-arg-type-mismatch |
11277 | @opindex Wno-analyzer-va-arg-type-mismatch | |
ddf6fe37 | 11278 | @item -Wno-analyzer-va-arg-type-mismatch |
d77de738 ML |
11279 | This warning requires @option{-fanalyzer}, which enables it; use |
11280 | @option{-Wno-analyzer-va-arg-type-mismatch} | |
11281 | to disable it. | |
11282 | ||
11283 | This diagnostic warns for interprocedural paths through the code for which | |
11284 | the analyzer detects an attempt to use @code{va_arg} to extract a value | |
11285 | passed to a variadic call, but uses a type that does not match that of | |
11286 | the expression passed to the call. | |
11287 | ||
11288 | See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}. | |
11289 | ||
d77de738 ML |
11290 | @opindex Wanalyzer-va-list-exhausted |
11291 | @opindex Wno-analyzer-va-list-exhausted | |
ddf6fe37 | 11292 | @item -Wno-analyzer-va-list-exhausted |
d77de738 ML |
11293 | This warning requires @option{-fanalyzer}, which enables it; use |
11294 | @option{-Wno-analyzer-va-list-exhausted} | |
11295 | to disable it. | |
11296 | ||
11297 | This diagnostic warns for interprocedural paths through the code for which | |
11298 | the analyzer detects an attempt to use @code{va_arg} to access the next | |
11299 | value passed to a variadic call, but all of the values in the | |
11300 | @code{va_list} have already been consumed. | |
11301 | ||
11302 | See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}. | |
11303 | ||
d77de738 ML |
11304 | @opindex Wanalyzer-va-list-leak |
11305 | @opindex Wno-analyzer-va-list-leak | |
ddf6fe37 | 11306 | @item -Wno-analyzer-va-list-leak |
d77de738 ML |
11307 | This warning requires @option{-fanalyzer}, which enables it; use |
11308 | @option{-Wno-analyzer-va-list-leak} | |
11309 | to disable it. | |
11310 | ||
11311 | This diagnostic warns for interprocedural paths through the code for which | |
11312 | the analyzer detects that @code{va_start} or @code{va_copy} has been called | |
11313 | on a @code{va_list} without a corresponding call to @code{va_end}. | |
11314 | ||
d77de738 ML |
11315 | @opindex Wanalyzer-va-list-use-after-va-end |
11316 | @opindex Wno-analyzer-va-list-use-after-va-end | |
ddf6fe37 | 11317 | @item -Wno-analyzer-va-list-use-after-va-end |
d77de738 ML |
11318 | This warning requires @option{-fanalyzer}, which enables it; use |
11319 | @option{-Wno-analyzer-va-list-use-after-va-end} | |
11320 | to disable it. | |
11321 | ||
11322 | This diagnostic warns for interprocedural paths through the code for which | |
11323 | the analyzer detects an attempt to use a @code{va_list} after | |
11324 | @code{va_end} has been called on it. | |
11325 | @code{va_list}. | |
11326 | ||
d77de738 ML |
11327 | @opindex Wanalyzer-write-to-const |
11328 | @opindex Wno-analyzer-write-to-const | |
ddf6fe37 | 11329 | @item -Wno-analyzer-write-to-const |
d77de738 ML |
11330 | This warning requires @option{-fanalyzer}, which enables it; use |
11331 | @option{-Wno-analyzer-write-to-const} | |
11332 | to disable it. | |
11333 | ||
11334 | This diagnostic warns for paths through the code in which the analyzer | |
11335 | detects an attempt to write through a pointer to a @code{const} object. | |
11336 | However, the analyzer does not prioritize detection of such paths, so | |
11337 | false negatives are more likely relative to other warnings. | |
11338 | ||
d77de738 ML |
11339 | @opindex Wanalyzer-write-to-string-literal |
11340 | @opindex Wno-analyzer-write-to-string-literal | |
ddf6fe37 | 11341 | @item -Wno-analyzer-write-to-string-literal |
d77de738 ML |
11342 | This warning requires @option{-fanalyzer}, which enables it; use |
11343 | @option{-Wno-analyzer-write-to-string-literal} | |
11344 | to disable it. | |
11345 | ||
11346 | This diagnostic warns for paths through the code in which the analyzer | |
11347 | detects an attempt to write through a pointer to a string literal. | |
11348 | However, the analyzer does not prioritize detection of such paths, so | |
11349 | false negatives are more likely relative to other warnings. | |
11350 | ||
d77de738 ML |
11351 | @opindex Wanalyzer-use-of-uninitialized-value |
11352 | @opindex Wno-analyzer-use-of-uninitialized-value | |
ddf6fe37 | 11353 | @item -Wno-analyzer-use-of-uninitialized-value |
d77de738 ML |
11354 | This warning requires @option{-fanalyzer}, which enables it; use |
11355 | @option{-Wno-analyzer-use-of-uninitialized-value} to disable it. | |
11356 | ||
11357 | This diagnostic warns for paths through the code in which an uninitialized | |
11358 | value is used. | |
11359 | ||
11360 | See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}. | |
11361 | ||
11362 | @end table | |
11363 | ||
11364 | The analyzer has hardcoded knowledge about the behavior of the following | |
11365 | memory-management functions: | |
11366 | ||
11367 | @itemize @bullet | |
11368 | @item @code{alloca} | |
11369 | @item The built-in functions @code{__builtin_alloc}, | |
11370 | @code{__builtin_alloc_with_align}, @item @code{__builtin_calloc}, | |
11371 | @code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy}, | |
11372 | @code{__builtin_memcpy_chk}, @code{__builtin_memset}, | |
11373 | @code{__builtin_memset_chk}, @code{__builtin_realloc}, | |
11374 | @code{__builtin_stack_restore}, and @code{__builtin_stack_save} | |
11375 | @item @code{calloc} | |
11376 | @item @code{free} | |
11377 | @item @code{malloc} | |
11378 | @item @code{memset} | |
11379 | @item @code{operator delete} | |
11380 | @item @code{operator delete []} | |
11381 | @item @code{operator new} | |
11382 | @item @code{operator new []} | |
11383 | @item @code{realloc} | |
11384 | @item @code{strdup} | |
11385 | @item @code{strndup} | |
11386 | @end itemize | |
11387 | ||
4ace81b6 | 11388 | @noindent |
d77de738 ML |
11389 | of the following functions for working with file descriptors: |
11390 | ||
11391 | @itemize @bullet | |
11392 | @item @code{open} | |
11393 | @item @code{close} | |
11394 | @item @code{creat} | |
11395 | @item @code{dup}, @code{dup2} and @code{dup3} | |
78a17f44 | 11396 | @item @code{isatty} |
d77de738 ML |
11397 | @item @code{pipe}, and @code{pipe2} |
11398 | @item @code{read} | |
11399 | @item @code{write} | |
86a90006 | 11400 | @item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect} |
d77de738 ML |
11401 | @end itemize |
11402 | ||
4ace81b6 | 11403 | @noindent |
d77de738 ML |
11404 | of the following functions for working with @code{<stdio.h>} streams: |
11405 | @itemize @bullet | |
11406 | @item The built-in functions @code{__builtin_fprintf}, | |
11407 | @code{__builtin_fprintf_unlocked}, @code{__builtin_fputc}, | |
11408 | @code{__builtin_fputc_unlocked}, @code{__builtin_fputs}, | |
11409 | @code{__builtin_fputs_unlocked}, @code{__builtin_fwrite}, | |
11410 | @code{__builtin_fwrite_unlocked}, @code{__builtin_printf}, | |
11411 | @code{__builtin_printf_unlocked}, @code{__builtin_putc}, | |
11412 | @code{__builtin_putchar}, @code{__builtin_putchar_unlocked}, | |
11413 | @code{__builtin_putc_unlocked}, @code{__builtin_puts}, | |
11414 | @code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and | |
11415 | @code{__builtin_vprintf} | |
11416 | @item @code{fopen} | |
11417 | @item @code{fclose} | |
78a17f44 | 11418 | @item @code{ferror} |
d77de738 ML |
11419 | @item @code{fgets} |
11420 | @item @code{fgets_unlocked} | |
78a17f44 | 11421 | @item @code{fileno} |
d77de738 | 11422 | @item @code{fread} |
78a17f44 | 11423 | @item @code{getc} |
d77de738 ML |
11424 | @item @code{getchar} |
11425 | @item @code{fprintf} | |
11426 | @item @code{printf} | |
11427 | @item @code{fwrite} | |
11428 | @end itemize | |
11429 | ||
4ace81b6 | 11430 | @noindent |
d77de738 ML |
11431 | and of the following functions: |
11432 | ||
11433 | @itemize @bullet | |
11434 | @item The built-in functions @code{__builtin_expect}, | |
11435 | @code{__builtin_expect_with_probability}, @code{__builtin_strchr}, | |
11436 | @code{__builtin_strcpy}, @code{__builtin_strcpy_chk}, | |
11437 | @code{__builtin_strlen}, @code{__builtin_va_copy}, and | |
11438 | @code{__builtin_va_start} | |
11439 | @item The GNU extensions @code{error} and @code{error_at_line} | |
11440 | @item @code{getpass} | |
11441 | @item @code{longjmp} | |
11442 | @item @code{putenv} | |
11443 | @item @code{setjmp} | |
11444 | @item @code{siglongjmp} | |
11445 | @item @code{signal} | |
11446 | @item @code{sigsetjmp} | |
bbdc0e0d | 11447 | @item @code{strcat} |
d77de738 ML |
11448 | @item @code{strchr} |
11449 | @item @code{strlen} | |
11450 | @end itemize | |
11451 | ||
11452 | In addition, various functions with an @code{__analyzer_} prefix have | |
11453 | special meaning to the analyzer, described in the GCC Internals manual. | |
11454 | ||
11455 | Pertinent parameters for controlling the exploration are: | |
4ace81b6 SL |
11456 | @itemize @bullet |
11457 | @item @option{--param analyzer-bb-explosion-factor=@var{value}} | |
11458 | @item @option{--param analyzer-max-enodes-per-program-point=@var{value}} | |
11459 | @item @option{--param analyzer-max-recursion-depth=@var{value}} | |
11460 | @item @option{--param analyzer-min-snodes-for-call-summary=@var{value}} | |
11461 | @end itemize | |
d77de738 ML |
11462 | |
11463 | The following options control the analyzer. | |
11464 | ||
11465 | @table @gcctabopt | |
11466 | ||
d77de738 ML |
11467 | @opindex fanalyzer-call-summaries |
11468 | @opindex fno-analyzer-call-summaries | |
ddf6fe37 | 11469 | @item -fanalyzer-call-summaries |
d77de738 ML |
11470 | Simplify interprocedural analysis by computing the effect of certain calls, |
11471 | rather than exploring all paths through the function from callsite to each | |
11472 | possible return. | |
11473 | ||
11474 | If enabled, call summaries are only used for functions with more than one | |
11475 | call site, and that are sufficiently complicated (as per | |
11476 | @option{--param analyzer-min-snodes-for-call-summary=@var{value}}). | |
11477 | ||
d77de738 | 11478 | @opindex fanalyzer-checker |
ddf6fe37 | 11479 | @item -fanalyzer-checker=@var{name} |
d77de738 ML |
11480 | Restrict the analyzer to run just the named checker, and enable it. |
11481 | ||
0e466e97 DM |
11482 | @opindex fanalyzer-debug-text-art |
11483 | @opindex fno-analyzer-debug-text-art | |
11484 | @item -fanalyzer-debug-text-art-headings | |
11485 | This option is intended for analyzer developers. If enabled, | |
11486 | the analyzer will add extra annotations to any diagrams it generates. | |
11487 | ||
d77de738 ML |
11488 | @opindex fanalyzer-feasibility |
11489 | @opindex fno-analyzer-feasibility | |
ddf6fe37 | 11490 | @item -fno-analyzer-feasibility |
d77de738 ML |
11491 | This option is intended for analyzer developers. |
11492 | ||
11493 | By default the analyzer verifies that there is a feasible control flow path | |
11494 | for each diagnostic it emits: that the conditions that hold are not mutually | |
11495 | exclusive. Diagnostics for which no feasible path can be found are rejected. | |
11496 | This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for | |
11497 | debugging issues in this code. | |
11498 | ||
d77de738 ML |
11499 | @opindex fanalyzer-fine-grained |
11500 | @opindex fno-analyzer-fine-grained | |
ddf6fe37 | 11501 | @item -fanalyzer-fine-grained |
d77de738 ML |
11502 | This option is intended for analyzer developers. |
11503 | ||
11504 | Internally the analyzer builds an ``exploded graph'' that combines | |
11505 | control flow graphs with data flow information. | |
11506 | ||
11507 | By default, an edge in this graph can contain the effects of a run | |
11508 | of multiple statements within a basic block. With | |
11509 | @option{-fanalyzer-fine-grained}, each statement gets its own edge. | |
11510 | ||
d77de738 ML |
11511 | @opindex fanalyzer-show-duplicate-count |
11512 | @opindex fno-analyzer-show-duplicate-count | |
ddf6fe37 | 11513 | @item -fanalyzer-show-duplicate-count |
d77de738 ML |
11514 | This option is intended for analyzer developers: if multiple diagnostics |
11515 | have been detected as being duplicates of each other, it emits a note when | |
11516 | reporting the best diagnostic, giving the number of additional diagnostics | |
11517 | that were suppressed by the deduplication logic. | |
11518 | ||
ce8cdf5b | 11519 | @opindex fanalyzer-show-events-in-system-headers |
11520 | @opindex fno-analyzer-show-events-in-system-headers | |
11521 | @item -fanalyzer-show-events-in-system-headers | |
11522 | By default the analyzer emits simplified diagnostics paths by hiding | |
11523 | events fully located within a system header. | |
11524 | With @option{-fanalyzer-show-events-in-system-headers} such | |
11525 | events are no longer suppressed. | |
11526 | ||
d77de738 ML |
11527 | @opindex fanalyzer-state-merge |
11528 | @opindex fno-analyzer-state-merge | |
ddf6fe37 | 11529 | @item -fno-analyzer-state-merge |
d77de738 ML |
11530 | This option is intended for analyzer developers. |
11531 | ||
11532 | By default the analyzer attempts to simplify analysis by merging | |
11533 | sufficiently similar states at each program point as it builds its | |
11534 | ``exploded graph''. With @option{-fno-analyzer-state-merge} this | |
11535 | merging can be suppressed, for debugging state-handling issues. | |
11536 | ||
d77de738 ML |
11537 | @opindex fanalyzer-state-purge |
11538 | @opindex fno-analyzer-state-purge | |
ddf6fe37 | 11539 | @item -fno-analyzer-state-purge |
d77de738 ML |
11540 | This option is intended for analyzer developers. |
11541 | ||
11542 | By default the analyzer attempts to simplify analysis by purging | |
11543 | aspects of state at a program point that appear to no longer be relevant | |
11544 | e.g. the values of locals that aren't accessed later in the function | |
11545 | and which aren't relevant to leak analysis. | |
11546 | ||
11547 | With @option{-fno-analyzer-state-purge} this purging of state can | |
11548 | be suppressed, for debugging state-handling issues. | |
11549 | ||
8f636915 DM |
11550 | @opindex fanalyzer-suppress-followups |
11551 | @opindex fno-analyzer-suppress-followups | |
f33d7a88 | 11552 | @item -fno-analyzer-suppress-followups |
8f636915 DM |
11553 | This option is intended for analyzer developers. |
11554 | ||
11555 | By default the analyzer will stop exploring an execution path after | |
11556 | encountering certain diagnostics, in order to avoid potentially issuing a | |
11557 | cascade of follow-up diagnostics. | |
11558 | ||
11559 | The diagnostics that terminate analysis along a path are: | |
11560 | ||
11561 | @itemize | |
11562 | @item @option{-Wanalyzer-null-argument} | |
11563 | @item @option{-Wanalyzer-null-dereference} | |
11564 | @item @option{-Wanalyzer-use-after-free} | |
11565 | @item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame} | |
11566 | @item @option{-Wanalyzer-use-of-uninitialized-value} | |
11567 | @end itemize | |
11568 | ||
11569 | With @option{-fno-analyzer-suppress-followups} the analyzer will | |
11570 | continue to explore such paths even after such diagnostics, which may | |
11571 | be helpful for debugging issues in the analyzer, or for microbenchmarks | |
11572 | for detecting undefined behavior. | |
11573 | ||
d77de738 ML |
11574 | @opindex fanalyzer-transitivity |
11575 | @opindex fno-analyzer-transitivity | |
ddf6fe37 | 11576 | @item -fanalyzer-transitivity |
d77de738 ML |
11577 | This option enables transitivity of constraints within the analyzer. |
11578 | ||
d77de738 ML |
11579 | @opindex fanalyzer-undo-inlining |
11580 | @opindex fno-analyzer-undo-inlining | |
ddf6fe37 | 11581 | @item -fno-analyzer-undo-inlining |
d77de738 ML |
11582 | This option is intended for analyzer developers. |
11583 | ||
11584 | @option{-fanalyzer} runs relatively late compared to other code analysis | |
11585 | tools, and some optimizations have already been applied to the code. In | |
11586 | particular function inlining may have occurred, leading to the | |
11587 | interprocedural execution paths emitted by the analyzer containing | |
11588 | function frames that don't correspond to those in the original source | |
11589 | code. | |
11590 | ||
11591 | By default the analyzer attempts to reconstruct the original function | |
11592 | frames, and to emit events showing the inlined calls. | |
11593 | ||
11594 | With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct | |
11595 | the original frame information can be be disabled, which may be of help | |
11596 | when debugging issues in the analyzer. | |
11597 | ||
11598 | @item -fanalyzer-verbose-edges | |
11599 | This option is intended for analyzer developers. It enables more | |
11600 | verbose, lower-level detail in the descriptions of control flow | |
11601 | within diagnostic paths. | |
11602 | ||
11603 | @item -fanalyzer-verbose-state-changes | |
11604 | This option is intended for analyzer developers. It enables more | |
11605 | verbose, lower-level detail in the descriptions of events relating | |
11606 | to state machines within diagnostic paths. | |
11607 | ||
11608 | @item -fanalyzer-verbosity=@var{level} | |
11609 | This option controls the complexity of the control flow paths that are | |
11610 | emitted for analyzer diagnostics. | |
11611 | ||
11612 | The @var{level} can be one of: | |
11613 | ||
11614 | @table @samp | |
11615 | @item 0 | |
11616 | At this level, interprocedural call and return events are displayed, | |
11617 | along with the most pertinent state-change events relating to | |
11618 | a diagnostic. For example, for a double-@code{free} diagnostic, | |
11619 | both calls to @code{free} will be shown. | |
11620 | ||
11621 | @item 1 | |
11622 | As per the previous level, but also show events for the entry | |
11623 | to each function. | |
11624 | ||
11625 | @item 2 | |
11626 | As per the previous level, but also show events relating to | |
11627 | control flow that are significant to triggering the issue | |
11628 | (e.g. ``true path taken'' at a conditional). | |
11629 | ||
11630 | This level is the default. | |
11631 | ||
11632 | @item 3 | |
11633 | As per the previous level, but show all control flow events, not | |
11634 | just significant ones. | |
11635 | ||
11636 | @item 4 | |
11637 | This level is intended for analyzer developers; it adds various | |
11638 | other events intended for debugging the analyzer. | |
11639 | ||
11640 | @end table | |
11641 | ||
d77de738 | 11642 | @opindex fdump-analyzer |
ddf6fe37 | 11643 | @item -fdump-analyzer |
d77de738 ML |
11644 | Dump internal details about what the analyzer is doing to |
11645 | @file{@var{file}.analyzer.txt}. | |
4ace81b6 | 11646 | @option{-fdump-analyzer-stderr} overrides this option. |
d77de738 | 11647 | |
d77de738 | 11648 | @opindex fdump-analyzer-stderr |
ddf6fe37 | 11649 | @item -fdump-analyzer-stderr |
d77de738 ML |
11650 | Dump internal details about what the analyzer is doing to stderr. |
11651 | This option overrides @option{-fdump-analyzer}. | |
11652 | ||
d77de738 | 11653 | @opindex fdump-analyzer-callgraph |
ddf6fe37 | 11654 | @item -fdump-analyzer-callgraph |
d77de738 ML |
11655 | Dump a representation of the call graph suitable for viewing with |
11656 | GraphViz to @file{@var{file}.callgraph.dot}. | |
11657 | ||
d77de738 | 11658 | @opindex fdump-analyzer-exploded-graph |
ddf6fe37 | 11659 | @item -fdump-analyzer-exploded-graph |
d77de738 ML |
11660 | Dump a representation of the ``exploded graph'' suitable for viewing with |
11661 | GraphViz to @file{@var{file}.eg.dot}. | |
11662 | Nodes are color-coded based on state-machine states to emphasize | |
11663 | state changes. | |
11664 | ||
d77de738 | 11665 | @opindex dump-analyzer-exploded-nodes |
ddf6fe37 | 11666 | @item -fdump-analyzer-exploded-nodes |
d77de738 ML |
11667 | Emit diagnostics showing where nodes in the ``exploded graph'' are |
11668 | in relation to the program source. | |
11669 | ||
d77de738 | 11670 | @opindex dump-analyzer-exploded-nodes-2 |
ddf6fe37 | 11671 | @item -fdump-analyzer-exploded-nodes-2 |
d77de738 ML |
11672 | Dump a textual representation of the ``exploded graph'' to |
11673 | @file{@var{file}.eg.txt}. | |
11674 | ||
d77de738 | 11675 | @opindex dump-analyzer-exploded-nodes-3 |
ddf6fe37 | 11676 | @item -fdump-analyzer-exploded-nodes-3 |
d77de738 ML |
11677 | Dump a textual representation of the ``exploded graph'' to |
11678 | one dump file per node, to @file{@var{file}.eg-@var{id}.txt}. | |
11679 | This is typically a large number of dump files. | |
11680 | ||
d77de738 | 11681 | @opindex fdump-analyzer-exploded-paths |
ddf6fe37 | 11682 | @item -fdump-analyzer-exploded-paths |
d77de738 ML |
11683 | Dump a textual representation of the ``exploded path'' for each |
11684 | diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}. | |
11685 | ||
d77de738 | 11686 | @opindex dump-analyzer-feasibility |
ddf6fe37 | 11687 | @item -fdump-analyzer-feasibility |
d77de738 ML |
11688 | Dump internal details about the analyzer's search for feasible paths. |
11689 | The details are written in a form suitable for viewing with GraphViz | |
11690 | to filenames of the form @file{@var{file}.*.fg.dot}, | |
11691 | @file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}. | |
11692 | ||
841008d3 DM |
11693 | @opindex dump-analyzer-infinite-loop |
11694 | @item -fdump-analyzer-infinite-loop | |
11695 | Dump internal details about the analyzer's search for infinite loops. | |
11696 | The details are written in a form suitable for viewing with GraphViz | |
11697 | to filenames of the form @file{@var{file}.*.infinite-loop.dot}. | |
11698 | ||
d77de738 | 11699 | @opindex fdump-analyzer-json |
ddf6fe37 | 11700 | @item -fdump-analyzer-json |
d77de738 ML |
11701 | Dump a compressed JSON representation of analyzer internals to |
11702 | @file{@var{file}.analyzer.json.gz}. The precise format is subject | |
11703 | to change. | |
11704 | ||
d77de738 | 11705 | @opindex fdump-analyzer-state-purge |
ddf6fe37 | 11706 | @item -fdump-analyzer-state-purge |
d77de738 ML |
11707 | As per @option{-fdump-analyzer-supergraph}, dump a representation of the |
11708 | ``supergraph'' suitable for viewing with GraphViz, but annotate the | |
11709 | graph with information on what state will be purged at each node. | |
11710 | The graph is written to @file{@var{file}.state-purge.dot}. | |
11711 | ||
d77de738 | 11712 | @opindex fdump-analyzer-supergraph |
ddf6fe37 | 11713 | @item -fdump-analyzer-supergraph |
d77de738 ML |
11714 | Dump representations of the ``supergraph'' suitable for viewing with |
11715 | GraphViz to @file{@var{file}.supergraph.dot} and to | |
11716 | @file{@var{file}.supergraph-eg.dot}. These show all of the | |
11717 | control flow graphs in the program, with interprocedural edges for | |
11718 | calls and returns. The second dump contains annotations showing nodes | |
11719 | in the ``exploded graph'' and diagnostics associated with them. | |
11720 | ||
d77de738 | 11721 | @opindex fdump-analyzer-untracked |
ddf6fe37 | 11722 | @item -fdump-analyzer-untracked |
d77de738 ML |
11723 | Emit custom warnings with internal details intended for analyzer developers. |
11724 | ||
11725 | @end table | |
11726 | ||
11727 | @node Debugging Options | |
11728 | @section Options for Debugging Your Program | |
11729 | @cindex options, debugging | |
11730 | @cindex debugging information options | |
11731 | ||
11732 | To tell GCC to emit extra information for use by a debugger, in almost | |
11733 | all cases you need only to add @option{-g} to your other options. Some debug | |
11734 | formats can co-exist (like DWARF with CTF) when each of them is enabled | |
11735 | explicitly by adding the respective command line option to your other options. | |
11736 | ||
11737 | GCC allows you to use @option{-g} with | |
11738 | @option{-O}. The shortcuts taken by optimized code may occasionally | |
11739 | be surprising: some variables you declared may not exist | |
11740 | at all; flow of control may briefly move where you did not expect it; | |
11741 | some statements may not be executed because they compute constant | |
11742 | results or their values are already at hand; some statements may | |
11743 | execute in different places because they have been moved out of loops. | |
11744 | Nevertheless it is possible to debug optimized output. This makes | |
11745 | it reasonable to use the optimizer for programs that might have bugs. | |
11746 | ||
11747 | If you are not using some other optimization option, consider | |
11748 | using @option{-Og} (@pxref{Optimize Options}) with @option{-g}. | |
11749 | With no @option{-O} option at all, some compiler passes that collect | |
11750 | information useful for debugging do not run at all, so that | |
11751 | @option{-Og} may result in a better debugging experience. | |
11752 | ||
11753 | @table @gcctabopt | |
d77de738 | 11754 | @opindex g |
ddf6fe37 | 11755 | @item -g |
d77de738 ML |
11756 | Produce debugging information in the operating system's native format |
11757 | (stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging | |
11758 | information. | |
11759 | ||
11760 | On most systems that use stabs format, @option{-g} enables use of extra | |
11761 | debugging information that only GDB can use; this extra information | |
11762 | makes debugging work better in GDB but probably makes other debuggers | |
11763 | crash or refuse to read the program. If you want to control for certain whether | |
11764 | to generate the extra information, use @option{-gvms} (see below). | |
11765 | ||
d77de738 | 11766 | @opindex ggdb |
ddf6fe37 | 11767 | @item -ggdb |
d77de738 ML |
11768 | Produce debugging information for use by GDB@. This means to use the |
11769 | most expressive format available (DWARF, stabs, or the native format | |
11770 | if neither of those are supported), including GDB extensions if at all | |
11771 | possible. | |
11772 | ||
ddf6fe37 | 11773 | @opindex gdwarf |
d77de738 ML |
11774 | @item -gdwarf |
11775 | @itemx -gdwarf-@var{version} | |
d77de738 ML |
11776 | Produce debugging information in DWARF format (if that is supported). |
11777 | The value of @var{version} may be either 2, 3, 4 or 5; the default | |
11778 | version for most targets is 5 (with the exception of VxWorks, TPF and | |
a335cf24 | 11779 | Darwin / macOS, which default to version 2, and AIX, which defaults |
d77de738 ML |
11780 | to version 4). |
11781 | ||
11782 | Note that with DWARF Version 2, some ports require and always | |
11783 | use some non-conflicting DWARF 3 extensions in the unwind tables. | |
11784 | ||
11785 | Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments} | |
11786 | for maximum benefit. Version 5 requires GDB 8.0 or higher. | |
11787 | ||
11788 | GCC no longer supports DWARF Version 1, which is substantially | |
11789 | different than Version 2 and later. For historical reasons, some | |
11790 | other DWARF-related options such as | |
11791 | @option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2 | |
11792 | in their names, but apply to all currently-supported versions of DWARF. | |
11793 | ||
d77de738 | 11794 | @opindex gbtf |
ddf6fe37 | 11795 | @item -gbtf |
d77de738 ML |
11796 | Request BTF debug information. BTF is the default debugging format for the |
11797 | eBPF target. On other targets, like x86, BTF debug information can be | |
11798 | generated along with DWARF debug information when both of the debug formats are | |
11799 | enabled explicitly via their respective command line options. | |
11800 | ||
ddf6fe37 | 11801 | @opindex gctf |
d77de738 ML |
11802 | @item -gctf |
11803 | @itemx -gctf@var{level} | |
d77de738 ML |
11804 | Request CTF debug information and use level to specify how much CTF debug |
11805 | information should be produced. If @option{-gctf} is specified | |
11806 | without a value for level, the default level of CTF debug information is 2. | |
11807 | ||
11808 | CTF debug information can be generated along with DWARF debug information when | |
11809 | both of the debug formats are enabled explicitly via their respective command | |
11810 | line options. | |
11811 | ||
11812 | Level 0 produces no CTF debug information at all. Thus, @option{-gctf0} | |
11813 | negates @option{-gctf}. | |
11814 | ||
11815 | Level 1 produces CTF information for tracebacks only. This includes callsite | |
11816 | information, but does not include type information. | |
11817 | ||
11818 | Level 2 produces type information for entities (functions, data objects etc.) | |
11819 | at file-scope or global-scope only. | |
11820 | ||
d77de738 | 11821 | @opindex gvms |
ddf6fe37 | 11822 | @item -gvms |
d77de738 ML |
11823 | Produce debugging information in Alpha/VMS debug format (if that is |
11824 | supported). This is the format used by DEBUG on Alpha/VMS systems. | |
11825 | ||
2f7e7bfa MH |
11826 | @item -gcodeview |
11827 | @opindex gcodeview | |
11828 | Produce debugging information in CodeView debug format (if that is | |
11829 | supported). This is the format used by Microsoft Visual C++ on | |
11830 | Windows. | |
11831 | ||
d77de738 ML |
11832 | @item -g@var{level} |
11833 | @itemx -ggdb@var{level} | |
11834 | @itemx -gvms@var{level} | |
11835 | Request debugging information and also use @var{level} to specify how | |
11836 | much information. The default level is 2. | |
11837 | ||
11838 | Level 0 produces no debug information at all. Thus, @option{-g0} negates | |
11839 | @option{-g}. | |
11840 | ||
11841 | Level 1 produces minimal information, enough for making backtraces in | |
11842 | parts of the program that you don't plan to debug. This includes | |
11843 | descriptions of functions and external variables, and line number | |
11844 | tables, but no information about local variables. | |
11845 | ||
11846 | Level 3 includes extra information, such as all the macro definitions | |
11847 | present in the program. Some debuggers support macro expansion when | |
11848 | you use @option{-g3}. | |
11849 | ||
11850 | If you use multiple @option{-g} options, with or without level numbers, | |
11851 | the last such option is the one that is effective. | |
11852 | ||
11853 | @option{-gdwarf} does not accept a concatenated debug level, to avoid | |
11854 | confusion with @option{-gdwarf-@var{level}}. | |
11855 | Instead use an additional @option{-g@var{level}} option to change the | |
11856 | debug level for DWARF. | |
11857 | ||
d77de738 ML |
11858 | @opindex feliminate-unused-debug-symbols |
11859 | @opindex fno-eliminate-unused-debug-symbols | |
ddf6fe37 | 11860 | @item -fno-eliminate-unused-debug-symbols |
d77de738 ML |
11861 | By default, no debug information is produced for symbols that are not actually |
11862 | used. Use this option if you want debug information for all symbols. | |
11863 | ||
d77de738 | 11864 | @opindex femit-class-debug-always |
ddf6fe37 | 11865 | @item -femit-class-debug-always |
d77de738 ML |
11866 | Instead of emitting debugging information for a C++ class in only one |
11867 | object file, emit it in all object files using the class. This option | |
11868 | should be used only with debuggers that are unable to handle the way GCC | |
11869 | normally emits debugging information for classes because using this | |
11870 | option increases the size of debugging information by as much as a | |
11871 | factor of two. | |
11872 | ||
d77de738 ML |
11873 | @opindex fmerge-debug-strings |
11874 | @opindex fno-merge-debug-strings | |
ddf6fe37 | 11875 | @item -fno-merge-debug-strings |
d77de738 ML |
11876 | Direct the linker to not merge together strings in the debugging |
11877 | information that are identical in different object files. Merging is | |
11878 | not supported by all assemblers or linkers. Merging decreases the size | |
11879 | of the debug information in the output file at the cost of increasing | |
11880 | link processing time. Merging is enabled by default. | |
11881 | ||
d77de738 | 11882 | @opindex fdebug-prefix-map |
ddf6fe37 | 11883 | @item -fdebug-prefix-map=@var{old}=@var{new} |
d77de738 ML |
11884 | When compiling files residing in directory @file{@var{old}}, record |
11885 | debugging information describing them as if the files resided in | |
11886 | directory @file{@var{new}} instead. This can be used to replace a | |
11887 | build-time path with an install-time path in the debug info. It can | |
11888 | also be used to change an absolute path to a relative path by using | |
11889 | @file{.} for @var{new}. This can give more reproducible builds, which | |
11890 | are location independent, but may require an extra command to tell GDB | |
2eb0191a JJ |
11891 | where to find the source files. See also @option{-ffile-prefix-map} |
11892 | and @option{-fcanon-prefix-map}. | |
d77de738 | 11893 | |
d77de738 | 11894 | @opindex fvar-tracking |
ddf6fe37 | 11895 | @item -fvar-tracking |
d77de738 ML |
11896 | Run variable tracking pass. It computes where variables are stored at each |
11897 | position in code. Better debugging information is then generated | |
11898 | (if the debugging information format supports this information). | |
11899 | ||
11900 | It is enabled by default when compiling with optimization (@option{-Os}, | |
11901 | @option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and | |
11902 | the debug info format supports it. | |
11903 | ||
d77de738 ML |
11904 | @opindex fvar-tracking-assignments |
11905 | @opindex fno-var-tracking-assignments | |
ddf6fe37 | 11906 | @item -fvar-tracking-assignments |
d77de738 ML |
11907 | Annotate assignments to user variables early in the compilation and |
11908 | attempt to carry the annotations over throughout the compilation all the | |
11909 | way to the end, in an attempt to improve debug information while | |
11910 | optimizing. Use of @option{-gdwarf-4} is recommended along with it. | |
11911 | ||
11912 | It can be enabled even if var-tracking is disabled, in which case | |
11913 | annotations are created and maintained, but discarded at the end. | |
11914 | By default, this flag is enabled together with @option{-fvar-tracking}, | |
11915 | except when selective scheduling is enabled. | |
11916 | ||
d77de738 | 11917 | @opindex gsplit-dwarf |
ddf6fe37 | 11918 | @item -gsplit-dwarf |
d77de738 ML |
11919 | If DWARF debugging information is enabled, separate as much debugging |
11920 | information as possible into a separate output file with the extension | |
11921 | @file{.dwo}. This option allows the build system to avoid linking files with | |
11922 | debug information. To be useful, this option requires a debugger capable of | |
11923 | reading @file{.dwo} files. | |
11924 | ||
d77de738 ML |
11925 | @opindex gdwarf32 |
11926 | @opindex gdwarf64 | |
ddf6fe37 AA |
11927 | @item -gdwarf32 |
11928 | @itemx -gdwarf64 | |
d77de738 ML |
11929 | If DWARF debugging information is enabled, the @option{-gdwarf32} selects |
11930 | the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit | |
11931 | DWARF format. The default is target specific, on most targets it is | |
11932 | @option{-gdwarf32} though. The 32-bit DWARF format is smaller, but | |
11933 | can't support more than 2GiB of debug information in any of the DWARF | |
11934 | debug information sections. The 64-bit DWARF format allows larger debug | |
11935 | information and might not be well supported by all consumers yet. | |
11936 | ||
d77de738 | 11937 | @opindex gdescribe-dies |
ddf6fe37 | 11938 | @item -gdescribe-dies |
d77de738 ML |
11939 | Add description attributes to some DWARF DIEs that have no name attribute, |
11940 | such as artificial variables, external references and call site | |
11941 | parameter DIEs. | |
11942 | ||
d77de738 | 11943 | @opindex gpubnames |
ddf6fe37 | 11944 | @item -gpubnames |
d77de738 ML |
11945 | Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections. |
11946 | ||
d77de738 | 11947 | @opindex ggnu-pubnames |
ddf6fe37 | 11948 | @item -ggnu-pubnames |
d77de738 ML |
11949 | Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format |
11950 | suitable for conversion into a GDB@ index. This option is only useful | |
11951 | with a linker that can produce GDB@ index version 7. | |
11952 | ||
d77de738 ML |
11953 | @opindex fdebug-types-section |
11954 | @opindex fno-debug-types-section | |
ddf6fe37 | 11955 | @item -fdebug-types-section |
d77de738 ML |
11956 | When using DWARF Version 4 or higher, type DIEs can be put into |
11957 | their own @code{.debug_types} section instead of making them part of the | |
11958 | @code{.debug_info} section. It is more efficient to put them in a separate | |
11959 | comdat section since the linker can then remove duplicates. | |
11960 | But not all DWARF consumers support @code{.debug_types} sections yet | |
11961 | and on some objects @code{.debug_types} produces larger instead of smaller | |
11962 | debugging information. | |
11963 | ||
d77de738 ML |
11964 | @opindex grecord-gcc-switches |
11965 | @opindex gno-record-gcc-switches | |
ddf6fe37 AA |
11966 | @item -grecord-gcc-switches |
11967 | @itemx -gno-record-gcc-switches | |
d77de738 ML |
11968 | This switch causes the command-line options used to invoke the |
11969 | compiler that may affect code generation to be appended to the | |
11970 | DW_AT_producer attribute in DWARF debugging information. The options | |
11971 | are concatenated with spaces separating them from each other and from | |
11972 | the compiler version. | |
11973 | It is enabled by default. | |
11974 | See also @option{-frecord-gcc-switches} for another | |
11975 | way of storing compiler options into the object file. | |
11976 | ||
d77de738 | 11977 | @opindex gstrict-dwarf |
ddf6fe37 | 11978 | @item -gstrict-dwarf |
d77de738 ML |
11979 | Disallow using extensions of later DWARF standard version than selected |
11980 | with @option{-gdwarf-@var{version}}. On most targets using non-conflicting | |
11981 | DWARF extensions from later standard versions is allowed. | |
11982 | ||
d77de738 | 11983 | @opindex gno-strict-dwarf |
ddf6fe37 | 11984 | @item -gno-strict-dwarf |
d77de738 ML |
11985 | Allow using extensions of later DWARF standard version than selected with |
11986 | @option{-gdwarf-@var{version}}. | |
11987 | ||
d77de738 | 11988 | @opindex gas-loc-support |
ddf6fe37 | 11989 | @item -gas-loc-support |
d77de738 ML |
11990 | Inform the compiler that the assembler supports @code{.loc} directives. |
11991 | It may then use them for the assembler to generate DWARF2+ line number | |
11992 | tables. | |
11993 | ||
11994 | This is generally desirable, because assembler-generated line-number | |
11995 | tables are a lot more compact than those the compiler can generate | |
11996 | itself. | |
11997 | ||
11998 | This option will be enabled by default if, at GCC configure time, the | |
11999 | assembler was found to support such directives. | |
12000 | ||
d77de738 | 12001 | @opindex gno-as-loc-support |
ddf6fe37 | 12002 | @item -gno-as-loc-support |
d77de738 ML |
12003 | Force GCC to generate DWARF2+ line number tables internally, if DWARF2+ |
12004 | line number tables are to be generated. | |
12005 | ||
d77de738 | 12006 | @opindex gas-locview-support |
ddf6fe37 | 12007 | @item -gas-locview-support |
d77de738 ML |
12008 | Inform the compiler that the assembler supports @code{view} assignment |
12009 | and reset assertion checking in @code{.loc} directives. | |
12010 | ||
12011 | This option will be enabled by default if, at GCC configure time, the | |
12012 | assembler was found to support them. | |
12013 | ||
12014 | @item -gno-as-locview-support | |
12015 | Force GCC to assign view numbers internally, if | |
12016 | @option{-gvariable-location-views} are explicitly requested. | |
12017 | ||
d77de738 ML |
12018 | @opindex gcolumn-info |
12019 | @opindex gno-column-info | |
ddf6fe37 AA |
12020 | @item -gcolumn-info |
12021 | @itemx -gno-column-info | |
d77de738 ML |
12022 | Emit location column information into DWARF debugging information, rather |
12023 | than just file and line. | |
12024 | This option is enabled by default. | |
12025 | ||
d77de738 ML |
12026 | @opindex gstatement-frontiers |
12027 | @opindex gno-statement-frontiers | |
ddf6fe37 AA |
12028 | @item -gstatement-frontiers |
12029 | @itemx -gno-statement-frontiers | |
d77de738 ML |
12030 | This option causes GCC to create markers in the internal representation |
12031 | at the beginning of statements, and to keep them roughly in place | |
12032 | throughout compilation, using them to guide the output of @code{is_stmt} | |
12033 | markers in the line number table. This is enabled by default when | |
12034 | compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2}, | |
12035 | @dots{}), and outputting DWARF 2 debug information at the normal level. | |
12036 | ||
d77de738 ML |
12037 | @opindex gvariable-location-views |
12038 | @opindex gvariable-location-views=incompat5 | |
12039 | @opindex gno-variable-location-views | |
ddf6fe37 AA |
12040 | @item -gvariable-location-views |
12041 | @itemx -gvariable-location-views=incompat5 | |
12042 | @itemx -gno-variable-location-views | |
d77de738 ML |
12043 | Augment variable location lists with progressive view numbers implied |
12044 | from the line number table. This enables debug information consumers to | |
12045 | inspect state at certain points of the program, even if no instructions | |
12046 | associated with the corresponding source locations are present at that | |
12047 | point. If the assembler lacks support for view numbers in line number | |
12048 | tables, this will cause the compiler to emit the line number table, | |
12049 | which generally makes them somewhat less compact. The augmented line | |
12050 | number tables and location lists are fully backward-compatible, so they | |
12051 | can be consumed by debug information consumers that are not aware of | |
12052 | these augmentations, but they won't derive any benefit from them either. | |
12053 | ||
12054 | This is enabled by default when outputting DWARF 2 debug information at | |
12055 | the normal level, as long as there is assembler support, | |
12056 | @option{-fvar-tracking-assignments} is enabled and | |
12057 | @option{-gstrict-dwarf} is not. When assembler support is not | |
12058 | available, this may still be enabled, but it will force GCC to output | |
12059 | internal line number tables, and if | |
12060 | @option{-ginternal-reset-location-views} is not enabled, that will most | |
12061 | certainly lead to silently mismatching location views. | |
12062 | ||
12063 | There is a proposed representation for view numbers that is not backward | |
12064 | compatible with the location list format introduced in DWARF 5, that can | |
12065 | be enabled with @option{-gvariable-location-views=incompat5}. This | |
12066 | option may be removed in the future, is only provided as a reference | |
12067 | implementation of the proposed representation. Debug information | |
12068 | consumers are not expected to support this extended format, and they | |
12069 | would be rendered unable to decode location lists using it. | |
12070 | ||
d77de738 ML |
12071 | @opindex ginternal-reset-location-views |
12072 | @opindex gno-internal-reset-location-views | |
ddf6fe37 AA |
12073 | @item -ginternal-reset-location-views |
12074 | @itemx -gno-internal-reset-location-views | |
d77de738 ML |
12075 | Attempt to determine location views that can be omitted from location |
12076 | view lists. This requires the compiler to have very accurate insn | |
12077 | length estimates, which isn't always the case, and it may cause | |
12078 | incorrect view lists to be generated silently when using an assembler | |
12079 | that does not support location view lists. The GNU assembler will flag | |
12080 | any such error as a @code{view number mismatch}. This is only enabled | |
12081 | on ports that define a reliable estimation function. | |
12082 | ||
d77de738 ML |
12083 | @opindex ginline-points |
12084 | @opindex gno-inline-points | |
ddf6fe37 AA |
12085 | @item -ginline-points |
12086 | @itemx -gno-inline-points | |
d77de738 ML |
12087 | Generate extended debug information for inlined functions. Location |
12088 | view tracking markers are inserted at inlined entry points, so that | |
12089 | address and view numbers can be computed and output in debug | |
12090 | information. This can be enabled independently of location views, in | |
12091 | which case the view numbers won't be output, but it can only be enabled | |
12092 | along with statement frontiers, and it is only enabled by default if | |
12093 | location views are enabled. | |
12094 | ||
d77de738 | 12095 | @opindex gz |
ddf6fe37 | 12096 | @item -gz@r{[}=@var{type}@r{]} |
d77de738 ML |
12097 | Produce compressed debug sections in DWARF format, if that is supported. |
12098 | If @var{type} is not given, the default type depends on the capabilities | |
12099 | of the assembler and linker used. @var{type} may be one of | |
12100 | @samp{none} (don't compress debug sections), or @samp{zlib} (use zlib | |
12101 | compression in ELF gABI format). If the linker doesn't support writing | |
12102 | compressed debug sections, the option is rejected. Otherwise, if the | |
12103 | assembler does not support them, @option{-gz} is silently ignored when | |
12104 | producing object files. | |
12105 | ||
d77de738 | 12106 | @opindex femit-struct-debug-baseonly |
ddf6fe37 | 12107 | @item -femit-struct-debug-baseonly |
d77de738 ML |
12108 | Emit debug information for struct-like types |
12109 | only when the base name of the compilation source file | |
12110 | matches the base name of file in which the struct is defined. | |
12111 | ||
12112 | This option substantially reduces the size of debugging information, | |
12113 | but at significant potential loss in type information to the debugger. | |
12114 | See @option{-femit-struct-debug-reduced} for a less aggressive option. | |
12115 | See @option{-femit-struct-debug-detailed} for more detailed control. | |
12116 | ||
12117 | This option works only with DWARF debug output. | |
12118 | ||
d77de738 | 12119 | @opindex femit-struct-debug-reduced |
ddf6fe37 | 12120 | @item -femit-struct-debug-reduced |
d77de738 ML |
12121 | Emit debug information for struct-like types |
12122 | only when the base name of the compilation source file | |
12123 | matches the base name of file in which the type is defined, | |
12124 | unless the struct is a template or defined in a system header. | |
12125 | ||
12126 | This option significantly reduces the size of debugging information, | |
12127 | with some potential loss in type information to the debugger. | |
12128 | See @option{-femit-struct-debug-baseonly} for a more aggressive option. | |
12129 | See @option{-femit-struct-debug-detailed} for more detailed control. | |
12130 | ||
12131 | This option works only with DWARF debug output. | |
12132 | ||
d77de738 | 12133 | @opindex femit-struct-debug-detailed |
ddf6fe37 | 12134 | @item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} |
d77de738 ML |
12135 | Specify the struct-like types |
12136 | for which the compiler generates debug information. | |
12137 | The intent is to reduce duplicate struct debug information | |
12138 | between different object files within the same program. | |
12139 | ||
12140 | This option is a detailed version of | |
12141 | @option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly}, | |
12142 | which serves for most needs. | |
12143 | ||
12144 | A specification has the syntax@* | |
12145 | [@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none}) | |
12146 | ||
12147 | The optional first word limits the specification to | |
12148 | structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}). | |
12149 | A struct type is used directly when it is the type of a variable, member. | |
12150 | Indirect uses arise through pointers to structs. | |
12151 | That is, when use of an incomplete struct is valid, the use is indirect. | |
12152 | An example is | |
12153 | @samp{struct one direct; struct two * indirect;}. | |
12154 | ||
12155 | The optional second word limits the specification to | |
12156 | ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}). | |
12157 | Generic structs are a bit complicated to explain. | |
12158 | For C++, these are non-explicit specializations of template classes, | |
12159 | or non-template classes within the above. | |
12160 | Other programming languages have generics, | |
12161 | but @option{-femit-struct-debug-detailed} does not yet implement them. | |
12162 | ||
12163 | The third word specifies the source files for those | |
12164 | structs for which the compiler should emit debug information. | |
12165 | The values @samp{none} and @samp{any} have the normal meaning. | |
12166 | The value @samp{base} means that | |
12167 | the base of name of the file in which the type declaration appears | |
12168 | must match the base of the name of the main compilation file. | |
12169 | In practice, this means that when compiling @file{foo.c}, debug information | |
12170 | is generated for types declared in that file and @file{foo.h}, | |
12171 | but not other header files. | |
12172 | The value @samp{sys} means those types satisfying @samp{base} | |
12173 | or declared in system or compiler headers. | |
12174 | ||
12175 | You may need to experiment to determine the best settings for your application. | |
12176 | ||
12177 | The default is @option{-femit-struct-debug-detailed=all}. | |
12178 | ||
12179 | This option works only with DWARF debug output. | |
12180 | ||
d77de738 ML |
12181 | @opindex fdwarf2-cfi-asm |
12182 | @opindex fno-dwarf2-cfi-asm | |
ddf6fe37 | 12183 | @item -fno-dwarf2-cfi-asm |
d77de738 ML |
12184 | Emit DWARF unwind info as compiler generated @code{.eh_frame} section |
12185 | instead of using GAS @code{.cfi_*} directives. | |
12186 | ||
d77de738 ML |
12187 | @opindex feliminate-unused-debug-types |
12188 | @opindex fno-eliminate-unused-debug-types | |
ddf6fe37 | 12189 | @item -fno-eliminate-unused-debug-types |
d77de738 ML |
12190 | Normally, when producing DWARF output, GCC avoids producing debug symbol |
12191 | output for types that are nowhere used in the source file being compiled. | |
12192 | Sometimes it is useful to have GCC emit debugging | |
12193 | information for all types declared in a compilation | |
12194 | unit, regardless of whether or not they are actually used | |
12195 | in that compilation unit, for example | |
12196 | if, in the debugger, you want to cast a value to a type that is | |
12197 | not actually used in your program (but is declared). More often, | |
12198 | however, this results in a significant amount of wasted space. | |
12199 | @end table | |
12200 | ||
12201 | @node Optimize Options | |
12202 | @section Options That Control Optimization | |
12203 | @cindex optimize options | |
12204 | @cindex options, optimization | |
12205 | ||
12206 | These options control various sorts of optimizations. | |
12207 | ||
12208 | Without any optimization option, the compiler's goal is to reduce the | |
12209 | cost of compilation and to make debugging produce the expected | |
12210 | results. Statements are independent: if you stop the program with a | |
12211 | breakpoint between statements, you can then assign a new value to any | |
12212 | variable or change the program counter to any other statement in the | |
12213 | function and get exactly the results you expect from the source | |
12214 | code. | |
12215 | ||
12216 | Turning on optimization flags makes the compiler attempt to improve | |
12217 | the performance and/or code size at the expense of compilation time | |
12218 | and possibly the ability to debug the program. | |
12219 | ||
12220 | The compiler performs optimization based on the knowledge it has of the | |
12221 | program. Compiling multiple files at once to a single output file mode allows | |
12222 | the compiler to use information gained from all of the files when compiling | |
12223 | each of them. | |
12224 | ||
12225 | Not all optimizations are controlled directly by a flag. Only | |
12226 | optimizations that have a flag are listed in this section. | |
12227 | ||
12228 | Most optimizations are completely disabled at @option{-O0} or if an | |
12229 | @option{-O} level is not set on the command line, even if individual | |
12230 | optimization flags are specified. Similarly, @option{-Og} suppresses | |
12231 | many optimization passes. | |
12232 | ||
12233 | Depending on the target and how GCC was configured, a slightly different | |
12234 | set of optimizations may be enabled at each @option{-O} level than | |
12235 | those listed here. You can invoke GCC with @option{-Q --help=optimizers} | |
12236 | to find out the exact set of optimizations that are enabled at each level. | |
12237 | @xref{Overall Options}, for examples. | |
12238 | ||
12239 | @table @gcctabopt | |
d77de738 ML |
12240 | @opindex O |
12241 | @opindex O1 | |
ddf6fe37 AA |
12242 | @item -O |
12243 | @itemx -O1 | |
d77de738 ML |
12244 | Optimize. Optimizing compilation takes somewhat more time, and a lot |
12245 | more memory for a large function. | |
12246 | ||
12247 | With @option{-O}, the compiler tries to reduce code size and execution | |
12248 | time, without performing any optimizations that take a great deal of | |
12249 | compilation time. | |
12250 | ||
12251 | @c Note that in addition to the default_options_table list in opts.cc, | |
12252 | @c several optimization flags default to true but control optimization | |
12253 | @c passes that are explicitly disabled at -O0. | |
12254 | ||
12255 | @option{-O} turns on the following optimization flags: | |
12256 | ||
12257 | @c Please keep the following list alphabetized. | |
43b72ede AA |
12258 | @gccoptlist{-fauto-inc-dec |
12259 | -fbranch-count-reg | |
12260 | -fcombine-stack-adjustments | |
12261 | -fcompare-elim | |
12262 | -fcprop-registers | |
12263 | -fdce | |
12264 | -fdefer-pop | |
12265 | -fdelayed-branch | |
12266 | -fdse | |
12267 | -fforward-propagate | |
12268 | -fguess-branch-probability | |
12269 | -fif-conversion | |
12270 | -fif-conversion2 | |
12271 | -finline-functions-called-once | |
12272 | -fipa-modref | |
12273 | -fipa-profile | |
12274 | -fipa-pure-const | |
12275 | -fipa-reference | |
12276 | -fipa-reference-addressable | |
12277 | -fmerge-constants | |
12278 | -fmove-loop-invariants | |
12279 | -fmove-loop-stores | |
12280 | -fomit-frame-pointer | |
12281 | -freorder-blocks | |
12282 | -fshrink-wrap | |
12283 | -fshrink-wrap-separate | |
12284 | -fsplit-wide-types | |
12285 | -fssa-backprop | |
12286 | -fssa-phiopt | |
12287 | -ftree-bit-ccp | |
12288 | -ftree-ccp | |
12289 | -ftree-ch | |
12290 | -ftree-coalesce-vars | |
12291 | -ftree-copy-prop | |
12292 | -ftree-dce | |
12293 | -ftree-dominator-opts | |
12294 | -ftree-dse | |
12295 | -ftree-forwprop | |
12296 | -ftree-fre | |
12297 | -ftree-phiprop | |
12298 | -ftree-pta | |
12299 | -ftree-scev-cprop | |
12300 | -ftree-sink | |
12301 | -ftree-slsr | |
12302 | -ftree-sra | |
12303 | -ftree-ter | |
d77de738 ML |
12304 | -funit-at-a-time} |
12305 | ||
d77de738 | 12306 | @opindex O2 |
ddf6fe37 | 12307 | @item -O2 |
d77de738 ML |
12308 | Optimize even more. GCC performs nearly all supported optimizations |
12309 | that do not involve a space-speed tradeoff. | |
12310 | As compared to @option{-O}, this option increases both compilation time | |
12311 | and the performance of the generated code. | |
12312 | ||
12313 | @option{-O2} turns on all optimization flags specified by @option{-O1}. It | |
12314 | also turns on the following optimization flags: | |
12315 | ||
12316 | @c Please keep the following list alphabetized! | |
43b72ede AA |
12317 | @gccoptlist{-falign-functions -falign-jumps |
12318 | -falign-labels -falign-loops | |
12319 | -fcaller-saves | |
12320 | -fcode-hoisting | |
12321 | -fcrossjumping | |
12322 | -fcse-follow-jumps -fcse-skip-blocks | |
12323 | -fdelete-null-pointer-checks | |
12324 | -fdevirtualize -fdevirtualize-speculatively | |
12325 | -fexpensive-optimizations | |
12326 | -ffinite-loops | |
12327 | -fgcse -fgcse-lm | |
12328 | -fhoist-adjacent-loads | |
12329 | -finline-functions | |
12330 | -finline-small-functions | |
12331 | -findirect-inlining | |
12332 | -fipa-bit-cp -fipa-cp -fipa-icf | |
12333 | -fipa-ra -fipa-sra -fipa-vrp | |
12334 | -fisolate-erroneous-paths-dereference | |
12335 | -flra-remat | |
12336 | -foptimize-sibling-calls | |
12337 | -foptimize-strlen | |
12338 | -fpartial-inlining | |
12339 | -fpeephole2 | |
12340 | -freorder-blocks-algorithm=stc | |
12341 | -freorder-blocks-and-partition -freorder-functions | |
12342 | -frerun-cse-after-loop | |
12343 | -fschedule-insns -fschedule-insns2 | |
12344 | -fsched-interblock -fsched-spec | |
12345 | -fstore-merging | |
12346 | -fstrict-aliasing | |
12347 | -fthread-jumps | |
12348 | -ftree-builtin-call-dce | |
12349 | -ftree-loop-vectorize | |
12350 | -ftree-pre | |
12351 | -ftree-slp-vectorize | |
12352 | -ftree-switch-conversion -ftree-tail-merge | |
12353 | -ftree-vrp | |
d77de738 ML |
12354 | -fvect-cost-model=very-cheap} |
12355 | ||
12356 | Please note the warning under @option{-fgcse} about | |
12357 | invoking @option{-O2} on programs that use computed gotos. | |
12358 | ||
d77de738 | 12359 | @opindex O3 |
ddf6fe37 | 12360 | @item -O3 |
d77de738 ML |
12361 | Optimize yet more. @option{-O3} turns on all optimizations specified |
12362 | by @option{-O2} and also turns on the following optimization flags: | |
12363 | ||
12364 | @c Please keep the following list alphabetized! | |
43b72ede | 12365 | @gccoptlist{-fgcse-after-reload |
d77de738 | 12366 | -fipa-cp-clone |
43b72ede AA |
12367 | -floop-interchange |
12368 | -floop-unroll-and-jam | |
12369 | -fpeel-loops | |
12370 | -fpredictive-commoning | |
12371 | -fsplit-loops | |
12372 | -fsplit-paths | |
12373 | -ftree-loop-distribution | |
12374 | -ftree-partial-pre | |
12375 | -funswitch-loops | |
12376 | -fvect-cost-model=dynamic | |
d77de738 ML |
12377 | -fversion-loops-for-strides} |
12378 | ||
d77de738 | 12379 | @opindex O0 |
ddf6fe37 | 12380 | @item -O0 |
d77de738 ML |
12381 | Reduce compilation time and make debugging produce the expected |
12382 | results. This is the default. | |
12383 | ||
d77de738 | 12384 | @opindex Os |
ddf6fe37 | 12385 | @item -Os |
d77de738 ML |
12386 | Optimize for size. @option{-Os} enables all @option{-O2} optimizations |
12387 | except those that often increase code size: | |
12388 | ||
43b72ede AA |
12389 | @gccoptlist{-falign-functions -falign-jumps |
12390 | -falign-labels -falign-loops | |
d77de738 ML |
12391 | -fprefetch-loop-arrays -freorder-blocks-algorithm=stc} |
12392 | ||
12393 | It also enables @option{-finline-functions}, causes the compiler to tune for | |
12394 | code size rather than execution speed, and performs further optimizations | |
12395 | designed to reduce code size. | |
12396 | ||
d77de738 | 12397 | @opindex Ofast |
ddf6fe37 | 12398 | @item -Ofast |
d77de738 ML |
12399 | Disregard strict standards compliance. @option{-Ofast} enables all |
12400 | @option{-O3} optimizations. It also enables optimizations that are not | |
12401 | valid for all standard-compliant programs. | |
12402 | It turns on @option{-ffast-math}, @option{-fallow-store-data-races} | |
12403 | and the Fortran-specific @option{-fstack-arrays}, unless | |
12404 | @option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}. | |
12405 | It turns off @option{-fsemantic-interposition}. | |
12406 | ||
d77de738 | 12407 | @opindex Og |
ddf6fe37 | 12408 | @item -Og |
d77de738 ML |
12409 | Optimize debugging experience. @option{-Og} should be the optimization |
12410 | level of choice for the standard edit-compile-debug cycle, offering | |
12411 | a reasonable level of optimization while maintaining fast compilation | |
12412 | and a good debugging experience. It is a better choice than @option{-O0} | |
12413 | for producing debuggable code because some compiler passes | |
12414 | that collect debug information are disabled at @option{-O0}. | |
12415 | ||
12416 | Like @option{-O0}, @option{-Og} completely disables a number of | |
12417 | optimization passes so that individual options controlling them have | |
12418 | no effect. Otherwise @option{-Og} enables all @option{-O1} | |
12419 | optimization flags except for those that may interfere with debugging: | |
12420 | ||
43b72ede AA |
12421 | @gccoptlist{-fbranch-count-reg -fdelayed-branch |
12422 | -fdse -fif-conversion -fif-conversion2 | |
12423 | -finline-functions-called-once | |
12424 | -fmove-loop-invariants -fmove-loop-stores -fssa-phiopt | |
d77de738 ML |
12425 | -ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra} |
12426 | ||
d77de738 | 12427 | @opindex Oz |
ddf6fe37 | 12428 | @item -Oz |
d77de738 ML |
12429 | Optimize aggressively for size rather than speed. This may increase |
12430 | the number of instructions executed if those instructions require | |
12431 | fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os} | |
12432 | including enabling most @option{-O2} optimizations. | |
12433 | ||
12434 | @end table | |
12435 | ||
12436 | If you use multiple @option{-O} options, with or without level numbers, | |
12437 | the last such option is the one that is effective. | |
12438 | ||
12439 | Options of the form @option{-f@var{flag}} specify machine-independent | |
12440 | flags. Most flags have both positive and negative forms; the negative | |
12441 | form of @option{-ffoo} is @option{-fno-foo}. In the table | |
12442 | below, only one of the forms is listed---the one you typically | |
12443 | use. You can figure out the other form by either removing @samp{no-} | |
12444 | or adding it. | |
12445 | ||
12446 | The following options control specific optimizations. They are either | |
12447 | activated by @option{-O} options or are related to ones that are. You | |
12448 | can use the following flags in the rare cases when ``fine-tuning'' of | |
12449 | optimizations to be performed is desired. | |
12450 | ||
12451 | @table @gcctabopt | |
d77de738 ML |
12452 | @opindex fno-defer-pop |
12453 | @opindex fdefer-pop | |
ddf6fe37 | 12454 | @item -fno-defer-pop |
d77de738 ML |
12455 | For machines that must pop arguments after a function call, always pop |
12456 | the arguments as soon as each function returns. | |
12457 | At levels @option{-O1} and higher, @option{-fdefer-pop} is the default; | |
12458 | this allows the compiler to let arguments accumulate on the stack for several | |
12459 | function calls and pop them all at once. | |
12460 | ||
d77de738 | 12461 | @opindex fforward-propagate |
ddf6fe37 | 12462 | @item -fforward-propagate |
d77de738 ML |
12463 | Perform a forward propagation pass on RTL@. The pass tries to combine two |
12464 | instructions and checks if the result can be simplified. If loop unrolling | |
12465 | is active, two passes are performed and the second is scheduled after | |
12466 | loop unrolling. | |
12467 | ||
12468 | This option is enabled by default at optimization levels @option{-O1}, | |
12469 | @option{-O2}, @option{-O3}, @option{-Os}. | |
12470 | ||
d77de738 | 12471 | @opindex ffp-contract |
ddf6fe37 | 12472 | @item -ffp-contract=@var{style} |
d77de738 ML |
12473 | @option{-ffp-contract=off} disables floating-point expression contraction. |
12474 | @option{-ffp-contract=fast} enables floating-point expression contraction | |
12475 | such as forming of fused multiply-add operations if the target has | |
12476 | native support for them. | |
12477 | @option{-ffp-contract=on} enables floating-point expression contraction | |
1c1dd396 AM |
12478 | if allowed by the language standard. This is implemented for C and C++, |
12479 | where it enables contraction within one expression, but not across | |
12480 | different statements. | |
d77de738 | 12481 | |
1c1dd396 AM |
12482 | The default is @option{-ffp-contract=off} for C in a standards compliant mode |
12483 | (@option{-std=c11} or similar), @option{-ffp-contract=fast} otherwise. | |
d77de738 | 12484 | |
d77de738 | 12485 | @opindex fomit-frame-pointer |
ddf6fe37 | 12486 | @item -fomit-frame-pointer |
d77de738 ML |
12487 | Omit the frame pointer in functions that don't need one. This avoids the |
12488 | instructions to save, set up and restore the frame pointer; on many targets | |
12489 | it also makes an extra register available. | |
12490 | ||
12491 | On some targets this flag has no effect because the standard calling sequence | |
12492 | always uses a frame pointer, so it cannot be omitted. | |
12493 | ||
12494 | Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer | |
12495 | is used in all functions. Several targets always omit the frame pointer in | |
12496 | leaf functions. | |
12497 | ||
12498 | Enabled by default at @option{-O1} and higher. | |
12499 | ||
d77de738 | 12500 | @opindex foptimize-sibling-calls |
ddf6fe37 | 12501 | @item -foptimize-sibling-calls |
d77de738 ML |
12502 | Optimize sibling and tail recursive calls. |
12503 | ||
12504 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12505 | ||
d77de738 | 12506 | @opindex foptimize-strlen |
ddf6fe37 | 12507 | @item -foptimize-strlen |
d77de738 ML |
12508 | Optimize various standard C string functions (e.g.@: @code{strlen}, |
12509 | @code{strchr} or @code{strcpy}) and | |
12510 | their @code{_FORTIFY_SOURCE} counterparts into faster alternatives. | |
12511 | ||
12512 | Enabled at levels @option{-O2}, @option{-O3}. | |
12513 | ||
1ff6d9f7 AO |
12514 | @opindex finline-stringops |
12515 | @item -finline-stringops[=@var{fn}] | |
12516 | Expand memory and string operations (for now, only @code{memset}) | |
12517 | inline, even when the length is variable or big enough as to require | |
12518 | looping. This is most useful along with @option{-ffreestanding} and | |
12519 | @option{-fno-builtin}. | |
12520 | ||
12521 | In some circumstances, it enables the compiler to generate code that | |
12522 | takes advantage of known alignment and length multipliers, but even then | |
12523 | it may be less efficient than optimized runtime implementations, and | |
12524 | grow code size so much that even a less performant but shared | |
12525 | implementation runs faster due to better use of code caches. This | |
12526 | option is disabled by default. | |
12527 | ||
d77de738 ML |
12528 | @opindex fno-inline |
12529 | @opindex finline | |
ddf6fe37 | 12530 | @item -fno-inline |
d77de738 ML |
12531 | Do not expand any functions inline apart from those marked with |
12532 | the @code{always_inline} attribute. This is the default when not | |
12533 | optimizing. | |
12534 | ||
12535 | Single functions can be exempted from inlining by marking them | |
12536 | with the @code{noinline} attribute. | |
12537 | ||
d77de738 | 12538 | @opindex finline-small-functions |
ddf6fe37 | 12539 | @item -finline-small-functions |
d77de738 ML |
12540 | Integrate functions into their callers when their body is smaller than expected |
12541 | function call code (so overall size of program gets smaller). The compiler | |
12542 | heuristically decides which functions are simple enough to be worth integrating | |
12543 | in this way. This inlining applies to all functions, even those not declared | |
12544 | inline. | |
12545 | ||
12546 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12547 | ||
d77de738 | 12548 | @opindex findirect-inlining |
ddf6fe37 | 12549 | @item -findirect-inlining |
d77de738 ML |
12550 | Inline also indirect calls that are discovered to be known at compile |
12551 | time thanks to previous inlining. This option has any effect only | |
12552 | when inlining itself is turned on by the @option{-finline-functions} | |
12553 | or @option{-finline-small-functions} options. | |
12554 | ||
12555 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12556 | ||
d77de738 | 12557 | @opindex finline-functions |
ddf6fe37 | 12558 | @item -finline-functions |
d77de738 ML |
12559 | Consider all functions for inlining, even if they are not declared inline. |
12560 | The compiler heuristically decides which functions are worth integrating | |
12561 | in this way. | |
12562 | ||
12563 | If all calls to a given function are integrated, and the function is | |
12564 | declared @code{static}, then the function is normally not output as | |
12565 | assembler code in its own right. | |
12566 | ||
12567 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled | |
12568 | by @option{-fprofile-use} and @option{-fauto-profile}. | |
12569 | ||
d77de738 | 12570 | @opindex finline-functions-called-once |
ddf6fe37 | 12571 | @item -finline-functions-called-once |
d77de738 ML |
12572 | Consider all @code{static} functions called once for inlining into their |
12573 | caller even if they are not marked @code{inline}. If a call to a given | |
12574 | function is integrated, then the function is not output as assembler code | |
12575 | in its own right. | |
12576 | ||
12577 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os}, | |
12578 | but not @option{-Og}. | |
12579 | ||
d77de738 | 12580 | @opindex fearly-inlining |
ddf6fe37 | 12581 | @item -fearly-inlining |
d77de738 ML |
12582 | Inline functions marked by @code{always_inline} and functions whose body seems |
12583 | smaller than the function call overhead early before doing | |
12584 | @option{-fprofile-generate} instrumentation and real inlining pass. Doing so | |
12585 | makes profiling significantly cheaper and usually inlining faster on programs | |
12586 | having large chains of nested wrapper functions. | |
12587 | ||
12588 | Enabled by default. | |
12589 | ||
d77de738 | 12590 | @opindex fipa-sra |
ddf6fe37 | 12591 | @item -fipa-sra |
d77de738 ML |
12592 | Perform interprocedural scalar replacement of aggregates, removal of |
12593 | unused parameters and replacement of parameters passed by reference | |
12594 | by parameters passed by value. | |
12595 | ||
12596 | Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}. | |
12597 | ||
d77de738 | 12598 | @opindex finline-limit |
ddf6fe37 | 12599 | @item -finline-limit=@var{n} |
d77de738 ML |
12600 | By default, GCC limits the size of functions that can be inlined. This flag |
12601 | allows coarse control of this limit. @var{n} is the size of functions that | |
12602 | can be inlined in number of pseudo instructions. | |
12603 | ||
12604 | Inlining is actually controlled by a number of parameters, which may be | |
12605 | specified individually by using @option{--param @var{name}=@var{value}}. | |
12606 | The @option{-finline-limit=@var{n}} option sets some of these parameters | |
12607 | as follows: | |
12608 | ||
12609 | @table @gcctabopt | |
12610 | @item max-inline-insns-single | |
12611 | is set to @var{n}/2. | |
12612 | @item max-inline-insns-auto | |
12613 | is set to @var{n}/2. | |
12614 | @end table | |
12615 | ||
12616 | See below for a documentation of the individual | |
12617 | parameters controlling inlining and for the defaults of these parameters. | |
12618 | ||
12619 | @emph{Note:} there may be no value to @option{-finline-limit} that results | |
12620 | in default behavior. | |
12621 | ||
12622 | @emph{Note:} pseudo instruction represents, in this particular context, an | |
12623 | abstract measurement of function's size. In no way does it represent a count | |
12624 | of assembly instructions and as such its exact meaning might change from one | |
12625 | release to an another. | |
12626 | ||
d77de738 ML |
12627 | @opindex fno-keep-inline-dllexport |
12628 | @opindex fkeep-inline-dllexport | |
ddf6fe37 | 12629 | @item -fno-keep-inline-dllexport |
d77de738 ML |
12630 | This is a more fine-grained version of @option{-fkeep-inline-functions}, |
12631 | which applies only to functions that are declared using the @code{dllexport} | |
12632 | attribute or declspec. @xref{Function Attributes,,Declaring Attributes of | |
12633 | Functions}. | |
12634 | ||
d77de738 | 12635 | @opindex fkeep-inline-functions |
ddf6fe37 | 12636 | @item -fkeep-inline-functions |
d77de738 ML |
12637 | In C, emit @code{static} functions that are declared @code{inline} |
12638 | into the object file, even if the function has been inlined into all | |
12639 | of its callers. This switch does not affect functions using the | |
12640 | @code{extern inline} extension in GNU C90@. In C++, emit any and all | |
12641 | inline functions into the object file. | |
12642 | ||
d77de738 | 12643 | @opindex fkeep-static-functions |
ddf6fe37 | 12644 | @item -fkeep-static-functions |
d77de738 ML |
12645 | Emit @code{static} functions into the object file, even if the function |
12646 | is never used. | |
12647 | ||
d77de738 | 12648 | @opindex fkeep-static-consts |
ddf6fe37 | 12649 | @item -fkeep-static-consts |
d77de738 ML |
12650 | Emit variables declared @code{static const} when optimization isn't turned |
12651 | on, even if the variables aren't referenced. | |
12652 | ||
12653 | GCC enables this option by default. If you want to force the compiler to | |
12654 | check if a variable is referenced, regardless of whether or not | |
12655 | optimization is turned on, use the @option{-fno-keep-static-consts} option. | |
12656 | ||
d77de738 | 12657 | @opindex fmerge-constants |
ddf6fe37 | 12658 | @item -fmerge-constants |
d77de738 ML |
12659 | Attempt to merge identical constants (string constants and floating-point |
12660 | constants) across compilation units. | |
12661 | ||
12662 | This option is the default for optimized compilation if the assembler and | |
12663 | linker support it. Use @option{-fno-merge-constants} to inhibit this | |
12664 | behavior. | |
12665 | ||
12666 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
12667 | ||
d77de738 | 12668 | @opindex fmerge-all-constants |
ddf6fe37 | 12669 | @item -fmerge-all-constants |
d77de738 ML |
12670 | Attempt to merge identical constants and identical variables. |
12671 | ||
12672 | This option implies @option{-fmerge-constants}. In addition to | |
12673 | @option{-fmerge-constants} this considers e.g.@: even constant initialized | |
12674 | arrays or initialized constant variables with integral or floating-point | |
12675 | types. Languages like C or C++ require each variable, including multiple | |
12676 | instances of the same variable in recursive calls, to have distinct locations, | |
12677 | so using this option results in non-conforming | |
12678 | behavior. | |
12679 | ||
d77de738 | 12680 | @opindex fmodulo-sched |
ddf6fe37 | 12681 | @item -fmodulo-sched |
d77de738 ML |
12682 | Perform swing modulo scheduling immediately before the first scheduling |
12683 | pass. This pass looks at innermost loops and reorders their | |
12684 | instructions by overlapping different iterations. | |
12685 | ||
d77de738 | 12686 | @opindex fmodulo-sched-allow-regmoves |
ddf6fe37 | 12687 | @item -fmodulo-sched-allow-regmoves |
d77de738 ML |
12688 | Perform more aggressive SMS-based modulo scheduling with register moves |
12689 | allowed. By setting this flag certain anti-dependences edges are | |
12690 | deleted, which triggers the generation of reg-moves based on the | |
12691 | life-range analysis. This option is effective only with | |
12692 | @option{-fmodulo-sched} enabled. | |
12693 | ||
d77de738 ML |
12694 | @opindex fno-branch-count-reg |
12695 | @opindex fbranch-count-reg | |
ddf6fe37 | 12696 | @item -fno-branch-count-reg |
d77de738 ML |
12697 | Disable the optimization pass that scans for opportunities to use |
12698 | ``decrement and branch'' instructions on a count register instead of | |
12699 | instruction sequences that decrement a register, compare it against zero, and | |
12700 | then branch based upon the result. This option is only meaningful on | |
12701 | architectures that support such instructions, which include x86, PowerPC, | |
12702 | IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option | |
12703 | doesn't remove the decrement and branch instructions from the generated | |
12704 | instruction stream introduced by other optimization passes. | |
12705 | ||
12706 | The default is @option{-fbranch-count-reg} at @option{-O1} and higher, | |
12707 | except for @option{-Og}. | |
12708 | ||
d77de738 ML |
12709 | @opindex fno-function-cse |
12710 | @opindex ffunction-cse | |
ddf6fe37 | 12711 | @item -fno-function-cse |
d77de738 ML |
12712 | Do not put function addresses in registers; make each instruction that |
12713 | calls a constant function contain the function's address explicitly. | |
12714 | ||
12715 | This option results in less efficient code, but some strange hacks | |
12716 | that alter the assembler output may be confused by the optimizations | |
12717 | performed when this option is not used. | |
12718 | ||
12719 | The default is @option{-ffunction-cse} | |
12720 | ||
d77de738 ML |
12721 | @opindex fno-zero-initialized-in-bss |
12722 | @opindex fzero-initialized-in-bss | |
ddf6fe37 | 12723 | @item -fno-zero-initialized-in-bss |
d77de738 ML |
12724 | If the target supports a BSS section, GCC by default puts variables that |
12725 | are initialized to zero into BSS@. This can save space in the resulting | |
12726 | code. | |
12727 | ||
12728 | This option turns off this behavior because some programs explicitly | |
12729 | rely on variables going to the data section---e.g., so that the | |
12730 | resulting executable can find the beginning of that section and/or make | |
12731 | assumptions based on that. | |
12732 | ||
12733 | The default is @option{-fzero-initialized-in-bss}. | |
12734 | ||
d77de738 | 12735 | @opindex fthread-jumps |
ddf6fe37 | 12736 | @item -fthread-jumps |
d77de738 ML |
12737 | Perform optimizations that check to see if a jump branches to a |
12738 | location where another comparison subsumed by the first is found. If | |
12739 | so, the first branch is redirected to either the destination of the | |
12740 | second branch or a point immediately following it, depending on whether | |
12741 | the condition is known to be true or false. | |
12742 | ||
12743 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
12744 | ||
d77de738 | 12745 | @opindex fsplit-wide-types |
ddf6fe37 | 12746 | @item -fsplit-wide-types |
d77de738 ML |
12747 | When using a type that occupies multiple registers, such as @code{long |
12748 | long} on a 32-bit system, split the registers apart and allocate them | |
12749 | independently. This normally generates better code for those types, | |
12750 | but may make debugging more difficult. | |
12751 | ||
12752 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, | |
12753 | @option{-Os}. | |
12754 | ||
d77de738 | 12755 | @opindex fsplit-wide-types-early |
ddf6fe37 | 12756 | @item -fsplit-wide-types-early |
d77de738 ML |
12757 | Fully split wide types early, instead of very late. |
12758 | This option has no effect unless @option{-fsplit-wide-types} is turned on. | |
12759 | ||
12760 | This is the default on some targets. | |
12761 | ||
d77de738 | 12762 | @opindex fcse-follow-jumps |
ddf6fe37 | 12763 | @item -fcse-follow-jumps |
d77de738 ML |
12764 | In common subexpression elimination (CSE), scan through jump instructions |
12765 | when the target of the jump is not reached by any other path. For | |
12766 | example, when CSE encounters an @code{if} statement with an | |
12767 | @code{else} clause, CSE follows the jump when the condition | |
12768 | tested is false. | |
12769 | ||
12770 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12771 | ||
d77de738 | 12772 | @opindex fcse-skip-blocks |
ddf6fe37 | 12773 | @item -fcse-skip-blocks |
d77de738 ML |
12774 | This is similar to @option{-fcse-follow-jumps}, but causes CSE to |
12775 | follow jumps that conditionally skip over blocks. When CSE | |
12776 | encounters a simple @code{if} statement with no else clause, | |
12777 | @option{-fcse-skip-blocks} causes CSE to follow the jump around the | |
12778 | body of the @code{if}. | |
12779 | ||
12780 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12781 | ||
d77de738 | 12782 | @opindex frerun-cse-after-loop |
ddf6fe37 | 12783 | @item -frerun-cse-after-loop |
d77de738 ML |
12784 | Re-run common subexpression elimination after loop optimizations are |
12785 | performed. | |
12786 | ||
12787 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12788 | ||
d77de738 | 12789 | @opindex fgcse |
ddf6fe37 | 12790 | @item -fgcse |
d77de738 ML |
12791 | Perform a global common subexpression elimination pass. |
12792 | This pass also performs global constant and copy propagation. | |
12793 | ||
12794 | @emph{Note:} When compiling a program using computed gotos, a GCC | |
12795 | extension, you may get better run-time performance if you disable | |
12796 | the global common subexpression elimination pass by adding | |
12797 | @option{-fno-gcse} to the command line. | |
12798 | ||
12799 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12800 | ||
d77de738 | 12801 | @opindex fgcse-lm |
ddf6fe37 | 12802 | @item -fgcse-lm |
d77de738 ML |
12803 | When @option{-fgcse-lm} is enabled, global common subexpression elimination |
12804 | attempts to move loads that are only killed by stores into themselves. This | |
12805 | allows a loop containing a load/store sequence to be changed to a load outside | |
12806 | the loop, and a copy/store within the loop. | |
12807 | ||
12808 | Enabled by default when @option{-fgcse} is enabled. | |
12809 | ||
d77de738 | 12810 | @opindex fgcse-sm |
ddf6fe37 | 12811 | @item -fgcse-sm |
d77de738 ML |
12812 | When @option{-fgcse-sm} is enabled, a store motion pass is run after |
12813 | global common subexpression elimination. This pass attempts to move | |
12814 | stores out of loops. When used in conjunction with @option{-fgcse-lm}, | |
12815 | loops containing a load/store sequence can be changed to a load before | |
12816 | the loop and a store after the loop. | |
12817 | ||
12818 | Not enabled at any optimization level. | |
12819 | ||
d77de738 | 12820 | @opindex fgcse-las |
ddf6fe37 | 12821 | @item -fgcse-las |
d77de738 ML |
12822 | When @option{-fgcse-las} is enabled, the global common subexpression |
12823 | elimination pass eliminates redundant loads that come after stores to the | |
12824 | same memory location (both partial and full redundancies). | |
12825 | ||
12826 | Not enabled at any optimization level. | |
12827 | ||
d77de738 | 12828 | @opindex fgcse-after-reload |
ddf6fe37 | 12829 | @item -fgcse-after-reload |
d77de738 ML |
12830 | When @option{-fgcse-after-reload} is enabled, a redundant load elimination |
12831 | pass is performed after reload. The purpose of this pass is to clean up | |
12832 | redundant spilling. | |
12833 | ||
12834 | Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}. | |
12835 | ||
d77de738 | 12836 | @opindex faggressive-loop-optimizations |
ddf6fe37 | 12837 | @item -faggressive-loop-optimizations |
d77de738 ML |
12838 | This option tells the loop optimizer to use language constraints to |
12839 | derive bounds for the number of iterations of a loop. This assumes that | |
12840 | loop code does not invoke undefined behavior by for example causing signed | |
12841 | integer overflows or out-of-bound array accesses. The bounds for the | |
12842 | number of iterations of a loop are used to guide loop unrolling and peeling | |
12843 | and loop exit test optimizations. | |
12844 | This option is enabled by default. | |
12845 | ||
d77de738 | 12846 | @opindex funconstrained-commons |
ddf6fe37 | 12847 | @item -funconstrained-commons |
d77de738 ML |
12848 | This option tells the compiler that variables declared in common blocks |
12849 | (e.g.@: Fortran) may later be overridden with longer trailing arrays. This | |
12850 | prevents certain optimizations that depend on knowing the array bounds. | |
12851 | ||
d77de738 | 12852 | @opindex fcrossjumping |
ddf6fe37 | 12853 | @item -fcrossjumping |
d77de738 ML |
12854 | Perform cross-jumping transformation. |
12855 | This transformation unifies equivalent code and saves code size. The | |
12856 | resulting code may or may not perform better than without cross-jumping. | |
12857 | ||
12858 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12859 | ||
d77de738 | 12860 | @opindex fauto-inc-dec |
ddf6fe37 | 12861 | @item -fauto-inc-dec |
d77de738 ML |
12862 | Combine increments or decrements of addresses with memory accesses. |
12863 | This pass is always skipped on architectures that do not have | |
12864 | instructions to support this. Enabled by default at @option{-O1} and | |
12865 | higher on architectures that support this. | |
12866 | ||
d77de738 | 12867 | @opindex fdce |
ddf6fe37 | 12868 | @item -fdce |
d77de738 ML |
12869 | Perform dead code elimination (DCE) on RTL@. |
12870 | Enabled by default at @option{-O1} and higher. | |
12871 | ||
d77de738 | 12872 | @opindex fdse |
ddf6fe37 | 12873 | @item -fdse |
d77de738 ML |
12874 | Perform dead store elimination (DSE) on RTL@. |
12875 | Enabled by default at @option{-O1} and higher. | |
12876 | ||
d77de738 | 12877 | @opindex fif-conversion |
ddf6fe37 | 12878 | @item -fif-conversion |
d77de738 ML |
12879 | Attempt to transform conditional jumps into branch-less equivalents. This |
12880 | includes use of conditional moves, min, max, set flags and abs instructions, and | |
12881 | some tricks doable by standard arithmetics. The use of conditional execution | |
12882 | on chips where it is available is controlled by @option{-fif-conversion2}. | |
12883 | ||
12884 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but | |
12885 | not with @option{-Og}. | |
12886 | ||
d77de738 | 12887 | @opindex fif-conversion2 |
ddf6fe37 | 12888 | @item -fif-conversion2 |
d77de738 ML |
12889 | Use conditional execution (where available) to transform conditional jumps into |
12890 | branch-less equivalents. | |
12891 | ||
12892 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but | |
12893 | not with @option{-Og}. | |
12894 | ||
d77de738 | 12895 | @opindex fdeclone-ctor-dtor |
ddf6fe37 | 12896 | @item -fdeclone-ctor-dtor |
d77de738 ML |
12897 | The C++ ABI requires multiple entry points for constructors and |
12898 | destructors: one for a base subobject, one for a complete object, and | |
12899 | one for a virtual destructor that calls operator delete afterwards. | |
12900 | For a hierarchy with virtual bases, the base and complete variants are | |
12901 | clones, which means two copies of the function. With this option, the | |
12902 | base and complete variants are changed to be thunks that call a common | |
12903 | implementation. | |
12904 | ||
12905 | Enabled by @option{-Os}. | |
12906 | ||
d77de738 | 12907 | @opindex fdelete-null-pointer-checks |
ddf6fe37 | 12908 | @item -fdelete-null-pointer-checks |
d77de738 ML |
12909 | Assume that programs cannot safely dereference null pointers, and that |
12910 | no code or data element resides at address zero. | |
12911 | This option enables simple constant | |
12912 | folding optimizations at all optimization levels. In addition, other | |
12913 | optimization passes in GCC use this flag to control global dataflow | |
12914 | analyses that eliminate useless checks for null pointers; these assume | |
12915 | that a memory access to address zero always results in a trap, so | |
12916 | that if a pointer is checked after it has already been dereferenced, | |
12917 | it cannot be null. | |
12918 | ||
12919 | Note however that in some environments this assumption is not true. | |
12920 | Use @option{-fno-delete-null-pointer-checks} to disable this optimization | |
12921 | for programs that depend on that behavior. | |
12922 | ||
12923 | This option is enabled by default on most targets. On Nios II ELF, it | |
12924 | defaults to off. On AVR and MSP430, this option is completely disabled. | |
12925 | ||
12926 | Passes that use the dataflow information | |
12927 | are enabled independently at different optimization levels. | |
12928 | ||
d77de738 | 12929 | @opindex fdevirtualize |
ddf6fe37 | 12930 | @item -fdevirtualize |
d77de738 ML |
12931 | Attempt to convert calls to virtual functions to direct calls. This |
12932 | is done both within a procedure and interprocedurally as part of | |
12933 | indirect inlining (@option{-findirect-inlining}) and interprocedural constant | |
12934 | propagation (@option{-fipa-cp}). | |
12935 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12936 | ||
d77de738 | 12937 | @opindex fdevirtualize-speculatively |
ddf6fe37 | 12938 | @item -fdevirtualize-speculatively |
d77de738 ML |
12939 | Attempt to convert calls to virtual functions to speculative direct calls. |
12940 | Based on the analysis of the type inheritance graph, determine for a given call | |
12941 | the set of likely targets. If the set is small, preferably of size 1, change | |
12942 | the call into a conditional deciding between direct and indirect calls. The | |
12943 | speculative calls enable more optimizations, such as inlining. When they seem | |
12944 | useless after further optimization, they are converted back into original form. | |
12945 | ||
d77de738 | 12946 | @opindex fdevirtualize-at-ltrans |
ddf6fe37 | 12947 | @item -fdevirtualize-at-ltrans |
d77de738 ML |
12948 | Stream extra information needed for aggressive devirtualization when running |
12949 | the link-time optimizer in local transformation mode. | |
12950 | This option enables more devirtualization but | |
12951 | significantly increases the size of streamed data. For this reason it is | |
12952 | disabled by default. | |
12953 | ||
d77de738 | 12954 | @opindex fexpensive-optimizations |
ddf6fe37 | 12955 | @item -fexpensive-optimizations |
d77de738 ML |
12956 | Perform a number of minor optimizations that are relatively expensive. |
12957 | ||
12958 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12959 | ||
d77de738 | 12960 | @opindex free |
ddf6fe37 | 12961 | @item -free |
d77de738 ML |
12962 | Attempt to remove redundant extension instructions. This is especially |
12963 | helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit | |
12964 | registers after writing to their lower 32-bit half. | |
12965 | ||
88ae53a3 LC |
12966 | Enabled for Alpha, AArch64, LoongArch, PowerPC, RISC-V, SPARC, h83000 and x86 at |
12967 | levels @option{-O2}, @option{-O3}, @option{-Os}. | |
d77de738 | 12968 | |
d77de738 ML |
12969 | @opindex fno-lifetime-dse |
12970 | @opindex flifetime-dse | |
ddf6fe37 | 12971 | @item -fno-lifetime-dse |
d77de738 ML |
12972 | In C++ the value of an object is only affected by changes within its |
12973 | lifetime: when the constructor begins, the object has an indeterminate | |
12974 | value, and any changes during the lifetime of the object are dead when | |
12975 | the object is destroyed. Normally dead store elimination will take | |
12976 | advantage of this; if your code relies on the value of the object | |
12977 | storage persisting beyond the lifetime of the object, you can use this | |
12978 | flag to disable this optimization. To preserve stores before the | |
12979 | constructor starts (e.g.@: because your operator new clears the object | |
12980 | storage) but still treat the object as dead after the destructor, you | |
12981 | can use @option{-flifetime-dse=1}. The default behavior can be | |
12982 | explicitly selected with @option{-flifetime-dse=2}. | |
12983 | @option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}. | |
12984 | ||
d77de738 | 12985 | @opindex flive-range-shrinkage |
ddf6fe37 | 12986 | @item -flive-range-shrinkage |
d77de738 ML |
12987 | Attempt to decrease register pressure through register live range |
12988 | shrinkage. This is helpful for fast processors with small or moderate | |
12989 | size register sets. | |
12990 | ||
d77de738 | 12991 | @opindex fira-algorithm |
ddf6fe37 | 12992 | @item -fira-algorithm=@var{algorithm} |
d77de738 ML |
12993 | Use the specified coloring algorithm for the integrated register |
12994 | allocator. The @var{algorithm} argument can be @samp{priority}, which | |
12995 | specifies Chow's priority coloring, or @samp{CB}, which specifies | |
12996 | Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented | |
12997 | for all architectures, but for those targets that do support it, it is | |
12998 | the default because it generates better code. | |
12999 | ||
d77de738 | 13000 | @opindex fira-region |
ddf6fe37 | 13001 | @item -fira-region=@var{region} |
d77de738 ML |
13002 | Use specified regions for the integrated register allocator. The |
13003 | @var{region} argument should be one of the following: | |
13004 | ||
13005 | @table @samp | |
13006 | ||
13007 | @item all | |
13008 | Use all loops as register allocation regions. | |
13009 | This can give the best results for machines with a small and/or | |
13010 | irregular register set. | |
13011 | ||
13012 | @item mixed | |
13013 | Use all loops except for loops with small register pressure | |
13014 | as the regions. This value usually gives | |
13015 | the best results in most cases and for most architectures, | |
13016 | and is enabled by default when compiling with optimization for speed | |
13017 | (@option{-O}, @option{-O2}, @dots{}). | |
13018 | ||
13019 | @item one | |
13020 | Use all functions as a single region. | |
13021 | This typically results in the smallest code size, and is enabled by default for | |
13022 | @option{-Os} or @option{-O0}. | |
13023 | ||
13024 | @end table | |
13025 | ||
d77de738 | 13026 | @opindex fira-hoist-pressure |
ddf6fe37 | 13027 | @item -fira-hoist-pressure |
d77de738 ML |
13028 | Use IRA to evaluate register pressure in the code hoisting pass for |
13029 | decisions to hoist expressions. This option usually results in smaller | |
13030 | code, but it can slow the compiler down. | |
13031 | ||
13032 | This option is enabled at level @option{-Os} for all targets. | |
13033 | ||
d77de738 | 13034 | @opindex fira-loop-pressure |
ddf6fe37 | 13035 | @item -fira-loop-pressure |
d77de738 ML |
13036 | Use IRA to evaluate register pressure in loops for decisions to move |
13037 | loop invariants. This option usually results in generation | |
13038 | of faster and smaller code on machines with large register files (>= 32 | |
13039 | registers), but it can slow the compiler down. | |
13040 | ||
13041 | This option is enabled at level @option{-O3} for some targets. | |
13042 | ||
d77de738 ML |
13043 | @opindex fno-ira-share-save-slots |
13044 | @opindex fira-share-save-slots | |
ddf6fe37 | 13045 | @item -fno-ira-share-save-slots |
d77de738 ML |
13046 | Disable sharing of stack slots used for saving call-used hard |
13047 | registers living through a call. Each hard register gets a | |
13048 | separate stack slot, and as a result function stack frames are | |
13049 | larger. | |
13050 | ||
d77de738 ML |
13051 | @opindex fno-ira-share-spill-slots |
13052 | @opindex fira-share-spill-slots | |
ddf6fe37 | 13053 | @item -fno-ira-share-spill-slots |
d77de738 ML |
13054 | Disable sharing of stack slots allocated for pseudo-registers. Each |
13055 | pseudo-register that does not get a hard register gets a separate | |
13056 | stack slot, and as a result function stack frames are larger. | |
13057 | ||
d77de738 | 13058 | @opindex flra-remat |
ddf6fe37 | 13059 | @item -flra-remat |
d77de738 ML |
13060 | Enable CFG-sensitive rematerialization in LRA. Instead of loading |
13061 | values of spilled pseudos, LRA tries to rematerialize (recalculate) | |
13062 | values if it is profitable. | |
13063 | ||
13064 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13065 | ||
d77de738 | 13066 | @opindex fdelayed-branch |
ddf6fe37 | 13067 | @item -fdelayed-branch |
d77de738 ML |
13068 | If supported for the target machine, attempt to reorder instructions |
13069 | to exploit instruction slots available after delayed branch | |
13070 | instructions. | |
13071 | ||
13072 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, | |
13073 | but not at @option{-Og}. | |
13074 | ||
d77de738 | 13075 | @opindex fschedule-insns |
ddf6fe37 | 13076 | @item -fschedule-insns |
d77de738 ML |
13077 | If supported for the target machine, attempt to reorder instructions to |
13078 | eliminate execution stalls due to required data being unavailable. This | |
13079 | helps machines that have slow floating point or memory load instructions | |
13080 | by allowing other instructions to be issued until the result of the load | |
13081 | or floating-point instruction is required. | |
13082 | ||
13083 | Enabled at levels @option{-O2}, @option{-O3}. | |
13084 | ||
d77de738 | 13085 | @opindex fschedule-insns2 |
ddf6fe37 | 13086 | @item -fschedule-insns2 |
d77de738 ML |
13087 | Similar to @option{-fschedule-insns}, but requests an additional pass of |
13088 | instruction scheduling after register allocation has been done. This is | |
13089 | especially useful on machines with a relatively small number of | |
13090 | registers and where memory load instructions take more than one cycle. | |
13091 | ||
13092 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13093 | ||
d77de738 ML |
13094 | @opindex fno-sched-interblock |
13095 | @opindex fsched-interblock | |
ddf6fe37 | 13096 | @item -fno-sched-interblock |
d77de738 ML |
13097 | Disable instruction scheduling across basic blocks, which |
13098 | is normally enabled when scheduling before register allocation, i.e.@: | |
13099 | with @option{-fschedule-insns} or at @option{-O2} or higher. | |
13100 | ||
d77de738 ML |
13101 | @opindex fno-sched-spec |
13102 | @opindex fsched-spec | |
ddf6fe37 | 13103 | @item -fno-sched-spec |
d77de738 ML |
13104 | Disable speculative motion of non-load instructions, which |
13105 | is normally enabled when scheduling before register allocation, i.e.@: | |
13106 | with @option{-fschedule-insns} or at @option{-O2} or higher. | |
13107 | ||
d77de738 | 13108 | @opindex fsched-pressure |
ddf6fe37 | 13109 | @item -fsched-pressure |
d77de738 ML |
13110 | Enable register pressure sensitive insn scheduling before register |
13111 | allocation. This only makes sense when scheduling before register | |
13112 | allocation is enabled, i.e.@: with @option{-fschedule-insns} or at | |
13113 | @option{-O2} or higher. Usage of this option can improve the | |
13114 | generated code and decrease its size by preventing register pressure | |
13115 | increase above the number of available hard registers and subsequent | |
13116 | spills in register allocation. | |
13117 | ||
d77de738 | 13118 | @opindex fsched-spec-load |
ddf6fe37 | 13119 | @item -fsched-spec-load |
d77de738 ML |
13120 | Allow speculative motion of some load instructions. This only makes |
13121 | sense when scheduling before register allocation, i.e.@: with | |
13122 | @option{-fschedule-insns} or at @option{-O2} or higher. | |
13123 | ||
d77de738 | 13124 | @opindex fsched-spec-load-dangerous |
ddf6fe37 | 13125 | @item -fsched-spec-load-dangerous |
d77de738 ML |
13126 | Allow speculative motion of more load instructions. This only makes |
13127 | sense when scheduling before register allocation, i.e.@: with | |
13128 | @option{-fschedule-insns} or at @option{-O2} or higher. | |
13129 | ||
ddf6fe37 | 13130 | @opindex fsched-stalled-insns |
d77de738 ML |
13131 | @item -fsched-stalled-insns |
13132 | @itemx -fsched-stalled-insns=@var{n} | |
d77de738 ML |
13133 | Define how many insns (if any) can be moved prematurely from the queue |
13134 | of stalled insns into the ready list during the second scheduling pass. | |
13135 | @option{-fno-sched-stalled-insns} means that no insns are moved | |
13136 | prematurely, @option{-fsched-stalled-insns=0} means there is no limit | |
13137 | on how many queued insns can be moved prematurely. | |
13138 | @option{-fsched-stalled-insns} without a value is equivalent to | |
13139 | @option{-fsched-stalled-insns=1}. | |
13140 | ||
ddf6fe37 | 13141 | @opindex fsched-stalled-insns-dep |
d77de738 ML |
13142 | @item -fsched-stalled-insns-dep |
13143 | @itemx -fsched-stalled-insns-dep=@var{n} | |
d77de738 ML |
13144 | Define how many insn groups (cycles) are examined for a dependency |
13145 | on a stalled insn that is a candidate for premature removal from the queue | |
13146 | of stalled insns. This has an effect only during the second scheduling pass, | |
13147 | and only if @option{-fsched-stalled-insns} is used. | |
13148 | @option{-fno-sched-stalled-insns-dep} is equivalent to | |
13149 | @option{-fsched-stalled-insns-dep=0}. | |
13150 | @option{-fsched-stalled-insns-dep} without a value is equivalent to | |
13151 | @option{-fsched-stalled-insns-dep=1}. | |
13152 | ||
d77de738 | 13153 | @opindex fsched2-use-superblocks |
ddf6fe37 | 13154 | @item -fsched2-use-superblocks |
d77de738 ML |
13155 | When scheduling after register allocation, use superblock scheduling. |
13156 | This allows motion across basic block boundaries, | |
13157 | resulting in faster schedules. This option is experimental, as not all machine | |
13158 | descriptions used by GCC model the CPU closely enough to avoid unreliable | |
13159 | results from the algorithm. | |
13160 | ||
13161 | This only makes sense when scheduling after register allocation, i.e.@: with | |
13162 | @option{-fschedule-insns2} or at @option{-O2} or higher. | |
13163 | ||
d77de738 | 13164 | @opindex fsched-group-heuristic |
ddf6fe37 | 13165 | @item -fsched-group-heuristic |
d77de738 ML |
13166 | Enable the group heuristic in the scheduler. This heuristic favors |
13167 | the instruction that belongs to a schedule group. This is enabled | |
13168 | by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns} | |
13169 | or @option{-fschedule-insns2} or at @option{-O2} or higher. | |
13170 | ||
d77de738 | 13171 | @opindex fsched-critical-path-heuristic |
ddf6fe37 | 13172 | @item -fsched-critical-path-heuristic |
d77de738 ML |
13173 | Enable the critical-path heuristic in the scheduler. This heuristic favors |
13174 | instructions on the critical path. This is enabled by default when | |
13175 | scheduling is enabled, i.e.@: with @option{-fschedule-insns} | |
13176 | or @option{-fschedule-insns2} or at @option{-O2} or higher. | |
13177 | ||
d77de738 | 13178 | @opindex fsched-spec-insn-heuristic |
ddf6fe37 | 13179 | @item -fsched-spec-insn-heuristic |
d77de738 ML |
13180 | Enable the speculative instruction heuristic in the scheduler. This |
13181 | heuristic favors speculative instructions with greater dependency weakness. | |
13182 | This is enabled by default when scheduling is enabled, i.e.@: | |
13183 | with @option{-fschedule-insns} or @option{-fschedule-insns2} | |
13184 | or at @option{-O2} or higher. | |
13185 | ||
d77de738 | 13186 | @opindex fsched-rank-heuristic |
ddf6fe37 | 13187 | @item -fsched-rank-heuristic |
d77de738 ML |
13188 | Enable the rank heuristic in the scheduler. This heuristic favors |
13189 | the instruction belonging to a basic block with greater size or frequency. | |
13190 | This is enabled by default when scheduling is enabled, i.e.@: | |
13191 | with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
13192 | at @option{-O2} or higher. | |
13193 | ||
d77de738 | 13194 | @opindex fsched-last-insn-heuristic |
ddf6fe37 | 13195 | @item -fsched-last-insn-heuristic |
d77de738 ML |
13196 | Enable the last-instruction heuristic in the scheduler. This heuristic |
13197 | favors the instruction that is less dependent on the last instruction | |
13198 | scheduled. This is enabled by default when scheduling is enabled, | |
13199 | i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
13200 | at @option{-O2} or higher. | |
13201 | ||
d77de738 | 13202 | @opindex fsched-dep-count-heuristic |
ddf6fe37 | 13203 | @item -fsched-dep-count-heuristic |
d77de738 ML |
13204 | Enable the dependent-count heuristic in the scheduler. This heuristic |
13205 | favors the instruction that has more instructions depending on it. | |
13206 | This is enabled by default when scheduling is enabled, i.e.@: | |
13207 | with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
13208 | at @option{-O2} or higher. | |
13209 | ||
d77de738 | 13210 | @opindex freschedule-modulo-scheduled-loops |
ddf6fe37 | 13211 | @item -freschedule-modulo-scheduled-loops |
d77de738 ML |
13212 | Modulo scheduling is performed before traditional scheduling. If a loop |
13213 | is modulo scheduled, later scheduling passes may change its schedule. | |
13214 | Use this option to control that behavior. | |
13215 | ||
d77de738 | 13216 | @opindex fselective-scheduling |
ddf6fe37 | 13217 | @item -fselective-scheduling |
d77de738 ML |
13218 | Schedule instructions using selective scheduling algorithm. Selective |
13219 | scheduling runs instead of the first scheduler pass. | |
13220 | ||
d77de738 | 13221 | @opindex fselective-scheduling2 |
ddf6fe37 | 13222 | @item -fselective-scheduling2 |
d77de738 ML |
13223 | Schedule instructions using selective scheduling algorithm. Selective |
13224 | scheduling runs instead of the second scheduler pass. | |
13225 | ||
d77de738 | 13226 | @opindex fsel-sched-pipelining |
ddf6fe37 | 13227 | @item -fsel-sched-pipelining |
d77de738 ML |
13228 | Enable software pipelining of innermost loops during selective scheduling. |
13229 | This option has no effect unless one of @option{-fselective-scheduling} or | |
13230 | @option{-fselective-scheduling2} is turned on. | |
13231 | ||
d77de738 | 13232 | @opindex fsel-sched-pipelining-outer-loops |
ddf6fe37 | 13233 | @item -fsel-sched-pipelining-outer-loops |
d77de738 ML |
13234 | When pipelining loops during selective scheduling, also pipeline outer loops. |
13235 | This option has no effect unless @option{-fsel-sched-pipelining} is turned on. | |
13236 | ||
d77de738 | 13237 | @opindex fsemantic-interposition |
ddf6fe37 | 13238 | @item -fsemantic-interposition |
d77de738 ML |
13239 | Some object formats, like ELF, allow interposing of symbols by the |
13240 | dynamic linker. | |
13241 | This means that for symbols exported from the DSO, the compiler cannot perform | |
13242 | interprocedural propagation, inlining and other optimizations in anticipation | |
13243 | that the function or variable in question may change. While this feature is | |
13244 | useful, for example, to rewrite memory allocation functions by a debugging | |
13245 | implementation, it is expensive in the terms of code quality. | |
13246 | With @option{-fno-semantic-interposition} the compiler assumes that | |
13247 | if interposition happens for functions the overwriting function will have | |
13248 | precisely the same semantics (and side effects). | |
13249 | Similarly if interposition happens | |
13250 | for variables, the constructor of the variable will be the same. The flag | |
13251 | has no effect for functions explicitly declared inline | |
13252 | (where it is never allowed for interposition to change semantics) | |
13253 | and for symbols explicitly declared weak. | |
13254 | ||
d77de738 | 13255 | @opindex fshrink-wrap |
ddf6fe37 | 13256 | @item -fshrink-wrap |
d77de738 ML |
13257 | Emit function prologues only before parts of the function that need it, |
13258 | rather than at the top of the function. This flag is enabled by default at | |
13259 | @option{-O} and higher. | |
13260 | ||
d77de738 | 13261 | @opindex fshrink-wrap-separate |
ddf6fe37 | 13262 | @item -fshrink-wrap-separate |
d77de738 ML |
13263 | Shrink-wrap separate parts of the prologue and epilogue separately, so that |
13264 | those parts are only executed when needed. | |
13265 | This option is on by default, but has no effect unless @option{-fshrink-wrap} | |
13266 | is also turned on and the target supports this. | |
13267 | ||
d77de738 | 13268 | @opindex fcaller-saves |
ddf6fe37 | 13269 | @item -fcaller-saves |
d77de738 ML |
13270 | Enable allocation of values to registers that are clobbered by |
13271 | function calls, by emitting extra instructions to save and restore the | |
13272 | registers around such calls. Such allocation is done only when it | |
13273 | seems to result in better code. | |
13274 | ||
13275 | This option is always enabled by default on certain machines, usually | |
13276 | those which have no call-preserved registers to use instead. | |
13277 | ||
13278 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13279 | ||
d77de738 | 13280 | @opindex fcombine-stack-adjustments |
ddf6fe37 | 13281 | @item -fcombine-stack-adjustments |
d77de738 ML |
13282 | Tracks stack adjustments (pushes and pops) and stack memory references |
13283 | and then tries to find ways to combine them. | |
13284 | ||
13285 | Enabled by default at @option{-O1} and higher. | |
13286 | ||
d77de738 | 13287 | @opindex fipa-ra |
ddf6fe37 | 13288 | @item -fipa-ra |
d77de738 ML |
13289 | Use caller save registers for allocation if those registers are not used by |
13290 | any called function. In that case it is not necessary to save and restore | |
13291 | them around calls. This is only possible if called functions are part of | |
13292 | same compilation unit as current function and they are compiled before it. | |
13293 | ||
13294 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option | |
13295 | is disabled if generated code will be instrumented for profiling | |
13296 | (@option{-p}, or @option{-pg}) or if callee's register usage cannot be known | |
13297 | exactly (this happens on targets that do not expose prologues | |
13298 | and epilogues in RTL). | |
13299 | ||
d77de738 | 13300 | @opindex fconserve-stack |
ddf6fe37 | 13301 | @item -fconserve-stack |
d77de738 ML |
13302 | Attempt to minimize stack usage. The compiler attempts to use less |
13303 | stack space, even if that makes the program slower. This option | |
13304 | implies setting the @option{large-stack-frame} parameter to 100 | |
13305 | and the @option{large-stack-frame-growth} parameter to 400. | |
13306 | ||
d77de738 | 13307 | @opindex ftree-reassoc |
ddf6fe37 | 13308 | @item -ftree-reassoc |
d77de738 ML |
13309 | Perform reassociation on trees. This flag is enabled by default |
13310 | at @option{-O1} and higher. | |
13311 | ||
d77de738 | 13312 | @opindex fcode-hoisting |
ddf6fe37 | 13313 | @item -fcode-hoisting |
d77de738 ML |
13314 | Perform code hoisting. Code hoisting tries to move the |
13315 | evaluation of expressions executed on all paths to the function exit | |
13316 | as early as possible. This is especially useful as a code size | |
13317 | optimization, but it often helps for code speed as well. | |
13318 | This flag is enabled by default at @option{-O2} and higher. | |
13319 | ||
d77de738 | 13320 | @opindex ftree-pre |
ddf6fe37 | 13321 | @item -ftree-pre |
d77de738 ML |
13322 | Perform partial redundancy elimination (PRE) on trees. This flag is |
13323 | enabled by default at @option{-O2} and @option{-O3}. | |
13324 | ||
d77de738 | 13325 | @opindex ftree-partial-pre |
ddf6fe37 | 13326 | @item -ftree-partial-pre |
d77de738 ML |
13327 | Make partial redundancy elimination (PRE) more aggressive. This flag is |
13328 | enabled by default at @option{-O3}. | |
13329 | ||
d77de738 | 13330 | @opindex ftree-forwprop |
ddf6fe37 | 13331 | @item -ftree-forwprop |
d77de738 ML |
13332 | Perform forward propagation on trees. This flag is enabled by default |
13333 | at @option{-O1} and higher. | |
13334 | ||
d77de738 | 13335 | @opindex ftree-fre |
ddf6fe37 | 13336 | @item -ftree-fre |
d77de738 ML |
13337 | Perform full redundancy elimination (FRE) on trees. The difference |
13338 | between FRE and PRE is that FRE only considers expressions | |
13339 | that are computed on all paths leading to the redundant computation. | |
13340 | This analysis is faster than PRE, though it exposes fewer redundancies. | |
13341 | This flag is enabled by default at @option{-O1} and higher. | |
13342 | ||
d77de738 | 13343 | @opindex ftree-phiprop |
ddf6fe37 | 13344 | @item -ftree-phiprop |
d77de738 ML |
13345 | Perform hoisting of loads from conditional pointers on trees. This |
13346 | pass is enabled by default at @option{-O1} and higher. | |
13347 | ||
d77de738 | 13348 | @opindex fhoist-adjacent-loads |
ddf6fe37 | 13349 | @item -fhoist-adjacent-loads |
d77de738 ML |
13350 | Speculatively hoist loads from both branches of an if-then-else if the |
13351 | loads are from adjacent locations in the same structure and the target | |
13352 | architecture has a conditional move instruction. This flag is enabled | |
13353 | by default at @option{-O2} and higher. | |
13354 | ||
d77de738 | 13355 | @opindex ftree-copy-prop |
ddf6fe37 | 13356 | @item -ftree-copy-prop |
d77de738 ML |
13357 | Perform copy propagation on trees. This pass eliminates unnecessary |
13358 | copy operations. This flag is enabled by default at @option{-O1} and | |
13359 | higher. | |
13360 | ||
d77de738 | 13361 | @opindex fipa-pure-const |
ddf6fe37 | 13362 | @item -fipa-pure-const |
d77de738 ML |
13363 | Discover which functions are pure or constant. |
13364 | Enabled by default at @option{-O1} and higher. | |
13365 | ||
d77de738 | 13366 | @opindex fipa-reference |
ddf6fe37 | 13367 | @item -fipa-reference |
d77de738 ML |
13368 | Discover which static variables do not escape the |
13369 | compilation unit. | |
13370 | Enabled by default at @option{-O1} and higher. | |
13371 | ||
d77de738 | 13372 | @opindex fipa-reference-addressable |
ddf6fe37 | 13373 | @item -fipa-reference-addressable |
d77de738 ML |
13374 | Discover read-only, write-only and non-addressable static variables. |
13375 | Enabled by default at @option{-O1} and higher. | |
13376 | ||
d77de738 | 13377 | @opindex fipa-stack-alignment |
ddf6fe37 | 13378 | @item -fipa-stack-alignment |
d77de738 ML |
13379 | Reduce stack alignment on call sites if possible. |
13380 | Enabled by default. | |
13381 | ||
d77de738 | 13382 | @opindex fipa-pta |
ddf6fe37 | 13383 | @item -fipa-pta |
d77de738 ML |
13384 | Perform interprocedural pointer analysis and interprocedural modification |
13385 | and reference analysis. This option can cause excessive memory and | |
13386 | compile-time usage on large compilation units. It is not enabled by | |
13387 | default at any optimization level. | |
13388 | ||
d77de738 | 13389 | @opindex fipa-profile |
ddf6fe37 | 13390 | @item -fipa-profile |
d77de738 ML |
13391 | Perform interprocedural profile propagation. The functions called only from |
13392 | cold functions are marked as cold. Also functions executed once (such as | |
13393 | @code{cold}, @code{noreturn}, static constructors or destructors) are | |
13394 | identified. Cold functions and loop less parts of functions executed once are | |
13395 | then optimized for size. | |
13396 | Enabled by default at @option{-O1} and higher. | |
13397 | ||
d77de738 | 13398 | @opindex fipa-modref |
ddf6fe37 | 13399 | @item -fipa-modref |
d77de738 ML |
13400 | Perform interprocedural mod/ref analysis. This optimization analyzes the side |
13401 | effects of functions (memory locations that are modified or referenced) and | |
13402 | enables better optimization across the function call boundary. This flag is | |
13403 | enabled by default at @option{-O1} and higher. | |
13404 | ||
d77de738 | 13405 | @opindex fipa-cp |
ddf6fe37 | 13406 | @item -fipa-cp |
d77de738 ML |
13407 | Perform interprocedural constant propagation. |
13408 | This optimization analyzes the program to determine when values passed | |
13409 | to functions are constants and then optimizes accordingly. | |
13410 | This optimization can substantially increase performance | |
13411 | if the application has constants passed to functions. | |
13412 | This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}. | |
13413 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13414 | ||
d77de738 | 13415 | @opindex fipa-cp-clone |
ddf6fe37 | 13416 | @item -fipa-cp-clone |
d77de738 ML |
13417 | Perform function cloning to make interprocedural constant propagation stronger. |
13418 | When enabled, interprocedural constant propagation performs function cloning | |
13419 | when externally visible function can be called with constant arguments. | |
13420 | Because this optimization can create multiple copies of functions, | |
13421 | it may significantly increase code size | |
13422 | (see @option{--param ipa-cp-unit-growth=@var{value}}). | |
13423 | This flag is enabled by default at @option{-O3}. | |
13424 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13425 | ||
d77de738 | 13426 | @opindex fipa-bit-cp |
ddf6fe37 | 13427 | @item -fipa-bit-cp |
d77de738 ML |
13428 | When enabled, perform interprocedural bitwise constant |
13429 | propagation. This flag is enabled by default at @option{-O2} and | |
13430 | by @option{-fprofile-use} and @option{-fauto-profile}. | |
13431 | It requires that @option{-fipa-cp} is enabled. | |
13432 | ||
d77de738 | 13433 | @opindex fipa-vrp |
ddf6fe37 | 13434 | @item -fipa-vrp |
d77de738 ML |
13435 | When enabled, perform interprocedural propagation of value |
13436 | ranges. This flag is enabled by default at @option{-O2}. It requires | |
13437 | that @option{-fipa-cp} is enabled. | |
13438 | ||
d77de738 | 13439 | @opindex fipa-icf |
ddf6fe37 | 13440 | @item -fipa-icf |
d77de738 ML |
13441 | Perform Identical Code Folding for functions and read-only variables. |
13442 | The optimization reduces code size and may disturb unwind stacks by replacing | |
13443 | a function by equivalent one with a different name. The optimization works | |
13444 | more effectively with link-time optimization enabled. | |
13445 | ||
13446 | Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF | |
13447 | works on different levels and thus the optimizations are not same - there are | |
13448 | equivalences that are found only by GCC and equivalences found only by Gold. | |
13449 | ||
13450 | This flag is enabled by default at @option{-O2} and @option{-Os}. | |
13451 | ||
d77de738 | 13452 | @opindex flive-patching |
ddf6fe37 | 13453 | @item -flive-patching=@var{level} |
d77de738 ML |
13454 | Control GCC's optimizations to produce output suitable for live-patching. |
13455 | ||
13456 | If the compiler's optimization uses a function's body or information extracted | |
13457 | from its body to optimize/change another function, the latter is called an | |
13458 | impacted function of the former. If a function is patched, its impacted | |
13459 | functions should be patched too. | |
13460 | ||
13461 | The impacted functions are determined by the compiler's interprocedural | |
13462 | optimizations. For example, a caller is impacted when inlining a function | |
13463 | into its caller, | |
13464 | cloning a function and changing its caller to call this new clone, | |
13465 | or extracting a function's pureness/constness information to optimize | |
13466 | its direct or indirect callers, etc. | |
13467 | ||
13468 | Usually, the more IPA optimizations enabled, the larger the number of | |
13469 | impacted functions for each function. In order to control the number of | |
13470 | impacted functions and more easily compute the list of impacted function, | |
13471 | IPA optimizations can be partially enabled at two different levels. | |
13472 | ||
13473 | The @var{level} argument should be one of the following: | |
13474 | ||
13475 | @table @samp | |
13476 | ||
13477 | @item inline-clone | |
13478 | ||
13479 | Only enable inlining and cloning optimizations, which includes inlining, | |
13480 | cloning, interprocedural scalar replacement of aggregates and partial inlining. | |
13481 | As a result, when patching a function, all its callers and its clones' | |
13482 | callers are impacted, therefore need to be patched as well. | |
13483 | ||
13484 | @option{-flive-patching=inline-clone} disables the following optimization flags: | |
43b72ede AA |
13485 | @gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra |
13486 | -fipa-icf -fipa-icf-functions -fipa-icf-variables | |
13487 | -fipa-bit-cp -fipa-vrp -fipa-pure-const | |
13488 | -fipa-reference-addressable | |
d77de738 ML |
13489 | -fipa-stack-alignment -fipa-modref} |
13490 | ||
13491 | @item inline-only-static | |
13492 | ||
13493 | Only enable inlining of static functions. | |
13494 | As a result, when patching a static function, all its callers are impacted | |
13495 | and so need to be patched as well. | |
13496 | ||
13497 | In addition to all the flags that @option{-flive-patching=inline-clone} | |
13498 | disables, | |
13499 | @option{-flive-patching=inline-only-static} disables the following additional | |
13500 | optimization flags: | |
13501 | @gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp} | |
13502 | ||
13503 | @end table | |
13504 | ||
13505 | When @option{-flive-patching} is specified without any value, the default value | |
13506 | is @var{inline-clone}. | |
13507 | ||
13508 | This flag is disabled by default. | |
13509 | ||
13510 | Note that @option{-flive-patching} is not supported with link-time optimization | |
13511 | (@option{-flto}). | |
13512 | ||
d77de738 | 13513 | @opindex fisolate-erroneous-paths-dereference |
ddf6fe37 | 13514 | @item -fisolate-erroneous-paths-dereference |
d77de738 ML |
13515 | Detect paths that trigger erroneous or undefined behavior due to |
13516 | dereferencing a null pointer. Isolate those paths from the main control | |
13517 | flow and turn the statement with erroneous or undefined behavior into a trap. | |
13518 | This flag is enabled by default at @option{-O2} and higher and depends on | |
13519 | @option{-fdelete-null-pointer-checks} also being enabled. | |
13520 | ||
d77de738 | 13521 | @opindex fisolate-erroneous-paths-attribute |
ddf6fe37 | 13522 | @item -fisolate-erroneous-paths-attribute |
d77de738 ML |
13523 | Detect paths that trigger erroneous or undefined behavior due to a null value |
13524 | being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull} | |
13525 | attribute. Isolate those paths from the main control flow and turn the | |
13526 | statement with erroneous or undefined behavior into a trap. This is not | |
13527 | currently enabled, but may be enabled by @option{-O2} in the future. | |
13528 | ||
d77de738 | 13529 | @opindex ftree-sink |
ddf6fe37 | 13530 | @item -ftree-sink |
d77de738 ML |
13531 | Perform forward store motion on trees. This flag is |
13532 | enabled by default at @option{-O1} and higher. | |
13533 | ||
d77de738 | 13534 | @opindex ftree-bit-ccp |
ddf6fe37 | 13535 | @item -ftree-bit-ccp |
d77de738 ML |
13536 | Perform sparse conditional bit constant propagation on trees and propagate |
13537 | pointer alignment information. | |
13538 | This pass only operates on local scalar variables and is enabled by default | |
13539 | at @option{-O1} and higher, except for @option{-Og}. | |
13540 | It requires that @option{-ftree-ccp} is enabled. | |
13541 | ||
d77de738 | 13542 | @opindex ftree-ccp |
ddf6fe37 | 13543 | @item -ftree-ccp |
d77de738 ML |
13544 | Perform sparse conditional constant propagation (CCP) on trees. This |
13545 | pass only operates on local scalar variables and is enabled by default | |
13546 | at @option{-O1} and higher. | |
13547 | ||
d77de738 | 13548 | @opindex fssa-backprop |
ddf6fe37 | 13549 | @item -fssa-backprop |
d77de738 ML |
13550 | Propagate information about uses of a value up the definition chain |
13551 | in order to simplify the definitions. For example, this pass strips | |
13552 | sign operations if the sign of a value never matters. The flag is | |
13553 | enabled by default at @option{-O1} and higher. | |
13554 | ||
d77de738 | 13555 | @opindex fssa-phiopt |
ddf6fe37 | 13556 | @item -fssa-phiopt |
d77de738 ML |
13557 | Perform pattern matching on SSA PHI nodes to optimize conditional |
13558 | code. This pass is enabled by default at @option{-O1} and higher, | |
13559 | except for @option{-Og}. | |
13560 | ||
d77de738 | 13561 | @opindex ftree-switch-conversion |
ddf6fe37 | 13562 | @item -ftree-switch-conversion |
d77de738 ML |
13563 | Perform conversion of simple initializations in a switch to |
13564 | initializations from a scalar array. This flag is enabled by default | |
13565 | at @option{-O2} and higher. | |
13566 | ||
d77de738 | 13567 | @opindex ftree-tail-merge |
ddf6fe37 | 13568 | @item -ftree-tail-merge |
d77de738 ML |
13569 | Look for identical code sequences. When found, replace one with a jump to the |
13570 | other. This optimization is known as tail merging or cross jumping. This flag | |
13571 | is enabled by default at @option{-O2} and higher. The compilation time | |
13572 | in this pass can | |
13573 | be limited using @option{max-tail-merge-comparisons} parameter and | |
13574 | @option{max-tail-merge-iterations} parameter. | |
13575 | ||
d77de738 | 13576 | @opindex ftree-dce |
ddf6fe37 | 13577 | @item -ftree-dce |
d77de738 ML |
13578 | Perform dead code elimination (DCE) on trees. This flag is enabled by |
13579 | default at @option{-O1} and higher. | |
13580 | ||
d77de738 | 13581 | @opindex ftree-builtin-call-dce |
ddf6fe37 | 13582 | @item -ftree-builtin-call-dce |
d77de738 ML |
13583 | Perform conditional dead code elimination (DCE) for calls to built-in functions |
13584 | that may set @code{errno} but are otherwise free of side effects. This flag is | |
13585 | enabled by default at @option{-O2} and higher if @option{-Os} is not also | |
13586 | specified. | |
13587 | ||
d77de738 ML |
13588 | @opindex ffinite-loops |
13589 | @opindex fno-finite-loops | |
ddf6fe37 | 13590 | @item -ffinite-loops |
d77de738 ML |
13591 | Assume that a loop with an exit will eventually take the exit and not loop |
13592 | indefinitely. This allows the compiler to remove loops that otherwise have | |
13593 | no side-effects, not considering eventual endless looping as such. | |
13594 | ||
13595 | This option is enabled by default at @option{-O2} for C++ with -std=c++11 | |
13596 | or higher. | |
13597 | ||
d77de738 | 13598 | @opindex ftree-dominator-opts |
ddf6fe37 | 13599 | @item -ftree-dominator-opts |
d77de738 ML |
13600 | Perform a variety of simple scalar cleanups (constant/copy |
13601 | propagation, redundancy elimination, range propagation and expression | |
13602 | simplification) based on a dominator tree traversal. This also | |
13603 | performs jump threading (to reduce jumps to jumps). This flag is | |
13604 | enabled by default at @option{-O1} and higher. | |
13605 | ||
d77de738 | 13606 | @opindex ftree-dse |
ddf6fe37 | 13607 | @item -ftree-dse |
d77de738 ML |
13608 | Perform dead store elimination (DSE) on trees. A dead store is a store into |
13609 | a memory location that is later overwritten by another store without | |
13610 | any intervening loads. In this case the earlier store can be deleted. This | |
13611 | flag is enabled by default at @option{-O1} and higher. | |
13612 | ||
d77de738 | 13613 | @opindex ftree-ch |
ddf6fe37 | 13614 | @item -ftree-ch |
d77de738 ML |
13615 | Perform loop header copying on trees. This is beneficial since it increases |
13616 | effectiveness of code motion optimizations. It also saves one jump. This flag | |
13617 | is enabled by default at @option{-O1} and higher. It is not enabled | |
13618 | for @option{-Os}, since it usually increases code size. | |
13619 | ||
d77de738 | 13620 | @opindex ftree-loop-optimize |
ddf6fe37 | 13621 | @item -ftree-loop-optimize |
d77de738 ML |
13622 | Perform loop optimizations on trees. This flag is enabled by default |
13623 | at @option{-O1} and higher. | |
13624 | ||
d77de738 ML |
13625 | @opindex ftree-loop-linear |
13626 | @opindex floop-strip-mine | |
13627 | @opindex floop-block | |
ddf6fe37 AA |
13628 | @item -ftree-loop-linear |
13629 | @itemx -floop-strip-mine | |
13630 | @itemx -floop-block | |
d77de738 ML |
13631 | Perform loop nest optimizations. Same as |
13632 | @option{-floop-nest-optimize}. To use this code transformation, GCC has | |
13633 | to be configured with @option{--with-isl} to enable the Graphite loop | |
13634 | transformation infrastructure. | |
13635 | ||
d77de738 | 13636 | @opindex fgraphite-identity |
ddf6fe37 | 13637 | @item -fgraphite-identity |
d77de738 ML |
13638 | Enable the identity transformation for graphite. For every SCoP we generate |
13639 | the polyhedral representation and transform it back to gimple. Using | |
13640 | @option{-fgraphite-identity} we can check the costs or benefits of the | |
13641 | GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations | |
13642 | are also performed by the code generator isl, like index splitting and | |
13643 | dead code elimination in loops. | |
13644 | ||
d77de738 | 13645 | @opindex floop-nest-optimize |
ddf6fe37 | 13646 | @item -floop-nest-optimize |
d77de738 ML |
13647 | Enable the isl based loop nest optimizer. This is a generic loop nest |
13648 | optimizer based on the Pluto optimization algorithms. It calculates a loop | |
13649 | structure optimized for data-locality and parallelism. This option | |
13650 | is experimental. | |
13651 | ||
d77de738 | 13652 | @opindex floop-parallelize-all |
ddf6fe37 | 13653 | @item -floop-parallelize-all |
d77de738 ML |
13654 | Use the Graphite data dependence analysis to identify loops that can |
13655 | be parallelized. Parallelize all the loops that can be analyzed to | |
13656 | not contain loop carried dependences without checking that it is | |
13657 | profitable to parallelize the loops. | |
13658 | ||
d77de738 | 13659 | @opindex ftree-coalesce-vars |
ddf6fe37 | 13660 | @item -ftree-coalesce-vars |
d77de738 ML |
13661 | While transforming the program out of the SSA representation, attempt to |
13662 | reduce copying by coalescing versions of different user-defined | |
13663 | variables, instead of just compiler temporaries. This may severely | |
13664 | limit the ability to debug an optimized program compiled with | |
13665 | @option{-fno-var-tracking-assignments}. In the negated form, this flag | |
13666 | prevents SSA coalescing of user variables. This option is enabled by | |
13667 | default if optimization is enabled, and it does very little otherwise. | |
13668 | ||
d77de738 | 13669 | @opindex ftree-loop-if-convert |
ddf6fe37 | 13670 | @item -ftree-loop-if-convert |
d77de738 ML |
13671 | Attempt to transform conditional jumps in the innermost loops to |
13672 | branch-less equivalents. The intent is to remove control-flow from | |
13673 | the innermost loops in order to improve the ability of the | |
13674 | vectorization pass to handle these loops. This is enabled by default | |
13675 | if vectorization is enabled. | |
13676 | ||
d77de738 | 13677 | @opindex ftree-loop-distribution |
ddf6fe37 | 13678 | @item -ftree-loop-distribution |
d77de738 ML |
13679 | Perform loop distribution. This flag can improve cache performance on |
13680 | big loop bodies and allow further loop optimizations, like | |
13681 | parallelization or vectorization, to take place. For example, the loop | |
13682 | @smallexample | |
13683 | DO I = 1, N | |
13684 | A(I) = B(I) + C | |
13685 | D(I) = E(I) * F | |
13686 | ENDDO | |
13687 | @end smallexample | |
13688 | is transformed to | |
13689 | @smallexample | |
13690 | DO I = 1, N | |
13691 | A(I) = B(I) + C | |
13692 | ENDDO | |
13693 | DO I = 1, N | |
13694 | D(I) = E(I) * F | |
13695 | ENDDO | |
13696 | @end smallexample | |
13697 | This flag is enabled by default at @option{-O3}. | |
13698 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13699 | ||
d77de738 | 13700 | @opindex ftree-loop-distribute-patterns |
ddf6fe37 | 13701 | @item -ftree-loop-distribute-patterns |
d77de738 ML |
13702 | Perform loop distribution of patterns that can be code generated with |
13703 | calls to a library. This flag is enabled by default at @option{-O2} and | |
13704 | higher, and by @option{-fprofile-use} and @option{-fauto-profile}. | |
13705 | ||
13706 | This pass distributes the initialization loops and generates a call to | |
13707 | memset zero. For example, the loop | |
13708 | @smallexample | |
13709 | DO I = 1, N | |
13710 | A(I) = 0 | |
13711 | B(I) = A(I) + I | |
13712 | ENDDO | |
13713 | @end smallexample | |
13714 | is transformed to | |
13715 | @smallexample | |
13716 | DO I = 1, N | |
13717 | A(I) = 0 | |
13718 | ENDDO | |
13719 | DO I = 1, N | |
13720 | B(I) = A(I) + I | |
13721 | ENDDO | |
13722 | @end smallexample | |
13723 | and the initialization loop is transformed into a call to memset zero. | |
13724 | This flag is enabled by default at @option{-O3}. | |
13725 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13726 | ||
d77de738 | 13727 | @opindex floop-interchange |
ddf6fe37 | 13728 | @item -floop-interchange |
d77de738 ML |
13729 | Perform loop interchange outside of graphite. This flag can improve cache |
13730 | performance on loop nest and allow further loop optimizations, like | |
13731 | vectorization, to take place. For example, the loop | |
13732 | @smallexample | |
13733 | for (int i = 0; i < N; i++) | |
13734 | for (int j = 0; j < N; j++) | |
13735 | for (int k = 0; k < N; k++) | |
13736 | c[i][j] = c[i][j] + a[i][k]*b[k][j]; | |
13737 | @end smallexample | |
13738 | is transformed to | |
13739 | @smallexample | |
13740 | for (int i = 0; i < N; i++) | |
13741 | for (int k = 0; k < N; k++) | |
13742 | for (int j = 0; j < N; j++) | |
13743 | c[i][j] = c[i][j] + a[i][k]*b[k][j]; | |
13744 | @end smallexample | |
13745 | This flag is enabled by default at @option{-O3}. | |
13746 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13747 | ||
d77de738 | 13748 | @opindex floop-unroll-and-jam |
ddf6fe37 | 13749 | @item -floop-unroll-and-jam |
d77de738 ML |
13750 | Apply unroll and jam transformations on feasible loops. In a loop |
13751 | nest this unrolls the outer loop by some factor and fuses the resulting | |
13752 | multiple inner loops. This flag is enabled by default at @option{-O3}. | |
13753 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13754 | ||
d77de738 | 13755 | @opindex ftree-loop-im |
ddf6fe37 | 13756 | @item -ftree-loop-im |
d77de738 ML |
13757 | Perform loop invariant motion on trees. This pass moves only invariants that |
13758 | are hard to handle at RTL level (function calls, operations that expand to | |
13759 | nontrivial sequences of insns). With @option{-funswitch-loops} it also moves | |
13760 | operands of conditions that are invariant out of the loop, so that we can use | |
13761 | just trivial invariantness analysis in loop unswitching. The pass also includes | |
13762 | store motion. | |
13763 | ||
d77de738 | 13764 | @opindex ftree-loop-ivcanon |
ddf6fe37 | 13765 | @item -ftree-loop-ivcanon |
d77de738 ML |
13766 | Create a canonical counter for number of iterations in loops for which |
13767 | determining number of iterations requires complicated analysis. Later | |
13768 | optimizations then may determine the number easily. Useful especially | |
13769 | in connection with unrolling. | |
13770 | ||
d77de738 | 13771 | @opindex ftree-scev-cprop |
ddf6fe37 | 13772 | @item -ftree-scev-cprop |
d77de738 ML |
13773 | Perform final value replacement. If a variable is modified in a loop |
13774 | in such a way that its value when exiting the loop can be determined using | |
13775 | only its initial value and the number of loop iterations, replace uses of | |
13776 | the final value by such a computation, provided it is sufficiently cheap. | |
13777 | This reduces data dependencies and may allow further simplifications. | |
13778 | Enabled by default at @option{-O1} and higher. | |
13779 | ||
d77de738 | 13780 | @opindex fivopts |
ddf6fe37 | 13781 | @item -fivopts |
d77de738 ML |
13782 | Perform induction variable optimizations (strength reduction, induction |
13783 | variable merging and induction variable elimination) on trees. | |
13784 | ||
d77de738 | 13785 | @opindex ftree-parallelize-loops |
ddf6fe37 | 13786 | @item -ftree-parallelize-loops=n |
d77de738 ML |
13787 | Parallelize loops, i.e., split their iteration space to run in n threads. |
13788 | This is only possible for loops whose iterations are independent | |
13789 | and can be arbitrarily reordered. The optimization is only | |
13790 | profitable on multiprocessor machines, for loops that are CPU-intensive, | |
13791 | rather than constrained e.g.@: by memory bandwidth. This option | |
13792 | implies @option{-pthread}, and thus is only supported on targets | |
13793 | that have support for @option{-pthread}. | |
13794 | ||
d77de738 | 13795 | @opindex ftree-pta |
ddf6fe37 | 13796 | @item -ftree-pta |
d77de738 ML |
13797 | Perform function-local points-to analysis on trees. This flag is |
13798 | enabled by default at @option{-O1} and higher, except for @option{-Og}. | |
13799 | ||
d77de738 | 13800 | @opindex ftree-sra |
ddf6fe37 | 13801 | @item -ftree-sra |
d77de738 ML |
13802 | Perform scalar replacement of aggregates. This pass replaces structure |
13803 | references with scalars to prevent committing structures to memory too | |
13804 | early. This flag is enabled by default at @option{-O1} and higher, | |
13805 | except for @option{-Og}. | |
13806 | ||
d77de738 | 13807 | @opindex fstore-merging |
ddf6fe37 | 13808 | @item -fstore-merging |
d77de738 ML |
13809 | Perform merging of narrow stores to consecutive memory addresses. This pass |
13810 | merges contiguous stores of immediate values narrower than a word into fewer | |
13811 | wider stores to reduce the number of instructions. This is enabled by default | |
13812 | at @option{-O2} and higher as well as @option{-Os}. | |
13813 | ||
d77de738 | 13814 | @opindex ftree-ter |
ddf6fe37 | 13815 | @item -ftree-ter |
d77de738 ML |
13816 | Perform temporary expression replacement during the SSA->normal phase. Single |
13817 | use/single def temporaries are replaced at their use location with their | |
13818 | defining expression. This results in non-GIMPLE code, but gives the expanders | |
13819 | much more complex trees to work on resulting in better RTL generation. This is | |
13820 | enabled by default at @option{-O1} and higher. | |
13821 | ||
d77de738 | 13822 | @opindex ftree-slsr |
ddf6fe37 | 13823 | @item -ftree-slsr |
d77de738 ML |
13824 | Perform straight-line strength reduction on trees. This recognizes related |
13825 | expressions involving multiplications and replaces them by less expensive | |
13826 | calculations when possible. This is enabled by default at @option{-O1} and | |
13827 | higher. | |
13828 | ||
d77de738 | 13829 | @opindex ftree-vectorize |
ddf6fe37 | 13830 | @item -ftree-vectorize |
d77de738 ML |
13831 | Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize} |
13832 | and @option{-ftree-slp-vectorize} if not explicitly specified. | |
13833 | ||
d77de738 | 13834 | @opindex ftree-loop-vectorize |
ddf6fe37 | 13835 | @item -ftree-loop-vectorize |
d77de738 ML |
13836 | Perform loop vectorization on trees. This flag is enabled by default at |
13837 | @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use}, | |
13838 | and @option{-fauto-profile}. | |
13839 | ||
d77de738 | 13840 | @opindex ftree-slp-vectorize |
ddf6fe37 | 13841 | @item -ftree-slp-vectorize |
d77de738 ML |
13842 | Perform basic block vectorization on trees. This flag is enabled by default at |
13843 | @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use}, | |
13844 | and @option{-fauto-profile}. | |
13845 | ||
d77de738 | 13846 | @opindex ftrivial-auto-var-init |
ddf6fe37 | 13847 | @item -ftrivial-auto-var-init=@var{choice} |
d77de738 ML |
13848 | Initialize automatic variables with either a pattern or with zeroes to increase |
13849 | the security and predictability of a program by preventing uninitialized memory | |
13850 | disclosure and use. | |
13851 | GCC still considers an automatic variable that doesn't have an explicit | |
13852 | initializer as uninitialized, @option{-Wuninitialized} and | |
13853 | @option{-Wanalyzer-use-of-uninitialized-value} will still report | |
8f4634fb RB |
13854 | warning messages on such automatic variables and the compiler will |
13855 | perform optimization as if the variable were uninitialized. | |
d77de738 ML |
13856 | With this option, GCC will also initialize any padding of automatic variables |
13857 | that have structure or union types to zeroes. | |
13858 | However, the current implementation cannot initialize automatic variables that | |
13859 | are declared between the controlling expression and the first case of a | |
13860 | @code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all | |
13861 | such cases. | |
13862 | ||
13863 | The three values of @var{choice} are: | |
13864 | ||
13865 | @itemize @bullet | |
13866 | @item | |
13867 | @samp{uninitialized} doesn't initialize any automatic variables. | |
13868 | This is C and C++'s default. | |
13869 | ||
13870 | @item | |
13871 | @samp{pattern} Initialize automatic variables with values which will likely | |
13872 | transform logic bugs into crashes down the line, are easily recognized in a | |
13873 | crash dump and without being values that programmers can rely on for useful | |
13874 | program semantics. | |
13875 | The current value is byte-repeatable pattern with byte "0xFE". | |
13876 | The values used for pattern initialization might be changed in the future. | |
13877 | ||
13878 | @item | |
13879 | @samp{zero} Initialize automatic variables with zeroes. | |
13880 | @end itemize | |
13881 | ||
13882 | The default is @samp{uninitialized}. | |
13883 | ||
862867ea AO |
13884 | Note that the initializer values, whether @samp{zero} or @samp{pattern}, |
13885 | refer to data representation (in memory or machine registers), rather | |
13886 | than to their interpretation as numerical values. This distinction may | |
13887 | be important in languages that support types with biases or implicit | |
13888 | multipliers, and with such extensions as @samp{hardbool} (@pxref{Type | |
13889 | Attributes}). For example, a variable that uses 8 bits to represent | |
13890 | (biased) quantities in the @code{range 160..400} will be initialized | |
13891 | with the bit patterns @code{0x00} or @code{0xFE}, depending on | |
13892 | @var{choice}, whether or not these representations stand for values in | |
13893 | that range, and even if they do, the interpretation of the value held by | |
13894 | the variable will depend on the bias. A @samp{hardbool} variable that | |
13895 | uses say @code{0X5A} and @code{0xA5} for @code{false} and @code{true}, | |
13896 | respectively, will trap with either @samp{choice} of trivial | |
13897 | initializer, i.e., @samp{zero} initialization will not convert to the | |
13898 | representation for @code{false}, even if it would for a @code{static} | |
13899 | variable of the same type. This means the initializer pattern doesn't | |
13900 | generally depend on the type of the initialized variable. One notable | |
13901 | exception is that (non-hardened) boolean variables that fit in registers | |
13902 | are initialized with @code{false} (zero), even when @samp{pattern} is | |
13903 | requested. | |
13904 | ||
d77de738 ML |
13905 | You can control this behavior for a specific variable by using the variable |
13906 | attribute @code{uninitialized} (@pxref{Variable Attributes}). | |
13907 | ||
d77de738 | 13908 | @opindex fvect-cost-model |
ddf6fe37 | 13909 | @item -fvect-cost-model=@var{model} |
d77de738 ML |
13910 | Alter the cost model used for vectorization. The @var{model} argument |
13911 | should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or | |
13912 | @samp{very-cheap}. | |
13913 | With the @samp{unlimited} model the vectorized code-path is assumed | |
13914 | to be profitable while with the @samp{dynamic} model a runtime check | |
13915 | guards the vectorized code-path to enable it only for iteration | |
13916 | counts that will likely execute faster than when executing the original | |
13917 | scalar loop. The @samp{cheap} model disables vectorization of | |
13918 | loops where doing so would be cost prohibitive for example due to | |
13919 | required runtime checks for data dependence or alignment but otherwise | |
13920 | is equal to the @samp{dynamic} model. The @samp{very-cheap} model only | |
13921 | allows vectorization if the vector code would entirely replace the | |
13922 | scalar code that is being vectorized. For example, if each iteration | |
13923 | of a vectorized loop would only be able to handle exactly four iterations | |
13924 | of the scalar loop, the @samp{very-cheap} model would only allow | |
13925 | vectorization if the scalar iteration count is known to be a multiple | |
13926 | of four. | |
13927 | ||
13928 | The default cost model depends on other optimization flags and is | |
13929 | either @samp{dynamic} or @samp{cheap}. | |
13930 | ||
d77de738 | 13931 | @opindex fsimd-cost-model |
ddf6fe37 | 13932 | @item -fsimd-cost-model=@var{model} |
d77de738 ML |
13933 | Alter the cost model used for vectorization of loops marked with the OpenMP |
13934 | simd directive. The @var{model} argument should be one of | |
13935 | @samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model} | |
13936 | have the same meaning as described in @option{-fvect-cost-model} and by | |
13937 | default a cost model defined with @option{-fvect-cost-model} is used. | |
13938 | ||
d77de738 | 13939 | @opindex ftree-vrp |
ddf6fe37 | 13940 | @item -ftree-vrp |
d77de738 ML |
13941 | Perform Value Range Propagation on trees. This is similar to the |
13942 | constant propagation pass, but instead of values, ranges of values are | |
13943 | propagated. This allows the optimizers to remove unnecessary range | |
13944 | checks like array bound checks and null pointer checks. This is | |
13945 | enabled by default at @option{-O2} and higher. Null pointer check | |
13946 | elimination is only done if @option{-fdelete-null-pointer-checks} is | |
13947 | enabled. | |
13948 | ||
d77de738 | 13949 | @opindex fsplit-paths |
ddf6fe37 | 13950 | @item -fsplit-paths |
d77de738 ML |
13951 | Split paths leading to loop backedges. This can improve dead code |
13952 | elimination and common subexpression elimination. This is enabled by | |
13953 | default at @option{-O3} and above. | |
13954 | ||
d77de738 | 13955 | @opindex fsplit-ivs-in-unroller |
ddf6fe37 | 13956 | @item -fsplit-ivs-in-unroller |
d77de738 ML |
13957 | Enables expression of values of induction variables in later iterations |
13958 | of the unrolled loop using the value in the first iteration. This breaks | |
13959 | long dependency chains, thus improving efficiency of the scheduling passes. | |
13960 | ||
13961 | A combination of @option{-fweb} and CSE is often sufficient to obtain the | |
13962 | same effect. However, that is not reliable in cases where the loop body | |
13963 | is more complicated than a single basic block. It also does not work at all | |
13964 | on some architectures due to restrictions in the CSE pass. | |
13965 | ||
13966 | This optimization is enabled by default. | |
13967 | ||
d77de738 | 13968 | @opindex fvariable-expansion-in-unroller |
ddf6fe37 | 13969 | @item -fvariable-expansion-in-unroller |
d77de738 ML |
13970 | With this option, the compiler creates multiple copies of some |
13971 | local variables when unrolling a loop, which can result in superior code. | |
13972 | ||
13973 | This optimization is enabled by default for PowerPC targets, but disabled | |
13974 | by default otherwise. | |
13975 | ||
d77de738 | 13976 | @opindex fpartial-inlining |
ddf6fe37 | 13977 | @item -fpartial-inlining |
d77de738 ML |
13978 | Inline parts of functions. This option has any effect only |
13979 | when inlining itself is turned on by the @option{-finline-functions} | |
13980 | or @option{-finline-small-functions} options. | |
13981 | ||
13982 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13983 | ||
d77de738 | 13984 | @opindex fpredictive-commoning |
ddf6fe37 | 13985 | @item -fpredictive-commoning |
d77de738 ML |
13986 | Perform predictive commoning optimization, i.e., reusing computations |
13987 | (especially memory loads and stores) performed in previous | |
13988 | iterations of loops. | |
13989 | ||
13990 | This option is enabled at level @option{-O3}. | |
13991 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13992 | ||
d77de738 | 13993 | @opindex fprefetch-loop-arrays |
ddf6fe37 | 13994 | @item -fprefetch-loop-arrays |
d77de738 ML |
13995 | If supported by the target machine, generate instructions to prefetch |
13996 | memory to improve the performance of loops that access large arrays. | |
13997 | ||
13998 | This option may generate better or worse code; results are highly | |
13999 | dependent on the structure of loops within the source code. | |
14000 | ||
14001 | Disabled at level @option{-Os}. | |
14002 | ||
d77de738 ML |
14003 | @opindex fno-printf-return-value |
14004 | @opindex fprintf-return-value | |
ddf6fe37 | 14005 | @item -fno-printf-return-value |
d77de738 ML |
14006 | Do not substitute constants for known return value of formatted output |
14007 | functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and | |
14008 | @code{vsnprintf} (but not @code{printf} of @code{fprintf}). This | |
14009 | transformation allows GCC to optimize or even eliminate branches based | |
14010 | on the known return value of these functions called with arguments that | |
14011 | are either constant, or whose values are known to be in a range that | |
14012 | makes determining the exact return value possible. For example, when | |
14013 | @option{-fprintf-return-value} is in effect, both the branch and the | |
14014 | body of the @code{if} statement (but not the call to @code{snprint}) | |
14015 | can be optimized away when @code{i} is a 32-bit or smaller integer | |
14016 | because the return value is guaranteed to be at most 8. | |
14017 | ||
14018 | @smallexample | |
14019 | char buf[9]; | |
14020 | if (snprintf (buf, "%08x", i) >= sizeof buf) | |
14021 | @dots{} | |
14022 | @end smallexample | |
14023 | ||
14024 | The @option{-fprintf-return-value} option relies on other optimizations | |
14025 | and yields best results with @option{-O2} and above. It works in tandem | |
14026 | with the @option{-Wformat-overflow} and @option{-Wformat-truncation} | |
14027 | options. The @option{-fprintf-return-value} option is enabled by default. | |
14028 | ||
d77de738 ML |
14029 | @opindex fno-peephole |
14030 | @opindex fpeephole | |
14031 | @opindex fno-peephole2 | |
14032 | @opindex fpeephole2 | |
ddf6fe37 AA |
14033 | @item -fno-peephole |
14034 | @itemx -fno-peephole2 | |
d77de738 ML |
14035 | Disable any machine-specific peephole optimizations. The difference |
14036 | between @option{-fno-peephole} and @option{-fno-peephole2} is in how they | |
14037 | are implemented in the compiler; some targets use one, some use the | |
14038 | other, a few use both. | |
14039 | ||
14040 | @option{-fpeephole} is enabled by default. | |
14041 | @option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
14042 | ||
d77de738 ML |
14043 | @opindex fno-guess-branch-probability |
14044 | @opindex fguess-branch-probability | |
ddf6fe37 | 14045 | @item -fno-guess-branch-probability |
d77de738 ML |
14046 | Do not guess branch probabilities using heuristics. |
14047 | ||
14048 | GCC uses heuristics to guess branch probabilities if they are | |
14049 | not provided by profiling feedback (@option{-fprofile-arcs}). These | |
14050 | heuristics are based on the control flow graph. If some branch probabilities | |
14051 | are specified by @code{__builtin_expect}, then the heuristics are | |
14052 | used to guess branch probabilities for the rest of the control flow graph, | |
14053 | taking the @code{__builtin_expect} info into account. The interactions | |
14054 | between the heuristics and @code{__builtin_expect} can be complex, and in | |
14055 | some cases, it may be useful to disable the heuristics so that the effects | |
14056 | of @code{__builtin_expect} are easier to understand. | |
14057 | ||
14058 | It is also possible to specify expected probability of the expression | |
14059 | with @code{__builtin_expect_with_probability} built-in function. | |
14060 | ||
14061 | The default is @option{-fguess-branch-probability} at levels | |
14062 | @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. | |
14063 | ||
d77de738 | 14064 | @opindex freorder-blocks |
ddf6fe37 | 14065 | @item -freorder-blocks |
d77de738 ML |
14066 | Reorder basic blocks in the compiled function in order to reduce number of |
14067 | taken branches and improve code locality. | |
14068 | ||
14069 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
14070 | ||
d77de738 | 14071 | @opindex freorder-blocks-algorithm |
ddf6fe37 | 14072 | @item -freorder-blocks-algorithm=@var{algorithm} |
d77de738 ML |
14073 | Use the specified algorithm for basic block reordering. The |
14074 | @var{algorithm} argument can be @samp{simple}, which does not increase | |
14075 | code size (except sometimes due to secondary effects like alignment), | |
14076 | or @samp{stc}, the ``software trace cache'' algorithm, which tries to | |
14077 | put all often executed code together, minimizing the number of branches | |
14078 | executed by making extra copies of code. | |
14079 | ||
14080 | The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and | |
14081 | @samp{stc} at levels @option{-O2}, @option{-O3}. | |
14082 | ||
d77de738 | 14083 | @opindex freorder-blocks-and-partition |
ddf6fe37 | 14084 | @item -freorder-blocks-and-partition |
d77de738 ML |
14085 | In addition to reordering basic blocks in the compiled function, in order |
14086 | to reduce number of taken branches, partitions hot and cold basic blocks | |
14087 | into separate sections of the assembly and @file{.o} files, to improve | |
14088 | paging and cache locality performance. | |
14089 | ||
14090 | This optimization is automatically turned off in the presence of | |
14091 | exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined | |
14092 | section attribute and on any architecture that does not support named | |
14093 | sections. When @option{-fsplit-stack} is used this option is not | |
14094 | enabled by default (to avoid linker errors), but may be enabled | |
14095 | explicitly (if using a working linker). | |
14096 | ||
14097 | Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
14098 | ||
d77de738 | 14099 | @opindex freorder-functions |
ddf6fe37 | 14100 | @item -freorder-functions |
d77de738 ML |
14101 | Reorder functions in the object file in order to |
14102 | improve code locality. This is implemented by using special | |
14103 | subsections @code{.text.hot} for most frequently executed functions and | |
14104 | @code{.text.unlikely} for unlikely executed functions. Reordering is done by | |
14105 | the linker so object file format must support named sections and linker must | |
14106 | place them in a reasonable way. | |
14107 | ||
14108 | This option isn't effective unless you either provide profile feedback | |
14109 | (see @option{-fprofile-arcs} for details) or manually annotate functions with | |
14110 | @code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}). | |
14111 | ||
14112 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
14113 | ||
d77de738 | 14114 | @opindex fstrict-aliasing |
ddf6fe37 | 14115 | @item -fstrict-aliasing |
d77de738 ML |
14116 | Allow the compiler to assume the strictest aliasing rules applicable to |
14117 | the language being compiled. For C (and C++), this activates | |
14118 | optimizations based on the type of expressions. In particular, an | |
14119 | object of one type is assumed never to reside at the same address as an | |
14120 | object of a different type, unless the types are almost the same. For | |
14121 | example, an @code{unsigned int} can alias an @code{int}, but not a | |
14122 | @code{void*} or a @code{double}. A character type may alias any other | |
14123 | type. | |
14124 | ||
14125 | @anchor{Type-punning}Pay special attention to code like this: | |
14126 | @smallexample | |
14127 | union a_union @{ | |
14128 | int i; | |
14129 | double d; | |
14130 | @}; | |
14131 | ||
14132 | int f() @{ | |
14133 | union a_union t; | |
14134 | t.d = 3.0; | |
14135 | return t.i; | |
14136 | @} | |
14137 | @end smallexample | |
14138 | The practice of reading from a different union member than the one most | |
14139 | recently written to (called ``type-punning'') is common. Even with | |
14140 | @option{-fstrict-aliasing}, type-punning is allowed, provided the memory | |
14141 | is accessed through the union type. So, the code above works as | |
14142 | expected. @xref{Structures unions enumerations and bit-fields | |
14143 | implementation}. However, this code might not: | |
14144 | @smallexample | |
14145 | int f() @{ | |
14146 | union a_union t; | |
14147 | int* ip; | |
14148 | t.d = 3.0; | |
14149 | ip = &t.i; | |
14150 | return *ip; | |
14151 | @} | |
14152 | @end smallexample | |
14153 | ||
14154 | Similarly, access by taking the address, casting the resulting pointer | |
14155 | and dereferencing the result has undefined behavior, even if the cast | |
14156 | uses a union type, e.g.: | |
14157 | @smallexample | |
14158 | int f() @{ | |
14159 | double d = 3.0; | |
14160 | return ((union a_union *) &d)->i; | |
14161 | @} | |
14162 | @end smallexample | |
14163 | ||
14164 | The @option{-fstrict-aliasing} option is enabled at levels | |
14165 | @option{-O2}, @option{-O3}, @option{-Os}. | |
14166 | ||
d77de738 | 14167 | @opindex fipa-strict-aliasing |
ddf6fe37 | 14168 | @item -fipa-strict-aliasing |
d77de738 ML |
14169 | Controls whether rules of @option{-fstrict-aliasing} are applied across |
14170 | function boundaries. Note that if multiple functions gets inlined into a | |
14171 | single function the memory accesses are no longer considered to be crossing a | |
14172 | function boundary. | |
14173 | ||
14174 | The @option{-fipa-strict-aliasing} option is enabled by default and is | |
14175 | effective only in combination with @option{-fstrict-aliasing}. | |
14176 | ||
ddf6fe37 | 14177 | @opindex falign-functions |
d77de738 ML |
14178 | @item -falign-functions |
14179 | @itemx -falign-functions=@var{n} | |
14180 | @itemx -falign-functions=@var{n}:@var{m} | |
14181 | @itemx -falign-functions=@var{n}:@var{m}:@var{n2} | |
14182 | @itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
14183 | Align the start of functions to the next power-of-two greater than or |
14184 | equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at | |
14185 | least the first @var{m} bytes of the function can be fetched by the CPU | |
14186 | without crossing an @var{n}-byte alignment boundary. | |
14187 | ||
14188 | If @var{m} is not specified, it defaults to @var{n}. | |
14189 | ||
14190 | Examples: @option{-falign-functions=32} aligns functions to the next | |
14191 | 32-byte boundary, @option{-falign-functions=24} aligns to the next | |
14192 | 32-byte boundary only if this can be done by skipping 23 bytes or less, | |
14193 | @option{-falign-functions=32:7} aligns to the next | |
14194 | 32-byte boundary only if this can be done by skipping 6 bytes or less. | |
14195 | ||
14196 | The second pair of @var{n2}:@var{m2} values allows you to specify | |
14197 | a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to | |
14198 | the next 64-byte boundary if this can be done by skipping 6 bytes or less, | |
14199 | otherwise aligns to the next 32-byte boundary if this can be done | |
14200 | by skipping 2 bytes or less. | |
14201 | If @var{m2} is not specified, it defaults to @var{n2}. | |
14202 | ||
14203 | Some assemblers only support this flag when @var{n} is a power of two; | |
14204 | in that case, it is rounded up. | |
14205 | ||
14206 | @option{-fno-align-functions} and @option{-falign-functions=1} are | |
14207 | equivalent and mean that functions are not aligned. | |
14208 | ||
14209 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
14210 | The maximum allowed @var{n} option value is 65536. | |
14211 | ||
14212 | Enabled at levels @option{-O2}, @option{-O3}. | |
14213 | ||
14214 | @item -flimit-function-alignment | |
14215 | If this option is enabled, the compiler tries to avoid unnecessarily | |
14216 | overaligning functions. It attempts to instruct the assembler to align | |
14217 | by the amount specified by @option{-falign-functions}, but not to | |
14218 | skip more bytes than the size of the function. | |
14219 | ||
ddf6fe37 | 14220 | @opindex falign-labels |
d77de738 ML |
14221 | @item -falign-labels |
14222 | @itemx -falign-labels=@var{n} | |
14223 | @itemx -falign-labels=@var{n}:@var{m} | |
14224 | @itemx -falign-labels=@var{n}:@var{m}:@var{n2} | |
14225 | @itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
14226 | Align all branch targets to a power-of-two boundary. |
14227 | ||
14228 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
14229 | @option{-fno-align-labels} and @option{-falign-labels=1} are | |
14230 | equivalent and mean that labels are not aligned. | |
14231 | ||
14232 | If @option{-falign-loops} or @option{-falign-jumps} are applicable and | |
14233 | are greater than this value, then their values are used instead. | |
14234 | ||
14235 | If @var{n} is not specified or is zero, use a machine-dependent default | |
14236 | which is very likely to be @samp{1}, meaning no alignment. | |
14237 | The maximum allowed @var{n} option value is 65536. | |
14238 | ||
14239 | Enabled at levels @option{-O2}, @option{-O3}. | |
14240 | ||
ddf6fe37 | 14241 | @opindex falign-loops |
d77de738 ML |
14242 | @item -falign-loops |
14243 | @itemx -falign-loops=@var{n} | |
14244 | @itemx -falign-loops=@var{n}:@var{m} | |
14245 | @itemx -falign-loops=@var{n}:@var{m}:@var{n2} | |
14246 | @itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
14247 | Align loops to a power-of-two boundary. If the loops are executed |
14248 | many times, this makes up for any execution of the dummy padding | |
14249 | instructions. | |
14250 | ||
14251 | If @option{-falign-labels} is greater than this value, then its value | |
14252 | is used instead. | |
14253 | ||
14254 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
14255 | @option{-fno-align-loops} and @option{-falign-loops=1} are | |
14256 | equivalent and mean that loops are not aligned. | |
14257 | The maximum allowed @var{n} option value is 65536. | |
14258 | ||
14259 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
14260 | ||
14261 | Enabled at levels @option{-O2}, @option{-O3}. | |
14262 | ||
ddf6fe37 | 14263 | @opindex falign-jumps |
d77de738 ML |
14264 | @item -falign-jumps |
14265 | @itemx -falign-jumps=@var{n} | |
14266 | @itemx -falign-jumps=@var{n}:@var{m} | |
14267 | @itemx -falign-jumps=@var{n}:@var{m}:@var{n2} | |
14268 | @itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
14269 | Align branch targets to a power-of-two boundary, for branch targets |
14270 | where the targets can only be reached by jumping. In this case, | |
14271 | no dummy operations need be executed. | |
14272 | ||
14273 | If @option{-falign-labels} is greater than this value, then its value | |
14274 | is used instead. | |
14275 | ||
14276 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
14277 | @option{-fno-align-jumps} and @option{-falign-jumps=1} are | |
14278 | equivalent and mean that loops are not aligned. | |
14279 | ||
14280 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
14281 | The maximum allowed @var{n} option value is 65536. | |
14282 | ||
14283 | Enabled at levels @option{-O2}, @option{-O3}. | |
14284 | ||
d77de738 | 14285 | @opindex fno-allocation-dce |
ddf6fe37 | 14286 | @item -fno-allocation-dce |
d77de738 ML |
14287 | Do not remove unused C++ allocations in dead code elimination. |
14288 | ||
d77de738 | 14289 | @opindex fallow-store-data-races |
ddf6fe37 | 14290 | @item -fallow-store-data-races |
d77de738 ML |
14291 | Allow the compiler to perform optimizations that may introduce new data races |
14292 | on stores, without proving that the variable cannot be concurrently accessed | |
14293 | by other threads. Does not affect optimization of local data. It is safe to | |
14294 | use this option if it is known that global data will not be accessed by | |
14295 | multiple threads. | |
14296 | ||
14297 | Examples of optimizations enabled by @option{-fallow-store-data-races} include | |
14298 | hoisting or if-conversions that may cause a value that was already in memory | |
14299 | to be re-written with that same value. Such re-writing is safe in a single | |
14300 | threaded context but may be unsafe in a multi-threaded context. Note that on | |
14301 | some processors, if-conversions may be required in order to enable | |
14302 | vectorization. | |
14303 | ||
14304 | Enabled at level @option{-Ofast}. | |
14305 | ||
d77de738 | 14306 | @opindex funit-at-a-time |
ddf6fe37 | 14307 | @item -funit-at-a-time |
d77de738 ML |
14308 | This option is left for compatibility reasons. @option{-funit-at-a-time} |
14309 | has no effect, while @option{-fno-unit-at-a-time} implies | |
14310 | @option{-fno-toplevel-reorder} and @option{-fno-section-anchors}. | |
14311 | ||
14312 | Enabled by default. | |
14313 | ||
d77de738 ML |
14314 | @opindex fno-toplevel-reorder |
14315 | @opindex ftoplevel-reorder | |
ddf6fe37 | 14316 | @item -fno-toplevel-reorder |
d77de738 ML |
14317 | Do not reorder top-level functions, variables, and @code{asm} |
14318 | statements. Output them in the same order that they appear in the | |
14319 | input file. When this option is used, unreferenced static variables | |
14320 | are not removed. This option is intended to support existing code | |
14321 | that relies on a particular ordering. For new code, it is better to | |
14322 | use attributes when possible. | |
14323 | ||
14324 | @option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and | |
14325 | also at @option{-O0} if @option{-fsection-anchors} is explicitly requested. | |
14326 | Additionally @option{-fno-toplevel-reorder} implies | |
14327 | @option{-fno-section-anchors}. | |
14328 | ||
d77de738 | 14329 | @opindex funreachable-traps |
ddf6fe37 | 14330 | @item -funreachable-traps |
d77de738 ML |
14331 | With this option, the compiler turns calls to |
14332 | @code{__builtin_unreachable} into traps, instead of using them for | |
14333 | optimization. This also affects any such calls implicitly generated | |
14334 | by the compiler. | |
14335 | ||
14336 | This option has the same effect as @option{-fsanitize=unreachable | |
14337 | -fsanitize-trap=unreachable}, but does not affect the values of those | |
14338 | options. If @option{-fsanitize=unreachable} is enabled, that option | |
14339 | takes priority over this one. | |
14340 | ||
14341 | This option is enabled by default at @option{-O0} and @option{-Og}. | |
14342 | ||
d77de738 | 14343 | @opindex fweb |
ddf6fe37 | 14344 | @item -fweb |
d77de738 ML |
14345 | Constructs webs as commonly used for register allocation purposes and assign |
14346 | each web individual pseudo register. This allows the register allocation pass | |
14347 | to operate on pseudos directly, but also strengthens several other optimization | |
14348 | passes, such as CSE, loop optimizer and trivial dead code remover. It can, | |
14349 | however, make debugging impossible, since variables no longer stay in a | |
14350 | ``home register''. | |
14351 | ||
14352 | Enabled by default with @option{-funroll-loops}. | |
14353 | ||
d77de738 | 14354 | @opindex fwhole-program |
ddf6fe37 | 14355 | @item -fwhole-program |
d77de738 ML |
14356 | Assume that the current compilation unit represents the whole program being |
14357 | compiled. All public functions and variables with the exception of @code{main} | |
14358 | and those merged by attribute @code{externally_visible} become static functions | |
14359 | and in effect are optimized more aggressively by interprocedural optimizers. | |
14360 | ||
39ebd3a9 JH |
14361 | With @option{-flto} this option has a limited use. In most cases the |
14362 | precise list of symbols used or exported from the binary is known the | |
14363 | resolution info passed to the link-time optimizer by the linker plugin. It is | |
14364 | still useful if no linker plugin is used or during incremental link step when | |
14365 | final code is produced (with @option{-flto} | |
14366 | @option{-flinker-output=nolto-rel}). | |
d77de738 | 14367 | |
d77de738 | 14368 | @opindex flto |
ddf6fe37 | 14369 | @item -flto[=@var{n}] |
d77de738 ML |
14370 | This option runs the standard link-time optimizer. When invoked |
14371 | with source code, it generates GIMPLE (one of GCC's internal | |
14372 | representations) and writes it to special ELF sections in the object | |
14373 | file. When the object files are linked together, all the function | |
14374 | bodies are read from these ELF sections and instantiated as if they | |
14375 | had been part of the same translation unit. | |
14376 | ||
14377 | To use the link-time optimizer, @option{-flto} and optimization | |
14378 | options should be specified at compile time and during the final link. | |
14379 | It is recommended that you compile all the files participating in the | |
14380 | same link with the same options and also specify those options at | |
14381 | link time. | |
14382 | For example: | |
14383 | ||
14384 | @smallexample | |
14385 | gcc -c -O2 -flto foo.c | |
14386 | gcc -c -O2 -flto bar.c | |
14387 | gcc -o myprog -flto -O2 foo.o bar.o | |
14388 | @end smallexample | |
14389 | ||
14390 | The first two invocations to GCC save a bytecode representation | |
14391 | of GIMPLE into special ELF sections inside @file{foo.o} and | |
14392 | @file{bar.o}. The final invocation reads the GIMPLE bytecode from | |
14393 | @file{foo.o} and @file{bar.o}, merges the two files into a single | |
14394 | internal image, and compiles the result as usual. Since both | |
14395 | @file{foo.o} and @file{bar.o} are merged into a single image, this | |
14396 | causes all the interprocedural analyses and optimizations in GCC to | |
14397 | work across the two files as if they were a single one. This means, | |
14398 | for example, that the inliner is able to inline functions in | |
14399 | @file{bar.o} into functions in @file{foo.o} and vice-versa. | |
14400 | ||
14401 | Another (simpler) way to enable link-time optimization is: | |
14402 | ||
14403 | @smallexample | |
14404 | gcc -o myprog -flto -O2 foo.c bar.c | |
14405 | @end smallexample | |
14406 | ||
14407 | The above generates bytecode for @file{foo.c} and @file{bar.c}, | |
14408 | merges them together into a single GIMPLE representation and optimizes | |
14409 | them as usual to produce @file{myprog}. | |
14410 | ||
14411 | The important thing to keep in mind is that to enable link-time | |
14412 | optimizations you need to use the GCC driver to perform the link step. | |
14413 | GCC automatically performs link-time optimization if any of the | |
14414 | objects involved were compiled with the @option{-flto} command-line option. | |
14415 | You can always override | |
14416 | the automatic decision to do link-time optimization | |
14417 | by passing @option{-fno-lto} to the link command. | |
14418 | ||
14419 | To make whole program optimization effective, it is necessary to make | |
14420 | certain whole program assumptions. The compiler needs to know | |
14421 | what functions and variables can be accessed by libraries and runtime | |
14422 | outside of the link-time optimized unit. When supported by the linker, | |
14423 | the linker plugin (see @option{-fuse-linker-plugin}) passes information | |
14424 | to the compiler about used and externally visible symbols. When | |
14425 | the linker plugin is not available, @option{-fwhole-program} should be | |
14426 | used to allow the compiler to make these assumptions, which leads | |
14427 | to more aggressive optimization decisions. | |
14428 | ||
14429 | When a file is compiled with @option{-flto} without | |
14430 | @option{-fuse-linker-plugin}, the generated object file is larger than | |
14431 | a regular object file because it contains GIMPLE bytecodes and the usual | |
14432 | final code (see @option{-ffat-lto-objects}). This means that | |
14433 | object files with LTO information can be linked as normal object | |
14434 | files; if @option{-fno-lto} is passed to the linker, no | |
14435 | interprocedural optimizations are applied. Note that when | |
14436 | @option{-fno-fat-lto-objects} is enabled the compile stage is faster | |
14437 | but you cannot perform a regular, non-LTO link on them. | |
14438 | ||
14439 | When producing the final binary, GCC only | |
14440 | applies link-time optimizations to those files that contain bytecode. | |
14441 | Therefore, you can mix and match object files and libraries with | |
14442 | GIMPLE bytecodes and final object code. GCC automatically selects | |
14443 | which files to optimize in LTO mode and which files to link without | |
14444 | further processing. | |
14445 | ||
14446 | Generally, options specified at link time override those | |
14447 | specified at compile time, although in some cases GCC attempts to infer | |
14448 | link-time options from the settings used to compile the input files. | |
14449 | ||
14450 | If you do not specify an optimization level option @option{-O} at | |
14451 | link time, then GCC uses the highest optimization level | |
14452 | used when compiling the object files. Note that it is generally | |
14453 | ineffective to specify an optimization level option only at link time and | |
14454 | not at compile time, for two reasons. First, compiling without | |
14455 | optimization suppresses compiler passes that gather information | |
14456 | needed for effective optimization at link time. Second, some early | |
14457 | optimization passes can be performed only at compile time and | |
14458 | not at link time. | |
14459 | ||
14460 | There are some code generation flags preserved by GCC when | |
14461 | generating bytecodes, as they need to be used during the final link. | |
14462 | Currently, the following options and their settings are taken from | |
14463 | the first object file that explicitly specifies them: | |
14464 | @option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions}, | |
14465 | @option{-fgnu-tm} and all the @option{-m} target flags. | |
14466 | ||
14467 | The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and | |
14468 | @option{-fPIE} are combined based on the following scheme: | |
14469 | ||
14470 | @smallexample | |
14471 | @option{-fPIC} + @option{-fpic} = @option{-fpic} | |
14472 | @option{-fPIC} + @option{-fno-pic} = @option{-fno-pic} | |
14473 | @option{-fpic/-fPIC} + (no option) = (no option) | |
14474 | @option{-fPIC} + @option{-fPIE} = @option{-fPIE} | |
14475 | @option{-fpic} + @option{-fPIE} = @option{-fpie} | |
14476 | @option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie} | |
14477 | @end smallexample | |
14478 | ||
14479 | Certain ABI-changing flags are required to match in all compilation units, | |
14480 | and trying to override this at link time with a conflicting value | |
14481 | is ignored. This includes options such as @option{-freg-struct-return} | |
14482 | and @option{-fpcc-struct-return}. | |
14483 | ||
14484 | Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow}, | |
14485 | @option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing} | |
14486 | are passed through to the link stage and merged conservatively for | |
14487 | conflicting translation units. Specifically | |
14488 | @option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take | |
14489 | precedence; and for example @option{-ffp-contract=off} takes precedence | |
14490 | over @option{-ffp-contract=fast}. You can override them at link time. | |
14491 | ||
14492 | Diagnostic options such as @option{-Wstringop-overflow} are passed | |
14493 | through to the link stage and their setting matches that of the | |
14494 | compile-step at function granularity. Note that this matters only | |
14495 | for diagnostics emitted during optimization. Note that code | |
14496 | transforms such as inlining can lead to warnings being enabled | |
14497 | or disabled for regions if code not consistent with the setting | |
14498 | at compile time. | |
14499 | ||
14500 | When you need to pass options to the assembler via @option{-Wa} or | |
14501 | @option{-Xassembler} make sure to either compile such translation | |
14502 | units with @option{-fno-lto} or consistently use the same assembler | |
14503 | options on all translation units. You can alternatively also | |
14504 | specify assembler options at LTO link time. | |
14505 | ||
14506 | To enable debug info generation you need to supply @option{-g} at | |
14507 | compile time. If any of the input files at link time were built | |
14508 | with debug info generation enabled the link will enable debug info | |
14509 | generation as well. Any elaborate debug info settings | |
14510 | like the dwarf level @option{-gdwarf-5} need to be explicitly repeated | |
14511 | at the linker command line and mixing different settings in different | |
14512 | translation units is discouraged. | |
14513 | ||
14514 | If LTO encounters objects with C linkage declared with incompatible | |
14515 | types in separate translation units to be linked together (undefined | |
14516 | behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be | |
14517 | issued. The behavior is still undefined at run time. Similar | |
14518 | diagnostics may be raised for other languages. | |
14519 | ||
14520 | Another feature of LTO is that it is possible to apply interprocedural | |
14521 | optimizations on files written in different languages: | |
14522 | ||
14523 | @smallexample | |
14524 | gcc -c -flto foo.c | |
14525 | g++ -c -flto bar.cc | |
14526 | gfortran -c -flto baz.f90 | |
14527 | g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran | |
14528 | @end smallexample | |
14529 | ||
14530 | Notice that the final link is done with @command{g++} to get the C++ | |
14531 | runtime libraries and @option{-lgfortran} is added to get the Fortran | |
14532 | runtime libraries. In general, when mixing languages in LTO mode, you | |
14533 | should use the same link command options as when mixing languages in a | |
14534 | regular (non-LTO) compilation. | |
14535 | ||
14536 | If object files containing GIMPLE bytecode are stored in a library archive, say | |
14537 | @file{libfoo.a}, it is possible to extract and use them in an LTO link if you | |
14538 | are using a linker with plugin support. To create static libraries suitable | |
14539 | for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar} | |
14540 | and @command{ranlib}; | |
14541 | to show the symbols of object files with GIMPLE bytecode, use | |
14542 | @command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib} | |
14543 | and @command{nm} have been compiled with plugin support. At link time, use the | |
14544 | flag @option{-fuse-linker-plugin} to ensure that the library participates in | |
14545 | the LTO optimization process: | |
14546 | ||
14547 | @smallexample | |
14548 | gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo | |
14549 | @end smallexample | |
14550 | ||
14551 | With the linker plugin enabled, the linker extracts the needed | |
14552 | GIMPLE files from @file{libfoo.a} and passes them on to the running GCC | |
14553 | to make them part of the aggregated GIMPLE image to be optimized. | |
14554 | ||
14555 | If you are not using a linker with plugin support and/or do not | |
14556 | enable the linker plugin, then the objects inside @file{libfoo.a} | |
14557 | are extracted and linked as usual, but they do not participate | |
14558 | in the LTO optimization process. In order to make a static library suitable | |
14559 | for both LTO optimization and usual linkage, compile its object files with | |
14560 | @option{-flto} @option{-ffat-lto-objects}. | |
14561 | ||
14562 | Link-time optimizations do not require the presence of the whole program to | |
14563 | operate. If the program does not require any symbols to be exported, it is | |
14564 | possible to combine @option{-flto} and @option{-fwhole-program} to allow | |
14565 | the interprocedural optimizers to use more aggressive assumptions which may | |
14566 | lead to improved optimization opportunities. | |
14567 | Use of @option{-fwhole-program} is not needed when linker plugin is | |
14568 | active (see @option{-fuse-linker-plugin}). | |
14569 | ||
14570 | The current implementation of LTO makes no | |
14571 | attempt to generate bytecode that is portable between different | |
14572 | types of hosts. The bytecode files are versioned and there is a | |
14573 | strict version check, so bytecode files generated in one version of | |
14574 | GCC do not work with an older or newer version of GCC. | |
14575 | ||
14576 | Link-time optimization does not work well with generation of debugging | |
14577 | information on systems other than those using a combination of ELF and | |
14578 | DWARF. | |
14579 | ||
14580 | If you specify the optional @var{n}, the optimization and code | |
14581 | generation done at link time is executed in parallel using @var{n} | |
14582 | parallel jobs by utilizing an installed @command{make} program. The | |
14583 | environment variable @env{MAKE} may be used to override the program | |
14584 | used. | |
14585 | ||
14586 | You can also specify @option{-flto=jobserver} to use GNU make's | |
14587 | job server mode to determine the number of parallel jobs. This | |
14588 | is useful when the Makefile calling GCC is already executing in parallel. | |
14589 | You must prepend a @samp{+} to the command recipe in the parent Makefile | |
14590 | for this to work. This option likely only works if @env{MAKE} is | |
14591 | GNU make. Even without the option value, GCC tries to automatically | |
14592 | detect a running GNU make's job server. | |
14593 | ||
14594 | Use @option{-flto=auto} to use GNU make's job server, if available, | |
14595 | or otherwise fall back to autodetection of the number of CPU threads | |
14596 | present in your system. | |
14597 | ||
d77de738 | 14598 | @opindex flto-partition |
ddf6fe37 | 14599 | @item -flto-partition=@var{alg} |
d77de738 ML |
14600 | Specify the partitioning algorithm used by the link-time optimizer. |
14601 | The value is either @samp{1to1} to specify a partitioning mirroring | |
14602 | the original source files or @samp{balanced} to specify partitioning | |
14603 | into equally sized chunks (whenever possible) or @samp{max} to create | |
14604 | new partition for every symbol where possible. Specifying @samp{none} | |
14605 | as an algorithm disables partitioning and streaming completely. | |
14606 | The default value is @samp{balanced}. While @samp{1to1} can be used | |
14607 | as an workaround for various code ordering issues, the @samp{max} | |
14608 | partitioning is intended for internal testing only. | |
14609 | The value @samp{one} specifies that exactly one partition should be | |
14610 | used while the value @samp{none} bypasses partitioning and executes | |
14611 | the link-time optimization step directly from the WPA phase. | |
14612 | ||
d77de738 | 14613 | @opindex flto-compression-level |
ddf6fe37 | 14614 | @item -flto-compression-level=@var{n} |
d77de738 ML |
14615 | This option specifies the level of compression used for intermediate |
14616 | language written to LTO object files, and is only meaningful in | |
14617 | conjunction with LTO mode (@option{-flto}). GCC currently supports two | |
14618 | LTO compression algorithms. For zstd, valid values are 0 (no compression) | |
14619 | to 19 (maximum compression), while zlib supports values from 0 to 9. | |
14620 | Values outside this range are clamped to either minimum or maximum | |
14621 | of the supported values. If the option is not given, | |
14622 | a default balanced compression setting is used. | |
14623 | ||
d77de738 | 14624 | @opindex fuse-linker-plugin |
ddf6fe37 | 14625 | @item -fuse-linker-plugin |
d77de738 ML |
14626 | Enables the use of a linker plugin during link-time optimization. This |
14627 | option relies on plugin support in the linker, which is available in gold | |
14628 | or in GNU ld 2.21 or newer. | |
14629 | ||
14630 | This option enables the extraction of object files with GIMPLE bytecode out | |
14631 | of library archives. This improves the quality of optimization by exposing | |
14632 | more code to the link-time optimizer. This information specifies what | |
14633 | symbols can be accessed externally (by non-LTO object or during dynamic | |
14634 | linking). Resulting code quality improvements on binaries (and shared | |
14635 | libraries that use hidden visibility) are similar to @option{-fwhole-program}. | |
14636 | See @option{-flto} for a description of the effect of this flag and how to | |
14637 | use it. | |
14638 | ||
14639 | This option is enabled by default when LTO support in GCC is enabled | |
14640 | and GCC was configured for use with | |
14641 | a linker supporting plugins (GNU ld 2.21 or newer or gold). | |
14642 | ||
d77de738 | 14643 | @opindex ffat-lto-objects |
ddf6fe37 | 14644 | @item -ffat-lto-objects |
d77de738 ML |
14645 | Fat LTO objects are object files that contain both the intermediate language |
14646 | and the object code. This makes them usable for both LTO linking and normal | |
14647 | linking. This option is effective only when compiling with @option{-flto} | |
14648 | and is ignored at link time. | |
14649 | ||
14650 | @option{-fno-fat-lto-objects} improves compilation time over plain LTO, but | |
14651 | requires the complete toolchain to be aware of LTO. It requires a linker with | |
14652 | linker plugin support for basic functionality. Additionally, | |
14653 | @command{nm}, @command{ar} and @command{ranlib} | |
14654 | need to support linker plugins to allow a full-featured build environment | |
14655 | (capable of building static libraries etc). GCC provides the @command{gcc-ar}, | |
14656 | @command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options | |
14657 | to these tools. With non fat LTO makefiles need to be modified to use them. | |
14658 | ||
14659 | Note that modern binutils provide plugin auto-load mechanism. | |
14660 | Installing the linker plugin into @file{$libdir/bfd-plugins} has the same | |
14661 | effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and | |
14662 | @command{gcc-ranlib}). | |
14663 | ||
14664 | The default is @option{-fno-fat-lto-objects} on targets with linker plugin | |
14665 | support. | |
14666 | ||
d77de738 | 14667 | @opindex fcompare-elim |
ddf6fe37 | 14668 | @item -fcompare-elim |
d77de738 ML |
14669 | After register allocation and post-register allocation instruction splitting, |
14670 | identify arithmetic instructions that compute processor flags similar to a | |
14671 | comparison operation based on that arithmetic. If possible, eliminate the | |
14672 | explicit comparison operation. | |
14673 | ||
14674 | This pass only applies to certain targets that cannot explicitly represent | |
14675 | the comparison operation before register allocation is complete. | |
14676 | ||
14677 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
14678 | ||
04c9cf5c MT |
14679 | @opindex ffold-mem-offsets |
14680 | @item -ffold-mem-offsets | |
14681 | @itemx -fno-fold-mem-offsets | |
14682 | Try to eliminate add instructions by folding them in memory loads/stores. | |
14683 | ||
14684 | Enabled at levels @option{-O2}, @option{-O3}. | |
14685 | ||
d77de738 | 14686 | @opindex fcprop-registers |
ddf6fe37 | 14687 | @item -fcprop-registers |
d77de738 ML |
14688 | After register allocation and post-register allocation instruction splitting, |
14689 | perform a copy-propagation pass to try to reduce scheduling dependencies | |
14690 | and occasionally eliminate the copy. | |
14691 | ||
14692 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
14693 | ||
d77de738 | 14694 | @opindex fprofile-correction |
ddf6fe37 | 14695 | @item -fprofile-correction |
d77de738 ML |
14696 | Profiles collected using an instrumented binary for multi-threaded programs may |
14697 | be inconsistent due to missed counter updates. When this option is specified, | |
14698 | GCC uses heuristics to correct or smooth out such inconsistencies. By | |
14699 | default, GCC emits an error message when an inconsistent profile is detected. | |
14700 | ||
14701 | This option is enabled by @option{-fauto-profile}. | |
14702 | ||
d77de738 | 14703 | @opindex fprofile-partial-training |
ddf6fe37 | 14704 | @item -fprofile-partial-training |
d77de738 ML |
14705 | With @code{-fprofile-use} all portions of programs not executed during train |
14706 | run are optimized agressively for size rather than speed. In some cases it is | |
14707 | not practical to train all possible hot paths in the program. (For | |
14708 | example, program may contain functions specific for a given hardware and | |
14709 | trianing may not cover all hardware configurations program is run on.) With | |
14710 | @code{-fprofile-partial-training} profile feedback will be ignored for all | |
14711 | functions not executed during the train run leading them to be optimized as if | |
14712 | they were compiled without profile feedback. This leads to better performance | |
14713 | when train run is not representative but also leads to significantly bigger | |
14714 | code. | |
14715 | ||
ddf6fe37 | 14716 | @opindex fprofile-use |
d77de738 ML |
14717 | @item -fprofile-use |
14718 | @itemx -fprofile-use=@var{path} | |
d77de738 ML |
14719 | Enable profile feedback-directed optimizations, |
14720 | and the following optimizations, many of which | |
14721 | are generally profitable only with profile feedback available: | |
14722 | ||
43b72ede AA |
14723 | @gccoptlist{-fbranch-probabilities -fprofile-values |
14724 | -funroll-loops -fpeel-loops -ftracer -fvpt | |
14725 | -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp | |
14726 | -fpredictive-commoning -fsplit-loops -funswitch-loops | |
14727 | -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize | |
14728 | -fvect-cost-model=dynamic -ftree-loop-distribute-patterns | |
d77de738 ML |
14729 | -fprofile-reorder-functions} |
14730 | ||
14731 | Before you can use this option, you must first generate profiling information. | |
14732 | @xref{Instrumentation Options}, for information about the | |
14733 | @option{-fprofile-generate} option. | |
14734 | ||
14735 | By default, GCC emits an error message if the feedback profiles do not | |
14736 | match the source code. This error can be turned into a warning by using | |
14737 | @option{-Wno-error=coverage-mismatch}. Note this may result in poorly | |
14738 | optimized code. Additionally, by default, GCC also emits a warning message if | |
14739 | the feedback profiles do not exist (see @option{-Wmissing-profile}). | |
14740 | ||
14741 | If @var{path} is specified, GCC looks at the @var{path} to find | |
14742 | the profile feedback data files. See @option{-fprofile-dir}. | |
14743 | ||
ddf6fe37 | 14744 | @opindex fauto-profile |
d77de738 ML |
14745 | @item -fauto-profile |
14746 | @itemx -fauto-profile=@var{path} | |
d77de738 ML |
14747 | Enable sampling-based feedback-directed optimizations, |
14748 | and the following optimizations, | |
14749 | many of which are generally profitable only with profile feedback available: | |
14750 | ||
43b72ede AA |
14751 | @gccoptlist{-fbranch-probabilities -fprofile-values |
14752 | -funroll-loops -fpeel-loops -ftracer -fvpt | |
14753 | -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp | |
14754 | -fpredictive-commoning -fsplit-loops -funswitch-loops | |
14755 | -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize | |
14756 | -fvect-cost-model=dynamic -ftree-loop-distribute-patterns | |
d77de738 ML |
14757 | -fprofile-correction} |
14758 | ||
14759 | @var{path} is the name of a file containing AutoFDO profile information. | |
14760 | If omitted, it defaults to @file{fbdata.afdo} in the current directory. | |
14761 | ||
14762 | Producing an AutoFDO profile data file requires running your program | |
14763 | with the @command{perf} utility on a supported GNU/Linux target system. | |
14764 | For more information, see @uref{https://perf.wiki.kernel.org/}. | |
14765 | ||
14766 | E.g. | |
14767 | @smallexample | |
14768 | perf record -e br_inst_retired:near_taken -b -o perf.data \ | |
14769 | -- your_program | |
14770 | @end smallexample | |
14771 | ||
14772 | Then use the @command{create_gcov} tool to convert the raw profile data | |
14773 | to a format that can be used by GCC.@ You must also supply the | |
14774 | unstripped binary for your program to this tool. | |
14775 | See @uref{https://github.com/google/autofdo}. | |
14776 | ||
14777 | E.g. | |
14778 | @smallexample | |
14779 | create_gcov --binary=your_program.unstripped --profile=perf.data \ | |
14780 | --gcov=profile.afdo | |
14781 | @end smallexample | |
14782 | @end table | |
14783 | ||
14784 | The following options control compiler behavior regarding floating-point | |
14785 | arithmetic. These options trade off between speed and | |
14786 | correctness. All must be specifically enabled. | |
14787 | ||
14788 | @table @gcctabopt | |
d77de738 | 14789 | @opindex ffloat-store |
ddf6fe37 | 14790 | @item -ffloat-store |
d77de738 ML |
14791 | Do not store floating-point variables in registers, and inhibit other |
14792 | options that might change whether a floating-point value is taken from a | |
14793 | register or memory. | |
14794 | ||
14795 | @cindex floating-point precision | |
14796 | This option prevents undesirable excess precision on machines such as | |
14797 | the 68000 where the floating registers (of the 68881) keep more | |
14798 | precision than a @code{double} is supposed to have. Similarly for the | |
14799 | x86 architecture. For most programs, the excess precision does only | |
14800 | good, but a few programs rely on the precise definition of IEEE floating | |
14801 | point. Use @option{-ffloat-store} for such programs, after modifying | |
14802 | them to store all pertinent intermediate computations into variables. | |
14803 | ||
d77de738 | 14804 | @opindex fexcess-precision |
ddf6fe37 | 14805 | @item -fexcess-precision=@var{style} |
d77de738 ML |
14806 | This option allows further control over excess precision on machines |
14807 | where floating-point operations occur in a format with more precision or | |
14808 | range than the IEEE standard and interchange floating-point types. By | |
14809 | default, @option{-fexcess-precision=fast} is in effect; this means that | |
14810 | operations may be carried out in a wider precision than the types specified | |
14811 | in the source if that would result in faster code, and it is unpredictable | |
14812 | when rounding to the types specified in the source code takes place. | |
14813 | When compiling C or C++, if @option{-fexcess-precision=standard} is specified | |
14814 | then excess precision follows the rules specified in ISO C99 or C++; in particular, | |
14815 | both casts and assignments cause values to be rounded to their | |
14816 | semantic types (whereas @option{-ffloat-store} only affects | |
14817 | assignments). This option is enabled by default for C or C++ if a strict | |
14818 | conformance option such as @option{-std=c99} or @option{-std=c++17} is used. | |
14819 | @option{-ffast-math} enables @option{-fexcess-precision=fast} by default | |
14820 | regardless of whether a strict conformance option is used. | |
14821 | ||
14822 | @opindex mfpmath | |
14823 | @option{-fexcess-precision=standard} is not implemented for languages | |
14824 | other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse} | |
14825 | or @option{-mfpmath=sse+387} is specified; in the former case, IEEE | |
14826 | semantics apply without excess precision, and in the latter, rounding | |
14827 | is unpredictable. | |
14828 | ||
d77de738 | 14829 | @opindex ffast-math |
ddf6fe37 | 14830 | @item -ffast-math |
d77de738 ML |
14831 | Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, |
14832 | @option{-ffinite-math-only}, @option{-fno-rounding-math}, | |
14833 | @option{-fno-signaling-nans}, @option{-fcx-limited-range} and | |
14834 | @option{-fexcess-precision=fast}. | |
14835 | ||
14836 | This option causes the preprocessor macro @code{__FAST_MATH__} to be defined. | |
14837 | ||
14838 | This option is not turned on by any @option{-O} option besides | |
14839 | @option{-Ofast} since it can result in incorrect output for programs | |
14840 | that depend on an exact implementation of IEEE or ISO rules/specifications | |
14841 | for math functions. It may, however, yield faster code for programs | |
14842 | that do not require the guarantees of these specifications. | |
14843 | ||
d77de738 ML |
14844 | @opindex fno-math-errno |
14845 | @opindex fmath-errno | |
ddf6fe37 | 14846 | @item -fno-math-errno |
d77de738 ML |
14847 | Do not set @code{errno} after calling math functions that are executed |
14848 | with a single instruction, e.g., @code{sqrt}. A program that relies on | |
14849 | IEEE exceptions for math error handling may want to use this flag | |
14850 | for speed while maintaining IEEE arithmetic compatibility. | |
14851 | ||
14852 | This option is not turned on by any @option{-O} option since | |
14853 | it can result in incorrect output for programs that depend on | |
14854 | an exact implementation of IEEE or ISO rules/specifications for | |
14855 | math functions. It may, however, yield faster code for programs | |
14856 | that do not require the guarantees of these specifications. | |
14857 | ||
14858 | The default is @option{-fmath-errno}. | |
14859 | ||
14860 | On Darwin systems, the math library never sets @code{errno}. There is | |
14861 | therefore no reason for the compiler to consider the possibility that | |
14862 | it might, and @option{-fno-math-errno} is the default. | |
14863 | ||
d77de738 | 14864 | @opindex funsafe-math-optimizations |
ddf6fe37 | 14865 | @item -funsafe-math-optimizations |
d77de738 ML |
14866 | |
14867 | Allow optimizations for floating-point arithmetic that (a) assume | |
14868 | that arguments and results are valid and (b) may violate IEEE or | |
14869 | ANSI standards. When used at link time, it may include libraries | |
14870 | or startup files that change the default FPU control word or other | |
14871 | similar optimizations. | |
14872 | ||
14873 | This option is not turned on by any @option{-O} option since | |
14874 | it can result in incorrect output for programs that depend on | |
14875 | an exact implementation of IEEE or ISO rules/specifications for | |
14876 | math functions. It may, however, yield faster code for programs | |
14877 | that do not require the guarantees of these specifications. | |
14878 | Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math}, | |
14879 | @option{-fassociative-math} and @option{-freciprocal-math}. | |
14880 | ||
14881 | The default is @option{-fno-unsafe-math-optimizations}. | |
14882 | ||
d77de738 | 14883 | @opindex fassociative-math |
ddf6fe37 | 14884 | @item -fassociative-math |
d77de738 ML |
14885 | |
14886 | Allow re-association of operands in series of floating-point operations. | |
14887 | This violates the ISO C and C++ language standard by possibly changing | |
14888 | computation result. NOTE: re-ordering may change the sign of zero as | |
14889 | well as ignore NaNs and inhibit or create underflow or overflow (and | |
14890 | thus cannot be used on code that relies on rounding behavior like | |
14891 | @code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons | |
14892 | and thus may not be used when ordered comparisons are required. | |
14893 | This option requires that both @option{-fno-signed-zeros} and | |
14894 | @option{-fno-trapping-math} be in effect. Moreover, it doesn't make | |
14895 | much sense with @option{-frounding-math}. For Fortran the option | |
14896 | is automatically enabled when both @option{-fno-signed-zeros} and | |
14897 | @option{-fno-trapping-math} are in effect. | |
14898 | ||
14899 | The default is @option{-fno-associative-math}. | |
14900 | ||
d77de738 | 14901 | @opindex freciprocal-math |
ddf6fe37 | 14902 | @item -freciprocal-math |
d77de738 ML |
14903 | |
14904 | Allow the reciprocal of a value to be used instead of dividing by | |
14905 | the value if this enables optimizations. For example @code{x / y} | |
14906 | can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)} | |
14907 | is subject to common subexpression elimination. Note that this loses | |
14908 | precision and increases the number of flops operating on the value. | |
14909 | ||
14910 | The default is @option{-fno-reciprocal-math}. | |
14911 | ||
d77de738 | 14912 | @opindex ffinite-math-only |
ddf6fe37 | 14913 | @item -ffinite-math-only |
d77de738 ML |
14914 | Allow optimizations for floating-point arithmetic that assume |
14915 | that arguments and results are not NaNs or +-Infs. | |
14916 | ||
14917 | This option is not turned on by any @option{-O} option since | |
14918 | it can result in incorrect output for programs that depend on | |
14919 | an exact implementation of IEEE or ISO rules/specifications for | |
14920 | math functions. It may, however, yield faster code for programs | |
14921 | that do not require the guarantees of these specifications. | |
14922 | ||
14923 | The default is @option{-fno-finite-math-only}. | |
14924 | ||
d77de738 ML |
14925 | @opindex fno-signed-zeros |
14926 | @opindex fsigned-zeros | |
ddf6fe37 | 14927 | @item -fno-signed-zeros |
d77de738 ML |
14928 | Allow optimizations for floating-point arithmetic that ignore the |
14929 | signedness of zero. IEEE arithmetic specifies the behavior of | |
14930 | distinct +0.0 and @minus{}0.0 values, which then prohibits simplification | |
14931 | of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}). | |
14932 | This option implies that the sign of a zero result isn't significant. | |
14933 | ||
14934 | The default is @option{-fsigned-zeros}. | |
14935 | ||
d77de738 ML |
14936 | @opindex fno-trapping-math |
14937 | @opindex ftrapping-math | |
ddf6fe37 | 14938 | @item -fno-trapping-math |
d77de738 ML |
14939 | Compile code assuming that floating-point operations cannot generate |
14940 | user-visible traps. These traps include division by zero, overflow, | |
14941 | underflow, inexact result and invalid operation. This option requires | |
14942 | that @option{-fno-signaling-nans} be in effect. Setting this option may | |
14943 | allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example. | |
14944 | ||
14945 | This option should never be turned on by any @option{-O} option since | |
14946 | it can result in incorrect output for programs that depend on | |
14947 | an exact implementation of IEEE or ISO rules/specifications for | |
14948 | math functions. | |
14949 | ||
14950 | The default is @option{-ftrapping-math}. | |
14951 | ||
14952 | Future versions of GCC may provide finer control of this setting | |
14953 | using C99's @code{FENV_ACCESS} pragma. This command-line option | |
14954 | will be used along with @option{-frounding-math} to specify the | |
14955 | default state for @code{FENV_ACCESS}. | |
14956 | ||
d77de738 | 14957 | @opindex frounding-math |
ddf6fe37 | 14958 | @item -frounding-math |
d77de738 ML |
14959 | Disable transformations and optimizations that assume default floating-point |
14960 | rounding behavior. This is round-to-zero for all floating point | |
14961 | to integer conversions, and round-to-nearest for all other arithmetic | |
14962 | truncations. This option should be specified for programs that change | |
14963 | the FP rounding mode dynamically, or that may be executed with a | |
14964 | non-default rounding mode. This option disables constant folding of | |
14965 | floating-point expressions at compile time (which may be affected by | |
14966 | rounding mode) and arithmetic transformations that are unsafe in the | |
14967 | presence of sign-dependent rounding modes. | |
14968 | ||
14969 | The default is @option{-fno-rounding-math}. | |
14970 | ||
14971 | This option is experimental and does not currently guarantee to | |
14972 | disable all GCC optimizations that are affected by rounding mode. | |
14973 | Future versions of GCC may provide finer control of this setting | |
14974 | using C99's @code{FENV_ACCESS} pragma. This command-line option | |
14975 | will be used along with @option{-ftrapping-math} to specify the | |
14976 | default state for @code{FENV_ACCESS}. | |
14977 | ||
d77de738 | 14978 | @opindex fsignaling-nans |
ddf6fe37 | 14979 | @item -fsignaling-nans |
d77de738 ML |
14980 | Compile code assuming that IEEE signaling NaNs may generate user-visible |
14981 | traps during floating-point operations. Setting this option disables | |
14982 | optimizations that may change the number of exceptions visible with | |
14983 | signaling NaNs. This option implies @option{-ftrapping-math}. | |
14984 | ||
14985 | This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to | |
14986 | be defined. | |
14987 | ||
14988 | The default is @option{-fno-signaling-nans}. | |
14989 | ||
14990 | This option is experimental and does not currently guarantee to | |
14991 | disable all GCC optimizations that affect signaling NaN behavior. | |
14992 | ||
d77de738 ML |
14993 | @opindex fno-fp-int-builtin-inexact |
14994 | @opindex ffp-int-builtin-inexact | |
ddf6fe37 | 14995 | @item -fno-fp-int-builtin-inexact |
d77de738 ML |
14996 | Do not allow the built-in functions @code{ceil}, @code{floor}, |
14997 | @code{round} and @code{trunc}, and their @code{float} and @code{long | |
14998 | double} variants, to generate code that raises the ``inexact'' | |
14999 | floating-point exception for noninteger arguments. ISO C99 and C11 | |
15000 | allow these functions to raise the ``inexact'' exception, but ISO/IEC | |
15001 | TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into | |
094a609c | 15002 | ISO C23, does not allow these functions to do so. |
d77de738 ML |
15003 | |
15004 | The default is @option{-ffp-int-builtin-inexact}, allowing the | |
094a609c | 15005 | exception to be raised, unless C23 or a later C standard is selected. |
d77de738 ML |
15006 | This option does nothing unless @option{-ftrapping-math} is in effect. |
15007 | ||
15008 | Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions | |
15009 | generate a call to a library function then the ``inexact'' exception | |
15010 | may be raised if the library implementation does not follow TS 18661. | |
15011 | ||
d77de738 | 15012 | @opindex fsingle-precision-constant |
ddf6fe37 | 15013 | @item -fsingle-precision-constant |
d77de738 ML |
15014 | Treat floating-point constants as single precision instead of |
15015 | implicitly converting them to double-precision constants. | |
15016 | ||
d77de738 | 15017 | @opindex fcx-limited-range |
ddf6fe37 | 15018 | @item -fcx-limited-range |
d77de738 ML |
15019 | When enabled, this option states that a range reduction step is not |
15020 | needed when performing complex division. Also, there is no checking | |
15021 | whether the result of a complex multiplication or division is @code{NaN | |
15022 | + I*NaN}, with an attempt to rescue the situation in that case. The | |
15023 | default is @option{-fno-cx-limited-range}, but is enabled by | |
15024 | @option{-ffast-math}. | |
15025 | ||
15026 | This option controls the default setting of the ISO C99 | |
15027 | @code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to | |
15028 | all languages. | |
15029 | ||
d77de738 | 15030 | @opindex fcx-fortran-rules |
ddf6fe37 | 15031 | @item -fcx-fortran-rules |
d77de738 ML |
15032 | Complex multiplication and division follow Fortran rules. Range |
15033 | reduction is done as part of complex division, but there is no checking | |
15034 | whether the result of a complex multiplication or division is @code{NaN | |
15035 | + I*NaN}, with an attempt to rescue the situation in that case. | |
15036 | ||
15037 | The default is @option{-fno-cx-fortran-rules}. | |
15038 | ||
15039 | @end table | |
15040 | ||
15041 | The following options control optimizations that may improve | |
15042 | performance, but are not enabled by any @option{-O} options. This | |
15043 | section includes experimental options that may produce broken code. | |
15044 | ||
15045 | @table @gcctabopt | |
d77de738 | 15046 | @opindex fbranch-probabilities |
ddf6fe37 | 15047 | @item -fbranch-probabilities |
d77de738 ML |
15048 | After running a program compiled with @option{-fprofile-arcs} |
15049 | (@pxref{Instrumentation Options}), | |
15050 | you can compile it a second time using | |
15051 | @option{-fbranch-probabilities}, to improve optimizations based on | |
15052 | the number of times each branch was taken. When a program | |
15053 | compiled with @option{-fprofile-arcs} exits, it saves arc execution | |
15054 | counts to a file called @file{@var{sourcename}.gcda} for each source | |
15055 | file. The information in this data file is very dependent on the | |
15056 | structure of the generated code, so you must use the same source code | |
15057 | and the same optimization options for both compilations. | |
15058 | See details about the file naming in @option{-fprofile-arcs}. | |
15059 | ||
15060 | With @option{-fbranch-probabilities}, GCC puts a | |
15061 | @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}. | |
15062 | These can be used to improve optimization. Currently, they are only | |
15063 | used in one place: in @file{reorg.cc}, instead of guessing which path a | |
15064 | branch is most likely to take, the @samp{REG_BR_PROB} values are used to | |
15065 | exactly determine which path is taken more often. | |
15066 | ||
15067 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
15068 | ||
d77de738 | 15069 | @opindex fprofile-values |
ddf6fe37 | 15070 | @item -fprofile-values |
d77de738 ML |
15071 | If combined with @option{-fprofile-arcs}, it adds code so that some |
15072 | data about values of expressions in the program is gathered. | |
15073 | ||
15074 | With @option{-fbranch-probabilities}, it reads back the data gathered | |
15075 | from profiling values of expressions for usage in optimizations. | |
15076 | ||
15077 | Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and | |
15078 | @option{-fauto-profile}. | |
15079 | ||
d77de738 | 15080 | @opindex fprofile-reorder-functions |
ddf6fe37 | 15081 | @item -fprofile-reorder-functions |
d77de738 ML |
15082 | Function reordering based on profile instrumentation collects |
15083 | first time of execution of a function and orders these functions | |
15084 | in ascending order. | |
15085 | ||
15086 | Enabled with @option{-fprofile-use}. | |
15087 | ||
d77de738 | 15088 | @opindex fvpt |
ddf6fe37 | 15089 | @item -fvpt |
d77de738 ML |
15090 | If combined with @option{-fprofile-arcs}, this option instructs the compiler |
15091 | to add code to gather information about values of expressions. | |
15092 | ||
15093 | With @option{-fbranch-probabilities}, it reads back the data gathered | |
15094 | and actually performs the optimizations based on them. | |
15095 | Currently the optimizations include specialization of division operations | |
15096 | using the knowledge about the value of the denominator. | |
15097 | ||
15098 | Enabled with @option{-fprofile-use} and @option{-fauto-profile}. | |
15099 | ||
d77de738 | 15100 | @opindex frename-registers |
ddf6fe37 | 15101 | @item -frename-registers |
d77de738 ML |
15102 | Attempt to avoid false dependencies in scheduled code by making use |
15103 | of registers left over after register allocation. This optimization | |
15104 | most benefits processors with lots of registers. Depending on the | |
15105 | debug information format adopted by the target, however, it can | |
15106 | make debugging impossible, since variables no longer stay in | |
15107 | a ``home register''. | |
15108 | ||
15109 | Enabled by default with @option{-funroll-loops}. | |
15110 | ||
d77de738 | 15111 | @opindex fschedule-fusion |
ddf6fe37 | 15112 | @item -fschedule-fusion |
d77de738 ML |
15113 | Performs a target dependent pass over the instruction stream to schedule |
15114 | instructions of same type together because target machine can execute them | |
15115 | more efficiently if they are adjacent to each other in the instruction flow. | |
15116 | ||
15117 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
15118 | ||
d77de738 | 15119 | @opindex ftracer |
ddf6fe37 | 15120 | @item -ftracer |
d77de738 ML |
15121 | Perform tail duplication to enlarge superblock size. This transformation |
15122 | simplifies the control flow of the function allowing other optimizations to do | |
15123 | a better job. | |
15124 | ||
15125 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
15126 | ||
d77de738 | 15127 | @opindex funroll-loops |
ddf6fe37 | 15128 | @item -funroll-loops |
d77de738 ML |
15129 | Unroll loops whose number of iterations can be determined at compile time or |
15130 | upon entry to the loop. @option{-funroll-loops} implies | |
15131 | @option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}. | |
15132 | It also turns on complete loop peeling (i.e.@: complete removal of loops with | |
15133 | a small constant number of iterations). This option makes code larger, and may | |
15134 | or may not make it run faster. | |
15135 | ||
15136 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
15137 | ||
d77de738 | 15138 | @opindex funroll-all-loops |
ddf6fe37 | 15139 | @item -funroll-all-loops |
d77de738 ML |
15140 | Unroll all loops, even if their number of iterations is uncertain when |
15141 | the loop is entered. This usually makes programs run more slowly. | |
15142 | @option{-funroll-all-loops} implies the same options as | |
15143 | @option{-funroll-loops}. | |
15144 | ||
d77de738 | 15145 | @opindex fpeel-loops |
ddf6fe37 | 15146 | @item -fpeel-loops |
d77de738 ML |
15147 | Peels loops for which there is enough information that they do not |
15148 | roll much (from profile feedback or static analysis). It also turns on | |
15149 | complete loop peeling (i.e.@: complete removal of loops with small constant | |
15150 | number of iterations). | |
15151 | ||
15152 | Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}. | |
15153 | ||
d77de738 | 15154 | @opindex fmove-loop-invariants |
ddf6fe37 | 15155 | @item -fmove-loop-invariants |
d77de738 ML |
15156 | Enables the loop invariant motion pass in the RTL loop optimizer. Enabled |
15157 | at level @option{-O1} and higher, except for @option{-Og}. | |
15158 | ||
d77de738 | 15159 | @opindex fmove-loop-stores |
ddf6fe37 | 15160 | @item -fmove-loop-stores |
d77de738 ML |
15161 | Enables the loop store motion pass in the GIMPLE loop optimizer. This |
15162 | moves invariant stores to after the end of the loop in exchange for | |
15163 | carrying the stored value in a register across the iteration. | |
15164 | Note for this option to have an effect @option{-ftree-loop-im} has to | |
15165 | be enabled as well. Enabled at level @option{-O1} and higher, except | |
15166 | for @option{-Og}. | |
15167 | ||
d77de738 | 15168 | @opindex fsplit-loops |
ddf6fe37 | 15169 | @item -fsplit-loops |
d77de738 ML |
15170 | Split a loop into two if it contains a condition that's always true |
15171 | for one side of the iteration space and false for the other. | |
15172 | ||
15173 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
15174 | ||
d77de738 | 15175 | @opindex funswitch-loops |
ddf6fe37 | 15176 | @item -funswitch-loops |
d77de738 ML |
15177 | Move branches with loop invariant conditions out of the loop, with duplicates |
15178 | of the loop on both branches (modified according to result of the condition). | |
15179 | ||
15180 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
15181 | ||
d77de738 | 15182 | @opindex fversion-loops-for-strides |
ddf6fe37 | 15183 | @item -fversion-loops-for-strides |
d77de738 ML |
15184 | If a loop iterates over an array with a variable stride, create another |
15185 | version of the loop that assumes the stride is always one. For example: | |
15186 | ||
15187 | @smallexample | |
15188 | for (int i = 0; i < n; ++i) | |
15189 | x[i * stride] = @dots{}; | |
15190 | @end smallexample | |
15191 | ||
15192 | becomes: | |
15193 | ||
15194 | @smallexample | |
15195 | if (stride == 1) | |
15196 | for (int i = 0; i < n; ++i) | |
15197 | x[i] = @dots{}; | |
15198 | else | |
15199 | for (int i = 0; i < n; ++i) | |
15200 | x[i * stride] = @dots{}; | |
15201 | @end smallexample | |
15202 | ||
15203 | This is particularly useful for assumed-shape arrays in Fortran where | |
15204 | (for example) it allows better vectorization assuming contiguous accesses. | |
15205 | This flag is enabled by default at @option{-O3}. | |
15206 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
15207 | ||
d77de738 ML |
15208 | @opindex ffunction-sections |
15209 | @opindex fdata-sections | |
ddf6fe37 AA |
15210 | @item -ffunction-sections |
15211 | @itemx -fdata-sections | |
d77de738 ML |
15212 | Place each function or data item into its own section in the output |
15213 | file if the target supports arbitrary sections. The name of the | |
15214 | function or the name of the data item determines the section's name | |
15215 | in the output file. | |
15216 | ||
15217 | Use these options on systems where the linker can perform optimizations to | |
15218 | improve locality of reference in the instruction space. Most systems using the | |
15219 | ELF object format have linkers with such optimizations. On AIX, the linker | |
15220 | rearranges sections (CSECTs) based on the call graph. The performance impact | |
15221 | varies. | |
15222 | ||
15223 | Together with a linker garbage collection (linker @option{--gc-sections} | |
15224 | option) these options may lead to smaller statically-linked executables (after | |
15225 | stripping). | |
15226 | ||
15227 | On ELF/DWARF systems these options do not degenerate the quality of the debug | |
15228 | information. There could be issues with other object files/debug info formats. | |
15229 | ||
15230 | Only use these options when there are significant benefits from doing so. When | |
15231 | you specify these options, the assembler and linker create larger object and | |
15232 | executable files and are also slower. These options affect code generation. | |
15233 | They prevent optimizations by the compiler and assembler using relative | |
15234 | locations inside a translation unit since the locations are unknown until | |
15235 | link time. An example of such an optimization is relaxing calls to short call | |
15236 | instructions. | |
15237 | ||
d77de738 | 15238 | @opindex fstdarg-opt |
ddf6fe37 | 15239 | @item -fstdarg-opt |
d77de738 ML |
15240 | Optimize the prologue of variadic argument functions with respect to usage of |
15241 | those arguments. | |
15242 | ||
d77de738 | 15243 | @opindex fsection-anchors |
ddf6fe37 | 15244 | @item -fsection-anchors |
d77de738 ML |
15245 | Try to reduce the number of symbolic address calculations by using |
15246 | shared ``anchor'' symbols to address nearby objects. This transformation | |
15247 | can help to reduce the number of GOT entries and GOT accesses on some | |
15248 | targets. | |
15249 | ||
15250 | For example, the implementation of the following function @code{foo}: | |
15251 | ||
15252 | @smallexample | |
15253 | static int a, b, c; | |
15254 | int foo (void) @{ return a + b + c; @} | |
15255 | @end smallexample | |
15256 | ||
15257 | @noindent | |
15258 | usually calculates the addresses of all three variables, but if you | |
15259 | compile it with @option{-fsection-anchors}, it accesses the variables | |
15260 | from a common anchor point instead. The effect is similar to the | |
15261 | following pseudocode (which isn't valid C): | |
15262 | ||
15263 | @smallexample | |
15264 | int foo (void) | |
15265 | @{ | |
15266 | register int *xr = &x; | |
15267 | return xr[&a - &x] + xr[&b - &x] + xr[&c - &x]; | |
15268 | @} | |
15269 | @end smallexample | |
15270 | ||
15271 | Not all targets support this option. | |
15272 | ||
d77de738 | 15273 | @opindex fzero-call-used-regs |
ddf6fe37 | 15274 | @item -fzero-call-used-regs=@var{choice} |
d77de738 ML |
15275 | Zero call-used registers at function return to increase program |
15276 | security by either mitigating Return-Oriented Programming (ROP) | |
15277 | attacks or preventing information leakage through registers. | |
15278 | ||
15279 | The possible values of @var{choice} are the same as for the | |
15280 | @code{zero_call_used_regs} attribute (@pxref{Function Attributes}). | |
15281 | The default is @samp{skip}. | |
15282 | ||
15283 | You can control this behavior for a specific function by using the function | |
15284 | attribute @code{zero_call_used_regs} (@pxref{Function Attributes}). | |
15285 | ||
d77de738 | 15286 | @opindex param |
ddf6fe37 | 15287 | @item --param @var{name}=@var{value} |
d77de738 ML |
15288 | In some places, GCC uses various constants to control the amount of |
15289 | optimization that is done. For example, GCC does not inline functions | |
15290 | that contain more than a certain number of instructions. You can | |
15291 | control some of these constants on the command line using the | |
15292 | @option{--param} option. | |
15293 | ||
15294 | The names of specific parameters, and the meaning of the values, are | |
15295 | tied to the internals of the compiler, and are subject to change | |
15296 | without notice in future releases. | |
15297 | ||
c381327d GP |
15298 | In order to get the minimal, maximal and default values of a parameter, |
15299 | use the @option{--help=param -Q} options. | |
d77de738 ML |
15300 | |
15301 | In each case, the @var{value} is an integer. The following choices | |
15302 | of @var{name} are recognized for all targets: | |
15303 | ||
15304 | @table @gcctabopt | |
15305 | @item predictable-branch-outcome | |
15306 | When branch is predicted to be taken with probability lower than this threshold | |
15307 | (in percent), then it is considered well predictable. | |
15308 | ||
15309 | @item max-rtl-if-conversion-insns | |
15310 | RTL if-conversion tries to remove conditional branches around a block and | |
15311 | replace them with conditionally executed instructions. This parameter | |
15312 | gives the maximum number of instructions in a block which should be | |
15313 | considered for if-conversion. The compiler will | |
15314 | also use other heuristics to decide whether if-conversion is likely to be | |
15315 | profitable. | |
15316 | ||
15317 | @item max-rtl-if-conversion-predictable-cost | |
15318 | RTL if-conversion will try to remove conditional branches around a block | |
15319 | and replace them with conditionally executed instructions. These parameters | |
15320 | give the maximum permissible cost for the sequence that would be generated | |
15321 | by if-conversion depending on whether the branch is statically determined | |
15322 | to be predictable or not. The units for this parameter are the same as | |
15323 | those for the GCC internal seq_cost metric. The compiler will try to | |
15324 | provide a reasonable default for this parameter using the BRANCH_COST | |
15325 | target macro. | |
15326 | ||
15327 | @item max-crossjump-edges | |
15328 | The maximum number of incoming edges to consider for cross-jumping. | |
15329 | The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in | |
15330 | the number of edges incoming to each block. Increasing values mean | |
15331 | more aggressive optimization, making the compilation time increase with | |
15332 | probably small improvement in executable size. | |
15333 | ||
15334 | @item min-crossjump-insns | |
15335 | The minimum number of instructions that must be matched at the end | |
15336 | of two blocks before cross-jumping is performed on them. This | |
15337 | value is ignored in the case where all instructions in the block being | |
15338 | cross-jumped from are matched. | |
15339 | ||
15340 | @item max-grow-copy-bb-insns | |
15341 | The maximum code size expansion factor when copying basic blocks | |
15342 | instead of jumping. The expansion is relative to a jump instruction. | |
15343 | ||
15344 | @item max-goto-duplication-insns | |
15345 | The maximum number of instructions to duplicate to a block that jumps | |
15346 | to a computed goto. To avoid @math{O(N^2)} behavior in a number of | |
15347 | passes, GCC factors computed gotos early in the compilation process, | |
15348 | and unfactors them as late as possible. Only computed jumps at the | |
15349 | end of a basic blocks with no more than max-goto-duplication-insns are | |
15350 | unfactored. | |
15351 | ||
15352 | @item max-delay-slot-insn-search | |
15353 | The maximum number of instructions to consider when looking for an | |
15354 | instruction to fill a delay slot. If more than this arbitrary number of | |
15355 | instructions are searched, the time savings from filling the delay slot | |
15356 | are minimal, so stop searching. Increasing values mean more | |
15357 | aggressive optimization, making the compilation time increase with probably | |
15358 | small improvement in execution time. | |
15359 | ||
15360 | @item max-delay-slot-live-search | |
15361 | When trying to fill delay slots, the maximum number of instructions to | |
15362 | consider when searching for a block with valid live register | |
15363 | information. Increasing this arbitrarily chosen value means more | |
15364 | aggressive optimization, increasing the compilation time. This parameter | |
15365 | should be removed when the delay slot code is rewritten to maintain the | |
15366 | control-flow graph. | |
15367 | ||
15368 | @item max-gcse-memory | |
15369 | The approximate maximum amount of memory in @code{kB} that can be allocated in | |
15370 | order to perform the global common subexpression elimination | |
15371 | optimization. If more memory than specified is required, the | |
15372 | optimization is not done. | |
15373 | ||
15374 | @item max-gcse-insertion-ratio | |
15375 | If the ratio of expression insertions to deletions is larger than this value | |
15376 | for any expression, then RTL PRE inserts or removes the expression and thus | |
15377 | leaves partially redundant computations in the instruction stream. | |
15378 | ||
15379 | @item max-pending-list-length | |
15380 | The maximum number of pending dependencies scheduling allows | |
15381 | before flushing the current state and starting over. Large functions | |
15382 | with few branches or calls can create excessively large lists which | |
15383 | needlessly consume memory and resources. | |
15384 | ||
15385 | @item max-modulo-backtrack-attempts | |
15386 | The maximum number of backtrack attempts the scheduler should make | |
15387 | when modulo scheduling a loop. Larger values can exponentially increase | |
15388 | compilation time. | |
15389 | ||
15390 | @item max-inline-functions-called-once-loop-depth | |
15391 | Maximal loop depth of a call considered by inline heuristics that tries to | |
15392 | inline all functions called once. | |
15393 | ||
15394 | @item max-inline-functions-called-once-insns | |
15395 | Maximal estimated size of functions produced while inlining functions called | |
15396 | once. | |
15397 | ||
15398 | @item max-inline-insns-single | |
15399 | Several parameters control the tree inliner used in GCC@. This number sets the | |
15400 | maximum number of instructions (counted in GCC's internal representation) in a | |
15401 | single function that the tree inliner considers for inlining. This only | |
15402 | affects functions declared inline and methods implemented in a class | |
15403 | declaration (C++). | |
15404 | ||
15405 | ||
15406 | @item max-inline-insns-auto | |
15407 | When you use @option{-finline-functions} (included in @option{-O3}), | |
15408 | a lot of functions that would otherwise not be considered for inlining | |
15409 | by the compiler are investigated. To those functions, a different | |
15410 | (more restrictive) limit compared to functions declared inline can | |
15411 | be applied (@option{--param max-inline-insns-auto}). | |
15412 | ||
15413 | @item max-inline-insns-small | |
15414 | This is bound applied to calls which are considered relevant with | |
15415 | @option{-finline-small-functions}. | |
15416 | ||
15417 | @item max-inline-insns-size | |
15418 | This is bound applied to calls which are optimized for size. Small growth | |
15419 | may be desirable to anticipate optimization oppurtunities exposed by inlining. | |
15420 | ||
15421 | @item uninlined-function-insns | |
15422 | Number of instructions accounted by inliner for function overhead such as | |
15423 | function prologue and epilogue. | |
15424 | ||
15425 | @item uninlined-function-time | |
15426 | Extra time accounted by inliner for function overhead such as time needed to | |
15427 | execute function prologue and epilogue. | |
15428 | ||
15429 | @item inline-heuristics-hint-percent | |
15430 | The scale (in percents) applied to @option{inline-insns-single}, | |
15431 | @option{inline-insns-single-O2}, @option{inline-insns-auto} | |
15432 | when inline heuristics hints that inlining is | |
15433 | very profitable (will enable later optimizations). | |
15434 | ||
15435 | @item uninlined-thunk-insns | |
15436 | @item uninlined-thunk-time | |
15437 | Same as @option{--param uninlined-function-insns} and | |
15438 | @option{--param uninlined-function-time} but applied to function thunks. | |
15439 | ||
15440 | @item inline-min-speedup | |
15441 | When estimated performance improvement of caller + callee runtime exceeds this | |
15442 | threshold (in percent), the function can be inlined regardless of the limit on | |
15443 | @option{--param max-inline-insns-single} and @option{--param | |
15444 | max-inline-insns-auto}. | |
15445 | ||
15446 | @item large-function-insns | |
15447 | The limit specifying really large functions. For functions larger than this | |
15448 | limit after inlining, inlining is constrained by | |
15449 | @option{--param large-function-growth}. This parameter is useful primarily | |
15450 | to avoid extreme compilation time caused by non-linear algorithms used by the | |
15451 | back end. | |
15452 | ||
15453 | @item large-function-growth | |
15454 | Specifies maximal growth of large function caused by inlining in percents. | |
15455 | For example, parameter value 100 limits large function growth to 2.0 times | |
15456 | the original size. | |
15457 | ||
15458 | @item large-unit-insns | |
15459 | The limit specifying large translation unit. Growth caused by inlining of | |
15460 | units larger than this limit is limited by @option{--param inline-unit-growth}. | |
15461 | For small units this might be too tight. | |
15462 | For example, consider a unit consisting of function A | |
15463 | that is inline and B that just calls A three times. If B is small relative to | |
15464 | A, the growth of unit is 300\% and yet such inlining is very sane. For very | |
15465 | large units consisting of small inlineable functions, however, the overall unit | |
15466 | growth limit is needed to avoid exponential explosion of code size. Thus for | |
15467 | smaller units, the size is increased to @option{--param large-unit-insns} | |
15468 | before applying @option{--param inline-unit-growth}. | |
15469 | ||
15470 | @item lazy-modules | |
15471 | Maximum number of concurrently open C++ module files when lazy loading. | |
15472 | ||
15473 | @item inline-unit-growth | |
15474 | Specifies maximal overall growth of the compilation unit caused by inlining. | |
15475 | For example, parameter value 20 limits unit growth to 1.2 times the original | |
15476 | size. Cold functions (either marked cold via an attribute or by profile | |
15477 | feedback) are not accounted into the unit size. | |
15478 | ||
15479 | @item ipa-cp-unit-growth | |
15480 | Specifies maximal overall growth of the compilation unit caused by | |
15481 | interprocedural constant propagation. For example, parameter value 10 limits | |
15482 | unit growth to 1.1 times the original size. | |
15483 | ||
15484 | @item ipa-cp-large-unit-insns | |
15485 | The size of translation unit that IPA-CP pass considers large. | |
15486 | ||
15487 | @item large-stack-frame | |
15488 | The limit specifying large stack frames. While inlining the algorithm is trying | |
15489 | to not grow past this limit too much. | |
15490 | ||
15491 | @item large-stack-frame-growth | |
15492 | Specifies maximal growth of large stack frames caused by inlining in percents. | |
15493 | For example, parameter value 1000 limits large stack frame growth to 11 times | |
15494 | the original size. | |
15495 | ||
15496 | @item max-inline-insns-recursive | |
15497 | @itemx max-inline-insns-recursive-auto | |
15498 | Specifies the maximum number of instructions an out-of-line copy of a | |
15499 | self-recursive inline | |
15500 | function can grow into by performing recursive inlining. | |
15501 | ||
15502 | @option{--param max-inline-insns-recursive} applies to functions | |
15503 | declared inline. | |
15504 | For functions not declared inline, recursive inlining | |
15505 | happens only when @option{-finline-functions} (included in @option{-O3}) is | |
15506 | enabled; @option{--param max-inline-insns-recursive-auto} applies instead. | |
15507 | ||
15508 | @item max-inline-recursive-depth | |
15509 | @itemx max-inline-recursive-depth-auto | |
15510 | Specifies the maximum recursion depth used for recursive inlining. | |
15511 | ||
15512 | @option{--param max-inline-recursive-depth} applies to functions | |
15513 | declared inline. For functions not declared inline, recursive inlining | |
15514 | happens only when @option{-finline-functions} (included in @option{-O3}) is | |
15515 | enabled; @option{--param max-inline-recursive-depth-auto} applies instead. | |
15516 | ||
15517 | @item min-inline-recursive-probability | |
15518 | Recursive inlining is profitable only for function having deep recursion | |
15519 | in average and can hurt for function having little recursion depth by | |
15520 | increasing the prologue size or complexity of function body to other | |
15521 | optimizers. | |
15522 | ||
15523 | When profile feedback is available (see @option{-fprofile-generate}) the actual | |
15524 | recursion depth can be guessed from the probability that function recurses | |
15525 | via a given call expression. This parameter limits inlining only to call | |
15526 | expressions whose probability exceeds the given threshold (in percents). | |
15527 | ||
15528 | @item early-inlining-insns | |
15529 | Specify growth that the early inliner can make. In effect it increases | |
15530 | the amount of inlining for code having a large abstraction penalty. | |
15531 | ||
15532 | @item max-early-inliner-iterations | |
15533 | Limit of iterations of the early inliner. This basically bounds | |
15534 | the number of nested indirect calls the early inliner can resolve. | |
15535 | Deeper chains are still handled by late inlining. | |
15536 | ||
15537 | @item comdat-sharing-probability | |
15538 | Probability (in percent) that C++ inline function with comdat visibility | |
15539 | are shared across multiple compilation units. | |
15540 | ||
15541 | @item modref-max-bases | |
15542 | @item modref-max-refs | |
15543 | @item modref-max-accesses | |
15544 | Specifies the maximal number of base pointers, references and accesses stored | |
15545 | for a single function by mod/ref analysis. | |
15546 | ||
15547 | @item modref-max-tests | |
15548 | Specifies the maxmal number of tests alias oracle can perform to disambiguate | |
15549 | memory locations using the mod/ref information. This parameter ought to be | |
15550 | bigger than @option{--param modref-max-bases} and @option{--param | |
15551 | modref-max-refs}. | |
15552 | ||
15553 | @item modref-max-depth | |
15554 | Specifies the maximum depth of DFS walk used by modref escape analysis. | |
15555 | Setting to 0 disables the analysis completely. | |
15556 | ||
15557 | @item modref-max-escape-points | |
15558 | Specifies the maximum number of escape points tracked by modref per SSA-name. | |
15559 | ||
15560 | @item modref-max-adjustments | |
15561 | Specifies the maximum number the access range is enlarged during modref dataflow | |
15562 | analysis. | |
15563 | ||
15564 | @item profile-func-internal-id | |
15565 | A parameter to control whether to use function internal id in profile | |
15566 | database lookup. If the value is 0, the compiler uses an id that | |
15567 | is based on function assembler name and filename, which makes old profile | |
15568 | data more tolerant to source changes such as function reordering etc. | |
15569 | ||
15570 | @item min-vect-loop-bound | |
15571 | The minimum number of iterations under which loops are not vectorized | |
15572 | when @option{-ftree-vectorize} is used. The number of iterations after | |
15573 | vectorization needs to be greater than the value specified by this option | |
15574 | to allow vectorization. | |
15575 | ||
15576 | @item gcse-cost-distance-ratio | |
15577 | Scaling factor in calculation of maximum distance an expression | |
15578 | can be moved by GCSE optimizations. This is currently supported only in the | |
15579 | code hoisting pass. The bigger the ratio, the more aggressive code hoisting | |
15580 | is with simple expressions, i.e., the expressions that have cost | |
15581 | less than @option{gcse-unrestricted-cost}. Specifying 0 disables | |
15582 | hoisting of simple expressions. | |
15583 | ||
15584 | @item gcse-unrestricted-cost | |
15585 | Cost, roughly measured as the cost of a single typical machine | |
15586 | instruction, at which GCSE optimizations do not constrain | |
15587 | the distance an expression can travel. This is currently | |
15588 | supported only in the code hoisting pass. The lesser the cost, | |
15589 | the more aggressive code hoisting is. Specifying 0 | |
15590 | allows all expressions to travel unrestricted distances. | |
15591 | ||
15592 | @item max-hoist-depth | |
15593 | The depth of search in the dominator tree for expressions to hoist. | |
15594 | This is used to avoid quadratic behavior in hoisting algorithm. | |
15595 | The value of 0 does not limit on the search, but may slow down compilation | |
15596 | of huge functions. | |
15597 | ||
15598 | @item max-tail-merge-comparisons | |
15599 | The maximum amount of similar bbs to compare a bb with. This is used to | |
15600 | avoid quadratic behavior in tree tail merging. | |
15601 | ||
15602 | @item max-tail-merge-iterations | |
15603 | The maximum amount of iterations of the pass over the function. This is used to | |
15604 | limit compilation time in tree tail merging. | |
15605 | ||
15606 | @item store-merging-allow-unaligned | |
15607 | Allow the store merging pass to introduce unaligned stores if it is legal to | |
15608 | do so. | |
15609 | ||
15610 | @item max-stores-to-merge | |
15611 | The maximum number of stores to attempt to merge into wider stores in the store | |
15612 | merging pass. | |
15613 | ||
15614 | @item max-store-chains-to-track | |
15615 | The maximum number of store chains to track at the same time in the attempt | |
15616 | to merge them into wider stores in the store merging pass. | |
15617 | ||
15618 | @item max-stores-to-track | |
15619 | The maximum number of stores to track at the same time in the attemt to | |
15620 | to merge them into wider stores in the store merging pass. | |
15621 | ||
15622 | @item max-unrolled-insns | |
15623 | The maximum number of instructions that a loop may have to be unrolled. | |
15624 | If a loop is unrolled, this parameter also determines how many times | |
15625 | the loop code is unrolled. | |
15626 | ||
15627 | @item max-average-unrolled-insns | |
15628 | The maximum number of instructions biased by probabilities of their execution | |
15629 | that a loop may have to be unrolled. If a loop is unrolled, | |
15630 | this parameter also determines how many times the loop code is unrolled. | |
15631 | ||
15632 | @item max-unroll-times | |
15633 | The maximum number of unrollings of a single loop. | |
15634 | ||
15635 | @item max-peeled-insns | |
15636 | The maximum number of instructions that a loop may have to be peeled. | |
15637 | If a loop is peeled, this parameter also determines how many times | |
15638 | the loop code is peeled. | |
15639 | ||
15640 | @item max-peel-times | |
15641 | The maximum number of peelings of a single loop. | |
15642 | ||
15643 | @item max-peel-branches | |
15644 | The maximum number of branches on the hot path through the peeled sequence. | |
15645 | ||
15646 | @item max-completely-peeled-insns | |
15647 | The maximum number of insns of a completely peeled loop. | |
15648 | ||
15649 | @item max-completely-peel-times | |
15650 | The maximum number of iterations of a loop to be suitable for complete peeling. | |
15651 | ||
15652 | @item max-completely-peel-loop-nest-depth | |
15653 | The maximum depth of a loop nest suitable for complete peeling. | |
15654 | ||
15655 | @item max-unswitch-insns | |
15656 | The maximum number of insns of an unswitched loop. | |
15657 | ||
5b50850c RB |
15658 | @item max-unswitch-depth |
15659 | The maximum depth of a loop nest to be unswitched. | |
15660 | ||
d77de738 ML |
15661 | @item lim-expensive |
15662 | The minimum cost of an expensive expression in the loop invariant motion. | |
15663 | ||
15664 | @item min-loop-cond-split-prob | |
15665 | When FDO profile information is available, @option{min-loop-cond-split-prob} | |
15666 | specifies minimum threshold for probability of semi-invariant condition | |
15667 | statement to trigger loop split. | |
15668 | ||
15669 | @item iv-consider-all-candidates-bound | |
15670 | Bound on number of candidates for induction variables, below which | |
15671 | all candidates are considered for each use in induction variable | |
15672 | optimizations. If there are more candidates than this, | |
15673 | only the most relevant ones are considered to avoid quadratic time complexity. | |
15674 | ||
15675 | @item iv-max-considered-uses | |
15676 | The induction variable optimizations give up on loops that contain more | |
15677 | induction variable uses. | |
15678 | ||
15679 | @item iv-always-prune-cand-set-bound | |
15680 | If the number of candidates in the set is smaller than this value, | |
15681 | always try to remove unnecessary ivs from the set | |
15682 | when adding a new one. | |
15683 | ||
15684 | @item avg-loop-niter | |
15685 | Average number of iterations of a loop. | |
15686 | ||
15687 | @item dse-max-object-size | |
15688 | Maximum size (in bytes) of objects tracked bytewise by dead store elimination. | |
15689 | Larger values may result in larger compilation times. | |
15690 | ||
15691 | @item dse-max-alias-queries-per-store | |
15692 | Maximum number of queries into the alias oracle per store. | |
15693 | Larger values result in larger compilation times and may result in more | |
15694 | removed dead stores. | |
15695 | ||
15696 | @item scev-max-expr-size | |
15697 | Bound on size of expressions used in the scalar evolutions analyzer. | |
15698 | Large expressions slow the analyzer. | |
15699 | ||
15700 | @item scev-max-expr-complexity | |
15701 | Bound on the complexity of the expressions in the scalar evolutions analyzer. | |
15702 | Complex expressions slow the analyzer. | |
15703 | ||
15704 | @item max-tree-if-conversion-phi-args | |
15705 | Maximum number of arguments in a PHI supported by TREE if conversion | |
15706 | unless the loop is marked with simd pragma. | |
15707 | ||
15708 | @item vect-max-layout-candidates | |
15709 | The maximum number of possible vector layouts (such as permutations) | |
15710 | to consider when optimizing to-be-vectorized code. | |
15711 | ||
15712 | @item vect-max-version-for-alignment-checks | |
15713 | The maximum number of run-time checks that can be performed when | |
15714 | doing loop versioning for alignment in the vectorizer. | |
15715 | ||
15716 | @item vect-max-version-for-alias-checks | |
15717 | The maximum number of run-time checks that can be performed when | |
15718 | doing loop versioning for alias in the vectorizer. | |
15719 | ||
15720 | @item vect-max-peeling-for-alignment | |
15721 | The maximum number of loop peels to enhance access alignment | |
15722 | for vectorizer. Value -1 means no limit. | |
15723 | ||
15724 | @item max-iterations-to-track | |
15725 | The maximum number of iterations of a loop the brute-force algorithm | |
15726 | for analysis of the number of iterations of the loop tries to evaluate. | |
15727 | ||
15728 | @item hot-bb-count-fraction | |
15729 | The denominator n of fraction 1/n of the maximal execution count of a | |
15730 | basic block in the entire program that a basic block needs to at least | |
15731 | have in order to be considered hot. The default is 10000, which means | |
15732 | that a basic block is considered hot if its execution count is greater | |
15733 | than 1/10000 of the maximal execution count. 0 means that it is never | |
15734 | considered hot. Used in non-LTO mode. | |
15735 | ||
15736 | @item hot-bb-count-ws-permille | |
15737 | The number of most executed permilles, ranging from 0 to 1000, of the | |
15738 | profiled execution of the entire program to which the execution count | |
15739 | of a basic block must be part of in order to be considered hot. The | |
15740 | default is 990, which means that a basic block is considered hot if | |
15741 | its execution count contributes to the upper 990 permilles, or 99.0%, | |
15742 | of the profiled execution of the entire program. 0 means that it is | |
15743 | never considered hot. Used in LTO mode. | |
15744 | ||
15745 | @item hot-bb-frequency-fraction | |
15746 | The denominator n of fraction 1/n of the execution frequency of the | |
15747 | entry block of a function that a basic block of this function needs | |
15748 | to at least have in order to be considered hot. The default is 1000, | |
15749 | which means that a basic block is considered hot in a function if it | |
15750 | is executed more frequently than 1/1000 of the frequency of the entry | |
15751 | block of the function. 0 means that it is never considered hot. | |
15752 | ||
15753 | @item unlikely-bb-count-fraction | |
15754 | The denominator n of fraction 1/n of the number of profiled runs of | |
15755 | the entire program below which the execution count of a basic block | |
15756 | must be in order for the basic block to be considered unlikely executed. | |
15757 | The default is 20, which means that a basic block is considered unlikely | |
15758 | executed if it is executed in fewer than 1/20, or 5%, of the runs of | |
15759 | the program. 0 means that it is always considered unlikely executed. | |
15760 | ||
15761 | @item max-predicted-iterations | |
15762 | The maximum number of loop iterations we predict statically. This is useful | |
15763 | in cases where a function contains a single loop with known bound and | |
15764 | another loop with unknown bound. | |
15765 | The known number of iterations is predicted correctly, while | |
15766 | the unknown number of iterations average to roughly 10. This means that the | |
15767 | loop without bounds appears artificially cold relative to the other one. | |
15768 | ||
15769 | @item builtin-expect-probability | |
15770 | Control the probability of the expression having the specified value. This | |
15771 | parameter takes a percentage (i.e.@: 0 ... 100) as input. | |
15772 | ||
15773 | @item builtin-string-cmp-inline-length | |
15774 | The maximum length of a constant string for a builtin string cmp call | |
15775 | eligible for inlining. | |
15776 | ||
15777 | @item align-threshold | |
15778 | ||
15779 | Select fraction of the maximal frequency of executions of a basic block in | |
15780 | a function to align the basic block. | |
15781 | ||
15782 | @item align-loop-iterations | |
15783 | ||
15784 | A loop expected to iterate at least the selected number of iterations is | |
15785 | aligned. | |
15786 | ||
15787 | @item tracer-dynamic-coverage | |
15788 | @itemx tracer-dynamic-coverage-feedback | |
15789 | ||
15790 | This value is used to limit superblock formation once the given percentage of | |
15791 | executed instructions is covered. This limits unnecessary code size | |
15792 | expansion. | |
15793 | ||
15794 | The @option{tracer-dynamic-coverage-feedback} parameter | |
15795 | is used only when profile | |
15796 | feedback is available. The real profiles (as opposed to statically estimated | |
15797 | ones) are much less balanced allowing the threshold to be larger value. | |
15798 | ||
15799 | @item tracer-max-code-growth | |
15800 | Stop tail duplication once code growth has reached given percentage. This is | |
15801 | a rather artificial limit, as most of the duplicates are eliminated later in | |
15802 | cross jumping, so it may be set to much higher values than is the desired code | |
15803 | growth. | |
15804 | ||
15805 | @item tracer-min-branch-ratio | |
15806 | ||
15807 | Stop reverse growth when the reverse probability of best edge is less than this | |
15808 | threshold (in percent). | |
15809 | ||
15810 | @item tracer-min-branch-probability | |
15811 | @itemx tracer-min-branch-probability-feedback | |
15812 | ||
15813 | Stop forward growth if the best edge has probability lower than this | |
15814 | threshold. | |
15815 | ||
15816 | Similarly to @option{tracer-dynamic-coverage} two parameters are | |
15817 | provided. @option{tracer-min-branch-probability-feedback} is used for | |
15818 | compilation with profile feedback and @option{tracer-min-branch-probability} | |
15819 | compilation without. The value for compilation with profile feedback | |
15820 | needs to be more conservative (higher) in order to make tracer | |
15821 | effective. | |
15822 | ||
15823 | @item stack-clash-protection-guard-size | |
15824 | Specify the size of the operating system provided stack guard as | |
15825 | 2 raised to @var{num} bytes. Higher values may reduce the | |
15826 | number of explicit probes, but a value larger than the operating system | |
15827 | provided guard will leave code vulnerable to stack clash style attacks. | |
15828 | ||
15829 | @item stack-clash-protection-probe-interval | |
15830 | Stack clash protection involves probing stack space as it is allocated. This | |
15831 | param controls the maximum distance between probes into the stack as 2 raised | |
15832 | to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value | |
15833 | larger than the operating system provided guard will leave code vulnerable to | |
15834 | stack clash style attacks. | |
15835 | ||
15836 | @item max-cse-path-length | |
15837 | ||
15838 | The maximum number of basic blocks on path that CSE considers. | |
15839 | ||
15840 | @item max-cse-insns | |
15841 | The maximum number of instructions CSE processes before flushing. | |
15842 | ||
15843 | @item ggc-min-expand | |
15844 | ||
15845 | GCC uses a garbage collector to manage its own memory allocation. This | |
15846 | parameter specifies the minimum percentage by which the garbage | |
15847 | collector's heap should be allowed to expand between collections. | |
15848 | Tuning this may improve compilation speed; it has no effect on code | |
15849 | generation. | |
15850 | ||
15851 | The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when | |
15852 | RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is | |
15853 | the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If | |
15854 | GCC is not able to calculate RAM on a particular platform, the lower | |
15855 | bound of 30% is used. Setting this parameter and | |
15856 | @option{ggc-min-heapsize} to zero causes a full collection to occur at | |
15857 | every opportunity. This is extremely slow, but can be useful for | |
15858 | debugging. | |
15859 | ||
15860 | @item ggc-min-heapsize | |
15861 | ||
15862 | Minimum size of the garbage collector's heap before it begins bothering | |
15863 | to collect garbage. The first collection occurs after the heap expands | |
15864 | by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again, | |
15865 | tuning this may improve compilation speed, and has no effect on code | |
15866 | generation. | |
15867 | ||
15868 | The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that | |
15869 | tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but | |
15870 | with a lower bound of 4096 (four megabytes) and an upper bound of | |
15871 | 131072 (128 megabytes). If GCC is not able to calculate RAM on a | |
15872 | particular platform, the lower bound is used. Setting this parameter | |
15873 | very large effectively disables garbage collection. Setting this | |
15874 | parameter and @option{ggc-min-expand} to zero causes a full collection | |
15875 | to occur at every opportunity. | |
15876 | ||
15877 | @item max-reload-search-insns | |
15878 | The maximum number of instruction reload should look backward for equivalent | |
15879 | register. Increasing values mean more aggressive optimization, making the | |
15880 | compilation time increase with probably slightly better performance. | |
15881 | ||
15882 | @item max-cselib-memory-locations | |
15883 | The maximum number of memory locations cselib should take into account. | |
15884 | Increasing values mean more aggressive optimization, making the compilation time | |
15885 | increase with probably slightly better performance. | |
15886 | ||
15887 | @item max-sched-ready-insns | |
15888 | The maximum number of instructions ready to be issued the scheduler should | |
15889 | consider at any given time during the first scheduling pass. Increasing | |
15890 | values mean more thorough searches, making the compilation time increase | |
15891 | with probably little benefit. | |
15892 | ||
15893 | @item max-sched-region-blocks | |
15894 | The maximum number of blocks in a region to be considered for | |
15895 | interblock scheduling. | |
15896 | ||
15897 | @item max-pipeline-region-blocks | |
15898 | The maximum number of blocks in a region to be considered for | |
15899 | pipelining in the selective scheduler. | |
15900 | ||
15901 | @item max-sched-region-insns | |
15902 | The maximum number of insns in a region to be considered for | |
15903 | interblock scheduling. | |
15904 | ||
15905 | @item max-pipeline-region-insns | |
15906 | The maximum number of insns in a region to be considered for | |
15907 | pipelining in the selective scheduler. | |
15908 | ||
15909 | @item min-spec-prob | |
15910 | The minimum probability (in percents) of reaching a source block | |
15911 | for interblock speculative scheduling. | |
15912 | ||
15913 | @item max-sched-extend-regions-iters | |
15914 | The maximum number of iterations through CFG to extend regions. | |
15915 | A value of 0 disables region extensions. | |
15916 | ||
15917 | @item max-sched-insn-conflict-delay | |
15918 | The maximum conflict delay for an insn to be considered for speculative motion. | |
15919 | ||
15920 | @item sched-spec-prob-cutoff | |
15921 | The minimal probability of speculation success (in percents), so that | |
15922 | speculative insns are scheduled. | |
15923 | ||
15924 | @item sched-state-edge-prob-cutoff | |
15925 | The minimum probability an edge must have for the scheduler to save its | |
15926 | state across it. | |
15927 | ||
15928 | @item sched-mem-true-dep-cost | |
15929 | Minimal distance (in CPU cycles) between store and load targeting same | |
15930 | memory locations. | |
15931 | ||
15932 | @item selsched-max-lookahead | |
15933 | The maximum size of the lookahead window of selective scheduling. It is a | |
15934 | depth of search for available instructions. | |
15935 | ||
15936 | @item selsched-max-sched-times | |
15937 | The maximum number of times that an instruction is scheduled during | |
15938 | selective scheduling. This is the limit on the number of iterations | |
15939 | through which the instruction may be pipelined. | |
15940 | ||
15941 | @item selsched-insns-to-rename | |
15942 | The maximum number of best instructions in the ready list that are considered | |
15943 | for renaming in the selective scheduler. | |
15944 | ||
15945 | @item sms-min-sc | |
15946 | The minimum value of stage count that swing modulo scheduler | |
15947 | generates. | |
15948 | ||
15949 | @item max-last-value-rtl | |
15950 | The maximum size measured as number of RTLs that can be recorded in an expression | |
15951 | in combiner for a pseudo register as last known value of that register. | |
15952 | ||
15953 | @item max-combine-insns | |
15954 | The maximum number of instructions the RTL combiner tries to combine. | |
15955 | ||
15956 | @item integer-share-limit | |
15957 | Small integer constants can use a shared data structure, reducing the | |
15958 | compiler's memory usage and increasing its speed. This sets the maximum | |
15959 | value of a shared integer constant. | |
15960 | ||
15961 | @item ssp-buffer-size | |
15962 | The minimum size of buffers (i.e.@: arrays) that receive stack smashing | |
15963 | protection when @option{-fstack-protector} is used. | |
15964 | ||
15965 | @item min-size-for-stack-sharing | |
15966 | The minimum size of variables taking part in stack slot sharing when not | |
15967 | optimizing. | |
15968 | ||
15969 | @item max-jump-thread-duplication-stmts | |
15970 | Maximum number of statements allowed in a block that needs to be | |
15971 | duplicated when threading jumps. | |
15972 | ||
15973 | @item max-jump-thread-paths | |
15974 | The maximum number of paths to consider when searching for jump threading | |
15975 | opportunities. When arriving at a block, incoming edges are only considered | |
15976 | if the number of paths to be searched so far multiplied by the number of | |
15977 | incoming edges does not exhaust the specified maximum number of paths to | |
15978 | consider. | |
15979 | ||
15980 | @item max-fields-for-field-sensitive | |
15981 | Maximum number of fields in a structure treated in | |
15982 | a field sensitive manner during pointer analysis. | |
15983 | ||
15984 | @item prefetch-latency | |
15985 | Estimate on average number of instructions that are executed before | |
15986 | prefetch finishes. The distance prefetched ahead is proportional | |
15987 | to this constant. Increasing this number may also lead to less | |
15988 | streams being prefetched (see @option{simultaneous-prefetches}). | |
15989 | ||
15990 | @item simultaneous-prefetches | |
15991 | Maximum number of prefetches that can run at the same time. | |
15992 | ||
15993 | @item l1-cache-line-size | |
15994 | The size of cache line in L1 data cache, in bytes. | |
15995 | ||
15996 | @item l1-cache-size | |
15997 | The size of L1 data cache, in kilobytes. | |
15998 | ||
15999 | @item l2-cache-size | |
16000 | The size of L2 data cache, in kilobytes. | |
16001 | ||
16002 | @item prefetch-dynamic-strides | |
16003 | Whether the loop array prefetch pass should issue software prefetch hints | |
16004 | for strides that are non-constant. In some cases this may be | |
16005 | beneficial, though the fact the stride is non-constant may make it | |
16006 | hard to predict when there is clear benefit to issuing these hints. | |
16007 | ||
16008 | Set to 1 if the prefetch hints should be issued for non-constant | |
16009 | strides. Set to 0 if prefetch hints should be issued only for strides that | |
16010 | are known to be constant and below @option{prefetch-minimum-stride}. | |
16011 | ||
16012 | @item prefetch-minimum-stride | |
16013 | Minimum constant stride, in bytes, to start using prefetch hints for. If | |
16014 | the stride is less than this threshold, prefetch hints will not be issued. | |
16015 | ||
16016 | This setting is useful for processors that have hardware prefetchers, in | |
16017 | which case there may be conflicts between the hardware prefetchers and | |
16018 | the software prefetchers. If the hardware prefetchers have a maximum | |
16019 | stride they can handle, it should be used here to improve the use of | |
16020 | software prefetchers. | |
16021 | ||
16022 | A value of -1 means we don't have a threshold and therefore | |
16023 | prefetch hints can be issued for any constant stride. | |
16024 | ||
16025 | This setting is only useful for strides that are known and constant. | |
16026 | ||
16027 | @item destructive-interference-size | |
16028 | @item constructive-interference-size | |
16029 | The values for the C++17 variables | |
16030 | @code{std::hardware_destructive_interference_size} and | |
16031 | @code{std::hardware_constructive_interference_size}. The destructive | |
16032 | interference size is the minimum recommended offset between two | |
16033 | independent concurrently-accessed objects; the constructive | |
16034 | interference size is the maximum recommended size of contiguous memory | |
16035 | accessed together. Typically both will be the size of an L1 cache | |
16036 | line for the target, in bytes. For a generic target covering a range of L1 | |
16037 | cache line sizes, typically the constructive interference size will be | |
16038 | the small end of the range and the destructive size will be the large | |
16039 | end. | |
16040 | ||
16041 | The destructive interference size is intended to be used for layout, | |
16042 | and thus has ABI impact. The default value is not expected to be | |
16043 | stable, and on some targets varies with @option{-mtune}, so use of | |
16044 | this variable in a context where ABI stability is important, such as | |
16045 | the public interface of a library, is strongly discouraged; if it is | |
16046 | used in that context, users can stabilize the value using this | |
16047 | option. | |
16048 | ||
16049 | The constructive interference size is less sensitive, as it is | |
16050 | typically only used in a @samp{static_assert} to make sure that a type | |
16051 | fits within a cache line. | |
16052 | ||
16053 | See also @option{-Winterference-size}. | |
16054 | ||
16055 | @item loop-interchange-max-num-stmts | |
16056 | The maximum number of stmts in a loop to be interchanged. | |
16057 | ||
16058 | @item loop-interchange-stride-ratio | |
16059 | The minimum ratio between stride of two loops for interchange to be profitable. | |
16060 | ||
16061 | @item min-insn-to-prefetch-ratio | |
16062 | The minimum ratio between the number of instructions and the | |
16063 | number of prefetches to enable prefetching in a loop. | |
16064 | ||
16065 | @item prefetch-min-insn-to-mem-ratio | |
16066 | The minimum ratio between the number of instructions and the | |
16067 | number of memory references to enable prefetching in a loop. | |
16068 | ||
16069 | @item use-canonical-types | |
16070 | Whether the compiler should use the ``canonical'' type system. | |
16071 | Should always be 1, which uses a more efficient internal | |
16072 | mechanism for comparing types in C++ and Objective-C++. However, if | |
16073 | bugs in the canonical type system are causing compilation failures, | |
16074 | set this value to 0 to disable canonical types. | |
16075 | ||
16076 | @item switch-conversion-max-branch-ratio | |
16077 | Switch initialization conversion refuses to create arrays that are | |
16078 | bigger than @option{switch-conversion-max-branch-ratio} times the number of | |
16079 | branches in the switch. | |
16080 | ||
16081 | @item max-partial-antic-length | |
16082 | Maximum length of the partial antic set computed during the tree | |
16083 | partial redundancy elimination optimization (@option{-ftree-pre}) when | |
16084 | optimizing at @option{-O3} and above. For some sorts of source code | |
16085 | the enhanced partial redundancy elimination optimization can run away, | |
16086 | consuming all of the memory available on the host machine. This | |
16087 | parameter sets a limit on the length of the sets that are computed, | |
16088 | which prevents the runaway behavior. Setting a value of 0 for | |
16089 | this parameter allows an unlimited set length. | |
16090 | ||
16091 | @item rpo-vn-max-loop-depth | |
16092 | Maximum loop depth that is value-numbered optimistically. | |
16093 | When the limit hits the innermost | |
16094 | @var{rpo-vn-max-loop-depth} loops and the outermost loop in the | |
16095 | loop nest are value-numbered optimistically and the remaining ones not. | |
16096 | ||
16097 | @item sccvn-max-alias-queries-per-access | |
16098 | Maximum number of alias-oracle queries we perform when looking for | |
16099 | redundancies for loads and stores. If this limit is hit the search | |
16100 | is aborted and the load or store is not considered redundant. The | |
16101 | number of queries is algorithmically limited to the number of | |
16102 | stores on all paths from the load to the function entry. | |
16103 | ||
16104 | @item ira-max-loops-num | |
16105 | IRA uses regional register allocation by default. If a function | |
16106 | contains more loops than the number given by this parameter, only at most | |
16107 | the given number of the most frequently-executed loops form regions | |
16108 | for regional register allocation. | |
16109 | ||
16110 | @item ira-max-conflict-table-size | |
16111 | Although IRA uses a sophisticated algorithm to compress the conflict | |
16112 | table, the table can still require excessive amounts of memory for | |
16113 | huge functions. If the conflict table for a function could be more | |
16114 | than the size in MB given by this parameter, the register allocator | |
16115 | instead uses a faster, simpler, and lower-quality | |
16116 | algorithm that does not require building a pseudo-register conflict table. | |
16117 | ||
16118 | @item ira-loop-reserved-regs | |
16119 | IRA can be used to evaluate more accurate register pressure in loops | |
16120 | for decisions to move loop invariants (see @option{-O3}). The number | |
16121 | of available registers reserved for some other purposes is given | |
16122 | by this parameter. Default of the parameter | |
16123 | is the best found from numerous experiments. | |
16124 | ||
16125 | @item ira-consider-dup-in-all-alts | |
16126 | Make IRA to consider matching constraint (duplicated operand number) | |
16127 | heavily in all available alternatives for preferred register class. | |
16128 | If it is set as zero, it means IRA only respects the matching | |
16129 | constraint when it's in the only available alternative with an | |
16130 | appropriate register class. Otherwise, it means IRA will check all | |
16131 | available alternatives for preferred register class even if it has | |
16132 | found some choice with an appropriate register class and respect the | |
16133 | found qualified matching constraint. | |
16134 | ||
9847c753 ML |
16135 | @item ira-simple-lra-insn-threshold |
16136 | Approximate function insn number in 1K units triggering simple local RA. | |
16137 | ||
d77de738 ML |
16138 | @item lra-inheritance-ebb-probability-cutoff |
16139 | LRA tries to reuse values reloaded in registers in subsequent insns. | |
16140 | This optimization is called inheritance. EBB is used as a region to | |
16141 | do this optimization. The parameter defines a minimal fall-through | |
16142 | edge probability in percentage used to add BB to inheritance EBB in | |
16143 | LRA. The default value was chosen | |
16144 | from numerous runs of SPEC2000 on x86-64. | |
16145 | ||
16146 | @item loop-invariant-max-bbs-in-loop | |
16147 | Loop invariant motion can be very expensive, both in compilation time and | |
16148 | in amount of needed compile-time memory, with very large loops. Loops | |
16149 | with more basic blocks than this parameter won't have loop invariant | |
16150 | motion optimization performed on them. | |
16151 | ||
16152 | @item loop-max-datarefs-for-datadeps | |
16153 | Building data dependencies is expensive for very large loops. This | |
16154 | parameter limits the number of data references in loops that are | |
16155 | considered for data dependence analysis. These large loops are no | |
16156 | handled by the optimizations using loop data dependencies. | |
16157 | ||
16158 | @item max-vartrack-size | |
16159 | Sets a maximum number of hash table slots to use during variable | |
16160 | tracking dataflow analysis of any function. If this limit is exceeded | |
16161 | with variable tracking at assignments enabled, analysis for that | |
16162 | function is retried without it, after removing all debug insns from | |
16163 | the function. If the limit is exceeded even without debug insns, var | |
16164 | tracking analysis is completely disabled for the function. Setting | |
16165 | the parameter to zero makes it unlimited. | |
16166 | ||
16167 | @item max-vartrack-expr-depth | |
16168 | Sets a maximum number of recursion levels when attempting to map | |
16169 | variable names or debug temporaries to value expressions. This trades | |
16170 | compilation time for more complete debug information. If this is set too | |
16171 | low, value expressions that are available and could be represented in | |
16172 | debug information may end up not being used; setting this higher may | |
16173 | enable the compiler to find more complex debug expressions, but compile | |
16174 | time and memory use may grow. | |
16175 | ||
16176 | @item max-debug-marker-count | |
16177 | Sets a threshold on the number of debug markers (e.g.@: begin stmt | |
16178 | markers) to avoid complexity explosion at inlining or expanding to RTL. | |
16179 | If a function has more such gimple stmts than the set limit, such stmts | |
16180 | will be dropped from the inlined copy of a function, and from its RTL | |
16181 | expansion. | |
16182 | ||
16183 | @item min-nondebug-insn-uid | |
16184 | Use uids starting at this parameter for nondebug insns. The range below | |
16185 | the parameter is reserved exclusively for debug insns created by | |
16186 | @option{-fvar-tracking-assignments}, but debug insns may get | |
16187 | (non-overlapping) uids above it if the reserved range is exhausted. | |
16188 | ||
10478270 MJ |
16189 | @item ipa-sra-deref-prob-threshold |
16190 | IPA-SRA replaces a pointer which is known not be NULL with one or more | |
16191 | new parameters only when the probability (in percent, relative to | |
16192 | function entry) of it being dereferenced is higher than this parameter. | |
16193 | ||
d77de738 ML |
16194 | @item ipa-sra-ptr-growth-factor |
16195 | IPA-SRA replaces a pointer to an aggregate with one or more new | |
16196 | parameters only when their cumulative size is less or equal to | |
16197 | @option{ipa-sra-ptr-growth-factor} times the size of the original | |
16198 | pointer parameter. | |
16199 | ||
69363825 ML |
16200 | @item ipa-sra-ptrwrap-growth-factor |
16201 | Additional maximum allowed growth of total size of new parameters | |
16202 | that ipa-sra replaces a pointer to an aggregate with, | |
049dccd0 MJ |
16203 | if it points to a local variable that the caller only writes to and |
16204 | passes it as an argument to other functions. | |
69363825 | 16205 | |
d77de738 ML |
16206 | @item ipa-sra-max-replacements |
16207 | Maximum pieces of an aggregate that IPA-SRA tracks. As a | |
16208 | consequence, it is also the maximum number of replacements of a formal | |
16209 | parameter. | |
16210 | ||
16211 | @item sra-max-scalarization-size-Ospeed | |
16212 | @itemx sra-max-scalarization-size-Osize | |
16213 | The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to | |
16214 | replace scalar parts of aggregates with uses of independent scalar | |
16215 | variables. These parameters control the maximum size, in storage units, | |
16216 | of aggregate which is considered for replacement when compiling for | |
16217 | speed | |
16218 | (@option{sra-max-scalarization-size-Ospeed}) or size | |
16219 | (@option{sra-max-scalarization-size-Osize}) respectively. | |
16220 | ||
16221 | @item sra-max-propagations | |
16222 | The maximum number of artificial accesses that Scalar Replacement of | |
16223 | Aggregates (SRA) will track, per one local variable, in order to | |
16224 | facilitate copy propagation. | |
16225 | ||
16226 | @item tm-max-aggregate-size | |
16227 | When making copies of thread-local variables in a transaction, this | |
16228 | parameter specifies the size in bytes after which variables are | |
16229 | saved with the logging functions as opposed to save/restore code | |
16230 | sequence pairs. This option only applies when using | |
16231 | @option{-fgnu-tm}. | |
16232 | ||
16233 | @item graphite-max-nb-scop-params | |
16234 | To avoid exponential effects in the Graphite loop transforms, the | |
16235 | number of parameters in a Static Control Part (SCoP) is bounded. | |
16236 | A value of zero can be used to lift | |
16237 | the bound. A variable whose value is unknown at compilation time and | |
16238 | defined outside a SCoP is a parameter of the SCoP. | |
16239 | ||
551935d1 AO |
16240 | @item hardcfr-max-blocks |
16241 | Disable @option{-fharden-control-flow-redundancy} for functions with a | |
16242 | larger number of blocks than the specified value. Zero removes any | |
16243 | limit. | |
16244 | ||
16245 | @item hardcfr-max-inline-blocks | |
16246 | Force @option{-fharden-control-flow-redundancy} to use out-of-line | |
16247 | checking for functions with a larger number of basic blocks than the | |
16248 | specified value. | |
16249 | ||
d77de738 ML |
16250 | @item loop-block-tile-size |
16251 | Loop blocking or strip mining transforms, enabled with | |
16252 | @option{-floop-block} or @option{-floop-strip-mine}, strip mine each | |
16253 | loop in the loop nest by a given number of iterations. The strip | |
16254 | length can be changed using the @option{loop-block-tile-size} | |
16255 | parameter. | |
16256 | ||
16257 | @item ipa-jump-function-lookups | |
16258 | Specifies number of statements visited during jump function offset discovery. | |
16259 | ||
16260 | @item ipa-cp-value-list-size | |
16261 | IPA-CP attempts to track all possible values and types passed to a function's | |
16262 | parameter in order to propagate them and perform devirtualization. | |
16263 | @option{ipa-cp-value-list-size} is the maximum number of values and types it | |
16264 | stores per one formal parameter of a function. | |
16265 | ||
16266 | @item ipa-cp-eval-threshold | |
16267 | IPA-CP calculates its own score of cloning profitability heuristics | |
16268 | and performs those cloning opportunities with scores that exceed | |
16269 | @option{ipa-cp-eval-threshold}. | |
16270 | ||
16271 | @item ipa-cp-max-recursive-depth | |
16272 | Maximum depth of recursive cloning for self-recursive function. | |
16273 | ||
16274 | @item ipa-cp-min-recursive-probability | |
16275 | Recursive cloning only when the probability of call being executed exceeds | |
16276 | the parameter. | |
16277 | ||
16278 | @item ipa-cp-profile-count-base | |
16279 | When using @option{-fprofile-use} option, IPA-CP will consider the measured | |
16280 | execution count of a call graph edge at this percentage position in their | |
16281 | histogram as the basis for its heuristics calculation. | |
16282 | ||
16283 | @item ipa-cp-recursive-freq-factor | |
16284 | The number of times interprocedural copy propagation expects recursive | |
16285 | functions to call themselves. | |
16286 | ||
16287 | @item ipa-cp-recursion-penalty | |
16288 | Percentage penalty the recursive functions will receive when they | |
16289 | are evaluated for cloning. | |
16290 | ||
16291 | @item ipa-cp-single-call-penalty | |
16292 | Percentage penalty functions containing a single call to another | |
16293 | function will receive when they are evaluated for cloning. | |
16294 | ||
16295 | @item ipa-max-agg-items | |
16296 | IPA-CP is also capable to propagate a number of scalar values passed | |
16297 | in an aggregate. @option{ipa-max-agg-items} controls the maximum | |
16298 | number of such values per one parameter. | |
16299 | ||
16300 | @item ipa-cp-loop-hint-bonus | |
16301 | When IPA-CP determines that a cloning candidate would make the number | |
16302 | of iterations of a loop known, it adds a bonus of | |
16303 | @option{ipa-cp-loop-hint-bonus} to the profitability score of | |
16304 | the candidate. | |
16305 | ||
16306 | @item ipa-max-loop-predicates | |
16307 | The maximum number of different predicates IPA will use to describe when | |
16308 | loops in a function have known properties. | |
16309 | ||
16310 | @item ipa-max-aa-steps | |
16311 | During its analysis of function bodies, IPA-CP employs alias analysis | |
16312 | in order to track values pointed to by function parameters. In order | |
16313 | not spend too much time analyzing huge functions, it gives up and | |
16314 | consider all memory clobbered after examining | |
16315 | @option{ipa-max-aa-steps} statements modifying memory. | |
16316 | ||
16317 | @item ipa-max-switch-predicate-bounds | |
16318 | Maximal number of boundary endpoints of case ranges of switch statement. | |
16319 | For switch exceeding this limit, IPA-CP will not construct cloning cost | |
16320 | predicate, which is used to estimate cloning benefit, for default case | |
16321 | of the switch statement. | |
16322 | ||
16323 | @item ipa-max-param-expr-ops | |
16324 | IPA-CP will analyze conditional statement that references some function | |
16325 | parameter to estimate benefit for cloning upon certain constant value. | |
16326 | But if number of operations in a parameter expression exceeds | |
16327 | @option{ipa-max-param-expr-ops}, the expression is treated as complicated | |
16328 | one, and is not handled by IPA analysis. | |
16329 | ||
16330 | @item lto-partitions | |
16331 | Specify desired number of partitions produced during WHOPR compilation. | |
16332 | The number of partitions should exceed the number of CPUs used for compilation. | |
16333 | ||
16334 | @item lto-min-partition | |
16335 | Size of minimal partition for WHOPR (in estimated instructions). | |
16336 | This prevents expenses of splitting very small programs into too many | |
16337 | partitions. | |
16338 | ||
16339 | @item lto-max-partition | |
16340 | Size of max partition for WHOPR (in estimated instructions). | |
16341 | to provide an upper bound for individual size of partition. | |
16342 | Meant to be used only with balanced partitioning. | |
16343 | ||
16344 | @item lto-max-streaming-parallelism | |
16345 | Maximal number of parallel processes used for LTO streaming. | |
16346 | ||
16347 | @item cxx-max-namespaces-for-diagnostic-help | |
16348 | The maximum number of namespaces to consult for suggestions when C++ | |
16349 | name lookup fails for an identifier. | |
16350 | ||
16351 | @item sink-frequency-threshold | |
16352 | The maximum relative execution frequency (in percents) of the target block | |
16353 | relative to a statement's original block to allow statement sinking of a | |
16354 | statement. Larger numbers result in more aggressive statement sinking. | |
16355 | A small positive adjustment is applied for | |
16356 | statements with memory operands as those are even more profitable so sink. | |
16357 | ||
16358 | @item max-stores-to-sink | |
16359 | The maximum number of conditional store pairs that can be sunk. Set to 0 | |
16360 | if either vectorization (@option{-ftree-vectorize}) or if-conversion | |
16361 | (@option{-ftree-loop-if-convert}) is disabled. | |
16362 | ||
16363 | @item case-values-threshold | |
16364 | The smallest number of different values for which it is best to use a | |
16365 | jump-table instead of a tree of conditional branches. If the value is | |
16366 | 0, use the default for the machine. | |
16367 | ||
16368 | @item jump-table-max-growth-ratio-for-size | |
16369 | The maximum code size growth ratio when expanding | |
16370 | into a jump table (in percent). The parameter is used when | |
16371 | optimizing for size. | |
16372 | ||
16373 | @item jump-table-max-growth-ratio-for-speed | |
16374 | The maximum code size growth ratio when expanding | |
16375 | into a jump table (in percent). The parameter is used when | |
16376 | optimizing for speed. | |
16377 | ||
16378 | @item tree-reassoc-width | |
16379 | Set the maximum number of instructions executed in parallel in | |
16380 | reassociated tree. This parameter overrides target dependent | |
16381 | heuristics used by default if has non zero value. | |
16382 | ||
16383 | @item sched-pressure-algorithm | |
16384 | Choose between the two available implementations of | |
16385 | @option{-fsched-pressure}. Algorithm 1 is the original implementation | |
16386 | and is the more likely to prevent instructions from being reordered. | |
16387 | Algorithm 2 was designed to be a compromise between the relatively | |
16388 | conservative approach taken by algorithm 1 and the rather aggressive | |
16389 | approach taken by the default scheduler. It relies more heavily on | |
16390 | having a regular register file and accurate register pressure classes. | |
16391 | See @file{haifa-sched.cc} in the GCC sources for more details. | |
16392 | ||
16393 | The default choice depends on the target. | |
16394 | ||
16395 | @item max-slsr-cand-scan | |
16396 | Set the maximum number of existing candidates that are considered when | |
16397 | seeking a basis for a new straight-line strength reduction candidate. | |
16398 | ||
16399 | @item asan-globals | |
16400 | Enable buffer overflow detection for global objects. This kind | |
16401 | of protection is enabled by default if you are using | |
16402 | @option{-fsanitize=address} option. | |
16403 | To disable global objects protection use @option{--param asan-globals=0}. | |
16404 | ||
16405 | @item asan-stack | |
16406 | Enable buffer overflow detection for stack objects. This kind of | |
16407 | protection is enabled by default when using @option{-fsanitize=address}. | |
16408 | To disable stack protection use @option{--param asan-stack=0} option. | |
16409 | ||
16410 | @item asan-instrument-reads | |
16411 | Enable buffer overflow detection for memory reads. This kind of | |
16412 | protection is enabled by default when using @option{-fsanitize=address}. | |
16413 | To disable memory reads protection use | |
16414 | @option{--param asan-instrument-reads=0}. | |
16415 | ||
16416 | @item asan-instrument-writes | |
16417 | Enable buffer overflow detection for memory writes. This kind of | |
16418 | protection is enabled by default when using @option{-fsanitize=address}. | |
16419 | To disable memory writes protection use | |
16420 | @option{--param asan-instrument-writes=0} option. | |
16421 | ||
16422 | @item asan-memintrin | |
16423 | Enable detection for built-in functions. This kind of protection | |
16424 | is enabled by default when using @option{-fsanitize=address}. | |
16425 | To disable built-in functions protection use | |
16426 | @option{--param asan-memintrin=0}. | |
16427 | ||
16428 | @item asan-use-after-return | |
16429 | Enable detection of use-after-return. This kind of protection | |
16430 | is enabled by default when using the @option{-fsanitize=address} option. | |
16431 | To disable it use @option{--param asan-use-after-return=0}. | |
16432 | ||
16433 | Note: By default the check is disabled at run time. To enable it, | |
16434 | add @code{detect_stack_use_after_return=1} to the environment variable | |
16435 | @env{ASAN_OPTIONS}. | |
16436 | ||
16437 | @item asan-instrumentation-with-call-threshold | |
16438 | If number of memory accesses in function being instrumented | |
16439 | is greater or equal to this number, use callbacks instead of inline checks. | |
16440 | E.g. to disable inline code use | |
16441 | @option{--param asan-instrumentation-with-call-threshold=0}. | |
16442 | ||
545c9f8b | 16443 | @item asan-kernel-mem-intrinsic-prefix |
f56ed5b3 SL |
16444 | If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove} |
16445 | with @samp{__asan_} or @samp{__hwasan_} | |
16446 | for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress}, | |
16447 | respectively. | |
545c9f8b | 16448 | |
d77de738 ML |
16449 | @item hwasan-instrument-stack |
16450 | Enable hwasan instrumentation of statically sized stack-allocated variables. | |
16451 | This kind of instrumentation is enabled by default when using | |
16452 | @option{-fsanitize=hwaddress} and disabled by default when using | |
16453 | @option{-fsanitize=kernel-hwaddress}. | |
16454 | To disable stack instrumentation use | |
16455 | @option{--param hwasan-instrument-stack=0}, and to enable it use | |
16456 | @option{--param hwasan-instrument-stack=1}. | |
16457 | ||
16458 | @item hwasan-random-frame-tag | |
16459 | When using stack instrumentation, decide tags for stack variables using a | |
16460 | deterministic sequence beginning at a random tag for each frame. With this | |
16461 | parameter unset tags are chosen using the same sequence but beginning from 1. | |
16462 | This is enabled by default for @option{-fsanitize=hwaddress} and unavailable | |
16463 | for @option{-fsanitize=kernel-hwaddress}. | |
16464 | To disable it use @option{--param hwasan-random-frame-tag=0}. | |
16465 | ||
16466 | @item hwasan-instrument-allocas | |
16467 | Enable hwasan instrumentation of dynamically sized stack-allocated variables. | |
16468 | This kind of instrumentation is enabled by default when using | |
16469 | @option{-fsanitize=hwaddress} and disabled by default when using | |
16470 | @option{-fsanitize=kernel-hwaddress}. | |
16471 | To disable instrumentation of such variables use | |
16472 | @option{--param hwasan-instrument-allocas=0}, and to enable it use | |
16473 | @option{--param hwasan-instrument-allocas=1}. | |
16474 | ||
16475 | @item hwasan-instrument-reads | |
16476 | Enable hwasan checks on memory reads. Instrumentation of reads is enabled by | |
16477 | default for both @option{-fsanitize=hwaddress} and | |
16478 | @option{-fsanitize=kernel-hwaddress}. | |
16479 | To disable checking memory reads use | |
16480 | @option{--param hwasan-instrument-reads=0}. | |
16481 | ||
16482 | @item hwasan-instrument-writes | |
16483 | Enable hwasan checks on memory writes. Instrumentation of writes is enabled by | |
16484 | default for both @option{-fsanitize=hwaddress} and | |
16485 | @option{-fsanitize=kernel-hwaddress}. | |
16486 | To disable checking memory writes use | |
16487 | @option{--param hwasan-instrument-writes=0}. | |
16488 | ||
16489 | @item hwasan-instrument-mem-intrinsics | |
16490 | Enable hwasan instrumentation of builtin functions. Instrumentation of these | |
16491 | builtin functions is enabled by default for both @option{-fsanitize=hwaddress} | |
16492 | and @option{-fsanitize=kernel-hwaddress}. | |
16493 | To disable instrumentation of builtin functions use | |
16494 | @option{--param hwasan-instrument-mem-intrinsics=0}. | |
16495 | ||
16496 | @item use-after-scope-direct-emission-threshold | |
16497 | If the size of a local variable in bytes is smaller or equal to this | |
16498 | number, directly poison (or unpoison) shadow memory instead of using | |
16499 | run-time callbacks. | |
16500 | ||
16501 | @item tsan-distinguish-volatile | |
16502 | Emit special instrumentation for accesses to volatiles. | |
16503 | ||
16504 | @item tsan-instrument-func-entry-exit | |
16505 | Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit(). | |
16506 | ||
16507 | @item max-fsm-thread-path-insns | |
16508 | Maximum number of instructions to copy when duplicating blocks on a | |
16509 | finite state automaton jump thread path. | |
16510 | ||
16511 | @item threader-debug | |
16512 | threader-debug=[none|all] Enables verbose dumping of the threader solver. | |
16513 | ||
16514 | @item parloops-chunk-size | |
16515 | Chunk size of omp schedule for loops parallelized by parloops. | |
16516 | ||
16517 | @item parloops-schedule | |
16518 | Schedule type of omp schedule for loops parallelized by parloops (static, | |
16519 | dynamic, guided, auto, runtime). | |
16520 | ||
16521 | @item parloops-min-per-thread | |
16522 | The minimum number of iterations per thread of an innermost parallelized | |
16523 | loop for which the parallelized variant is preferred over the single threaded | |
16524 | one. Note that for a parallelized loop nest the | |
16525 | minimum number of iterations of the outermost loop per thread is two. | |
16526 | ||
16527 | @item max-ssa-name-query-depth | |
16528 | Maximum depth of recursion when querying properties of SSA names in things | |
16529 | like fold routines. One level of recursion corresponds to following a | |
16530 | use-def chain. | |
16531 | ||
16532 | @item max-speculative-devirt-maydefs | |
16533 | The maximum number of may-defs we analyze when looking for a must-def | |
16534 | specifying the dynamic type of an object that invokes a virtual call | |
16535 | we may be able to devirtualize speculatively. | |
16536 | ||
d77de738 ML |
16537 | @item ranger-debug |
16538 | Specifies the type of debug output to be issued for ranges. | |
16539 | ||
d77de738 ML |
16540 | @item unroll-jam-min-percent |
16541 | The minimum percentage of memory references that must be optimized | |
16542 | away for the unroll-and-jam transformation to be considered profitable. | |
16543 | ||
16544 | @item unroll-jam-max-unroll | |
16545 | The maximum number of times the outer loop should be unrolled by | |
16546 | the unroll-and-jam transformation. | |
16547 | ||
16548 | @item max-rtl-if-conversion-unpredictable-cost | |
16549 | Maximum permissible cost for the sequence that would be generated | |
16550 | by the RTL if-conversion pass for a branch that is considered unpredictable. | |
16551 | ||
16552 | @item max-variable-expansions-in-unroller | |
16553 | If @option{-fvariable-expansion-in-unroller} is used, the maximum number | |
16554 | of times that an individual variable will be expanded during loop unrolling. | |
16555 | ||
16556 | @item partial-inlining-entry-probability | |
16557 | Maximum probability of the entry BB of split region | |
16558 | (in percent relative to entry BB of the function) | |
16559 | to make partial inlining happen. | |
16560 | ||
16561 | @item max-tracked-strlens | |
16562 | Maximum number of strings for which strlen optimization pass will | |
16563 | track string lengths. | |
16564 | ||
16565 | @item gcse-after-reload-partial-fraction | |
16566 | The threshold ratio for performing partial redundancy | |
16567 | elimination after reload. | |
16568 | ||
16569 | @item gcse-after-reload-critical-fraction | |
16570 | The threshold ratio of critical edges execution count that | |
16571 | permit performing redundancy elimination after reload. | |
16572 | ||
16573 | @item max-loop-header-insns | |
16574 | The maximum number of insns in loop header duplicated | |
16575 | by the copy loop headers pass. | |
16576 | ||
16577 | @item vect-epilogues-nomask | |
16578 | Enable loop epilogue vectorization using smaller vector size. | |
16579 | ||
16580 | @item vect-partial-vector-usage | |
16581 | Controls when the loop vectorizer considers using partial vector loads | |
16582 | and stores as an alternative to falling back to scalar code. 0 stops | |
16583 | the vectorizer from ever using partial vector loads and stores. 1 allows | |
16584 | partial vector loads and stores if vectorization removes the need for the | |
16585 | code to iterate. 2 allows partial vector loads and stores in all loops. | |
16586 | The parameter only has an effect on targets that support partial | |
16587 | vector loads and stores. | |
16588 | ||
16589 | @item vect-inner-loop-cost-factor | |
16590 | The maximum factor which the loop vectorizer applies to the cost of statements | |
16591 | in an inner loop relative to the loop being vectorized. The factor applied | |
16592 | is the maximum of the estimated number of iterations of the inner loop and | |
16593 | this parameter. The default value of this parameter is 50. | |
16594 | ||
16595 | @item vect-induction-float | |
16596 | Enable loop vectorization of floating point inductions. | |
16597 | ||
cbe32d38 ML |
16598 | @item vrp-sparse-threshold |
16599 | Maximum number of basic blocks before VRP uses a sparse bitmap cache. | |
16600 | ||
16601 | @item vrp-switch-limit | |
16602 | Maximum number of outgoing edges in a switch before VRP will not process it. | |
16603 | ||
16604 | @item vrp-vector-threshold | |
16605 | Maximum number of basic blocks for VRP to use a basic cache vector. | |
16606 | ||
d77de738 ML |
16607 | @item avoid-fma-max-bits |
16608 | Maximum number of bits for which we avoid creating FMAs. | |
16609 | ||
8afdbcdd DZ |
16610 | @item fully-pipelined-fma |
16611 | Whether the target fully pipelines FMA instructions. If non-zero, | |
16612 | reassociation considers the benefit of parallelizing FMA's multiplication | |
16613 | part and addition part, assuming FMUL and FMA use the same units that can | |
16614 | also do FADD. | |
16615 | ||
d77de738 ML |
16616 | @item sms-loop-average-count-threshold |
16617 | A threshold on the average loop count considered by the swing modulo scheduler. | |
16618 | ||
16619 | @item sms-dfa-history | |
16620 | The number of cycles the swing modulo scheduler considers when checking | |
16621 | conflicts using DFA. | |
16622 | ||
16623 | @item graphite-allow-codegen-errors | |
16624 | Whether codegen errors should be ICEs when @option{-fchecking}. | |
16625 | ||
16626 | @item sms-max-ii-factor | |
16627 | A factor for tuning the upper bound that swing modulo scheduler | |
16628 | uses for scheduling a loop. | |
16629 | ||
16630 | @item lra-max-considered-reload-pseudos | |
16631 | The max number of reload pseudos which are considered during | |
16632 | spilling a non-reload pseudo. | |
16633 | ||
16634 | @item max-pow-sqrt-depth | |
16635 | Maximum depth of sqrt chains to use when synthesizing exponentiation | |
16636 | by a real constant. | |
16637 | ||
16638 | @item max-dse-active-local-stores | |
16639 | Maximum number of active local stores in RTL dead store elimination. | |
16640 | ||
16641 | @item asan-instrument-allocas | |
16642 | Enable asan allocas/VLAs protection. | |
16643 | ||
16644 | @item max-iterations-computation-cost | |
16645 | Bound on the cost of an expression to compute the number of iterations. | |
16646 | ||
16647 | @item max-isl-operations | |
16648 | Maximum number of isl operations, 0 means unlimited. | |
16649 | ||
16650 | @item graphite-max-arrays-per-scop | |
16651 | Maximum number of arrays per scop. | |
16652 | ||
16653 | @item max-vartrack-reverse-op-size | |
16654 | Max. size of loc list for which reverse ops should be added. | |
16655 | ||
16656 | @item fsm-scale-path-stmts | |
16657 | Scale factor to apply to the number of statements in a threading path | |
7c9f20fc RB |
16658 | crossing a loop backedge when comparing to |
16659 | @option{--param=max-jump-thread-duplication-stmts}. | |
d77de738 ML |
16660 | |
16661 | @item uninit-control-dep-attempts | |
16662 | Maximum number of nested calls to search for control dependencies | |
16663 | during uninitialized variable analysis. | |
16664 | ||
b8a2a124 RB |
16665 | @item uninit-max-chain-len |
16666 | Maximum number of predicates anded for each predicate ored in the normalized | |
16667 | predicate chain. | |
16668 | ||
16669 | @item uninit-max-num-chains | |
16670 | Maximum number of predicates ored in the normalized predicate chain. | |
16671 | ||
d77de738 ML |
16672 | @item sched-autopref-queue-depth |
16673 | Hardware autoprefetcher scheduler model control flag. | |
16674 | Number of lookahead cycles the model looks into; at ' | |
16675 | ' only enable instruction sorting heuristic. | |
16676 | ||
16677 | @item loop-versioning-max-inner-insns | |
16678 | The maximum number of instructions that an inner loop can have | |
16679 | before the loop versioning pass considers it too big to copy. | |
16680 | ||
16681 | @item loop-versioning-max-outer-insns | |
16682 | The maximum number of instructions that an outer loop can have | |
16683 | before the loop versioning pass considers it too big to copy, | |
16684 | discounting any instructions in inner loops that directly benefit | |
16685 | from versioning. | |
16686 | ||
16687 | @item ssa-name-def-chain-limit | |
16688 | The maximum number of SSA_NAME assignments to follow in determining | |
16689 | a property of a variable such as its value. This limits the number | |
16690 | of iterations or recursive calls GCC performs when optimizing certain | |
16691 | statements or when determining their validity prior to issuing | |
16692 | diagnostics. | |
16693 | ||
16694 | @item store-merging-max-size | |
16695 | Maximum size of a single store merging region in bytes. | |
16696 | ||
16697 | @item hash-table-verification-limit | |
16698 | The number of elements for which hash table verification is done | |
16699 | for each searched element. | |
16700 | ||
16701 | @item max-find-base-term-values | |
16702 | Maximum number of VALUEs handled during a single find_base_term call. | |
16703 | ||
16704 | @item analyzer-max-enodes-per-program-point | |
16705 | The maximum number of exploded nodes per program point within | |
16706 | the analyzer, before terminating analysis of that point. | |
16707 | ||
16708 | @item analyzer-max-constraints | |
16709 | The maximum number of constraints per state. | |
16710 | ||
16711 | @item analyzer-min-snodes-for-call-summary | |
16712 | The minimum number of supernodes within a function for the | |
16713 | analyzer to consider summarizing its effects at call sites. | |
16714 | ||
16715 | @item analyzer-max-enodes-for-full-dump | |
16716 | The maximum depth of exploded nodes that should appear in a dot dump | |
16717 | before switching to a less verbose format. | |
16718 | ||
16719 | @item analyzer-max-recursion-depth | |
16720 | The maximum number of times a callsite can appear in a call stack | |
16721 | within the analyzer, before terminating analysis of a call that would | |
16722 | recurse deeper. | |
16723 | ||
16724 | @item analyzer-max-svalue-depth | |
16725 | The maximum depth of a symbolic value, before approximating | |
16726 | the value as unknown. | |
16727 | ||
16728 | @item analyzer-max-infeasible-edges | |
16729 | The maximum number of infeasible edges to reject before declaring | |
16730 | a diagnostic as infeasible. | |
16731 | ||
16732 | @item gimple-fe-computed-hot-bb-threshold | |
16733 | The number of executions of a basic block which is considered hot. | |
16734 | The parameter is used only in GIMPLE FE. | |
16735 | ||
16736 | @item analyzer-bb-explosion-factor | |
16737 | The maximum number of 'after supernode' exploded nodes within the analyzer | |
16738 | per supernode, before terminating analysis. | |
16739 | ||
c0c5a57b MJ |
16740 | @item analyzer-text-art-string-ellipsis-threshold |
16741 | The number of bytes at which to ellipsize string literals in analyzer text art diagrams. | |
16742 | ||
16743 | @item analyzer-text-art-ideal-canvas-width | |
16744 | The ideal width in characters of text art diagrams generated by the analyzer. | |
16745 | ||
16746 | @item analyzer-text-art-string-ellipsis-head-len | |
16747 | The number of literal bytes to show at the head of a string literal in text art when ellipsizing it. | |
16748 | ||
16749 | @item analyzer-text-art-string-ellipsis-tail-len | |
16750 | The number of literal bytes to show at the tail of a string literal in text art when ellipsizing it. | |
16751 | ||
d77de738 ML |
16752 | @item ranger-logical-depth |
16753 | Maximum depth of logical expression evaluation ranger will look through | |
16754 | when evaluating outgoing edge ranges. | |
16755 | ||
9fd6d83a ML |
16756 | @item ranger-recompute-depth |
16757 | Maximum depth of instruction chains to consider for recomputation | |
16758 | in the outgoing range calculator. | |
16759 | ||
d77de738 ML |
16760 | @item relation-block-limit |
16761 | Maximum number of relations the oracle will register in a basic block. | |
16762 | ||
16763 | @item min-pagesize | |
16764 | Minimum page size for warning purposes. | |
16765 | ||
16766 | @item openacc-kernels | |
16767 | Specify mode of OpenACC `kernels' constructs handling. | |
16768 | With @option{--param=openacc-kernels=decompose}, OpenACC `kernels' | |
16769 | constructs are decomposed into parts, a sequence of compute | |
16770 | constructs, each then handled individually. | |
16771 | This is work in progress. | |
16772 | With @option{--param=openacc-kernels=parloops}, OpenACC `kernels' | |
16773 | constructs are handled by the @samp{parloops} pass, en bloc. | |
16774 | This is the current default. | |
16775 | ||
16776 | @item openacc-privatization | |
4ace81b6 SL |
16777 | Control whether the @option{-fopt-info-omp-note} and applicable |
16778 | @option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics. | |
d77de738 ML |
16779 | With @option{--param=openacc-privatization=quiet}, don't diagnose. |
16780 | This is the current default. | |
16781 | With @option{--param=openacc-privatization=noisy}, do diagnose. | |
16782 | ||
16783 | @end table | |
16784 | ||
16785 | The following choices of @var{name} are available on AArch64 targets: | |
16786 | ||
16787 | @table @gcctabopt | |
7328faf8 RS |
16788 | @item aarch64-vect-compare-costs |
16789 | When vectorizing, consider using multiple different approaches and use | |
16790 | the cost model to choose the cheapest one. This includes: | |
16791 | ||
16792 | @itemize | |
16793 | @item | |
16794 | Trying both SVE and Advanced SIMD, when SVE is available. | |
16795 | ||
16796 | @item | |
16797 | Trying to use 64-bit Advanced SIMD vectors for the smallest data elements, | |
16798 | rather than using 128-bit vectors for everything. | |
16799 | ||
16800 | @item | |
16801 | Trying to use ``unpacked'' SVE vectors for smaller elements. This includes | |
16802 | storing smaller elements in larger containers and accessing elements with | |
16803 | extending loads and truncating stores. | |
16804 | @end itemize | |
d77de738 ML |
16805 | |
16806 | @item aarch64-float-recp-precision | |
16807 | The number of Newton iterations for calculating the reciprocal for float type. | |
16808 | The precision of division is proportional to this param when division | |
16809 | approximation is enabled. The default value is 1. | |
16810 | ||
16811 | @item aarch64-double-recp-precision | |
16812 | The number of Newton iterations for calculating the reciprocal for double type. | |
16813 | The precision of division is propotional to this param when division | |
16814 | approximation is enabled. The default value is 2. | |
16815 | ||
16816 | @item aarch64-autovec-preference | |
16817 | Force an ISA selection strategy for auto-vectorization. Accepts values from | |
16818 | 0 to 4, inclusive. | |
16819 | @table @samp | |
16820 | @item 0 | |
16821 | Use the default heuristics. | |
16822 | @item 1 | |
16823 | Use only Advanced SIMD for auto-vectorization. | |
16824 | @item 2 | |
16825 | Use only SVE for auto-vectorization. | |
16826 | @item 3 | |
16827 | Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are | |
16828 | deemed equal. | |
16829 | @item 4 | |
16830 | Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal. | |
16831 | @end table | |
16832 | The default value is 0. | |
16833 | ||
834fc2bf MA |
16834 | @item aarch64-ldp-policy |
16835 | Fine-grained policy for load pairs. | |
16836 | With @option{--param=aarch64-ldp-policy=default}, use the policy of the | |
16837 | tuning structure. This is the current default. | |
16838 | With @option{--param=aarch64-ldp-policy=always}, emit ldp regardless | |
16839 | of alignment. | |
16840 | With @option{--param=aarch64-ldp-policy=never}, do not emit ldp. | |
16841 | With @option{--param=aarch64-ldp-policy=aligned}, emit ldp only if the | |
16842 | source pointer is aligned to at least double the alignment of the type. | |
16843 | ||
16844 | @item aarch64-stp-policy | |
16845 | Fine-grained policy for store pairs. | |
16846 | With @option{--param=aarch64-stp-policy=default}, use the policy of the | |
16847 | tuning structure. This is the current default. | |
16848 | With @option{--param=aarch64-stp-policy=always}, emit stp regardless | |
16849 | of alignment. | |
16850 | With @option{--param=aarch64-stp-policy=never}, do not emit stp. | |
16851 | With @option{--param=aarch64-stp-policy=aligned}, emit stp only if the | |
16852 | source pointer is aligned to at least double the alignment of the type. | |
16853 | ||
c0911c6b AC |
16854 | @item aarch64-ldp-alias-check-limit |
16855 | Limit on the number of alias checks performed by the AArch64 load/store pair | |
16856 | fusion pass when attempting to form an ldp/stp. Higher values make the pass | |
16857 | more aggressive at re-ordering loads over stores, at the expense of increased | |
16858 | compile time. | |
16859 | ||
16860 | @item aarch64-ldp-writeback | |
16861 | Param to control which writeback opportunities we try to handle in the AArch64 | |
16862 | load/store pair fusion pass. A value of zero disables writeback handling. One | |
16863 | means we try to form pairs involving one or more existing individual writeback | |
16864 | accesses where possible. A value of two means we also try to opportunistically | |
16865 | form writeback opportunities by folding in trailing destructive updates of the | |
16866 | base register used by a pair. | |
16867 | ||
d77de738 ML |
16868 | @item aarch64-loop-vect-issue-rate-niters |
16869 | The tuning for some AArch64 CPUs tries to take both latencies and issue | |
16870 | rates into account when deciding whether a loop should be vectorized | |
16871 | using SVE, vectorized using Advanced SIMD, or not vectorized at all. | |
16872 | If this parameter is set to @var{n}, GCC will not use this heuristic | |
16873 | for loops that are known to execute in fewer than @var{n} Advanced | |
16874 | SIMD iterations. | |
16875 | ||
16876 | @item aarch64-vect-unroll-limit | |
16877 | The vectorizer will use available tuning information to determine whether it | |
16878 | would be beneficial to unroll the main vectorized loop and by how much. This | |
16879 | parameter set's the upper bound of how much the vectorizer will unroll the main | |
16880 | loop. The default value is four. | |
16881 | ||
16882 | @end table | |
16883 | ||
16884 | The following choices of @var{name} are available on i386 and x86_64 targets: | |
16885 | ||
16886 | @table @gcctabopt | |
16887 | @item x86-stlf-window-ninsns | |
16888 | Instructions number above which STFL stall penalty can be compensated. | |
16889 | ||
60101899 RB |
16890 | @item x86-stv-max-visits |
16891 | The maximum number of use and def visits when discovering a STV chain before | |
16892 | the discovery is aborted. | |
16893 | ||
d77de738 ML |
16894 | @end table |
16895 | ||
16896 | @end table | |
16897 | ||
16898 | @node Instrumentation Options | |
16899 | @section Program Instrumentation Options | |
16900 | @cindex instrumentation options | |
16901 | @cindex program instrumentation options | |
16902 | @cindex run-time error checking options | |
16903 | @cindex profiling options | |
16904 | @cindex options, program instrumentation | |
16905 | @cindex options, run-time error checking | |
16906 | @cindex options, profiling | |
16907 | ||
16908 | GCC supports a number of command-line options that control adding | |
16909 | run-time instrumentation to the code it normally generates. | |
16910 | For example, one purpose of instrumentation is collect profiling | |
16911 | statistics for use in finding program hot spots, code coverage | |
16912 | analysis, or profile-guided optimizations. | |
16913 | Another class of program instrumentation is adding run-time checking | |
16914 | to detect programming errors like invalid pointer | |
16915 | dereferences or out-of-bounds array accesses, as well as deliberately | |
16916 | hostile attacks such as stack smashing or C++ vtable hijacking. | |
16917 | There is also a general hook which can be used to implement other | |
16918 | forms of tracing or function-level instrumentation for debug or | |
16919 | program analysis purposes. | |
16920 | ||
16921 | @table @gcctabopt | |
16922 | @cindex @command{prof} | |
16923 | @cindex @command{gprof} | |
d77de738 ML |
16924 | @opindex p |
16925 | @opindex pg | |
ddf6fe37 AA |
16926 | @item -p |
16927 | @itemx -pg | |
d77de738 ML |
16928 | Generate extra code to write profile information suitable for the |
16929 | analysis program @command{prof} (for @option{-p}) or @command{gprof} | |
16930 | (for @option{-pg}). You must use this option when compiling | |
16931 | the source files you want data about, and you must also use it when | |
16932 | linking. | |
16933 | ||
16934 | You can use the function attribute @code{no_instrument_function} to | |
16935 | suppress profiling of individual functions when compiling with these options. | |
16936 | @xref{Common Function Attributes}. | |
16937 | ||
d77de738 | 16938 | @opindex fprofile-arcs |
ddf6fe37 | 16939 | @item -fprofile-arcs |
d77de738 ML |
16940 | Add code so that program flow @dfn{arcs} are instrumented. During |
16941 | execution the program records how many times each branch and call is | |
16942 | executed and how many times it is taken or returns. On targets that support | |
16943 | constructors with priority support, profiling properly handles constructors, | |
16944 | destructors and C++ constructors (and destructors) of classes which are used | |
16945 | as a type of a global variable. | |
16946 | ||
16947 | When the compiled | |
16948 | program exits it saves this data to a file called | |
16949 | @file{@var{auxname}.gcda} for each source file. The data may be used for | |
16950 | profile-directed optimizations (@option{-fbranch-probabilities}), or for | |
16951 | test coverage analysis (@option{-ftest-coverage}). Each object file's | |
16952 | @var{auxname} is generated from the name of the output file, if | |
16953 | explicitly specified and it is not the final executable, otherwise it is | |
16954 | the basename of the source file. In both cases any suffix is removed | |
16955 | (e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or | |
16956 | @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}). | |
16957 | ||
16958 | Note that if a command line directly links source files, the corresponding | |
16959 | @var{.gcda} files will be prefixed with the unsuffixed name of the output file. | |
16960 | E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and | |
16961 | @file{binary-b.gcda} files. | |
16962 | ||
16963 | @xref{Cross-profiling}. | |
16964 | ||
16965 | @cindex @command{gcov} | |
d77de738 | 16966 | @opindex coverage |
ddf6fe37 | 16967 | @item --coverage |
d77de738 ML |
16968 | |
16969 | This option is used to compile and link code instrumented for coverage | |
16970 | analysis. The option is a synonym for @option{-fprofile-arcs} | |
16971 | @option{-ftest-coverage} (when compiling) and @option{-lgcov} (when | |
16972 | linking). See the documentation for those options for more details. | |
16973 | ||
16974 | @itemize | |
16975 | ||
16976 | @item | |
16977 | Compile the source files with @option{-fprofile-arcs} plus optimization | |
16978 | and code generation options. For test coverage analysis, use the | |
16979 | additional @option{-ftest-coverage} option. You do not need to profile | |
16980 | every source file in a program. | |
16981 | ||
16982 | @item | |
16983 | Compile the source files additionally with @option{-fprofile-abs-path} | |
16984 | to create absolute path names in the @file{.gcno} files. This allows | |
16985 | @command{gcov} to find the correct sources in projects where compilations | |
16986 | occur with different working directories. | |
16987 | ||
16988 | @item | |
16989 | Link your object files with @option{-lgcov} or @option{-fprofile-arcs} | |
16990 | (the latter implies the former). | |
16991 | ||
16992 | @item | |
16993 | Run the program on a representative workload to generate the arc profile | |
16994 | information. This may be repeated any number of times. You can run | |
16995 | concurrent instances of your program, and provided that the file system | |
16996 | supports locking, the data files will be correctly updated. Unless | |
16997 | a strict ISO C dialect option is in effect, @code{fork} calls are | |
16998 | detected and correctly handled without double counting. | |
16999 | ||
17000 | Moreover, an object file can be recompiled multiple times | |
17001 | and the corresponding @file{.gcda} file merges as long as | |
17002 | the source file and the compiler options are unchanged. | |
17003 | ||
17004 | @item | |
17005 | For profile-directed optimizations, compile the source files again with | |
17006 | the same optimization and code generation options plus | |
17007 | @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that | |
17008 | Control Optimization}). | |
17009 | ||
17010 | @item | |
17011 | For test coverage analysis, use @command{gcov} to produce human readable | |
17012 | information from the @file{.gcno} and @file{.gcda} files. Refer to the | |
17013 | @command{gcov} documentation for further information. | |
17014 | ||
17015 | @end itemize | |
17016 | ||
17017 | With @option{-fprofile-arcs}, for each function of your program GCC | |
17018 | creates a program flow graph, then finds a spanning tree for the graph. | |
17019 | Only arcs that are not on the spanning tree have to be instrumented: the | |
17020 | compiler adds code to count the number of times that these arcs are | |
17021 | executed. When an arc is the only exit or only entrance to a block, the | |
17022 | instrumentation code can be added to the block; otherwise, a new basic | |
17023 | block must be created to hold the instrumentation code. | |
17024 | ||
17025 | @need 2000 | |
d77de738 | 17026 | @opindex ftest-coverage |
ddf6fe37 | 17027 | @item -ftest-coverage |
d77de738 ML |
17028 | Produce a notes file that the @command{gcov} code-coverage utility |
17029 | (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to | |
17030 | show program coverage. Each source file's note file is called | |
17031 | @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option | |
17032 | above for a description of @var{auxname} and instructions on how to | |
17033 | generate test coverage data. Coverage data matches the source files | |
17034 | more closely if you do not optimize. | |
17035 | ||
d77de738 | 17036 | @opindex fprofile-abs-path |
ddf6fe37 | 17037 | @item -fprofile-abs-path |
d77de738 ML |
17038 | Automatically convert relative source file names to absolute path names |
17039 | in the @file{.gcno} files. This allows @command{gcov} to find the correct | |
17040 | sources in projects where compilations occur with different working | |
17041 | directories. | |
17042 | ||
d77de738 | 17043 | @opindex fprofile-dir |
ddf6fe37 | 17044 | @item -fprofile-dir=@var{path} |
d77de738 ML |
17045 | |
17046 | Set the directory to search for the profile data files in to @var{path}. | |
17047 | This option affects only the profile data generated by | |
17048 | @option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs} | |
17049 | and used by @option{-fprofile-use} and @option{-fbranch-probabilities} | |
17050 | and its related options. Both absolute and relative paths can be used. | |
17051 | By default, GCC uses the current directory as @var{path}, thus the | |
17052 | profile data file appears in the same directory as the object file. | |
17053 | In order to prevent the file name clashing, if the object file name is | |
17054 | not an absolute path, we mangle the absolute path of the | |
17055 | @file{@var{sourcename}.gcda} file and use it as the file name of a | |
17056 | @file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}. | |
17057 | See similar option @option{-fprofile-note}. | |
17058 | ||
17059 | When an executable is run in a massive parallel environment, it is recommended | |
17060 | to save profile to different folders. That can be done with variables | |
17061 | in @var{path} that are exported during run-time: | |
17062 | ||
17063 | @table @gcctabopt | |
17064 | ||
17065 | @item %p | |
17066 | process ID. | |
17067 | ||
17068 | @item %q@{VAR@} | |
17069 | value of environment variable @var{VAR} | |
17070 | ||
17071 | @end table | |
17072 | ||
ddf6fe37 | 17073 | @opindex fprofile-generate |
d77de738 ML |
17074 | @item -fprofile-generate |
17075 | @itemx -fprofile-generate=@var{path} | |
d77de738 ML |
17076 | |
17077 | Enable options usually used for instrumenting application to produce | |
17078 | profile useful for later recompilation with profile feedback based | |
17079 | optimization. You must use @option{-fprofile-generate} both when | |
17080 | compiling and when linking your program. | |
17081 | ||
17082 | The following options are enabled: | |
17083 | @option{-fprofile-arcs}, @option{-fprofile-values}, | |
17084 | @option{-finline-functions}, and @option{-fipa-bit-cp}. | |
17085 | ||
17086 | If @var{path} is specified, GCC looks at the @var{path} to find | |
17087 | the profile feedback data files. See @option{-fprofile-dir}. | |
17088 | ||
17089 | To optimize the program based on the collected profile information, use | |
17090 | @option{-fprofile-use}. @xref{Optimize Options}, for more information. | |
17091 | ||
ddf6fe37 | 17092 | @opindex fprofile-info-section |
d77de738 ML |
17093 | @item -fprofile-info-section |
17094 | @itemx -fprofile-info-section=@var{name} | |
d77de738 ML |
17095 | |
17096 | Register the profile information in the specified section instead of using a | |
17097 | constructor/destructor. The section name is @var{name} if it is specified, | |
17098 | otherwise the section name defaults to @code{.gcov_info}. A pointer to the | |
17099 | profile information generated by @option{-fprofile-arcs} is placed in the | |
17100 | specified section for each translation unit. This option disables the profile | |
17101 | information registration through a constructor and it disables the profile | |
17102 | information processing through a destructor. This option is not intended to be | |
17103 | used in hosted environments such as GNU/Linux. It targets freestanding | |
17104 | environments (for example embedded systems) with limited resources which do not | |
17105 | support constructors/destructors or the C library file I/O. | |
17106 | ||
17107 | The linker could collect the input sections in a continuous memory block and | |
17108 | define start and end symbols. A GNU linker script example which defines a | |
17109 | linker output section follows: | |
17110 | ||
17111 | @smallexample | |
17112 | .gcov_info : | |
17113 | @{ | |
17114 | PROVIDE (__gcov_info_start = .); | |
17115 | KEEP (*(.gcov_info)) | |
17116 | PROVIDE (__gcov_info_end = .); | |
17117 | @} | |
17118 | @end smallexample | |
17119 | ||
17120 | The program could dump the profiling information registered in this linker set | |
17121 | for example like this: | |
17122 | ||
17123 | @smallexample | |
17124 | #include <gcov.h> | |
17125 | #include <stdio.h> | |
17126 | #include <stdlib.h> | |
17127 | ||
17128 | extern const struct gcov_info *const __gcov_info_start[]; | |
17129 | extern const struct gcov_info *const __gcov_info_end[]; | |
17130 | ||
17131 | static void | |
17132 | dump (const void *d, unsigned n, void *arg) | |
17133 | @{ | |
17134 | const unsigned char *c = d; | |
17135 | ||
17136 | for (unsigned i = 0; i < n; ++i) | |
17137 | printf ("%02x", c[i]); | |
17138 | @} | |
17139 | ||
17140 | static void | |
17141 | filename (const char *f, void *arg) | |
17142 | @{ | |
17143 | __gcov_filename_to_gcfn (f, dump, arg ); | |
17144 | @} | |
17145 | ||
17146 | static void * | |
17147 | allocate (unsigned length, void *arg) | |
17148 | @{ | |
17149 | return malloc (length); | |
17150 | @} | |
17151 | ||
17152 | static void | |
17153 | dump_gcov_info (void) | |
17154 | @{ | |
17155 | const struct gcov_info *const *info = __gcov_info_start; | |
17156 | const struct gcov_info *const *end = __gcov_info_end; | |
17157 | ||
17158 | /* Obfuscate variable to prevent compiler optimizations. */ | |
17159 | __asm__ ("" : "+r" (info)); | |
17160 | ||
17161 | while (info != end) | |
17162 | @{ | |
17163 | void *arg = NULL; | |
17164 | __gcov_info_to_gcda (*info, filename, dump, allocate, arg); | |
17165 | putchar ('\n'); | |
17166 | ++info; | |
17167 | @} | |
17168 | @} | |
17169 | ||
17170 | int | |
17171 | main (void) | |
17172 | @{ | |
17173 | dump_gcov_info (); | |
17174 | return 0; | |
17175 | @} | |
17176 | @end smallexample | |
17177 | ||
17178 | The @command{merge-stream} subcommand of @command{gcov-tool} may be used to | |
17179 | deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and | |
17180 | @code{__gcov_info_to_gcda} functions and merge the profile information into | |
17181 | @file{.gcda} files on the host filesystem. | |
17182 | ||
d77de738 | 17183 | @opindex fprofile-note |
ddf6fe37 | 17184 | @item -fprofile-note=@var{path} |
d77de738 ML |
17185 | |
17186 | If @var{path} is specified, GCC saves @file{.gcno} file into @var{path} | |
17187 | location. If you combine the option with multiple source files, | |
17188 | the @file{.gcno} file will be overwritten. | |
17189 | ||
d77de738 | 17190 | @opindex fprofile-prefix-path |
ddf6fe37 | 17191 | @item -fprofile-prefix-path=@var{path} |
d77de738 ML |
17192 | |
17193 | This option can be used in combination with | |
17194 | @option{profile-generate=}@var{profile_dir} and | |
17195 | @option{profile-use=}@var{profile_dir} to inform GCC where is the base | |
17196 | directory of built source tree. By default @var{profile_dir} will contain | |
17197 | files with mangled absolute paths of all object files in the built project. | |
17198 | This is not desirable when directory used to build the instrumented binary | |
17199 | differs from the directory used to build the binary optimized with profile | |
17200 | feedback because the profile data will not be found during the optimized build. | |
17201 | In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path} | |
17202 | pointing to the base directory of the build can be used to strip the irrelevant | |
17203 | part of the path and keep all file names relative to the main build directory. | |
17204 | ||
d77de738 | 17205 | @opindex fprofile-prefix-map |
ddf6fe37 | 17206 | @item -fprofile-prefix-map=@var{old}=@var{new} |
d77de738 ML |
17207 | When compiling files residing in directory @file{@var{old}}, record |
17208 | profiling information (with @option{--coverage}) | |
17209 | describing them as if the files resided in | |
17210 | directory @file{@var{new}} instead. | |
2eb0191a | 17211 | See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}. |
d77de738 | 17212 | |
d77de738 | 17213 | @opindex fprofile-update |
ddf6fe37 | 17214 | @item -fprofile-update=@var{method} |
d77de738 ML |
17215 | |
17216 | Alter the update method for an application instrumented for profile | |
17217 | feedback based optimization. The @var{method} argument should be one of | |
17218 | @samp{single}, @samp{atomic} or @samp{prefer-atomic}. | |
17219 | The first one is useful for single-threaded applications, | |
17220 | while the second one prevents profile corruption by emitting thread-safe code. | |
17221 | ||
17222 | @strong{Warning:} When an application does not properly join all threads | |
17223 | (or creates an detached thread), a profile file can be still corrupted. | |
17224 | ||
17225 | Using @samp{prefer-atomic} would be transformed either to @samp{atomic}, | |
17226 | when supported by a target, or to @samp{single} otherwise. The GCC driver | |
17227 | automatically selects @samp{prefer-atomic} when @option{-pthread} | |
20a3c74c SH |
17228 | is present in the command line, otherwise the default method is @samp{single}. |
17229 | ||
17230 | If @samp{atomic} is selected, then the profile information is updated using | |
17231 | atomic operations on a best-effort basis. Ideally, the profile information is | |
17232 | updated through atomic operations in hardware. If the target platform does not | |
17233 | support the required atomic operations in hardware, however, @file{libatomic} | |
17234 | is available, then the profile information is updated through calls to | |
17235 | @file{libatomic}. If the target platform neither supports the required atomic | |
17236 | operations in hardware nor @file{libatomic}, then the profile information is | |
17237 | not atomically updated and a warning is issued. In this case, the obtained | |
17238 | profiling information may be corrupt for multi-threaded applications. | |
17239 | ||
17240 | For performance reasons, if 64-bit counters are used for the profiling | |
17241 | information and the target platform only supports 32-bit atomic operations in | |
17242 | hardware, then the performance critical profiling updates are done using two | |
17243 | 32-bit atomic operations for each counter update. If a signal interrupts these | |
17244 | two operations updating a counter, then the profiling information may be in an | |
17245 | inconsistent state. | |
d77de738 | 17246 | |
d77de738 | 17247 | @opindex fprofile-filter-files |
ddf6fe37 | 17248 | @item -fprofile-filter-files=@var{regex} |
d77de738 ML |
17249 | |
17250 | Instrument only functions from files whose name matches | |
17251 | any of the regular expressions (separated by semi-colons). | |
17252 | ||
17253 | For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument | |
17254 | only @file{main.c} and all C files starting with 'module'. | |
17255 | ||
d77de738 | 17256 | @opindex fprofile-exclude-files |
ddf6fe37 | 17257 | @item -fprofile-exclude-files=@var{regex} |
d77de738 ML |
17258 | |
17259 | Instrument only functions from files whose name does not match | |
17260 | any of the regular expressions (separated by semi-colons). | |
17261 | ||
17262 | For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation | |
17263 | of all files that are located in the @file{/usr/} folder. | |
17264 | ||
d77de738 | 17265 | @opindex fprofile-reproducible |
ddf6fe37 | 17266 | @item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} |
d77de738 ML |
17267 | Control level of reproducibility of profile gathered by |
17268 | @code{-fprofile-generate}. This makes it possible to rebuild program | |
17269 | with same outcome which is useful, for example, for distribution | |
17270 | packages. | |
17271 | ||
17272 | With @option{-fprofile-reproducible=serial} the profile gathered by | |
17273 | @option{-fprofile-generate} is reproducible provided the trained program | |
17274 | behaves the same at each invocation of the train run, it is not | |
17275 | multi-threaded and profile data streaming is always done in the same | |
17276 | order. Note that profile streaming happens at the end of program run but | |
17277 | also before @code{fork} function is invoked. | |
17278 | ||
17279 | Note that it is quite common that execution counts of some part of | |
17280 | programs depends, for example, on length of temporary file names or | |
17281 | memory space randomization (that may affect hash-table collision rate). | |
17282 | Such non-reproducible part of programs may be annotated by | |
17283 | @code{no_instrument_function} function attribute. @command{gcov-dump} with | |
17284 | @option{-l} can be used to dump gathered data and verify that they are | |
17285 | indeed reproducible. | |
17286 | ||
17287 | With @option{-fprofile-reproducible=parallel-runs} collected profile | |
17288 | stays reproducible regardless the order of streaming of the data into | |
17289 | gcda files. This setting makes it possible to run multiple instances of | |
17290 | instrumented program in parallel (such as with @code{make -j}). This | |
17291 | reduces quality of gathered data, in particular of indirect call | |
17292 | profiling. | |
17293 | ||
d77de738 | 17294 | @opindex fsanitize=address |
ddf6fe37 | 17295 | @item -fsanitize=address |
d77de738 ML |
17296 | Enable AddressSanitizer, a fast memory error detector. |
17297 | Memory access instructions are instrumented to detect | |
17298 | out-of-bounds and use-after-free bugs. | |
17299 | The option enables @option{-fsanitize-address-use-after-scope}. | |
17300 | See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for | |
17301 | more details. The run-time behavior can be influenced using the | |
17302 | @env{ASAN_OPTIONS} environment variable. When set to @code{help=1}, | |
17303 | the available options are shown at startup of the instrumented program. See | |
17304 | @url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags} | |
17305 | for a list of supported options. | |
17306 | The option cannot be combined with @option{-fsanitize=thread} or | |
17307 | @option{-fsanitize=hwaddress}. Note that the only target | |
17308 | @option{-fsanitize=hwaddress} is currently supported on is AArch64. | |
17309 | ||
6a07798c MP |
17310 | To get more accurate stack traces, it is possible to use options such as |
17311 | @option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent | |
17312 | most function inlining), @option{-fno-optimize-sibling-calls} (which prevents | |
17313 | optimizing sibling and tail recursive calls; this option is implicit for | |
17314 | @option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which | |
17315 | disables Identical Code Folding for functions). Since multiple runs of the | |
17316 | program may yield backtraces with different addresses due to ASLR (Address | |
17317 | Space Layout Randomization), it may be desirable to turn ASLR off. On Linux, | |
17318 | this can be achieved with @samp{setarch `uname -m` -R ./prog}. | |
17319 | ||
d77de738 | 17320 | @opindex fsanitize=kernel-address |
f33d7a88 | 17321 | @item -fsanitize=kernel-address |
d77de738 | 17322 | Enable AddressSanitizer for Linux kernel. |
a0bf71be | 17323 | See @uref{https://github.com/google/kernel-sanitizers} for more details. |
d77de738 | 17324 | |
d77de738 | 17325 | @opindex fsanitize=hwaddress |
f33d7a88 | 17326 | @item -fsanitize=hwaddress |
d77de738 ML |
17327 | Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to |
17328 | ignore the top byte of a pointer to allow the detection of memory errors with | |
17329 | a low memory overhead. | |
17330 | Memory access instructions are instrumented to detect out-of-bounds and | |
17331 | use-after-free bugs. | |
17332 | The option enables @option{-fsanitize-address-use-after-scope}. | |
17333 | See | |
17334 | @uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html} | |
17335 | for more details. The run-time behavior can be influenced using the | |
17336 | @env{HWASAN_OPTIONS} environment variable. When set to @code{help=1}, | |
17337 | the available options are shown at startup of the instrumented program. | |
17338 | The option cannot be combined with @option{-fsanitize=thread} or | |
17339 | @option{-fsanitize=address}, and is currently only available on AArch64. | |
17340 | ||
d77de738 | 17341 | @opindex fsanitize=kernel-hwaddress |
ddf6fe37 | 17342 | @item -fsanitize=kernel-hwaddress |
d77de738 ML |
17343 | Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel. |
17344 | Similar to @option{-fsanitize=kernel-address} but using an alternate | |
17345 | instrumentation method, and similar to @option{-fsanitize=hwaddress} but with | |
17346 | instrumentation differences necessary for compiling the Linux kernel. | |
17347 | These differences are to avoid hwasan library initialization calls and to | |
17348 | account for the stack pointer having a different value in its top byte. | |
17349 | ||
17350 | @emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}. | |
17351 | Instrumenting the stack and alloca calls are not on by default but are still | |
17352 | possible by specifying the command-line options | |
17353 | @option{--param hwasan-instrument-stack=1} and | |
17354 | @option{--param hwasan-instrument-allocas=1} respectively. Using a random frame | |
17355 | tag is not implemented for kernel instrumentation. | |
17356 | ||
d77de738 | 17357 | @opindex fsanitize=pointer-compare |
ddf6fe37 | 17358 | @item -fsanitize=pointer-compare |
d77de738 ML |
17359 | Instrument comparison operation (<, <=, >, >=) with pointer operands. |
17360 | The option must be combined with either @option{-fsanitize=kernel-address} or | |
17361 | @option{-fsanitize=address} | |
17362 | The option cannot be combined with @option{-fsanitize=thread}. | |
17363 | Note: By default the check is disabled at run time. To enable it, | |
17364 | add @code{detect_invalid_pointer_pairs=2} to the environment variable | |
17365 | @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects | |
17366 | invalid operation only when both pointers are non-null. | |
17367 | ||
d77de738 | 17368 | @opindex fsanitize=pointer-subtract |
ddf6fe37 | 17369 | @item -fsanitize=pointer-subtract |
d77de738 ML |
17370 | Instrument subtraction with pointer operands. |
17371 | The option must be combined with either @option{-fsanitize=kernel-address} or | |
17372 | @option{-fsanitize=address} | |
17373 | The option cannot be combined with @option{-fsanitize=thread}. | |
17374 | Note: By default the check is disabled at run time. To enable it, | |
17375 | add @code{detect_invalid_pointer_pairs=2} to the environment variable | |
17376 | @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects | |
17377 | invalid operation only when both pointers are non-null. | |
17378 | ||
d77de738 | 17379 | @opindex fsanitize=shadow-call-stack |
ddf6fe37 | 17380 | @item -fsanitize=shadow-call-stack |
d77de738 ML |
17381 | Enable ShadowCallStack, a security enhancement mechanism used to protect |
17382 | programs against return address overwrites (e.g. stack buffer overflows.) | |
17383 | It works by saving a function's return address to a separately allocated | |
17384 | shadow call stack in the function prologue and restoring the return address | |
17385 | from the shadow call stack in the function epilogue. Instrumentation only | |
17386 | occurs in functions that need to save the return address to the stack. | |
17387 | ||
17388 | Currently it only supports the aarch64 platform. It is specifically | |
17389 | designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option. | |
17390 | For the user space programs, runtime support is not currently provided | |
17391 | in libc and libgcc. Users who want to use this feature in user space need | |
17392 | to provide their own support for the runtime. It should be noted that | |
17393 | this may cause the ABI rules to be broken. | |
17394 | ||
17395 | On aarch64, the instrumentation makes use of the platform register @code{x18}. | |
17396 | This generally means that any code that may run on the same thread as code | |
17397 | compiled with ShadowCallStack must be compiled with the flag | |
17398 | @option{-ffixed-x18}, otherwise functions compiled without | |
17399 | @option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow | |
17400 | stack pointer. | |
17401 | ||
17402 | Also, because there is no userspace runtime support, code compiled with | |
17403 | ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions} | |
17404 | to turn off exceptions. | |
17405 | ||
17406 | See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more | |
17407 | details. | |
17408 | ||
d77de738 | 17409 | @opindex fsanitize=thread |
ddf6fe37 | 17410 | @item -fsanitize=thread |
d77de738 ML |
17411 | Enable ThreadSanitizer, a fast data race detector. |
17412 | Memory access instructions are instrumented to detect | |
17413 | data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more | |
17414 | details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS} | |
17415 | environment variable; see | |
17416 | @url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of | |
17417 | supported options. | |
17418 | The option cannot be combined with @option{-fsanitize=address}, | |
17419 | @option{-fsanitize=leak}. | |
17420 | ||
17421 | Note that sanitized atomic builtins cannot throw exceptions when | |
17422 | operating on invalid memory addresses with non-call exceptions | |
17423 | (@option{-fnon-call-exceptions}). | |
17424 | ||
d77de738 | 17425 | @opindex fsanitize=leak |
ddf6fe37 | 17426 | @item -fsanitize=leak |
d77de738 | 17427 | Enable LeakSanitizer, a memory leak detector. |
c5c4fdac JG |
17428 | This option only matters for linking of executables. |
17429 | The executable is linked against a library that overrides @code{malloc} | |
d77de738 ML |
17430 | and other allocator functions. See |
17431 | @uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more | |
17432 | details. The run-time behavior can be influenced using the | |
17433 | @env{LSAN_OPTIONS} environment variable. | |
17434 | The option cannot be combined with @option{-fsanitize=thread}. | |
17435 | ||
d77de738 | 17436 | @opindex fsanitize=undefined |
ddf6fe37 | 17437 | @item -fsanitize=undefined |
d77de738 ML |
17438 | Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector. |
17439 | Various computations are instrumented to detect undefined behavior | |
17440 | at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the | |
17441 | @env{UBSAN_OPTIONS} environment variable. Current suboptions are: | |
17442 | ||
17443 | @table @gcctabopt | |
17444 | ||
d77de738 | 17445 | @opindex fsanitize=shift |
ddf6fe37 | 17446 | @item -fsanitize=shift |
d77de738 ML |
17447 | This option enables checking that the result of a shift operation is |
17448 | not undefined. Note that what exactly is considered undefined differs | |
17449 | slightly between C and C++, as well as between ISO C90 and C99, etc. | |
17450 | This option has two suboptions, @option{-fsanitize=shift-base} and | |
17451 | @option{-fsanitize=shift-exponent}. | |
17452 | ||
d77de738 | 17453 | @opindex fsanitize=shift-exponent |
ddf6fe37 | 17454 | @item -fsanitize=shift-exponent |
d77de738 ML |
17455 | This option enables checking that the second argument of a shift operation |
17456 | is not negative and is smaller than the precision of the promoted first | |
17457 | argument. | |
17458 | ||
d77de738 | 17459 | @opindex fsanitize=shift-base |
ddf6fe37 | 17460 | @item -fsanitize=shift-base |
d77de738 ML |
17461 | If the second argument of a shift operation is within range, check that the |
17462 | result of a shift operation is not undefined. Note that what exactly is | |
17463 | considered undefined differs slightly between C and C++, as well as between | |
17464 | ISO C90 and C99, etc. | |
17465 | ||
d77de738 | 17466 | @opindex fsanitize=integer-divide-by-zero |
ddf6fe37 | 17467 | @item -fsanitize=integer-divide-by-zero |
d77de738 ML |
17468 | Detect integer division by zero. |
17469 | ||
d77de738 | 17470 | @opindex fsanitize=unreachable |
ddf6fe37 | 17471 | @item -fsanitize=unreachable |
d77de738 ML |
17472 | With this option, the compiler turns the @code{__builtin_unreachable} |
17473 | call into a diagnostics message call instead. When reaching the | |
17474 | @code{__builtin_unreachable} call, the behavior is undefined. | |
17475 | ||
d77de738 | 17476 | @opindex fsanitize=vla-bound |
ddf6fe37 | 17477 | @item -fsanitize=vla-bound |
d77de738 ML |
17478 | This option instructs the compiler to check that the size of a variable |
17479 | length array is positive. | |
17480 | ||
d77de738 | 17481 | @opindex fsanitize=null |
ddf6fe37 | 17482 | @item -fsanitize=null |
d77de738 ML |
17483 | This option enables pointer checking. Particularly, the application |
17484 | built with this option turned on will issue an error message when it | |
17485 | tries to dereference a NULL pointer, or if a reference (possibly an | |
17486 | rvalue reference) is bound to a NULL pointer, or if a method is invoked | |
17487 | on an object pointed by a NULL pointer. | |
17488 | ||
d77de738 | 17489 | @opindex fsanitize=return |
ddf6fe37 | 17490 | @item -fsanitize=return |
d77de738 ML |
17491 | This option enables return statement checking. Programs |
17492 | built with this option turned on will issue an error message | |
17493 | when the end of a non-void function is reached without actually | |
17494 | returning a value. This option works in C++ only. | |
17495 | ||
d77de738 | 17496 | @opindex fsanitize=signed-integer-overflow |
ddf6fe37 | 17497 | @item -fsanitize=signed-integer-overflow |
d77de738 ML |
17498 | This option enables signed integer overflow checking. We check that |
17499 | the result of @code{+}, @code{*}, and both unary and binary @code{-} | |
17500 | does not overflow in the signed arithmetics. This also detects | |
17501 | @code{INT_MIN / -1} signed division. Note, integer promotion | |
17502 | rules must be taken into account. That is, the following is not an | |
17503 | overflow: | |
17504 | @smallexample | |
17505 | signed char a = SCHAR_MAX; | |
17506 | a++; | |
17507 | @end smallexample | |
17508 | ||
d77de738 | 17509 | @opindex fsanitize=bounds |
ddf6fe37 | 17510 | @item -fsanitize=bounds |
d77de738 ML |
17511 | This option enables instrumentation of array bounds. Various out of bounds |
17512 | accesses are detected. Flexible array members, flexible array member-like | |
c7728805 JJ |
17513 | arrays, and initializers of variables with static storage are not |
17514 | instrumented, with the exception of flexible array member-like arrays | |
17515 | for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=} | |
17516 | options or @code{strict_flex_array} attributes say they shouldn't be treated | |
17517 | like flexible array member-like arrays. | |
d77de738 | 17518 | |
d77de738 | 17519 | @opindex fsanitize=bounds-strict |
ddf6fe37 | 17520 | @item -fsanitize=bounds-strict |
d77de738 | 17521 | This option enables strict instrumentation of array bounds. Most out of bounds |
c7728805 JJ |
17522 | accesses are detected, including flexible array member-like arrays. |
17523 | Initializers of variables with static storage are not instrumented. | |
d77de738 | 17524 | |
d77de738 | 17525 | @opindex fsanitize=alignment |
ddf6fe37 | 17526 | @item -fsanitize=alignment |
d77de738 ML |
17527 | |
17528 | This option enables checking of alignment of pointers when they are | |
17529 | dereferenced, or when a reference is bound to insufficiently aligned target, | |
17530 | or when a method or constructor is invoked on insufficiently aligned object. | |
17531 | ||
d77de738 | 17532 | @opindex fsanitize=object-size |
ddf6fe37 | 17533 | @item -fsanitize=object-size |
d77de738 | 17534 | This option enables instrumentation of memory references using the |
7283380a SP |
17535 | @code{__builtin_dynamic_object_size} function. Various out of bounds |
17536 | pointer accesses are detected. | |
d77de738 | 17537 | |
d77de738 | 17538 | @opindex fsanitize=float-divide-by-zero |
ddf6fe37 | 17539 | @item -fsanitize=float-divide-by-zero |
d77de738 ML |
17540 | Detect floating-point division by zero. Unlike other similar options, |
17541 | @option{-fsanitize=float-divide-by-zero} is not enabled by | |
17542 | @option{-fsanitize=undefined}, since floating-point division by zero can | |
17543 | be a legitimate way of obtaining infinities and NaNs. | |
17544 | ||
d77de738 | 17545 | @opindex fsanitize=float-cast-overflow |
ddf6fe37 | 17546 | @item -fsanitize=float-cast-overflow |
d77de738 ML |
17547 | This option enables floating-point type to integer conversion checking. |
17548 | We check that the result of the conversion does not overflow. | |
17549 | Unlike other similar options, @option{-fsanitize=float-cast-overflow} is | |
17550 | not enabled by @option{-fsanitize=undefined}. | |
17551 | This option does not work well with @code{FE_INVALID} exceptions enabled. | |
17552 | ||
d77de738 | 17553 | @opindex fsanitize=nonnull-attribute |
ddf6fe37 | 17554 | @item -fsanitize=nonnull-attribute |
d77de738 ML |
17555 | |
17556 | This option enables instrumentation of calls, checking whether null values | |
17557 | are not passed to arguments marked as requiring a non-null value by the | |
17558 | @code{nonnull} function attribute. | |
17559 | ||
d77de738 | 17560 | @opindex fsanitize=returns-nonnull-attribute |
ddf6fe37 | 17561 | @item -fsanitize=returns-nonnull-attribute |
d77de738 ML |
17562 | |
17563 | This option enables instrumentation of return statements in functions | |
17564 | marked with @code{returns_nonnull} function attribute, to detect returning | |
17565 | of null values from such functions. | |
17566 | ||
d77de738 | 17567 | @opindex fsanitize=bool |
ddf6fe37 | 17568 | @item -fsanitize=bool |
d77de738 ML |
17569 | |
17570 | This option enables instrumentation of loads from bool. If a value other | |
17571 | than 0/1 is loaded, a run-time error is issued. | |
17572 | ||
d77de738 | 17573 | @opindex fsanitize=enum |
ddf6fe37 | 17574 | @item -fsanitize=enum |
d77de738 ML |
17575 | |
17576 | This option enables instrumentation of loads from an enum type. If | |
17577 | a value outside the range of values for the enum type is loaded, | |
17578 | a run-time error is issued. | |
17579 | ||
d77de738 | 17580 | @opindex fsanitize=vptr |
ddf6fe37 | 17581 | @item -fsanitize=vptr |
d77de738 ML |
17582 | |
17583 | This option enables instrumentation of C++ member function calls, member | |
17584 | accesses and some conversions between pointers to base and derived classes, | |
17585 | to verify the referenced object has the correct dynamic type. | |
17586 | ||
d77de738 | 17587 | @opindex fsanitize=pointer-overflow |
ddf6fe37 | 17588 | @item -fsanitize=pointer-overflow |
d77de738 ML |
17589 | |
17590 | This option enables instrumentation of pointer arithmetics. If the pointer | |
17591 | arithmetics overflows, a run-time error is issued. | |
17592 | ||
d77de738 | 17593 | @opindex fsanitize=builtin |
ddf6fe37 | 17594 | @item -fsanitize=builtin |
d77de738 ML |
17595 | |
17596 | This option enables instrumentation of arguments to selected builtin | |
17597 | functions. If an invalid value is passed to such arguments, a run-time | |
17598 | error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz} | |
17599 | or @code{__builtin_clz} invokes undefined behavior and is diagnosed | |
17600 | by this option. | |
17601 | ||
17602 | @end table | |
17603 | ||
17604 | Note that sanitizers tend to increase the rate of false positive | |
17605 | warnings, most notably those around @option{-Wmaybe-uninitialized}. | |
17606 | We recommend against combining @option{-Werror} and [the use of] | |
17607 | sanitizers. | |
17608 | ||
17609 | While @option{-ftrapv} causes traps for signed overflows to be emitted, | |
17610 | @option{-fsanitize=undefined} gives a diagnostic message. | |
17611 | This currently works only for the C family of languages. | |
17612 | ||
d77de738 | 17613 | @opindex fno-sanitize=all |
ddf6fe37 | 17614 | @item -fno-sanitize=all |
d77de738 ML |
17615 | |
17616 | This option disables all previously enabled sanitizers. | |
17617 | @option{-fsanitize=all} is not allowed, as some sanitizers cannot be used | |
17618 | together. | |
17619 | ||
d77de738 | 17620 | @opindex fasan-shadow-offset |
ddf6fe37 | 17621 | @item -fasan-shadow-offset=@var{number} |
d77de738 ML |
17622 | This option forces GCC to use custom shadow offset in AddressSanitizer checks. |
17623 | It is useful for experimenting with different shadow memory layouts in | |
17624 | Kernel AddressSanitizer. | |
17625 | ||
d77de738 | 17626 | @opindex fsanitize-sections |
ddf6fe37 | 17627 | @item -fsanitize-sections=@var{s1},@var{s2},... |
d77de738 ML |
17628 | Sanitize global variables in selected user-defined sections. @var{si} may |
17629 | contain wildcards. | |
17630 | ||
d77de738 ML |
17631 | @opindex fsanitize-recover |
17632 | @opindex fno-sanitize-recover | |
ddf6fe37 | 17633 | @item -fsanitize-recover@r{[}=@var{opts}@r{]} |
d77de738 ML |
17634 | @option{-fsanitize-recover=} controls error recovery mode for sanitizers |
17635 | mentioned in comma-separated list of @var{opts}. Enabling this option | |
17636 | for a sanitizer component causes it to attempt to continue | |
17637 | running the program as if no error happened. This means multiple | |
17638 | runtime errors can be reported in a single program run, and the exit | |
17639 | code of the program may indicate success even when errors | |
17640 | have been reported. The @option{-fno-sanitize-recover=} option | |
17641 | can be used to alter | |
17642 | this behavior: only the first detected error is reported | |
17643 | and program then exits with a non-zero exit code. | |
17644 | ||
17645 | Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions | |
17646 | except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}), | |
17647 | @option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero}, | |
17648 | @option{-fsanitize=bounds-strict}, | |
17649 | @option{-fsanitize=kernel-address} and @option{-fsanitize=address}. | |
17650 | For these sanitizers error recovery is turned on by default, | |
17651 | except @option{-fsanitize=address}, for which this feature is experimental. | |
17652 | @option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also | |
17653 | accepted, the former enables recovery for all sanitizers that support it, | |
17654 | the latter disables recovery for all sanitizers that support it. | |
17655 | ||
17656 | Even if a recovery mode is turned on the compiler side, it needs to be also | |
17657 | enabled on the runtime library side, otherwise the failures are still fatal. | |
17658 | The runtime library defaults to @code{halt_on_error=0} for | |
17659 | ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for | |
17660 | AddressSanitizer is @code{halt_on_error=1}. This can be overridden through | |
17661 | setting the @code{halt_on_error} flag in the corresponding environment variable. | |
17662 | ||
17663 | Syntax without an explicit @var{opts} parameter is deprecated. It is | |
17664 | equivalent to specifying an @var{opts} list of: | |
17665 | ||
17666 | @smallexample | |
17667 | undefined,float-cast-overflow,float-divide-by-zero,bounds-strict | |
17668 | @end smallexample | |
17669 | ||
d77de738 | 17670 | @opindex fsanitize-address-use-after-scope |
ddf6fe37 | 17671 | @item -fsanitize-address-use-after-scope |
d77de738 ML |
17672 | Enable sanitization of local variables to detect use-after-scope bugs. |
17673 | The option sets @option{-fstack-reuse} to @samp{none}. | |
17674 | ||
d77de738 ML |
17675 | @opindex fsanitize-trap |
17676 | @opindex fno-sanitize-trap | |
ddf6fe37 | 17677 | @item -fsanitize-trap@r{[}=@var{opts}@r{]} |
d77de738 ML |
17678 | The @option{-fsanitize-trap=} option instructs the compiler to |
17679 | report for sanitizers mentioned in comma-separated list of @var{opts} | |
17680 | undefined behavior using @code{__builtin_trap} rather than a @code{libubsan} | |
17681 | library routine. If this option is enabled for certain sanitizer, | |
17682 | it takes precedence over the @option{-fsanitizer-recover=} for that | |
17683 | sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless | |
17684 | of whether recovery is enabled or disabled using @option{-fsanitize-recover=}. | |
17685 | ||
17686 | The advantage of this is that the @code{libubsan} library is not needed | |
17687 | and is not linked in, so this is usable even in freestanding environments. | |
17688 | ||
17689 | Currently this feature works with @option{-fsanitize=undefined} (and its suboptions | |
17690 | except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow}, | |
17691 | @option{-fsanitize=float-divide-by-zero} and | |
17692 | @option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also | |
17693 | specified, which enables it for @code{undefined} suboptions, | |
17694 | @option{-fsanitize=float-cast-overflow}, | |
17695 | @option{-fsanitize=float-divide-by-zero} and | |
17696 | @option{-fsanitize=bounds-strict}. | |
17697 | If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used | |
17698 | and @code{-fsanitize=vptr} is enabled on the command line, the | |
17699 | instrumentation is silently ignored as the instrumentation always needs | |
17700 | @code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed. | |
17701 | ||
d77de738 | 17702 | @opindex fsanitize-undefined-trap-on-error |
ddf6fe37 | 17703 | @item -fsanitize-undefined-trap-on-error |
d77de738 ML |
17704 | The @option{-fsanitize-undefined-trap-on-error} option is deprecated |
17705 | equivalent of @option{-fsanitize-trap=all}. | |
17706 | ||
d77de738 | 17707 | @opindex fsanitize-coverage=trace-pc |
ddf6fe37 | 17708 | @item -fsanitize-coverage=trace-pc |
d77de738 ML |
17709 | Enable coverage-guided fuzzing code instrumentation. |
17710 | Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block. | |
17711 | ||
d77de738 | 17712 | @opindex fsanitize-coverage=trace-cmp |
ddf6fe37 | 17713 | @item -fsanitize-coverage=trace-cmp |
d77de738 ML |
17714 | Enable dataflow guided fuzzing code instrumentation. |
17715 | Inserts a call to @code{__sanitizer_cov_trace_cmp1}, | |
17716 | @code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or | |
17717 | @code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands | |
17718 | variable or @code{__sanitizer_cov_trace_const_cmp1}, | |
17719 | @code{__sanitizer_cov_trace_const_cmp2}, | |
17720 | @code{__sanitizer_cov_trace_const_cmp4} or | |
17721 | @code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one | |
17722 | operand constant, @code{__sanitizer_cov_trace_cmpf} or | |
17723 | @code{__sanitizer_cov_trace_cmpd} for float or double comparisons and | |
17724 | @code{__sanitizer_cov_trace_switch} for switch statements. | |
17725 | ||
d77de738 | 17726 | @opindex fcf-protection |
ddf6fe37 | 17727 | @item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} |
d77de738 ML |
17728 | Enable code instrumentation of control-flow transfers to increase |
17729 | program security by checking that target addresses of control-flow | |
17730 | transfer instructions (such as indirect function call, function return, | |
17731 | indirect jump) are valid. This prevents diverting the flow of control | |
17732 | to an unexpected target. This is intended to protect against such | |
17733 | threats as Return-oriented Programming (ROP), and similarly | |
17734 | call/jmp-oriented programming (COP/JOP). | |
17735 | ||
17736 | The value @code{branch} tells the compiler to implement checking of | |
17737 | validity of control-flow transfer at the point of indirect branch | |
17738 | instructions, i.e.@: call/jmp instructions. The value @code{return} | |
17739 | implements checking of validity at the point of returning from a | |
17740 | function. The value @code{full} is an alias for specifying both | |
17741 | @code{branch} and @code{return}. The value @code{none} turns off | |
17742 | instrumentation. | |
17743 | ||
75ed4655 | 17744 | To override @option{-fcf-protection}, @option{-fcf-protection=none} |
17745 | needs to be added and then with @option{-fcf-protection=xxx}. | |
17746 | ||
d77de738 ML |
17747 | The value @code{check} is used for the final link with link-time |
17748 | optimization (LTO). An error is issued if LTO object files are | |
17749 | compiled with different @option{-fcf-protection} values. The | |
17750 | value @code{check} is ignored at the compile time. | |
17751 | ||
17752 | The macro @code{__CET__} is defined when @option{-fcf-protection} is | |
17753 | used. The first bit of @code{__CET__} is set to 1 for the value | |
17754 | @code{branch} and the second bit of @code{__CET__} is set to 1 for | |
17755 | the @code{return}. | |
17756 | ||
17757 | You can also use the @code{nocf_check} attribute to identify | |
17758 | which functions and calls should be skipped from instrumentation | |
17759 | (@pxref{Function Attributes}). | |
17760 | ||
17761 | Currently the x86 GNU/Linux target provides an implementation based | |
17762 | on Intel Control-flow Enforcement Technology (CET) which works for | |
17763 | i686 processor or newer. | |
17764 | ||
d77de738 | 17765 | @opindex fharden-compares |
ddf6fe37 | 17766 | @item -fharden-compares |
d77de738 ML |
17767 | For every logical test that survives gimple optimizations and is |
17768 | @emph{not} the condition in a conditional branch (for example, | |
17769 | conditions tested for conditional moves, or to store in boolean | |
17770 | variables), emit extra code to compute and verify the reversed | |
17771 | condition, and to call @code{__builtin_trap} if the results do not | |
17772 | match. Use with @samp{-fharden-conditional-branches} to cover all | |
17773 | conditionals. | |
17774 | ||
d77de738 | 17775 | @opindex fharden-conditional-branches |
ddf6fe37 | 17776 | @item -fharden-conditional-branches |
d77de738 ML |
17777 | For every non-vectorized conditional branch that survives gimple |
17778 | optimizations, emit extra code to compute and verify the reversed | |
17779 | condition, and to call @code{__builtin_trap} if the result is | |
17780 | unexpected. Use with @samp{-fharden-compares} to cover all | |
17781 | conditionals. | |
17782 | ||
551935d1 AO |
17783 | @opindex fharden-control-flow-redundancy |
17784 | @item -fharden-control-flow-redundancy | |
17785 | Emit extra code to set booleans when entering basic blocks, and to | |
17786 | verify and trap, at function exits, when the booleans do not form an | |
17787 | execution path that is compatible with the control flow graph. | |
17788 | ||
17789 | Verification takes place before returns, before mandatory tail calls | |
17790 | (see below) and, optionally, before escaping exceptions with | |
17791 | @option{-fhardcfr-check-exceptions}, before returning calls with | |
17792 | @option{-fhardcfr-check-returning-calls}, and before noreturn calls with | |
17793 | @option{-fhardcfr-check-noreturn-calls}). Tuning options | |
17794 | @option{--param hardcfr-max-blocks} and @option{--param | |
17795 | hardcfr-max-inline-blocks} are available. | |
17796 | ||
17797 | Tail call optimization takes place too late to affect control flow | |
17798 | redundancy, but calls annotated as mandatory tail calls by language | |
17799 | front-ends, and any calls marked early enough as potential tail calls | |
17800 | would also have verification issued before the call, but these | |
17801 | possibilities are merely theoretical, as these conditions can only be | |
17802 | met when using custom compiler plugins. | |
17803 | ||
17804 | @opindex fhardcfr-skip-leaf | |
17805 | @item -fhardcfr-skip-leaf | |
17806 | Disable @option{-fharden-control-flow-redundancy} in leaf functions. | |
17807 | ||
17808 | @opindex fhardcfr-check-exceptions | |
17809 | @opindex fno-hardcfr-check-exceptions | |
17810 | @item -fhardcfr-check-exceptions | |
17811 | When @option{-fharden-control-flow-redundancy} is active, check the | |
17812 | recorded execution path against the control flow graph at exception | |
17813 | escape points, as if the function body was wrapped with a cleanup | |
17814 | handler that performed the check and reraised. This option is enabled | |
17815 | by default; use @option{-fno-hardcfr-check-exceptions} to disable it. | |
17816 | ||
17817 | @opindex fhardcfr-check-returning-calls | |
17818 | @opindex fno-hardcfr-check-returning-calls | |
17819 | @item -fhardcfr-check-returning-calls | |
17820 | When @option{-fharden-control-flow-redundancy} is active, check the | |
17821 | recorded execution path against the control flow graph before any | |
17822 | function call immediately followed by a return of its result, if any, so | |
17823 | as to not prevent tail-call optimization, whether or not it is | |
17824 | ultimately optimized to a tail call. | |
17825 | ||
17826 | This option is enabled by default whenever sibling call optimizations | |
17827 | are enabled (see @option{-foptimize-sibling-calls}), but it can be | |
17828 | enabled (or disabled, using its negated form) explicitly, regardless of | |
17829 | the optimizations. | |
17830 | ||
17831 | @opindex fhardcfr-check-noreturn-calls | |
17832 | @item -fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]} | |
17833 | When @option{-fharden-control-flow-redundancy} is active, check the | |
17834 | recorded execution path against the control flow graph before | |
17835 | @code{noreturn} calls, either all of them (@option{always}), those that | |
17836 | aren't expected to return control to the caller through an exception | |
17837 | (@option{no-xthrow}, the default), those that may not return control to | |
17838 | the caller through an exception either (@option{nothrow}), or none of | |
17839 | them (@option{never}). | |
17840 | ||
17841 | Checking before a @code{noreturn} function that may return control to | |
17842 | the caller through an exception may cause checking to be performed more | |
17843 | than once, if the exception is caught in the caller, whether by a | |
17844 | handler or a cleanup. When @option{-fhardcfr-check-exceptions} is also | |
17845 | enabled, the compiler will avoid associating a @code{noreturn} call with | |
17846 | the implicitly-added cleanup handler, since it would be redundant with | |
17847 | the check performed before the call, but other handlers or cleanups in | |
17848 | the function, if activated, will modify the recorded execution path and | |
17849 | check it again when another checkpoint is hit. The checkpoint may even | |
17850 | be another @code{noreturn} call, so checking may end up performed | |
17851 | multiple times. | |
17852 | ||
17853 | Various optimizers may cause calls to be marked as @code{noreturn} | |
17854 | and/or @code{nothrow}, even in the absence of the corresponding | |
17855 | attributes, which may affect the placement of checks before calls, as | |
17856 | well as the addition of implicit cleanup handlers for them. This | |
17857 | unpredictability, and the fact that raising and reraising exceptions | |
17858 | frequently amounts to implicitly calling @code{noreturn} functions, have | |
17859 | made @option{no-xthrow} the default setting for this option: it excludes | |
17860 | from the @code{noreturn} treatment only internal functions used to | |
17861 | (re)raise exceptions, that are not affected by these optimizations. | |
17862 | ||
24592abd MP |
17863 | @opindex fhardened |
17864 | @item -fhardened | |
17865 | Enable a set of flags for C and C++ that improve the security of the | |
17866 | generated code without affecting its ABI. The precise flags enabled | |
17867 | may change between major releases of GCC, but are currently: | |
17868 | ||
17869 | @c Keep this in sync with print_help_hardened! | |
17870 | @gccoptlist{ | |
17871 | -D_FORTIFY_SOURCE=3 | |
17872 | -D_GLIBCXX_ASSERTIONS | |
17873 | -ftrivial-auto-var-init=zero | |
17874 | -fPIE -pie -Wl,-z,relro,-z,now | |
17875 | -fstack-protector-strong | |
17876 | -fstack-clash-protection | |
17877 | -fcf-protection=full @r{(x86 GNU/Linux only)} | |
17878 | } | |
17879 | ||
17880 | The list of options enabled by @option{-fhardened} can be generated using | |
17881 | the @option{--help=hardened} option. | |
17882 | ||
17883 | When the system glibc is older than 2.35, @option{-D_FORTIFY_SOURCE=2} | |
17884 | is used instead. | |
17885 | ||
17886 | This option is intended to be used in production builds, not merely | |
17887 | in debug builds. | |
17888 | ||
17889 | Currently, @option{-fhardened} is only supported on GNU/Linux targets. | |
17890 | ||
17891 | @option{-fhardened} only enables a particular option if it wasn't | |
17892 | already specified anywhere on the command line. For instance, | |
17893 | @option{-fhardened} @option{-fstack-protector} will only enable | |
17894 | @option{-fstack-protector}, but not @option{-fstack-protector-strong}. | |
17895 | ||
d77de738 | 17896 | @opindex fstack-protector |
ddf6fe37 | 17897 | @item -fstack-protector |
d77de738 ML |
17898 | Emit extra code to check for buffer overflows, such as stack smashing |
17899 | attacks. This is done by adding a guard variable to functions with | |
17900 | vulnerable objects. This includes functions that call @code{alloca}, and | |
17901 | functions with buffers larger than or equal to 8 bytes. The guards are | |
17902 | initialized when a function is entered and then checked when the function | |
17903 | exits. If a guard check fails, an error message is printed and the program | |
17904 | exits. Only variables that are actually allocated on the stack are | |
17905 | considered, optimized away variables or variables allocated in registers | |
17906 | don't count. | |
17907 | ||
d77de738 | 17908 | @opindex fstack-protector-all |
ddf6fe37 | 17909 | @item -fstack-protector-all |
d77de738 ML |
17910 | Like @option{-fstack-protector} except that all functions are protected. |
17911 | ||
d77de738 | 17912 | @opindex fstack-protector-strong |
ddf6fe37 | 17913 | @item -fstack-protector-strong |
d77de738 ML |
17914 | Like @option{-fstack-protector} but includes additional functions to |
17915 | be protected --- those that have local array definitions, or have | |
17916 | references to local frame addresses. Only variables that are actually | |
17917 | allocated on the stack are considered, optimized away variables or variables | |
17918 | allocated in registers don't count. | |
17919 | ||
d77de738 | 17920 | @opindex fstack-protector-explicit |
ddf6fe37 | 17921 | @item -fstack-protector-explicit |
d77de738 ML |
17922 | Like @option{-fstack-protector} but only protects those functions which |
17923 | have the @code{stack_protect} attribute. | |
17924 | ||
d77de738 | 17925 | @opindex fstack-check |
ddf6fe37 | 17926 | @item -fstack-check |
d77de738 ML |
17927 | Generate code to verify that you do not go beyond the boundary of the |
17928 | stack. You should specify this flag if you are running in an | |
17929 | environment with multiple threads, but you only rarely need to specify it in | |
17930 | a single-threaded environment since stack overflow is automatically | |
17931 | detected on nearly all systems if there is only one stack. | |
17932 | ||
17933 | Note that this switch does not actually cause checking to be done; the | |
17934 | operating system or the language runtime must do that. The switch causes | |
17935 | generation of code to ensure that they see the stack being extended. | |
17936 | ||
17937 | You can additionally specify a string parameter: @samp{no} means no | |
17938 | checking, @samp{generic} means force the use of old-style checking, | |
17939 | @samp{specific} means use the best checking method and is equivalent | |
17940 | to bare @option{-fstack-check}. | |
17941 | ||
17942 | Old-style checking is a generic mechanism that requires no specific | |
17943 | target support in the compiler but comes with the following drawbacks: | |
17944 | ||
17945 | @enumerate | |
17946 | @item | |
17947 | Modified allocation strategy for large objects: they are always | |
17948 | allocated dynamically if their size exceeds a fixed threshold. Note this | |
17949 | may change the semantics of some code. | |
17950 | ||
17951 | @item | |
17952 | Fixed limit on the size of the static frame of functions: when it is | |
17953 | topped by a particular function, stack checking is not reliable and | |
17954 | a warning is issued by the compiler. | |
17955 | ||
17956 | @item | |
17957 | Inefficiency: because of both the modified allocation strategy and the | |
17958 | generic implementation, code performance is hampered. | |
17959 | @end enumerate | |
17960 | ||
17961 | Note that old-style stack checking is also the fallback method for | |
17962 | @samp{specific} if no target support has been added in the compiler. | |
17963 | ||
17964 | @samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion | |
17965 | and stack overflows. @samp{specific} is an excellent choice when compiling | |
17966 | Ada code. It is not generally sufficient to protect against stack-clash | |
17967 | attacks. To protect against those you want @samp{-fstack-clash-protection}. | |
17968 | ||
d77de738 | 17969 | @opindex fstack-clash-protection |
ddf6fe37 | 17970 | @item -fstack-clash-protection |
d77de738 ML |
17971 | Generate code to prevent stack clash style attacks. When this option is |
17972 | enabled, the compiler will only allocate one page of stack space at a time | |
17973 | and each page is accessed immediately after allocation. Thus, it prevents | |
17974 | allocations from jumping over any stack guard page provided by the | |
17975 | operating system. | |
17976 | ||
17977 | Most targets do not fully support stack clash protection. However, on | |
17978 | those targets @option{-fstack-clash-protection} will protect dynamic stack | |
17979 | allocations. @option{-fstack-clash-protection} may also provide limited | |
17980 | protection for static stack allocations if the target supports | |
17981 | @option{-fstack-check=specific}. | |
17982 | ||
d77de738 ML |
17983 | @opindex fstack-limit-register |
17984 | @opindex fstack-limit-symbol | |
17985 | @opindex fno-stack-limit | |
ddf6fe37 AA |
17986 | @item -fstack-limit-register=@var{reg} |
17987 | @itemx -fstack-limit-symbol=@var{sym} | |
17988 | @itemx -fno-stack-limit | |
d77de738 ML |
17989 | Generate code to ensure that the stack does not grow beyond a certain value, |
17990 | either the value of a register or the address of a symbol. If a larger | |
17991 | stack is required, a signal is raised at run time. For most targets, | |
17992 | the signal is raised before the stack overruns the boundary, so | |
17993 | it is possible to catch the signal without taking special precautions. | |
17994 | ||
17995 | For instance, if the stack starts at absolute address @samp{0x80000000} | |
17996 | and grows downwards, you can use the flags | |
17997 | @option{-fstack-limit-symbol=__stack_limit} and | |
17998 | @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit | |
17999 | of 128KB@. Note that this may only work with the GNU linker. | |
18000 | ||
18001 | You can locally override stack limit checking by using the | |
18002 | @code{no_stack_limit} function attribute (@pxref{Function Attributes}). | |
18003 | ||
d77de738 | 18004 | @opindex fsplit-stack |
ddf6fe37 | 18005 | @item -fsplit-stack |
d77de738 ML |
18006 | Generate code to automatically split the stack before it overflows. |
18007 | The resulting program has a discontiguous stack which can only | |
18008 | overflow if the program is unable to allocate any more memory. This | |
18009 | is most useful when running threaded programs, as it is no longer | |
18010 | necessary to calculate a good stack size to use for each thread. This | |
18011 | is currently only implemented for the x86 targets running | |
18012 | GNU/Linux. | |
18013 | ||
18014 | When code compiled with @option{-fsplit-stack} calls code compiled | |
18015 | without @option{-fsplit-stack}, there may not be much stack space | |
18016 | available for the latter code to run. If compiling all code, | |
18017 | including library code, with @option{-fsplit-stack} is not an option, | |
18018 | then the linker can fix up these calls so that the code compiled | |
18019 | without @option{-fsplit-stack} always has a large stack. Support for | |
18020 | this is implemented in the gold linker in GNU binutils release 2.21 | |
18021 | and later. | |
18022 | ||
f0a90c7d AO |
18023 | @opindex -fstrub=disable |
18024 | @item -fstrub=disable | |
18025 | Disable stack scrubbing entirely, ignoring any @code{strub} attributes. | |
18026 | See @xref{Common Type Attributes}. | |
18027 | ||
18028 | @opindex fstrub=strict | |
18029 | @item -fstrub=strict | |
18030 | Functions default to @code{strub} mode @code{disabled}, and apply | |
18031 | @option{strict}ly the restriction that only functions associated with | |
18032 | @code{strub}-@code{callable} modes (@code{at-calls}, @code{callable} and | |
18033 | @code{always_inline} @code{internal}) are @code{callable} by functions | |
18034 | with @code{strub}-enabled modes (@code{at-calls} and @code{internal}). | |
18035 | ||
18036 | @opindex fstrub=relaxed | |
18037 | @item -fstrub=relaxed | |
18038 | Restore the default stack scrub (@code{strub}) setting, namely, | |
18039 | @code{strub} is only enabled as required by @code{strub} attributes | |
18040 | associated with function and data types. @code{Relaxed} means that | |
18041 | strub contexts are only prevented from calling functions explicitly | |
18042 | associated with @code{strub} mode @code{disabled}. This option is only | |
18043 | useful to override other @option{-fstrub=*} options that precede it in | |
18044 | the command line. | |
18045 | ||
18046 | @opindex fstrub=at-calls | |
18047 | @item -fstrub=at-calls | |
18048 | Enable @code{at-calls} @code{strub} mode where viable. The primary use | |
18049 | of this option is for testing. It exercises the @code{strub} machinery | |
18050 | in scenarios strictly local to a translation unit. This @code{strub} | |
18051 | mode modifies function interfaces, so any function that is visible to | |
18052 | other translation units, or that has its address taken, will @emph{not} | |
18053 | be affected by this option. Optimization options may also affect | |
18054 | viability. See the @code{strub} attribute documentation for details on | |
18055 | viability and eligibility requirements. | |
18056 | ||
18057 | @opindex fstrub=internal | |
18058 | @item -fstrub=internal | |
18059 | Enable @code{internal} @code{strub} mode where viable. The primary use | |
18060 | of this option is for testing. This option is intended to exercise | |
18061 | thoroughly parts of the @code{strub} machinery that implement the less | |
18062 | efficient, but interface-preserving @code{strub} mode. Functions that | |
18063 | would not be affected by this option are quite uncommon. | |
18064 | ||
18065 | @opindex fstrub=all | |
18066 | @item -fstrub=all | |
18067 | Enable some @code{strub} mode where viable. When both strub modes are | |
18068 | viable, @code{at-calls} is preferred. @option{-fdump-ipa-strubm} adds | |
18069 | function attributes that tell which mode was selected for each function. | |
18070 | The primary use of this option is for testing, to exercise thoroughly | |
18071 | the @code{strub} machinery. | |
18072 | ||
d77de738 | 18073 | @opindex fvtable-verify |
ddf6fe37 | 18074 | @item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} |
d77de738 ML |
18075 | This option is only available when compiling C++ code. |
18076 | It turns on (or off, if using @option{-fvtable-verify=none}) the security | |
18077 | feature that verifies at run time, for every virtual call, that | |
18078 | the vtable pointer through which the call is made is valid for the type of | |
18079 | the object, and has not been corrupted or overwritten. If an invalid vtable | |
18080 | pointer is detected at run time, an error is reported and execution of the | |
18081 | program is immediately halted. | |
18082 | ||
18083 | This option causes run-time data structures to be built at program startup, | |
18084 | which are used for verifying the vtable pointers. | |
18085 | The options @samp{std} and @samp{preinit} | |
18086 | control the timing of when these data structures are built. In both cases the | |
18087 | data structures are built before execution reaches @code{main}. Using | |
18088 | @option{-fvtable-verify=std} causes the data structures to be built after | |
18089 | shared libraries have been loaded and initialized. | |
18090 | @option{-fvtable-verify=preinit} causes them to be built before shared | |
18091 | libraries have been loaded and initialized. | |
18092 | ||
18093 | If this option appears multiple times in the command line with different | |
18094 | values specified, @samp{none} takes highest priority over both @samp{std} and | |
18095 | @samp{preinit}; @samp{preinit} takes priority over @samp{std}. | |
18096 | ||
d77de738 | 18097 | @opindex fvtv-debug |
ddf6fe37 | 18098 | @item -fvtv-debug |
d77de738 ML |
18099 | When used in conjunction with @option{-fvtable-verify=std} or |
18100 | @option{-fvtable-verify=preinit}, causes debug versions of the | |
18101 | runtime functions for the vtable verification feature to be called. | |
18102 | This flag also causes the compiler to log information about which | |
18103 | vtable pointers it finds for each class. | |
18104 | This information is written to a file named @file{vtv_set_ptr_data.log} | |
18105 | in the directory named by the environment variable @env{VTV_LOGS_DIR} | |
18106 | if that is defined or the current working directory otherwise. | |
18107 | ||
18108 | Note: This feature @emph{appends} data to the log file. If you want a fresh log | |
18109 | file, be sure to delete any existing one. | |
18110 | ||
d77de738 | 18111 | @opindex fvtv-counts |
ddf6fe37 | 18112 | @item -fvtv-counts |
d77de738 ML |
18113 | This is a debugging flag. When used in conjunction with |
18114 | @option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this | |
18115 | causes the compiler to keep track of the total number of virtual calls | |
18116 | it encounters and the number of verifications it inserts. It also | |
18117 | counts the number of calls to certain run-time library functions | |
18118 | that it inserts and logs this information for each compilation unit. | |
18119 | The compiler writes this information to a file named | |
18120 | @file{vtv_count_data.log} in the directory named by the environment | |
18121 | variable @env{VTV_LOGS_DIR} if that is defined or the current working | |
18122 | directory otherwise. It also counts the size of the vtable pointer sets | |
18123 | for each class, and writes this information to @file{vtv_class_set_sizes.log} | |
18124 | in the same directory. | |
18125 | ||
18126 | Note: This feature @emph{appends} data to the log files. To get fresh log | |
18127 | files, be sure to delete any existing ones. | |
18128 | ||
d77de738 | 18129 | @opindex finstrument-functions |
ddf6fe37 | 18130 | @item -finstrument-functions |
d77de738 ML |
18131 | Generate instrumentation calls for entry and exit to functions. Just |
18132 | after function entry and just before function exit, the following | |
18133 | profiling functions are called with the address of the current | |
18134 | function and its call site. (On some platforms, | |
18135 | @code{__builtin_return_address} does not work beyond the current | |
18136 | function, so the call site information may not be available to the | |
18137 | profiling functions otherwise.) | |
18138 | ||
18139 | @smallexample | |
18140 | void __cyg_profile_func_enter (void *this_fn, | |
18141 | void *call_site); | |
18142 | void __cyg_profile_func_exit (void *this_fn, | |
18143 | void *call_site); | |
18144 | @end smallexample | |
18145 | ||
18146 | The first argument is the address of the start of the current function, | |
18147 | which may be looked up exactly in the symbol table. | |
18148 | ||
18149 | This instrumentation is also done for functions expanded inline in other | |
18150 | functions. The profiling calls indicate where, conceptually, the | |
18151 | inline function is entered and exited. This means that addressable | |
18152 | versions of such functions must be available. If all your uses of a | |
18153 | function are expanded inline, this may mean an additional expansion of | |
18154 | code size. If you use @code{extern inline} in your C code, an | |
18155 | addressable version of such functions must be provided. (This is | |
18156 | normally the case anyway, but if you get lucky and the optimizer always | |
18157 | expands the functions inline, you might have gotten away without | |
18158 | providing static copies.) | |
18159 | ||
18160 | A function may be given the attribute @code{no_instrument_function}, in | |
18161 | which case this instrumentation is not done. This can be used, for | |
18162 | example, for the profiling functions listed above, high-priority | |
18163 | interrupt routines, and any functions from which the profiling functions | |
18164 | cannot safely be called (perhaps signal handlers, if the profiling | |
18165 | routines generate output or allocate memory). | |
18166 | @xref{Common Function Attributes}. | |
18167 | ||
9c19597c | 18168 | @opindex finstrument-functions-once |
ddf6fe37 | 18169 | @item -finstrument-functions-once |
d77de738 ML |
18170 | This is similar to @option{-finstrument-functions}, but the profiling |
18171 | functions are called only once per instrumented function, i.e. the first | |
18172 | profiling function is called after the first entry into the instrumented | |
18173 | function and the second profiling function is called before the exit | |
18174 | corresponding to this first entry. | |
18175 | ||
18176 | The definition of @code{once} for the purpose of this option is a little | |
18177 | vague because the implementation is not protected against data races. | |
18178 | As a result, the implementation only guarantees that the profiling | |
18179 | functions are called at @emph{least} once per process and at @emph{most} | |
18180 | once per thread, but the calls are always paired, that is to say, if a | |
18181 | thread calls the first function, then it will call the second function, | |
18182 | unless it never reaches the exit of the instrumented function. | |
18183 | ||
d77de738 | 18184 | @opindex finstrument-functions-exclude-file-list |
ddf6fe37 | 18185 | @item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{} |
d77de738 ML |
18186 | |
18187 | Set the list of functions that are excluded from instrumentation (see | |
18188 | the description of @option{-finstrument-functions}). If the file that | |
18189 | contains a function definition matches with one of @var{file}, then | |
18190 | that function is not instrumented. The match is done on substrings: | |
18191 | if the @var{file} parameter is a substring of the file name, it is | |
18192 | considered to be a match. | |
18193 | ||
18194 | For example: | |
18195 | ||
18196 | @smallexample | |
18197 | -finstrument-functions-exclude-file-list=/bits/stl,include/sys | |
18198 | @end smallexample | |
18199 | ||
18200 | @noindent | |
18201 | excludes any inline function defined in files whose pathnames | |
18202 | contain @file{/bits/stl} or @file{include/sys}. | |
18203 | ||
18204 | If, for some reason, you want to include letter @samp{,} in one of | |
18205 | @var{sym}, write @samp{\,}. For example, | |
18206 | @option{-finstrument-functions-exclude-file-list='\,\,tmp'} | |
18207 | (note the single quote surrounding the option). | |
18208 | ||
d77de738 | 18209 | @opindex finstrument-functions-exclude-function-list |
ddf6fe37 | 18210 | @item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} |
d77de738 ML |
18211 | |
18212 | This is similar to @option{-finstrument-functions-exclude-file-list}, | |
18213 | but this option sets the list of function names to be excluded from | |
18214 | instrumentation. The function name to be matched is its user-visible | |
18215 | name, such as @code{vector<int> blah(const vector<int> &)}, not the | |
18216 | internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The | |
18217 | match is done on substrings: if the @var{sym} parameter is a substring | |
18218 | of the function name, it is considered to be a match. For C99 and C++ | |
18219 | extended identifiers, the function name must be given in UTF-8, not | |
18220 | using universal character names. | |
18221 | ||
d77de738 | 18222 | @opindex fpatchable-function-entry |
ddf6fe37 | 18223 | @item -fpatchable-function-entry=@var{N}[,@var{M}] |
d77de738 ML |
18224 | Generate @var{N} NOPs right at the beginning |
18225 | of each function, with the function entry point before the @var{M}th NOP. | |
18226 | If @var{M} is omitted, it defaults to @code{0} so the | |
18227 | function entry points to the address just at the first NOP. | |
18228 | The NOP instructions reserve extra space which can be used to patch in | |
18229 | any desired instrumentation at run time, provided that the code segment | |
18230 | is writable. The amount of space is controllable indirectly via | |
18231 | the number of NOPs; the NOP instruction used corresponds to the instruction | |
18232 | emitted by the internal GCC back-end interface @code{gen_nop}. This behavior | |
18233 | is target-specific and may also depend on the architecture variant and/or | |
18234 | other compilation options. | |
18235 | ||
18236 | For run-time identification, the starting addresses of these areas, | |
18237 | which correspond to their respective function entries minus @var{M}, | |
18238 | are additionally collected in the @code{__patchable_function_entries} | |
18239 | section of the resulting binary. | |
18240 | ||
18241 | Note that the value of @code{__attribute__ ((patchable_function_entry | |
18242 | (N,M)))} takes precedence over command-line option | |
18243 | @option{-fpatchable-function-entry=N,M}. This can be used to increase | |
18244 | the area size or to remove it completely on a single function. | |
18245 | If @code{N=0}, no pad location is recorded. | |
18246 | ||
18247 | The NOP instructions are inserted at---and maybe before, depending on | |
18248 | @var{M}---the function entry address, even before the prologue. On | |
18249 | PowerPC with the ELFv2 ABI, for a function with dual entry points, | |
18250 | the local entry point is this function entry address. | |
18251 | ||
18252 | The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the | |
18253 | ELFv2 ABI, for a function with dual entry points, the supported values | |
18254 | for @var{M} are 0, 2, 6 and 14. | |
18255 | @end table | |
18256 | ||
18257 | ||
18258 | @node Preprocessor Options | |
18259 | @section Options Controlling the Preprocessor | |
18260 | @cindex preprocessor options | |
18261 | @cindex options, preprocessor | |
18262 | ||
18263 | These options control the C preprocessor, which is run on each C source | |
18264 | file before actual compilation. | |
18265 | ||
18266 | If you use the @option{-E} option, nothing is done except preprocessing. | |
18267 | Some of these options make sense only together with @option{-E} because | |
18268 | they cause the preprocessor output to be unsuitable for actual | |
18269 | compilation. | |
18270 | ||
18271 | In addition to the options listed here, there are a number of options | |
18272 | to control search paths for include files documented in | |
18273 | @ref{Directory Options}. | |
18274 | Options to control preprocessor diagnostics are listed in | |
18275 | @ref{Warning Options}. | |
18276 | ||
18277 | @table @gcctabopt | |
18278 | @include cppopts.texi | |
18279 | ||
d77de738 | 18280 | @opindex Wp |
ddf6fe37 | 18281 | @item -Wp,@var{option} |
d77de738 ML |
18282 | You can use @option{-Wp,@var{option}} to bypass the compiler driver |
18283 | and pass @var{option} directly through to the preprocessor. If | |
18284 | @var{option} contains commas, it is split into multiple options at the | |
18285 | commas. However, many options are modified, translated or interpreted | |
18286 | by the compiler driver before being passed to the preprocessor, and | |
18287 | @option{-Wp} forcibly bypasses this phase. The preprocessor's direct | |
18288 | interface is undocumented and subject to change, so whenever possible | |
18289 | you should avoid using @option{-Wp} and let the driver handle the | |
18290 | options instead. | |
18291 | ||
d77de738 | 18292 | @opindex Xpreprocessor |
ddf6fe37 | 18293 | @item -Xpreprocessor @var{option} |
d77de738 ML |
18294 | Pass @var{option} as an option to the preprocessor. You can use this to |
18295 | supply system-specific preprocessor options that GCC does not | |
18296 | recognize. | |
18297 | ||
18298 | If you want to pass an option that takes an argument, you must use | |
18299 | @option{-Xpreprocessor} twice, once for the option and once for the argument. | |
18300 | ||
d77de738 | 18301 | @opindex no-integrated-cpp |
ddf6fe37 | 18302 | @item -no-integrated-cpp |
d77de738 ML |
18303 | Perform preprocessing as a separate pass before compilation. |
18304 | By default, GCC performs preprocessing as an integrated part of | |
18305 | input tokenization and parsing. | |
18306 | If this option is provided, the appropriate language front end | |
18307 | (@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++, | |
18308 | and Objective-C, respectively) is instead invoked twice, | |
18309 | once for preprocessing only and once for actual compilation | |
18310 | of the preprocessed input. | |
18311 | This option may be useful in conjunction with the @option{-B} or | |
18312 | @option{-wrapper} options to specify an alternate preprocessor or | |
18313 | perform additional processing of the program source between | |
18314 | normal preprocessing and compilation. | |
18315 | ||
d77de738 | 18316 | @opindex flarge-source-files |
ddf6fe37 | 18317 | @item -flarge-source-files |
d77de738 ML |
18318 | Adjust GCC to expect large source files, at the expense of slower |
18319 | compilation and higher memory usage. | |
18320 | ||
18321 | Specifically, GCC normally tracks both column numbers and line numbers | |
18322 | within source files and it normally prints both of these numbers in | |
18323 | diagnostics. However, once it has processed a certain number of source | |
18324 | lines, it stops tracking column numbers and only tracks line numbers. | |
18325 | This means that diagnostics for later lines do not include column numbers. | |
18326 | It also means that options like @option{-Wmisleading-indentation} cease to work | |
18327 | at that point, although the compiler prints a note if this happens. | |
18328 | Passing @option{-flarge-source-files} significantly increases the number | |
18329 | of source lines that GCC can process before it stops tracking columns. | |
18330 | ||
18331 | @end table | |
18332 | ||
18333 | @node Assembler Options | |
18334 | @section Passing Options to the Assembler | |
18335 | ||
18336 | @c prevent bad page break with this line | |
18337 | You can pass options to the assembler. | |
18338 | ||
18339 | @table @gcctabopt | |
d77de738 | 18340 | @opindex Wa |
ddf6fe37 | 18341 | @item -Wa,@var{option} |
d77de738 ML |
18342 | Pass @var{option} as an option to the assembler. If @var{option} |
18343 | contains commas, it is split into multiple options at the commas. | |
18344 | ||
d77de738 | 18345 | @opindex Xassembler |
ddf6fe37 | 18346 | @item -Xassembler @var{option} |
d77de738 ML |
18347 | Pass @var{option} as an option to the assembler. You can use this to |
18348 | supply system-specific assembler options that GCC does not | |
18349 | recognize. | |
18350 | ||
18351 | If you want to pass an option that takes an argument, you must use | |
18352 | @option{-Xassembler} twice, once for the option and once for the argument. | |
18353 | ||
18354 | @end table | |
18355 | ||
18356 | @node Link Options | |
18357 | @section Options for Linking | |
18358 | @cindex link options | |
18359 | @cindex options, linking | |
18360 | ||
18361 | These options come into play when the compiler links object files into | |
18362 | an executable output file. They are meaningless if the compiler is | |
18363 | not doing a link step. | |
18364 | ||
18365 | @table @gcctabopt | |
18366 | @cindex file names | |
18367 | @item @var{object-file-name} | |
18368 | A file name that does not end in a special recognized suffix is | |
18369 | considered to name an object file or library. (Object files are | |
18370 | distinguished from libraries by the linker according to the file | |
18371 | contents.) If linking is done, these object files are used as input | |
18372 | to the linker. | |
18373 | ||
d77de738 ML |
18374 | @opindex c |
18375 | @opindex S | |
18376 | @opindex E | |
ddf6fe37 AA |
18377 | @item -c |
18378 | @itemx -S | |
18379 | @itemx -E | |
d77de738 ML |
18380 | If any of these options is used, then the linker is not run, and |
18381 | object file names should not be used as arguments. @xref{Overall | |
18382 | Options}. | |
18383 | ||
d77de738 | 18384 | @opindex flinker-output |
ddf6fe37 | 18385 | @item -flinker-output=@var{type} |
d77de738 ML |
18386 | This option controls code generation of the link-time optimizer. By |
18387 | default the linker output is automatically determined by the linker | |
18388 | plugin. For debugging the compiler and if incremental linking with a | |
18389 | non-LTO object file is desired, it may be useful to control the type | |
18390 | manually. | |
18391 | ||
18392 | If @var{type} is @samp{exec}, code generation produces a static | |
18393 | binary. In this case @option{-fpic} and @option{-fpie} are both | |
18394 | disabled. | |
18395 | ||
18396 | If @var{type} is @samp{dyn}, code generation produces a shared | |
18397 | library. In this case @option{-fpic} or @option{-fPIC} is preserved, | |
18398 | but not enabled automatically. This allows to build shared libraries | |
18399 | without position-independent code on architectures where this is | |
18400 | possible, i.e.@: on x86. | |
18401 | ||
18402 | If @var{type} is @samp{pie}, code generation produces an @option{-fpie} | |
18403 | executable. This results in similar optimizations as @samp{exec} | |
18404 | except that @option{-fpie} is not disabled if specified at compilation | |
18405 | time. | |
18406 | ||
18407 | If @var{type} is @samp{rel}, the compiler assumes that incremental linking is | |
18408 | done. The sections containing intermediate code for link-time optimization are | |
18409 | merged, pre-optimized, and output to the resulting object file. In addition, if | |
18410 | @option{-ffat-lto-objects} is specified, binary code is produced for future | |
18411 | non-LTO linking. The object file produced by incremental linking is smaller | |
18412 | than a static library produced from the same object files. At link time the | |
18413 | result of incremental linking also loads faster than a static | |
18414 | library assuming that the majority of objects in the library are used. | |
18415 | ||
18416 | Finally @samp{nolto-rel} configures the compiler for incremental linking where | |
18417 | code generation is forced, a final binary is produced, and the intermediate | |
18418 | code for later link-time optimization is stripped. When multiple object files | |
18419 | are linked together the resulting code is better optimized than with | |
18420 | link-time optimizations disabled (for example, cross-module inlining | |
18421 | happens), but most of benefits of whole program optimizations are lost. | |
18422 | ||
18423 | During the incremental link (by @option{-r}) the linker plugin defaults to | |
18424 | @option{rel}. With current interfaces to GNU Binutils it is however not | |
18425 | possible to incrementally link LTO objects and non-LTO objects into a single | |
18426 | mixed object file. If any of object files in incremental link cannot | |
18427 | be used for link-time optimization, the linker plugin issues a warning and | |
18428 | uses @samp{nolto-rel}. To maintain whole program optimization, it is | |
18429 | recommended to link such objects into static library instead. Alternatively it | |
18430 | is possible to use H.J. Lu's binutils with support for mixed objects. | |
18431 | ||
d77de738 | 18432 | @opindex fuse-ld=bfd |
ddf6fe37 | 18433 | @item -fuse-ld=bfd |
d77de738 ML |
18434 | Use the @command{bfd} linker instead of the default linker. |
18435 | ||
d77de738 | 18436 | @opindex fuse-ld=gold |
ddf6fe37 | 18437 | @item -fuse-ld=gold |
d77de738 ML |
18438 | Use the @command{gold} linker instead of the default linker. |
18439 | ||
d77de738 | 18440 | @opindex fuse-ld=lld |
ddf6fe37 | 18441 | @item -fuse-ld=lld |
d77de738 ML |
18442 | Use the LLVM @command{lld} linker instead of the default linker. |
18443 | ||
d77de738 | 18444 | @opindex fuse-ld=mold |
ddf6fe37 | 18445 | @item -fuse-ld=mold |
d77de738 ML |
18446 | Use the Modern Linker (@command{mold}) instead of the default linker. |
18447 | ||
18448 | @cindex Libraries | |
ddf6fe37 | 18449 | @opindex l |
d77de738 ML |
18450 | @item -l@var{library} |
18451 | @itemx -l @var{library} | |
d77de738 ML |
18452 | Search the library named @var{library} when linking. (The second |
18453 | alternative with the library as a separate argument is only for | |
18454 | POSIX compliance and is not recommended.) | |
18455 | ||
18456 | The @option{-l} option is passed directly to the linker by GCC. Refer | |
18457 | to your linker documentation for exact details. The general | |
18458 | description below applies to the GNU linker. | |
18459 | ||
18460 | The linker searches a standard list of directories for the library. | |
18461 | The directories searched include several standard system directories | |
18462 | plus any that you specify with @option{-L}. | |
18463 | ||
18464 | Static libraries are archives of object files, and have file names | |
18465 | like @file{lib@var{library}.a}. Some targets also support shared | |
18466 | libraries, which typically have names like @file{lib@var{library}.so}. | |
18467 | If both static and shared libraries are found, the linker gives | |
18468 | preference to linking with the shared library unless the | |
18469 | @option{-static} option is used. | |
18470 | ||
18471 | It makes a difference where in the command you write this option; the | |
18472 | linker searches and processes libraries and object files in the order they | |
18473 | are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z} | |
18474 | after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers | |
18475 | to functions in @samp{z}, those functions may not be loaded. | |
18476 | ||
d77de738 | 18477 | @opindex lobjc |
ddf6fe37 | 18478 | @item -lobjc |
d77de738 ML |
18479 | You need this special case of the @option{-l} option in order to |
18480 | link an Objective-C or Objective-C++ program. | |
18481 | ||
d77de738 | 18482 | @opindex nostartfiles |
ddf6fe37 | 18483 | @item -nostartfiles |
d77de738 ML |
18484 | Do not use the standard system startup files when linking. |
18485 | The standard system libraries are used normally, unless @option{-nostdlib}, | |
18486 | @option{-nolibc}, or @option{-nodefaultlibs} is used. | |
18487 | ||
d77de738 | 18488 | @opindex nodefaultlibs |
ddf6fe37 | 18489 | @item -nodefaultlibs |
d77de738 ML |
18490 | Do not use the standard system libraries when linking. |
18491 | Only the libraries you specify are passed to the linker, and options | |
18492 | specifying linkage of the system libraries, such as @option{-static-libgcc} | |
18493 | or @option{-shared-libgcc}, are ignored. | |
18494 | The standard startup files are used normally, unless @option{-nostartfiles} | |
18495 | is used. | |
18496 | ||
18497 | The compiler may generate calls to @code{memcmp}, | |
18498 | @code{memset}, @code{memcpy} and @code{memmove}. | |
18499 | These entries are usually resolved by entries in | |
18500 | libc. These entry points should be supplied through some other | |
18501 | mechanism when this option is specified. | |
18502 | ||
d77de738 | 18503 | @opindex nolibc |
ddf6fe37 | 18504 | @item -nolibc |
d77de738 ML |
18505 | Do not use the C library or system libraries tightly coupled with it when |
18506 | linking. Still link with the startup files, @file{libgcc} or toolchain | |
18507 | provided language support libraries such as @file{libgnat}, @file{libgfortran} | |
18508 | or @file{libstdc++} unless options preventing their inclusion are used as | |
18509 | well. This typically removes @option{-lc} from the link command line, as well | |
18510 | as system libraries that normally go with it and become meaningless when | |
18511 | absence of a C library is assumed, for example @option{-lpthread} or | |
18512 | @option{-lm} in some configurations. This is intended for bare-board | |
18513 | targets when there is indeed no C library available. | |
18514 | ||
d77de738 | 18515 | @opindex nostdlib |
ddf6fe37 | 18516 | @item -nostdlib |
d77de738 ML |
18517 | Do not use the standard system startup files or libraries when linking. |
18518 | No startup files and only the libraries you specify are passed to | |
18519 | the linker, and options specifying linkage of the system libraries, such as | |
18520 | @option{-static-libgcc} or @option{-shared-libgcc}, are ignored. | |
18521 | ||
18522 | The compiler may generate calls to @code{memcmp}, @code{memset}, | |
18523 | @code{memcpy} and @code{memmove}. | |
18524 | These entries are usually resolved by entries in | |
18525 | libc. These entry points should be supplied through some other | |
18526 | mechanism when this option is specified. | |
18527 | ||
18528 | @cindex @option{-lgcc}, use with @option{-nostdlib} | |
18529 | @cindex @option{-nostdlib} and unresolved references | |
18530 | @cindex unresolved references and @option{-nostdlib} | |
18531 | @cindex @option{-lgcc}, use with @option{-nodefaultlibs} | |
18532 | @cindex @option{-nodefaultlibs} and unresolved references | |
18533 | @cindex unresolved references and @option{-nodefaultlibs} | |
18534 | One of the standard libraries bypassed by @option{-nostdlib} and | |
18535 | @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines | |
18536 | which GCC uses to overcome shortcomings of particular machines, or special | |
18537 | needs for some languages. | |
18538 | (@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler | |
18539 | Collection (GCC) Internals}, | |
18540 | for more discussion of @file{libgcc.a}.) | |
18541 | In most cases, you need @file{libgcc.a} even when you want to avoid | |
18542 | other standard libraries. In other words, when you specify @option{-nostdlib} | |
18543 | or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well. | |
18544 | This ensures that you have no unresolved references to internal GCC | |
18545 | library subroutines. | |
18546 | (An example of such an internal subroutine is @code{__main}, used to ensure C++ | |
18547 | constructors are called; @pxref{Collect2,,@code{collect2}, gccint, | |
18548 | GNU Compiler Collection (GCC) Internals}.) | |
18549 | ||
d77de738 | 18550 | @opindex nostdlib++ |
ddf6fe37 | 18551 | @item -nostdlib++ |
d77de738 ML |
18552 | Do not implicitly link with standard C++ libraries. |
18553 | ||
d77de738 ML |
18554 | @opindex e |
18555 | @opindex entry | |
ddf6fe37 AA |
18556 | @item -e @var{entry} |
18557 | @itemx --entry=@var{entry} | |
d77de738 ML |
18558 | |
18559 | Specify that the program entry point is @var{entry}. The argument is | |
18560 | interpreted by the linker; the GNU linker accepts either a symbol name | |
18561 | or an address. | |
18562 | ||
d77de738 | 18563 | @opindex pie |
ddf6fe37 | 18564 | @item -pie |
d77de738 ML |
18565 | Produce a dynamically linked position independent executable on targets |
18566 | that support it. For predictable results, you must also specify the same | |
18567 | set of options used for compilation (@option{-fpie}, @option{-fPIE}, | |
18568 | or model suboptions) when you specify this linker option. | |
18569 | ||
d77de738 | 18570 | @opindex no-pie |
ddf6fe37 | 18571 | @item -no-pie |
d77de738 ML |
18572 | Don't produce a dynamically linked position independent executable. |
18573 | ||
d77de738 | 18574 | @opindex static-pie |
ddf6fe37 | 18575 | @item -static-pie |
d77de738 ML |
18576 | Produce a static position independent executable on targets that support |
18577 | it. A static position independent executable is similar to a static | |
18578 | executable, but can be loaded at any address without a dynamic linker. | |
18579 | For predictable results, you must also specify the same set of options | |
18580 | used for compilation (@option{-fpie}, @option{-fPIE}, or model | |
18581 | suboptions) when you specify this linker option. | |
18582 | ||
d77de738 | 18583 | @opindex pthread |
ddf6fe37 | 18584 | @item -pthread |
d77de738 ML |
18585 | Link with the POSIX threads library. This option is supported on |
18586 | GNU/Linux targets, most other Unix derivatives, and also on | |
18587 | x86 Cygwin and MinGW targets. On some targets this option also sets | |
18588 | flags for the preprocessor, so it should be used consistently for both | |
18589 | compilation and linking. | |
18590 | ||
d77de738 | 18591 | @opindex r |
ddf6fe37 | 18592 | @item -r |
d77de738 ML |
18593 | Produce a relocatable object as output. This is also known as partial |
18594 | linking. | |
18595 | ||
d77de738 | 18596 | @opindex rdynamic |
ddf6fe37 | 18597 | @item -rdynamic |
d77de738 ML |
18598 | Pass the flag @option{-export-dynamic} to the ELF linker, on targets |
18599 | that support it. This instructs the linker to add all symbols, not | |
18600 | only used ones, to the dynamic symbol table. This option is needed | |
18601 | for some uses of @code{dlopen} or to allow obtaining backtraces | |
18602 | from within a program. | |
18603 | ||
d77de738 | 18604 | @opindex s |
ddf6fe37 | 18605 | @item -s |
d77de738 ML |
18606 | Remove all symbol table and relocation information from the executable. |
18607 | ||
d77de738 | 18608 | @opindex static |
ddf6fe37 | 18609 | @item -static |
d77de738 ML |
18610 | On systems that support dynamic linking, this overrides @option{-pie} |
18611 | and prevents linking with the shared libraries. On other systems, this | |
18612 | option has no effect. | |
18613 | ||
d77de738 | 18614 | @opindex shared |
ddf6fe37 | 18615 | @item -shared |
d77de738 ML |
18616 | Produce a shared object which can then be linked with other objects to |
18617 | form an executable. Not all systems support this option. For predictable | |
18618 | results, you must also specify the same set of options used for compilation | |
18619 | (@option{-fpic}, @option{-fPIC}, or model suboptions) when | |
18620 | you specify this linker option.@footnote{On some systems, @samp{gcc -shared} | |
18621 | needs to build supplementary stub code for constructors to work. On | |
18622 | multi-libbed systems, @samp{gcc -shared} must select the correct support | |
18623 | libraries to link against. Failing to supply the correct flags may lead | |
18624 | to subtle defects. Supplying them in cases where they are not necessary | |
b799acef RB |
18625 | is innocuous. @option{-shared} suppresses the addition of startup code |
18626 | to alter the floating-point environment as done with @option{-ffast-math}, | |
18627 | @option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.} | |
d77de738 | 18628 | |
d77de738 ML |
18629 | @opindex shared-libgcc |
18630 | @opindex static-libgcc | |
ddf6fe37 AA |
18631 | @item -shared-libgcc |
18632 | @itemx -static-libgcc | |
d77de738 ML |
18633 | On systems that provide @file{libgcc} as a shared library, these options |
18634 | force the use of either the shared or static version, respectively. | |
18635 | If no shared version of @file{libgcc} was built when the compiler was | |
18636 | configured, these options have no effect. | |
18637 | ||
18638 | There are several situations in which an application should use the | |
18639 | shared @file{libgcc} instead of the static version. The most common | |
18640 | of these is when the application wishes to throw and catch exceptions | |
18641 | across different shared libraries. In that case, each of the libraries | |
18642 | as well as the application itself should use the shared @file{libgcc}. | |
18643 | ||
18644 | Therefore, the G++ driver automatically adds @option{-shared-libgcc} | |
18645 | whenever you build a shared library or a main executable, because C++ | |
18646 | programs typically use exceptions, so this is the right thing to do. | |
18647 | ||
18648 | If, instead, you use the GCC driver to create shared libraries, you may | |
18649 | find that they are not always linked with the shared @file{libgcc}. | |
18650 | If GCC finds, at its configuration time, that you have a non-GNU linker | |
18651 | or a GNU linker that does not support option @option{--eh-frame-hdr}, | |
18652 | it links the shared version of @file{libgcc} into shared libraries | |
18653 | by default. Otherwise, it takes advantage of the linker and optimizes | |
18654 | away the linking with the shared version of @file{libgcc}, linking with | |
18655 | the static version of libgcc by default. This allows exceptions to | |
18656 | propagate through such shared libraries, without incurring relocation | |
18657 | costs at library load time. | |
18658 | ||
18659 | However, if a library or main executable is supposed to throw or catch | |
18660 | exceptions, you must link it using the G++ driver, or using the option | |
18661 | @option{-shared-libgcc}, such that it is linked with the shared | |
18662 | @file{libgcc}. | |
18663 | ||
d77de738 | 18664 | @opindex static-libasan |
ddf6fe37 | 18665 | @item -static-libasan |
d77de738 ML |
18666 | When the @option{-fsanitize=address} option is used to link a program, |
18667 | the GCC driver automatically links against @option{libasan}. If | |
18668 | @file{libasan} is available as a shared library, and the @option{-static} | |
18669 | option is not used, then this links against the shared version of | |
18670 | @file{libasan}. The @option{-static-libasan} option directs the GCC | |
18671 | driver to link @file{libasan} statically, without necessarily linking | |
18672 | other libraries statically. | |
18673 | ||
d77de738 | 18674 | @opindex static-libtsan |
ddf6fe37 | 18675 | @item -static-libtsan |
d77de738 ML |
18676 | When the @option{-fsanitize=thread} option is used to link a program, |
18677 | the GCC driver automatically links against @option{libtsan}. If | |
18678 | @file{libtsan} is available as a shared library, and the @option{-static} | |
18679 | option is not used, then this links against the shared version of | |
18680 | @file{libtsan}. The @option{-static-libtsan} option directs the GCC | |
18681 | driver to link @file{libtsan} statically, without necessarily linking | |
18682 | other libraries statically. | |
18683 | ||
d77de738 | 18684 | @opindex static-liblsan |
ddf6fe37 | 18685 | @item -static-liblsan |
d77de738 ML |
18686 | When the @option{-fsanitize=leak} option is used to link a program, |
18687 | the GCC driver automatically links against @option{liblsan}. If | |
18688 | @file{liblsan} is available as a shared library, and the @option{-static} | |
18689 | option is not used, then this links against the shared version of | |
18690 | @file{liblsan}. The @option{-static-liblsan} option directs the GCC | |
18691 | driver to link @file{liblsan} statically, without necessarily linking | |
18692 | other libraries statically. | |
18693 | ||
d77de738 | 18694 | @opindex static-libubsan |
ddf6fe37 | 18695 | @item -static-libubsan |
d77de738 ML |
18696 | When the @option{-fsanitize=undefined} option is used to link a program, |
18697 | the GCC driver automatically links against @option{libubsan}. If | |
18698 | @file{libubsan} is available as a shared library, and the @option{-static} | |
18699 | option is not used, then this links against the shared version of | |
18700 | @file{libubsan}. The @option{-static-libubsan} option directs the GCC | |
18701 | driver to link @file{libubsan} statically, without necessarily linking | |
18702 | other libraries statically. | |
18703 | ||
d77de738 | 18704 | @opindex static-libstdc++ |
ddf6fe37 | 18705 | @item -static-libstdc++ |
d77de738 ML |
18706 | When the @command{g++} program is used to link a C++ program, it |
18707 | normally automatically links against @option{libstdc++}. If | |
18708 | @file{libstdc++} is available as a shared library, and the | |
18709 | @option{-static} option is not used, then this links against the | |
18710 | shared version of @file{libstdc++}. That is normally fine. However, it | |
18711 | is sometimes useful to freeze the version of @file{libstdc++} used by | |
18712 | the program without going all the way to a fully static link. The | |
18713 | @option{-static-libstdc++} option directs the @command{g++} driver to | |
18714 | link @file{libstdc++} statically, without necessarily linking other | |
18715 | libraries statically. | |
18716 | ||
d77de738 | 18717 | @opindex symbolic |
ddf6fe37 | 18718 | @item -symbolic |
d77de738 ML |
18719 | Bind references to global symbols when building a shared object. Warn |
18720 | about any unresolved references (unless overridden by the link editor | |
18721 | option @option{-Xlinker -z -Xlinker defs}). Only a few systems support | |
18722 | this option. | |
18723 | ||
d77de738 ML |
18724 | @opindex T |
18725 | @cindex linker script | |
f33d7a88 | 18726 | @item -T @var{script} |
d77de738 ML |
18727 | Use @var{script} as the linker script. This option is supported by most |
18728 | systems using the GNU linker. On some targets, such as bare-board | |
18729 | targets without an operating system, the @option{-T} option may be required | |
18730 | when linking to avoid references to undefined symbols. | |
18731 | ||
d77de738 | 18732 | @opindex Xlinker |
ddf6fe37 | 18733 | @item -Xlinker @var{option} |
d77de738 ML |
18734 | Pass @var{option} as an option to the linker. You can use this to |
18735 | supply system-specific linker options that GCC does not recognize. | |
18736 | ||
18737 | If you want to pass an option that takes a separate argument, you must use | |
18738 | @option{-Xlinker} twice, once for the option and once for the argument. | |
18739 | For example, to pass @option{-assert definitions}, you must write | |
18740 | @option{-Xlinker -assert -Xlinker definitions}. It does not work to write | |
18741 | @option{-Xlinker "-assert definitions"}, because this passes the entire | |
18742 | string as a single argument, which is not what the linker expects. | |
18743 | ||
18744 | When using the GNU linker, it is usually more convenient to pass | |
18745 | arguments to linker options using the @option{@var{option}=@var{value}} | |
18746 | syntax than as separate arguments. For example, you can specify | |
18747 | @option{-Xlinker -Map=output.map} rather than | |
18748 | @option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support | |
18749 | this syntax for command-line options. | |
18750 | ||
d77de738 | 18751 | @opindex Wl |
ddf6fe37 | 18752 | @item -Wl,@var{option} |
d77de738 ML |
18753 | Pass @var{option} as an option to the linker. If @var{option} contains |
18754 | commas, it is split into multiple options at the commas. You can use this | |
18755 | syntax to pass an argument to the option. | |
18756 | For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the | |
18757 | linker. When using the GNU linker, you can also get the same effect with | |
18758 | @option{-Wl,-Map=output.map}. | |
18759 | ||
d77de738 | 18760 | @opindex u |
ddf6fe37 | 18761 | @item -u @var{symbol} |
d77de738 ML |
18762 | Pretend the symbol @var{symbol} is undefined, to force linking of |
18763 | library modules to define it. You can use @option{-u} multiple times with | |
18764 | different symbols to force loading of additional library modules. | |
18765 | ||
d77de738 | 18766 | @opindex z |
ddf6fe37 | 18767 | @item -z @var{keyword} |
d77de738 ML |
18768 | @option{-z} is passed directly on to the linker along with the keyword |
18769 | @var{keyword}. See the section in the documentation of your linker for | |
18770 | permitted values and their meanings. | |
18771 | @end table | |
18772 | ||
18773 | @node Directory Options | |
18774 | @section Options for Directory Search | |
18775 | @cindex directory options | |
18776 | @cindex options, directory search | |
18777 | @cindex search path | |
18778 | ||
18779 | These options specify directories to search for header files, for | |
18780 | libraries and for parts of the compiler: | |
18781 | ||
18782 | @table @gcctabopt | |
18783 | @include cppdiropts.texi | |
18784 | ||
d77de738 | 18785 | @opindex iplugindir= |
ddf6fe37 | 18786 | @item -iplugindir=@var{dir} |
d77de738 ML |
18787 | Set the directory to search for plugins that are passed |
18788 | by @option{-fplugin=@var{name}} instead of | |
18789 | @option{-fplugin=@var{path}/@var{name}.so}. This option is not meant | |
18790 | to be used by the user, but only passed by the driver. | |
18791 | ||
d77de738 | 18792 | @opindex L |
ddf6fe37 | 18793 | @item -L@var{dir} |
d77de738 ML |
18794 | Add directory @var{dir} to the list of directories to be searched |
18795 | for @option{-l}. | |
18796 | ||
d77de738 | 18797 | @opindex B |
ddf6fe37 | 18798 | @item -B@var{prefix} |
d77de738 ML |
18799 | This option specifies where to find the executables, libraries, |
18800 | include files, and data files of the compiler itself. | |
18801 | ||
18802 | The compiler driver program runs one or more of the subprograms | |
18803 | @command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries | |
18804 | @var{prefix} as a prefix for each program it tries to run, both with and | |
18805 | without @samp{@var{machine}/@var{version}/} for the corresponding target | |
18806 | machine and compiler version. | |
18807 | ||
18808 | For each subprogram to be run, the compiler driver first tries the | |
18809 | @option{-B} prefix, if any. If that name is not found, or if @option{-B} | |
18810 | is not specified, the driver tries two standard prefixes, | |
18811 | @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of | |
18812 | those results in a file name that is found, the unmodified program | |
18813 | name is searched for using the directories specified in your | |
18814 | @env{PATH} environment variable. | |
18815 | ||
18816 | The compiler checks to see if the path provided by @option{-B} | |
18817 | refers to a directory, and if necessary it adds a directory | |
18818 | separator character at the end of the path. | |
18819 | ||
18820 | @option{-B} prefixes that effectively specify directory names also apply | |
18821 | to libraries in the linker, because the compiler translates these | |
18822 | options into @option{-L} options for the linker. They also apply to | |
18823 | include files in the preprocessor, because the compiler translates these | |
18824 | options into @option{-isystem} options for the preprocessor. In this case, | |
18825 | the compiler appends @samp{include} to the prefix. | |
18826 | ||
18827 | The runtime support file @file{libgcc.a} can also be searched for using | |
18828 | the @option{-B} prefix, if needed. If it is not found there, the two | |
18829 | standard prefixes above are tried, and that is all. The file is left | |
18830 | out of the link if it is not found by those means. | |
18831 | ||
18832 | Another way to specify a prefix much like the @option{-B} prefix is to use | |
18833 | the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment | |
18834 | Variables}. | |
18835 | ||
18836 | As a special kludge, if the path provided by @option{-B} is | |
18837 | @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to | |
18838 | 9, then it is replaced by @file{[dir/]include}. This is to help | |
18839 | with boot-strapping the compiler. | |
18840 | ||
d77de738 | 18841 | @opindex no-canonical-prefixes |
ddf6fe37 | 18842 | @item -no-canonical-prefixes |
d77de738 ML |
18843 | Do not expand any symbolic links, resolve references to @samp{/../} |
18844 | or @samp{/./}, or make the path absolute when generating a relative | |
18845 | prefix. | |
18846 | ||
d77de738 | 18847 | @opindex sysroot |
ddf6fe37 | 18848 | @item --sysroot=@var{dir} |
d77de738 ML |
18849 | Use @var{dir} as the logical root directory for headers and libraries. |
18850 | For example, if the compiler normally searches for headers in | |
18851 | @file{/usr/include} and libraries in @file{/usr/lib}, it instead | |
18852 | searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}. | |
18853 | ||
18854 | If you use both this option and the @option{-isysroot} option, then | |
18855 | the @option{--sysroot} option applies to libraries, but the | |
18856 | @option{-isysroot} option applies to header files. | |
18857 | ||
18858 | The GNU linker (beginning with version 2.16) has the necessary support | |
18859 | for this option. If your linker does not support this option, the | |
18860 | header file aspect of @option{--sysroot} still works, but the | |
18861 | library aspect does not. | |
18862 | ||
d77de738 | 18863 | @opindex no-sysroot-suffix |
ddf6fe37 | 18864 | @item --no-sysroot-suffix |
d77de738 ML |
18865 | For some targets, a suffix is added to the root directory specified |
18866 | with @option{--sysroot}, depending on the other options used, so that | |
18867 | headers may for example be found in | |
18868 | @file{@var{dir}/@var{suffix}/usr/include} instead of | |
18869 | @file{@var{dir}/usr/include}. This option disables the addition of | |
18870 | such a suffix. | |
18871 | ||
18872 | @end table | |
18873 | ||
18874 | @node Code Gen Options | |
18875 | @section Options for Code Generation Conventions | |
18876 | @cindex code generation conventions | |
18877 | @cindex options, code generation | |
18878 | @cindex run-time options | |
18879 | ||
18880 | These machine-independent options control the interface conventions | |
18881 | used in code generation. | |
18882 | ||
18883 | Most of them have both positive and negative forms; the negative form | |
18884 | of @option{-ffoo} is @option{-fno-foo}. In the table below, only | |
18885 | one of the forms is listed---the one that is not the default. You | |
18886 | can figure out the other form by either removing @samp{no-} or adding | |
18887 | it. | |
18888 | ||
18889 | @table @gcctabopt | |
d77de738 | 18890 | @opindex fstack_reuse |
ddf6fe37 | 18891 | @item -fstack-reuse=@var{reuse-level} |
d77de738 ML |
18892 | This option controls stack space reuse for user declared local/auto variables |
18893 | and compiler generated temporaries. @var{reuse_level} can be @samp{all}, | |
18894 | @samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all | |
18895 | local variables and temporaries, @samp{named_vars} enables the reuse only for | |
18896 | user defined local variables with names, and @samp{none} disables stack reuse | |
18897 | completely. The default value is @samp{all}. The option is needed when the | |
18898 | program extends the lifetime of a scoped local variable or a compiler generated | |
18899 | temporary beyond the end point defined by the language. When a lifetime of | |
18900 | a variable ends, and if the variable lives in memory, the optimizing compiler | |
18901 | has the freedom to reuse its stack space with other temporaries or scoped | |
18902 | local variables whose live range does not overlap with it. Legacy code extending | |
18903 | local lifetime is likely to break with the stack reuse optimization. | |
18904 | ||
18905 | For example, | |
18906 | ||
18907 | @smallexample | |
18908 | int *p; | |
18909 | @{ | |
18910 | int local1; | |
18911 | ||
18912 | p = &local1; | |
18913 | local1 = 10; | |
18914 | .... | |
18915 | @} | |
18916 | @{ | |
18917 | int local2; | |
18918 | local2 = 20; | |
18919 | ... | |
18920 | @} | |
18921 | ||
18922 | if (*p == 10) // out of scope use of local1 | |
18923 | @{ | |
18924 | ||
18925 | @} | |
18926 | @end smallexample | |
18927 | ||
18928 | Another example: | |
18929 | @smallexample | |
18930 | ||
18931 | struct A | |
18932 | @{ | |
18933 | A(int k) : i(k), j(k) @{ @} | |
18934 | int i; | |
18935 | int j; | |
18936 | @}; | |
18937 | ||
18938 | A *ap; | |
18939 | ||
18940 | void foo(const A& ar) | |
18941 | @{ | |
18942 | ap = &ar; | |
18943 | @} | |
18944 | ||
18945 | void bar() | |
18946 | @{ | |
18947 | foo(A(10)); // temp object's lifetime ends when foo returns | |
18948 | ||
18949 | @{ | |
18950 | A a(20); | |
18951 | .... | |
18952 | @} | |
18953 | ap->i+= 10; // ap references out of scope temp whose space | |
18954 | // is reused with a. What is the value of ap->i? | |
18955 | @} | |
18956 | ||
18957 | @end smallexample | |
18958 | ||
18959 | The lifetime of a compiler generated temporary is well defined by the C++ | |
18960 | standard. When a lifetime of a temporary ends, and if the temporary lives | |
18961 | in memory, the optimizing compiler has the freedom to reuse its stack | |
18962 | space with other temporaries or scoped local variables whose live range | |
18963 | does not overlap with it. However some of the legacy code relies on | |
18964 | the behavior of older compilers in which temporaries' stack space is | |
18965 | not reused, the aggressive stack reuse can lead to runtime errors. This | |
18966 | option is used to control the temporary stack reuse optimization. | |
18967 | ||
d77de738 | 18968 | @opindex ftrapv |
ddf6fe37 | 18969 | @item -ftrapv |
d77de738 ML |
18970 | This option generates traps for signed overflow on addition, subtraction, |
18971 | multiplication operations. | |
18972 | The options @option{-ftrapv} and @option{-fwrapv} override each other, so using | |
18973 | @option{-ftrapv} @option{-fwrapv} on the command-line results in | |
18974 | @option{-fwrapv} being effective. Note that only active options override, so | |
18975 | using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line | |
18976 | results in @option{-ftrapv} being effective. | |
18977 | ||
d77de738 | 18978 | @opindex fwrapv |
ddf6fe37 | 18979 | @item -fwrapv |
d77de738 ML |
18980 | This option instructs the compiler to assume that signed arithmetic |
18981 | overflow of addition, subtraction and multiplication wraps around | |
18982 | using twos-complement representation. This flag enables some optimizations | |
18983 | and disables others. | |
18984 | The options @option{-ftrapv} and @option{-fwrapv} override each other, so using | |
18985 | @option{-ftrapv} @option{-fwrapv} on the command-line results in | |
18986 | @option{-fwrapv} being effective. Note that only active options override, so | |
18987 | using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line | |
18988 | results in @option{-ftrapv} being effective. | |
18989 | ||
d77de738 | 18990 | @opindex fwrapv-pointer |
ddf6fe37 | 18991 | @item -fwrapv-pointer |
d77de738 ML |
18992 | This option instructs the compiler to assume that pointer arithmetic |
18993 | overflow on addition and subtraction wraps around using twos-complement | |
18994 | representation. This flag disables some optimizations which assume | |
18995 | pointer overflow is invalid. | |
18996 | ||
d77de738 | 18997 | @opindex fstrict-overflow |
ddf6fe37 | 18998 | @item -fstrict-overflow |
d77de738 ML |
18999 | This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when |
19000 | negated implies @option{-fwrapv} @option{-fwrapv-pointer}. | |
19001 | ||
d77de738 | 19002 | @opindex fexceptions |
ddf6fe37 | 19003 | @item -fexceptions |
d77de738 ML |
19004 | Enable exception handling. Generates extra code needed to propagate |
19005 | exceptions. For some targets, this implies GCC generates frame | |
19006 | unwind information for all functions, which can produce significant data | |
19007 | size overhead, although it does not affect execution. If you do not | |
19008 | specify this option, GCC enables it by default for languages like | |
19009 | C++ that normally require exception handling, and disables it for | |
19010 | languages like C that do not normally require it. However, you may need | |
19011 | to enable this option when compiling C code that needs to interoperate | |
19012 | properly with exception handlers written in C++. You may also wish to | |
19013 | disable this option if you are compiling older C++ programs that don't | |
19014 | use exception handling. | |
19015 | ||
d77de738 | 19016 | @opindex fnon-call-exceptions |
ddf6fe37 | 19017 | @item -fnon-call-exceptions |
d77de738 ML |
19018 | Generate code that allows trapping instructions to throw exceptions. |
19019 | Note that this requires platform-specific runtime support that does | |
19020 | not exist everywhere. Moreover, it only allows @emph{trapping} | |
19021 | instructions to throw exceptions, i.e.@: memory references or floating-point | |
19022 | instructions. It does not allow exceptions to be thrown from | |
19023 | arbitrary signal handlers such as @code{SIGALRM}. This enables | |
19024 | @option{-fexceptions}. | |
19025 | ||
d77de738 | 19026 | @opindex fdelete-dead-exceptions |
ddf6fe37 | 19027 | @item -fdelete-dead-exceptions |
d77de738 ML |
19028 | Consider that instructions that may throw exceptions but don't otherwise |
19029 | contribute to the execution of the program can be optimized away. | |
19030 | This does not affect calls to functions except those with the | |
19031 | @code{pure} or @code{const} attributes. | |
19032 | This option is enabled by default for the Ada and C++ compilers, as permitted by | |
19033 | the language specifications. | |
19034 | Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels. | |
19035 | ||
d77de738 | 19036 | @opindex funwind-tables |
ddf6fe37 | 19037 | @item -funwind-tables |
d77de738 ML |
19038 | Similar to @option{-fexceptions}, except that it just generates any needed |
19039 | static data, but does not affect the generated code in any other way. | |
19040 | You normally do not need to enable this option; instead, a language processor | |
19041 | that needs this handling enables it on your behalf. | |
19042 | ||
d77de738 | 19043 | @opindex fasynchronous-unwind-tables |
ddf6fe37 | 19044 | @item -fasynchronous-unwind-tables |
d77de738 ML |
19045 | Generate unwind table in DWARF format, if supported by target machine. The |
19046 | table is exact at each instruction boundary, so it can be used for stack | |
19047 | unwinding from asynchronous events (such as debugger or garbage collector). | |
19048 | ||
d77de738 ML |
19049 | @opindex fno-gnu-unique |
19050 | @opindex fgnu-unique | |
ddf6fe37 | 19051 | @item -fno-gnu-unique |
d77de738 ML |
19052 | On systems with recent GNU assembler and C library, the C++ compiler |
19053 | uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions | |
19054 | of template static data members and static local variables in inline | |
19055 | functions are unique even in the presence of @code{RTLD_LOCAL}; this | |
19056 | is necessary to avoid problems with a library used by two different | |
19057 | @code{RTLD_LOCAL} plugins depending on a definition in one of them and | |
19058 | therefore disagreeing with the other one about the binding of the | |
19059 | symbol. But this causes @code{dlclose} to be ignored for affected | |
19060 | DSOs; if your program relies on reinitialization of a DSO via | |
19061 | @code{dlclose} and @code{dlopen}, you can use | |
19062 | @option{-fno-gnu-unique}. | |
19063 | ||
d77de738 | 19064 | @opindex fpcc-struct-return |
ddf6fe37 | 19065 | @item -fpcc-struct-return |
d77de738 ML |
19066 | Return ``short'' @code{struct} and @code{union} values in memory like |
19067 | longer ones, rather than in registers. This convention is less | |
19068 | efficient, but it has the advantage of allowing intercallability between | |
19069 | GCC-compiled files and files compiled with other compilers, particularly | |
19070 | the Portable C Compiler (pcc). | |
19071 | ||
19072 | The precise convention for returning structures in memory depends | |
19073 | on the target configuration macros. | |
19074 | ||
19075 | Short structures and unions are those whose size and alignment match | |
19076 | that of some integer type. | |
19077 | ||
19078 | @strong{Warning:} code compiled with the @option{-fpcc-struct-return} | |
19079 | switch is not binary compatible with code compiled with the | |
19080 | @option{-freg-struct-return} switch. | |
19081 | Use it to conform to a non-default application binary interface. | |
19082 | ||
d77de738 | 19083 | @opindex freg-struct-return |
ddf6fe37 | 19084 | @item -freg-struct-return |
d77de738 ML |
19085 | Return @code{struct} and @code{union} values in registers when possible. |
19086 | This is more efficient for small structures than | |
19087 | @option{-fpcc-struct-return}. | |
19088 | ||
19089 | If you specify neither @option{-fpcc-struct-return} nor | |
19090 | @option{-freg-struct-return}, GCC defaults to whichever convention is | |
19091 | standard for the target. If there is no standard convention, GCC | |
19092 | defaults to @option{-fpcc-struct-return}, except on targets where GCC is | |
19093 | the principal compiler. In those cases, we can choose the standard, and | |
19094 | we chose the more efficient register return alternative. | |
19095 | ||
19096 | @strong{Warning:} code compiled with the @option{-freg-struct-return} | |
19097 | switch is not binary compatible with code compiled with the | |
19098 | @option{-fpcc-struct-return} switch. | |
19099 | Use it to conform to a non-default application binary interface. | |
19100 | ||
d77de738 | 19101 | @opindex fshort-enums |
ddf6fe37 | 19102 | @item -fshort-enums |
d77de738 ML |
19103 | Allocate to an @code{enum} type only as many bytes as it needs for the |
19104 | declared range of possible values. Specifically, the @code{enum} type | |
19105 | is equivalent to the smallest integer type that has enough room. | |
d8a656d5 JW |
19106 | This option has no effect for an enumeration type with a fixed underlying |
19107 | type. | |
d77de738 ML |
19108 | |
19109 | @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate | |
19110 | code that is not binary compatible with code generated without that switch. | |
19111 | Use it to conform to a non-default application binary interface. | |
19112 | ||
d77de738 | 19113 | @opindex fshort-wchar |
ddf6fe37 | 19114 | @item -fshort-wchar |
d77de738 ML |
19115 | Override the underlying type for @code{wchar_t} to be @code{short |
19116 | unsigned int} instead of the default for the target. This option is | |
19117 | useful for building programs to run under WINE@. | |
19118 | ||
19119 | @strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate | |
19120 | code that is not binary compatible with code generated without that switch. | |
19121 | Use it to conform to a non-default application binary interface. | |
19122 | ||
d77de738 ML |
19123 | @opindex fcommon |
19124 | @opindex fno-common | |
19125 | @cindex tentative definitions | |
f33d7a88 | 19126 | @item -fcommon |
d77de738 ML |
19127 | In C code, this option controls the placement of global variables |
19128 | defined without an initializer, known as @dfn{tentative definitions} | |
19129 | in the C standard. Tentative definitions are distinct from declarations | |
19130 | of a variable with the @code{extern} keyword, which do not allocate storage. | |
19131 | ||
19132 | The default is @option{-fno-common}, which specifies that the compiler places | |
19133 | uninitialized global variables in the BSS section of the object file. | |
19134 | This inhibits the merging of tentative definitions by the linker so you get a | |
19135 | multiple-definition error if the same variable is accidentally defined in more | |
19136 | than one compilation unit. | |
19137 | ||
19138 | The @option{-fcommon} places uninitialized global variables in a common block. | |
19139 | This allows the linker to resolve all tentative definitions of the same variable | |
19140 | in different compilation units to the same object, or to a non-tentative | |
19141 | definition. This behavior is inconsistent with C++, and on many targets implies | |
19142 | a speed and code size penalty on global variable references. It is mainly | |
19143 | useful to enable legacy code to link without errors. | |
19144 | ||
d77de738 ML |
19145 | @opindex fno-ident |
19146 | @opindex fident | |
ddf6fe37 | 19147 | @item -fno-ident |
d77de738 ML |
19148 | Ignore the @code{#ident} directive. |
19149 | ||
d77de738 | 19150 | @opindex finhibit-size-directive |
ddf6fe37 | 19151 | @item -finhibit-size-directive |
d77de738 ML |
19152 | Don't output a @code{.size} assembler directive, or anything else that |
19153 | would cause trouble if the function is split in the middle, and the | |
19154 | two halves are placed at locations far apart in memory. This option is | |
19155 | used when compiling @file{crtstuff.c}; you should not need to use it | |
19156 | for anything else. | |
19157 | ||
d77de738 | 19158 | @opindex fverbose-asm |
ddf6fe37 | 19159 | @item -fverbose-asm |
d77de738 ML |
19160 | Put extra commentary information in the generated assembly code to |
19161 | make it more readable. This option is generally only of use to those | |
19162 | who actually need to read the generated assembly code (perhaps while | |
19163 | debugging the compiler itself). | |
19164 | ||
19165 | @option{-fno-verbose-asm}, the default, causes the | |
19166 | extra information to be omitted and is useful when comparing two assembler | |
19167 | files. | |
19168 | ||
19169 | The added comments include: | |
19170 | ||
19171 | @itemize @bullet | |
19172 | ||
19173 | @item | |
19174 | information on the compiler version and command-line options, | |
19175 | ||
19176 | @item | |
19177 | the source code lines associated with the assembly instructions, | |
19178 | in the form FILENAME:LINENUMBER:CONTENT OF LINE, | |
19179 | ||
19180 | @item | |
19181 | hints on which high-level expressions correspond to | |
19182 | the various assembly instruction operands. | |
19183 | ||
19184 | @end itemize | |
19185 | ||
19186 | For example, given this C source file: | |
19187 | ||
19188 | @smallexample | |
19189 | int test (int n) | |
19190 | @{ | |
19191 | int i; | |
19192 | int total = 0; | |
19193 | ||
19194 | for (i = 0; i < n; i++) | |
19195 | total += i * i; | |
19196 | ||
19197 | return total; | |
19198 | @} | |
19199 | @end smallexample | |
19200 | ||
19201 | compiling to (x86_64) assembly via @option{-S} and emitting the result | |
19202 | direct to stdout via @option{-o} @option{-} | |
19203 | ||
19204 | @smallexample | |
19205 | gcc -S test.c -fverbose-asm -Os -o - | |
19206 | @end smallexample | |
19207 | ||
19208 | gives output similar to this: | |
19209 | ||
19210 | @smallexample | |
19211 | .file "test.c" | |
19212 | # GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu) | |
19213 | [...snip...] | |
19214 | # options passed: | |
19215 | [...snip...] | |
19216 | ||
19217 | .text | |
19218 | .globl test | |
19219 | .type test, @@function | |
19220 | test: | |
19221 | .LFB0: | |
19222 | .cfi_startproc | |
19223 | # test.c:4: int total = 0; | |
19224 | xorl %eax, %eax # <retval> | |
19225 | # test.c:6: for (i = 0; i < n; i++) | |
19226 | xorl %edx, %edx # i | |
19227 | .L2: | |
19228 | # test.c:6: for (i = 0; i < n; i++) | |
19229 | cmpl %edi, %edx # n, i | |
19230 | jge .L5 #, | |
19231 | # test.c:7: total += i * i; | |
19232 | movl %edx, %ecx # i, tmp92 | |
19233 | imull %edx, %ecx # i, tmp92 | |
19234 | # test.c:6: for (i = 0; i < n; i++) | |
19235 | incl %edx # i | |
19236 | # test.c:7: total += i * i; | |
19237 | addl %ecx, %eax # tmp92, <retval> | |
19238 | jmp .L2 # | |
19239 | .L5: | |
19240 | # test.c:10: @} | |
19241 | ret | |
19242 | .cfi_endproc | |
19243 | .LFE0: | |
19244 | .size test, .-test | |
19245 | .ident "GCC: (GNU) 7.0.0 20160809 (experimental)" | |
19246 | .section .note.GNU-stack,"",@@progbits | |
19247 | @end smallexample | |
19248 | ||
19249 | The comments are intended for humans rather than machines and hence the | |
19250 | precise format of the comments is subject to change. | |
19251 | ||
d77de738 | 19252 | @opindex frecord-gcc-switches |
ddf6fe37 | 19253 | @item -frecord-gcc-switches |
d77de738 ML |
19254 | This switch causes the command line used to invoke the |
19255 | compiler to be recorded into the object file that is being created. | |
19256 | This switch is only implemented on some targets and the exact format | |
19257 | of the recording is target and binary file format dependent, but it | |
19258 | usually takes the form of a section containing ASCII text. This | |
19259 | switch is related to the @option{-fverbose-asm} switch, but that | |
19260 | switch only records information in the assembler output file as | |
19261 | comments, so it never reaches the object file. | |
19262 | See also @option{-grecord-gcc-switches} for another | |
19263 | way of storing compiler options into the object file. | |
19264 | ||
d77de738 ML |
19265 | @opindex fpic |
19266 | @cindex global offset table | |
19267 | @cindex PIC | |
f33d7a88 | 19268 | @item -fpic |
d77de738 ML |
19269 | Generate position-independent code (PIC) suitable for use in a shared |
19270 | library, if supported for the target machine. Such code accesses all | |
19271 | constant addresses through a global offset table (GOT)@. The dynamic | |
19272 | loader resolves the GOT entries when the program starts (the dynamic | |
19273 | loader is not part of GCC; it is part of the operating system). If | |
19274 | the GOT size for the linked executable exceeds a machine-specific | |
19275 | maximum size, you get an error message from the linker indicating that | |
19276 | @option{-fpic} does not work; in that case, recompile with @option{-fPIC} | |
19277 | instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k | |
19278 | on the m68k and RS/6000. The x86 has no such limit.) | |
19279 | ||
19280 | Position-independent code requires special support, and therefore works | |
19281 | only on certain machines. For the x86, GCC supports PIC for System V | |
19282 | but not for the Sun 386i. Code generated for the IBM RS/6000 is always | |
19283 | position-independent. | |
19284 | ||
19285 | When this flag is set, the macros @code{__pic__} and @code{__PIC__} | |
19286 | are defined to 1. | |
19287 | ||
d77de738 | 19288 | @opindex fPIC |
ddf6fe37 | 19289 | @item -fPIC |
d77de738 ML |
19290 | If supported for the target machine, emit position-independent code, |
19291 | suitable for dynamic linking and avoiding any limit on the size of the | |
19292 | global offset table. This option makes a difference on AArch64, m68k, | |
19293 | PowerPC and SPARC@. | |
19294 | ||
19295 | Position-independent code requires special support, and therefore works | |
19296 | only on certain machines. | |
19297 | ||
19298 | When this flag is set, the macros @code{__pic__} and @code{__PIC__} | |
19299 | are defined to 2. | |
19300 | ||
d77de738 ML |
19301 | @opindex fpie |
19302 | @opindex fPIE | |
ddf6fe37 AA |
19303 | @item -fpie |
19304 | @itemx -fPIE | |
d77de738 ML |
19305 | These options are similar to @option{-fpic} and @option{-fPIC}, but the |
19306 | generated position-independent code can be only linked into executables. | |
19307 | Usually these options are used to compile code that will be linked using | |
19308 | the @option{-pie} GCC option. | |
19309 | ||
19310 | @option{-fpie} and @option{-fPIE} both define the macros | |
19311 | @code{__pie__} and @code{__PIE__}. The macros have the value 1 | |
19312 | for @option{-fpie} and 2 for @option{-fPIE}. | |
19313 | ||
d77de738 ML |
19314 | @opindex fno-plt |
19315 | @opindex fplt | |
ddf6fe37 | 19316 | @item -fno-plt |
d77de738 ML |
19317 | Do not use the PLT for external function calls in position-independent code. |
19318 | Instead, load the callee address at call sites from the GOT and branch to it. | |
19319 | This leads to more efficient code by eliminating PLT stubs and exposing | |
19320 | GOT loads to optimizations. On architectures such as 32-bit x86 where | |
19321 | PLT stubs expect the GOT pointer in a specific register, this gives more | |
19322 | register allocation freedom to the compiler. | |
19323 | Lazy binding requires use of the PLT; | |
19324 | with @option{-fno-plt} all external symbols are resolved at load time. | |
19325 | ||
19326 | Alternatively, the function attribute @code{noplt} can be used to avoid calls | |
19327 | through the PLT for specific external functions. | |
19328 | ||
19329 | In position-dependent code, a few targets also convert calls to | |
19330 | functions that are marked to not use the PLT to use the GOT instead. | |
19331 | ||
d77de738 ML |
19332 | @opindex fno-jump-tables |
19333 | @opindex fjump-tables | |
ddf6fe37 | 19334 | @item -fno-jump-tables |
d77de738 ML |
19335 | Do not use jump tables for switch statements even where it would be |
19336 | more efficient than other code generation strategies. This option is | |
19337 | of use in conjunction with @option{-fpic} or @option{-fPIC} for | |
19338 | building code that forms part of a dynamic linker and cannot | |
19339 | reference the address of a jump table. On some targets, jump tables | |
19340 | do not require a GOT and this option is not needed. | |
19341 | ||
d77de738 ML |
19342 | @opindex fno-bit-tests |
19343 | @opindex fbit-tests | |
ddf6fe37 | 19344 | @item -fno-bit-tests |
d77de738 ML |
19345 | Do not use bit tests for switch statements even where it would be |
19346 | more efficient than other code generation strategies. | |
19347 | ||
d77de738 | 19348 | @opindex ffixed |
ddf6fe37 | 19349 | @item -ffixed-@var{reg} |
d77de738 ML |
19350 | Treat the register named @var{reg} as a fixed register; generated code |
19351 | should never refer to it (except perhaps as a stack pointer, frame | |
19352 | pointer or in some other fixed role). | |
19353 | ||
19354 | @var{reg} must be the name of a register. The register names accepted | |
19355 | are machine-specific and are defined in the @code{REGISTER_NAMES} | |
19356 | macro in the machine description macro file. | |
19357 | ||
19358 | This flag does not have a negative form, because it specifies a | |
19359 | three-way choice. | |
19360 | ||
d77de738 | 19361 | @opindex fcall-used |
ddf6fe37 | 19362 | @item -fcall-used-@var{reg} |
d77de738 ML |
19363 | Treat the register named @var{reg} as an allocable register that is |
19364 | clobbered by function calls. It may be allocated for temporaries or | |
19365 | variables that do not live across a call. Functions compiled this way | |
19366 | do not save and restore the register @var{reg}. | |
19367 | ||
19368 | It is an error to use this flag with the frame pointer or stack pointer. | |
19369 | Use of this flag for other registers that have fixed pervasive roles in | |
19370 | the machine's execution model produces disastrous results. | |
19371 | ||
19372 | This flag does not have a negative form, because it specifies a | |
19373 | three-way choice. | |
19374 | ||
d77de738 | 19375 | @opindex fcall-saved |
ddf6fe37 | 19376 | @item -fcall-saved-@var{reg} |
d77de738 ML |
19377 | Treat the register named @var{reg} as an allocable register saved by |
19378 | functions. It may be allocated even for temporaries or variables that | |
19379 | live across a call. Functions compiled this way save and restore | |
19380 | the register @var{reg} if they use it. | |
19381 | ||
19382 | It is an error to use this flag with the frame pointer or stack pointer. | |
19383 | Use of this flag for other registers that have fixed pervasive roles in | |
19384 | the machine's execution model produces disastrous results. | |
19385 | ||
19386 | A different sort of disaster results from the use of this flag for | |
19387 | a register in which function values may be returned. | |
19388 | ||
19389 | This flag does not have a negative form, because it specifies a | |
19390 | three-way choice. | |
19391 | ||
d77de738 | 19392 | @opindex fpack-struct |
ddf6fe37 | 19393 | @item -fpack-struct[=@var{n}] |
d77de738 ML |
19394 | Without a value specified, pack all structure members together without |
19395 | holes. When a value is specified (which must be a small power of two), pack | |
19396 | structure members according to this value, representing the maximum | |
19397 | alignment (that is, objects with default alignment requirements larger than | |
19398 | this are output potentially unaligned at the next fitting location. | |
19399 | ||
19400 | @strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate | |
19401 | code that is not binary compatible with code generated without that switch. | |
19402 | Additionally, it makes the code suboptimal. | |
19403 | Use it to conform to a non-default application binary interface. | |
19404 | ||
d77de738 | 19405 | @opindex fleading-underscore |
ddf6fe37 | 19406 | @item -fleading-underscore |
d77de738 ML |
19407 | This option and its counterpart, @option{-fno-leading-underscore}, forcibly |
19408 | change the way C symbols are represented in the object file. One use | |
19409 | is to help link with legacy assembly code. | |
19410 | ||
19411 | @strong{Warning:} the @option{-fleading-underscore} switch causes GCC to | |
19412 | generate code that is not binary compatible with code generated without that | |
19413 | switch. Use it to conform to a non-default application binary interface. | |
19414 | Not all targets provide complete support for this switch. | |
19415 | ||
d77de738 | 19416 | @opindex ftls-model |
ddf6fe37 | 19417 | @item -ftls-model=@var{model} |
d77de738 ML |
19418 | Alter the thread-local storage model to be used (@pxref{Thread-Local}). |
19419 | The @var{model} argument should be one of @samp{global-dynamic}, | |
19420 | @samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}. | |
19421 | Note that the choice is subject to optimization: the compiler may use | |
19422 | a more efficient model for symbols not visible outside of the translation | |
19423 | unit, or if @option{-fpic} is not given on the command line. | |
19424 | ||
19425 | The default without @option{-fpic} is @samp{initial-exec}; with | |
19426 | @option{-fpic} the default is @samp{global-dynamic}. | |
19427 | ||
d77de738 | 19428 | @opindex ftrampolines |
ddf6fe37 | 19429 | @item -ftrampolines |
d77de738 ML |
19430 | For targets that normally need trampolines for nested functions, always |
19431 | generate them instead of using descriptors. Otherwise, for targets that | |
19432 | do not need them, like for example HP-PA or IA-64, do nothing. | |
19433 | ||
19434 | A trampoline is a small piece of code that is created at run time on the | |
19435 | stack when the address of a nested function is taken, and is used to call | |
19436 | the nested function indirectly. Therefore, it requires the stack to be | |
19437 | made executable in order for the program to work properly. | |
19438 | ||
19439 | @option{-fno-trampolines} is enabled by default on a language by language | |
19440 | basis to let the compiler avoid generating them, if it computes that this | |
19441 | is safe, and replace them with descriptors. Descriptors are made up of data | |
19442 | only, but the generated code must be prepared to deal with them. As of this | |
19443 | writing, @option{-fno-trampolines} is enabled by default only for Ada. | |
19444 | ||
19445 | Moreover, code compiled with @option{-ftrampolines} and code compiled with | |
19446 | @option{-fno-trampolines} are not binary compatible if nested functions are | |
19447 | present. This option must therefore be used on a program-wide basis and be | |
19448 | manipulated with extreme care. | |
19449 | ||
19450 | For languages other than Ada, the @code{-ftrampolines} and | |
19451 | @code{-fno-trampolines} options currently have no effect, and | |
19452 | trampolines are always generated on platforms that need them | |
19453 | for nested functions. | |
19454 | ||
28d8c680 AB |
19455 | @opindex ftrampoline-impl |
19456 | @item -ftrampoline-impl=@r{[}stack@r{|}heap@r{]} | |
19457 | By default, trampolines are generated on stack. However, certain platforms | |
19458 | (such as the Apple M1) do not permit an executable stack. Compiling with | |
19459 | @option{-ftrampoline-impl=heap} generate calls to | |
19460 | @code{__builtin_nested_func_ptr_created} and | |
19461 | @code{__builtin_nested_func_ptr_deleted} in order to allocate and | |
19462 | deallocate trampoline space on the executable heap. These functions are | |
19463 | implemented in libgcc, and will only be provided on specific targets: | |
19464 | x86_64 Darwin, x86_64 and aarch64 Linux. @emph{PLEASE NOTE}: Heap | |
19465 | trampolines are @emph{not} guaranteed to be correctly deallocated if you | |
19466 | @code{setjmp}, instantiate nested functions, and then @code{longjmp} back | |
19467 | to a state prior to having allocated those nested functions. | |
19468 | ||
d77de738 | 19469 | @opindex fvisibility |
ddf6fe37 | 19470 | @item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} |
d77de738 ML |
19471 | Set the default ELF image symbol visibility to the specified option---all |
19472 | symbols are marked with this unless overridden within the code. | |
19473 | Using this feature can very substantially improve linking and | |
19474 | load times of shared object libraries, produce more optimized | |
19475 | code, provide near-perfect API export and prevent symbol clashes. | |
19476 | It is @strong{strongly} recommended that you use this in any shared objects | |
19477 | you distribute. | |
19478 | ||
19479 | Despite the nomenclature, @samp{default} always means public; i.e., | |
19480 | available to be linked against from outside the shared object. | |
19481 | @samp{protected} and @samp{internal} are pretty useless in real-world | |
19482 | usage so the only other commonly used option is @samp{hidden}. | |
19483 | The default if @option{-fvisibility} isn't specified is | |
19484 | @samp{default}, i.e., make every symbol public. | |
19485 | ||
19486 | A good explanation of the benefits offered by ensuring ELF | |
19487 | symbols have the correct visibility is given by ``How To Write | |
19488 | Shared Libraries'' by Ulrich Drepper (which can be found at | |
19489 | @w{@uref{https://www.akkadia.org/drepper/}})---however a superior | |
19490 | solution made possible by this option to marking things hidden when | |
19491 | the default is public is to make the default hidden and mark things | |
19492 | public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden} | |
19493 | and @code{__attribute__ ((visibility("default")))} instead of | |
19494 | @code{__declspec(dllexport)} you get almost identical semantics with | |
19495 | identical syntax. This is a great boon to those working with | |
19496 | cross-platform projects. | |
19497 | ||
19498 | For those adding visibility support to existing code, you may find | |
19499 | @code{#pragma GCC visibility} of use. This works by you enclosing | |
19500 | the declarations you wish to set visibility for with (for example) | |
19501 | @code{#pragma GCC visibility push(hidden)} and | |
19502 | @code{#pragma GCC visibility pop}. | |
19503 | Bear in mind that symbol visibility should be viewed @strong{as | |
19504 | part of the API interface contract} and thus all new code should | |
19505 | always specify visibility when it is not the default; i.e., declarations | |
19506 | only for use within the local DSO should @strong{always} be marked explicitly | |
19507 | as hidden as so to avoid PLT indirection overheads---making this | |
19508 | abundantly clear also aids readability and self-documentation of the code. | |
19509 | Note that due to ISO C++ specification requirements, @code{operator new} and | |
19510 | @code{operator delete} must always be of default visibility. | |
19511 | ||
19512 | Be aware that headers from outside your project, in particular system | |
19513 | headers and headers from any other library you use, may not be | |
19514 | expecting to be compiled with visibility other than the default. You | |
19515 | may need to explicitly say @code{#pragma GCC visibility push(default)} | |
19516 | before including any such headers. | |
19517 | ||
19518 | @code{extern} declarations are not affected by @option{-fvisibility}, so | |
19519 | a lot of code can be recompiled with @option{-fvisibility=hidden} with | |
19520 | no modifications. However, this means that calls to @code{extern} | |
19521 | functions with no explicit visibility use the PLT, so it is more | |
19522 | effective to use @code{__attribute ((visibility))} and/or | |
19523 | @code{#pragma GCC visibility} to tell the compiler which @code{extern} | |
19524 | declarations should be treated as hidden. | |
19525 | ||
19526 | Note that @option{-fvisibility} does affect C++ vague linkage | |
19527 | entities. This means that, for instance, an exception class that is | |
19528 | be thrown between DSOs must be explicitly marked with default | |
19529 | visibility so that the @samp{type_info} nodes are unified between | |
19530 | the DSOs. | |
19531 | ||
19532 | An overview of these techniques, their benefits and how to use them | |
19533 | is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}. | |
19534 | ||
d77de738 | 19535 | @opindex fstrict-volatile-bitfields |
ddf6fe37 | 19536 | @item -fstrict-volatile-bitfields |
d77de738 ML |
19537 | This option should be used if accesses to volatile bit-fields (or other |
19538 | structure fields, although the compiler usually honors those types | |
19539 | anyway) should use a single access of the width of the | |
19540 | field's type, aligned to a natural alignment if possible. For | |
19541 | example, targets with memory-mapped peripheral registers might require | |
19542 | all such accesses to be 16 bits wide; with this flag you can | |
19543 | declare all peripheral bit-fields as @code{unsigned short} (assuming short | |
19544 | is 16 bits on these targets) to force GCC to use 16-bit accesses | |
19545 | instead of, perhaps, a more efficient 32-bit access. | |
19546 | ||
19547 | If this option is disabled, the compiler uses the most efficient | |
19548 | instruction. In the previous example, that might be a 32-bit load | |
19549 | instruction, even though that accesses bytes that do not contain | |
19550 | any portion of the bit-field, or memory-mapped registers unrelated to | |
19551 | the one being updated. | |
19552 | ||
19553 | In some cases, such as when the @code{packed} attribute is applied to a | |
19554 | structure field, it may not be possible to access the field with a single | |
19555 | read or write that is correctly aligned for the target machine. In this | |
19556 | case GCC falls back to generating multiple accesses rather than code that | |
19557 | will fault or truncate the result at run time. | |
19558 | ||
19559 | Note: Due to restrictions of the C/C++11 memory model, write accesses are | |
19560 | not allowed to touch non bit-field members. It is therefore recommended | |
19561 | to define all bits of the field's type as bit-field members. | |
19562 | ||
19563 | The default value of this option is determined by the application binary | |
19564 | interface for the target processor. | |
19565 | ||
d77de738 | 19566 | @opindex fsync-libcalls |
ddf6fe37 | 19567 | @item -fsync-libcalls |
d77de738 ML |
19568 | This option controls whether any out-of-line instance of the @code{__sync} |
19569 | family of functions may be used to implement the C++11 @code{__atomic} | |
19570 | family of functions. | |
19571 | ||
19572 | The default value of this option is enabled, thus the only useful form | |
19573 | of the option is @option{-fno-sync-libcalls}. This option is used in | |
19574 | the implementation of the @file{libatomic} runtime library. | |
19575 | ||
19576 | @end table | |
19577 | ||
19578 | @node Developer Options | |
19579 | @section GCC Developer Options | |
19580 | @cindex developer options | |
19581 | @cindex debugging GCC | |
19582 | @cindex debug dump options | |
19583 | @cindex dump options | |
19584 | @cindex compilation statistics | |
19585 | ||
19586 | This section describes command-line options that are primarily of | |
19587 | interest to GCC developers, including options to support compiler | |
19588 | testing and investigation of compiler bugs and compile-time | |
19589 | performance problems. This includes options that produce debug dumps | |
19590 | at various points in the compilation; that print statistics such as | |
19591 | memory use and execution time; and that print information about GCC's | |
19592 | configuration, such as where it searches for libraries. You should | |
19593 | rarely need to use any of these options for ordinary compilation and | |
19594 | linking tasks. | |
19595 | ||
19596 | Many developer options that cause GCC to dump output to a file take an | |
19597 | optional @samp{=@var{filename}} suffix. You can specify @samp{stdout} | |
19598 | or @samp{-} to dump to standard output, and @samp{stderr} for standard | |
19599 | error. | |
19600 | ||
19601 | If @samp{=@var{filename}} is omitted, a default dump file name is | |
19602 | constructed by concatenating the base dump file name, a pass number, | |
19603 | phase letter, and pass name. The base dump file name is the name of | |
19604 | output file produced by the compiler if explicitly specified and not | |
19605 | an executable; otherwise it is the source file name. | |
19606 | The pass number is determined by the order passes are registered with | |
19607 | the compiler's pass manager. | |
19608 | This is generally the same as the order of execution, but passes | |
19609 | registered by plugins, target-specific passes, or passes that are | |
19610 | otherwise registered late are numbered higher than the pass named | |
19611 | @samp{final}, even if they are executed earlier. The phase letter is | |
19612 | one of @samp{i} (inter-procedural analysis), @samp{l} | |
19613 | (language-specific), @samp{r} (RTL), or @samp{t} (tree). | |
19614 | The files are created in the directory of the output file. | |
19615 | ||
19616 | @table @gcctabopt | |
19617 | ||
ddf6fe37 | 19618 | @opindex fcallgraph-info |
d77de738 ML |
19619 | @item -fcallgraph-info |
19620 | @itemx -fcallgraph-info=@var{MARKERS} | |
d77de738 ML |
19621 | Makes the compiler output callgraph information for the program, on a |
19622 | per-object-file basis. The information is generated in the common VCG | |
19623 | format. It can be decorated with additional, per-node and/or per-edge | |
19624 | information, if a list of comma-separated markers is additionally | |
19625 | specified. When the @code{su} marker is specified, the callgraph is | |
19626 | decorated with stack usage information; it is equivalent to | |
19627 | @option{-fstack-usage}. When the @code{da} marker is specified, the | |
19628 | callgraph is decorated with information about dynamically allocated | |
19629 | objects. | |
19630 | ||
19631 | When compiling with @option{-flto}, no callgraph information is output | |
19632 | along with the object file. At LTO link time, @option{-fcallgraph-info} | |
19633 | may generate multiple callgraph information files next to intermediate | |
19634 | LTO output files. | |
19635 | ||
ddf6fe37 AA |
19636 | @opindex d |
19637 | @opindex fdump-rtl-@var{pass} | |
d77de738 ML |
19638 | @item -d@var{letters} |
19639 | @itemx -fdump-rtl-@var{pass} | |
19640 | @itemx -fdump-rtl-@var{pass}=@var{filename} | |
d77de738 ML |
19641 | Says to make debugging dumps during compilation at times specified by |
19642 | @var{letters}. This is used for debugging the RTL-based passes of the | |
19643 | compiler. | |
19644 | ||
19645 | Some @option{-d@var{letters}} switches have different meaning when | |
19646 | @option{-E} is used for preprocessing. @xref{Preprocessor Options}, | |
19647 | for information about preprocessor-specific dump options. | |
19648 | ||
19649 | Debug dumps can be enabled with a @option{-fdump-rtl} switch or some | |
19650 | @option{-d} option @var{letters}. Here are the possible | |
19651 | letters for use in @var{pass} and @var{letters}, and their meanings: | |
19652 | ||
19653 | @table @gcctabopt | |
19654 | ||
d77de738 | 19655 | @opindex fdump-rtl-alignments |
ddf6fe37 | 19656 | @item -fdump-rtl-alignments |
d77de738 ML |
19657 | Dump after branch alignments have been computed. |
19658 | ||
d77de738 | 19659 | @opindex fdump-rtl-asmcons |
ddf6fe37 | 19660 | @item -fdump-rtl-asmcons |
d77de738 ML |
19661 | Dump after fixing rtl statements that have unsatisfied in/out constraints. |
19662 | ||
d77de738 | 19663 | @opindex fdump-rtl-auto_inc_dec |
ddf6fe37 | 19664 | @item -fdump-rtl-auto_inc_dec |
d77de738 ML |
19665 | Dump after auto-inc-dec discovery. This pass is only run on |
19666 | architectures that have auto inc or auto dec instructions. | |
19667 | ||
d77de738 | 19668 | @opindex fdump-rtl-barriers |
ddf6fe37 | 19669 | @item -fdump-rtl-barriers |
d77de738 ML |
19670 | Dump after cleaning up the barrier instructions. |
19671 | ||
d77de738 | 19672 | @opindex fdump-rtl-bbpart |
ddf6fe37 | 19673 | @item -fdump-rtl-bbpart |
d77de738 ML |
19674 | Dump after partitioning hot and cold basic blocks. |
19675 | ||
d77de738 | 19676 | @opindex fdump-rtl-bbro |
ddf6fe37 | 19677 | @item -fdump-rtl-bbro |
d77de738 ML |
19678 | Dump after block reordering. |
19679 | ||
d77de738 ML |
19680 | @opindex fdump-rtl-btl2 |
19681 | @opindex fdump-rtl-btl2 | |
ddf6fe37 AA |
19682 | @item -fdump-rtl-btl1 |
19683 | @itemx -fdump-rtl-btl2 | |
d77de738 ML |
19684 | @option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping |
19685 | after the two branch | |
19686 | target load optimization passes. | |
19687 | ||
d77de738 | 19688 | @opindex fdump-rtl-bypass |
ddf6fe37 | 19689 | @item -fdump-rtl-bypass |
d77de738 ML |
19690 | Dump after jump bypassing and control flow optimizations. |
19691 | ||
d77de738 | 19692 | @opindex fdump-rtl-combine |
ddf6fe37 | 19693 | @item -fdump-rtl-combine |
d77de738 ML |
19694 | Dump after the RTL instruction combination pass. |
19695 | ||
d77de738 | 19696 | @opindex fdump-rtl-compgotos |
ddf6fe37 | 19697 | @item -fdump-rtl-compgotos |
d77de738 ML |
19698 | Dump after duplicating the computed gotos. |
19699 | ||
d77de738 ML |
19700 | @opindex fdump-rtl-ce1 |
19701 | @opindex fdump-rtl-ce2 | |
19702 | @opindex fdump-rtl-ce3 | |
ddf6fe37 AA |
19703 | @item -fdump-rtl-ce1 |
19704 | @itemx -fdump-rtl-ce2 | |
19705 | @itemx -fdump-rtl-ce3 | |
d77de738 ML |
19706 | @option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and |
19707 | @option{-fdump-rtl-ce3} enable dumping after the three | |
19708 | if conversion passes. | |
19709 | ||
d77de738 | 19710 | @opindex fdump-rtl-cprop_hardreg |
ddf6fe37 | 19711 | @item -fdump-rtl-cprop_hardreg |
d77de738 ML |
19712 | Dump after hard register copy propagation. |
19713 | ||
d77de738 | 19714 | @opindex fdump-rtl-csa |
ddf6fe37 | 19715 | @item -fdump-rtl-csa |
d77de738 ML |
19716 | Dump after combining stack adjustments. |
19717 | ||
d77de738 ML |
19718 | @opindex fdump-rtl-cse1 |
19719 | @opindex fdump-rtl-cse2 | |
ddf6fe37 AA |
19720 | @item -fdump-rtl-cse1 |
19721 | @itemx -fdump-rtl-cse2 | |
d77de738 ML |
19722 | @option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after |
19723 | the two common subexpression elimination passes. | |
19724 | ||
d77de738 | 19725 | @opindex fdump-rtl-dce |
ddf6fe37 | 19726 | @item -fdump-rtl-dce |
d77de738 ML |
19727 | Dump after the standalone dead code elimination passes. |
19728 | ||
d77de738 | 19729 | @opindex fdump-rtl-dbr |
ddf6fe37 | 19730 | @item -fdump-rtl-dbr |
d77de738 ML |
19731 | Dump after delayed branch scheduling. |
19732 | ||
d77de738 ML |
19733 | @opindex fdump-rtl-dce1 |
19734 | @opindex fdump-rtl-dce2 | |
ddf6fe37 AA |
19735 | @item -fdump-rtl-dce1 |
19736 | @itemx -fdump-rtl-dce2 | |
d77de738 ML |
19737 | @option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after |
19738 | the two dead store elimination passes. | |
19739 | ||
d77de738 | 19740 | @opindex fdump-rtl-eh |
ddf6fe37 | 19741 | @item -fdump-rtl-eh |
d77de738 ML |
19742 | Dump after finalization of EH handling code. |
19743 | ||
d77de738 | 19744 | @opindex fdump-rtl-eh_ranges |
ddf6fe37 | 19745 | @item -fdump-rtl-eh_ranges |
d77de738 ML |
19746 | Dump after conversion of EH handling range regions. |
19747 | ||
d77de738 | 19748 | @opindex fdump-rtl-expand |
ddf6fe37 | 19749 | @item -fdump-rtl-expand |
d77de738 ML |
19750 | Dump after RTL generation. |
19751 | ||
d77de738 ML |
19752 | @opindex fdump-rtl-fwprop1 |
19753 | @opindex fdump-rtl-fwprop2 | |
ddf6fe37 AA |
19754 | @item -fdump-rtl-fwprop1 |
19755 | @itemx -fdump-rtl-fwprop2 | |
d77de738 ML |
19756 | @option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable |
19757 | dumping after the two forward propagation passes. | |
19758 | ||
d77de738 ML |
19759 | @opindex fdump-rtl-gcse1 |
19760 | @opindex fdump-rtl-gcse2 | |
ddf6fe37 AA |
19761 | @item -fdump-rtl-gcse1 |
19762 | @itemx -fdump-rtl-gcse2 | |
d77de738 ML |
19763 | @option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping |
19764 | after global common subexpression elimination. | |
19765 | ||
d77de738 | 19766 | @opindex fdump-rtl-init-regs |
ddf6fe37 | 19767 | @item -fdump-rtl-init-regs |
d77de738 ML |
19768 | Dump after the initialization of the registers. |
19769 | ||
d77de738 | 19770 | @opindex fdump-rtl-initvals |
ddf6fe37 | 19771 | @item -fdump-rtl-initvals |
d77de738 ML |
19772 | Dump after the computation of the initial value sets. |
19773 | ||
d77de738 | 19774 | @opindex fdump-rtl-into_cfglayout |
ddf6fe37 | 19775 | @item -fdump-rtl-into_cfglayout |
d77de738 ML |
19776 | Dump after converting to cfglayout mode. |
19777 | ||
d77de738 | 19778 | @opindex fdump-rtl-ira |
ddf6fe37 | 19779 | @item -fdump-rtl-ira |
d77de738 ML |
19780 | Dump after iterated register allocation. |
19781 | ||
d77de738 | 19782 | @opindex fdump-rtl-jump |
ddf6fe37 | 19783 | @item -fdump-rtl-jump |
d77de738 ML |
19784 | Dump after the second jump optimization. |
19785 | ||
d77de738 | 19786 | @opindex fdump-rtl-loop2 |
ddf6fe37 | 19787 | @item -fdump-rtl-loop2 |
d77de738 ML |
19788 | @option{-fdump-rtl-loop2} enables dumping after the rtl |
19789 | loop optimization passes. | |
19790 | ||
d77de738 | 19791 | @opindex fdump-rtl-mach |
ddf6fe37 | 19792 | @item -fdump-rtl-mach |
d77de738 ML |
19793 | Dump after performing the machine dependent reorganization pass, if that |
19794 | pass exists. | |
19795 | ||
d77de738 | 19796 | @opindex fdump-rtl-mode_sw |
ddf6fe37 | 19797 | @item -fdump-rtl-mode_sw |
d77de738 ML |
19798 | Dump after removing redundant mode switches. |
19799 | ||
d77de738 | 19800 | @opindex fdump-rtl-rnreg |
ddf6fe37 | 19801 | @item -fdump-rtl-rnreg |
d77de738 ML |
19802 | Dump after register renumbering. |
19803 | ||
d77de738 | 19804 | @opindex fdump-rtl-outof_cfglayout |
ddf6fe37 | 19805 | @item -fdump-rtl-outof_cfglayout |
d77de738 ML |
19806 | Dump after converting from cfglayout mode. |
19807 | ||
d77de738 | 19808 | @opindex fdump-rtl-peephole2 |
ddf6fe37 | 19809 | @item -fdump-rtl-peephole2 |
d77de738 ML |
19810 | Dump after the peephole pass. |
19811 | ||
d77de738 | 19812 | @opindex fdump-rtl-postreload |
ddf6fe37 | 19813 | @item -fdump-rtl-postreload |
d77de738 ML |
19814 | Dump after post-reload optimizations. |
19815 | ||
d77de738 | 19816 | @opindex fdump-rtl-pro_and_epilogue |
ddf6fe37 | 19817 | @item -fdump-rtl-pro_and_epilogue |
d77de738 ML |
19818 | Dump after generating the function prologues and epilogues. |
19819 | ||
d77de738 ML |
19820 | @opindex fdump-rtl-sched1 |
19821 | @opindex fdump-rtl-sched2 | |
ddf6fe37 AA |
19822 | @item -fdump-rtl-sched1 |
19823 | @itemx -fdump-rtl-sched2 | |
d77de738 ML |
19824 | @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping |
19825 | after the basic block scheduling passes. | |
19826 | ||
d77de738 | 19827 | @opindex fdump-rtl-ree |
ddf6fe37 | 19828 | @item -fdump-rtl-ree |
d77de738 ML |
19829 | Dump after sign/zero extension elimination. |
19830 | ||
d77de738 | 19831 | @opindex fdump-rtl-seqabstr |
ddf6fe37 | 19832 | @item -fdump-rtl-seqabstr |
d77de738 ML |
19833 | Dump after common sequence discovery. |
19834 | ||
d77de738 | 19835 | @opindex fdump-rtl-shorten |
ddf6fe37 | 19836 | @item -fdump-rtl-shorten |
d77de738 ML |
19837 | Dump after shortening branches. |
19838 | ||
d77de738 | 19839 | @opindex fdump-rtl-sibling |
ddf6fe37 | 19840 | @item -fdump-rtl-sibling |
d77de738 ML |
19841 | Dump after sibling call optimizations. |
19842 | ||
d77de738 ML |
19843 | @opindex fdump-rtl-split1 |
19844 | @opindex fdump-rtl-split2 | |
19845 | @opindex fdump-rtl-split3 | |
19846 | @opindex fdump-rtl-split4 | |
19847 | @opindex fdump-rtl-split5 | |
ddf6fe37 AA |
19848 | @item -fdump-rtl-split1 |
19849 | @itemx -fdump-rtl-split2 | |
19850 | @itemx -fdump-rtl-split3 | |
19851 | @itemx -fdump-rtl-split4 | |
19852 | @itemx -fdump-rtl-split5 | |
d77de738 ML |
19853 | These options enable dumping after five rounds of |
19854 | instruction splitting. | |
19855 | ||
d77de738 | 19856 | @opindex fdump-rtl-sms |
ddf6fe37 | 19857 | @item -fdump-rtl-sms |
d77de738 ML |
19858 | Dump after modulo scheduling. This pass is only run on some |
19859 | architectures. | |
19860 | ||
d77de738 | 19861 | @opindex fdump-rtl-stack |
ddf6fe37 | 19862 | @item -fdump-rtl-stack |
d77de738 ML |
19863 | Dump after conversion from GCC's ``flat register file'' registers to the |
19864 | x87's stack-like registers. This pass is only run on x86 variants. | |
19865 | ||
d77de738 ML |
19866 | @opindex fdump-rtl-subreg1 |
19867 | @opindex fdump-rtl-subreg2 | |
ddf6fe37 AA |
19868 | @item -fdump-rtl-subreg1 |
19869 | @itemx -fdump-rtl-subreg2 | |
d77de738 ML |
19870 | @option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after |
19871 | the two subreg expansion passes. | |
19872 | ||
d77de738 | 19873 | @opindex fdump-rtl-unshare |
ddf6fe37 | 19874 | @item -fdump-rtl-unshare |
d77de738 ML |
19875 | Dump after all rtl has been unshared. |
19876 | ||
d77de738 | 19877 | @opindex fdump-rtl-vartrack |
ddf6fe37 | 19878 | @item -fdump-rtl-vartrack |
d77de738 ML |
19879 | Dump after variable tracking. |
19880 | ||
d77de738 | 19881 | @opindex fdump-rtl-vregs |
ddf6fe37 | 19882 | @item -fdump-rtl-vregs |
d77de738 ML |
19883 | Dump after converting virtual registers to hard registers. |
19884 | ||
d77de738 | 19885 | @opindex fdump-rtl-web |
ddf6fe37 | 19886 | @item -fdump-rtl-web |
d77de738 ML |
19887 | Dump after live range splitting. |
19888 | ||
d77de738 ML |
19889 | @opindex fdump-rtl-regclass |
19890 | @opindex fdump-rtl-subregs_of_mode_init | |
19891 | @opindex fdump-rtl-subregs_of_mode_finish | |
19892 | @opindex fdump-rtl-dfinit | |
19893 | @opindex fdump-rtl-dfinish | |
ddf6fe37 AA |
19894 | @item -fdump-rtl-regclass |
19895 | @itemx -fdump-rtl-subregs_of_mode_init | |
19896 | @itemx -fdump-rtl-subregs_of_mode_finish | |
19897 | @itemx -fdump-rtl-dfinit | |
19898 | @itemx -fdump-rtl-dfinish | |
d77de738 ML |
19899 | These dumps are defined but always produce empty files. |
19900 | ||
d77de738 ML |
19901 | @opindex da |
19902 | @opindex fdump-rtl-all | |
ddf6fe37 AA |
19903 | @item -da |
19904 | @itemx -fdump-rtl-all | |
d77de738 ML |
19905 | Produce all the dumps listed above. |
19906 | ||
d77de738 | 19907 | @opindex dA |
ddf6fe37 | 19908 | @item -dA |
d77de738 ML |
19909 | Annotate the assembler output with miscellaneous debugging information. |
19910 | ||
d77de738 | 19911 | @opindex dD |
ddf6fe37 | 19912 | @item -dD |
d77de738 ML |
19913 | Dump all macro definitions, at the end of preprocessing, in addition to |
19914 | normal output. | |
19915 | ||
d77de738 | 19916 | @opindex dH |
ddf6fe37 | 19917 | @item -dH |
d77de738 ML |
19918 | Produce a core dump whenever an error occurs. |
19919 | ||
d77de738 | 19920 | @opindex dp |
ddf6fe37 | 19921 | @item -dp |
d77de738 ML |
19922 | Annotate the assembler output with a comment indicating which |
19923 | pattern and alternative is used. The length and cost of each instruction are | |
19924 | also printed. | |
19925 | ||
d77de738 | 19926 | @opindex dP |
ddf6fe37 | 19927 | @item -dP |
d77de738 ML |
19928 | Dump the RTL in the assembler output as a comment before each instruction. |
19929 | Also turns on @option{-dp} annotation. | |
19930 | ||
d77de738 | 19931 | @opindex dx |
ddf6fe37 | 19932 | @item -dx |
d77de738 ML |
19933 | Just generate RTL for a function instead of compiling it. Usually used |
19934 | with @option{-fdump-rtl-expand}. | |
19935 | @end table | |
19936 | ||
d77de738 | 19937 | @opindex fdump-debug |
ddf6fe37 | 19938 | @item -fdump-debug |
d77de738 ML |
19939 | Dump debugging information generated during the debug |
19940 | generation phase. | |
19941 | ||
d77de738 | 19942 | @opindex fdump-earlydebug |
ddf6fe37 | 19943 | @item -fdump-earlydebug |
d77de738 ML |
19944 | Dump debugging information generated during the early debug |
19945 | generation phase. | |
19946 | ||
d77de738 | 19947 | @opindex fdump-noaddr |
ddf6fe37 | 19948 | @item -fdump-noaddr |
d77de738 ML |
19949 | When doing debugging dumps, suppress address output. This makes it more |
19950 | feasible to use diff on debugging dumps for compiler invocations with | |
19951 | different compiler binaries and/or different | |
19952 | text / bss / data / heap / stack / dso start locations. | |
19953 | ||
d77de738 | 19954 | @opindex freport-bug |
ddf6fe37 | 19955 | @item -freport-bug |
d77de738 ML |
19956 | Collect and dump debug information into a temporary file if an |
19957 | internal compiler error (ICE) occurs. | |
19958 | ||
d77de738 | 19959 | @opindex fdump-unnumbered |
ddf6fe37 | 19960 | @item -fdump-unnumbered |
d77de738 ML |
19961 | When doing debugging dumps, suppress instruction numbers and address output. |
19962 | This makes it more feasible to use diff on debugging dumps for compiler | |
19963 | invocations with different options, in particular with and without | |
19964 | @option{-g}. | |
19965 | ||
d77de738 | 19966 | @opindex fdump-unnumbered-links |
ddf6fe37 | 19967 | @item -fdump-unnumbered-links |
d77de738 ML |
19968 | When doing debugging dumps (see @option{-d} option above), suppress |
19969 | instruction numbers for the links to the previous and next instructions | |
19970 | in a sequence. | |
19971 | ||
ddf6fe37 | 19972 | @opindex fdump-ipa |
d77de738 ML |
19973 | @item -fdump-ipa-@var{switch} |
19974 | @itemx -fdump-ipa-@var{switch}-@var{options} | |
d77de738 ML |
19975 | Control the dumping at various stages of inter-procedural analysis |
19976 | language tree to a file. The file name is generated by appending a | |
19977 | switch specific suffix to the source file name, and the file is created | |
19978 | in the same directory as the output file. The following dumps are | |
19979 | possible: | |
19980 | ||
19981 | @table @samp | |
19982 | @item all | |
19983 | Enables all inter-procedural analysis dumps. | |
19984 | ||
19985 | @item cgraph | |
19986 | Dumps information about call-graph optimization, unused function removal, | |
19987 | and inlining decisions. | |
19988 | ||
19989 | @item inline | |
19990 | Dump after function inlining. | |
19991 | ||
f0a90c7d AO |
19992 | @item strubm |
19993 | Dump after selecting @code{strub} modes, and recording the selections as | |
19994 | function attributes. | |
19995 | ||
19996 | @item strub | |
19997 | Dump @code{strub} transformations: interface changes, function wrapping, | |
19998 | and insertion of builtin calls for stack scrubbing and watermarking. | |
19999 | ||
d77de738 ML |
20000 | @end table |
20001 | ||
20002 | Additionally, the options @option{-optimized}, @option{-missed}, | |
20003 | @option{-note}, and @option{-all} can be provided, with the same meaning | |
20004 | as for @option{-fopt-info}, defaulting to @option{-optimized}. | |
20005 | ||
20006 | For example, @option{-fdump-ipa-inline-optimized-missed} will emit | |
20007 | information on callsites that were inlined, along with callsites | |
20008 | that were not inlined. | |
20009 | ||
20010 | By default, the dump will contain messages about successful | |
20011 | optimizations (equivalent to @option{-optimized}) together with | |
20012 | low-level details about the analysis. | |
20013 | ||
d77de738 | 20014 | @opindex fdump-lang |
ddf6fe37 | 20015 | @item -fdump-lang |
d77de738 ML |
20016 | Dump language-specific information. The file name is made by appending |
20017 | @file{.lang} to the source file name. | |
20018 | ||
ddf6fe37 AA |
20019 | @opindex fdump-lang-all |
20020 | @opindex fdump-lang | |
d77de738 ML |
20021 | @item -fdump-lang-all |
20022 | @itemx -fdump-lang-@var{switch} | |
20023 | @itemx -fdump-lang-@var{switch}-@var{options} | |
20024 | @itemx -fdump-lang-@var{switch}-@var{options}=@var{filename} | |
d77de738 ML |
20025 | Control the dumping of language-specific information. The @var{options} |
20026 | and @var{filename} portions behave as described in the | |
20027 | @option{-fdump-tree} option. The following @var{switch} values are | |
20028 | accepted: | |
20029 | ||
20030 | @table @samp | |
20031 | @item all | |
20032 | ||
20033 | Enable all language-specific dumps. | |
20034 | ||
20035 | @item class | |
20036 | Dump class hierarchy information. Virtual table information is emitted | |
20037 | unless '@option{slim}' is specified. This option is applicable to C++ only. | |
20038 | ||
20039 | @item module | |
20040 | Dump module information. Options @option{lineno} (locations), | |
20041 | @option{graph} (reachability), @option{blocks} (clusters), | |
20042 | @option{uid} (serialization), @option{alias} (mergeable), | |
20043 | @option{asmname} (Elrond), @option{eh} (mapper) & @option{vops} | |
20044 | (macros) may provide additional information. This option is | |
20045 | applicable to C++ only. | |
20046 | ||
20047 | @item raw | |
20048 | Dump the raw internal tree data. This option is applicable to C++ only. | |
20049 | ||
20050 | @end table | |
20051 | ||
d77de738 | 20052 | @opindex fdump-passes |
ddf6fe37 | 20053 | @item -fdump-passes |
d77de738 ML |
20054 | Print on @file{stderr} the list of optimization passes that are turned |
20055 | on and off by the current command-line options. | |
20056 | ||
d77de738 | 20057 | @opindex fdump-statistics |
ddf6fe37 | 20058 | @item -fdump-statistics-@var{option} |
d77de738 ML |
20059 | Enable and control dumping of pass statistics in a separate file. The |
20060 | file name is generated by appending a suffix ending in | |
20061 | @samp{.statistics} to the source file name, and the file is created in | |
20062 | the same directory as the output file. If the @samp{-@var{option}} | |
20063 | form is used, @samp{-stats} causes counters to be summed over the | |
20064 | whole compilation unit while @samp{-details} dumps every event as | |
20065 | the passes generate them. The default with no option is to sum | |
20066 | counters for each function compiled. | |
20067 | ||
ddf6fe37 AA |
20068 | @opindex fdump-tree-all |
20069 | @opindex fdump-tree | |
d77de738 ML |
20070 | @item -fdump-tree-all |
20071 | @itemx -fdump-tree-@var{switch} | |
20072 | @itemx -fdump-tree-@var{switch}-@var{options} | |
20073 | @itemx -fdump-tree-@var{switch}-@var{options}=@var{filename} | |
d77de738 ML |
20074 | Control the dumping at various stages of processing the intermediate |
20075 | language tree to a file. If the @samp{-@var{options}} | |
20076 | form is used, @var{options} is a list of @samp{-} separated options | |
20077 | which control the details of the dump. Not all options are applicable | |
20078 | to all dumps; those that are not meaningful are ignored. The | |
20079 | following options are available | |
20080 | ||
20081 | @table @samp | |
20082 | @item address | |
20083 | Print the address of each node. Usually this is not meaningful as it | |
20084 | changes according to the environment and source file. Its primary use | |
20085 | is for tying up a dump file with a debug environment. | |
20086 | @item asmname | |
20087 | If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that | |
20088 | in the dump instead of @code{DECL_NAME}. Its primary use is ease of | |
20089 | use working backward from mangled names in the assembly file. | |
20090 | @item slim | |
20091 | When dumping front-end intermediate representations, inhibit dumping | |
20092 | of members of a scope or body of a function merely because that scope | |
20093 | has been reached. Only dump such items when they are directly reachable | |
20094 | by some other path. | |
20095 | ||
20096 | When dumping pretty-printed trees, this option inhibits dumping the | |
20097 | bodies of control structures. | |
20098 | ||
20099 | When dumping RTL, print the RTL in slim (condensed) form instead of | |
20100 | the default LISP-like representation. | |
20101 | @item raw | |
20102 | Print a raw representation of the tree. By default, trees are | |
20103 | pretty-printed into a C-like representation. | |
20104 | @item details | |
20105 | Enable more detailed dumps (not honored by every dump option). Also | |
20106 | include information from the optimization passes. | |
20107 | @item stats | |
20108 | Enable dumping various statistics about the pass (not honored by every dump | |
20109 | option). | |
20110 | @item blocks | |
20111 | Enable showing basic block boundaries (disabled in raw dumps). | |
20112 | @item graph | |
20113 | For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}), | |
20114 | dump a representation of the control flow graph suitable for viewing with | |
20115 | GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in | |
20116 | the file is pretty-printed as a subgraph, so that GraphViz can render them | |
20117 | all in a single plot. | |
20118 | ||
20119 | This option currently only works for RTL dumps, and the RTL is always | |
20120 | dumped in slim form. | |
20121 | @item vops | |
20122 | Enable showing virtual operands for every statement. | |
20123 | @item lineno | |
20124 | Enable showing line numbers for statements. | |
20125 | @item uid | |
20126 | Enable showing the unique ID (@code{DECL_UID}) for each variable. | |
20127 | @item verbose | |
20128 | Enable showing the tree dump for each statement. | |
20129 | @item eh | |
20130 | Enable showing the EH region number holding each statement. | |
20131 | @item scev | |
20132 | Enable showing scalar evolution analysis details. | |
20133 | @item optimized | |
20134 | Enable showing optimization information (only available in certain | |
20135 | passes). | |
20136 | @item missed | |
20137 | Enable showing missed optimization information (only available in certain | |
20138 | passes). | |
20139 | @item note | |
20140 | Enable other detailed optimization information (only available in | |
20141 | certain passes). | |
20142 | @item all | |
20143 | Turn on all options, except @option{raw}, @option{slim}, @option{verbose} | |
20144 | and @option{lineno}. | |
20145 | @item optall | |
20146 | Turn on all optimization options, i.e., @option{optimized}, | |
20147 | @option{missed}, and @option{note}. | |
20148 | @end table | |
20149 | ||
20150 | To determine what tree dumps are available or find the dump for a pass | |
20151 | of interest follow the steps below. | |
20152 | ||
20153 | @enumerate | |
20154 | @item | |
20155 | Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output | |
20156 | look for a code that corresponds to the pass you are interested in. | |
20157 | For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and | |
20158 | @code{tree-vrp2} correspond to the three Value Range Propagation passes. | |
20159 | The number at the end distinguishes distinct invocations of the same pass. | |
20160 | @item | |
20161 | To enable the creation of the dump file, append the pass code to | |
20162 | the @option{-fdump-} option prefix and invoke GCC with it. For example, | |
20163 | to enable the dump from the Early Value Range Propagation pass, invoke | |
20164 | GCC with the @option{-fdump-tree-evrp} option. Optionally, you may | |
20165 | specify the name of the dump file. If you don't specify one, GCC | |
20166 | creates as described below. | |
20167 | @item | |
20168 | Find the pass dump in a file whose name is composed of three components | |
20169 | separated by a period: the name of the source file GCC was invoked to | |
20170 | compile, a numeric suffix indicating the pass number followed by the | |
20171 | letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes), | |
20172 | and finally the pass code. For example, the Early VRP pass dump might | |
20173 | be in a file named @file{myfile.c.038t.evrp} in the current working | |
20174 | directory. Note that the numeric codes are not stable and may change | |
20175 | from one version of GCC to another. | |
20176 | @end enumerate | |
20177 | ||
ddf6fe37 | 20178 | @opindex fopt-info |
d77de738 ML |
20179 | @item -fopt-info |
20180 | @itemx -fopt-info-@var{options} | |
20181 | @itemx -fopt-info-@var{options}=@var{filename} | |
d77de738 ML |
20182 | Controls optimization dumps from various optimization passes. If the |
20183 | @samp{-@var{options}} form is used, @var{options} is a list of | |
20184 | @samp{-} separated option keywords to select the dump details and | |
20185 | optimizations. | |
20186 | ||
20187 | The @var{options} can be divided into three groups: | |
20188 | @enumerate | |
20189 | @item | |
20190 | options describing what kinds of messages should be emitted, | |
20191 | @item | |
20192 | options describing the verbosity of the dump, and | |
20193 | @item | |
20194 | options describing which optimizations should be included. | |
20195 | @end enumerate | |
20196 | The options from each group can be freely mixed as they are | |
20197 | non-overlapping. However, in case of any conflicts, | |
20198 | the later options override the earlier options on the command | |
20199 | line. | |
20200 | ||
20201 | The following options control which kinds of messages should be emitted: | |
20202 | ||
20203 | @table @samp | |
20204 | @item optimized | |
20205 | Print information when an optimization is successfully applied. It is | |
20206 | up to a pass to decide which information is relevant. For example, the | |
20207 | vectorizer passes print the source location of loops which are | |
20208 | successfully vectorized. | |
20209 | @item missed | |
20210 | Print information about missed optimizations. Individual passes | |
20211 | control which information to include in the output. | |
20212 | @item note | |
20213 | Print verbose information about optimizations, such as certain | |
20214 | transformations, more detailed messages about decisions etc. | |
20215 | @item all | |
20216 | Print detailed optimization information. This includes | |
20217 | @samp{optimized}, @samp{missed}, and @samp{note}. | |
20218 | @end table | |
20219 | ||
20220 | The following option controls the dump verbosity: | |
20221 | ||
20222 | @table @samp | |
20223 | @item internals | |
20224 | By default, only ``high-level'' messages are emitted. This option enables | |
20225 | additional, more detailed, messages, which are likely to only be of interest | |
20226 | to GCC developers. | |
20227 | @end table | |
20228 | ||
20229 | One or more of the following option keywords can be used to describe a | |
20230 | group of optimizations: | |
20231 | ||
20232 | @table @samp | |
20233 | @item ipa | |
20234 | Enable dumps from all interprocedural optimizations. | |
20235 | @item loop | |
20236 | Enable dumps from all loop optimizations. | |
20237 | @item inline | |
20238 | Enable dumps from all inlining optimizations. | |
20239 | @item omp | |
20240 | Enable dumps from all OMP (Offloading and Multi Processing) optimizations. | |
20241 | @item vec | |
20242 | Enable dumps from all vectorization optimizations. | |
20243 | @item optall | |
20244 | Enable dumps from all optimizations. This is a superset of | |
20245 | the optimization groups listed above. | |
20246 | @end table | |
20247 | ||
20248 | If @var{options} is | |
20249 | omitted, it defaults to @samp{optimized-optall}, which means to dump messages | |
20250 | about successful optimizations from all the passes, omitting messages | |
20251 | that are treated as ``internals''. | |
20252 | ||
20253 | If the @var{filename} is provided, then the dumps from all the | |
20254 | applicable optimizations are concatenated into the @var{filename}. | |
20255 | Otherwise the dump is output onto @file{stderr}. Though multiple | |
20256 | @option{-fopt-info} options are accepted, only one of them can include | |
20257 | a @var{filename}. If other filenames are provided then all but the | |
20258 | first such option are ignored. | |
20259 | ||
20260 | Note that the output @var{filename} is overwritten | |
20261 | in case of multiple translation units. If a combined output from | |
20262 | multiple translation units is desired, @file{stderr} should be used | |
20263 | instead. | |
20264 | ||
20265 | In the following example, the optimization info is output to | |
20266 | @file{stderr}: | |
20267 | ||
20268 | @smallexample | |
20269 | gcc -O3 -fopt-info | |
20270 | @end smallexample | |
20271 | ||
20272 | This example: | |
20273 | @smallexample | |
20274 | gcc -O3 -fopt-info-missed=missed.all | |
20275 | @end smallexample | |
20276 | ||
20277 | @noindent | |
20278 | outputs missed optimization report from all the passes into | |
20279 | @file{missed.all}, and this one: | |
20280 | ||
20281 | @smallexample | |
20282 | gcc -O2 -ftree-vectorize -fopt-info-vec-missed | |
20283 | @end smallexample | |
20284 | ||
20285 | @noindent | |
20286 | prints information about missed optimization opportunities from | |
20287 | vectorization passes on @file{stderr}. | |
20288 | Note that @option{-fopt-info-vec-missed} is equivalent to | |
20289 | @option{-fopt-info-missed-vec}. The order of the optimization group | |
20290 | names and message types listed after @option{-fopt-info} does not matter. | |
20291 | ||
20292 | As another example, | |
20293 | @smallexample | |
20294 | gcc -O3 -fopt-info-inline-optimized-missed=inline.txt | |
20295 | @end smallexample | |
20296 | ||
20297 | @noindent | |
20298 | outputs information about missed optimizations as well as | |
20299 | optimized locations from all the inlining passes into | |
20300 | @file{inline.txt}. | |
20301 | ||
20302 | Finally, consider: | |
20303 | ||
20304 | @smallexample | |
20305 | gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt | |
20306 | @end smallexample | |
20307 | ||
20308 | @noindent | |
20309 | Here the two output filenames @file{vec.miss} and @file{loop.opt} are | |
20310 | in conflict since only one output file is allowed. In this case, only | |
20311 | the first option takes effect and the subsequent options are | |
20312 | ignored. Thus only @file{vec.miss} is produced which contains | |
20313 | dumps from the vectorizer about missed opportunities. | |
20314 | ||
d77de738 | 20315 | @opindex fsave-optimization-record |
ddf6fe37 | 20316 | @item -fsave-optimization-record |
d77de738 ML |
20317 | Write a SRCFILE.opt-record.json.gz file detailing what optimizations |
20318 | were performed, for those optimizations that support @option{-fopt-info}. | |
20319 | ||
20320 | This option is experimental and the format of the data within the | |
20321 | compressed JSON file is subject to change. | |
20322 | ||
20323 | It is roughly equivalent to a machine-readable version of | |
20324 | @option{-fopt-info-all}, as a collection of messages with source file, | |
20325 | line number and column number, with the following additional data for | |
20326 | each message: | |
20327 | ||
20328 | @itemize @bullet | |
20329 | ||
20330 | @item | |
20331 | the execution count of the code being optimized, along with metadata about | |
20332 | whether this was from actual profile data, or just an estimate, allowing | |
20333 | consumers to prioritize messages by code hotness, | |
20334 | ||
20335 | @item | |
20336 | the function name of the code being optimized, where applicable, | |
20337 | ||
20338 | @item | |
20339 | the ``inlining chain'' for the code being optimized, so that when | |
20340 | a function is inlined into several different places (which might | |
20341 | themselves be inlined), the reader can distinguish between the copies, | |
20342 | ||
20343 | @item | |
20344 | objects identifying those parts of the message that refer to expressions, | |
20345 | statements or symbol-table nodes, which of these categories they are, and, | |
20346 | when available, their source code location, | |
20347 | ||
20348 | @item | |
20349 | the GCC pass that emitted the message, and | |
20350 | ||
20351 | @item | |
20352 | the location in GCC's own code from which the message was emitted | |
20353 | ||
20354 | @end itemize | |
20355 | ||
20356 | Additionally, some messages are logically nested within other | |
20357 | messages, reflecting implementation details of the optimization | |
20358 | passes. | |
20359 | ||
d77de738 | 20360 | @opindex fsched-verbose |
ddf6fe37 | 20361 | @item -fsched-verbose=@var{n} |
d77de738 ML |
20362 | On targets that use instruction scheduling, this option controls the |
20363 | amount of debugging output the scheduler prints to the dump files. | |
20364 | ||
20365 | For @var{n} greater than zero, @option{-fsched-verbose} outputs the | |
20366 | same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}. | |
20367 | For @var{n} greater than one, it also output basic block probabilities, | |
20368 | detailed ready list information and unit/insn info. For @var{n} greater | |
20369 | than two, it includes RTL at abort point, control-flow and regions info. | |
20370 | And for @var{n} over four, @option{-fsched-verbose} also includes | |
20371 | dependence info. | |
20372 | ||
20373 | ||
20374 | ||
d77de738 ML |
20375 | @opindex fdisable- |
20376 | @opindex fenable- | |
ddf6fe37 AA |
20377 | @item -fenable-@var{kind}-@var{pass} |
20378 | @itemx -fdisable-@var{kind}-@var{pass}=@var{range-list} | |
d77de738 ML |
20379 | |
20380 | This is a set of options that are used to explicitly disable/enable | |
20381 | optimization passes. These options are intended for use for debugging GCC. | |
20382 | Compiler users should use regular options for enabling/disabling | |
20383 | passes instead. | |
20384 | ||
20385 | @table @gcctabopt | |
20386 | ||
20387 | @item -fdisable-ipa-@var{pass} | |
20388 | Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
20389 | statically invoked in the compiler multiple times, the pass name should be | |
20390 | appended with a sequential number starting from 1. | |
20391 | ||
20392 | @item -fdisable-rtl-@var{pass} | |
20393 | @itemx -fdisable-rtl-@var{pass}=@var{range-list} | |
20394 | Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
20395 | statically invoked in the compiler multiple times, the pass name should be | |
20396 | appended with a sequential number starting from 1. @var{range-list} is a | |
20397 | comma-separated list of function ranges or assembler names. Each range is a number | |
20398 | pair separated by a colon. The range is inclusive in both ends. If the range | |
20399 | is trivial, the number pair can be simplified as a single number. If the | |
20400 | function's call graph node's @var{uid} falls within one of the specified ranges, | |
20401 | the @var{pass} is disabled for that function. The @var{uid} is shown in the | |
20402 | function header of a dump file, and the pass names can be dumped by using | |
20403 | option @option{-fdump-passes}. | |
20404 | ||
20405 | @item -fdisable-tree-@var{pass} | |
20406 | @itemx -fdisable-tree-@var{pass}=@var{range-list} | |
20407 | Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of | |
20408 | option arguments. | |
20409 | ||
20410 | @item -fenable-ipa-@var{pass} | |
20411 | Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
20412 | statically invoked in the compiler multiple times, the pass name should be | |
20413 | appended with a sequential number starting from 1. | |
20414 | ||
20415 | @item -fenable-rtl-@var{pass} | |
20416 | @itemx -fenable-rtl-@var{pass}=@var{range-list} | |
20417 | Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument | |
20418 | description and examples. | |
20419 | ||
20420 | @item -fenable-tree-@var{pass} | |
20421 | @itemx -fenable-tree-@var{pass}=@var{range-list} | |
20422 | Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description | |
20423 | of option arguments. | |
20424 | ||
20425 | @end table | |
20426 | ||
20427 | Here are some examples showing uses of these options. | |
20428 | ||
20429 | @smallexample | |
20430 | ||
20431 | # disable ccp1 for all functions | |
20432 | -fdisable-tree-ccp1 | |
20433 | # disable complete unroll for function whose cgraph node uid is 1 | |
20434 | -fenable-tree-cunroll=1 | |
20435 | # disable gcse2 for functions at the following ranges [1,1], | |
20436 | # [300,400], and [400,1000] | |
20437 | # disable gcse2 for functions foo and foo2 | |
20438 | -fdisable-rtl-gcse2=foo,foo2 | |
20439 | # disable early inlining | |
20440 | -fdisable-tree-einline | |
20441 | # disable ipa inlining | |
20442 | -fdisable-ipa-inline | |
20443 | # enable tree full unroll | |
20444 | -fenable-tree-unroll | |
20445 | ||
20446 | @end smallexample | |
20447 | ||
d77de738 ML |
20448 | @opindex fchecking |
20449 | @opindex fno-checking | |
ddf6fe37 AA |
20450 | @item -fchecking |
20451 | @itemx -fchecking=@var{n} | |
d77de738 ML |
20452 | Enable internal consistency checking. The default depends on |
20453 | the compiler configuration. @option{-fchecking=2} enables further | |
20454 | internal consistency checking that might affect code generation. | |
20455 | ||
d77de738 | 20456 | @opindex frandom-seed |
ddf6fe37 | 20457 | @item -frandom-seed=@var{string} |
d77de738 ML |
20458 | This option provides a seed that GCC uses in place of |
20459 | random numbers in generating certain symbol names | |
20460 | that have to be different in every compiled file. It is also used to | |
20461 | place unique stamps in coverage data files and the object files that | |
20462 | produce them. You can use the @option{-frandom-seed} option to produce | |
20463 | reproducibly identical object files. | |
20464 | ||
20465 | The @var{string} can either be a number (decimal, octal or hex) or an | |
20466 | arbitrary string (in which case it's converted to a number by | |
20467 | computing CRC32). | |
20468 | ||
20469 | The @var{string} should be different for every file you compile. | |
20470 | ||
d77de738 | 20471 | @opindex save-temps |
ddf6fe37 | 20472 | @item -save-temps |
d77de738 ML |
20473 | Store the usual ``temporary'' intermediate files permanently; name them |
20474 | as auxiliary output files, as specified described under | |
20475 | @option{-dumpbase} and @option{-dumpdir}. | |
20476 | ||
20477 | When used in combination with the @option{-x} command-line option, | |
20478 | @option{-save-temps} is sensible enough to avoid overwriting an | |
20479 | input source file with the same extension as an intermediate file. | |
20480 | The corresponding intermediate file may be obtained by renaming the | |
20481 | source file before using @option{-save-temps}. | |
20482 | ||
d77de738 | 20483 | @opindex save-temps=cwd |
ddf6fe37 | 20484 | @item -save-temps=cwd |
d77de738 ML |
20485 | Equivalent to @option{-save-temps -dumpdir ./}. |
20486 | ||
d77de738 | 20487 | @opindex save-temps=obj |
ddf6fe37 | 20488 | @item -save-temps=obj |
d77de738 ML |
20489 | Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where |
20490 | @file{outdir/} is the directory of the output file specified after the | |
20491 | @option{-o} option, including any directory separators. If the | |
20492 | @option{-o} option is not used, the @option{-save-temps=obj} switch | |
20493 | behaves like @option{-save-temps=cwd}. | |
20494 | ||
d77de738 | 20495 | @opindex time |
ddf6fe37 | 20496 | @item -time@r{[}=@var{file}@r{]} |
d77de738 ML |
20497 | Report the CPU time taken by each subprocess in the compilation |
20498 | sequence. For C source files, this is the compiler proper and assembler | |
20499 | (plus the linker if linking is done). | |
20500 | ||
20501 | Without the specification of an output file, the output looks like this: | |
20502 | ||
20503 | @smallexample | |
20504 | # cc1 0.12 0.01 | |
20505 | # as 0.00 0.01 | |
20506 | @end smallexample | |
20507 | ||
20508 | The first number on each line is the ``user time'', that is time spent | |
20509 | executing the program itself. The second number is ``system time'', | |
20510 | time spent executing operating system routines on behalf of the program. | |
20511 | Both numbers are in seconds. | |
20512 | ||
20513 | With the specification of an output file, the output is appended to the | |
20514 | named file, and it looks like this: | |
20515 | ||
20516 | @smallexample | |
20517 | 0.12 0.01 cc1 @var{options} | |
20518 | 0.00 0.01 as @var{options} | |
20519 | @end smallexample | |
20520 | ||
20521 | The ``user time'' and the ``system time'' are moved before the program | |
20522 | name, and the options passed to the program are displayed, so that one | |
20523 | can later tell what file was being compiled, and with which options. | |
20524 | ||
d77de738 | 20525 | @opindex fdump-final-insns |
ddf6fe37 | 20526 | @item -fdump-final-insns@r{[}=@var{file}@r{]} |
d77de738 ML |
20527 | Dump the final internal representation (RTL) to @var{file}. If the |
20528 | optional argument is omitted (or if @var{file} is @code{.}), the name | |
20529 | of the dump file is determined by appending @code{.gkd} to the | |
20530 | dump base name, see @option{-dumpbase}. | |
20531 | ||
d77de738 ML |
20532 | @opindex fcompare-debug |
20533 | @opindex fno-compare-debug | |
ddf6fe37 | 20534 | @item -fcompare-debug@r{[}=@var{opts}@r{]} |
d77de738 ML |
20535 | If no error occurs during compilation, run the compiler a second time, |
20536 | adding @var{opts} and @option{-fcompare-debug-second} to the arguments | |
20537 | passed to the second compilation. Dump the final internal | |
20538 | representation in both compilations, and print an error if they differ. | |
20539 | ||
20540 | If the equal sign is omitted, the default @option{-gtoggle} is used. | |
20541 | ||
20542 | The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty | |
20543 | and nonzero, implicitly enables @option{-fcompare-debug}. If | |
20544 | @env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash, | |
20545 | then it is used for @var{opts}, otherwise the default @option{-gtoggle} | |
20546 | is used. | |
20547 | ||
20548 | @option{-fcompare-debug=}, with the equal sign but without @var{opts}, | |
20549 | is equivalent to @option{-fno-compare-debug}, which disables the dumping | |
20550 | of the final representation and the second compilation, preventing even | |
20551 | @env{GCC_COMPARE_DEBUG} from taking effect. | |
20552 | ||
20553 | To verify full coverage during @option{-fcompare-debug} testing, set | |
20554 | @env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden}, | |
20555 | which GCC rejects as an invalid option in any actual compilation | |
20556 | (rather than preprocessing, assembly or linking). To get just a | |
20557 | warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug | |
20558 | not overridden} will do. | |
20559 | ||
d77de738 | 20560 | @opindex fcompare-debug-second |
ddf6fe37 | 20561 | @item -fcompare-debug-second |
d77de738 ML |
20562 | This option is implicitly passed to the compiler for the second |
20563 | compilation requested by @option{-fcompare-debug}, along with options to | |
20564 | silence warnings, and omitting other options that would cause the compiler | |
20565 | to produce output to files or to standard output as a side effect. Dump | |
20566 | files and preserved temporary files are renamed so as to contain the | |
20567 | @code{.gk} additional extension during the second compilation, to avoid | |
20568 | overwriting those generated by the first. | |
20569 | ||
20570 | When this option is passed to the compiler driver, it causes the | |
20571 | @emph{first} compilation to be skipped, which makes it useful for little | |
20572 | other than debugging the compiler proper. | |
20573 | ||
d77de738 | 20574 | @opindex gtoggle |
ddf6fe37 | 20575 | @item -gtoggle |
d77de738 ML |
20576 | Turn off generation of debug info, if leaving out this option |
20577 | generates it, or turn it on at level 2 otherwise. The position of this | |
20578 | argument in the command line does not matter; it takes effect after all | |
20579 | other options are processed, and it does so only once, no matter how | |
20580 | many times it is given. This is mainly intended to be used with | |
20581 | @option{-fcompare-debug}. | |
20582 | ||
d77de738 ML |
20583 | @opindex fvar-tracking-assignments-toggle |
20584 | @opindex fno-var-tracking-assignments-toggle | |
ddf6fe37 | 20585 | @item -fvar-tracking-assignments-toggle |
d77de738 ML |
20586 | Toggle @option{-fvar-tracking-assignments}, in the same way that |
20587 | @option{-gtoggle} toggles @option{-g}. | |
20588 | ||
d77de738 | 20589 | @opindex Q |
ddf6fe37 | 20590 | @item -Q |
d77de738 ML |
20591 | Makes the compiler print out each function name as it is compiled, and |
20592 | print some statistics about each pass when it finishes. | |
20593 | ||
d77de738 | 20594 | @opindex ftime-report |
ddf6fe37 | 20595 | @item -ftime-report |
75d62394 DM |
20596 | Makes the compiler print some statistics to stderr about the time consumed |
20597 | by each pass when it finishes. | |
20598 | ||
20599 | If SARIF output of diagnostics was requested via | |
20600 | @option{-fdiagnostics-format=sarif-file} or | |
20601 | @option{-fdiagnostics-format=sarif-stderr} then the @option{-ftime-report} | |
20602 | information is instead emitted in JSON form as part of SARIF output. The | |
20603 | precise format of this JSON data is subject to change, and the values may | |
20604 | not exactly match those emitted to stderr due to being written out at a | |
20605 | slightly different place within the compiler. | |
d77de738 | 20606 | |
d77de738 | 20607 | @opindex ftime-report-details |
ddf6fe37 | 20608 | @item -ftime-report-details |
d77de738 ML |
20609 | Record the time consumed by infrastructure parts separately for each pass. |
20610 | ||
d77de738 | 20611 | @opindex fira-verbose |
ddf6fe37 | 20612 | @item -fira-verbose=@var{n} |
d77de738 ML |
20613 | Control the verbosity of the dump file for the integrated register allocator. |
20614 | The default value is 5. If the value @var{n} is greater or equal to 10, | |
20615 | the dump output is sent to stderr using the same format as @var{n} minus 10. | |
20616 | ||
d77de738 | 20617 | @opindex flto-report |
ddf6fe37 | 20618 | @item -flto-report |
d77de738 ML |
20619 | Prints a report with internal details on the workings of the link-time |
20620 | optimizer. The contents of this report vary from version to version. | |
20621 | It is meant to be useful to GCC developers when processing object | |
20622 | files in LTO mode (via @option{-flto}). | |
20623 | ||
20624 | Disabled by default. | |
20625 | ||
d77de738 | 20626 | @opindex flto-report-wpa |
ddf6fe37 | 20627 | @item -flto-report-wpa |
d77de738 ML |
20628 | Like @option{-flto-report}, but only print for the WPA phase of link-time |
20629 | optimization. | |
20630 | ||
d77de738 | 20631 | @opindex fmem-report |
ddf6fe37 | 20632 | @item -fmem-report |
d77de738 ML |
20633 | Makes the compiler print some statistics about permanent memory |
20634 | allocation when it finishes. | |
20635 | ||
d77de738 | 20636 | @opindex fmem-report-wpa |
ddf6fe37 | 20637 | @item -fmem-report-wpa |
d77de738 ML |
20638 | Makes the compiler print some statistics about permanent memory |
20639 | allocation for the WPA phase only. | |
20640 | ||
d77de738 | 20641 | @opindex fpre-ipa-mem-report |
d77de738 | 20642 | @opindex fpost-ipa-mem-report |
ddf6fe37 AA |
20643 | @item -fpre-ipa-mem-report |
20644 | @item -fpost-ipa-mem-report | |
d77de738 ML |
20645 | Makes the compiler print some statistics about permanent memory |
20646 | allocation before or after interprocedural optimization. | |
20647 | ||
d77de738 | 20648 | @opindex fmultiflags |
ddf6fe37 | 20649 | @item -fmultiflags |
d77de738 ML |
20650 | This option enables multilib-aware @code{TFLAGS} to be used to build |
20651 | target libraries with options different from those the compiler is | |
8e0568d8 AO |
20652 | configured to use by default, through the use of specs (@pxref{Spec |
20653 | Files}) set up by compiler internals, by the target, or by builders at | |
d77de738 ML |
20654 | configure time. |
20655 | ||
20656 | Like @code{TFLAGS}, this allows the target libraries to be built for | |
20657 | portable baseline environments, while the compiler defaults to more | |
20658 | demanding ones. That's useful because users can easily override the | |
20659 | defaults the compiler is configured to use to build their own programs, | |
20660 | if the defaults are not ideal for their target environment, whereas | |
20661 | rebuilding the runtime libraries is usually not as easy or desirable. | |
20662 | ||
20663 | Unlike @code{TFLAGS}, the use of specs enables different flags to be | |
20664 | selected for different multilibs. The way to accomplish that is to | |
20665 | build with @samp{make TFLAGS=-fmultiflags}, after configuring | |
20666 | @samp{--with-specs=%@{fmultiflags:...@}}. | |
20667 | ||
20668 | This option is discarded by the driver once it's done processing driver | |
20669 | self spec. | |
20670 | ||
20671 | It is also useful to check that @code{TFLAGS} are being used to build | |
20672 | all target libraries, by configuring a non-bootstrap compiler | |
20673 | @samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building | |
20674 | the compiler and target libraries. | |
20675 | ||
d77de738 | 20676 | @opindex fprofile-report |
ddf6fe37 | 20677 | @item -fprofile-report |
d77de738 ML |
20678 | Makes the compiler print some statistics about consistency of the |
20679 | (estimated) profile and effect of individual passes. | |
20680 | ||
d77de738 | 20681 | @opindex fstack-usage |
ddf6fe37 | 20682 | @item -fstack-usage |
d77de738 ML |
20683 | Makes the compiler output stack usage information for the program, on a |
20684 | per-function basis. The filename for the dump is made by appending | |
20685 | @file{.su} to the @var{auxname}. @var{auxname} is generated from the name of | |
20686 | the output file, if explicitly specified and it is not an executable, | |
20687 | otherwise it is the basename of the source file. An entry is made up | |
20688 | of three fields: | |
20689 | ||
20690 | @itemize | |
20691 | @item | |
20692 | The name of the function. | |
20693 | @item | |
20694 | A number of bytes. | |
20695 | @item | |
20696 | One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}. | |
20697 | @end itemize | |
20698 | ||
20699 | The qualifier @code{static} means that the function manipulates the stack | |
20700 | statically: a fixed number of bytes are allocated for the frame on function | |
20701 | entry and released on function exit; no stack adjustments are otherwise made | |
20702 | in the function. The second field is this fixed number of bytes. | |
20703 | ||
20704 | The qualifier @code{dynamic} means that the function manipulates the stack | |
20705 | dynamically: in addition to the static allocation described above, stack | |
20706 | adjustments are made in the body of the function, for example to push/pop | |
20707 | arguments around function calls. If the qualifier @code{bounded} is also | |
20708 | present, the amount of these adjustments is bounded at compile time and | |
20709 | the second field is an upper bound of the total amount of stack used by | |
20710 | the function. If it is not present, the amount of these adjustments is | |
20711 | not bounded at compile time and the second field only represents the | |
20712 | bounded part. | |
20713 | ||
d77de738 | 20714 | @opindex fstats |
ddf6fe37 | 20715 | @item -fstats |
d77de738 ML |
20716 | Emit statistics about front-end processing at the end of the compilation. |
20717 | This option is supported only by the C++ front end, and | |
20718 | the information is generally only useful to the G++ development team. | |
20719 | ||
d77de738 | 20720 | @opindex fdbg-cnt-list |
ddf6fe37 | 20721 | @item -fdbg-cnt-list |
d77de738 ML |
20722 | Print the name and the counter upper bound for all debug counters. |
20723 | ||
20724 | ||
d77de738 | 20725 | @opindex fdbg-cnt |
ddf6fe37 | 20726 | @item -fdbg-cnt=@var{counter-value-list} |
d77de738 ML |
20727 | Set the internal debug counter lower and upper bound. @var{counter-value-list} |
20728 | is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1} | |
20729 | [:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets | |
20730 | the name of the counter and list of closed intervals. | |
20731 | The @var{lower_bound} is optional and is zero | |
20732 | initialized if not set. | |
20733 | For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10}, | |
20734 | @code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and | |
20735 | eleventh invocation. | |
20736 | For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations. | |
20737 | ||
d77de738 | 20738 | @opindex print-file-name |
ddf6fe37 | 20739 | @item -print-file-name=@var{library} |
d77de738 ML |
20740 | Print the full absolute name of the library file @var{library} that |
20741 | would be used when linking---and don't do anything else. With this | |
20742 | option, GCC does not compile or link anything; it just prints the | |
20743 | file name. | |
20744 | ||
d77de738 | 20745 | @opindex print-multi-directory |
ddf6fe37 | 20746 | @item -print-multi-directory |
d77de738 ML |
20747 | Print the directory name corresponding to the multilib selected by any |
20748 | other switches present in the command line. This directory is supposed | |
20749 | to exist in @env{GCC_EXEC_PREFIX}. | |
20750 | ||
d77de738 | 20751 | @opindex print-multi-lib |
ddf6fe37 | 20752 | @item -print-multi-lib |
d77de738 ML |
20753 | Print the mapping from multilib directory names to compiler switches |
20754 | that enable them. The directory name is separated from the switches by | |
20755 | @samp{;}, and each switch starts with an @samp{@@} instead of the | |
20756 | @samp{-}, without spaces between multiple switches. This is supposed to | |
20757 | ease shell processing. | |
20758 | ||
d77de738 | 20759 | @opindex print-multi-os-directory |
ddf6fe37 | 20760 | @item -print-multi-os-directory |
d77de738 ML |
20761 | Print the path to OS libraries for the selected |
20762 | multilib, relative to some @file{lib} subdirectory. If OS libraries are | |
20763 | present in the @file{lib} subdirectory and no multilibs are used, this is | |
20764 | usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}} | |
20765 | sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or | |
20766 | @file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}} | |
20767 | subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}. | |
20768 | ||
d77de738 | 20769 | @opindex print-multiarch |
ddf6fe37 | 20770 | @item -print-multiarch |
d77de738 ML |
20771 | Print the path to OS libraries for the selected multiarch, |
20772 | relative to some @file{lib} subdirectory. | |
20773 | ||
d77de738 | 20774 | @opindex print-prog-name |
ddf6fe37 | 20775 | @item -print-prog-name=@var{program} |
d77de738 ML |
20776 | Like @option{-print-file-name}, but searches for a program such as @command{cpp}. |
20777 | ||
d77de738 | 20778 | @opindex print-libgcc-file-name |
ddf6fe37 | 20779 | @item -print-libgcc-file-name |
d77de738 ML |
20780 | Same as @option{-print-file-name=libgcc.a}. |
20781 | ||
20782 | This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs} | |
20783 | but you do want to link with @file{libgcc.a}. You can do: | |
20784 | ||
20785 | @smallexample | |
20786 | gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name` | |
20787 | @end smallexample | |
20788 | ||
d77de738 | 20789 | @opindex print-search-dirs |
ddf6fe37 | 20790 | @item -print-search-dirs |
d77de738 ML |
20791 | Print the name of the configured installation directory and a list of |
20792 | program and library directories @command{gcc} searches---and don't do anything else. | |
20793 | ||
20794 | This is useful when @command{gcc} prints the error message | |
20795 | @samp{installation problem, cannot exec cpp0: No such file or directory}. | |
20796 | To resolve this you either need to put @file{cpp0} and the other compiler | |
20797 | components where @command{gcc} expects to find them, or you can set the environment | |
20798 | variable @env{GCC_EXEC_PREFIX} to the directory where you installed them. | |
20799 | Don't forget the trailing @samp{/}. | |
20800 | @xref{Environment Variables}. | |
20801 | ||
d77de738 | 20802 | @opindex print-sysroot |
ddf6fe37 | 20803 | @item -print-sysroot |
d77de738 ML |
20804 | Print the target sysroot directory that is used during |
20805 | compilation. This is the target sysroot specified either at configure | |
20806 | time or using the @option{--sysroot} option, possibly with an extra | |
20807 | suffix that depends on compilation options. If no target sysroot is | |
20808 | specified, the option prints nothing. | |
20809 | ||
d77de738 | 20810 | @opindex print-sysroot-headers-suffix |
ddf6fe37 | 20811 | @item -print-sysroot-headers-suffix |
d77de738 ML |
20812 | Print the suffix added to the target sysroot when searching for |
20813 | headers, or give an error if the compiler is not configured with such | |
20814 | a suffix---and don't do anything else. | |
20815 | ||
d77de738 | 20816 | @opindex dumpmachine |
ddf6fe37 | 20817 | @item -dumpmachine |
d77de738 ML |
20818 | Print the compiler's target machine (for example, |
20819 | @samp{i686-pc-linux-gnu})---and don't do anything else. | |
20820 | ||
d77de738 | 20821 | @opindex dumpversion |
ddf6fe37 | 20822 | @item -dumpversion |
d77de738 ML |
20823 | Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do |
20824 | anything else. This is the compiler version used in filesystem paths and | |
20825 | specs. Depending on how the compiler has been configured it can be just | |
20826 | a single number (major version), two numbers separated by a dot (major and | |
20827 | minor version) or three numbers separated by dots (major, minor and patchlevel | |
20828 | version). | |
20829 | ||
d77de738 | 20830 | @opindex dumpfullversion |
ddf6fe37 | 20831 | @item -dumpfullversion |
d77de738 ML |
20832 | Print the full compiler version---and don't do anything else. The output is |
20833 | always three numbers separated by dots, major, minor and patchlevel version. | |
20834 | ||
d77de738 | 20835 | @opindex dumpspecs |
ddf6fe37 | 20836 | @item -dumpspecs |
d77de738 ML |
20837 | Print the compiler's built-in specs---and don't do anything else. (This |
20838 | is used when GCC itself is being built.) @xref{Spec Files}. | |
20839 | @end table | |
20840 | ||
20841 | @node Submodel Options | |
20842 | @section Machine-Dependent Options | |
20843 | @cindex submodel options | |
20844 | @cindex specifying hardware config | |
20845 | @cindex hardware models and configurations, specifying | |
20846 | @cindex target-dependent options | |
20847 | @cindex machine-dependent options | |
20848 | ||
20849 | Each target machine supported by GCC can have its own options---for | |
20850 | example, to allow you to compile for a particular processor variant or | |
20851 | ABI, or to control optimizations specific to that machine. By | |
20852 | convention, the names of machine-specific options start with | |
20853 | @samp{-m}. | |
20854 | ||
20855 | Some configurations of the compiler also support additional target-specific | |
20856 | options, usually for compatibility with other compilers on the same | |
20857 | platform. | |
20858 | ||
20859 | @c This list is ordered alphanumerically by subsection name. | |
20860 | @c It should be the same order and spelling as these options are listed | |
20861 | @c in Machine Dependent Options | |
20862 | ||
20863 | @menu | |
20864 | * AArch64 Options:: | |
20865 | * Adapteva Epiphany Options:: | |
20866 | * AMD GCN Options:: | |
20867 | * ARC Options:: | |
20868 | * ARM Options:: | |
20869 | * AVR Options:: | |
20870 | * Blackfin Options:: | |
20871 | * C6X Options:: | |
20872 | * CRIS Options:: | |
20873 | * C-SKY Options:: | |
20874 | * Darwin Options:: | |
20875 | * DEC Alpha Options:: | |
20876 | * eBPF Options:: | |
20877 | * FR30 Options:: | |
20878 | * FT32 Options:: | |
20879 | * FRV Options:: | |
20880 | * GNU/Linux Options:: | |
20881 | * H8/300 Options:: | |
20882 | * HPPA Options:: | |
20883 | * IA-64 Options:: | |
20884 | * LM32 Options:: | |
20885 | * LoongArch Options:: | |
20886 | * M32C Options:: | |
20887 | * M32R/D Options:: | |
20888 | * M680x0 Options:: | |
20889 | * MCore Options:: | |
d77de738 ML |
20890 | * MicroBlaze Options:: |
20891 | * MIPS Options:: | |
20892 | * MMIX Options:: | |
20893 | * MN10300 Options:: | |
20894 | * Moxie Options:: | |
20895 | * MSP430 Options:: | |
20896 | * NDS32 Options:: | |
20897 | * Nios II Options:: | |
20898 | * Nvidia PTX Options:: | |
20899 | * OpenRISC Options:: | |
20900 | * PDP-11 Options:: | |
d77de738 ML |
20901 | * PowerPC Options:: |
20902 | * PRU Options:: | |
20903 | * RISC-V Options:: | |
20904 | * RL78 Options:: | |
20905 | * RS/6000 and PowerPC Options:: | |
20906 | * RX Options:: | |
20907 | * S/390 and zSeries Options:: | |
d77de738 ML |
20908 | * SH Options:: |
20909 | * Solaris 2 Options:: | |
20910 | * SPARC Options:: | |
20911 | * System V Options:: | |
20912 | * V850 Options:: | |
20913 | * VAX Options:: | |
20914 | * Visium Options:: | |
20915 | * VMS Options:: | |
20916 | * VxWorks Options:: | |
20917 | * x86 Options:: | |
20918 | * x86 Windows Options:: | |
20919 | * Xstormy16 Options:: | |
20920 | * Xtensa Options:: | |
20921 | * zSeries Options:: | |
20922 | @end menu | |
20923 | ||
20924 | @node AArch64 Options | |
20925 | @subsection AArch64 Options | |
20926 | @cindex AArch64 Options | |
20927 | ||
20928 | These options are defined for AArch64 implementations: | |
20929 | ||
20930 | @table @gcctabopt | |
20931 | ||
d77de738 | 20932 | @opindex mabi |
ddf6fe37 | 20933 | @item -mabi=@var{name} |
d77de738 ML |
20934 | Generate code for the specified data model. Permissible values |
20935 | are @samp{ilp32} for SysV-like data model where int, long int and pointers | |
20936 | are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits, | |
20937 | but long int and pointers are 64 bits. | |
20938 | ||
20939 | The default depends on the specific target configuration. Note that | |
20940 | the LP64 and ILP32 ABIs are not link-compatible; you must compile your | |
20941 | entire program with the same ABI, and link with a compatible set of libraries. | |
20942 | ||
d77de738 | 20943 | @opindex mbig-endian |
ddf6fe37 | 20944 | @item -mbig-endian |
d77de738 ML |
20945 | Generate big-endian code. This is the default when GCC is configured for an |
20946 | @samp{aarch64_be-*-*} target. | |
20947 | ||
d77de738 | 20948 | @opindex mgeneral-regs-only |
ddf6fe37 | 20949 | @item -mgeneral-regs-only |
d77de738 ML |
20950 | Generate code which uses only the general-purpose registers. This will prevent |
20951 | the compiler from using floating-point and Advanced SIMD registers but will not | |
20952 | impose any restrictions on the assembler. | |
20953 | ||
d77de738 | 20954 | @opindex mlittle-endian |
ddf6fe37 | 20955 | @item -mlittle-endian |
d77de738 ML |
20956 | Generate little-endian code. This is the default when GCC is configured for an |
20957 | @samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target. | |
20958 | ||
d77de738 | 20959 | @opindex mcmodel=tiny |
ddf6fe37 | 20960 | @item -mcmodel=tiny |
d77de738 ML |
20961 | Generate code for the tiny code model. The program and its statically defined |
20962 | symbols must be within 1MB of each other. Programs can be statically or | |
20963 | dynamically linked. | |
20964 | ||
d77de738 | 20965 | @opindex mcmodel=small |
ddf6fe37 | 20966 | @item -mcmodel=small |
d77de738 ML |
20967 | Generate code for the small code model. The program and its statically defined |
20968 | symbols must be within 4GB of each other. Programs can be statically or | |
20969 | dynamically linked. This is the default code model. | |
20970 | ||
d77de738 | 20971 | @opindex mcmodel=large |
ddf6fe37 | 20972 | @item -mcmodel=large |
d77de738 ML |
20973 | Generate code for the large code model. This makes no assumptions about |
20974 | addresses and sizes of sections. Programs can be statically linked only. The | |
20975 | @option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32}, | |
20976 | @option{-fpic} and @option{-fPIC}. | |
20977 | ||
573624ec KT |
20978 | @item -mtp=@var{name} |
20979 | @opindex mtp | |
20980 | Specify the system register to use as a thread pointer. The valid values | |
4389a2d2 KT |
20981 | are @samp{tpidr_el0}, @samp{tpidrro_el0}, @samp{tpidr_el1}, @samp{tpidr_el2}, |
20982 | @samp{tpidr_el3}. For backwards compatibility the aliases @samp{el0}, | |
20983 | @samp{el1}, @samp{el2}, @samp{el3} are also accepted. | |
20984 | The default setting is @samp{tpidr_el0}. It is recommended to compile all | |
20985 | code intended to interoperate with the same value of this option to avoid | |
20986 | accessing a different thread pointer from the wrong exception level. | |
573624ec | 20987 | |
d77de738 ML |
20988 | @opindex mstrict-align |
20989 | @opindex mno-strict-align | |
ddf6fe37 AA |
20990 | @item -mstrict-align |
20991 | @itemx -mno-strict-align | |
d77de738 ML |
20992 | Avoid or allow generating memory accesses that may not be aligned on a natural |
20993 | object boundary as described in the architecture specification. | |
20994 | ||
d77de738 ML |
20995 | @opindex momit-leaf-frame-pointer |
20996 | @opindex mno-omit-leaf-frame-pointer | |
ddf6fe37 AA |
20997 | @item -momit-leaf-frame-pointer |
20998 | @itemx -mno-omit-leaf-frame-pointer | |
d77de738 ML |
20999 | Omit or keep the frame pointer in leaf functions. The former behavior is the |
21000 | default. | |
21001 | ||
d77de738 ML |
21002 | @opindex mstack-protector-guard |
21003 | @opindex mstack-protector-guard-reg | |
21004 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
21005 | @item -mstack-protector-guard=@var{guard} |
21006 | @itemx -mstack-protector-guard-reg=@var{reg} | |
21007 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
21008 | Generate stack protection code using canary at @var{guard}. Supported |
21009 | locations are @samp{global} for a global canary or @samp{sysreg} for a | |
21010 | canary in an appropriate system register. | |
21011 | ||
21012 | With the latter choice the options | |
21013 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
21014 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
21015 | which system register to use as base register for reading the canary, | |
21016 | and from what offset from that base register. There is no default | |
21017 | register or offset as this is entirely for use within the Linux | |
21018 | kernel. | |
21019 | ||
d77de738 | 21020 | @opindex mtls-dialect=desc |
ddf6fe37 | 21021 | @item -mtls-dialect=desc |
d77de738 ML |
21022 | Use TLS descriptors as the thread-local storage mechanism for dynamic accesses |
21023 | of TLS variables. This is the default. | |
21024 | ||
d77de738 | 21025 | @opindex mtls-dialect=traditional |
ddf6fe37 | 21026 | @item -mtls-dialect=traditional |
d77de738 ML |
21027 | Use traditional TLS as the thread-local storage mechanism for dynamic accesses |
21028 | of TLS variables. | |
21029 | ||
d77de738 | 21030 | @opindex mtls-size |
ddf6fe37 | 21031 | @item -mtls-size=@var{size} |
d77de738 ML |
21032 | Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48. |
21033 | This option requires binutils 2.26 or newer. | |
21034 | ||
d77de738 ML |
21035 | @opindex mfix-cortex-a53-835769 |
21036 | @opindex mno-fix-cortex-a53-835769 | |
ddf6fe37 AA |
21037 | @item -mfix-cortex-a53-835769 |
21038 | @itemx -mno-fix-cortex-a53-835769 | |
d77de738 ML |
21039 | Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769. |
21040 | This involves inserting a NOP instruction between memory instructions and | |
21041 | 64-bit integer multiply-accumulate instructions. | |
21042 | ||
d77de738 ML |
21043 | @opindex mfix-cortex-a53-843419 |
21044 | @opindex mno-fix-cortex-a53-843419 | |
ddf6fe37 AA |
21045 | @item -mfix-cortex-a53-843419 |
21046 | @itemx -mno-fix-cortex-a53-843419 | |
d77de738 ML |
21047 | Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419. |
21048 | This erratum workaround is made at link time and this will only pass the | |
21049 | corresponding flag to the linker. | |
21050 | ||
d77de738 ML |
21051 | @opindex mlow-precision-recip-sqrt |
21052 | @opindex mno-low-precision-recip-sqrt | |
ddf6fe37 AA |
21053 | @item -mlow-precision-recip-sqrt |
21054 | @itemx -mno-low-precision-recip-sqrt | |
d77de738 ML |
21055 | Enable or disable the reciprocal square root approximation. |
21056 | This option only has an effect if @option{-ffast-math} or | |
21057 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
21058 | precision of reciprocal square root results to about 16 bits for | |
21059 | single precision and to 32 bits for double precision. | |
21060 | ||
d77de738 ML |
21061 | @opindex mlow-precision-sqrt |
21062 | @opindex mno-low-precision-sqrt | |
ddf6fe37 AA |
21063 | @item -mlow-precision-sqrt |
21064 | @itemx -mno-low-precision-sqrt | |
d77de738 ML |
21065 | Enable or disable the square root approximation. |
21066 | This option only has an effect if @option{-ffast-math} or | |
21067 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
21068 | precision of square root results to about 16 bits for | |
21069 | single precision and to 32 bits for double precision. | |
21070 | If enabled, it implies @option{-mlow-precision-recip-sqrt}. | |
21071 | ||
d77de738 ML |
21072 | @opindex mlow-precision-div |
21073 | @opindex mno-low-precision-div | |
ddf6fe37 AA |
21074 | @item -mlow-precision-div |
21075 | @itemx -mno-low-precision-div | |
d77de738 ML |
21076 | Enable or disable the division approximation. |
21077 | This option only has an effect if @option{-ffast-math} or | |
21078 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
21079 | precision of division results to about 16 bits for | |
21080 | single precision and to 32 bits for double precision. | |
21081 | ||
21082 | @item -mtrack-speculation | |
21083 | @itemx -mno-track-speculation | |
21084 | Enable or disable generation of additional code to track speculative | |
21085 | execution through conditional branches. The tracking state can then | |
21086 | be used by the compiler when expanding calls to | |
21087 | @code{__builtin_speculation_safe_copy} to permit a more efficient code | |
21088 | sequence to be generated. | |
21089 | ||
21090 | @item -moutline-atomics | |
21091 | @itemx -mno-outline-atomics | |
21092 | Enable or disable calls to out-of-line helpers to implement atomic operations. | |
21093 | These helpers will, at runtime, determine if the LSE instructions from | |
21094 | ARMv8.1-A can be used; if not, they will use the load/store-exclusive | |
21095 | instructions that are present in the base ARMv8.0 ISA. | |
21096 | ||
21097 | This option is only applicable when compiling for the base ARMv8.0 | |
21098 | instruction set. If using a later revision, e.g. @option{-march=armv8.1-a} | |
21099 | or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be | |
21100 | used directly. The same applies when using @option{-mcpu=} when the | |
21101 | selected cpu supports the @samp{lse} feature. | |
21102 | This option is on by default. | |
21103 | ||
d77de738 | 21104 | @opindex march |
ddf6fe37 | 21105 | @item -march=@var{name} |
d77de738 ML |
21106 | Specify the name of the target architecture and, optionally, one or |
21107 | more feature modifiers. This option has the form | |
21108 | @option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}. | |
21109 | ||
21110 | The table below summarizes the permissible values for @var{arch} | |
21111 | and the features that they enable by default: | |
21112 | ||
21113 | @multitable @columnfractions 0.20 0.20 0.60 | |
21114 | @headitem @var{arch} value @tab Architecture @tab Includes by default | |
21115 | @item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd} | |
21116 | @item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma} | |
21117 | @item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a} | |
21118 | @item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth} | |
21119 | @item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod} | |
21120 | @item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres} | |
21121 | @item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm} | |
21122 | @item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64} | |
21123 | @item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops} | |
16a05fac | 21124 | @item @samp{armv8.9-a} @tab Armv8.9-a @tab @samp{armv8.8-a} |
d77de738 ML |
21125 | @item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2} |
21126 | @item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm} | |
21127 | @item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64} | |
21128 | @item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops} | |
16a05fac | 21129 | @item @samp{armv9.4-a} @tab Armv9.4-A @tab @samp{armv9.3-a} |
d77de738 ML |
21130 | @item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r} |
21131 | @end multitable | |
21132 | ||
21133 | The value @samp{native} is available on native AArch64 GNU/Linux and | |
21134 | causes the compiler to pick the architecture of the host system. This | |
21135 | option has no effect if the compiler is unable to recognize the | |
21136 | architecture of the host system, | |
21137 | ||
21138 | The permissible values for @var{feature} are listed in the sub-section | |
21139 | on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu} | |
21140 | Feature Modifiers}. Where conflicting feature modifiers are | |
21141 | specified, the right-most feature is used. | |
21142 | ||
21143 | GCC uses @var{name} to determine what kind of instructions it can emit | |
21144 | when generating assembly code. If @option{-march} is specified | |
21145 | without either of @option{-mtune} or @option{-mcpu} also being | |
21146 | specified, the code is tuned to perform well across a range of target | |
21147 | processors implementing the target architecture. | |
21148 | ||
d77de738 | 21149 | @opindex mtune |
ddf6fe37 | 21150 | @item -mtune=@var{name} |
d77de738 ML |
21151 | Specify the name of the target processor for which GCC should tune the |
21152 | performance of the code. Permissible values for this option are: | |
21153 | @samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, | |
21154 | @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, | |
21155 | @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77}, | |
21156 | @samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34}, | |
21157 | @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, | |
21158 | @samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor}, | |
21159 | @samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1}, | |
21160 | @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx}, | |
21161 | @samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan}, | |
21162 | @samp{octeontx}, @samp{octeontx81}, @samp{octeontx83}, | |
21163 | @samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96} | |
21164 | @samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n}, | |
21165 | @samp{octeontx2f95mm}, | |
21166 | @samp{a64fx}, | |
21167 | @samp{thunderx}, @samp{thunderxt88}, | |
21168 | @samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110}, | |
21169 | @samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus}, | |
21170 | @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
21171 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
21172 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}, | |
ce51e843 | 21173 | @samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2}, |
3bfde22c SJ |
21174 | @samp{cortex-x3}, @samp{cortex-x4}, @samp{cortex-a510}, @samp{cortex-a520}, |
21175 | @samp{cortex-a710}, @samp{cortex-a715}, @samp{cortex-a720}, @samp{ampere1}, | |
a0d16e1c | 21176 | @samp{ampere1a}, @samp{ampere1b}, @samp{cobalt-100} and @samp{native}. |
d77de738 ML |
21177 | |
21178 | The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
21179 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
21180 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC | |
21181 | should tune for a big.LITTLE system. | |
21182 | ||
21183 | The value @samp{neoverse-512tvb} specifies that GCC should tune | |
21184 | for Neoverse cores that (a) implement SVE and (b) have a total vector | |
21185 | bandwidth of 512 bits per cycle. In other words, the option tells GCC to | |
21186 | tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic | |
21187 | instructions a cycle and that can execute an equivalent number of SVE | |
21188 | arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE). | |
21189 | This is more general than tuning for a specific core like Neoverse V1 | |
21190 | but is more specific than the default tuning described below. | |
21191 | ||
21192 | Additionally on native AArch64 GNU/Linux systems the value | |
21193 | @samp{native} tunes performance to the host system. This option has no effect | |
21194 | if the compiler is unable to recognize the processor of the host system. | |
21195 | ||
21196 | Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=} | |
21197 | are specified, the code is tuned to perform well across a range | |
21198 | of target processors. | |
21199 | ||
21200 | This option cannot be suffixed by feature modifiers. | |
21201 | ||
d77de738 | 21202 | @opindex mcpu |
ddf6fe37 | 21203 | @item -mcpu=@var{name} |
d77de738 ML |
21204 | Specify the name of the target processor, optionally suffixed by one |
21205 | or more feature modifiers. This option has the form | |
21206 | @option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where | |
21207 | the permissible values for @var{cpu} are the same as those available | |
21208 | for @option{-mtune}. The permissible values for @var{feature} are | |
21209 | documented in the sub-section on | |
21210 | @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu} | |
21211 | Feature Modifiers}. Where conflicting feature modifiers are | |
21212 | specified, the right-most feature is used. | |
21213 | ||
21214 | GCC uses @var{name} to determine what kind of instructions it can emit when | |
21215 | generating assembly code (as if by @option{-march}) and to determine | |
21216 | the target processor for which to tune for performance (as if | |
21217 | by @option{-mtune}). Where this option is used in conjunction | |
21218 | with @option{-march} or @option{-mtune}, those options take precedence | |
21219 | over the appropriate part of this option. | |
21220 | ||
21221 | @option{-mcpu=neoverse-512tvb} is special in that it does not refer | |
21222 | to a specific core, but instead refers to all Neoverse cores that | |
21223 | (a) implement SVE and (b) have a total vector bandwidth of 512 bits | |
21224 | a cycle. Unless overridden by @option{-march}, | |
21225 | @option{-mcpu=neoverse-512tvb} generates code that can run on a | |
21226 | Neoverse V1 core, since Neoverse V1 is the first Neoverse core with | |
21227 | these properties. Unless overridden by @option{-mtune}, | |
21228 | @option{-mcpu=neoverse-512tvb} tunes code in the same way as for | |
21229 | @option{-mtune=neoverse-512tvb}. | |
21230 | ||
d77de738 | 21231 | @opindex moverride |
ddf6fe37 | 21232 | @item -moverride=@var{string} |
d77de738 ML |
21233 | Override tuning decisions made by the back-end in response to a |
21234 | @option{-mtune=} switch. The syntax, semantics, and accepted values | |
21235 | for @var{string} in this option are not guaranteed to be consistent | |
21236 | across releases. | |
21237 | ||
21238 | This option is only intended to be useful when developing GCC. | |
21239 | ||
d77de738 | 21240 | @opindex mverbose-cost-dump |
ddf6fe37 | 21241 | @item -mverbose-cost-dump |
d77de738 ML |
21242 | Enable verbose cost model dumping in the debug dump files. This option is |
21243 | provided for use in debugging the compiler. | |
21244 | ||
d77de738 ML |
21245 | @opindex mpc-relative-literal-loads |
21246 | @opindex mno-pc-relative-literal-loads | |
ddf6fe37 AA |
21247 | @item -mpc-relative-literal-loads |
21248 | @itemx -mno-pc-relative-literal-loads | |
d77de738 ML |
21249 | Enable or disable PC-relative literal loads. With this option literal pools are |
21250 | accessed using a single instruction and emitted after each function. This | |
21251 | limits the maximum size of functions to 1MB. This is enabled by default for | |
21252 | @option{-mcmodel=tiny}. | |
21253 | ||
d77de738 | 21254 | @opindex msign-return-address |
ddf6fe37 | 21255 | @item -msign-return-address=@var{scope} |
d77de738 ML |
21256 | Select the function scope on which return address signing will be applied. |
21257 | Permissible values are @samp{none}, which disables return address signing, | |
21258 | @samp{non-leaf}, which enables pointer signing for functions which are not leaf | |
21259 | functions, and @samp{all}, which enables pointer signing for all functions. The | |
21260 | default value is @samp{none}. This option has been deprecated by | |
21261 | -mbranch-protection. | |
21262 | ||
d77de738 | 21263 | @opindex mbranch-protection |
ddf6fe37 | 21264 | @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti} |
d77de738 ML |
21265 | Select the branch protection features to use. |
21266 | @samp{none} is the default and turns off all types of branch protection. | |
21267 | @samp{standard} turns on all types of branch protection features. If a feature | |
21268 | has additional tuning options, then @samp{standard} sets it to its standard | |
21269 | level. | |
21270 | @samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard | |
21271 | level: signing functions that save the return address to memory (non-leaf | |
21272 | functions will practically always do this) using the a-key. The optional | |
21273 | argument @samp{leaf} can be used to extend the signing to include leaf | |
21274 | functions. The optional argument @samp{b-key} can be used to sign the functions | |
21275 | with the B-key instead of the A-key. | |
21276 | @samp{bti} turns on branch target identification mechanism. | |
21277 | ||
d77de738 | 21278 | @opindex mharden-sls |
ddf6fe37 | 21279 | @item -mharden-sls=@var{opts} |
d77de738 ML |
21280 | Enable compiler hardening against straight line speculation (SLS). |
21281 | @var{opts} is a comma-separated list of the following options: | |
21282 | @table @samp | |
21283 | @item retbr | |
21284 | @item blr | |
21285 | @end table | |
21286 | In addition, @samp{-mharden-sls=all} enables all SLS hardening while | |
21287 | @samp{-mharden-sls=none} disables all SLS hardening. | |
21288 | ||
9f0f7d80 RS |
21289 | @opindex mearly-ra |
21290 | @item -mearly-ra=@var{scope} | |
21291 | Determine when to enable an early register allocation pass. This pass runs | |
21292 | before instruction scheduling and tries to find a spill-free allocation of | |
21293 | floating-point and vector code. It also tries to make use of strided | |
21294 | multi-register instructions, such as SME2's strided LD1 and ST1. | |
21295 | ||
21296 | The possible values of @var{scope} are: @var{all}, which runs the pass on | |
21297 | all functions; @var{strided}, which runs the pass on functions that have | |
21298 | access to strided multi-register instructions; and @var{none}, which | |
21299 | disables the pass. | |
21300 | ||
21301 | @option{-mearly-ra=all} is the default for @option{-O2} and above, and for | |
21302 | @option{-Os}. @option{-mearly-ra=none} is the default otherwise. | |
21303 | ||
c0911c6b AC |
21304 | @opindex mearly-ldp-fusion |
21305 | @item -mearly-ldp-fusion | |
21306 | Enable the copy of the AArch64 load/store pair fusion pass that runs before | |
21307 | register allocation. Enabled by default at @samp{-O} and above. | |
21308 | ||
21309 | @opindex mlate-ldp-fusion | |
21310 | @item -mlate-ldp-fusion | |
21311 | Enable the copy of the AArch64 load/store pair fusion pass that runs after | |
21312 | register allocation. Enabled by default at @samp{-O} and above. | |
21313 | ||
d77de738 | 21314 | @opindex msve-vector-bits |
ddf6fe37 | 21315 | @item -msve-vector-bits=@var{bits} |
d77de738 ML |
21316 | Specify the number of bits in an SVE vector register. This option only has |
21317 | an effect when SVE is enabled. | |
21318 | ||
21319 | GCC supports two forms of SVE code generation: ``vector-length | |
21320 | agnostic'' output that works with any size of vector register and | |
21321 | ``vector-length specific'' output that allows GCC to make assumptions | |
21322 | about the vector length when it is useful for optimization reasons. | |
21323 | The possible values of @samp{bits} are: @samp{scalable}, @samp{128}, | |
21324 | @samp{256}, @samp{512}, @samp{1024} and @samp{2048}. | |
21325 | Specifying @samp{scalable} selects vector-length agnostic | |
21326 | output. At present @samp{-msve-vector-bits=128} also generates vector-length | |
21327 | agnostic output for big-endian targets. All other values generate | |
21328 | vector-length specific code. The behavior of these values may change | |
21329 | in future releases and no value except @samp{scalable} should be | |
21330 | relied on for producing code that is portable across different | |
21331 | hardware SVE vector lengths. | |
21332 | ||
21333 | The default is @samp{-msve-vector-bits=scalable}, which produces | |
21334 | vector-length agnostic code. | |
21335 | @end table | |
21336 | ||
21337 | @subsubsection @option{-march} and @option{-mcpu} Feature Modifiers | |
21338 | @anchor{aarch64-feature-modifiers} | |
21339 | @cindex @option{-march} feature modifiers | |
21340 | @cindex @option{-mcpu} feature modifiers | |
21341 | Feature modifiers used with @option{-march} and @option{-mcpu} can be any of | |
21342 | the following and their inverses @option{no@var{feature}}: | |
21343 | ||
21344 | @table @samp | |
21345 | @item crc | |
21346 | Enable CRC extension. This is on by default for | |
21347 | @option{-march=armv8.1-a}. | |
21348 | @item crypto | |
21349 | Enable Crypto extension. This also enables Advanced SIMD and floating-point | |
21350 | instructions. | |
21351 | @item fp | |
21352 | Enable floating-point instructions. This is on by default for all possible | |
21353 | values for options @option{-march} and @option{-mcpu}. | |
21354 | @item simd | |
21355 | Enable Advanced SIMD instructions. This also enables floating-point | |
21356 | instructions. This is on by default for all possible values for options | |
21357 | @option{-march} and @option{-mcpu}. | |
21358 | @item sve | |
21359 | Enable Scalable Vector Extension instructions. This also enables Advanced | |
21360 | SIMD and floating-point instructions. | |
21361 | @item lse | |
21362 | Enable Large System Extension instructions. This is on by default for | |
21363 | @option{-march=armv8.1-a}. | |
21364 | @item rdma | |
21365 | Enable Round Double Multiply Accumulate instructions. This is on by default | |
21366 | for @option{-march=armv8.1-a}. | |
21367 | @item fp16 | |
21368 | Enable FP16 extension. This also enables floating-point instructions. | |
21369 | @item fp16fml | |
21370 | Enable FP16 fmla extension. This also enables FP16 extensions and | |
21371 | floating-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. | |
21372 | ||
21373 | @item rcpc | |
0431e8ae AV |
21374 | Enable the RCpc extension. This enables the use of the LDAPR instructions for |
21375 | load-acquire atomic semantics, and passes it on to the assembler, enabling | |
21376 | inline asm statements to use instructions from the RCpc extension. | |
d77de738 ML |
21377 | @item dotprod |
21378 | Enable the Dot Product extension. This also enables Advanced SIMD instructions. | |
21379 | @item aes | |
21380 | Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced | |
21381 | SIMD instructions. | |
21382 | @item sha2 | |
21383 | Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions. | |
21384 | @item sha3 | |
21385 | Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD | |
21386 | instructions. Use of this option with architectures prior to Armv8.2-A is not supported. | |
21387 | @item sm4 | |
21388 | Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions. | |
21389 | Use of this option with architectures prior to Armv8.2-A is not supported. | |
21390 | @item profile | |
21391 | Enable the Statistical Profiling extension. This option is only to enable the | |
21392 | extension at the assembler level and does not affect code generation. | |
21393 | @item rng | |
21394 | Enable the Armv8.5-a Random Number instructions. This option is only to | |
21395 | enable the extension at the assembler level and does not affect code | |
21396 | generation. | |
21397 | @item memtag | |
21398 | Enable the Armv8.5-a Memory Tagging Extensions. | |
21399 | Use of this option with architectures prior to Armv8.5-A is not supported. | |
21400 | @item sb | |
21401 | Enable the Armv8-a Speculation Barrier instruction. This option is only to | |
21402 | enable the extension at the assembler level and does not affect code | |
21403 | generation. This option is enabled by default for @option{-march=armv8.5-a}. | |
21404 | @item ssbs | |
21405 | Enable the Armv8-a Speculative Store Bypass Safe instruction. This option | |
21406 | is only to enable the extension at the assembler level and does not affect code | |
21407 | generation. This option is enabled by default for @option{-march=armv8.5-a}. | |
21408 | @item predres | |
21409 | Enable the Armv8-a Execution and Data Prediction Restriction instructions. | |
21410 | This option is only to enable the extension at the assembler level and does | |
21411 | not affect code generation. This option is enabled by default for | |
21412 | @option{-march=armv8.5-a}. | |
21413 | @item sve2 | |
21414 | Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE | |
21415 | instructions. | |
21416 | @item sve2-bitperm | |
21417 | Enable SVE2 bitperm instructions. This also enables SVE2 instructions. | |
21418 | @item sve2-sm4 | |
21419 | Enable SVE2 sm4 instructions. This also enables SVE2 instructions. | |
21420 | @item sve2-aes | |
21421 | Enable SVE2 aes instructions. This also enables SVE2 instructions. | |
21422 | @item sve2-sha3 | |
21423 | Enable SVE2 sha3 instructions. This also enables SVE2 instructions. | |
21424 | @item tme | |
21425 | Enable the Transactional Memory Extension. | |
21426 | @item i8mm | |
21427 | Enable 8-bit Integer Matrix Multiply instructions. This also enables | |
21428 | Advanced SIMD and floating-point instructions. This option is enabled by | |
21429 | default for @option{-march=armv8.6-a}. Use of this option with architectures | |
21430 | prior to Armv8.2-A is not supported. | |
21431 | @item f32mm | |
21432 | Enable 32-bit Floating point Matrix Multiply instructions. This also enables | |
21433 | SVE instructions. Use of this option with architectures prior to Armv8.2-A is | |
21434 | not supported. | |
21435 | @item f64mm | |
21436 | Enable 64-bit Floating point Matrix Multiply instructions. This also enables | |
21437 | SVE instructions. Use of this option with architectures prior to Armv8.2-A is | |
21438 | not supported. | |
21439 | @item bf16 | |
21440 | Enable brain half-precision floating-point instructions. This also enables | |
21441 | Advanced SIMD and floating-point instructions. This option is enabled by | |
21442 | default for @option{-march=armv8.6-a}. Use of this option with architectures | |
21443 | prior to Armv8.2-A is not supported. | |
21444 | @item ls64 | |
21445 | Enable the 64-byte atomic load and store instructions for accelerators. | |
21446 | This option is enabled by default for @option{-march=armv8.7-a}. | |
21447 | @item mops | |
21448 | Enable the instructions to accelerate memory operations like @code{memcpy}, | |
21449 | @code{memmove}, @code{memset}. This option is enabled by default for | |
21450 | @option{-march=armv8.8-a} | |
21451 | @item flagm | |
21452 | Enable the Flag Manipulation instructions Extension. | |
21453 | @item pauth | |
21454 | Enable the Pointer Authentication Extension. | |
d758d190 KT |
21455 | @item cssc |
21456 | Enable the Common Short Sequence Compression instructions. | |
7e04bd1f RS |
21457 | @item sme |
21458 | Enable the Scalable Matrix Extension. | |
4f6ab953 RS |
21459 | @item sme-i16i64 |
21460 | Enable the FEAT_SME_I16I64 extension to SME. | |
21461 | @item sme-f64f64 | |
21462 | Enable the FEAT_SME_F64F64 extension to SME. | |
3b58b220 RS |
21463 | +@item sme2 |
21464 | Enable the Scalable Matrix Extension 2. This also enables SME instructions. | |
16a05fac VDN |
21465 | @item d128 |
21466 | Enable support for 128-bit system register read/write instructions. | |
3aba0458 VDN |
21467 | @item gcs |
21468 | Enable support for Armv9.4-a Guarded Control Stack extension. | |
16a05fac VDN |
21469 | @item the |
21470 | Enable support for Armv8.9-a/9.4-a translation hardening extension. | |
df193bda VDN |
21471 | @item rcpc3 |
21472 | Enable the RCpc3 (Release Consistency) extension. | |
16a05fac | 21473 | |
d77de738 ML |
21474 | @end table |
21475 | ||
21476 | Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd}, | |
21477 | which implies @option{fp}. | |
21478 | Conversely, @option{nofp} implies @option{nosimd}, which implies | |
21479 | @option{nocrypto}, @option{noaes} and @option{nosha2}. | |
21480 | ||
21481 | @node Adapteva Epiphany Options | |
21482 | @subsection Adapteva Epiphany Options | |
21483 | ||
21484 | These @samp{-m} options are defined for Adapteva Epiphany: | |
21485 | ||
21486 | @table @gcctabopt | |
d77de738 | 21487 | @opindex mhalf-reg-file |
ddf6fe37 | 21488 | @item -mhalf-reg-file |
d77de738 ML |
21489 | Don't allocate any register in the range @code{r32}@dots{}@code{r63}. |
21490 | That allows code to run on hardware variants that lack these registers. | |
21491 | ||
d77de738 | 21492 | @opindex mprefer-short-insn-regs |
ddf6fe37 | 21493 | @item -mprefer-short-insn-regs |
d77de738 ML |
21494 | Preferentially allocate registers that allow short instruction generation. |
21495 | This can result in increased instruction count, so this may either reduce or | |
21496 | increase overall code size. | |
21497 | ||
d77de738 | 21498 | @opindex mbranch-cost |
ddf6fe37 | 21499 | @item -mbranch-cost=@var{num} |
d77de738 ML |
21500 | Set the cost of branches to roughly @var{num} ``simple'' instructions. |
21501 | This cost is only a heuristic and is not guaranteed to produce | |
21502 | consistent results across releases. | |
21503 | ||
d77de738 | 21504 | @opindex mcmove |
ddf6fe37 | 21505 | @item -mcmove |
d77de738 ML |
21506 | Enable the generation of conditional moves. |
21507 | ||
d77de738 | 21508 | @opindex mnops |
ddf6fe37 | 21509 | @item -mnops=@var{num} |
d77de738 ML |
21510 | Emit @var{num} NOPs before every other generated instruction. |
21511 | ||
d77de738 ML |
21512 | @opindex mno-soft-cmpsf |
21513 | @opindex msoft-cmpsf | |
ddf6fe37 | 21514 | @item -mno-soft-cmpsf |
d77de738 ML |
21515 | For single-precision floating-point comparisons, emit an @code{fsub} instruction |
21516 | and test the flags. This is faster than a software comparison, but can | |
21517 | get incorrect results in the presence of NaNs, or when two different small | |
21518 | numbers are compared such that their difference is calculated as zero. | |
21519 | The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant, | |
21520 | software comparisons. | |
21521 | ||
d77de738 | 21522 | @opindex mstack-offset |
ddf6fe37 | 21523 | @item -mstack-offset=@var{num} |
d77de738 ML |
21524 | Set the offset between the top of the stack and the stack pointer. |
21525 | E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7} | |
21526 | can be used by leaf functions without stack allocation. | |
21527 | Values other than @samp{8} or @samp{16} are untested and unlikely to work. | |
21528 | Note also that this option changes the ABI; compiling a program with a | |
21529 | different stack offset than the libraries have been compiled with | |
21530 | generally does not work. | |
21531 | This option can be useful if you want to evaluate if a different stack | |
21532 | offset would give you better code, but to actually use a different stack | |
21533 | offset to build working programs, it is recommended to configure the | |
21534 | toolchain with the appropriate @option{--with-stack-offset=@var{num}} option. | |
21535 | ||
d77de738 ML |
21536 | @opindex mno-round-nearest |
21537 | @opindex mround-nearest | |
ddf6fe37 | 21538 | @item -mno-round-nearest |
d77de738 ML |
21539 | Make the scheduler assume that the rounding mode has been set to |
21540 | truncating. The default is @option{-mround-nearest}. | |
21541 | ||
d77de738 | 21542 | @opindex mlong-calls |
ddf6fe37 | 21543 | @item -mlong-calls |
d77de738 ML |
21544 | If not otherwise specified by an attribute, assume all calls might be beyond |
21545 | the offset range of the @code{b} / @code{bl} instructions, and therefore load the | |
21546 | function address into a register before performing a (otherwise direct) call. | |
21547 | This is the default. | |
21548 | ||
d77de738 | 21549 | @opindex short-calls |
ddf6fe37 | 21550 | @item -mshort-calls |
d77de738 ML |
21551 | If not otherwise specified by an attribute, assume all direct calls are |
21552 | in the range of the @code{b} / @code{bl} instructions, so use these instructions | |
21553 | for direct calls. The default is @option{-mlong-calls}. | |
21554 | ||
d77de738 | 21555 | @opindex msmall16 |
ddf6fe37 | 21556 | @item -msmall16 |
d77de738 ML |
21557 | Assume addresses can be loaded as 16-bit unsigned values. This does not |
21558 | apply to function addresses for which @option{-mlong-calls} semantics | |
21559 | are in effect. | |
21560 | ||
d77de738 | 21561 | @opindex mfp-mode |
ddf6fe37 | 21562 | @item -mfp-mode=@var{mode} |
d77de738 ML |
21563 | Set the prevailing mode of the floating-point unit. |
21564 | This determines the floating-point mode that is provided and expected | |
21565 | at function call and return time. Making this mode match the mode you | |
21566 | predominantly need at function start can make your programs smaller and | |
21567 | faster by avoiding unnecessary mode switches. | |
21568 | ||
21569 | @var{mode} can be set to one the following values: | |
21570 | ||
21571 | @table @samp | |
21572 | @item caller | |
21573 | Any mode at function entry is valid, and retained or restored when | |
21574 | the function returns, and when it calls other functions. | |
21575 | This mode is useful for compiling libraries or other compilation units | |
21576 | you might want to incorporate into different programs with different | |
21577 | prevailing FPU modes, and the convenience of being able to use a single | |
21578 | object file outweighs the size and speed overhead for any extra | |
21579 | mode switching that might be needed, compared with what would be needed | |
21580 | with a more specific choice of prevailing FPU mode. | |
21581 | ||
21582 | @item truncate | |
21583 | This is the mode used for floating-point calculations with | |
21584 | truncating (i.e.@: round towards zero) rounding mode. That includes | |
21585 | conversion from floating point to integer. | |
21586 | ||
21587 | @item round-nearest | |
21588 | This is the mode used for floating-point calculations with | |
21589 | round-to-nearest-or-even rounding mode. | |
21590 | ||
21591 | @item int | |
21592 | This is the mode used to perform integer calculations in the FPU, e.g.@: | |
21593 | integer multiply, or integer multiply-and-accumulate. | |
21594 | @end table | |
21595 | ||
21596 | The default is @option{-mfp-mode=caller} | |
21597 | ||
d77de738 ML |
21598 | @opindex mno-split-lohi |
21599 | @opindex msplit-lohi | |
21600 | @opindex mno-postinc | |
21601 | @opindex mpostinc | |
21602 | @opindex mno-postmodify | |
21603 | @opindex mpostmodify | |
ddf6fe37 AA |
21604 | @item -mno-split-lohi |
21605 | @itemx -mno-postinc | |
21606 | @itemx -mno-postmodify | |
d77de738 ML |
21607 | Code generation tweaks that disable, respectively, splitting of 32-bit |
21608 | loads, generation of post-increment addresses, and generation of | |
21609 | post-modify addresses. The defaults are @option{msplit-lohi}, | |
21610 | @option{-mpost-inc}, and @option{-mpost-modify}. | |
21611 | ||
d77de738 ML |
21612 | @opindex mno-vect-double |
21613 | @opindex mvect-double | |
ddf6fe37 | 21614 | @item -mnovect-double |
d77de738 ML |
21615 | Change the preferred SIMD mode to SImode. The default is |
21616 | @option{-mvect-double}, which uses DImode as preferred SIMD mode. | |
21617 | ||
d77de738 | 21618 | @opindex max-vect-align |
ddf6fe37 | 21619 | @item -max-vect-align=@var{num} |
d77de738 ML |
21620 | The maximum alignment for SIMD vector mode types. |
21621 | @var{num} may be 4 or 8. The default is 8. | |
21622 | Note that this is an ABI change, even though many library function | |
21623 | interfaces are unaffected if they don't use SIMD vector modes | |
21624 | in places that affect size and/or alignment of relevant types. | |
21625 | ||
d77de738 | 21626 | @opindex msplit-vecmove-early |
ddf6fe37 | 21627 | @item -msplit-vecmove-early |
d77de738 ML |
21628 | Split vector moves into single word moves before reload. In theory this |
21629 | can give better register allocation, but so far the reverse seems to be | |
21630 | generally the case. | |
21631 | ||
d77de738 | 21632 | @opindex m1reg- |
ddf6fe37 | 21633 | @item -m1reg-@var{reg} |
d77de738 ML |
21634 | Specify a register to hold the constant @minus{}1, which makes loading small negative |
21635 | constants and certain bitmasks faster. | |
21636 | Allowable values for @var{reg} are @samp{r43} and @samp{r63}, | |
21637 | which specify use of that register as a fixed register, | |
21638 | and @samp{none}, which means that no register is used for this | |
21639 | purpose. The default is @option{-m1reg-none}. | |
21640 | ||
21641 | @end table | |
21642 | ||
21643 | @node AMD GCN Options | |
21644 | @subsection AMD GCN Options | |
21645 | @cindex AMD GCN Options | |
21646 | ||
21647 | These options are defined specifically for the AMD GCN port. | |
21648 | ||
21649 | @table @gcctabopt | |
21650 | ||
d77de738 | 21651 | @opindex march |
d77de738 | 21652 | @opindex mtune |
ddf6fe37 AA |
21653 | @item -march=@var{gpu} |
21654 | @itemx -mtune=@var{gpu} | |
d77de738 ML |
21655 | Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu} |
21656 | are | |
21657 | ||
21658 | @table @samp | |
21659 | @item fiji | |
56ed1055 AS |
21660 | Compile for GCN3 Fiji devices (gfx803). Support deprecated; availablility |
21661 | depends on how GCC has been configured, see @option{--with-arch} and | |
21662 | @option{--with-multilib-list}. | |
d77de738 ML |
21663 | |
21664 | @item gfx900 | |
21665 | Compile for GCN5 Vega 10 devices (gfx900). | |
21666 | ||
21667 | @item gfx906 | |
21668 | Compile for GCN5 Vega 20 devices (gfx906). | |
21669 | ||
21670 | @item gfx908 | |
21671 | Compile for CDNA1 Instinct MI100 series devices (gfx908). | |
21672 | ||
21673 | @item gfx90a | |
21674 | Compile for CDNA2 Instinct MI200 series devices (gfx90a). | |
21675 | ||
21676 | @end table | |
21677 | ||
ddf6fe37 | 21678 | @opindex msram-ecc |
d77de738 ML |
21679 | @item -msram-ecc=on |
21680 | @itemx -msram-ecc=off | |
21681 | @itemx -msram-ecc=any | |
d77de738 ML |
21682 | Compile binaries suitable for devices with the SRAM-ECC feature enabled, |
21683 | disabled, or either mode. This feature can be enabled per-process on some | |
21684 | devices. The compiled code must match the device mode. The default is | |
21685 | @samp{any}, for devices that support it. | |
21686 | ||
d77de738 | 21687 | @opindex mstack-size |
ddf6fe37 | 21688 | @item -mstack-size=@var{bytes} |
d77de738 ML |
21689 | Specify how many @var{bytes} of stack space will be requested for each GPU |
21690 | thread (wave-front). Beware that there may be many threads and limited memory | |
21691 | available. The size of the stack allocation may also have an impact on | |
21692 | run-time performance. The default is 32KB when using OpenACC or OpenMP, and | |
21693 | 1MB otherwise. | |
21694 | ||
d77de738 | 21695 | @opindex mxnack |
366e3d30 TB |
21696 | @item -mxnack=on |
21697 | @itemx -mxnack=off | |
21698 | @itemx -mxnack=any | |
21699 | Compile binaries suitable for devices with the XNACK feature enabled, disabled, | |
21700 | or either mode. Some devices always require XNACK and some allow the user to | |
21701 | configure XNACK. The compiled code must match the device mode. | |
4c12bcbe AS |
21702 | The default is @samp{-mxnack=any} on devices that support Unified Shared |
21703 | Memory, and @samp{-mxnack=no} otherwise. | |
d77de738 ML |
21704 | |
21705 | @end table | |
21706 | ||
21707 | @node ARC Options | |
21708 | @subsection ARC Options | |
21709 | @cindex ARC options | |
21710 | ||
21711 | The following options control the architecture variant for which code | |
21712 | is being compiled: | |
21713 | ||
21714 | @c architecture variants | |
21715 | @table @gcctabopt | |
21716 | ||
d77de738 | 21717 | @opindex mbarrel-shifter |
ddf6fe37 | 21718 | @item -mbarrel-shifter |
d77de738 ML |
21719 | Generate instructions supported by barrel shifter. This is the default |
21720 | unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect. | |
21721 | ||
d77de738 | 21722 | @opindex mjli-always |
ddf6fe37 | 21723 | @item -mjli-always |
d77de738 ML |
21724 | Force to call a function using jli_s instruction. This option is |
21725 | valid only for ARCv2 architecture. | |
21726 | ||
d77de738 | 21727 | @opindex mcpu |
ddf6fe37 | 21728 | @item -mcpu=@var{cpu} |
d77de738 ML |
21729 | Set architecture type, register usage, and instruction scheduling |
21730 | parameters for @var{cpu}. There are also shortcut alias options | |
21731 | available for backward compatibility and convenience. Supported | |
21732 | values for @var{cpu} are | |
21733 | ||
21734 | @table @samp | |
21735 | @opindex mA6 | |
21736 | @opindex mARC600 | |
21737 | @item arc600 | |
21738 | Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}. | |
21739 | ||
d77de738 | 21740 | @opindex mARC601 |
ddf6fe37 | 21741 | @item arc601 |
d77de738 ML |
21742 | Compile for ARC601. Alias: @option{-mARC601}. |
21743 | ||
d77de738 ML |
21744 | @opindex mA7 |
21745 | @opindex mARC700 | |
ddf6fe37 | 21746 | @item arc700 |
d77de738 ML |
21747 | Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}. |
21748 | This is the default when configured with @option{--with-cpu=arc700}@. | |
21749 | ||
21750 | @item arcem | |
21751 | Compile for ARC EM. | |
21752 | ||
21753 | @item archs | |
21754 | Compile for ARC HS. | |
21755 | ||
21756 | @item em | |
21757 | Compile for ARC EM CPU with no hardware extensions. | |
21758 | ||
21759 | @item em4 | |
21760 | Compile for ARC EM4 CPU. | |
21761 | ||
21762 | @item em4_dmips | |
21763 | Compile for ARC EM4 DMIPS CPU. | |
21764 | ||
21765 | @item em4_fpus | |
21766 | Compile for ARC EM4 DMIPS CPU with the single-precision floating-point | |
21767 | extension. | |
21768 | ||
21769 | @item em4_fpuda | |
21770 | Compile for ARC EM4 DMIPS CPU with single-precision floating-point and | |
21771 | double assist instructions. | |
21772 | ||
21773 | @item hs | |
21774 | Compile for ARC HS CPU with no hardware extensions except the atomic | |
21775 | instructions. | |
21776 | ||
21777 | @item hs34 | |
21778 | Compile for ARC HS34 CPU. | |
21779 | ||
21780 | @item hs38 | |
21781 | Compile for ARC HS38 CPU. | |
21782 | ||
21783 | @item hs38_linux | |
21784 | Compile for ARC HS38 CPU with all hardware extensions on. | |
21785 | ||
21786 | @item hs4x | |
21787 | Compile for ARC HS4x CPU. | |
21788 | ||
21789 | @item hs4xd | |
21790 | Compile for ARC HS4xD CPU. | |
21791 | ||
21792 | @item hs4x_rel31 | |
21793 | Compile for ARC HS4x CPU release 3.10a. | |
21794 | ||
21795 | @item arc600_norm | |
21796 | Compile for ARC 600 CPU with @code{norm} instructions enabled. | |
21797 | ||
21798 | @item arc600_mul32x16 | |
21799 | Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply | |
21800 | instructions enabled. | |
21801 | ||
21802 | @item arc600_mul64 | |
21803 | Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family | |
21804 | instructions enabled. | |
21805 | ||
21806 | @item arc601_norm | |
21807 | Compile for ARC 601 CPU with @code{norm} instructions enabled. | |
21808 | ||
21809 | @item arc601_mul32x16 | |
21810 | Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply | |
21811 | instructions enabled. | |
21812 | ||
21813 | @item arc601_mul64 | |
21814 | Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family | |
21815 | instructions enabled. | |
21816 | ||
21817 | @item nps400 | |
21818 | Compile for ARC 700 on NPS400 chip. | |
21819 | ||
21820 | @item em_mini | |
21821 | Compile for ARC EM minimalist configuration featuring reduced register | |
21822 | set. | |
21823 | ||
21824 | @end table | |
21825 | ||
d77de738 | 21826 | @opindex mdpfp |
d77de738 | 21827 | @opindex mdpfp-compact |
ddf6fe37 AA |
21828 | @item -mdpfp |
21829 | @itemx -mdpfp-compact | |
d77de738 ML |
21830 | Generate double-precision FPX instructions, tuned for the compact |
21831 | implementation. | |
21832 | ||
d77de738 | 21833 | @opindex mdpfp-fast |
ddf6fe37 | 21834 | @item -mdpfp-fast |
d77de738 ML |
21835 | Generate double-precision FPX instructions, tuned for the fast |
21836 | implementation. | |
21837 | ||
d77de738 | 21838 | @opindex mno-dpfp-lrsr |
ddf6fe37 | 21839 | @item -mno-dpfp-lrsr |
d77de738 ML |
21840 | Disable @code{lr} and @code{sr} instructions from using FPX extension |
21841 | aux registers. | |
21842 | ||
d77de738 | 21843 | @opindex mea |
ddf6fe37 | 21844 | @item -mea |
d77de738 ML |
21845 | Generate extended arithmetic instructions. Currently only |
21846 | @code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are | |
21847 | supported. Only valid for @option{-mcpu=ARC700}. | |
21848 | ||
d77de738 ML |
21849 | @opindex mno-mpy |
21850 | @opindex mmpy | |
ddf6fe37 | 21851 | @item -mno-mpy |
d77de738 ML |
21852 | Do not generate @code{mpy}-family instructions for ARC700. This option is |
21853 | deprecated. | |
21854 | ||
d77de738 | 21855 | @opindex mmul32x16 |
ddf6fe37 | 21856 | @item -mmul32x16 |
d77de738 ML |
21857 | Generate 32x16-bit multiply and multiply-accumulate instructions. |
21858 | ||
d77de738 | 21859 | @opindex mmul64 |
ddf6fe37 | 21860 | @item -mmul64 |
d77de738 ML |
21861 | Generate @code{mul64} and @code{mulu64} instructions. |
21862 | Only valid for @option{-mcpu=ARC600}. | |
21863 | ||
d77de738 | 21864 | @opindex mnorm |
ddf6fe37 | 21865 | @item -mnorm |
d77de738 ML |
21866 | Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700} |
21867 | is in effect. | |
21868 | ||
d77de738 | 21869 | @opindex mspfp |
d77de738 | 21870 | @opindex mspfp-compact |
ddf6fe37 AA |
21871 | @item -mspfp |
21872 | @itemx -mspfp-compact | |
d77de738 ML |
21873 | Generate single-precision FPX instructions, tuned for the compact |
21874 | implementation. | |
21875 | ||
d77de738 | 21876 | @opindex mspfp-fast |
ddf6fe37 | 21877 | @item -mspfp-fast |
d77de738 ML |
21878 | Generate single-precision FPX instructions, tuned for the fast |
21879 | implementation. | |
21880 | ||
d77de738 | 21881 | @opindex msimd |
ddf6fe37 | 21882 | @item -msimd |
d77de738 ML |
21883 | Enable generation of ARC SIMD instructions via target-specific |
21884 | builtins. Only valid for @option{-mcpu=ARC700}. | |
21885 | ||
d77de738 | 21886 | @opindex msoft-float |
ddf6fe37 | 21887 | @item -msoft-float |
d77de738 ML |
21888 | This option ignored; it is provided for compatibility purposes only. |
21889 | Software floating-point code is emitted by default, and this default | |
21890 | can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or | |
21891 | @option{-mspfp-fast} for single precision, and @option{-mdpfp}, | |
21892 | @option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision. | |
21893 | ||
d77de738 | 21894 | @opindex mswap |
ddf6fe37 | 21895 | @item -mswap |
d77de738 ML |
21896 | Generate @code{swap} instructions. |
21897 | ||
d77de738 | 21898 | @opindex matomic |
ddf6fe37 | 21899 | @item -matomic |
d77de738 ML |
21900 | This enables use of the locked load/store conditional extension to implement |
21901 | atomic memory built-in functions. Not available for ARC 6xx or ARC | |
21902 | EM cores. | |
21903 | ||
d77de738 | 21904 | @opindex mdiv-rem |
ddf6fe37 | 21905 | @item -mdiv-rem |
d77de738 ML |
21906 | Enable @code{div} and @code{rem} instructions for ARCv2 cores. |
21907 | ||
d77de738 | 21908 | @opindex mcode-density |
ddf6fe37 | 21909 | @item -mcode-density |
d77de738 ML |
21910 | Enable code density instructions for ARC EM. |
21911 | This option is on by default for ARC HS. | |
21912 | ||
d77de738 | 21913 | @opindex mll64 |
ddf6fe37 | 21914 | @item -mll64 |
d77de738 ML |
21915 | Enable double load/store operations for ARC HS cores. |
21916 | ||
d77de738 | 21917 | @opindex mtp-regno |
ddf6fe37 | 21918 | @item -mtp-regno=@var{regno} |
d77de738 ML |
21919 | Specify thread pointer register number. |
21920 | ||
d77de738 | 21921 | @opindex mmpy-option |
ddf6fe37 | 21922 | @item -mmpy-option=@var{multo} |
d77de738 ML |
21923 | Compile ARCv2 code with a multiplier design option. You can specify |
21924 | the option using either a string or numeric value for @var{multo}. | |
21925 | @samp{wlh1} is the default value. The recognized values are: | |
21926 | ||
21927 | @table @samp | |
21928 | @item 0 | |
21929 | @itemx none | |
21930 | No multiplier available. | |
21931 | ||
21932 | @item 1 | |
21933 | @itemx w | |
21934 | 16x16 multiplier, fully pipelined. | |
21935 | The following instructions are enabled: @code{mpyw} and @code{mpyuw}. | |
21936 | ||
21937 | @item 2 | |
21938 | @itemx wlh1 | |
21939 | 32x32 multiplier, fully | |
21940 | pipelined (1 stage). The following instructions are additionally | |
21941 | enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21942 | ||
21943 | @item 3 | |
21944 | @itemx wlh2 | |
21945 | 32x32 multiplier, fully pipelined | |
21946 | (2 stages). The following instructions are additionally enabled: @code{mpy}, | |
21947 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21948 | ||
21949 | @item 4 | |
21950 | @itemx wlh3 | |
21951 | Two 16x16 multipliers, blocking, | |
21952 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21953 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21954 | ||
21955 | @item 5 | |
21956 | @itemx wlh4 | |
21957 | One 16x16 multiplier, blocking, | |
21958 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21959 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21960 | ||
21961 | @item 6 | |
21962 | @itemx wlh5 | |
21963 | One 32x4 multiplier, blocking, | |
21964 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21965 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21966 | ||
21967 | @item 7 | |
21968 | @itemx plus_dmpy | |
21969 | ARC HS SIMD support. | |
21970 | ||
21971 | @item 8 | |
21972 | @itemx plus_macd | |
21973 | ARC HS SIMD support. | |
21974 | ||
21975 | @item 9 | |
21976 | @itemx plus_qmacw | |
21977 | ARC HS SIMD support. | |
21978 | ||
21979 | @end table | |
21980 | ||
21981 | This option is only available for ARCv2 cores@. | |
21982 | ||
d77de738 | 21983 | @opindex mfpu |
ddf6fe37 | 21984 | @item -mfpu=@var{fpu} |
d77de738 ML |
21985 | Enables support for specific floating-point hardware extensions for ARCv2 |
21986 | cores. Supported values for @var{fpu} are: | |
21987 | ||
21988 | @table @samp | |
21989 | ||
21990 | @item fpus | |
21991 | Enables support for single-precision floating-point hardware | |
21992 | extensions@. | |
21993 | ||
21994 | @item fpud | |
21995 | Enables support for double-precision floating-point hardware | |
21996 | extensions. The single-precision floating-point extension is also | |
21997 | enabled. Not available for ARC EM@. | |
21998 | ||
21999 | @item fpuda | |
22000 | Enables support for double-precision floating-point hardware | |
22001 | extensions using double-precision assist instructions. The single-precision | |
22002 | floating-point extension is also enabled. This option is | |
22003 | only available for ARC EM@. | |
22004 | ||
22005 | @item fpuda_div | |
22006 | Enables support for double-precision floating-point hardware | |
22007 | extensions using double-precision assist instructions. | |
22008 | The single-precision floating-point, square-root, and divide | |
22009 | extensions are also enabled. This option is | |
22010 | only available for ARC EM@. | |
22011 | ||
22012 | @item fpuda_fma | |
22013 | Enables support for double-precision floating-point hardware | |
22014 | extensions using double-precision assist instructions. | |
22015 | The single-precision floating-point and fused multiply and add | |
22016 | hardware extensions are also enabled. This option is | |
22017 | only available for ARC EM@. | |
22018 | ||
22019 | @item fpuda_all | |
22020 | Enables support for double-precision floating-point hardware | |
22021 | extensions using double-precision assist instructions. | |
22022 | All single-precision floating-point hardware extensions are also | |
22023 | enabled. This option is only available for ARC EM@. | |
22024 | ||
22025 | @item fpus_div | |
22026 | Enables support for single-precision floating-point, square-root and divide | |
22027 | hardware extensions@. | |
22028 | ||
22029 | @item fpud_div | |
22030 | Enables support for double-precision floating-point, square-root and divide | |
22031 | hardware extensions. This option | |
22032 | includes option @samp{fpus_div}. Not available for ARC EM@. | |
22033 | ||
22034 | @item fpus_fma | |
22035 | Enables support for single-precision floating-point and | |
22036 | fused multiply and add hardware extensions@. | |
22037 | ||
22038 | @item fpud_fma | |
22039 | Enables support for double-precision floating-point and | |
22040 | fused multiply and add hardware extensions. This option | |
22041 | includes option @samp{fpus_fma}. Not available for ARC EM@. | |
22042 | ||
22043 | @item fpus_all | |
22044 | Enables support for all single-precision floating-point hardware | |
22045 | extensions@. | |
22046 | ||
22047 | @item fpud_all | |
22048 | Enables support for all single- and double-precision floating-point | |
22049 | hardware extensions. Not available for ARC EM@. | |
22050 | ||
22051 | @end table | |
22052 | ||
d77de738 | 22053 | @opindex mirq-ctrl-saved |
ddf6fe37 | 22054 | @item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count} |
d77de738 ML |
22055 | Specifies general-purposes registers that the processor automatically |
22056 | saves/restores on interrupt entry and exit. @var{register-range} is | |
22057 | specified as two registers separated by a dash. The register range | |
22058 | always starts with @code{r0}, the upper limit is @code{fp} register. | |
22059 | @var{blink} and @var{lp_count} are optional. This option is only | |
22060 | valid for ARC EM and ARC HS cores. | |
22061 | ||
d77de738 | 22062 | @opindex mrgf-banked-regs |
ddf6fe37 | 22063 | @item -mrgf-banked-regs=@var{number} |
d77de738 ML |
22064 | Specifies the number of registers replicated in second register bank |
22065 | on entry to fast interrupt. Fast interrupts are interrupts with the | |
22066 | highest priority level P0. These interrupts save only PC and STATUS32 | |
22067 | registers to avoid memory transactions during interrupt entry and exit | |
22068 | sequences. Use this option when you are using fast interrupts in an | |
22069 | ARC V2 family processor. Permitted values are 4, 8, 16, and 32. | |
22070 | ||
d77de738 | 22071 | @opindex mlpc-width |
ddf6fe37 | 22072 | @item -mlpc-width=@var{width} |
d77de738 ML |
22073 | Specify the width of the @code{lp_count} register. Valid values for |
22074 | @var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is | |
22075 | fixed to 32 bits. If the width is less than 32, the compiler does not | |
22076 | attempt to transform loops in your program to use the zero-delay loop | |
22077 | mechanism unless it is known that the @code{lp_count} register can | |
22078 | hold the required loop-counter value. Depending on the width | |
22079 | specified, the compiler and run-time library might continue to use the | |
22080 | loop mechanism for various needs. This option defines macro | |
22081 | @code{__ARC_LPC_WIDTH__} with the value of @var{width}. | |
22082 | ||
d77de738 | 22083 | @opindex mrf16 |
ddf6fe37 | 22084 | @item -mrf16 |
d77de738 ML |
22085 | This option instructs the compiler to generate code for a 16-entry |
22086 | register file. This option defines the @code{__ARC_RF16__} | |
22087 | preprocessor macro. | |
22088 | ||
d77de738 | 22089 | @opindex mbranch-index |
ddf6fe37 | 22090 | @item -mbranch-index |
d77de738 ML |
22091 | Enable use of @code{bi} or @code{bih} instructions to implement jump |
22092 | tables. | |
22093 | ||
22094 | @end table | |
22095 | ||
22096 | The following options are passed through to the assembler, and also | |
22097 | define preprocessor macro symbols. | |
22098 | ||
22099 | @c Flags used by the assembler, but for which we define preprocessor | |
22100 | @c macro symbols as well. | |
22101 | @table @gcctabopt | |
d77de738 | 22102 | @opindex mdsp-packa |
ddf6fe37 | 22103 | @item -mdsp-packa |
d77de738 ML |
22104 | Passed down to the assembler to enable the DSP Pack A extensions. |
22105 | Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is | |
22106 | deprecated. | |
22107 | ||
d77de738 | 22108 | @opindex mdvbf |
ddf6fe37 | 22109 | @item -mdvbf |
d77de738 ML |
22110 | Passed down to the assembler to enable the dual Viterbi butterfly |
22111 | extension. Also sets the preprocessor symbol @code{__Xdvbf}. This | |
22112 | option is deprecated. | |
22113 | ||
22114 | @c ARC700 4.10 extension instruction | |
d77de738 | 22115 | @opindex mlock |
ddf6fe37 | 22116 | @item -mlock |
d77de738 ML |
22117 | Passed down to the assembler to enable the locked load/store |
22118 | conditional extension. Also sets the preprocessor symbol | |
22119 | @code{__Xlock}. | |
22120 | ||
d77de738 | 22121 | @opindex mmac-d16 |
ddf6fe37 | 22122 | @item -mmac-d16 |
d77de738 ML |
22123 | Passed down to the assembler. Also sets the preprocessor symbol |
22124 | @code{__Xxmac_d16}. This option is deprecated. | |
22125 | ||
d77de738 | 22126 | @opindex mmac-24 |
ddf6fe37 | 22127 | @item -mmac-24 |
d77de738 ML |
22128 | Passed down to the assembler. Also sets the preprocessor symbol |
22129 | @code{__Xxmac_24}. This option is deprecated. | |
22130 | ||
22131 | @c ARC700 4.10 extension instruction | |
d77de738 | 22132 | @opindex mrtsc |
ddf6fe37 | 22133 | @item -mrtsc |
d77de738 ML |
22134 | Passed down to the assembler to enable the 64-bit time-stamp counter |
22135 | extension instruction. Also sets the preprocessor symbol | |
22136 | @code{__Xrtsc}. This option is deprecated. | |
22137 | ||
22138 | @c ARC700 4.10 extension instruction | |
d77de738 | 22139 | @opindex mswape |
ddf6fe37 | 22140 | @item -mswape |
d77de738 ML |
22141 | Passed down to the assembler to enable the swap byte ordering |
22142 | extension instruction. Also sets the preprocessor symbol | |
22143 | @code{__Xswape}. | |
22144 | ||
d77de738 | 22145 | @opindex mtelephony |
ddf6fe37 | 22146 | @item -mtelephony |
d77de738 ML |
22147 | Passed down to the assembler to enable dual- and single-operand |
22148 | instructions for telephony. Also sets the preprocessor symbol | |
22149 | @code{__Xtelephony}. This option is deprecated. | |
22150 | ||
d77de738 | 22151 | @opindex mxy |
ddf6fe37 | 22152 | @item -mxy |
d77de738 ML |
22153 | Passed down to the assembler to enable the XY memory extension. Also |
22154 | sets the preprocessor symbol @code{__Xxy}. | |
22155 | ||
22156 | @end table | |
22157 | ||
22158 | The following options control how the assembly code is annotated: | |
22159 | ||
22160 | @c Assembly annotation options | |
22161 | @table @gcctabopt | |
d77de738 | 22162 | @opindex misize |
ddf6fe37 | 22163 | @item -misize |
d77de738 ML |
22164 | Annotate assembler instructions with estimated addresses. |
22165 | ||
d77de738 | 22166 | @opindex mannotate-align |
ddf6fe37 | 22167 | @item -mannotate-align |
e4b19406 | 22168 | Does nothing. Preserved for backward compatibility. |
d77de738 ML |
22169 | |
22170 | @end table | |
22171 | ||
22172 | The following options are passed through to the linker: | |
22173 | ||
22174 | @c options passed through to the linker | |
22175 | @table @gcctabopt | |
d77de738 | 22176 | @opindex marclinux |
ddf6fe37 | 22177 | @item -marclinux |
d77de738 ML |
22178 | Passed through to the linker, to specify use of the @code{arclinux} emulation. |
22179 | This option is enabled by default in tool chains built for | |
22180 | @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets | |
22181 | when profiling is not requested. | |
22182 | ||
d77de738 | 22183 | @opindex marclinux_prof |
ddf6fe37 | 22184 | @item -marclinux_prof |
d77de738 ML |
22185 | Passed through to the linker, to specify use of the |
22186 | @code{arclinux_prof} emulation. This option is enabled by default in | |
22187 | tool chains built for @w{@code{arc-linux-uclibc}} and | |
22188 | @w{@code{arceb-linux-uclibc}} targets when profiling is requested. | |
22189 | ||
22190 | @end table | |
22191 | ||
22192 | The following options control the semantics of generated code: | |
22193 | ||
22194 | @c semantically relevant code generation options | |
22195 | @table @gcctabopt | |
d77de738 | 22196 | @opindex mlong-calls |
ddf6fe37 | 22197 | @item -mlong-calls |
d77de738 ML |
22198 | Generate calls as register indirect calls, thus providing access |
22199 | to the full 32-bit address range. | |
22200 | ||
d77de738 | 22201 | @opindex mmedium-calls |
ddf6fe37 | 22202 | @item -mmedium-calls |
d77de738 ML |
22203 | Don't use less than 25-bit addressing range for calls, which is the |
22204 | offset available for an unconditional branch-and-link | |
22205 | instruction. Conditional execution of function calls is suppressed, to | |
22206 | allow use of the 25-bit range, rather than the 21-bit range with | |
22207 | conditional branch-and-link. This is the default for tool chains built | |
22208 | for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets. | |
22209 | ||
d77de738 | 22210 | @opindex G |
ddf6fe37 | 22211 | @item -G @var{num} |
d77de738 ML |
22212 | Put definitions of externally-visible data in a small data section if |
22213 | that data is no bigger than @var{num} bytes. The default value of | |
22214 | @var{num} is 4 for any ARC configuration, or 8 when we have double | |
22215 | load/store operations. | |
22216 | ||
d77de738 ML |
22217 | @opindex mno-sdata |
22218 | @opindex msdata | |
ddf6fe37 | 22219 | @item -mno-sdata |
d77de738 ML |
22220 | Do not generate sdata references. This is the default for tool chains |
22221 | built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} | |
22222 | targets. | |
22223 | ||
d77de738 | 22224 | @opindex mvolatile-cache |
ddf6fe37 | 22225 | @item -mvolatile-cache |
d77de738 ML |
22226 | Use ordinarily cached memory accesses for volatile references. This is the |
22227 | default. | |
22228 | ||
d77de738 ML |
22229 | @opindex mno-volatile-cache |
22230 | @opindex mvolatile-cache | |
ddf6fe37 | 22231 | @item -mno-volatile-cache |
d77de738 ML |
22232 | Enable cache bypass for volatile references. |
22233 | ||
22234 | @end table | |
22235 | ||
22236 | The following options fine tune code generation: | |
22237 | @c code generation tuning options | |
22238 | @table @gcctabopt | |
d77de738 | 22239 | @opindex malign-call |
ddf6fe37 | 22240 | @item -malign-call |
d77de738 ML |
22241 | Does nothing. Preserved for backward compatibility. |
22242 | ||
d77de738 | 22243 | @opindex mauto-modify-reg |
ddf6fe37 | 22244 | @item -mauto-modify-reg |
d77de738 ML |
22245 | Enable the use of pre/post modify with register displacement. |
22246 | ||
d77de738 | 22247 | @opindex mbbit-peephole |
ddf6fe37 | 22248 | @item -mbbit-peephole |
07f7615c | 22249 | Does nothing. Preserved for backward compatibility. |
d77de738 | 22250 | |
d77de738 | 22251 | @opindex mno-brcc |
ddf6fe37 | 22252 | @item -mno-brcc |
d77de738 ML |
22253 | This option disables a target-specific pass in @file{arc_reorg} to |
22254 | generate compare-and-branch (@code{br@var{cc}}) instructions. | |
22255 | It has no effect on | |
22256 | generation of these instructions driven by the combiner pass. | |
22257 | ||
d77de738 | 22258 | @opindex mcase-vector-pcrel |
ddf6fe37 | 22259 | @item -mcase-vector-pcrel |
d77de738 ML |
22260 | Use PC-relative switch case tables to enable case table shortening. |
22261 | This is the default for @option{-Os}. | |
22262 | ||
d77de738 | 22263 | @opindex mcompact-casesi |
ddf6fe37 | 22264 | @item -mcompact-casesi |
d77de738 ML |
22265 | Enable compact @code{casesi} pattern. This is the default for @option{-Os}, |
22266 | and only available for ARCv1 cores. This option is deprecated. | |
22267 | ||
d77de738 | 22268 | @opindex mno-cond-exec |
ddf6fe37 | 22269 | @item -mno-cond-exec |
d77de738 ML |
22270 | Disable the ARCompact-specific pass to generate conditional |
22271 | execution instructions. | |
22272 | ||
22273 | Due to delay slot scheduling and interactions between operand numbers, | |
22274 | literal sizes, instruction lengths, and the support for conditional execution, | |
22275 | the target-independent pass to generate conditional execution is often lacking, | |
22276 | so the ARC port has kept a special pass around that tries to find more | |
22277 | conditional execution generation opportunities after register allocation, | |
22278 | branch shortening, and delay slot scheduling have been done. This pass | |
22279 | generally, but not always, improves performance and code size, at the cost of | |
22280 | extra compilation time, which is why there is an option to switch it off. | |
22281 | If you have a problem with call instructions exceeding their allowable | |
22282 | offset range because they are conditionalized, you should consider using | |
22283 | @option{-mmedium-calls} instead. | |
22284 | ||
d77de738 | 22285 | @opindex mearly-cbranchsi |
ddf6fe37 | 22286 | @item -mearly-cbranchsi |
d77de738 ML |
22287 | Enable pre-reload use of the @code{cbranchsi} pattern. |
22288 | ||
d77de738 | 22289 | @opindex mexpand-adddi |
ddf6fe37 | 22290 | @item -mexpand-adddi |
d77de738 ML |
22291 | Expand @code{adddi3} and @code{subdi3} at RTL generation time into |
22292 | @code{add.f}, @code{adc} etc. This option is deprecated. | |
22293 | ||
d77de738 | 22294 | @opindex mindexed-loads |
ddf6fe37 | 22295 | @item -mindexed-loads |
d77de738 ML |
22296 | Enable the use of indexed loads. This can be problematic because some |
22297 | optimizers then assume that indexed stores exist, which is not | |
22298 | the case. | |
22299 | ||
d77de738 | 22300 | @opindex mlra |
ddf6fe37 | 22301 | @item -mlra |
d77de738 ML |
22302 | Enable Local Register Allocation. This is still experimental for ARC, |
22303 | so by default the compiler uses standard reload | |
22304 | (i.e.@: @option{-mno-lra}). | |
22305 | ||
d77de738 | 22306 | @opindex mlra-priority-none |
ddf6fe37 | 22307 | @item -mlra-priority-none |
d77de738 ML |
22308 | Don't indicate any priority for target registers. |
22309 | ||
d77de738 | 22310 | @opindex mlra-priority-compact |
ddf6fe37 | 22311 | @item -mlra-priority-compact |
d77de738 ML |
22312 | Indicate target register priority for r0..r3 / r12..r15. |
22313 | ||
d77de738 | 22314 | @opindex mlra-priority-noncompact |
ddf6fe37 | 22315 | @item -mlra-priority-noncompact |
d77de738 ML |
22316 | Reduce target register priority for r0..r3 / r12..r15. |
22317 | ||
d77de738 | 22318 | @opindex mmillicode |
ddf6fe37 | 22319 | @item -mmillicode |
d77de738 ML |
22320 | When optimizing for size (using @option{-Os}), prologues and epilogues |
22321 | that have to save or restore a large number of registers are often | |
22322 | shortened by using call to a special function in libgcc; this is | |
22323 | referred to as a @emph{millicode} call. As these calls can pose | |
22324 | performance issues, and/or cause linking issues when linking in a | |
22325 | nonstandard way, this option is provided to turn on or off millicode | |
22326 | call generation. | |
22327 | ||
d77de738 | 22328 | @opindex mcode-density-frame |
ddf6fe37 | 22329 | @item -mcode-density-frame |
d77de738 ML |
22330 | This option enable the compiler to emit @code{enter} and @code{leave} |
22331 | instructions. These instructions are only valid for CPUs with | |
22332 | code-density feature. | |
22333 | ||
d77de738 | 22334 | @opindex mmixed-code |
ddf6fe37 | 22335 | @item -mmixed-code |
d77de738 ML |
22336 | Does nothing. Preserved for backward compatibility. |
22337 | ||
d77de738 | 22338 | @opindex mq-class |
ddf6fe37 | 22339 | @item -mq-class |
d77de738 ML |
22340 | Ths option is deprecated. Enable @samp{q} instruction alternatives. |
22341 | This is the default for @option{-Os}. | |
22342 | ||
d77de738 | 22343 | @opindex mRcq |
ddf6fe37 | 22344 | @item -mRcq |
d77de738 ML |
22345 | Does nothing. Preserved for backward compatibility. |
22346 | ||
d77de738 | 22347 | @opindex mRcw |
ddf6fe37 | 22348 | @item -mRcw |
d77de738 ML |
22349 | Does nothing. Preserved for backward compatibility. |
22350 | ||
d77de738 | 22351 | @opindex msize-level |
ddf6fe37 | 22352 | @item -msize-level=@var{level} |
d77de738 ML |
22353 | Fine-tune size optimization with regards to instruction lengths and alignment. |
22354 | The recognized values for @var{level} are: | |
22355 | @table @samp | |
22356 | @item 0 | |
22357 | No size optimization. This level is deprecated and treated like @samp{1}. | |
22358 | ||
22359 | @item 1 | |
22360 | Short instructions are used opportunistically. | |
22361 | ||
22362 | @item 2 | |
22363 | In addition, alignment of loops and of code after barriers are dropped. | |
22364 | ||
22365 | @item 3 | |
22366 | In addition, optional data alignment is dropped, and the option @option{Os} is enabled. | |
22367 | ||
22368 | @end table | |
22369 | ||
22370 | This defaults to @samp{3} when @option{-Os} is in effect. Otherwise, | |
22371 | the behavior when this is not set is equivalent to level @samp{1}. | |
22372 | ||
d77de738 | 22373 | @opindex mtune |
ddf6fe37 | 22374 | @item -mtune=@var{cpu} |
d77de738 ML |
22375 | Set instruction scheduling parameters for @var{cpu}, overriding any implied |
22376 | by @option{-mcpu=}. | |
22377 | ||
22378 | Supported values for @var{cpu} are | |
22379 | ||
22380 | @table @samp | |
22381 | @item ARC600 | |
22382 | Tune for ARC600 CPU. | |
22383 | ||
22384 | @item ARC601 | |
22385 | Tune for ARC601 CPU. | |
22386 | ||
22387 | @item ARC700 | |
22388 | Tune for ARC700 CPU with standard multiplier block. | |
22389 | ||
22390 | @item ARC700-xmac | |
22391 | Tune for ARC700 CPU with XMAC block. | |
22392 | ||
22393 | @item ARC725D | |
22394 | Tune for ARC725D CPU. | |
22395 | ||
22396 | @item ARC750D | |
22397 | Tune for ARC750D CPU. | |
22398 | ||
22399 | @item core3 | |
22400 | Tune for ARCv2 core3 type CPU. This option enable usage of | |
22401 | @code{dbnz} instruction. | |
22402 | ||
22403 | @item release31a | |
22404 | Tune for ARC4x release 3.10a. | |
22405 | ||
22406 | @end table | |
22407 | ||
d77de738 | 22408 | @opindex mmultcost |
ddf6fe37 | 22409 | @item -mmultcost=@var{num} |
d77de738 ML |
22410 | Cost to assume for a multiply instruction, with @samp{4} being equal to a |
22411 | normal instruction. | |
22412 | ||
d77de738 | 22413 | @opindex munalign-prob-threshold |
ddf6fe37 | 22414 | @item -munalign-prob-threshold=@var{probability} |
d77de738 ML |
22415 | Does nothing. Preserved for backward compatibility. |
22416 | ||
22417 | @end table | |
22418 | ||
22419 | The following options are maintained for backward compatibility, but | |
22420 | are now deprecated and will be removed in a future release: | |
22421 | ||
22422 | @c Deprecated options | |
22423 | @table @gcctabopt | |
22424 | ||
d77de738 | 22425 | @opindex margonaut |
ddf6fe37 | 22426 | @item -margonaut |
d77de738 ML |
22427 | Obsolete FPX. |
22428 | ||
d77de738 | 22429 | @opindex mbig-endian |
d77de738 | 22430 | @opindex EB |
ddf6fe37 AA |
22431 | @item -mbig-endian |
22432 | @itemx -EB | |
d77de738 ML |
22433 | Compile code for big-endian targets. Use of these options is now |
22434 | deprecated. Big-endian code is supported by configuring GCC to build | |
22435 | @w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets, | |
22436 | for which big endian is the default. | |
22437 | ||
d77de738 | 22438 | @opindex mlittle-endian |
d77de738 | 22439 | @opindex EL |
ddf6fe37 AA |
22440 | @item -mlittle-endian |
22441 | @itemx -EL | |
d77de738 ML |
22442 | Compile code for little-endian targets. Use of these options is now |
22443 | deprecated. Little-endian code is supported by configuring GCC to build | |
22444 | @w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets, | |
22445 | for which little endian is the default. | |
22446 | ||
d77de738 | 22447 | @opindex mbarrel_shifter |
ddf6fe37 | 22448 | @item -mbarrel_shifter |
d77de738 ML |
22449 | Replaced by @option{-mbarrel-shifter}. |
22450 | ||
d77de738 | 22451 | @opindex mdpfp_compact |
ddf6fe37 | 22452 | @item -mdpfp_compact |
d77de738 ML |
22453 | Replaced by @option{-mdpfp-compact}. |
22454 | ||
d77de738 | 22455 | @opindex mdpfp_fast |
ddf6fe37 | 22456 | @item -mdpfp_fast |
d77de738 ML |
22457 | Replaced by @option{-mdpfp-fast}. |
22458 | ||
d77de738 | 22459 | @opindex mdsp_packa |
ddf6fe37 | 22460 | @item -mdsp_packa |
d77de738 ML |
22461 | Replaced by @option{-mdsp-packa}. |
22462 | ||
d77de738 | 22463 | @opindex mEA |
ddf6fe37 | 22464 | @item -mEA |
d77de738 ML |
22465 | Replaced by @option{-mea}. |
22466 | ||
d77de738 | 22467 | @opindex mmac_24 |
ddf6fe37 | 22468 | @item -mmac_24 |
d77de738 ML |
22469 | Replaced by @option{-mmac-24}. |
22470 | ||
d77de738 | 22471 | @opindex mmac_d16 |
ddf6fe37 | 22472 | @item -mmac_d16 |
d77de738 ML |
22473 | Replaced by @option{-mmac-d16}. |
22474 | ||
d77de738 | 22475 | @opindex mspfp_compact |
ddf6fe37 | 22476 | @item -mspfp_compact |
d77de738 ML |
22477 | Replaced by @option{-mspfp-compact}. |
22478 | ||
d77de738 | 22479 | @opindex mspfp_fast |
ddf6fe37 | 22480 | @item -mspfp_fast |
d77de738 ML |
22481 | Replaced by @option{-mspfp-fast}. |
22482 | ||
d77de738 | 22483 | @opindex mtune |
ddf6fe37 | 22484 | @item -mtune=@var{cpu} |
d77de738 ML |
22485 | Values @samp{arc600}, @samp{arc601}, @samp{arc700} and |
22486 | @samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600}, | |
22487 | @samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively. | |
22488 | ||
d77de738 | 22489 | @opindex multcost |
ddf6fe37 | 22490 | @item -multcost=@var{num} |
d77de738 ML |
22491 | Replaced by @option{-mmultcost}. |
22492 | ||
22493 | @end table | |
22494 | ||
22495 | @node ARM Options | |
22496 | @subsection ARM Options | |
22497 | @cindex ARM options | |
22498 | ||
22499 | These @samp{-m} options are defined for the ARM port: | |
22500 | ||
22501 | @table @gcctabopt | |
d77de738 | 22502 | @opindex mabi |
ddf6fe37 | 22503 | @item -mabi=@var{name} |
d77de738 ML |
22504 | Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu}, |
22505 | @samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}. | |
22506 | ||
d77de738 | 22507 | @opindex mapcs-frame |
ddf6fe37 | 22508 | @item -mapcs-frame |
d77de738 ML |
22509 | Generate a stack frame that is compliant with the ARM Procedure Call |
22510 | Standard for all functions, even if this is not strictly necessary for | |
22511 | correct execution of the code. Specifying @option{-fomit-frame-pointer} | |
22512 | with this option causes the stack frames not to be generated for | |
22513 | leaf functions. The default is @option{-mno-apcs-frame}. | |
22514 | This option is deprecated. | |
22515 | ||
d77de738 | 22516 | @opindex mapcs |
ddf6fe37 | 22517 | @item -mapcs |
d77de738 ML |
22518 | This is a synonym for @option{-mapcs-frame} and is deprecated. |
22519 | ||
22520 | @ignore | |
22521 | @c not currently implemented | |
d77de738 | 22522 | @opindex mapcs-stack-check |
ddf6fe37 | 22523 | @item -mapcs-stack-check |
d77de738 ML |
22524 | Generate code to check the amount of stack space available upon entry to |
22525 | every function (that actually uses some stack space). If there is | |
22526 | insufficient space available then either the function | |
22527 | @code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is | |
22528 | called, depending upon the amount of stack space required. The runtime | |
22529 | system is required to provide these functions. The default is | |
22530 | @option{-mno-apcs-stack-check}, since this produces smaller code. | |
22531 | ||
22532 | @c not currently implemented | |
d77de738 | 22533 | @opindex mapcs-reentrant |
ddf6fe37 | 22534 | @item -mapcs-reentrant |
d77de738 ML |
22535 | Generate reentrant, position-independent code. The default is |
22536 | @option{-mno-apcs-reentrant}. | |
22537 | @end ignore | |
22538 | ||
d77de738 | 22539 | @opindex mthumb-interwork |
ddf6fe37 | 22540 | @item -mthumb-interwork |
d77de738 ML |
22541 | Generate code that supports calling between the ARM and Thumb |
22542 | instruction sets. Without this option, on pre-v5 architectures, the | |
22543 | two instruction sets cannot be reliably used inside one program. The | |
22544 | default is @option{-mno-thumb-interwork}, since slightly larger code | |
22545 | is generated when @option{-mthumb-interwork} is specified. In AAPCS | |
22546 | configurations this option is meaningless. | |
22547 | ||
d77de738 ML |
22548 | @opindex mno-sched-prolog |
22549 | @opindex msched-prolog | |
ddf6fe37 | 22550 | @item -mno-sched-prolog |
d77de738 ML |
22551 | Prevent the reordering of instructions in the function prologue, or the |
22552 | merging of those instruction with the instructions in the function's | |
22553 | body. This means that all functions start with a recognizable set | |
22554 | of instructions (or in fact one of a choice from a small set of | |
22555 | different function prologues), and this information can be used to | |
22556 | locate the start of functions inside an executable piece of code. The | |
22557 | default is @option{-msched-prolog}. | |
22558 | ||
d77de738 | 22559 | @opindex mfloat-abi |
ddf6fe37 | 22560 | @item -mfloat-abi=@var{name} |
d77de738 ML |
22561 | Specifies which floating-point ABI to use. Permissible values |
22562 | are: @samp{soft}, @samp{softfp} and @samp{hard}. | |
22563 | ||
22564 | Specifying @samp{soft} causes GCC to generate output containing | |
22565 | library calls for floating-point operations. | |
22566 | @samp{softfp} allows the generation of code using hardware floating-point | |
22567 | instructions, but still uses the soft-float calling conventions. | |
22568 | @samp{hard} allows generation of floating-point instructions | |
22569 | and uses FPU-specific calling conventions. | |
22570 | ||
22571 | The default depends on the specific target configuration. Note that | |
22572 | the hard-float and soft-float ABIs are not link-compatible; you must | |
22573 | compile your entire program with the same ABI, and link with a | |
22574 | compatible set of libraries. | |
22575 | ||
d77de738 | 22576 | @opindex mgeneral-regs-only |
ddf6fe37 | 22577 | @item -mgeneral-regs-only |
d77de738 ML |
22578 | Generate code which uses only the general-purpose registers. This will prevent |
22579 | the compiler from using floating-point and Advanced SIMD registers but will not | |
22580 | impose any restrictions on the assembler. | |
22581 | ||
d77de738 | 22582 | @opindex mlittle-endian |
ddf6fe37 | 22583 | @item -mlittle-endian |
d77de738 ML |
22584 | Generate code for a processor running in little-endian mode. This is |
22585 | the default for all standard configurations. | |
22586 | ||
d77de738 | 22587 | @opindex mbig-endian |
ddf6fe37 | 22588 | @item -mbig-endian |
d77de738 ML |
22589 | Generate code for a processor running in big-endian mode; the default is |
22590 | to compile code for a little-endian processor. | |
22591 | ||
ddf6fe37 | 22592 | @opindex mbe8 |
d77de738 ML |
22593 | @item -mbe8 |
22594 | @itemx -mbe32 | |
d77de738 ML |
22595 | When linking a big-endian image select between BE8 and BE32 formats. |
22596 | The option has no effect for little-endian images and is ignored. The | |
22597 | default is dependent on the selected target architecture. For ARMv6 | |
22598 | and later architectures the default is BE8, for older architectures | |
22599 | the default is BE32. BE32 format has been deprecated by ARM. | |
22600 | ||
d77de738 | 22601 | @opindex march |
ddf6fe37 | 22602 | @item -march=@var{name}@r{[}+extension@dots{}@r{]} |
d77de738 ML |
22603 | This specifies the name of the target ARM architecture. GCC uses this |
22604 | name to determine what kind of instructions it can emit when generating | |
22605 | assembly code. This option can be used in conjunction with or instead | |
22606 | of the @option{-mcpu=} option. | |
22607 | ||
22608 | Permissible names are: | |
22609 | @samp{armv4t}, | |
22610 | @samp{armv5t}, @samp{armv5te}, | |
22611 | @samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2}, | |
22612 | @samp{armv6z}, @samp{armv6zk}, | |
22613 | @samp{armv7}, @samp{armv7-a}, @samp{armv7ve}, | |
22614 | @samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a}, | |
22615 | @samp{armv8.4-a}, | |
22616 | @samp{armv8.5-a}, | |
22617 | @samp{armv8.6-a}, | |
22618 | @samp{armv9-a}, | |
22619 | @samp{armv7-r}, | |
22620 | @samp{armv8-r}, | |
22621 | @samp{armv6-m}, @samp{armv6s-m}, | |
22622 | @samp{armv7-m}, @samp{armv7e-m}, | |
22623 | @samp{armv8-m.base}, @samp{armv8-m.main}, | |
22624 | @samp{armv8.1-m.main}, | |
22625 | @samp{armv9-a}, | |
22626 | @samp{iwmmxt} and @samp{iwmmxt2}. | |
22627 | ||
22628 | Additionally, the following architectures, which lack support for the | |
22629 | Thumb execution state, are recognized but support is deprecated: @samp{armv4}. | |
22630 | ||
22631 | Many of the architectures support extensions. These can be added by | |
22632 | appending @samp{+@var{extension}} to the architecture name. Extension | |
22633 | options are processed in order and capabilities accumulate. An extension | |
22634 | will also enable any necessary base extensions | |
22635 | upon which it depends. For example, the @samp{+crypto} extension | |
22636 | will always enable the @samp{+simd} extension. The exception to the | |
22637 | additive construction is for extensions that are prefixed with | |
22638 | @samp{+no@dots{}}: these extensions disable the specified option and | |
22639 | any other extensions that may depend on the presence of that | |
22640 | extension. | |
22641 | ||
22642 | For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to | |
22643 | writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is | |
22644 | entirely disabled by the @samp{+nofp} option that follows it. | |
22645 | ||
22646 | Most extension names are generically named, but have an effect that is | |
22647 | dependent upon the architecture to which it is applied. For example, | |
22648 | the @samp{+simd} option can be applied to both @samp{armv7-a} and | |
22649 | @samp{armv8-a} architectures, but will enable the original ARMv7-A | |
22650 | Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A | |
22651 | variant for @samp{armv8-a}. | |
22652 | ||
22653 | The table below lists the supported extensions for each architecture. | |
22654 | Architectures not mentioned do not support any extensions. | |
22655 | ||
22656 | @table @samp | |
22657 | @item armv5te | |
22658 | @itemx armv6 | |
22659 | @itemx armv6j | |
22660 | @itemx armv6k | |
22661 | @itemx armv6kz | |
22662 | @itemx armv6t2 | |
22663 | @itemx armv6z | |
22664 | @itemx armv6zk | |
22665 | @table @samp | |
22666 | @item +fp | |
22667 | The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be | |
22668 | used as an alias for this extension. | |
22669 | ||
22670 | @item +nofp | |
22671 | Disable the floating-point instructions. | |
22672 | @end table | |
22673 | ||
22674 | @item armv7 | |
22675 | The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures. | |
22676 | @table @samp | |
22677 | @item +fp | |
22678 | The VFPv3 floating-point instructions, with 16 double-precision | |
22679 | registers. The extension @samp{+vfpv3-d16} can be used as an alias | |
22680 | for this extension. Note that floating-point is not supported by the | |
22681 | base ARMv7-M architecture, but is compatible with both the ARMv7-A and | |
22682 | ARMv7-R architectures. | |
22683 | ||
22684 | @item +nofp | |
22685 | Disable the floating-point instructions. | |
22686 | @end table | |
22687 | ||
22688 | @item armv7-a | |
22689 | @table @samp | |
22690 | @item +mp | |
22691 | The multiprocessing extension. | |
22692 | ||
22693 | @item +sec | |
22694 | The security extension. | |
22695 | ||
22696 | @item +fp | |
22697 | The VFPv3 floating-point instructions, with 16 double-precision | |
22698 | registers. The extension @samp{+vfpv3-d16} can be used as an alias | |
22699 | for this extension. | |
22700 | ||
22701 | @item +simd | |
22702 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions. | |
22703 | The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases | |
22704 | for this extension. | |
22705 | ||
22706 | @item +vfpv3 | |
22707 | The VFPv3 floating-point instructions, with 32 double-precision | |
22708 | registers. | |
22709 | ||
22710 | @item +vfpv3-d16-fp16 | |
22711 | The VFPv3 floating-point instructions, with 16 double-precision | |
22712 | registers and the half-precision floating-point conversion operations. | |
22713 | ||
22714 | @item +vfpv3-fp16 | |
22715 | The VFPv3 floating-point instructions, with 32 double-precision | |
22716 | registers and the half-precision floating-point conversion operations. | |
22717 | ||
22718 | @item +vfpv4-d16 | |
22719 | The VFPv4 floating-point instructions, with 16 double-precision | |
22720 | registers. | |
22721 | ||
22722 | @item +vfpv4 | |
22723 | The VFPv4 floating-point instructions, with 32 double-precision | |
22724 | registers. | |
22725 | ||
22726 | @item +neon-fp16 | |
22727 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with | |
22728 | the half-precision floating-point conversion operations. | |
22729 | ||
22730 | @item +neon-vfpv4 | |
22731 | The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. | |
22732 | ||
22733 | @item +nosimd | |
22734 | Disable the Advanced SIMD instructions (does not disable floating point). | |
22735 | ||
22736 | @item +nofp | |
22737 | Disable the floating-point and Advanced SIMD instructions. | |
22738 | @end table | |
22739 | ||
22740 | @item armv7ve | |
22741 | The extended version of the ARMv7-A architecture with support for | |
22742 | virtualization. | |
22743 | @table @samp | |
22744 | @item +fp | |
22745 | The VFPv4 floating-point instructions, with 16 double-precision registers. | |
22746 | The extension @samp{+vfpv4-d16} can be used as an alias for this extension. | |
22747 | ||
22748 | @item +simd | |
22749 | The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The | |
22750 | extension @samp{+neon-vfpv4} can be used as an alias for this extension. | |
22751 | ||
22752 | @item +vfpv3-d16 | |
22753 | The VFPv3 floating-point instructions, with 16 double-precision | |
22754 | registers. | |
22755 | ||
22756 | @item +vfpv3 | |
22757 | The VFPv3 floating-point instructions, with 32 double-precision | |
22758 | registers. | |
22759 | ||
22760 | @item +vfpv3-d16-fp16 | |
22761 | The VFPv3 floating-point instructions, with 16 double-precision | |
22762 | registers and the half-precision floating-point conversion operations. | |
22763 | ||
22764 | @item +vfpv3-fp16 | |
22765 | The VFPv3 floating-point instructions, with 32 double-precision | |
22766 | registers and the half-precision floating-point conversion operations. | |
22767 | ||
22768 | @item +vfpv4-d16 | |
22769 | The VFPv4 floating-point instructions, with 16 double-precision | |
22770 | registers. | |
22771 | ||
22772 | @item +vfpv4 | |
22773 | The VFPv4 floating-point instructions, with 32 double-precision | |
22774 | registers. | |
22775 | ||
22776 | @item +neon | |
22777 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions. | |
22778 | The extension @samp{+neon-vfpv3} can be used as an alias for this extension. | |
22779 | ||
22780 | @item +neon-fp16 | |
22781 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with | |
22782 | the half-precision floating-point conversion operations. | |
22783 | ||
22784 | @item +nosimd | |
22785 | Disable the Advanced SIMD instructions (does not disable floating point). | |
22786 | ||
22787 | @item +nofp | |
22788 | Disable the floating-point and Advanced SIMD instructions. | |
22789 | @end table | |
22790 | ||
22791 | @item armv8-a | |
22792 | @table @samp | |
22793 | @item +crc | |
22794 | The Cyclic Redundancy Check (CRC) instructions. | |
22795 | @item +simd | |
22796 | The ARMv8-A Advanced SIMD and floating-point instructions. | |
22797 | @item +crypto | |
22798 | The cryptographic instructions. | |
22799 | @item +nocrypto | |
22800 | Disable the cryptographic instructions. | |
22801 | @item +nofp | |
22802 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22803 | @item +sb | |
22804 | Speculation Barrier Instruction. | |
22805 | @item +predres | |
22806 | Execution and Data Prediction Restriction Instructions. | |
22807 | @end table | |
22808 | ||
22809 | @item armv8.1-a | |
22810 | @table @samp | |
22811 | @item +simd | |
22812 | The ARMv8.1-A Advanced SIMD and floating-point instructions. | |
22813 | ||
22814 | @item +crypto | |
22815 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22816 | floating-point instructions. | |
22817 | ||
22818 | @item +nocrypto | |
22819 | Disable the cryptographic instructions. | |
22820 | ||
22821 | @item +nofp | |
22822 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22823 | ||
22824 | @item +sb | |
22825 | Speculation Barrier Instruction. | |
22826 | ||
22827 | @item +predres | |
22828 | Execution and Data Prediction Restriction Instructions. | |
22829 | @end table | |
22830 | ||
22831 | @item armv8.2-a | |
22832 | @itemx armv8.3-a | |
22833 | @table @samp | |
22834 | @item +fp16 | |
22835 | The half-precision floating-point data processing instructions. | |
22836 | This also enables the Advanced SIMD and floating-point instructions. | |
22837 | ||
22838 | @item +fp16fml | |
22839 | The half-precision floating-point fmla extension. This also enables | |
22840 | the half-precision floating-point extension and Advanced SIMD and | |
22841 | floating-point instructions. | |
22842 | ||
22843 | @item +simd | |
22844 | The ARMv8.1-A Advanced SIMD and floating-point instructions. | |
22845 | ||
22846 | @item +crypto | |
22847 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22848 | floating-point instructions. | |
22849 | ||
22850 | @item +dotprod | |
22851 | Enable the Dot Product extension. This also enables Advanced SIMD instructions. | |
22852 | ||
22853 | @item +nocrypto | |
22854 | Disable the cryptographic extension. | |
22855 | ||
22856 | @item +nofp | |
22857 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22858 | ||
22859 | @item +sb | |
22860 | Speculation Barrier Instruction. | |
22861 | ||
22862 | @item +predres | |
22863 | Execution and Data Prediction Restriction Instructions. | |
22864 | ||
22865 | @item +i8mm | |
22866 | 8-bit Integer Matrix Multiply instructions. | |
22867 | This also enables Advanced SIMD and floating-point instructions. | |
22868 | ||
22869 | @item +bf16 | |
22870 | Brain half-precision floating-point instructions. | |
22871 | This also enables Advanced SIMD and floating-point instructions. | |
22872 | @end table | |
22873 | ||
22874 | @item armv8.4-a | |
22875 | @table @samp | |
22876 | @item +fp16 | |
22877 | The half-precision floating-point data processing instructions. | |
22878 | This also enables the Advanced SIMD and floating-point instructions as well | |
22879 | as the Dot Product extension and the half-precision floating-point fmla | |
22880 | extension. | |
22881 | ||
22882 | @item +simd | |
22883 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22884 | Dot Product extension. | |
22885 | ||
22886 | @item +crypto | |
22887 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22888 | floating-point instructions as well as the Dot Product extension. | |
22889 | ||
22890 | @item +nocrypto | |
22891 | Disable the cryptographic extension. | |
22892 | ||
22893 | @item +nofp | |
22894 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22895 | ||
22896 | @item +sb | |
22897 | Speculation Barrier Instruction. | |
22898 | ||
22899 | @item +predres | |
22900 | Execution and Data Prediction Restriction Instructions. | |
22901 | ||
22902 | @item +i8mm | |
22903 | 8-bit Integer Matrix Multiply instructions. | |
22904 | This also enables Advanced SIMD and floating-point instructions. | |
22905 | ||
22906 | @item +bf16 | |
22907 | Brain half-precision floating-point instructions. | |
22908 | This also enables Advanced SIMD and floating-point instructions. | |
22909 | @end table | |
22910 | ||
22911 | @item armv8.5-a | |
22912 | @table @samp | |
22913 | @item +fp16 | |
22914 | The half-precision floating-point data processing instructions. | |
22915 | This also enables the Advanced SIMD and floating-point instructions as well | |
22916 | as the Dot Product extension and the half-precision floating-point fmla | |
22917 | extension. | |
22918 | ||
22919 | @item +simd | |
22920 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22921 | Dot Product extension. | |
22922 | ||
22923 | @item +crypto | |
22924 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22925 | floating-point instructions as well as the Dot Product extension. | |
22926 | ||
22927 | @item +nocrypto | |
22928 | Disable the cryptographic extension. | |
22929 | ||
22930 | @item +nofp | |
22931 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22932 | ||
22933 | @item +i8mm | |
22934 | 8-bit Integer Matrix Multiply instructions. | |
22935 | This also enables Advanced SIMD and floating-point instructions. | |
22936 | ||
22937 | @item +bf16 | |
22938 | Brain half-precision floating-point instructions. | |
22939 | This also enables Advanced SIMD and floating-point instructions. | |
22940 | @end table | |
22941 | ||
22942 | @item armv8.6-a | |
22943 | @table @samp | |
22944 | @item +fp16 | |
22945 | The half-precision floating-point data processing instructions. | |
22946 | This also enables the Advanced SIMD and floating-point instructions as well | |
22947 | as the Dot Product extension and the half-precision floating-point fmla | |
22948 | extension. | |
22949 | ||
22950 | @item +simd | |
22951 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22952 | Dot Product extension. | |
22953 | ||
22954 | @item +crypto | |
22955 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22956 | floating-point instructions as well as the Dot Product extension. | |
22957 | ||
22958 | @item +nocrypto | |
22959 | Disable the cryptographic extension. | |
22960 | ||
22961 | @item +nofp | |
22962 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22963 | ||
22964 | @item +i8mm | |
22965 | 8-bit Integer Matrix Multiply instructions. | |
22966 | This also enables Advanced SIMD and floating-point instructions. | |
22967 | ||
22968 | @item +bf16 | |
22969 | Brain half-precision floating-point instructions. | |
22970 | This also enables Advanced SIMD and floating-point instructions. | |
22971 | @end table | |
22972 | ||
22973 | @item armv7-r | |
22974 | @table @samp | |
22975 | @item +fp.sp | |
22976 | The single-precision VFPv3 floating-point instructions. The extension | |
22977 | @samp{+vfpv3xd} can be used as an alias for this extension. | |
22978 | ||
22979 | @item +fp | |
22980 | The VFPv3 floating-point instructions with 16 double-precision registers. | |
22981 | The extension +vfpv3-d16 can be used as an alias for this extension. | |
22982 | ||
22983 | @item +vfpv3xd-d16-fp16 | |
22984 | The single-precision VFPv3 floating-point instructions with 16 double-precision | |
22985 | registers and the half-precision floating-point conversion operations. | |
22986 | ||
22987 | @item +vfpv3-d16-fp16 | |
22988 | The VFPv3 floating-point instructions with 16 double-precision | |
22989 | registers and the half-precision floating-point conversion operations. | |
22990 | ||
22991 | @item +nofp | |
22992 | Disable the floating-point extension. | |
22993 | ||
22994 | @item +idiv | |
22995 | The ARM-state integer division instructions. | |
22996 | ||
22997 | @item +noidiv | |
22998 | Disable the ARM-state integer division extension. | |
22999 | @end table | |
23000 | ||
23001 | @item armv7e-m | |
23002 | @table @samp | |
23003 | @item +fp | |
23004 | The single-precision VFPv4 floating-point instructions. | |
23005 | ||
23006 | @item +fpv5 | |
23007 | The single-precision FPv5 floating-point instructions. | |
23008 | ||
23009 | @item +fp.dp | |
23010 | The single- and double-precision FPv5 floating-point instructions. | |
23011 | ||
23012 | @item +nofp | |
23013 | Disable the floating-point extensions. | |
23014 | @end table | |
23015 | ||
23016 | @item armv8.1-m.main | |
23017 | @table @samp | |
23018 | ||
23019 | @item +dsp | |
23020 | The DSP instructions. | |
23021 | ||
23022 | @item +mve | |
23023 | The M-Profile Vector Extension (MVE) integer instructions. | |
23024 | ||
23025 | @item +mve.fp | |
23026 | The M-Profile Vector Extension (MVE) integer and single precision | |
23027 | floating-point instructions. | |
23028 | ||
23029 | @item +fp | |
23030 | The single-precision floating-point instructions. | |
23031 | ||
23032 | @item +fp.dp | |
23033 | The single- and double-precision floating-point instructions. | |
23034 | ||
23035 | @item +nofp | |
23036 | Disable the floating-point extension. | |
23037 | ||
23038 | @item +cdecp0, +cdecp1, ... , +cdecp7 | |
23039 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
23040 | to the numbers given in the options in the range 0 to 7. | |
c91bb7b9 AC |
23041 | |
23042 | @item +pacbti | |
23043 | Enable the Pointer Authentication and Branch Target Identification Extension. | |
d77de738 ML |
23044 | @end table |
23045 | ||
23046 | @item armv8-m.main | |
23047 | @table @samp | |
23048 | @item +dsp | |
23049 | The DSP instructions. | |
23050 | ||
23051 | @item +nodsp | |
23052 | Disable the DSP extension. | |
23053 | ||
23054 | @item +fp | |
23055 | The single-precision floating-point instructions. | |
23056 | ||
23057 | @item +fp.dp | |
23058 | The single- and double-precision floating-point instructions. | |
23059 | ||
23060 | @item +nofp | |
23061 | Disable the floating-point extension. | |
23062 | ||
23063 | @item +cdecp0, +cdecp1, ... , +cdecp7 | |
23064 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
23065 | to the numbers given in the options in the range 0 to 7. | |
23066 | @end table | |
23067 | ||
23068 | @item armv8-r | |
23069 | @table @samp | |
23070 | @item +crc | |
23071 | The Cyclic Redundancy Check (CRC) instructions. | |
23072 | @item +fp.sp | |
23073 | The single-precision FPv5 floating-point instructions. | |
23074 | @item +simd | |
23075 | The ARMv8-A Advanced SIMD and floating-point instructions. | |
23076 | @item +crypto | |
23077 | The cryptographic instructions. | |
23078 | @item +nocrypto | |
23079 | Disable the cryptographic instructions. | |
23080 | @item +nofp | |
23081 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
23082 | @end table | |
23083 | ||
23084 | @end table | |
23085 | ||
23086 | @option{-march=native} causes the compiler to auto-detect the architecture | |
23087 | of the build computer. At present, this feature is only supported on | |
23088 | GNU/Linux, and not all architectures are recognized. If the auto-detect | |
23089 | is unsuccessful the option has no effect. | |
23090 | ||
d77de738 | 23091 | @opindex mtune |
ddf6fe37 | 23092 | @item -mtune=@var{name} |
d77de738 ML |
23093 | This option specifies the name of the target ARM processor for |
23094 | which GCC should tune the performance of the code. | |
23095 | For some ARM implementations better performance can be obtained by using | |
23096 | this option. | |
23097 | Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t}, | |
23098 | @samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110}, | |
23099 | @samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810}, | |
23100 | @samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t}, | |
23101 | @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s}, | |
23102 | @samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t}, | |
23103 | @samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e}, | |
23104 | @samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp}, | |
23105 | @samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s}, | |
23106 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8}, | |
23107 | @samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17}, | |
23108 | @samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, | |
23109 | @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, | |
23110 | @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77}, | |
23111 | @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710}, | |
23112 | @samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5}, | |
23113 | @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus}, | |
23114 | @samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3}, | |
23115 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33}, | |
43c4f982 | 23116 | @samp{cortex-m35p}, @samp{cortex-m52}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1}, |
ccfd1e7f | 23117 | @samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply}, |
d77de738 ML |
23118 | @samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4}, |
23119 | @samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale}, | |
23120 | @samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626}, | |
23121 | @samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1}, | |
23122 | @samp{xgene1}. | |
23123 | ||
23124 | Additionally, this option can specify that GCC should tune the performance | |
23125 | of the code for a big.LITTLE system. Permissible names are: | |
23126 | @samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7}, | |
23127 | @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
23128 | @samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
23129 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}. | |
23130 | ||
23131 | @option{-mtune=generic-@var{arch}} specifies that GCC should tune the | |
23132 | performance for a blend of processors within architecture @var{arch}. | |
23133 | The aim is to generate code that run well on the current most popular | |
23134 | processors, balancing between optimizations that benefit some CPUs in the | |
23135 | range, and avoiding performance pitfalls of other CPUs. The effects of | |
23136 | this option may change in future GCC versions as CPU models come and go. | |
23137 | ||
23138 | @option{-mtune} permits the same extension options as @option{-mcpu}, but | |
23139 | the extension options do not affect the tuning of the generated code. | |
23140 | ||
23141 | @option{-mtune=native} causes the compiler to auto-detect the CPU | |
23142 | of the build computer. At present, this feature is only supported on | |
23143 | GNU/Linux, and not all architectures are recognized. If the auto-detect is | |
23144 | unsuccessful the option has no effect. | |
23145 | ||
d77de738 | 23146 | @opindex mcpu |
ddf6fe37 | 23147 | @item -mcpu=@var{name}@r{[}+extension@dots{}@r{]} |
d77de738 ML |
23148 | This specifies the name of the target ARM processor. GCC uses this name |
23149 | to derive the name of the target ARM architecture (as if specified | |
23150 | by @option{-march}) and the ARM processor type for which to tune for | |
23151 | performance (as if specified by @option{-mtune}). Where this option | |
23152 | is used in conjunction with @option{-march} or @option{-mtune}, | |
23153 | those options take precedence over the appropriate part of this option. | |
23154 | ||
23155 | Many of the supported CPUs implement optional architectural | |
23156 | extensions. Where this is so the architectural extensions are | |
23157 | normally enabled by default. If implementations that lack the | |
23158 | extension exist, then the extension syntax can be used to disable | |
23159 | those extensions that have been omitted. For floating-point and | |
23160 | Advanced SIMD (Neon) instructions, the settings of the options | |
23161 | @option{-mfloat-abi} and @option{-mfpu} must also be considered: | |
23162 | floating-point and Advanced SIMD instructions will only be used if | |
23163 | @option{-mfloat-abi} is not set to @samp{soft}; and any setting of | |
23164 | @option{-mfpu} other than @samp{auto} will override the available | |
23165 | floating-point and SIMD extension instructions. | |
23166 | ||
23167 | For example, @samp{cortex-a9} can be found in three major | |
23168 | configurations: integer only, with just a floating-point unit or with | |
23169 | floating-point and Advanced SIMD. The default is to enable all the | |
23170 | instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can | |
23171 | be used to disable just the SIMD or both the SIMD and floating-point | |
23172 | instructions respectively. | |
23173 | ||
23174 | Permissible names for this option are the same as those for | |
23175 | @option{-mtune}. | |
23176 | ||
23177 | The following extension options are common to the listed CPUs: | |
23178 | ||
23179 | @table @samp | |
23180 | @item +nodsp | |
ccfd1e7f | 23181 | Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p}, |
43c4f982 CJW |
23182 | @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}. |
23183 | Also disable the M-Profile Vector Extension (MVE) integer and | |
23184 | single precision floating-point instructions on | |
23185 | @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}. | |
ccfd1e7f SP |
23186 | |
23187 | @item +nopacbti | |
23188 | Disable the Pointer Authentication and Branch Target Identification Extension | |
43c4f982 | 23189 | on @samp{cortex-m52} and @samp{cortex-m85}. |
d77de738 ML |
23190 | |
23191 | @item +nomve | |
23192 | Disable the M-Profile Vector Extension (MVE) integer and single precision | |
43c4f982 | 23193 | floating-point instructions on @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}. |
d77de738 ML |
23194 | |
23195 | @item +nomve.fp | |
23196 | Disable the M-Profile Vector Extension (MVE) single precision floating-point | |
43c4f982 | 23197 | instructions on @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}. |
d77de738 | 23198 | |
798a0d05 SP |
23199 | @item +cdecp0, +cdecp1, ... , +cdecp7 |
23200 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
43c4f982 | 23201 | to the numbers given in the options in the range 0 to 7 on @samp{cortex-m52} and @samp{cortex-m55}. |
798a0d05 | 23202 | |
d77de738 ML |
23203 | @item +nofp |
23204 | Disables the floating-point instructions on @samp{arm9e}, | |
23205 | @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e}, | |
23206 | @samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s}, | |
23207 | @samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, | |
ccfd1e7f | 23208 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}, |
43c4f982 | 23209 | @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}. |
d77de738 ML |
23210 | Disables the floating-point and SIMD instructions on |
23211 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, | |
23212 | @samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12}, | |
23213 | @samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7}, | |
23214 | @samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35}, | |
23215 | @samp{cortex-a53} and @samp{cortex-a55}. | |
23216 | ||
23217 | @item +nofp.dp | |
23218 | Disables the double-precision component of the floating-point instructions | |
23219 | on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, | |
23220 | @samp{cortex-r52plus} and @samp{cortex-m7}. | |
23221 | ||
23222 | @item +nosimd | |
23223 | Disables the SIMD (but not floating-point) instructions on | |
23224 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7} | |
23225 | and @samp{cortex-a9}. | |
23226 | ||
23227 | @item +crypto | |
23228 | Enables the cryptographic instructions on @samp{cortex-a32}, | |
23229 | @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57}, | |
23230 | @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1}, | |
23231 | @samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
23232 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and | |
23233 | @samp{cortex-a75.cortex-a55}. | |
23234 | @end table | |
23235 | ||
23236 | Additionally the @samp{generic-armv7-a} pseudo target defaults to | |
23237 | VFPv3 with 16 double-precision registers. It supports the following | |
23238 | extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16}, | |
23239 | @samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16}, | |
23240 | @samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3}, | |
23241 | @samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for | |
23242 | the extensions to @option{-march=armv7-a}. | |
23243 | ||
23244 | @option{-mcpu=generic-@var{arch}} is also permissible, and is | |
23245 | equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}. | |
23246 | See @option{-mtune} for more information. | |
23247 | ||
23248 | @option{-mcpu=native} causes the compiler to auto-detect the CPU | |
23249 | of the build computer. At present, this feature is only supported on | |
23250 | GNU/Linux, and not all architectures are recognized. If the auto-detect | |
23251 | is unsuccessful the option has no effect. | |
23252 | ||
d77de738 | 23253 | @opindex mfpu |
ddf6fe37 | 23254 | @item -mfpu=@var{name} |
d77de738 ML |
23255 | This specifies what floating-point hardware (or hardware emulation) is |
23256 | available on the target. Permissible names are: @samp{auto}, @samp{vfpv2}, | |
23257 | @samp{vfpv3}, | |
23258 | @samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd}, | |
23259 | @samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4}, | |
23260 | @samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4}, | |
23261 | @samp{fpv5-d16}, @samp{fpv5-sp-d16}, | |
23262 | @samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}. | |
23263 | Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp} | |
23264 | is an alias for @samp{vfpv2}. | |
23265 | ||
23266 | The setting @samp{auto} is the default and is special. It causes the | |
23267 | compiler to select the floating-point and Advanced SIMD instructions | |
23268 | based on the settings of @option{-mcpu} and @option{-march}. | |
23269 | ||
23270 | If the selected floating-point hardware includes the NEON extension | |
23271 | (e.g.@: @option{-mfpu=neon}), note that floating-point | |
23272 | operations are not generated by GCC's auto-vectorization pass unless | |
23273 | @option{-funsafe-math-optimizations} is also specified. This is | |
23274 | because NEON hardware does not fully implement the IEEE 754 standard for | |
23275 | floating-point arithmetic (in particular denormal values are treated as | |
23276 | zero), so the use of NEON instructions may lead to a loss of precision. | |
23277 | ||
23278 | You 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}). | |
23279 | ||
d77de738 | 23280 | @opindex mfp16-format |
ddf6fe37 | 23281 | @item -mfp16-format=@var{name} |
d77de738 ML |
23282 | Specify the format of the @code{__fp16} half-precision floating-point type. |
23283 | Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative}; | |
23284 | the default is @samp{none}, in which case the @code{__fp16} type is not | |
23285 | defined. @xref{Half-Precision}, for more information. | |
23286 | ||
d77de738 | 23287 | @opindex mstructure-size-boundary |
ddf6fe37 | 23288 | @item -mstructure-size-boundary=@var{n} |
d77de738 ML |
23289 | The sizes of all structures and unions are rounded up to a multiple |
23290 | of the number of bits set by this option. Permissible values are 8, 32 | |
23291 | and 64. The default value varies for different toolchains. For the COFF | |
23292 | targeted toolchain the default value is 8. A value of 64 is only allowed | |
23293 | if the underlying ABI supports it. | |
23294 | ||
23295 | Specifying a larger number can produce faster, more efficient code, but | |
23296 | can also increase the size of the program. Different values are potentially | |
23297 | incompatible. Code compiled with one value cannot necessarily expect to | |
23298 | work with code or libraries compiled with another value, if they exchange | |
23299 | information using structures or unions. | |
23300 | ||
23301 | This option is deprecated. | |
23302 | ||
d77de738 | 23303 | @opindex mabort-on-noreturn |
ddf6fe37 | 23304 | @item -mabort-on-noreturn |
d77de738 ML |
23305 | Generate a call to the function @code{abort} at the end of a |
23306 | @code{noreturn} function. It is executed if the function tries to | |
23307 | return. | |
23308 | ||
d77de738 ML |
23309 | @opindex mlong-calls |
23310 | @opindex mno-long-calls | |
ddf6fe37 AA |
23311 | @item -mlong-calls |
23312 | @itemx -mno-long-calls | |
d77de738 ML |
23313 | Tells the compiler to perform function calls by first loading the |
23314 | address of the function into a register and then performing a subroutine | |
23315 | call on this register. This switch is needed if the target function | |
23316 | lies outside of the 64-megabyte addressing range of the offset-based | |
23317 | version of subroutine call instruction. | |
23318 | ||
23319 | Even if this switch is enabled, not all function calls are turned | |
23320 | into long calls. The heuristic is that static functions, functions | |
23321 | that have the @code{short_call} attribute, functions that are inside | |
23322 | the scope of a @code{#pragma no_long_calls} directive, and functions whose | |
23323 | definitions have already been compiled within the current compilation | |
23324 | unit are not turned into long calls. The exceptions to this rule are | |
23325 | that weak function definitions, functions with the @code{long_call} | |
23326 | attribute or the @code{section} attribute, and functions that are within | |
23327 | the scope of a @code{#pragma long_calls} directive are always | |
23328 | turned into long calls. | |
23329 | ||
23330 | This feature is not enabled by default. Specifying | |
23331 | @option{-mno-long-calls} restores the default behavior, as does | |
23332 | placing the function calls within the scope of a @code{#pragma | |
23333 | long_calls_off} directive. Note these switches have no effect on how | |
23334 | the compiler generates code to handle function calls via function | |
23335 | pointers. | |
23336 | ||
d77de738 | 23337 | @opindex msingle-pic-base |
ddf6fe37 | 23338 | @item -msingle-pic-base |
d77de738 ML |
23339 | Treat the register used for PIC addressing as read-only, rather than |
23340 | loading it in the prologue for each function. The runtime system is | |
23341 | responsible for initializing this register with an appropriate value | |
23342 | before execution begins. | |
23343 | ||
d77de738 | 23344 | @opindex mpic-register |
ddf6fe37 | 23345 | @item -mpic-register=@var{reg} |
d77de738 ML |
23346 | Specify the register to be used for PIC addressing. |
23347 | For standard PIC base case, the default is any suitable register | |
23348 | determined by compiler. For single PIC base case, the default is | |
23349 | @samp{R9} if target is EABI based or stack-checking is enabled, | |
23350 | otherwise the default is @samp{R10}. | |
23351 | ||
d77de738 | 23352 | @opindex mpic-data-is-text-relative |
ddf6fe37 | 23353 | @item -mpic-data-is-text-relative |
d77de738 ML |
23354 | Assume that the displacement between the text and data segments is fixed |
23355 | at static link time. This permits using PC-relative addressing | |
23356 | operations to access data known to be in the data segment. For | |
23357 | non-VxWorks RTP targets, this option is enabled by default. When | |
23358 | disabled on such targets, it will enable @option{-msingle-pic-base} by | |
23359 | default. | |
23360 | ||
d77de738 | 23361 | @opindex mpoke-function-name |
ddf6fe37 | 23362 | @item -mpoke-function-name |
d77de738 ML |
23363 | Write the name of each function into the text section, directly |
23364 | preceding the function prologue. The generated code is similar to this: | |
23365 | ||
23366 | @smallexample | |
23367 | t0 | |
23368 | .ascii "arm_poke_function_name", 0 | |
23369 | .align | |
23370 | t1 | |
23371 | .word 0xff000000 + (t1 - t0) | |
23372 | arm_poke_function_name | |
23373 | mov ip, sp | |
23374 | stmfd sp!, @{fp, ip, lr, pc@} | |
23375 | sub fp, ip, #4 | |
23376 | @end smallexample | |
23377 | ||
23378 | When performing a stack backtrace, code can inspect the value of | |
23379 | @code{pc} stored at @code{fp + 0}. If the trace function then looks at | |
23380 | location @code{pc - 12} and the top 8 bits are set, then we know that | |
23381 | there is a function name embedded immediately preceding this location | |
23382 | and has length @code{((pc[-3]) & 0xff000000)}. | |
23383 | ||
d77de738 ML |
23384 | @opindex marm |
23385 | @opindex mthumb | |
ddf6fe37 AA |
23386 | @item -mthumb |
23387 | @itemx -marm | |
d77de738 ML |
23388 | |
23389 | Select between generating code that executes in ARM and Thumb | |
23390 | states. The default for most configurations is to generate code | |
23391 | that executes in ARM state, but the default can be changed by | |
23392 | configuring GCC with the @option{--with-mode=}@var{state} | |
23393 | configure option. | |
23394 | ||
23395 | You can also override the ARM and Thumb mode for each function | |
23396 | by using the @code{target("thumb")} and @code{target("arm")} function attributes | |
23397 | (@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}). | |
23398 | ||
d77de738 | 23399 | @opindex mflip-thumb |
ddf6fe37 | 23400 | @item -mflip-thumb |
d77de738 ML |
23401 | Switch ARM/Thumb modes on alternating functions. |
23402 | This option is provided for regression testing of mixed Thumb/ARM code | |
23403 | generation, and is not intended for ordinary use in compiling code. | |
23404 | ||
d77de738 | 23405 | @opindex mtpcs-frame |
ddf6fe37 | 23406 | @item -mtpcs-frame |
d77de738 ML |
23407 | Generate a stack frame that is compliant with the Thumb Procedure Call |
23408 | Standard for all non-leaf functions. (A leaf function is one that does | |
23409 | not call any other functions.) The default is @option{-mno-tpcs-frame}. | |
23410 | ||
d77de738 | 23411 | @opindex mtpcs-leaf-frame |
ddf6fe37 | 23412 | @item -mtpcs-leaf-frame |
d77de738 ML |
23413 | Generate a stack frame that is compliant with the Thumb Procedure Call |
23414 | Standard for all leaf functions. (A leaf function is one that does | |
23415 | not call any other functions.) The default is @option{-mno-apcs-leaf-frame}. | |
23416 | ||
d77de738 | 23417 | @opindex mcallee-super-interworking |
ddf6fe37 | 23418 | @item -mcallee-super-interworking |
d77de738 ML |
23419 | Gives all externally visible functions in the file being compiled an ARM |
23420 | instruction set header which switches to Thumb mode before executing the | |
23421 | rest of the function. This allows these functions to be called from | |
23422 | non-interworking code. This option is not valid in AAPCS configurations | |
23423 | because interworking is enabled by default. | |
23424 | ||
d77de738 | 23425 | @opindex mcaller-super-interworking |
ddf6fe37 | 23426 | @item -mcaller-super-interworking |
d77de738 ML |
23427 | Allows calls via function pointers (including virtual functions) to |
23428 | execute correctly regardless of whether the target code has been | |
23429 | compiled for interworking or not. There is a small overhead in the cost | |
23430 | of executing a function pointer if this option is enabled. This option | |
23431 | is not valid in AAPCS configurations because interworking is enabled | |
23432 | by default. | |
23433 | ||
d77de738 | 23434 | @opindex mtp |
ddf6fe37 | 23435 | @item -mtp=@var{name} |
cca8d9e5 KT |
23436 | Specify the access model for the thread local storage pointer. The model |
23437 | @samp{soft} generates calls to @code{__aeabi_read_tp}. Other accepted | |
23438 | models are @samp{tpidrurw}, @samp{tpidruro} and @samp{tpidrprw} which fetch | |
23439 | the thread pointer from the corresponding system register directly | |
23440 | (supported from the arm6k architecture and later). These system registers | |
23441 | are accessed through the CP15 co-processor interface and the argument | |
23442 | @samp{cp15} is also accepted as a convenience alias of @samp{tpidruro}. | |
23443 | The argument @samp{auto} uses the best available method for the selected | |
23444 | processor. The default setting is @samp{auto}. | |
d77de738 | 23445 | |
d77de738 | 23446 | @opindex mtls-dialect |
ddf6fe37 | 23447 | @item -mtls-dialect=@var{dialect} |
d77de738 ML |
23448 | Specify the dialect to use for accessing thread local storage. Two |
23449 | @var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The | |
23450 | @samp{gnu} dialect selects the original GNU scheme for supporting | |
23451 | local and global dynamic TLS models. The @samp{gnu2} dialect | |
23452 | selects the GNU descriptor scheme, which provides better performance | |
23453 | for shared libraries. The GNU descriptor scheme is compatible with | |
23454 | the original scheme, but does require new assembler, linker and | |
23455 | library support. Initial and local exec TLS models are unaffected by | |
23456 | this option and always use the original scheme. | |
23457 | ||
d77de738 | 23458 | @opindex mword-relocations |
ddf6fe37 | 23459 | @item -mword-relocations |
d77de738 ML |
23460 | Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32). |
23461 | This is enabled by default on targets (uClinux, SymbianOS) where the runtime | |
23462 | loader imposes this restriction, and when @option{-fpic} or @option{-fPIC} | |
23463 | is specified. This option conflicts with @option{-mslow-flash-data}. | |
23464 | ||
d77de738 | 23465 | @opindex mfix-cortex-m3-ldrd |
ddf6fe37 | 23466 | @item -mfix-cortex-m3-ldrd |
d77de738 ML |
23467 | Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions |
23468 | with overlapping destination and base registers are used. This option avoids | |
23469 | generating these instructions. This option is enabled by default when | |
23470 | @option{-mcpu=cortex-m3} is specified. | |
23471 | ||
23472 | @item -mfix-cortex-a57-aes-1742098 | |
23473 | @itemx -mno-fix-cortex-a57-aes-1742098 | |
23474 | @itemx -mfix-cortex-a72-aes-1655431 | |
23475 | @itemx -mno-fix-cortex-a72-aes-1655431 | |
23476 | Enable (disable) mitigation for an erratum on Cortex-A57 and | |
23477 | Cortex-A72 that affects the AES cryptographic instructions. This | |
23478 | option is enabled by default when either @option{-mcpu=cortex-a57} or | |
23479 | @option{-mcpu=cortex-a72} is specified. | |
23480 | ||
d77de738 ML |
23481 | @opindex munaligned-access |
23482 | @opindex mno-unaligned-access | |
ddf6fe37 AA |
23483 | @item -munaligned-access |
23484 | @itemx -mno-unaligned-access | |
d77de738 ML |
23485 | Enables (or disables) reading and writing of 16- and 32- bit values |
23486 | from addresses that are not 16- or 32- bit aligned. By default | |
23487 | unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for | |
23488 | ARMv8-M Baseline architectures, and enabled for all other | |
23489 | architectures. If unaligned access is not enabled then words in packed | |
23490 | data structures are accessed a byte at a time. | |
23491 | ||
23492 | The ARM attribute @code{Tag_CPU_unaligned_access} is set in the | |
23493 | generated object file to either true or false, depending upon the | |
23494 | setting of this option. If unaligned access is enabled then the | |
23495 | preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also | |
23496 | defined. | |
23497 | ||
d77de738 | 23498 | @opindex mneon-for-64bits |
ddf6fe37 | 23499 | @item -mneon-for-64bits |
d77de738 ML |
23500 | This option is deprecated and has no effect. |
23501 | ||
d77de738 | 23502 | @opindex mslow-flash-data |
ddf6fe37 | 23503 | @item -mslow-flash-data |
d77de738 ML |
23504 | Assume loading data from flash is slower than fetching instruction. |
23505 | Therefore literal load is minimized for better performance. | |
23506 | This option is only supported when compiling for ARMv7 M-profile and | |
23507 | off by default. It conflicts with @option{-mword-relocations}. | |
23508 | ||
d77de738 | 23509 | @opindex masm-syntax-unified |
ddf6fe37 | 23510 | @item -masm-syntax-unified |
d77de738 ML |
23511 | Assume inline assembler is using unified asm syntax. The default is |
23512 | currently off which implies divided syntax. This option has no impact | |
23513 | on Thumb2. However, this may change in future releases of GCC. | |
23514 | Divided syntax should be considered deprecated. | |
23515 | ||
d77de738 | 23516 | @opindex mrestrict-it |
ddf6fe37 | 23517 | @item -mrestrict-it |
d77de738 ML |
23518 | Restricts generation of IT blocks to conform to the rules of ARMv8-A. |
23519 | IT blocks can only contain a single 16-bit instruction from a select | |
23520 | set of instructions. This option is on by default for ARMv8-A Thumb mode. | |
23521 | ||
d77de738 | 23522 | @opindex mprint-tune-info |
ddf6fe37 | 23523 | @item -mprint-tune-info |
d77de738 ML |
23524 | Print CPU tuning information as comment in assembler file. This is |
23525 | an option used only for regression testing of the compiler and not | |
23526 | intended for ordinary use in compiling code. This option is disabled | |
23527 | by default. | |
23528 | ||
d77de738 | 23529 | @opindex mverbose-cost-dump |
ddf6fe37 | 23530 | @item -mverbose-cost-dump |
d77de738 ML |
23531 | Enable verbose cost model dumping in the debug dump files. This option is |
23532 | provided for use in debugging the compiler. | |
23533 | ||
d77de738 | 23534 | @opindex mpure-code |
ddf6fe37 | 23535 | @item -mpure-code |
d77de738 ML |
23536 | Do not allow constant data to be placed in code sections. |
23537 | Additionally, when compiling for ELF object format give all text sections the | |
23538 | ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option | |
23539 | is only available when generating non-pic code for M-profile targets. | |
23540 | ||
d77de738 | 23541 | @opindex mcmse |
ddf6fe37 | 23542 | @item -mcmse |
d77de738 ML |
23543 | Generate secure code as per the "ARMv8-M Security Extensions: Requirements on |
23544 | Development Tools Engineering Specification", which can be found on | |
23545 | @url{https://developer.arm.com/documentation/ecm0359818/latest/}. | |
23546 | ||
d77de738 | 23547 | @opindex mfix-cmse-cve-2021-35465 |
ddf6fe37 | 23548 | @item -mfix-cmse-cve-2021-35465 |
d77de738 ML |
23549 | Mitigate against a potential security issue with the @code{VLLDM} instruction |
23550 | in some M-profile devices when using CMSE (CVE-2021-365465). This option is | |
23551 | enabled by default when the option @option{-mcpu=} is used with | |
43c4f982 CJW |
23552 | @code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m52}, @code{cortex-m55}, |
23553 | @code{cortex-m85} or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465} | |
23554 | can be used to disable the mitigation. | |
d77de738 | 23555 | |
d77de738 ML |
23556 | @opindex mstack-protector-guard |
23557 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
23558 | @item -mstack-protector-guard=@var{guard} |
23559 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
23560 | Generate stack protection code using canary at @var{guard}. Supported |
23561 | locations are @samp{global} for a global canary or @samp{tls} for a | |
23562 | canary accessible via the TLS register. The option | |
23563 | @option{-mstack-protector-guard-offset=} is for use with | |
23564 | @option{-fstack-protector-guard=tls} and not for use in user-land code. | |
23565 | ||
d77de738 ML |
23566 | @opindex mfdpic |
23567 | @opindex mno-fdpic | |
ddf6fe37 AA |
23568 | @item -mfdpic |
23569 | @itemx -mno-fdpic | |
d77de738 ML |
23570 | Select the FDPIC ABI, which uses 64-bit function descriptors to |
23571 | represent pointers to functions. When the compiler is configured for | |
23572 | @code{arm-*-uclinuxfdpiceabi} targets, this option is on by default | |
23573 | and implies @option{-fPIE} if none of the PIC/PIE-related options is | |
23574 | provided. On other targets, it only enables the FDPIC-specific code | |
23575 | generation features, and the user should explicitly provide the | |
23576 | PIC/PIE-related options as needed. | |
23577 | ||
23578 | Note that static linking is not supported because it would still | |
23579 | involve the dynamic linker when the program self-relocates. If such | |
23580 | behavior is acceptable, use -static and -Wl,-dynamic-linker options. | |
23581 | ||
23582 | The opposite @option{-mno-fdpic} option is useful (and required) to | |
23583 | build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi}) | |
23584 | toolchain as the one used to build the userland programs. | |
23585 | ||
14fab5fb | 23586 | @opindex mbranch-protection |
ddf6fe37 | 23587 | @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]] |
14fab5fb AC |
23588 | Enable branch protection features (armv8.1-m.main only). |
23589 | @samp{none} generate code without branch protection or return address | |
23590 | signing. | |
23591 | @samp{standard[+@var{leaf}]} generate code with all branch protection | |
23592 | features enabled at their standard level. | |
23593 | @samp{pac-ret[+@var{leaf}]} generate code with return address signing | |
23594 | set to its standard level, which is to sign all functions that save | |
23595 | the return address to memory. | |
23596 | @samp{leaf} When return address signing is enabled, also sign leaf | |
23597 | functions even if they do not write the return address to memory. | |
23598 | +@samp{bti} Add landing-pad instructions at the permitted targets of | |
23599 | indirect branch instructions. | |
23600 | ||
23601 | If the @samp{+pacbti} architecture extension is not enabled, then all | |
23602 | branch protection and return address signing operations are | |
23603 | constrained to use only the instructions defined in the | |
23604 | architectural-NOP space. The generated code will remain | |
23605 | backwards-compatible with earlier versions of the architecture, but | |
23606 | the additional security can be enabled at run time on processors that | |
23607 | support the @samp{PACBTI} extension. | |
23608 | ||
23609 | Branch target enforcement using BTI can only be enabled at runtime if | |
23610 | all code in the application has been compiled with at least | |
23611 | @samp{-mbranch-protection=bti}. | |
23612 | ||
23613 | Any setting other than @samp{none} is supported only on armv8-m.main | |
23614 | or later. | |
23615 | ||
23616 | The default is to generate code without branch protection or return | |
23617 | address signing. | |
23618 | ||
d77de738 ML |
23619 | @end table |
23620 | ||
23621 | @node AVR Options | |
23622 | @subsection AVR Options | |
23623 | @cindex AVR Options | |
23624 | ||
23625 | These options are defined for AVR implementations: | |
23626 | ||
23627 | @table @gcctabopt | |
d77de738 | 23628 | @opindex mmcu |
ddf6fe37 | 23629 | @item -mmcu=@var{mcu} |
d77de738 ML |
23630 | Specify Atmel AVR instruction set architectures (ISA) or MCU type. |
23631 | ||
23632 | The default for this option is@tie{}@samp{avr2}. | |
23633 | ||
23634 | GCC supports the following AVR devices and ISAs: | |
23635 | ||
23636 | @include avr-mmcu.texi | |
23637 | ||
d77de738 | 23638 | @opindex mabsdata |
ddf6fe37 | 23639 | @item -mabsdata |
d77de738 ML |
23640 | |
23641 | Assume that all data in static storage can be accessed by LDS / STS | |
23642 | instructions. This option has only an effect on reduced Tiny devices like | |
23643 | ATtiny40. See also the @code{absdata} | |
23644 | @ref{AVR Variable Attributes,variable attribute}. | |
23645 | ||
d77de738 | 23646 | @opindex maccumulate-args |
ddf6fe37 | 23647 | @item -maccumulate-args |
d77de738 ML |
23648 | Accumulate outgoing function arguments and acquire/release the needed |
23649 | stack space for outgoing function arguments once in function | |
23650 | prologue/epilogue. Without this option, outgoing arguments are pushed | |
23651 | before calling a function and popped afterwards. | |
23652 | ||
23653 | Popping the arguments after the function call can be expensive on | |
23654 | AVR so that accumulating the stack space might lead to smaller | |
23655 | executables because arguments need not be removed from the | |
23656 | stack after such a function call. | |
23657 | ||
23658 | This option can lead to reduced code size for functions that perform | |
23659 | several calls to functions that get their arguments on the stack like | |
23660 | calls to printf-like functions. | |
23661 | ||
d77de738 | 23662 | @opindex mbranch-cost |
ddf6fe37 | 23663 | @item -mbranch-cost=@var{cost} |
d77de738 ML |
23664 | Set the branch costs for conditional branch instructions to |
23665 | @var{cost}. Reasonable values for @var{cost} are small, non-negative | |
23666 | integers. The default branch cost is 0. | |
23667 | ||
d77de738 | 23668 | @opindex mcall-prologues |
ddf6fe37 | 23669 | @item -mcall-prologues |
d77de738 ML |
23670 | Functions prologues/epilogues are expanded as calls to appropriate |
23671 | subroutines. Code size is smaller. | |
23672 | ||
d77de738 ML |
23673 | @opindex mdouble |
23674 | @opindex mlong-double | |
ddf6fe37 AA |
23675 | @item -mdouble=@var{bits} |
23676 | @itemx -mlong-double=@var{bits} | |
d77de738 ML |
23677 | Set the size (in bits) of the @code{double} or @code{long double} type, |
23678 | respectively. Possible values for @var{bits} are 32 and 64. | |
23679 | Whether or not a specific value for @var{bits} is allowed depends on | |
23680 | the @code{--with-double=} and @code{--with-long-double=} | |
23681 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}}, | |
23682 | and the same applies for the default values of the options. | |
23683 | ||
d77de738 | 23684 | @opindex mgas-isr-prologues |
ddf6fe37 | 23685 | @item -mgas-isr-prologues |
d77de738 ML |
23686 | Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo |
23687 | instruction supported by GNU Binutils. | |
23688 | If this option is on, the feature can still be disabled for individual | |
23689 | ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}} | |
23690 | function attribute. This feature is activated per default | |
23691 | if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}), | |
23692 | and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}. | |
23693 | ||
d77de738 | 23694 | @opindex mint8 |
ddf6fe37 | 23695 | @item -mint8 |
d77de738 ML |
23696 | Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a |
23697 | @code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes, | |
23698 | and @code{long long} is 4 bytes. Please note that this option does not | |
23699 | conform to the C standards, but it results in smaller code | |
23700 | size. | |
23701 | ||
d77de738 | 23702 | @opindex mmain-is-OS_task |
ddf6fe37 | 23703 | @item -mmain-is-OS_task |
d77de738 ML |
23704 | Do not save registers in @code{main}. The effect is the same like |
23705 | attaching attribute @ref{AVR Function Attributes,,@code{OS_task}} | |
23706 | to @code{main}. It is activated per default if optimization is on. | |
23707 | ||
d77de738 | 23708 | @opindex mno-interrupts |
ddf6fe37 | 23709 | @item -mno-interrupts |
d77de738 ML |
23710 | Generated code is not compatible with hardware interrupts. |
23711 | Code size is smaller. | |
23712 | ||
d77de738 | 23713 | @opindex mrelax |
ddf6fe37 | 23714 | @item -mrelax |
d77de738 ML |
23715 | Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter |
23716 | @code{RCALL} resp.@: @code{RJMP} instruction if applicable. | |
23717 | Setting @option{-mrelax} just adds the @option{--mlink-relax} option to | |
23718 | the assembler's command line and the @option{--relax} option to the | |
23719 | linker's command line. | |
23720 | ||
23721 | Jump relaxing is performed by the linker because jump offsets are not | |
23722 | known before code is located. Therefore, the assembler code generated by the | |
23723 | compiler is the same, but the instructions in the executable may | |
23724 | differ from instructions in the assembler code. | |
23725 | ||
23726 | Relaxing must be turned on if linker stubs are needed, see the | |
23727 | section on @code{EIND} and linker stubs below. | |
23728 | ||
48448055 GJL |
23729 | @opindex mrodata-in-ram |
23730 | @item -mrodata-in-ram | |
23731 | @itemx -mno-rodata-in-ram | |
23732 | Locate the @code{.rodata} sections for read-only data in RAM resp.@: | |
23733 | in program memory. | |
23734 | For most devices, there is no choice and this option acts rather | |
23735 | like an assertion. | |
23736 | ||
23737 | Since v14 and for the AVR64* and AVR128* devices, @code{.rodata} | |
23738 | is located in flash memory per default, provided the required GNU Binutils | |
23739 | support (@w{@uref{https://sourceware.org/PR31124,PR31124}}) is available. | |
23740 | In that case, @option{-mrodata-in-ram} can be used to return to the old | |
23741 | layout with @code{.rodata} in RAM. | |
23742 | ||
d77de738 | 23743 | @opindex mstrict-X |
ddf6fe37 | 23744 | @item -mstrict-X |
d77de738 ML |
23745 | Use address register @code{X} in a way proposed by the hardware. This means |
23746 | that @code{X} is only used in indirect, post-increment or | |
23747 | pre-decrement addressing. | |
23748 | ||
23749 | Without this option, the @code{X} register may be used in the same way | |
23750 | as @code{Y} or @code{Z} which then is emulated by additional | |
23751 | instructions. | |
23752 | For example, loading a value with @code{X+const} addressing with a | |
23753 | small non-negative @code{const < 64} to a register @var{Rn} is | |
23754 | performed as | |
23755 | ||
23756 | @example | |
23757 | adiw r26, const ; X += const | |
23758 | ld @var{Rn}, X ; @var{Rn} = *X | |
23759 | sbiw r26, const ; X -= const | |
23760 | @end example | |
23761 | ||
d77de738 | 23762 | @opindex mtiny-stack |
ddf6fe37 | 23763 | @item -mtiny-stack |
d77de738 ML |
23764 | Only change the lower 8@tie{}bits of the stack pointer. |
23765 | ||
d77de738 | 23766 | @opindex mfract-convert-truncate |
ddf6fe37 | 23767 | @item -mfract-convert-truncate |
d77de738 ML |
23768 | Allow to use truncation instead of rounding towards zero for fractional fixed-point types. |
23769 | ||
d77de738 | 23770 | @opindex nodevicelib |
ddf6fe37 | 23771 | @item -nodevicelib |
d77de738 ML |
23772 | Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}. |
23773 | ||
d77de738 | 23774 | @opindex nodevicespecs |
ddf6fe37 | 23775 | @item -nodevicespecs |
d77de738 ML |
23776 | Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's |
23777 | command line. The user takes responsibility for supplying the sub-processes | |
23778 | like compiler proper, assembler and linker with appropriate command line | |
23779 | options. This means that the user has to supply her private device specs | |
23780 | file by means of @option{-specs=@var{path-to-specs-file}}. There is no | |
23781 | more need for option @option{-mmcu=@var{mcu}}. | |
23782 | ||
23783 | This option can also serve as a replacement for the older way of | |
23784 | specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory | |
23785 | which contains a folder named @code{device-specs} which contains a specs file named | |
23786 | @code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}. | |
23787 | ||
d77de738 ML |
23788 | @opindex Waddr-space-convert |
23789 | @opindex Wno-addr-space-convert | |
ddf6fe37 | 23790 | @item -Waddr-space-convert |
d77de738 ML |
23791 | Warn about conversions between address spaces in the case where the |
23792 | resulting address space is not contained in the incoming address space. | |
23793 | ||
d77de738 ML |
23794 | @opindex Wmisspelled-isr |
23795 | @opindex Wno-misspelled-isr | |
ddf6fe37 | 23796 | @item -Wmisspelled-isr |
d77de738 ML |
23797 | Warn if the ISR is misspelled, i.e.@: without __vector prefix. |
23798 | Enabled by default. | |
23799 | @end table | |
23800 | ||
b793c218 | 23801 | @anchor{eind} |
d77de738 ML |
23802 | @subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash |
23803 | @cindex @code{EIND} | |
23804 | Pointers in the implementation are 16@tie{}bits wide. | |
23805 | The address of a function or label is represented as word address so | |
23806 | that indirect jumps and calls can target any code address in the | |
23807 | range of 64@tie{}Ki words. | |
23808 | ||
23809 | In order to facilitate indirect jump on devices with more than 128@tie{}Ki | |
23810 | bytes of program memory space, there is a special function register called | |
23811 | @code{EIND} that serves as most significant part of the target address | |
23812 | when @code{EICALL} or @code{EIJMP} instructions are used. | |
23813 | ||
23814 | Indirect jumps and calls on these devices are handled as follows by | |
23815 | the compiler and are subject to some limitations: | |
23816 | ||
23817 | @itemize @bullet | |
23818 | ||
23819 | @item | |
23820 | The compiler never sets @code{EIND}. | |
23821 | ||
23822 | @item | |
23823 | The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP} | |
23824 | instructions or might read @code{EIND} directly in order to emulate an | |
23825 | indirect call/jump by means of a @code{RET} instruction. | |
23826 | ||
23827 | @item | |
23828 | The compiler assumes that @code{EIND} never changes during the startup | |
23829 | code or during the application. In particular, @code{EIND} is not | |
23830 | saved/restored in function or interrupt service routine | |
23831 | prologue/epilogue. | |
23832 | ||
23833 | @item | |
23834 | For indirect calls to functions and computed goto, the linker | |
23835 | generates @emph{stubs}. Stubs are jump pads sometimes also called | |
23836 | @emph{trampolines}. Thus, the indirect call/jump jumps to such a stub. | |
23837 | The stub contains a direct jump to the desired address. | |
23838 | ||
23839 | @item | |
23840 | Linker relaxation must be turned on so that the linker generates | |
23841 | the stubs correctly in all situations. See the compiler option | |
23842 | @option{-mrelax} and the linker option @option{--relax}. | |
23843 | There are corner cases where the linker is supposed to generate stubs | |
23844 | but aborts without relaxation and without a helpful error message. | |
23845 | ||
23846 | @item | |
23847 | The default linker script is arranged for code with @code{EIND = 0}. | |
23848 | If code is supposed to work for a setup with @code{EIND != 0}, a custom | |
23849 | linker script has to be used in order to place the sections whose | |
23850 | name start with @code{.trampolines} into the segment where @code{EIND} | |
23851 | points to. | |
23852 | ||
23853 | @item | |
23854 | The startup code from libgcc never sets @code{EIND}. | |
23855 | Notice that startup code is a blend of code from libgcc and AVR-LibC. | |
23856 | For the impact of AVR-LibC on @code{EIND}, see the | |
a65da9be | 23857 | @w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}. |
d77de738 ML |
23858 | |
23859 | @item | |
23860 | It is legitimate for user-specific startup code to set up @code{EIND} | |
23861 | early, for example by means of initialization code located in | |
23862 | section @code{.init3}. Such code runs prior to general startup code | |
23863 | that initializes RAM and calls constructors, but after the bit | |
23864 | of startup code from AVR-LibC that sets @code{EIND} to the segment | |
23865 | where the vector table is located. | |
23866 | @example | |
23867 | #include <avr/io.h> | |
23868 | ||
23869 | static void | |
23870 | __attribute__((section(".init3"),naked,used,no_instrument_function)) | |
23871 | init3_set_eind (void) | |
23872 | @{ | |
23873 | __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t" | |
23874 | "out %i0,r24" :: "n" (&EIND) : "r24","memory"); | |
23875 | @} | |
23876 | @end example | |
23877 | ||
23878 | @noindent | |
23879 | The @code{__trampolines_start} symbol is defined in the linker script. | |
23880 | ||
23881 | @item | |
23882 | Stubs are generated automatically by the linker if | |
23883 | the following two conditions are met: | |
23884 | @itemize @minus | |
23885 | ||
23886 | @item The address of a label is taken by means of the @code{gs} modifier | |
23887 | (short for @emph{generate stubs}) like so: | |
23888 | @example | |
23889 | LDI r24, lo8(gs(@var{func})) | |
23890 | LDI r25, hi8(gs(@var{func})) | |
23891 | @end example | |
23892 | @item The final location of that label is in a code segment | |
23893 | @emph{outside} the segment where the stubs are located. | |
23894 | @end itemize | |
23895 | ||
23896 | @item | |
23897 | The compiler emits such @code{gs} modifiers for code labels in the | |
23898 | following situations: | |
23899 | @itemize @minus | |
23900 | @item Taking address of a function or code label. | |
23901 | @item Computed goto. | |
23902 | @item If prologue-save function is used, see @option{-mcall-prologues} | |
23903 | command-line option. | |
23904 | @item Switch/case dispatch tables. If you do not want such dispatch | |
23905 | tables you can specify the @option{-fno-jump-tables} command-line option. | |
23906 | @item C and C++ constructors/destructors called during startup/shutdown. | |
23907 | @item If the tools hit a @code{gs()} modifier explained above. | |
23908 | @end itemize | |
23909 | ||
23910 | @item | |
23911 | Jumping to non-symbolic addresses like so is @emph{not} supported: | |
23912 | ||
23913 | @example | |
23914 | int main (void) | |
23915 | @{ | |
23916 | /* Call function at word address 0x2 */ | |
23917 | return ((int(*)(void)) 0x2)(); | |
23918 | @} | |
23919 | @end example | |
23920 | ||
23921 | Instead, a stub has to be set up, i.e.@: the function has to be called | |
23922 | through a symbol (@code{func_4} in the example): | |
23923 | ||
23924 | @example | |
23925 | int main (void) | |
23926 | @{ | |
23927 | extern int func_4 (void); | |
23928 | ||
23929 | /* Call function at byte address 0x4 */ | |
23930 | return func_4(); | |
23931 | @} | |
23932 | @end example | |
23933 | ||
23934 | and the application be linked with @option{-Wl,--defsym,func_4=0x4}. | |
23935 | Alternatively, @code{func_4} can be defined in the linker script. | |
23936 | @end itemize | |
23937 | ||
b793c218 | 23938 | @anchor{ramp} |
d77de738 ML |
23939 | @subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers |
23940 | @cindex @code{RAMPD} | |
23941 | @cindex @code{RAMPX} | |
23942 | @cindex @code{RAMPY} | |
23943 | @cindex @code{RAMPZ} | |
23944 | Some AVR devices support memories larger than the 64@tie{}KiB range | |
23945 | that can be accessed with 16-bit pointers. To access memory locations | |
23946 | outside this 64@tie{}KiB range, the content of a @code{RAMP} | |
23947 | register is used as high part of the address: | |
23948 | The @code{X}, @code{Y}, @code{Z} address register is concatenated | |
23949 | with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function | |
23950 | register, respectively, to get a wide address. Similarly, | |
23951 | @code{RAMPD} is used together with direct addressing. | |
23952 | ||
23953 | @itemize | |
23954 | @item | |
23955 | The startup code initializes the @code{RAMP} special function | |
23956 | registers with zero. | |
23957 | ||
23958 | @item | |
23959 | If a @ref{AVR Named Address Spaces,named address space} other than | |
23960 | generic or @code{__flash} is used, then @code{RAMPZ} is set | |
23961 | as needed before the operation. | |
23962 | ||
23963 | @item | |
23964 | If the device supports RAM larger than 64@tie{}KiB and the compiler | |
23965 | needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ} | |
23966 | is reset to zero after the operation. | |
23967 | ||
23968 | @item | |
23969 | If the device comes with a specific @code{RAMP} register, the ISR | |
23970 | prologue/epilogue saves/restores that SFR and initializes it with | |
23971 | zero in case the ISR code might (implicitly) use it. | |
23972 | ||
23973 | @item | |
23974 | RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets. | |
23975 | If you use inline assembler to read from locations outside the | |
23976 | 16-bit address range and change one of the @code{RAMP} registers, | |
23977 | you must reset it to zero after the access. | |
23978 | ||
23979 | @end itemize | |
23980 | ||
b793c218 | 23981 | @anchor{avr-macros} |
d77de738 ML |
23982 | @subsubsection AVR Built-in Macros |
23983 | ||
23984 | GCC defines several built-in macros so that the user code can test | |
23985 | for the presence or absence of features. Almost any of the following | |
23986 | built-in macros are deduced from device capabilities and thus | |
23987 | triggered by the @option{-mmcu=} command-line option. | |
23988 | ||
23989 | For even more AVR-specific built-in macros see | |
23990 | @ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}. | |
23991 | ||
23992 | @table @code | |
23993 | ||
23994 | @item __AVR_ARCH__ | |
23995 | Build-in macro that resolves to a decimal number that identifies the | |
23996 | architecture and depends on the @option{-mmcu=@var{mcu}} option. | |
23997 | Possible values are: | |
23998 | ||
23999 | @code{2}, @code{25}, @code{3}, @code{31}, @code{35}, | |
24000 | @code{4}, @code{5}, @code{51}, @code{6} | |
24001 | ||
24002 | for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31}, | |
24003 | @code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6}, | |
24004 | ||
24005 | respectively and | |
24006 | ||
24007 | @code{100}, | |
24008 | @code{102}, @code{103}, @code{104}, | |
24009 | @code{105}, @code{106}, @code{107} | |
24010 | ||
24011 | for @var{mcu}=@code{avrtiny}, | |
24012 | @code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4}, | |
24013 | @code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively. | |
24014 | If @var{mcu} specifies a device, this built-in macro is set | |
24015 | accordingly. For example, with @option{-mmcu=atmega8} the macro is | |
24016 | defined to @code{4}. | |
24017 | ||
24018 | @item __AVR_@var{Device}__ | |
24019 | Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects | |
24020 | the device's name. For example, @option{-mmcu=atmega8} defines the | |
24021 | built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines | |
24022 | @code{__AVR_ATtiny261A__}, etc. | |
24023 | ||
24024 | The built-in macros' names follow | |
24025 | the scheme @code{__AVR_@var{Device}__} where @var{Device} is | |
24026 | the device name as from the AVR user manual. The difference between | |
24027 | @var{Device} in the built-in macro and @var{device} in | |
24028 | @option{-mmcu=@var{device}} is that the latter is always lowercase. | |
24029 | ||
24030 | If @var{device} is not a device but only a core architecture like | |
24031 | @samp{avr51}, this macro is not defined. | |
24032 | ||
24033 | @item __AVR_DEVICE_NAME__ | |
24034 | Setting @option{-mmcu=@var{device}} defines this built-in macro to | |
24035 | the device's name. For example, with @option{-mmcu=atmega8} the macro | |
24036 | is defined to @code{atmega8}. | |
24037 | ||
24038 | If @var{device} is not a device but only a core architecture like | |
24039 | @samp{avr51}, this macro is not defined. | |
24040 | ||
24041 | @item __AVR_XMEGA__ | |
24042 | The device / architecture belongs to the XMEGA family of devices. | |
24043 | ||
24044 | @item __AVR_HAVE_ELPM__ | |
24045 | The device has the @code{ELPM} instruction. | |
24046 | ||
24047 | @item __AVR_HAVE_ELPMX__ | |
24048 | The device has the @code{ELPM R@var{n},Z} and @code{ELPM | |
24049 | R@var{n},Z+} instructions. | |
24050 | ||
24051 | @item __AVR_HAVE_MOVW__ | |
24052 | The device has the @code{MOVW} instruction to perform 16-bit | |
24053 | register-register moves. | |
24054 | ||
24055 | @item __AVR_HAVE_LPMX__ | |
24056 | The device has the @code{LPM R@var{n},Z} and | |
24057 | @code{LPM R@var{n},Z+} instructions. | |
24058 | ||
24059 | @item __AVR_HAVE_MUL__ | |
24060 | The device has a hardware multiplier. | |
24061 | ||
24062 | @item __AVR_HAVE_JMP_CALL__ | |
24063 | The device has the @code{JMP} and @code{CALL} instructions. | |
24064 | This is the case for devices with more than 8@tie{}KiB of program | |
24065 | memory. | |
24066 | ||
24067 | @item __AVR_HAVE_EIJMP_EICALL__ | |
24068 | @itemx __AVR_3_BYTE_PC__ | |
24069 | The device has the @code{EIJMP} and @code{EICALL} instructions. | |
24070 | This is the case for devices with more than 128@tie{}KiB of program memory. | |
24071 | This also means that the program counter | |
24072 | (PC) is 3@tie{}bytes wide. | |
24073 | ||
24074 | @item __AVR_2_BYTE_PC__ | |
24075 | The program counter (PC) is 2@tie{}bytes wide. This is the case for devices | |
24076 | with up to 128@tie{}KiB of program memory. | |
24077 | ||
24078 | @item __AVR_HAVE_8BIT_SP__ | |
24079 | @itemx __AVR_HAVE_16BIT_SP__ | |
24080 | The stack pointer (SP) register is treated as 8-bit respectively | |
24081 | 16-bit register by the compiler. | |
24082 | The definition of these macros is affected by @option{-mtiny-stack}. | |
24083 | ||
24084 | @item __AVR_HAVE_SPH__ | |
24085 | @itemx __AVR_SP8__ | |
24086 | The device has the SPH (high part of stack pointer) special function | |
24087 | register or has an 8-bit stack pointer, respectively. | |
24088 | The definition of these macros is affected by @option{-mmcu=} and | |
24089 | in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also | |
24090 | by @option{-msp8}. | |
24091 | ||
24092 | @item __AVR_HAVE_RAMPD__ | |
24093 | @itemx __AVR_HAVE_RAMPX__ | |
24094 | @itemx __AVR_HAVE_RAMPY__ | |
24095 | @itemx __AVR_HAVE_RAMPZ__ | |
24096 | The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY}, | |
24097 | @code{RAMPZ} special function register, respectively. | |
24098 | ||
24099 | @item __NO_INTERRUPTS__ | |
24100 | This macro reflects the @option{-mno-interrupts} command-line option. | |
24101 | ||
24102 | @item __AVR_ERRATA_SKIP__ | |
24103 | @itemx __AVR_ERRATA_SKIP_JMP_CALL__ | |
24104 | Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit | |
24105 | instructions because of a hardware erratum. Skip instructions are | |
24106 | @code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}. | |
24107 | The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also | |
24108 | set. | |
24109 | ||
24110 | @item __AVR_ISA_RMW__ | |
24111 | The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT). | |
24112 | ||
24113 | @item __AVR_SFR_OFFSET__=@var{offset} | |
24114 | Instructions that can address I/O special function registers directly | |
24115 | like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different | |
24116 | address as if addressed by an instruction to access RAM like @code{LD} | |
24117 | or @code{STS}. This offset depends on the device architecture and has | |
24118 | to be subtracted from the RAM address in order to get the | |
24119 | respective I/O@tie{}address. | |
24120 | ||
24121 | @item __AVR_SHORT_CALLS__ | |
24122 | The @option{-mshort-calls} command line option is set. | |
24123 | ||
24124 | @item __AVR_PM_BASE_ADDRESS__=@var{addr} | |
24125 | Some devices support reading from flash memory by means of @code{LD*} | |
24126 | instructions. The flash memory is seen in the data address space | |
24127 | at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro | |
24128 | is not defined, this feature is not available. If defined, | |
24129 | the address space is linear and there is no need to put | |
24130 | @code{.rodata} into RAM. This is handled by the default linker | |
24131 | description file, and is currently available for | |
24132 | @code{avrtiny} and @code{avrxmega3}. Even more convenient, | |
24133 | there is no need to use address spaces like @code{__flash} or | |
24134 | features like attribute @code{progmem} and @code{pgm_read_*}. | |
24135 | ||
48448055 GJL |
24136 | @item __AVR_HAVE_FLMAP__ |
24137 | This macro is defined provided the following conditions are met: | |
24138 | @itemize @bullet | |
24139 | @item The device has the @code{NVMCTRL_CTRLB.FLMAP} bitfield. | |
24140 | This applies to the AVR64* and AVR128* devices. | |
24141 | @item It's not known at assembler-time which emulation will be used. | |
24142 | @end itemize | |
24143 | This implies the compiler was configured with GNU Binutils that implement | |
24144 | @w{@uref{https://sourceware.org/PR31124,PR31124}}. | |
24145 | ||
24146 | @item __AVR_RODATA_IN_RAM__ | |
24147 | This macro is undefined when the code is compiled for a core architecture. | |
24148 | ||
24149 | When the code is compiled for a device, the macro is defined to@tie{}1 | |
24150 | when the @code{.rodata} sections for read-only data is located in RAM; | |
24151 | and defined to@tie{}0, otherwise. | |
24152 | ||
d77de738 ML |
24153 | @item __WITH_AVRLIBC__ |
24154 | The compiler is configured to be used together with AVR-Libc. | |
24155 | See the @option{--with-avrlibc} configure option. | |
24156 | ||
24157 | @item __HAVE_DOUBLE_MULTILIB__ | |
24158 | Defined if @option{-mdouble=} acts as a multilib option. | |
24159 | ||
24160 | @item __HAVE_DOUBLE32__ | |
24161 | @itemx __HAVE_DOUBLE64__ | |
24162 | Defined if the compiler supports 32-bit double resp. 64-bit double. | |
24163 | The actual layout is specified by option @option{-mdouble=}. | |
24164 | ||
24165 | @item __DEFAULT_DOUBLE__ | |
24166 | The size in bits of @code{double} if @option{-mdouble=} is not set. | |
24167 | To test the layout of @code{double} in a program, use the built-in | |
24168 | macro @code{__SIZEOF_DOUBLE__}. | |
24169 | ||
24170 | @item __HAVE_LONG_DOUBLE32__ | |
24171 | @itemx __HAVE_LONG_DOUBLE64__ | |
24172 | @itemx __HAVE_LONG_DOUBLE_MULTILIB__ | |
24173 | @itemx __DEFAULT_LONG_DOUBLE__ | |
24174 | Same as above, but for @code{long double} instead of @code{double}. | |
24175 | ||
24176 | @item __WITH_DOUBLE_COMPARISON__ | |
24177 | Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}} | |
24178 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}} | |
24179 | and is defined to @code{2} or @code{3}. | |
24180 | ||
24181 | @item __WITH_LIBF7_LIBGCC__ | |
24182 | @itemx __WITH_LIBF7_MATH__ | |
24183 | @itemx __WITH_LIBF7_MATH_SYMBOLS__ | |
24184 | Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}} | |
24185 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}. | |
24186 | ||
24187 | @end table | |
24188 | ||
31461d2b GJL |
24189 | @subsubsection AVR Internal Options |
24190 | The following options are used internally by the compiler and to communicate | |
24191 | between device specs files and the compiler proper. You don't need to set these | |
24192 | options by hand, in particular they are not optimization options. | |
24193 | Using these options in the wrong way may lead to sub-optimal or wrong code. | |
24194 | They are documented for completeness, and in order to get a better | |
24195 | understanding of | |
24196 | @w{@uref{https://gcc.gnu.org/wiki/avr-gcc#spec-files,device specs}} | |
24197 | files. | |
24198 | ||
24199 | @table @gcctabopt | |
24200 | ||
24201 | @opindex mn-flash | |
24202 | @item -mn-flash=@var{num} | |
24203 | Assume that the flash memory has a size of @var{num} times 64@tie{}KiB. | |
24204 | This determines which @code{__flash@var{N}} address spaces are available. | |
24205 | ||
48448055 GJL |
24206 | @opindex mflmap |
24207 | @item -mflmap | |
24208 | The device has the @code{FLMAP} bit field located in special function | |
24209 | register @code{NVMCTRL_CTRLB}. | |
24210 | ||
31461d2b GJL |
24211 | @opindex mrmw |
24212 | @item -mrmw | |
24213 | Assume that the device supports the Read-Modify-Write | |
24214 | instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}. | |
24215 | ||
24216 | @opindex mshort-calls | |
24217 | @item -mshort-calls | |
24218 | ||
24219 | Assume that @code{RJMP} and @code{RCALL} can target the whole | |
24220 | program memory. This option is used for multilib generation and selection | |
24221 | for the devices from architecture @code{avrxmega3}. | |
24222 | ||
42503cc2 GJL |
24223 | @opindex mskip-bug |
24224 | @item -mskip-bug | |
24225 | ||
24226 | Generate code without skips (@code{CPSE}, @code{SBRS}, | |
24227 | @code{SBRC}, @code{SBIS}, @code{SBIC}) over 32-bit instructions. | |
24228 | ||
31461d2b GJL |
24229 | @opindex msp8 |
24230 | @item -msp8 | |
24231 | Treat the stack pointer register as an 8-bit register, | |
24232 | i.e.@: assume the high byte of the stack pointer is zero. | |
24233 | This option is used by the compiler to select and | |
24234 | build multilibs for architectures @code{avr2} and @code{avr25}. | |
24235 | These architectures mix devices with and without @code{SPH}. | |
24236 | ||
24237 | @end table | |
24238 | ||
d77de738 ML |
24239 | @node Blackfin Options |
24240 | @subsection Blackfin Options | |
24241 | @cindex Blackfin Options | |
24242 | ||
24243 | @table @gcctabopt | |
d77de738 | 24244 | @opindex mcpu= |
ddf6fe37 | 24245 | @item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} |
d77de738 ML |
24246 | Specifies the name of the target Blackfin processor. Currently, @var{cpu} |
24247 | can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518}, | |
24248 | @samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526}, | |
24249 | @samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533}, | |
24250 | @samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539}, | |
24251 | @samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549}, | |
24252 | @samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m}, | |
24253 | @samp{bf561}, @samp{bf592}. | |
24254 | ||
24255 | The optional @var{sirevision} specifies the silicon revision of the target | |
24256 | Blackfin processor. Any workarounds available for the targeted silicon revision | |
24257 | are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled. | |
24258 | If @var{sirevision} is @samp{any}, all workarounds for the targeted processor | |
24259 | are enabled. The @code{__SILICON_REVISION__} macro is defined to two | |
24260 | hexadecimal digits representing the major and minor numbers in the silicon | |
24261 | revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__} | |
24262 | is not defined. If @var{sirevision} is @samp{any}, the | |
24263 | @code{__SILICON_REVISION__} is defined to be @code{0xffff}. | |
24264 | If this optional @var{sirevision} is not used, GCC assumes the latest known | |
24265 | silicon revision of the targeted Blackfin processor. | |
24266 | ||
24267 | GCC defines a preprocessor macro for the specified @var{cpu}. | |
24268 | For the @samp{bfin-elf} toolchain, this option causes the hardware BSP | |
24269 | provided by libgloss to be linked in if @option{-msim} is not given. | |
24270 | ||
24271 | Without this option, @samp{bf532} is used as the processor by default. | |
24272 | ||
24273 | Note that support for @samp{bf561} is incomplete. For @samp{bf561}, | |
24274 | only the preprocessor macro is defined. | |
24275 | ||
d77de738 | 24276 | @opindex msim |
ddf6fe37 | 24277 | @item -msim |
d77de738 ML |
24278 | Specifies that the program will be run on the simulator. This causes |
24279 | the simulator BSP provided by libgloss to be linked in. This option | |
24280 | has effect only for @samp{bfin-elf} toolchain. | |
24281 | Certain other options, such as @option{-mid-shared-library} and | |
24282 | @option{-mfdpic}, imply @option{-msim}. | |
24283 | ||
d77de738 | 24284 | @opindex momit-leaf-frame-pointer |
ddf6fe37 | 24285 | @item -momit-leaf-frame-pointer |
d77de738 ML |
24286 | Don't keep the frame pointer in a register for leaf functions. This |
24287 | avoids the instructions to save, set up and restore frame pointers and | |
24288 | makes an extra register available in leaf functions. | |
24289 | ||
d77de738 | 24290 | @opindex mspecld-anomaly |
ddf6fe37 | 24291 | @item -mspecld-anomaly |
d77de738 ML |
24292 | When enabled, the compiler ensures that the generated code does not |
24293 | contain speculative loads after jump instructions. If this option is used, | |
24294 | @code{__WORKAROUND_SPECULATIVE_LOADS} is defined. | |
24295 | ||
d77de738 ML |
24296 | @opindex mno-specld-anomaly |
24297 | @opindex mspecld-anomaly | |
ddf6fe37 | 24298 | @item -mno-specld-anomaly |
d77de738 ML |
24299 | Don't generate extra code to prevent speculative loads from occurring. |
24300 | ||
d77de738 | 24301 | @opindex mcsync-anomaly |
ddf6fe37 | 24302 | @item -mcsync-anomaly |
d77de738 ML |
24303 | When enabled, the compiler ensures that the generated code does not |
24304 | contain CSYNC or SSYNC instructions too soon after conditional branches. | |
24305 | If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined. | |
24306 | ||
d77de738 ML |
24307 | @opindex mno-csync-anomaly |
24308 | @opindex mcsync-anomaly | |
ddf6fe37 | 24309 | @item -mno-csync-anomaly |
d77de738 ML |
24310 | Don't generate extra code to prevent CSYNC or SSYNC instructions from |
24311 | occurring too soon after a conditional branch. | |
24312 | ||
d77de738 | 24313 | @opindex mlow64k |
ddf6fe37 | 24314 | @item -mlow64k |
d77de738 ML |
24315 | When enabled, the compiler is free to take advantage of the knowledge that |
24316 | the entire program fits into the low 64k of memory. | |
24317 | ||
d77de738 | 24318 | @opindex mno-low64k |
ddf6fe37 | 24319 | @item -mno-low64k |
d77de738 ML |
24320 | Assume that the program is arbitrarily large. This is the default. |
24321 | ||
d77de738 | 24322 | @opindex mstack-check-l1 |
ddf6fe37 | 24323 | @item -mstack-check-l1 |
d77de738 ML |
24324 | Do stack checking using information placed into L1 scratchpad memory by the |
24325 | uClinux kernel. | |
24326 | ||
d77de738 | 24327 | @opindex mid-shared-library |
ddf6fe37 | 24328 | @item -mid-shared-library |
d77de738 ML |
24329 | Generate code that supports shared libraries via the library ID method. |
24330 | This allows for execute in place and shared libraries in an environment | |
24331 | without virtual memory management. This option implies @option{-fPIC}. | |
24332 | With a @samp{bfin-elf} target, this option implies @option{-msim}. | |
24333 | ||
d77de738 ML |
24334 | @opindex mno-id-shared-library |
24335 | @opindex mid-shared-library | |
ddf6fe37 | 24336 | @item -mno-id-shared-library |
d77de738 ML |
24337 | Generate code that doesn't assume ID-based shared libraries are being used. |
24338 | This is the default. | |
24339 | ||
d77de738 | 24340 | @opindex mleaf-id-shared-library |
ddf6fe37 | 24341 | @item -mleaf-id-shared-library |
d77de738 ML |
24342 | Generate code that supports shared libraries via the library ID method, |
24343 | but assumes that this library or executable won't link against any other | |
24344 | ID shared libraries. That allows the compiler to use faster code for jumps | |
24345 | and calls. | |
24346 | ||
d77de738 ML |
24347 | @opindex mno-leaf-id-shared-library |
24348 | @opindex mleaf-id-shared-library | |
ddf6fe37 | 24349 | @item -mno-leaf-id-shared-library |
d77de738 ML |
24350 | Do not assume that the code being compiled won't link against any ID shared |
24351 | libraries. Slower code is generated for jump and call insns. | |
24352 | ||
d77de738 | 24353 | @opindex mshared-library-id |
ddf6fe37 | 24354 | @item -mshared-library-id=n |
d77de738 ML |
24355 | Specifies the identification number of the ID-based shared library being |
24356 | compiled. Specifying a value of 0 generates more compact code; specifying | |
24357 | other values forces the allocation of that number to the current | |
24358 | library but is no more space- or time-efficient than omitting this option. | |
24359 | ||
d77de738 | 24360 | @opindex msep-data |
ddf6fe37 | 24361 | @item -msep-data |
d77de738 ML |
24362 | Generate code that allows the data segment to be located in a different |
24363 | area of memory from the text segment. This allows for execute in place in | |
24364 | an environment without virtual memory management by eliminating relocations | |
24365 | against the text section. | |
24366 | ||
d77de738 ML |
24367 | @opindex mno-sep-data |
24368 | @opindex msep-data | |
ddf6fe37 | 24369 | @item -mno-sep-data |
d77de738 ML |
24370 | Generate code that assumes that the data segment follows the text segment. |
24371 | This is the default. | |
24372 | ||
d77de738 ML |
24373 | @opindex mlong-calls |
24374 | @opindex mno-long-calls | |
ddf6fe37 AA |
24375 | @item -mlong-calls |
24376 | @itemx -mno-long-calls | |
d77de738 ML |
24377 | Tells the compiler to perform function calls by first loading the |
24378 | address of the function into a register and then performing a subroutine | |
24379 | call on this register. This switch is needed if the target function | |
24380 | lies outside of the 24-bit addressing range of the offset-based | |
24381 | version of subroutine call instruction. | |
24382 | ||
24383 | This feature is not enabled by default. Specifying | |
24384 | @option{-mno-long-calls} restores the default behavior. Note these | |
24385 | switches have no effect on how the compiler generates code to handle | |
24386 | function calls via function pointers. | |
24387 | ||
d77de738 | 24388 | @opindex mfast-fp |
ddf6fe37 | 24389 | @item -mfast-fp |
d77de738 ML |
24390 | Link with the fast floating-point library. This library relaxes some of |
24391 | the IEEE floating-point standard's rules for checking inputs against | |
24392 | Not-a-Number (NAN), in the interest of performance. | |
24393 | ||
d77de738 | 24394 | @opindex minline-plt |
ddf6fe37 | 24395 | @item -minline-plt |
d77de738 ML |
24396 | Enable inlining of PLT entries in function calls to functions that are |
24397 | not known to bind locally. It has no effect without @option{-mfdpic}. | |
24398 | ||
d77de738 | 24399 | @opindex mmulticore |
ddf6fe37 | 24400 | @item -mmulticore |
d77de738 ML |
24401 | Build a standalone application for multicore Blackfin processors. |
24402 | This option causes proper start files and link scripts supporting | |
24403 | multicore to be used, and defines the macro @code{__BFIN_MULTICORE}. | |
24404 | It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}. | |
24405 | ||
24406 | This option can be used with @option{-mcorea} or @option{-mcoreb}, which | |
24407 | selects the one-application-per-core programming model. Without | |
24408 | @option{-mcorea} or @option{-mcoreb}, the single-application/dual-core | |
24409 | programming model is used. In this model, the main function of Core B | |
24410 | should be named as @code{coreb_main}. | |
24411 | ||
24412 | If this option is not used, the single-core application programming | |
24413 | model is used. | |
24414 | ||
d77de738 | 24415 | @opindex mcorea |
ddf6fe37 | 24416 | @item -mcorea |
d77de738 ML |
24417 | Build a standalone application for Core A of BF561 when using |
24418 | the one-application-per-core programming model. Proper start files | |
24419 | and link scripts are used to support Core A, and the macro | |
24420 | @code{__BFIN_COREA} is defined. | |
24421 | This option can only be used in conjunction with @option{-mmulticore}. | |
24422 | ||
d77de738 | 24423 | @opindex mcoreb |
ddf6fe37 | 24424 | @item -mcoreb |
d77de738 ML |
24425 | Build a standalone application for Core B of BF561 when using |
24426 | the one-application-per-core programming model. Proper start files | |
24427 | and link scripts are used to support Core B, and the macro | |
24428 | @code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main} | |
24429 | should be used instead of @code{main}. | |
24430 | This option can only be used in conjunction with @option{-mmulticore}. | |
24431 | ||
d77de738 | 24432 | @opindex msdram |
ddf6fe37 | 24433 | @item -msdram |
d77de738 ML |
24434 | Build a standalone application for SDRAM. Proper start files and |
24435 | link scripts are used to put the application into SDRAM, and the macro | |
24436 | @code{__BFIN_SDRAM} is defined. | |
24437 | The loader should initialize SDRAM before loading the application. | |
24438 | ||
d77de738 | 24439 | @opindex micplb |
ddf6fe37 | 24440 | @item -micplb |
d77de738 ML |
24441 | Assume that ICPLBs are enabled at run time. This has an effect on certain |
24442 | anomaly workarounds. For Linux targets, the default is to assume ICPLBs | |
24443 | are enabled; for standalone applications the default is off. | |
24444 | @end table | |
24445 | ||
24446 | @node C6X Options | |
24447 | @subsection C6X Options | |
24448 | @cindex C6X Options | |
24449 | ||
24450 | @table @gcctabopt | |
d77de738 | 24451 | @opindex march |
ddf6fe37 | 24452 | @item -march=@var{name} |
d77de738 ML |
24453 | This specifies the name of the target architecture. GCC uses this |
24454 | name to determine what kind of instructions it can emit when generating | |
24455 | assembly code. Permissible names are: @samp{c62x}, | |
24456 | @samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}. | |
24457 | ||
d77de738 | 24458 | @opindex mbig-endian |
ddf6fe37 | 24459 | @item -mbig-endian |
d77de738 ML |
24460 | Generate code for a big-endian target. |
24461 | ||
d77de738 | 24462 | @opindex mlittle-endian |
ddf6fe37 | 24463 | @item -mlittle-endian |
d77de738 ML |
24464 | Generate code for a little-endian target. This is the default. |
24465 | ||
d77de738 | 24466 | @opindex msim |
ddf6fe37 | 24467 | @item -msim |
d77de738 ML |
24468 | Choose startup files and linker script suitable for the simulator. |
24469 | ||
d77de738 | 24470 | @opindex msdata=default |
ddf6fe37 | 24471 | @item -msdata=default |
d77de738 ML |
24472 | Put small global and static data in the @code{.neardata} section, |
24473 | which is pointed to by register @code{B14}. Put small uninitialized | |
24474 | global and static data in the @code{.bss} section, which is adjacent | |
24475 | to the @code{.neardata} section. Put small read-only data into the | |
24476 | @code{.rodata} section. The corresponding sections used for large | |
24477 | pieces of data are @code{.fardata}, @code{.far} and @code{.const}. | |
24478 | ||
d77de738 | 24479 | @opindex msdata=all |
ddf6fe37 | 24480 | @item -msdata=all |
d77de738 ML |
24481 | Put all data, not just small objects, into the sections reserved for |
24482 | small data, and use addressing relative to the @code{B14} register to | |
24483 | access them. | |
24484 | ||
d77de738 | 24485 | @opindex msdata=none |
ddf6fe37 | 24486 | @item -msdata=none |
d77de738 ML |
24487 | Make no use of the sections reserved for small data, and use absolute |
24488 | addresses to access all data. Put all initialized global and static | |
24489 | data in the @code{.fardata} section, and all uninitialized data in the | |
24490 | @code{.far} section. Put all constant data into the @code{.const} | |
24491 | section. | |
24492 | @end table | |
24493 | ||
24494 | @node CRIS Options | |
24495 | @subsection CRIS Options | |
24496 | @cindex CRIS Options | |
24497 | ||
24498 | These options are defined specifically for the CRIS ports. | |
24499 | ||
24500 | @table @gcctabopt | |
d77de738 ML |
24501 | @opindex march |
24502 | @opindex mcpu | |
ddf6fe37 AA |
24503 | @item -march=@var{architecture-type} |
24504 | @itemx -mcpu=@var{architecture-type} | |
d77de738 ML |
24505 | Generate code for the specified architecture. The choices for |
24506 | @var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for | |
24507 | respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@. | |
24508 | Default is @samp{v0}. | |
24509 | ||
d77de738 | 24510 | @opindex mtune |
ddf6fe37 | 24511 | @item -mtune=@var{architecture-type} |
d77de738 ML |
24512 | Tune to @var{architecture-type} everything applicable about the generated |
24513 | code, except for the ABI and the set of available instructions. The | |
24514 | choices for @var{architecture-type} are the same as for | |
24515 | @option{-march=@var{architecture-type}}. | |
24516 | ||
d77de738 | 24517 | @opindex mmax-stack-frame |
ddf6fe37 | 24518 | @item -mmax-stack-frame=@var{n} |
d77de738 ML |
24519 | Warn when the stack frame of a function exceeds @var{n} bytes. |
24520 | ||
d77de738 ML |
24521 | @opindex metrax4 |
24522 | @opindex metrax100 | |
ddf6fe37 AA |
24523 | @item -metrax4 |
24524 | @itemx -metrax100 | |
d77de738 ML |
24525 | The options @option{-metrax4} and @option{-metrax100} are synonyms for |
24526 | @option{-march=v3} and @option{-march=v8} respectively. | |
24527 | ||
d77de738 ML |
24528 | @opindex mmul-bug-workaround |
24529 | @opindex mno-mul-bug-workaround | |
ddf6fe37 AA |
24530 | @item -mmul-bug-workaround |
24531 | @itemx -mno-mul-bug-workaround | |
d77de738 ML |
24532 | Work around a bug in the @code{muls} and @code{mulu} instructions for CPU |
24533 | models where it applies. This option is disabled by default. | |
24534 | ||
d77de738 | 24535 | @opindex mpdebug |
ddf6fe37 | 24536 | @item -mpdebug |
d77de738 ML |
24537 | Enable CRIS-specific verbose debug-related information in the assembly |
24538 | code. This option also has the effect of turning off the @samp{#NO_APP} | |
24539 | formatted-code indicator to the assembler at the beginning of the | |
24540 | assembly file. | |
24541 | ||
d77de738 | 24542 | @opindex mcc-init |
ddf6fe37 | 24543 | @item -mcc-init |
d77de738 ML |
24544 | Do not use condition-code results from previous instruction; always emit |
24545 | compare and test instructions before use of condition codes. | |
24546 | ||
d77de738 ML |
24547 | @opindex mno-side-effects |
24548 | @opindex mside-effects | |
ddf6fe37 | 24549 | @item -mno-side-effects |
d77de738 ML |
24550 | Do not emit instructions with side effects in addressing modes other than |
24551 | post-increment. | |
24552 | ||
d77de738 ML |
24553 | @opindex mstack-align |
24554 | @opindex mno-stack-align | |
24555 | @opindex mdata-align | |
24556 | @opindex mno-data-align | |
24557 | @opindex mconst-align | |
24558 | @opindex mno-const-align | |
ddf6fe37 AA |
24559 | @item -mstack-align |
24560 | @itemx -mno-stack-align | |
24561 | @itemx -mdata-align | |
24562 | @itemx -mno-data-align | |
24563 | @itemx -mconst-align | |
24564 | @itemx -mno-const-align | |
d77de738 ML |
24565 | These options (@samp{no-} options) arrange (eliminate arrangements) for the |
24566 | stack frame, individual data and constants to be aligned for the maximum | |
24567 | single data access size for the chosen CPU model. The default is to | |
24568 | arrange for 32-bit alignment. ABI details such as structure layout are | |
24569 | not affected by these options. | |
24570 | ||
d77de738 ML |
24571 | @opindex m32-bit |
24572 | @opindex m16-bit | |
24573 | @opindex m8-bit | |
ddf6fe37 AA |
24574 | @item -m32-bit |
24575 | @itemx -m16-bit | |
24576 | @itemx -m8-bit | |
d77de738 ML |
24577 | Similar to the stack- data- and const-align options above, these options |
24578 | arrange for stack frame, writable data and constants to all be 32-bit, | |
24579 | 16-bit or 8-bit aligned. The default is 32-bit alignment. | |
24580 | ||
d77de738 ML |
24581 | @opindex mno-prologue-epilogue |
24582 | @opindex mprologue-epilogue | |
ddf6fe37 AA |
24583 | @item -mno-prologue-epilogue |
24584 | @itemx -mprologue-epilogue | |
d77de738 ML |
24585 | With @option{-mno-prologue-epilogue}, the normal function prologue and |
24586 | epilogue which set up the stack frame are omitted and no return | |
24587 | instructions or return sequences are generated in the code. Use this | |
24588 | option only together with visual inspection of the compiled code: no | |
24589 | warnings or errors are generated when call-saved registers must be saved, | |
24590 | or storage for local variables needs to be allocated. | |
24591 | ||
d77de738 | 24592 | @opindex melf |
ddf6fe37 | 24593 | @item -melf |
d77de738 ML |
24594 | Legacy no-op option. |
24595 | ||
d77de738 | 24596 | @opindex sim |
ddf6fe37 | 24597 | @item -sim |
d77de738 ML |
24598 | This option arranges |
24599 | to link with input-output functions from a simulator library. Code, | |
24600 | initialized data and zero-initialized data are allocated consecutively. | |
24601 | ||
d77de738 | 24602 | @opindex sim2 |
ddf6fe37 | 24603 | @item -sim2 |
d77de738 ML |
24604 | Like @option{-sim}, but pass linker options to locate initialized data at |
24605 | 0x40000000 and zero-initialized data at 0x80000000. | |
24606 | @end table | |
24607 | ||
24608 | @node C-SKY Options | |
24609 | @subsection C-SKY Options | |
24610 | @cindex C-SKY Options | |
24611 | ||
24612 | GCC supports these options when compiling for C-SKY V2 processors. | |
24613 | ||
24614 | @table @gcctabopt | |
24615 | ||
d77de738 | 24616 | @opindex march= |
ddf6fe37 | 24617 | @item -march=@var{arch} |
d77de738 ML |
24618 | Specify the C-SKY target architecture. Valid values for @var{arch} are: |
24619 | @samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}. | |
24620 | The default is @samp{ck810}. | |
24621 | ||
d77de738 | 24622 | @opindex mcpu= |
ddf6fe37 | 24623 | @item -mcpu=@var{cpu} |
d77de738 ML |
24624 | Specify the C-SKY target processor. Valid values for @var{cpu} are: |
24625 | @samp{ck801}, @samp{ck801t}, | |
24626 | @samp{ck802}, @samp{ck802t}, @samp{ck802j}, | |
24627 | @samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht}, | |
24628 | @samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh}, | |
24629 | @samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh}, | |
24630 | @samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1}, | |
24631 | @samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1}, | |
24632 | @samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1}, | |
24633 | @samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1}, | |
24634 | @samp{ck803eftr1}, @samp{ck803efhtr1}, | |
24635 | @samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf}, | |
24636 | @samp{ck803sef}, @samp{ck803seft}, | |
24637 | @samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f}, | |
24638 | @samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft}, | |
24639 | @samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv}, | |
24640 | @samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}. | |
24641 | ||
d77de738 | 24642 | @opindex mbig-endian |
d77de738 | 24643 | @opindex EB |
d77de738 | 24644 | @opindex mlittle-endian |
d77de738 | 24645 | @opindex EL |
ddf6fe37 AA |
24646 | @item -mbig-endian |
24647 | @itemx -EB | |
24648 | @itemx -mlittle-endian | |
24649 | @itemx -EL | |
d77de738 ML |
24650 | |
24651 | Select big- or little-endian code. The default is little-endian. | |
24652 | ||
d77de738 | 24653 | @opindex mfloat-abi |
ddf6fe37 | 24654 | @item -mfloat-abi=@var{name} |
d77de738 ML |
24655 | Specifies which floating-point ABI to use. Permissible values |
24656 | are: @samp{soft}, @samp{softfp} and @samp{hard}. | |
24657 | ||
24658 | Specifying @samp{soft} causes GCC to generate output containing | |
24659 | library calls for floating-point operations. | |
24660 | @samp{softfp} allows the generation of code using hardware floating-point | |
24661 | instructions, but still uses the soft-float calling conventions. | |
24662 | @samp{hard} allows generation of floating-point instructions | |
24663 | and uses FPU-specific calling conventions. | |
24664 | ||
24665 | The default depends on the specific target configuration. Note that | |
24666 | the hard-float and soft-float ABIs are not link-compatible; you must | |
24667 | compile your entire program with the same ABI, and link with a | |
24668 | compatible set of libraries. | |
24669 | ||
d77de738 | 24670 | @opindex mhard-float |
d77de738 | 24671 | @opindex msoft-float |
ddf6fe37 AA |
24672 | @item -mhard-float |
24673 | @itemx -msoft-float | |
d77de738 ML |
24674 | |
24675 | Select hardware or software floating-point implementations. | |
24676 | The default is soft float. | |
24677 | ||
ddf6fe37 | 24678 | @opindex mdouble-float |
d77de738 ML |
24679 | @item -mdouble-float |
24680 | @itemx -mno-double-float | |
d77de738 ML |
24681 | When @option{-mhard-float} is in effect, enable generation of |
24682 | double-precision float instructions. This is the default except | |
24683 | when compiling for CK803. | |
24684 | ||
ddf6fe37 | 24685 | @opindex mfdivdu |
d77de738 ML |
24686 | @item -mfdivdu |
24687 | @itemx -mno-fdivdu | |
d77de738 ML |
24688 | When @option{-mhard-float} is in effect, enable generation of |
24689 | @code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions. | |
24690 | This is the default except when compiling for CK803. | |
24691 | ||
d77de738 | 24692 | @opindex mfpu= |
ddf6fe37 | 24693 | @item -mfpu=@var{fpu} |
d77de738 ML |
24694 | Select the floating-point processor. This option can only be used with |
24695 | @option{-mhard-float}. | |
24696 | Values for @var{fpu} are | |
24697 | @samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}), | |
24698 | @samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and | |
24699 | @samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}). | |
24700 | ||
ddf6fe37 | 24701 | @opindex melrw |
d77de738 ML |
24702 | @item -melrw |
24703 | @itemx -mno-elrw | |
d77de738 ML |
24704 | Enable the extended @code{lrw} instruction. This option defaults to on |
24705 | for CK801 and off otherwise. | |
24706 | ||
ddf6fe37 | 24707 | @opindex mistack |
d77de738 ML |
24708 | @item -mistack |
24709 | @itemx -mno-istack | |
d77de738 ML |
24710 | Enable interrupt stack instructions; the default is off. |
24711 | ||
24712 | The @option{-mistack} option is required to handle the | |
24713 | @code{interrupt} and @code{isr} function attributes | |
24714 | (@pxref{C-SKY Function Attributes}). | |
24715 | ||
d77de738 | 24716 | @opindex mmp |
ddf6fe37 | 24717 | @item -mmp |
d77de738 ML |
24718 | Enable multiprocessor instructions; the default is off. |
24719 | ||
d77de738 | 24720 | @opindex mcp |
ddf6fe37 | 24721 | @item -mcp |
d77de738 ML |
24722 | Enable coprocessor instructions; the default is off. |
24723 | ||
d77de738 | 24724 | @opindex mcache |
ddf6fe37 | 24725 | @item -mcache |
d77de738 ML |
24726 | Enable coprocessor instructions; the default is off. |
24727 | ||
d77de738 | 24728 | @opindex msecurity |
ddf6fe37 | 24729 | @item -msecurity |
d77de738 ML |
24730 | Enable C-SKY security instructions; the default is off. |
24731 | ||
d77de738 | 24732 | @opindex mtrust |
ddf6fe37 | 24733 | @item -mtrust |
d77de738 ML |
24734 | Enable C-SKY trust instructions; the default is off. |
24735 | ||
d77de738 | 24736 | @opindex mdsp |
d77de738 | 24737 | @opindex medsp |
d77de738 | 24738 | @opindex mvdsp |
ddf6fe37 AA |
24739 | @item -mdsp |
24740 | @itemx -medsp | |
24741 | @itemx -mvdsp | |
d77de738 ML |
24742 | Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively. |
24743 | All of these options default to off. | |
24744 | ||
ddf6fe37 | 24745 | @opindex mdiv |
d77de738 ML |
24746 | @item -mdiv |
24747 | @itemx -mno-div | |
d77de738 ML |
24748 | Generate divide instructions. Default is off. |
24749 | ||
ddf6fe37 | 24750 | @opindex msmart |
d77de738 ML |
24751 | @item -msmart |
24752 | @itemx -mno-smart | |
d77de738 ML |
24753 | Generate code for Smart Mode, using only registers numbered 0-7 to allow |
24754 | use of 16-bit instructions. This option is ignored for CK801 where this | |
24755 | is the required behavior, and it defaults to on for CK802. | |
24756 | For other targets, the default is off. | |
24757 | ||
ddf6fe37 | 24758 | @opindex mhigh-registers |
d77de738 ML |
24759 | @item -mhigh-registers |
24760 | @itemx -mno-high-registers | |
d77de738 ML |
24761 | Generate code using the high registers numbered 16-31. This option |
24762 | is not supported on CK801, CK802, or CK803, and is enabled by default | |
24763 | for other processors. | |
24764 | ||
ddf6fe37 | 24765 | @opindex manchor |
d77de738 ML |
24766 | @item -manchor |
24767 | @itemx -mno-anchor | |
d77de738 ML |
24768 | Generate code using global anchor symbol addresses. |
24769 | ||
ddf6fe37 | 24770 | @opindex mpushpop |
d77de738 ML |
24771 | @item -mpushpop |
24772 | @itemx -mno-pushpop | |
d77de738 ML |
24773 | Generate code using @code{push} and @code{pop} instructions. This option |
24774 | defaults to on. | |
24775 | ||
ddf6fe37 | 24776 | @opindex mmultiple-stld |
d77de738 ML |
24777 | @item -mmultiple-stld |
24778 | @itemx -mstm | |
24779 | @itemx -mno-multiple-stld | |
24780 | @itemx -mno-stm | |
d77de738 ML |
24781 | Generate code using @code{stm} and @code{ldm} instructions. This option |
24782 | isn't supported on CK801 but is enabled by default on other processors. | |
24783 | ||
ddf6fe37 | 24784 | @opindex mconstpool |
d77de738 ML |
24785 | @item -mconstpool |
24786 | @itemx -mno-constpool | |
d77de738 ML |
24787 | Create constant pools in the compiler instead of deferring it to the |
24788 | assembler. This option is the default and required for correct code | |
24789 | generation on CK801 and CK802, and is optional on other processors. | |
24790 | ||
ddf6fe37 | 24791 | @opindex mstack-size |
d77de738 ML |
24792 | @item -mstack-size |
24793 | @item -mno-stack-size | |
d77de738 ML |
24794 | Emit @code{.stack_size} directives for each function in the assembly |
24795 | output. This option defaults to off. | |
24796 | ||
ddf6fe37 | 24797 | @opindex mccrt |
d77de738 ML |
24798 | @item -mccrt |
24799 | @itemx -mno-ccrt | |
d77de738 ML |
24800 | Generate code for the C-SKY compiler runtime instead of libgcc. This |
24801 | option defaults to off. | |
24802 | ||
d77de738 | 24803 | @opindex mbranch-cost= |
ddf6fe37 | 24804 | @item -mbranch-cost=@var{n} |
d77de738 ML |
24805 | Set the branch costs to roughly @code{n} instructions. The default is 1. |
24806 | ||
ddf6fe37 | 24807 | @opindex msched-prolog |
d77de738 ML |
24808 | @item -msched-prolog |
24809 | @itemx -mno-sched-prolog | |
d77de738 ML |
24810 | Permit scheduling of function prologue and epilogue sequences. Using |
24811 | this option can result in code that is not compliant with the C-SKY V2 ABI | |
24812 | prologue requirements and that cannot be debugged or backtraced. | |
24813 | It is disabled by default. | |
24814 | ||
d77de738 | 24815 | @opindex msim |
ddf6fe37 | 24816 | @item -msim |
d77de738 ML |
24817 | Links the library libsemi.a which is in compatible with simulator. Applicable |
24818 | to ELF compiler only. | |
24819 | ||
24820 | @end table | |
24821 | ||
24822 | @node Darwin Options | |
24823 | @subsection Darwin Options | |
24824 | @cindex Darwin options | |
24825 | ||
24826 | These options are defined for all architectures running the Darwin operating | |
24827 | system. | |
24828 | ||
24829 | FSF GCC on Darwin does not create ``fat'' object files; it creates | |
24830 | an object file for the single architecture that GCC was built to | |
24831 | target. Apple's GCC on Darwin does create ``fat'' files if multiple | |
24832 | @option{-arch} options are used; it does so by running the compiler or | |
24833 | linker multiple times and joining the results together with | |
24834 | @file{lipo}. | |
24835 | ||
24836 | The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or | |
24837 | @samp{i686}) is determined by the flags that specify the ISA | |
24838 | that GCC is targeting, like @option{-mcpu} or @option{-march}. The | |
24839 | @option{-force_cpusubtype_ALL} option can be used to override this. | |
24840 | ||
24841 | The Darwin tools vary in their behavior when presented with an ISA | |
24842 | mismatch. The assembler, @file{as}, only permits instructions to | |
24843 | be used that are valid for the subtype of the file it is generating, | |
24844 | so you cannot put 64-bit instructions in a @samp{ppc750} object file. | |
24845 | The linker for shared libraries, @file{/usr/bin/libtool}, fails | |
24846 | and prints an error if asked to create a shared library with a less | |
24847 | restrictive subtype than its input files (for instance, trying to put | |
24848 | a @samp{ppc970} object file in a @samp{ppc7400} library). The linker | |
24849 | for executables, @command{ld}, quietly gives the executable the most | |
24850 | restrictive subtype of any of its input files. | |
24851 | ||
24852 | @table @gcctabopt | |
d77de738 | 24853 | @opindex F |
ddf6fe37 | 24854 | @item -F@var{dir} |
d77de738 ML |
24855 | Add the framework directory @var{dir} to the head of the list of |
24856 | directories to be searched for header files. These directories are | |
24857 | interleaved with those specified by @option{-I} options and are | |
24858 | scanned in a left-to-right order. | |
24859 | ||
24860 | A framework directory is a directory with frameworks in it. A | |
24861 | framework is a directory with a @file{Headers} and/or | |
24862 | @file{PrivateHeaders} directory contained directly in it that ends | |
24863 | in @file{.framework}. The name of a framework is the name of this | |
24864 | directory excluding the @file{.framework}. Headers associated with | |
24865 | the framework are found in one of those two directories, with | |
24866 | @file{Headers} being searched first. A subframework is a framework | |
24867 | directory that is in a framework's @file{Frameworks} directory. | |
24868 | Includes of subframework headers can only appear in a header of a | |
24869 | framework that contains the subframework, or in a sibling subframework | |
24870 | header. Two subframeworks are siblings if they occur in the same | |
24871 | framework. A subframework should not have the same name as a | |
24872 | framework; a warning is issued if this is violated. Currently a | |
24873 | subframework cannot have subframeworks; in the future, the mechanism | |
24874 | may be extended to support this. The standard frameworks can be found | |
24875 | in @file{/System/Library/Frameworks} and | |
24876 | @file{/Library/Frameworks}. An example include looks like | |
24877 | @code{#include <Framework/header.h>}, where @file{Framework} denotes | |
24878 | the name of the framework and @file{header.h} is found in the | |
24879 | @file{PrivateHeaders} or @file{Headers} directory. | |
24880 | ||
d77de738 | 24881 | @opindex iframework |
ddf6fe37 | 24882 | @item -iframework@var{dir} |
d77de738 ML |
24883 | Like @option{-F} except the directory is a treated as a system |
24884 | directory. The main difference between this @option{-iframework} and | |
24885 | @option{-F} is that with @option{-iframework} the compiler does not | |
24886 | warn about constructs contained within header files found via | |
24887 | @var{dir}. This option is valid only for the C family of languages. | |
24888 | ||
d77de738 | 24889 | @opindex gused |
ddf6fe37 | 24890 | @item -gused |
d77de738 ML |
24891 | Emit debugging information for symbols that are used. For stabs |
24892 | debugging format, this enables @option{-feliminate-unused-debug-symbols}. | |
24893 | This is by default ON@. | |
24894 | ||
d77de738 | 24895 | @opindex gfull |
ddf6fe37 | 24896 | @item -gfull |
d77de738 ML |
24897 | Emit debugging information for all symbols and types. |
24898 | ||
cdd4b3c0 IS |
24899 | @opindex fconstant-cfstrings |
24900 | @item -fconstant-cfstrings | |
24901 | The @option{-fconstant-cfstrings} is an alias for @option{-mconstant-cfstrings}. | |
24902 | ||
24903 | @opindex mconstant-cfstrings | |
24904 | @item -mconstant-cfstrings | |
24905 | When the NeXT runtime is being used (the default on these systems), override | |
24906 | any @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} | |
24907 | literals to be laid out as constant CoreFoundation strings. | |
24908 | ||
24909 | @opindex mmacosx-version-min | |
d77de738 | 24910 | @item -mmacosx-version-min=@var{version} |
cdd4b3c0 IS |
24911 | The earliest version of MacOS X that this executable will run on is |
24912 | @var{version}. Typical values supported for @var{version} include @code{12}, | |
24913 | @code{10.12}, and @code{10.5.8}. | |
d77de738 ML |
24914 | |
24915 | If the compiler was built to use the system's headers by default, | |
24916 | then the default for this option is the system version on which the | |
24917 | compiler is running, otherwise the default is to make choices that | |
24918 | are compatible with as many systems and code bases as possible. | |
24919 | ||
d77de738 | 24920 | @opindex mkernel |
ddf6fe37 | 24921 | @item -mkernel |
d77de738 ML |
24922 | Enable kernel development mode. The @option{-mkernel} option sets |
24923 | @option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit}, | |
24924 | @option{-fno-exceptions}, @option{-fno-non-call-exceptions}, | |
24925 | @option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where | |
24926 | applicable. This mode also sets @option{-mno-altivec}, | |
24927 | @option{-msoft-float}, @option{-fno-builtin} and | |
24928 | @option{-mlong-branch} for PowerPC targets. | |
24929 | ||
d77de738 | 24930 | @opindex mone-byte-bool |
ddf6fe37 | 24931 | @item -mone-byte-bool |
d77de738 ML |
24932 | Override the defaults for @code{bool} so that @code{sizeof(bool)==1}. |
24933 | By default @code{sizeof(bool)} is @code{4} when compiling for | |
24934 | Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this | |
24935 | option has no effect on x86. | |
24936 | ||
24937 | @strong{Warning:} The @option{-mone-byte-bool} switch causes GCC | |
24938 | to generate code that is not binary compatible with code generated | |
24939 | without that switch. Using this switch may require recompiling all | |
24940 | other modules in a program, including system libraries. Use this | |
24941 | switch to conform to a non-default data model. | |
24942 | ||
d77de738 ML |
24943 | @opindex mfix-and-continue |
24944 | @opindex ffix-and-continue | |
24945 | @opindex findirect-data | |
ddf6fe37 AA |
24946 | @item -mfix-and-continue |
24947 | @itemx -ffix-and-continue | |
24948 | @itemx -findirect-data | |
d77de738 ML |
24949 | Generate code suitable for fast turnaround development, such as to |
24950 | allow GDB to dynamically load @file{.o} files into already-running | |
24951 | programs. @option{-findirect-data} and @option{-ffix-and-continue} | |
24952 | are provided for backwards compatibility. | |
24953 | ||
d77de738 | 24954 | @opindex all_load |
ddf6fe37 | 24955 | @item -all_load |
d77de738 ML |
24956 | Loads all members of static archive libraries. |
24957 | See man ld(1) for more information. | |
24958 | ||
d77de738 | 24959 | @opindex arch_errors_fatal |
ddf6fe37 | 24960 | @item -arch_errors_fatal |
d77de738 ML |
24961 | Cause the errors having to do with files that have the wrong architecture |
24962 | to be fatal. | |
24963 | ||
d77de738 | 24964 | @opindex bind_at_load |
ddf6fe37 | 24965 | @item -bind_at_load |
d77de738 ML |
24966 | Causes the output file to be marked such that the dynamic linker will |
24967 | bind all undefined references when the file is loaded or launched. | |
24968 | ||
d77de738 | 24969 | @opindex bundle |
ddf6fe37 | 24970 | @item -bundle |
d77de738 ML |
24971 | Produce a Mach-o bundle format file. |
24972 | See man ld(1) for more information. | |
24973 | ||
d77de738 | 24974 | @opindex bundle_loader |
ddf6fe37 | 24975 | @item -bundle_loader @var{executable} |
d77de738 ML |
24976 | This option specifies the @var{executable} that will load the build |
24977 | output file being linked. See man ld(1) for more information. | |
24978 | ||
d77de738 | 24979 | @opindex dynamiclib |
ddf6fe37 | 24980 | @item -dynamiclib |
d77de738 ML |
24981 | When passed this option, GCC produces a dynamic library instead of |
24982 | an executable when linking, using the Darwin @file{libtool} command. | |
24983 | ||
d77de738 | 24984 | @opindex force_cpusubtype_ALL |
ddf6fe37 | 24985 | @item -force_cpusubtype_ALL |
d77de738 ML |
24986 | This causes GCC's output file to have the @samp{ALL} subtype, instead of |
24987 | one controlled by the @option{-mcpu} or @option{-march} option. | |
24988 | ||
47b634a3 FXC |
24989 | @opindex nodefaultrpaths |
24990 | @item -nodefaultrpaths | |
24991 | Do not add default run paths for the compiler library directories to | |
24992 | executables, modules or dynamic libraries. On macOS 10.5 and later, | |
24993 | the embedded runpath is added by default unless the user adds | |
24994 | @option{-nodefaultrpaths} to the link line. Run paths are needed | |
24995 | (and therefore enforced) to build on macOS version 10.11 or later. | |
24996 | ||
d77de738 ML |
24997 | @item -allowable_client @var{client_name} |
24998 | @itemx -client_name | |
24999 | @itemx -compatibility_version | |
25000 | @itemx -current_version | |
25001 | @itemx -dead_strip | |
25002 | @itemx -dependency-file | |
25003 | @itemx -dylib_file | |
25004 | @itemx -dylinker_install_name | |
25005 | @itemx -dynamic | |
25006 | @itemx -exported_symbols_list | |
25007 | @itemx -filelist | |
25008 | @need 800 | |
25009 | @itemx -flat_namespace | |
25010 | @itemx -force_flat_namespace | |
25011 | @itemx -headerpad_max_install_names | |
25012 | @itemx -image_base | |
25013 | @itemx -init | |
25014 | @itemx -install_name | |
25015 | @itemx -keep_private_externs | |
25016 | @itemx -multi_module | |
25017 | @itemx -multiply_defined | |
25018 | @itemx -multiply_defined_unused | |
25019 | @need 800 | |
25020 | @itemx -noall_load | |
25021 | @itemx -no_dead_strip_inits_and_terms | |
25022 | @itemx -nofixprebinding | |
25023 | @itemx -nomultidefs | |
25024 | @itemx -noprebind | |
25025 | @itemx -noseglinkedit | |
25026 | @itemx -pagezero_size | |
25027 | @itemx -prebind | |
25028 | @itemx -prebind_all_twolevel_modules | |
25029 | @itemx -private_bundle | |
25030 | @need 800 | |
25031 | @itemx -read_only_relocs | |
25032 | @itemx -sectalign | |
25033 | @itemx -sectobjectsymbols | |
25034 | @itemx -whyload | |
25035 | @itemx -seg1addr | |
25036 | @itemx -sectcreate | |
25037 | @itemx -sectobjectsymbols | |
25038 | @itemx -sectorder | |
25039 | @itemx -segaddr | |
25040 | @itemx -segs_read_only_addr | |
25041 | @need 800 | |
25042 | @itemx -segs_read_write_addr | |
25043 | @itemx -seg_addr_table | |
25044 | @itemx -seg_addr_table_filename | |
25045 | @itemx -seglinkedit | |
25046 | @itemx -segprot | |
25047 | @itemx -segs_read_only_addr | |
25048 | @itemx -segs_read_write_addr | |
25049 | @itemx -single_module | |
25050 | @itemx -static | |
25051 | @itemx -sub_library | |
25052 | @need 800 | |
d77de738 ML |
25053 | @opindex allowable_client |
25054 | @opindex client_name | |
25055 | @opindex compatibility_version | |
25056 | @opindex current_version | |
25057 | @opindex dead_strip | |
25058 | @opindex dependency-file | |
25059 | @opindex dylib_file | |
25060 | @opindex dylinker_install_name | |
25061 | @opindex dynamic | |
25062 | @opindex exported_symbols_list | |
25063 | @opindex filelist | |
25064 | @opindex flat_namespace | |
25065 | @opindex force_flat_namespace | |
25066 | @opindex headerpad_max_install_names | |
25067 | @opindex image_base | |
25068 | @opindex init | |
25069 | @opindex install_name | |
25070 | @opindex keep_private_externs | |
25071 | @opindex multi_module | |
25072 | @opindex multiply_defined | |
25073 | @opindex multiply_defined_unused | |
25074 | @opindex noall_load | |
25075 | @opindex no_dead_strip_inits_and_terms | |
25076 | @opindex nofixprebinding | |
25077 | @opindex nomultidefs | |
25078 | @opindex noprebind | |
25079 | @opindex noseglinkedit | |
25080 | @opindex pagezero_size | |
25081 | @opindex prebind | |
25082 | @opindex prebind_all_twolevel_modules | |
25083 | @opindex private_bundle | |
25084 | @opindex read_only_relocs | |
25085 | @opindex sectalign | |
25086 | @opindex sectobjectsymbols | |
25087 | @opindex whyload | |
25088 | @opindex seg1addr | |
25089 | @opindex sectcreate | |
25090 | @opindex sectobjectsymbols | |
25091 | @opindex sectorder | |
25092 | @opindex segaddr | |
25093 | @opindex segs_read_only_addr | |
25094 | @opindex segs_read_write_addr | |
25095 | @opindex seg_addr_table | |
25096 | @opindex seg_addr_table_filename | |
25097 | @opindex seglinkedit | |
25098 | @opindex segprot | |
25099 | @opindex segs_read_only_addr | |
25100 | @opindex segs_read_write_addr | |
25101 | @opindex single_module | |
25102 | @opindex static | |
25103 | @opindex sub_library | |
25104 | @opindex sub_umbrella | |
25105 | @opindex twolevel_namespace | |
25106 | @opindex umbrella | |
25107 | @opindex undefined | |
25108 | @opindex unexported_symbols_list | |
25109 | @opindex weak_reference_mismatches | |
25110 | @opindex whatsloaded | |
ddf6fe37 AA |
25111 | @itemx -sub_umbrella |
25112 | @itemx -twolevel_namespace | |
25113 | @itemx -umbrella | |
25114 | @itemx -undefined | |
25115 | @itemx -unexported_symbols_list | |
25116 | @itemx -weak_reference_mismatches | |
25117 | @itemx -whatsloaded | |
d77de738 ML |
25118 | These options are passed to the Darwin linker. The Darwin linker man page |
25119 | describes them in detail. | |
25120 | @end table | |
25121 | ||
25122 | @node DEC Alpha Options | |
25123 | @subsection DEC Alpha Options | |
25124 | ||
25125 | These @samp{-m} options are defined for the DEC Alpha implementations: | |
25126 | ||
25127 | @table @gcctabopt | |
d77de738 ML |
25128 | @opindex mno-soft-float |
25129 | @opindex msoft-float | |
ddf6fe37 AA |
25130 | @item -mno-soft-float |
25131 | @itemx -msoft-float | |
d77de738 ML |
25132 | Use (do not use) the hardware floating-point instructions for |
25133 | floating-point operations. When @option{-msoft-float} is specified, | |
25134 | functions in @file{libgcc.a} are used to perform floating-point | |
25135 | operations. Unless they are replaced by routines that emulate the | |
25136 | floating-point operations, or compiled in such a way as to call such | |
25137 | emulations routines, these routines issue floating-point | |
25138 | operations. If you are compiling for an Alpha without floating-point | |
25139 | operations, you must ensure that the library is built so as not to call | |
25140 | them. | |
25141 | ||
25142 | Note that Alpha implementations without floating-point operations are | |
25143 | required to have floating-point registers. | |
25144 | ||
d77de738 ML |
25145 | @opindex mfp-reg |
25146 | @opindex mno-fp-regs | |
ddf6fe37 AA |
25147 | @item -mfp-reg |
25148 | @itemx -mno-fp-regs | |
d77de738 ML |
25149 | Generate code that uses (does not use) the floating-point register set. |
25150 | @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point | |
25151 | register set is not used, floating-point operands are passed in integer | |
25152 | registers as if they were integers and floating-point results are passed | |
25153 | in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence, | |
25154 | so any function with a floating-point argument or return value called by code | |
25155 | compiled with @option{-mno-fp-regs} must also be compiled with that | |
25156 | option. | |
25157 | ||
25158 | A typical use of this option is building a kernel that does not use, | |
25159 | and hence need not save and restore, any floating-point registers. | |
25160 | ||
d77de738 | 25161 | @opindex mieee |
ddf6fe37 | 25162 | @item -mieee |
d77de738 ML |
25163 | The Alpha architecture implements floating-point hardware optimized for |
25164 | maximum performance. It is mostly compliant with the IEEE floating-point | |
25165 | standard. However, for full compliance, software assistance is | |
25166 | required. This option generates code fully IEEE-compliant code | |
25167 | @emph{except} that the @var{inexact-flag} is not maintained (see below). | |
25168 | If this option is turned on, the preprocessor macro @code{_IEEE_FP} is | |
25169 | defined during compilation. The resulting code is less efficient but is | |
25170 | able to correctly support denormalized numbers and exceptional IEEE | |
25171 | values such as not-a-number and plus/minus infinity. Other Alpha | |
25172 | compilers call this option @option{-ieee_with_no_inexact}. | |
25173 | ||
d77de738 | 25174 | @opindex mieee-with-inexact |
ddf6fe37 | 25175 | @item -mieee-with-inexact |
d77de738 ML |
25176 | This is like @option{-mieee} except the generated code also maintains |
25177 | the IEEE @var{inexact-flag}. Turning on this option causes the | |
25178 | generated code to implement fully-compliant IEEE math. In addition to | |
25179 | @code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor | |
25180 | macro. On some Alpha implementations the resulting code may execute | |
25181 | significantly slower than the code generated by default. Since there is | |
25182 | very little code that depends on the @var{inexact-flag}, you should | |
25183 | normally not specify this option. Other Alpha compilers call this | |
25184 | option @option{-ieee_with_inexact}. | |
25185 | ||
d77de738 | 25186 | @opindex mfp-trap-mode |
ddf6fe37 | 25187 | @item -mfp-trap-mode=@var{trap-mode} |
d77de738 ML |
25188 | This option controls what floating-point related traps are enabled. |
25189 | Other Alpha compilers call this option @option{-fptm @var{trap-mode}}. | |
25190 | The trap mode can be set to one of four values: | |
25191 | ||
25192 | @table @samp | |
25193 | @item n | |
25194 | This is the default (normal) setting. The only traps that are enabled | |
25195 | are the ones that cannot be disabled in software (e.g., division by zero | |
25196 | trap). | |
25197 | ||
25198 | @item u | |
25199 | In addition to the traps enabled by @samp{n}, underflow traps are enabled | |
25200 | as well. | |
25201 | ||
25202 | @item su | |
25203 | Like @samp{u}, but the instructions are marked to be safe for software | |
25204 | completion (see Alpha architecture manual for details). | |
25205 | ||
25206 | @item sui | |
25207 | Like @samp{su}, but inexact traps are enabled as well. | |
25208 | @end table | |
25209 | ||
d77de738 | 25210 | @opindex mfp-rounding-mode |
ddf6fe37 | 25211 | @item -mfp-rounding-mode=@var{rounding-mode} |
d77de738 ML |
25212 | Selects the IEEE rounding mode. Other Alpha compilers call this option |
25213 | @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one | |
25214 | of: | |
25215 | ||
25216 | @table @samp | |
25217 | @item n | |
25218 | Normal IEEE rounding mode. Floating-point numbers are rounded towards | |
25219 | the nearest machine number or towards the even machine number in case | |
25220 | of a tie. | |
25221 | ||
25222 | @item m | |
25223 | Round towards minus infinity. | |
25224 | ||
25225 | @item c | |
25226 | Chopped rounding mode. Floating-point numbers are rounded towards zero. | |
25227 | ||
25228 | @item d | |
25229 | Dynamic rounding mode. A field in the floating-point control register | |
25230 | (@var{fpcr}, see Alpha architecture reference manual) controls the | |
25231 | rounding mode in effect. The C library initializes this register for | |
25232 | rounding towards plus infinity. Thus, unless your program modifies the | |
25233 | @var{fpcr}, @samp{d} corresponds to round towards plus infinity. | |
25234 | @end table | |
25235 | ||
d77de738 | 25236 | @opindex mtrap-precision |
ddf6fe37 | 25237 | @item -mtrap-precision=@var{trap-precision} |
d77de738 ML |
25238 | In the Alpha architecture, floating-point traps are imprecise. This |
25239 | means without software assistance it is impossible to recover from a | |
25240 | floating trap and program execution normally needs to be terminated. | |
25241 | GCC can generate code that can assist operating system trap handlers | |
25242 | in determining the exact location that caused a floating-point trap. | |
25243 | Depending on the requirements of an application, different levels of | |
25244 | precisions can be selected: | |
25245 | ||
25246 | @table @samp | |
25247 | @item p | |
25248 | Program precision. This option is the default and means a trap handler | |
25249 | can only identify which program caused a floating-point exception. | |
25250 | ||
25251 | @item f | |
25252 | Function precision. The trap handler can determine the function that | |
25253 | caused a floating-point exception. | |
25254 | ||
25255 | @item i | |
25256 | Instruction precision. The trap handler can determine the exact | |
25257 | instruction that caused a floating-point exception. | |
25258 | @end table | |
25259 | ||
25260 | Other Alpha compilers provide the equivalent options called | |
25261 | @option{-scope_safe} and @option{-resumption_safe}. | |
25262 | ||
d77de738 | 25263 | @opindex mieee-conformant |
ddf6fe37 | 25264 | @item -mieee-conformant |
d77de738 ML |
25265 | This option marks the generated code as IEEE conformant. You must not |
25266 | use this option unless you also specify @option{-mtrap-precision=i} and either | |
25267 | @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect | |
25268 | is to emit the line @samp{.eflag 48} in the function prologue of the | |
25269 | generated assembly file. | |
25270 | ||
d77de738 | 25271 | @opindex mbuild-constants |
ddf6fe37 | 25272 | @item -mbuild-constants |
d77de738 ML |
25273 | Normally GCC examines a 32- or 64-bit integer constant to |
25274 | see if it can construct it from smaller constants in two or three | |
25275 | instructions. If it cannot, it outputs the constant as a literal and | |
25276 | generates code to load it from the data segment at run time. | |
25277 | ||
25278 | Use this option to require GCC to construct @emph{all} integer constants | |
25279 | using code, even if it takes more instructions (the maximum is six). | |
25280 | ||
25281 | You typically use this option to build a shared library dynamic | |
25282 | loader. Itself a shared library, it must relocate itself in memory | |
25283 | before it can find the variables and constants in its own data segment. | |
25284 | ||
d77de738 ML |
25285 | @opindex mbwx |
25286 | @opindex mno-bwx | |
25287 | @opindex mcix | |
25288 | @opindex mno-cix | |
25289 | @opindex mfix | |
25290 | @opindex mno-fix | |
25291 | @opindex mmax | |
25292 | @opindex mno-max | |
ddf6fe37 AA |
25293 | @item -mbwx |
25294 | @itemx -mno-bwx | |
25295 | @itemx -mcix | |
25296 | @itemx -mno-cix | |
25297 | @itemx -mfix | |
25298 | @itemx -mno-fix | |
25299 | @itemx -mmax | |
25300 | @itemx -mno-max | |
d77de738 ML |
25301 | Indicate whether GCC should generate code to use the optional BWX, |
25302 | CIX, FIX and MAX instruction sets. The default is to use the instruction | |
25303 | sets supported by the CPU type specified via @option{-mcpu=} option or that | |
25304 | of the CPU on which GCC was built if none is specified. | |
25305 | ||
d77de738 ML |
25306 | @opindex mfloat-vax |
25307 | @opindex mfloat-ieee | |
ddf6fe37 AA |
25308 | @item -mfloat-vax |
25309 | @itemx -mfloat-ieee | |
d77de738 ML |
25310 | Generate code that uses (does not use) VAX F and G floating-point |
25311 | arithmetic instead of IEEE single and double precision. | |
25312 | ||
d77de738 ML |
25313 | @opindex mexplicit-relocs |
25314 | @opindex mno-explicit-relocs | |
ddf6fe37 AA |
25315 | @item -mexplicit-relocs |
25316 | @itemx -mno-explicit-relocs | |
d77de738 ML |
25317 | Older Alpha assemblers provided no way to generate symbol relocations |
25318 | except via assembler macros. Use of these macros does not allow | |
25319 | optimal instruction scheduling. GNU binutils as of version 2.12 | |
25320 | supports a new syntax that allows the compiler to explicitly mark | |
25321 | which relocations should apply to which instructions. This option | |
25322 | is mostly useful for debugging, as GCC detects the capabilities of | |
25323 | the assembler when it is built and sets the default accordingly. | |
25324 | ||
d77de738 ML |
25325 | @opindex msmall-data |
25326 | @opindex mlarge-data | |
ddf6fe37 AA |
25327 | @item -msmall-data |
25328 | @itemx -mlarge-data | |
d77de738 ML |
25329 | When @option{-mexplicit-relocs} is in effect, static data is |
25330 | accessed via @dfn{gp-relative} relocations. When @option{-msmall-data} | |
25331 | is used, objects 8 bytes long or smaller are placed in a @dfn{small data area} | |
25332 | (the @code{.sdata} and @code{.sbss} sections) and are accessed via | |
25333 | 16-bit relocations off of the @code{$gp} register. This limits the | |
25334 | size of the small data area to 64KB, but allows the variables to be | |
25335 | directly accessed via a single instruction. | |
25336 | ||
25337 | The default is @option{-mlarge-data}. With this option the data area | |
25338 | is limited to just below 2GB@. Programs that require more than 2GB of | |
25339 | data must use @code{malloc} or @code{mmap} to allocate the data in the | |
25340 | heap instead of in the program's data segment. | |
25341 | ||
25342 | When generating code for shared libraries, @option{-fpic} implies | |
25343 | @option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}. | |
25344 | ||
d77de738 ML |
25345 | @opindex msmall-text |
25346 | @opindex mlarge-text | |
ddf6fe37 AA |
25347 | @item -msmall-text |
25348 | @itemx -mlarge-text | |
d77de738 ML |
25349 | When @option{-msmall-text} is used, the compiler assumes that the |
25350 | code of the entire program (or shared library) fits in 4MB, and is | |
25351 | thus reachable with a branch instruction. When @option{-msmall-data} | |
25352 | is used, the compiler can assume that all local symbols share the | |
25353 | same @code{$gp} value, and thus reduce the number of instructions | |
25354 | required for a function call from 4 to 1. | |
25355 | ||
25356 | The default is @option{-mlarge-text}. | |
25357 | ||
d77de738 | 25358 | @opindex mcpu |
ddf6fe37 | 25359 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
25360 | Set the instruction set and instruction scheduling parameters for |
25361 | machine type @var{cpu_type}. You can specify either the @samp{EV} | |
25362 | style name or the corresponding chip number. GCC supports scheduling | |
25363 | parameters for the EV4, EV5 and EV6 family of processors and | |
25364 | chooses the default values for the instruction set from the processor | |
25365 | you specify. If you do not specify a processor type, GCC defaults | |
25366 | to the processor on which the compiler was built. | |
25367 | ||
25368 | Supported values for @var{cpu_type} are | |
25369 | ||
25370 | @table @samp | |
25371 | @item ev4 | |
25372 | @itemx ev45 | |
25373 | @itemx 21064 | |
25374 | Schedules as an EV4 and has no instruction set extensions. | |
25375 | ||
25376 | @item ev5 | |
25377 | @itemx 21164 | |
25378 | Schedules as an EV5 and has no instruction set extensions. | |
25379 | ||
25380 | @item ev56 | |
25381 | @itemx 21164a | |
25382 | Schedules as an EV5 and supports the BWX extension. | |
25383 | ||
25384 | @item pca56 | |
25385 | @itemx 21164pc | |
25386 | @itemx 21164PC | |
25387 | Schedules as an EV5 and supports the BWX and MAX extensions. | |
25388 | ||
25389 | @item ev6 | |
25390 | @itemx 21264 | |
25391 | Schedules as an EV6 and supports the BWX, FIX, and MAX extensions. | |
25392 | ||
25393 | @item ev67 | |
25394 | @itemx 21264a | |
25395 | Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions. | |
25396 | @end table | |
25397 | ||
25398 | Native toolchains also support the value @samp{native}, | |
25399 | which selects the best architecture option for the host processor. | |
25400 | @option{-mcpu=native} has no effect if GCC does not recognize | |
25401 | the processor. | |
25402 | ||
d77de738 | 25403 | @opindex mtune |
ddf6fe37 | 25404 | @item -mtune=@var{cpu_type} |
d77de738 ML |
25405 | Set only the instruction scheduling parameters for machine type |
25406 | @var{cpu_type}. The instruction set is not changed. | |
25407 | ||
25408 | Native toolchains also support the value @samp{native}, | |
25409 | which selects the best architecture option for the host processor. | |
25410 | @option{-mtune=native} has no effect if GCC does not recognize | |
25411 | the processor. | |
25412 | ||
d77de738 | 25413 | @opindex mmemory-latency |
ddf6fe37 | 25414 | @item -mmemory-latency=@var{time} |
d77de738 ML |
25415 | Sets the latency the scheduler should assume for typical memory |
25416 | references as seen by the application. This number is highly | |
25417 | dependent on the memory access patterns used by the application | |
25418 | and the size of the external cache on the machine. | |
25419 | ||
25420 | Valid options for @var{time} are | |
25421 | ||
25422 | @table @samp | |
25423 | @item @var{number} | |
25424 | A decimal number representing clock cycles. | |
25425 | ||
25426 | @item L1 | |
25427 | @itemx L2 | |
25428 | @itemx L3 | |
25429 | @itemx main | |
25430 | The compiler contains estimates of the number of clock cycles for | |
25431 | ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches | |
25432 | (also called Dcache, Scache, and Bcache), as well as to main memory. | |
25433 | Note that L3 is only valid for EV5. | |
25434 | ||
25435 | @end table | |
25436 | @end table | |
25437 | ||
25438 | @node eBPF Options | |
25439 | @subsection eBPF Options | |
25440 | @cindex eBPF Options | |
25441 | ||
25442 | @table @gcctabopt | |
25443 | @item -mframe-limit=@var{bytes} | |
25444 | This specifies the hard limit for frame sizes, in bytes. Currently, | |
25445 | the value that can be specified should be less than or equal to | |
25446 | @samp{32767}. Defaults to whatever limit is imposed by the version of | |
25447 | the Linux kernel targeted. | |
25448 | ||
d77de738 | 25449 | @opindex mbig-endian |
ddf6fe37 | 25450 | @item -mbig-endian |
d77de738 ML |
25451 | Generate code for a big-endian target. |
25452 | ||
d77de738 | 25453 | @opindex mlittle-endian |
ddf6fe37 | 25454 | @item -mlittle-endian |
d77de738 ML |
25455 | Generate code for a little-endian target. This is the default. |
25456 | ||
d77de738 | 25457 | @opindex mjmpext |
ddf6fe37 | 25458 | @item -mjmpext |
9cbf4286 DF |
25459 | @itemx -mno-jmpext |
25460 | Enable or disable generation of extra conditional-branch instructions. | |
d77de738 ML |
25461 | Enabled for CPU v2 and above. |
25462 | ||
d77de738 | 25463 | @opindex mjmp32 |
ddf6fe37 | 25464 | @item -mjmp32 |
9cbf4286 DF |
25465 | @itemx -mno-jmp32 |
25466 | Enable or disable generation of 32-bit jump instructions. | |
25467 | Enabled for CPU v3 and above. | |
d77de738 | 25468 | |
d77de738 | 25469 | @opindex malu32 |
ddf6fe37 | 25470 | @item -malu32 |
9cbf4286 DF |
25471 | @itemx -mno-alu32 |
25472 | Enable or disable generation of 32-bit ALU instructions. | |
25473 | Enabled for CPU v3 and above. | |
25474 | ||
25475 | @opindex mv3-atomics | |
25476 | @item -mv3-atomics | |
25477 | @itemx -mno-v3-atomics | |
25478 | Enable or disable instructions for general atomic operations introduced | |
25479 | in CPU v3. Enabled for CPU v3 and above. | |
d77de738 | 25480 | |
f1e34551 JM |
25481 | @opindex mbswap |
25482 | @item -mbswap | |
9cbf4286 DF |
25483 | @itemx -mno-bswap |
25484 | Enable or disable byte swap instructions. Enabled for CPU v4 and above. | |
f1e34551 | 25485 | |
4be3919f JM |
25486 | @opindex msdiv |
25487 | @item -msdiv | |
9cbf4286 DF |
25488 | @itemx -mno-sdiv |
25489 | Enable or disable signed division and modulus instructions. Enabled for | |
25490 | CPU v4 and above. | |
db189d02 | 25491 | |
14dab1a1 DF |
25492 | @opindex msmov |
25493 | @item -msmov | |
25494 | @itemx -mno-smov | |
25495 | Enable or disable sign-extending move and memory load instructions. | |
25496 | Enabled for CPU v4 and above. | |
25497 | ||
d77de738 | 25498 | @opindex mcpu |
ddf6fe37 | 25499 | @item -mcpu=@var{version} |
d77de738 | 25500 | This specifies which version of the eBPF ISA to target. Newer versions |
f1e34551 | 25501 | may not be supported by all kernels. The default is @samp{v4}. |
d77de738 ML |
25502 | |
25503 | Supported values for @var{version} are: | |
25504 | ||
25505 | @table @samp | |
25506 | @item v1 | |
25507 | The first stable eBPF ISA with no special features or extensions. | |
25508 | ||
25509 | @item v2 | |
25510 | Supports the jump extensions, as in @option{-mjmpext}. | |
25511 | ||
25512 | @item v3 | |
25513 | All features of v2, plus: | |
25514 | @itemize @minus | |
25515 | @item 32-bit jump operations, as in @option{-mjmp32} | |
25516 | @item 32-bit ALU operations, as in @option{-malu32} | |
db189d02 | 25517 | @item general atomic operations, as in @option{-mv3-atomics} |
d77de738 ML |
25518 | @end itemize |
25519 | ||
f1e34551 JM |
25520 | @item v4 |
25521 | All features of v3, plus: | |
25522 | @itemize @minus | |
25523 | @item Byte swap instructions, as in @option{-mbswap} | |
9cbf4286 | 25524 | @item Signed division and modulus instructions, as in @option{-msdiv} |
14dab1a1 | 25525 | @item Sign-extending move and memory load instructions, as in @option{-msmov} |
f1e34551 | 25526 | @end itemize |
d77de738 ML |
25527 | @end table |
25528 | ||
d77de738 | 25529 | @opindex mco-re |
ddf6fe37 | 25530 | @item -mco-re |
d77de738 ML |
25531 | Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and |
25532 | is implied by @option{-gbtf}. | |
25533 | ||
d77de738 | 25534 | @opindex mno-co-re |
ddf6fe37 | 25535 | @item -mno-co-re |
d77de738 ML |
25536 | Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE |
25537 | support is enabled by default when generating BTF debug information for | |
25538 | the BPF target. | |
25539 | ||
25540 | @item -mxbpf | |
25541 | Generate code for an expanded version of BPF, which relaxes some of | |
25542 | the restrictions imposed by the BPF architecture: | |
25543 | @itemize @minus | |
25544 | @item Save and restore callee-saved registers at function entry and | |
25545 | exit, respectively. | |
25546 | @end itemize | |
77d0f9ec CM |
25547 | |
25548 | @opindex masm=@var{dialect} | |
25549 | @item -masm=@var{dialect} | |
25550 | Outputs assembly instructions using eBPF selected @var{dialect}. The default | |
25551 | is @samp{normal}. | |
25552 | ||
25553 | Supported values for @var{dialect} are: | |
25554 | ||
25555 | @table @samp | |
25556 | @item normal | |
25557 | Outputs normal assembly dialect. | |
25558 | ||
25559 | @item pseudoc | |
25560 | Outputs pseudo-c assembly dialect. | |
25561 | ||
25562 | @end table | |
25563 | ||
d77de738 ML |
25564 | @end table |
25565 | ||
25566 | @node FR30 Options | |
25567 | @subsection FR30 Options | |
25568 | @cindex FR30 Options | |
25569 | ||
25570 | These options are defined specifically for the FR30 port. | |
25571 | ||
25572 | @table @gcctabopt | |
25573 | ||
d77de738 | 25574 | @opindex msmall-model |
ddf6fe37 | 25575 | @item -msmall-model |
d77de738 ML |
25576 | Use the small address space model. This can produce smaller code, but |
25577 | it does assume that all symbolic values and addresses fit into a | |
25578 | 20-bit range. | |
25579 | ||
d77de738 | 25580 | @opindex mno-lsim |
ddf6fe37 | 25581 | @item -mno-lsim |
d77de738 ML |
25582 | Assume that runtime support has been provided and so there is no need |
25583 | to include the simulator library (@file{libsim.a}) on the linker | |
25584 | command line. | |
25585 | ||
25586 | @end table | |
25587 | ||
25588 | @node FT32 Options | |
25589 | @subsection FT32 Options | |
25590 | @cindex FT32 Options | |
25591 | ||
25592 | These options are defined specifically for the FT32 port. | |
25593 | ||
25594 | @table @gcctabopt | |
25595 | ||
d77de738 | 25596 | @opindex msim |
ddf6fe37 | 25597 | @item -msim |
d77de738 ML |
25598 | Specifies that the program will be run on the simulator. This causes |
25599 | an alternate runtime startup and library to be linked. | |
25600 | You must not use this option when generating programs that will run on | |
25601 | real hardware; you must provide your own runtime library for whatever | |
25602 | I/O functions are needed. | |
25603 | ||
d77de738 | 25604 | @opindex mlra |
ddf6fe37 | 25605 | @item -mlra |
d77de738 ML |
25606 | Enable Local Register Allocation. This is still experimental for FT32, |
25607 | so by default the compiler uses standard reload. | |
25608 | ||
d77de738 | 25609 | @opindex mnodiv |
ddf6fe37 | 25610 | @item -mnodiv |
d77de738 ML |
25611 | Do not use div and mod instructions. |
25612 | ||
d77de738 | 25613 | @opindex mft32b |
ddf6fe37 | 25614 | @item -mft32b |
d77de738 ML |
25615 | Enable use of the extended instructions of the FT32B processor. |
25616 | ||
d77de738 | 25617 | @opindex mcompress |
ddf6fe37 | 25618 | @item -mcompress |
d77de738 ML |
25619 | Compress all code using the Ft32B code compression scheme. |
25620 | ||
d77de738 | 25621 | @opindex mnopm |
ddf6fe37 | 25622 | @item -mnopm |
d77de738 ML |
25623 | Do not generate code that reads program memory. |
25624 | ||
25625 | @end table | |
25626 | ||
25627 | @node FRV Options | |
25628 | @subsection FRV Options | |
25629 | @cindex FRV Options | |
25630 | ||
25631 | @table @gcctabopt | |
d77de738 | 25632 | @opindex mgpr-32 |
ddf6fe37 | 25633 | @item -mgpr-32 |
d77de738 ML |
25634 | |
25635 | Only use the first 32 general-purpose registers. | |
25636 | ||
d77de738 | 25637 | @opindex mgpr-64 |
ddf6fe37 | 25638 | @item -mgpr-64 |
d77de738 ML |
25639 | |
25640 | Use all 64 general-purpose registers. | |
25641 | ||
d77de738 | 25642 | @opindex mfpr-32 |
ddf6fe37 | 25643 | @item -mfpr-32 |
d77de738 ML |
25644 | |
25645 | Use only the first 32 floating-point registers. | |
25646 | ||
d77de738 | 25647 | @opindex mfpr-64 |
ddf6fe37 | 25648 | @item -mfpr-64 |
d77de738 ML |
25649 | |
25650 | Use all 64 floating-point registers. | |
25651 | ||
d77de738 | 25652 | @opindex mhard-float |
ddf6fe37 | 25653 | @item -mhard-float |
d77de738 ML |
25654 | |
25655 | Use hardware instructions for floating-point operations. | |
25656 | ||
d77de738 | 25657 | @opindex msoft-float |
ddf6fe37 | 25658 | @item -msoft-float |
d77de738 ML |
25659 | |
25660 | Use library routines for floating-point operations. | |
25661 | ||
d77de738 | 25662 | @opindex malloc-cc |
ddf6fe37 | 25663 | @item -malloc-cc |
d77de738 ML |
25664 | |
25665 | Dynamically allocate condition code registers. | |
25666 | ||
d77de738 | 25667 | @opindex mfixed-cc |
ddf6fe37 | 25668 | @item -mfixed-cc |
d77de738 ML |
25669 | |
25670 | Do not try to dynamically allocate condition code registers, only | |
25671 | use @code{icc0} and @code{fcc0}. | |
25672 | ||
d77de738 | 25673 | @opindex mdword |
ddf6fe37 | 25674 | @item -mdword |
d77de738 ML |
25675 | |
25676 | Change ABI to use double word insns. | |
25677 | ||
d77de738 ML |
25678 | @opindex mno-dword |
25679 | @opindex mdword | |
ddf6fe37 | 25680 | @item -mno-dword |
d77de738 ML |
25681 | |
25682 | Do not use double word instructions. | |
25683 | ||
d77de738 | 25684 | @opindex mdouble |
ddf6fe37 | 25685 | @item -mdouble |
d77de738 ML |
25686 | |
25687 | Use floating-point double instructions. | |
25688 | ||
d77de738 | 25689 | @opindex mno-double |
ddf6fe37 | 25690 | @item -mno-double |
d77de738 ML |
25691 | |
25692 | Do not use floating-point double instructions. | |
25693 | ||
d77de738 | 25694 | @opindex mmedia |
ddf6fe37 | 25695 | @item -mmedia |
d77de738 ML |
25696 | |
25697 | Use media instructions. | |
25698 | ||
d77de738 | 25699 | @opindex mno-media |
ddf6fe37 | 25700 | @item -mno-media |
d77de738 ML |
25701 | |
25702 | Do not use media instructions. | |
25703 | ||
d77de738 | 25704 | @opindex mmuladd |
ddf6fe37 | 25705 | @item -mmuladd |
d77de738 ML |
25706 | |
25707 | Use multiply and add/subtract instructions. | |
25708 | ||
d77de738 | 25709 | @opindex mno-muladd |
ddf6fe37 | 25710 | @item -mno-muladd |
d77de738 ML |
25711 | |
25712 | Do not use multiply and add/subtract instructions. | |
25713 | ||
d77de738 | 25714 | @opindex mfdpic |
ddf6fe37 | 25715 | @item -mfdpic |
d77de738 ML |
25716 | |
25717 | Select the FDPIC ABI, which uses function descriptors to represent | |
25718 | pointers to functions. Without any PIC/PIE-related options, it | |
25719 | implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it | |
25720 | assumes GOT entries and small data are within a 12-bit range from the | |
25721 | GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets | |
25722 | are computed with 32 bits. | |
25723 | With a @samp{bfin-elf} target, this option implies @option{-msim}. | |
25724 | ||
d77de738 | 25725 | @opindex minline-plt |
ddf6fe37 | 25726 | @item -minline-plt |
d77de738 ML |
25727 | |
25728 | Enable inlining of PLT entries in function calls to functions that are | |
25729 | not known to bind locally. It has no effect without @option{-mfdpic}. | |
25730 | It's enabled by default if optimizing for speed and compiling for | |
25731 | shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an | |
25732 | optimization option such as @option{-O3} or above is present in the | |
25733 | command line. | |
25734 | ||
d77de738 | 25735 | @opindex mTLS |
ddf6fe37 | 25736 | @item -mTLS |
d77de738 ML |
25737 | |
25738 | Assume a large TLS segment when generating thread-local code. | |
25739 | ||
d77de738 | 25740 | @opindex mtls |
ddf6fe37 | 25741 | @item -mtls |
d77de738 ML |
25742 | |
25743 | Do not assume a large TLS segment when generating thread-local code. | |
25744 | ||
d77de738 | 25745 | @opindex mgprel-ro |
ddf6fe37 | 25746 | @item -mgprel-ro |
d77de738 ML |
25747 | |
25748 | Enable the use of @code{GPREL} relocations in the FDPIC ABI for data | |
25749 | that is known to be in read-only sections. It's enabled by default, | |
25750 | except for @option{-fpic} or @option{-fpie}: even though it may help | |
25751 | make the global offset table smaller, it trades 1 instruction for 4. | |
25752 | With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4, | |
25753 | one of which may be shared by multiple symbols, and it avoids the need | |
25754 | for a GOT entry for the referenced symbol, so it's more likely to be a | |
25755 | win. If it is not, @option{-mno-gprel-ro} can be used to disable it. | |
25756 | ||
d77de738 | 25757 | @opindex multilib-library-pic |
ddf6fe37 | 25758 | @item -multilib-library-pic |
d77de738 ML |
25759 | |
25760 | Link with the (library, not FD) pic libraries. It's implied by | |
25761 | @option{-mlibrary-pic}, as well as by @option{-fPIC} and | |
25762 | @option{-fpic} without @option{-mfdpic}. You should never have to use | |
25763 | it explicitly. | |
25764 | ||
d77de738 | 25765 | @opindex mlinked-fp |
ddf6fe37 | 25766 | @item -mlinked-fp |
d77de738 ML |
25767 | |
25768 | Follow the EABI requirement of always creating a frame pointer whenever | |
25769 | a stack frame is allocated. This option is enabled by default and can | |
25770 | be disabled with @option{-mno-linked-fp}. | |
25771 | ||
d77de738 | 25772 | @opindex mlong-calls |
ddf6fe37 | 25773 | @item -mlong-calls |
d77de738 ML |
25774 | |
25775 | Use indirect addressing to call functions outside the current | |
25776 | compilation unit. This allows the functions to be placed anywhere | |
25777 | within the 32-bit address space. | |
25778 | ||
d77de738 | 25779 | @opindex malign-labels |
ddf6fe37 | 25780 | @item -malign-labels |
d77de738 ML |
25781 | |
25782 | Try to align labels to an 8-byte boundary by inserting NOPs into the | |
25783 | previous packet. This option only has an effect when VLIW packing | |
25784 | is enabled. It doesn't create new packets; it merely adds NOPs to | |
25785 | existing ones. | |
25786 | ||
d77de738 | 25787 | @opindex mlibrary-pic |
ddf6fe37 | 25788 | @item -mlibrary-pic |
d77de738 ML |
25789 | |
25790 | Generate position-independent EABI code. | |
25791 | ||
d77de738 | 25792 | @opindex macc-4 |
ddf6fe37 | 25793 | @item -macc-4 |
d77de738 ML |
25794 | |
25795 | Use only the first four media accumulator registers. | |
25796 | ||
d77de738 | 25797 | @opindex macc-8 |
ddf6fe37 | 25798 | @item -macc-8 |
d77de738 ML |
25799 | |
25800 | Use all eight media accumulator registers. | |
25801 | ||
d77de738 | 25802 | @opindex mpack |
ddf6fe37 | 25803 | @item -mpack |
d77de738 ML |
25804 | |
25805 | Pack VLIW instructions. | |
25806 | ||
d77de738 | 25807 | @opindex mno-pack |
ddf6fe37 | 25808 | @item -mno-pack |
d77de738 ML |
25809 | |
25810 | Do not pack VLIW instructions. | |
25811 | ||
d77de738 | 25812 | @opindex mno-eflags |
ddf6fe37 | 25813 | @item -mno-eflags |
d77de738 ML |
25814 | |
25815 | Do not mark ABI switches in e_flags. | |
25816 | ||
d77de738 | 25817 | @opindex mcond-move |
ddf6fe37 | 25818 | @item -mcond-move |
d77de738 ML |
25819 | |
25820 | Enable the use of conditional-move instructions (default). | |
25821 | ||
25822 | This switch is mainly for debugging the compiler and will likely be removed | |
25823 | in a future version. | |
25824 | ||
d77de738 | 25825 | @opindex mno-cond-move |
ddf6fe37 | 25826 | @item -mno-cond-move |
d77de738 ML |
25827 | |
25828 | Disable the use of conditional-move instructions. | |
25829 | ||
25830 | This switch is mainly for debugging the compiler and will likely be removed | |
25831 | in a future version. | |
25832 | ||
d77de738 | 25833 | @opindex mscc |
ddf6fe37 | 25834 | @item -mscc |
d77de738 ML |
25835 | |
25836 | Enable the use of conditional set instructions (default). | |
25837 | ||
25838 | This switch is mainly for debugging the compiler and will likely be removed | |
25839 | in a future version. | |
25840 | ||
d77de738 | 25841 | @opindex mno-scc |
ddf6fe37 | 25842 | @item -mno-scc |
d77de738 ML |
25843 | |
25844 | Disable the use of conditional set instructions. | |
25845 | ||
25846 | This switch is mainly for debugging the compiler and will likely be removed | |
25847 | in a future version. | |
25848 | ||
d77de738 | 25849 | @opindex mcond-exec |
ddf6fe37 | 25850 | @item -mcond-exec |
d77de738 ML |
25851 | |
25852 | Enable the use of conditional execution (default). | |
25853 | ||
25854 | This switch is mainly for debugging the compiler and will likely be removed | |
25855 | in a future version. | |
25856 | ||
d77de738 | 25857 | @opindex mno-cond-exec |
ddf6fe37 | 25858 | @item -mno-cond-exec |
d77de738 ML |
25859 | |
25860 | Disable the use of conditional execution. | |
25861 | ||
25862 | This switch is mainly for debugging the compiler and will likely be removed | |
25863 | in a future version. | |
25864 | ||
d77de738 | 25865 | @opindex mvliw-branch |
ddf6fe37 | 25866 | @item -mvliw-branch |
d77de738 ML |
25867 | |
25868 | Run a pass to pack branches into VLIW instructions (default). | |
25869 | ||
25870 | This switch is mainly for debugging the compiler and will likely be removed | |
25871 | in a future version. | |
25872 | ||
d77de738 | 25873 | @opindex mno-vliw-branch |
ddf6fe37 | 25874 | @item -mno-vliw-branch |
d77de738 ML |
25875 | |
25876 | Do not run a pass to pack branches into VLIW instructions. | |
25877 | ||
25878 | This switch is mainly for debugging the compiler and will likely be removed | |
25879 | in a future version. | |
25880 | ||
d77de738 | 25881 | @opindex mmulti-cond-exec |
ddf6fe37 | 25882 | @item -mmulti-cond-exec |
d77de738 ML |
25883 | |
25884 | Enable optimization of @code{&&} and @code{||} in conditional execution | |
25885 | (default). | |
25886 | ||
25887 | This switch is mainly for debugging the compiler and will likely be removed | |
25888 | in a future version. | |
25889 | ||
d77de738 | 25890 | @opindex mno-multi-cond-exec |
ddf6fe37 | 25891 | @item -mno-multi-cond-exec |
d77de738 ML |
25892 | |
25893 | Disable optimization of @code{&&} and @code{||} in conditional execution. | |
25894 | ||
25895 | This switch is mainly for debugging the compiler and will likely be removed | |
25896 | in a future version. | |
25897 | ||
d77de738 | 25898 | @opindex mnested-cond-exec |
ddf6fe37 | 25899 | @item -mnested-cond-exec |
d77de738 ML |
25900 | |
25901 | Enable nested conditional execution optimizations (default). | |
25902 | ||
25903 | This switch is mainly for debugging the compiler and will likely be removed | |
25904 | in a future version. | |
25905 | ||
d77de738 | 25906 | @opindex mno-nested-cond-exec |
ddf6fe37 | 25907 | @item -mno-nested-cond-exec |
d77de738 ML |
25908 | |
25909 | Disable nested conditional execution optimizations. | |
25910 | ||
25911 | This switch is mainly for debugging the compiler and will likely be removed | |
25912 | in a future version. | |
25913 | ||
d77de738 | 25914 | @opindex moptimize-membar |
ddf6fe37 | 25915 | @item -moptimize-membar |
d77de738 ML |
25916 | |
25917 | This switch removes redundant @code{membar} instructions from the | |
25918 | compiler-generated code. It is enabled by default. | |
25919 | ||
d77de738 ML |
25920 | @opindex mno-optimize-membar |
25921 | @opindex moptimize-membar | |
ddf6fe37 | 25922 | @item -mno-optimize-membar |
d77de738 ML |
25923 | |
25924 | This switch disables the automatic removal of redundant @code{membar} | |
25925 | instructions from the generated code. | |
25926 | ||
d77de738 | 25927 | @opindex mtomcat-stats |
ddf6fe37 | 25928 | @item -mtomcat-stats |
d77de738 ML |
25929 | |
25930 | Cause gas to print out tomcat statistics. | |
25931 | ||
d77de738 | 25932 | @opindex mcpu |
ddf6fe37 | 25933 | @item -mcpu=@var{cpu} |
d77de738 ML |
25934 | |
25935 | Select the processor type for which to generate code. Possible values are | |
25936 | @samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450}, | |
25937 | @samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}. | |
25938 | ||
25939 | @end table | |
25940 | ||
25941 | @node GNU/Linux Options | |
25942 | @subsection GNU/Linux Options | |
25943 | ||
25944 | These @samp{-m} options are defined for GNU/Linux targets: | |
25945 | ||
25946 | @table @gcctabopt | |
d77de738 | 25947 | @opindex mglibc |
ddf6fe37 | 25948 | @item -mglibc |
d77de738 ML |
25949 | Use the GNU C library. This is the default except |
25950 | on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and | |
25951 | @samp{*-*-linux-*android*} targets. | |
25952 | ||
d77de738 | 25953 | @opindex muclibc |
ddf6fe37 | 25954 | @item -muclibc |
d77de738 ML |
25955 | Use uClibc C library. This is the default on |
25956 | @samp{*-*-linux-*uclibc*} targets. | |
25957 | ||
d77de738 | 25958 | @opindex mmusl |
ddf6fe37 | 25959 | @item -mmusl |
d77de738 ML |
25960 | Use the musl C library. This is the default on |
25961 | @samp{*-*-linux-*musl*} targets. | |
25962 | ||
d77de738 | 25963 | @opindex mbionic |
ddf6fe37 | 25964 | @item -mbionic |
d77de738 ML |
25965 | Use Bionic C library. This is the default on |
25966 | @samp{*-*-linux-*android*} targets. | |
25967 | ||
d77de738 | 25968 | @opindex mandroid |
ddf6fe37 | 25969 | @item -mandroid |
d77de738 ML |
25970 | Compile code compatible with Android platform. This is the default on |
25971 | @samp{*-*-linux-*android*} targets. | |
25972 | ||
25973 | When compiling, this option enables @option{-mbionic}, @option{-fPIC}, | |
25974 | @option{-fno-exceptions} and @option{-fno-rtti} by default. When linking, | |
25975 | this option makes the GCC driver pass Android-specific options to the linker. | |
25976 | Finally, this option causes the preprocessor macro @code{__ANDROID__} | |
25977 | to be defined. | |
25978 | ||
d77de738 | 25979 | @opindex tno-android-cc |
ddf6fe37 | 25980 | @item -tno-android-cc |
d77de738 ML |
25981 | Disable compilation effects of @option{-mandroid}, i.e., do not enable |
25982 | @option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and | |
25983 | @option{-fno-rtti} by default. | |
25984 | ||
d77de738 | 25985 | @opindex tno-android-ld |
ddf6fe37 | 25986 | @item -tno-android-ld |
d77de738 ML |
25987 | Disable linking effects of @option{-mandroid}, i.e., pass standard Linux |
25988 | linking options to the linker. | |
25989 | ||
25990 | @end table | |
25991 | ||
25992 | @node H8/300 Options | |
25993 | @subsection H8/300 Options | |
25994 | ||
25995 | These @samp{-m} options are defined for the H8/300 implementations: | |
25996 | ||
25997 | @table @gcctabopt | |
d77de738 | 25998 | @opindex mrelax |
ddf6fe37 | 25999 | @item -mrelax |
d77de738 ML |
26000 | Shorten some address references at link time, when possible; uses the |
26001 | linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300, | |
26002 | ld, Using ld}, for a fuller description. | |
26003 | ||
d77de738 | 26004 | @opindex mh |
ddf6fe37 | 26005 | @item -mh |
d77de738 ML |
26006 | Generate code for the H8/300H@. |
26007 | ||
d77de738 | 26008 | @opindex ms |
ddf6fe37 | 26009 | @item -ms |
d77de738 ML |
26010 | Generate code for the H8S@. |
26011 | ||
d77de738 | 26012 | @opindex mn |
ddf6fe37 | 26013 | @item -mn |
d77de738 ML |
26014 | Generate code for the H8S and H8/300H in the normal mode. This switch |
26015 | must be used either with @option{-mh} or @option{-ms}. | |
26016 | ||
d77de738 | 26017 | @opindex ms2600 |
ddf6fe37 | 26018 | @item -ms2600 |
d77de738 ML |
26019 | Generate code for the H8S/2600. This switch must be used with @option{-ms}. |
26020 | ||
d77de738 | 26021 | @opindex mexr |
ddf6fe37 | 26022 | @item -mexr |
d77de738 ML |
26023 | Extended registers are stored on stack before execution of function |
26024 | with monitor attribute. Default option is @option{-mexr}. | |
26025 | This option is valid only for H8S targets. | |
26026 | ||
d77de738 ML |
26027 | @opindex mno-exr |
26028 | @opindex mexr | |
ddf6fe37 | 26029 | @item -mno-exr |
d77de738 ML |
26030 | Extended registers are not stored on stack before execution of function |
26031 | with monitor attribute. Default option is @option{-mno-exr}. | |
26032 | This option is valid only for H8S targets. | |
26033 | ||
d77de738 | 26034 | @opindex mint32 |
ddf6fe37 | 26035 | @item -mint32 |
d77de738 ML |
26036 | Make @code{int} data 32 bits by default. |
26037 | ||
d77de738 | 26038 | @opindex malign-300 |
ddf6fe37 | 26039 | @item -malign-300 |
d77de738 ML |
26040 | On the H8/300H and H8S, use the same alignment rules as for the H8/300. |
26041 | The default for the H8/300H and H8S is to align longs and floats on | |
26042 | 4-byte boundaries. | |
26043 | @option{-malign-300} causes them to be aligned on 2-byte boundaries. | |
26044 | This option has no effect on the H8/300. | |
26045 | @end table | |
26046 | ||
26047 | @node HPPA Options | |
26048 | @subsection HPPA Options | |
26049 | @cindex HPPA Options | |
26050 | ||
26051 | These @samp{-m} options are defined for the HPPA family of computers: | |
26052 | ||
26053 | @table @gcctabopt | |
d77de738 | 26054 | @opindex march |
ddf6fe37 | 26055 | @item -march=@var{architecture-type} |
d77de738 ML |
26056 | Generate code for the specified architecture. The choices for |
26057 | @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA | |
26058 | 1.1, and @samp{2.0} for PA 2.0 processors. Refer to | |
26059 | @file{/usr/lib/sched.models} on an HP-UX system to determine the proper | |
26060 | architecture option for your machine. Code compiled for lower numbered | |
26061 | architectures runs on higher numbered architectures, but not the | |
26062 | other way around. | |
26063 | ||
d77de738 ML |
26064 | @opindex mpa-risc-1-0 |
26065 | @opindex mpa-risc-1-1 | |
26066 | @opindex mpa-risc-2-0 | |
ddf6fe37 AA |
26067 | @item -mpa-risc-1-0 |
26068 | @itemx -mpa-risc-1-1 | |
26069 | @itemx -mpa-risc-2-0 | |
d77de738 ML |
26070 | Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively. |
26071 | ||
cf467fb9 JDA |
26072 | @opindex matomic-libcalls |
26073 | @opindex mno-atomic-libcalls | |
ddf6fe37 | 26074 | @item -matomic-libcalls |
cf467fb9 JDA |
26075 | Generate libcalls for atomic loads and stores when sync libcalls are disabled. |
26076 | This option is enabled by default. It only affects the generation of | |
26077 | atomic libcalls by the HPPA backend. | |
26078 | ||
26079 | Both the sync and @file{libatomic} libcall implementations use locking. | |
26080 | As a result, processor stores are not atomic with respect to other | |
26081 | atomic operations. Processor loads up to DImode are atomic with | |
26082 | respect to other atomic operations provided they are implemented as | |
26083 | a single access. | |
26084 | ||
26085 | The PA-RISC architecture does not support any atomic operations in | |
26086 | hardware except for the @code{ldcw} instruction. Thus, all atomic | |
26087 | support is implemented using sync and atomic libcalls. Sync libcall | |
26088 | support is in @file{libgcc.a}. Atomic libcall support is in | |
26089 | @file{libatomic}. | |
26090 | ||
26091 | This option generates @code{__atomic_exchange} calls for atomic stores. | |
26092 | It also provides special handling for atomic DImode accesses on 32-bit | |
26093 | targets. | |
26094 | ||
cf467fb9 | 26095 | @opindex mbig-switch |
ddf6fe37 | 26096 | @item -mbig-switch |
cf467fb9 JDA |
26097 | Does nothing. Preserved for backward compatibility. |
26098 | ||
d77de738 | 26099 | @opindex mcaller-copies |
ddf6fe37 | 26100 | @item -mcaller-copies |
d77de738 ML |
26101 | The caller copies function arguments passed by hidden reference. This |
26102 | option should be used with care as it is not compatible with the default | |
26103 | 32-bit runtime. However, only aggregates larger than eight bytes are | |
26104 | passed by hidden reference and the option provides better compatibility | |
26105 | with OpenMP. | |
26106 | ||
cf467fb9 | 26107 | @opindex mcoherent-ldcw |
ddf6fe37 | 26108 | @item -mcoherent-ldcw |
cf467fb9 | 26109 | Use ldcw/ldcd coherent cache-control hint. |
d77de738 | 26110 | |
d77de738 | 26111 | @opindex mdisable-fpregs |
ddf6fe37 | 26112 | @item -mdisable-fpregs |
cf467fb9 | 26113 | Disable floating-point registers. Equivalent to @code{-msoft-float}. |
d77de738 | 26114 | |
d77de738 | 26115 | @opindex mdisable-indexing |
ddf6fe37 | 26116 | @item -mdisable-indexing |
d77de738 ML |
26117 | Prevent the compiler from using indexing address modes. This avoids some |
26118 | rather obscure problems when compiling MIG generated code under MACH@. | |
26119 | ||
d77de738 | 26120 | @opindex mfast-indirect-calls |
ddf6fe37 | 26121 | @item -mfast-indirect-calls |
d77de738 ML |
26122 | Generate code that assumes calls never cross space boundaries. This |
26123 | allows GCC to emit code that performs faster indirect calls. | |
26124 | ||
26125 | This option does not work in the presence of shared libraries or nested | |
26126 | functions. | |
26127 | ||
d77de738 | 26128 | @opindex mfixed-range |
ddf6fe37 | 26129 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
26130 | Generate code treating the given register range as fixed registers. |
26131 | A fixed register is one that the register allocator cannot use. This is | |
26132 | useful when compiling kernel code. A register range is specified as | |
26133 | two registers separated by a dash. Multiple register ranges can be | |
26134 | specified separated by a comma. | |
26135 | ||
d77de738 | 26136 | @opindex mgas |
ddf6fe37 | 26137 | @item -mgas |
d77de738 ML |
26138 | Enable the use of assembler directives only GAS understands. |
26139 | ||
d77de738 | 26140 | @opindex mgnu-ld |
ddf6fe37 | 26141 | @item -mgnu-ld |
d77de738 ML |
26142 | Use options specific to GNU @command{ld}. |
26143 | This passes @option{-shared} to @command{ld} when | |
26144 | building a shared library. It is the default when GCC is configured, | |
26145 | explicitly or implicitly, with the GNU linker. This option does not | |
26146 | affect which @command{ld} is called; it only changes what parameters | |
26147 | are passed to that @command{ld}. | |
26148 | The @command{ld} that is called is determined by the | |
26149 | @option{--with-ld} configure option, GCC's program search path, and | |
26150 | finally by the user's @env{PATH}. The linker used by GCC can be printed | |
26151 | using @samp{which `gcc -print-prog-name=ld`}. This option is only available | |
26152 | on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}. | |
26153 | ||
d77de738 | 26154 | @opindex mhp-ld |
ddf6fe37 | 26155 | @item -mhp-ld |
d77de738 ML |
26156 | Use options specific to HP @command{ld}. |
26157 | This passes @option{-b} to @command{ld} when building | |
26158 | a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all | |
26159 | links. It is the default when GCC is configured, explicitly or | |
26160 | implicitly, with the HP linker. This option does not affect | |
26161 | which @command{ld} is called; it only changes what parameters are passed to that | |
26162 | @command{ld}. | |
26163 | The @command{ld} that is called is determined by the @option{--with-ld} | |
26164 | configure option, GCC's program search path, and finally by the user's | |
26165 | @env{PATH}. The linker used by GCC can be printed using @samp{which | |
26166 | `gcc -print-prog-name=ld`}. This option is only available on the 64-bit | |
26167 | HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}. | |
26168 | ||
cf467fb9 | 26169 | @opindex mlinker-opt |
ddf6fe37 | 26170 | @item -mlinker-opt |
cf467fb9 JDA |
26171 | Enable the optimization pass in the HP-UX linker. Note this makes symbolic |
26172 | debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9 | |
26173 | linkers in which they give bogus error messages when linking some programs. | |
26174 | ||
d77de738 ML |
26175 | @opindex mno-long-calls |
26176 | @opindex mlong-calls | |
ddf6fe37 | 26177 | @item -mlong-calls |
d77de738 ML |
26178 | Generate code that uses long call sequences. This ensures that a call |
26179 | is always able to reach linker generated stubs. The default is to generate | |
26180 | long calls only when the distance from the call site to the beginning | |
26181 | of the function or translation unit, as the case may be, exceeds a | |
26182 | predefined limit set by the branch type being used. The limits for | |
26183 | normal calls are 7,600,000 and 240,000 bytes, respectively for the | |
26184 | PA 2.0 and PA 1.X architectures. Sibcalls are always limited at | |
26185 | 240,000 bytes. | |
26186 | ||
26187 | Distances are measured from the beginning of functions when using the | |
26188 | @option{-ffunction-sections} option, or when using the @option{-mgas} | |
26189 | and @option{-mno-portable-runtime} options together under HP-UX with | |
26190 | the SOM linker. | |
26191 | ||
26192 | It is normally not desirable to use this option as it degrades | |
26193 | performance. However, it may be useful in large applications, | |
26194 | particularly when partial linking is used to build the application. | |
26195 | ||
26196 | The types of long calls used depends on the capabilities of the | |
26197 | assembler and linker, and the type of code being generated. The | |
26198 | impact on systems that support long absolute calls, and long pic | |
26199 | symbol-difference or pc-relative calls should be relatively small. | |
26200 | However, an indirect call is used on 32-bit ELF systems in pic code | |
26201 | and it is quite long. | |
26202 | ||
cf467fb9 | 26203 | @opindex mlong-load-store |
ddf6fe37 | 26204 | @item -mlong-load-store |
cf467fb9 JDA |
26205 | Generate 3-instruction load and store sequences as sometimes required by |
26206 | the HP-UX 10 linker. This is equivalent to the @samp{+k} option to | |
26207 | the HP compilers. | |
26208 | ||
cf467fb9 | 26209 | @opindex mjump-in-delay |
ddf6fe37 | 26210 | @item -mjump-in-delay |
cf467fb9 JDA |
26211 | This option is ignored and provided for compatibility purposes only. |
26212 | ||
cf467fb9 JDA |
26213 | @opindex mno-space-regs |
26214 | @opindex mspace-regs | |
ddf6fe37 | 26215 | @item -mno-space-regs |
cf467fb9 JDA |
26216 | Generate code that assumes the target has no space registers. This allows |
26217 | GCC to generate faster indirect calls and use unscaled index address modes. | |
26218 | ||
26219 | Such code is suitable for level 0 PA systems and kernels. | |
26220 | ||
cf467fb9 | 26221 | @opindex mordered |
ddf6fe37 | 26222 | @item -mordered |
cf467fb9 JDA |
26223 | Assume memory references are ordered and barriers are not needed. |
26224 | ||
cf467fb9 | 26225 | @opindex mportable-runtime |
ddf6fe37 | 26226 | @item -mportable-runtime |
cf467fb9 JDA |
26227 | Use the portable calling conventions proposed by HP for ELF systems. |
26228 | ||
cf467fb9 | 26229 | @opindex mschedule |
ddf6fe37 | 26230 | @item -mschedule=@var{cpu-type} |
cf467fb9 JDA |
26231 | Schedule code according to the constraints for the machine type |
26232 | @var{cpu-type}. The choices for @var{cpu-type} are @samp{700} | |
26233 | @samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer | |
26234 | to @file{/usr/lib/sched.models} on an HP-UX system to determine the | |
26235 | proper scheduling option for your machine. The default scheduling is | |
26236 | @samp{8000}. | |
26237 | ||
cf467fb9 | 26238 | @opindex msio |
ddf6fe37 | 26239 | @item -msio |
cf467fb9 JDA |
26240 | Generate the predefine, @code{_SIO}, for server IO@. The default is |
26241 | @option{-mwsio}. This generates the predefines, @code{__hp9000s700}, | |
26242 | @code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These | |
26243 | options are available under HP-UX and HI-UX@. | |
26244 | ||
cf467fb9 | 26245 | @opindex msoft-float |
ddf6fe37 | 26246 | @item -msoft-float |
cf467fb9 JDA |
26247 | Generate output containing library calls for floating point. |
26248 | @strong{Warning:} the requisite libraries are not available for all HPPA | |
26249 | targets. Normally the facilities of the machine's usual C compiler are | |
26250 | used, but this cannot be done directly in cross-compilation. You must make | |
26251 | your own arrangements to provide suitable library functions for | |
26252 | cross-compilation. | |
26253 | ||
26254 | @option{-msoft-float} changes the calling convention in the output file; | |
26255 | therefore, it is only useful if you compile @emph{all} of a program with | |
26256 | this option. In particular, you need to compile @file{libgcc.a}, the | |
26257 | library that comes with GCC, with @option{-msoft-float} in order for | |
26258 | this to work. | |
26259 | ||
cf467fb9 | 26260 | @opindex msoft-mult |
ddf6fe37 | 26261 | @item -msoft-mult |
cf467fb9 JDA |
26262 | Use software integer multiplication. |
26263 | ||
26264 | This disables the use of the @code{xmpyu} instruction. | |
26265 | ||
d77de738 | 26266 | @opindex march |
ddf6fe37 | 26267 | @item -munix=@var{unix-std} |
d77de738 ML |
26268 | Generate compiler predefines and select a startfile for the specified |
26269 | UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95} | |
26270 | and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95} | |
26271 | is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX | |
26272 | 11.11 and later. The default values are @samp{93} for HP-UX 10.00, | |
26273 | @samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11 | |
26274 | and later. | |
26275 | ||
26276 | @option{-munix=93} provides the same predefines as GCC 3.3 and 3.4. | |
26277 | @option{-munix=95} provides additional predefines for @code{XOPEN_UNIX} | |
26278 | and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}. | |
26279 | @option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX}, | |
26280 | @code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and | |
26281 | @code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}. | |
26282 | ||
26283 | It is @emph{important} to note that this option changes the interfaces | |
26284 | for various library routines. It also affects the operational behavior | |
26285 | of the C library. Thus, @emph{extreme} care is needed in using this | |
26286 | option. | |
26287 | ||
26288 | Library code that is intended to operate with more than one UNIX | |
26289 | standard must test, set and restore the variable @code{__xpg4_extended_mask} | |
26290 | as appropriate. Most GNU software doesn't provide this capability. | |
26291 | ||
d77de738 | 26292 | @opindex nolibdld |
ddf6fe37 | 26293 | @item -nolibdld |
d77de738 ML |
26294 | Suppress the generation of link options to search libdld.sl when the |
26295 | @option{-static} option is specified on HP-UX 10 and later. | |
26296 | ||
d77de738 | 26297 | @opindex static |
ddf6fe37 | 26298 | @item -static |
d77de738 ML |
26299 | The HP-UX implementation of setlocale in libc has a dependency on |
26300 | libdld.sl. There isn't an archive version of libdld.sl. Thus, | |
26301 | when the @option{-static} option is specified, special link options | |
26302 | are needed to resolve this dependency. | |
26303 | ||
26304 | On HP-UX 10 and later, the GCC driver adds the necessary options to | |
26305 | link with libdld.sl when the @option{-static} option is specified. | |
26306 | This causes the resulting binary to be dynamic. On the 64-bit port, | |
26307 | the linkers generate dynamic binaries by default in any case. The | |
26308 | @option{-nolibdld} option can be used to prevent the GCC driver from | |
26309 | adding these link options. | |
26310 | ||
d77de738 | 26311 | @opindex threads |
ddf6fe37 | 26312 | @item -threads |
d77de738 ML |
26313 | Add support for multithreading with the @dfn{dce thread} library |
26314 | under HP-UX@. This option sets flags for both the preprocessor and | |
26315 | linker. | |
26316 | @end table | |
26317 | ||
26318 | @node IA-64 Options | |
26319 | @subsection IA-64 Options | |
26320 | @cindex IA-64 Options | |
26321 | ||
26322 | These are the @samp{-m} options defined for the Intel IA-64 architecture. | |
26323 | ||
26324 | @table @gcctabopt | |
d77de738 | 26325 | @opindex mbig-endian |
ddf6fe37 | 26326 | @item -mbig-endian |
d77de738 ML |
26327 | Generate code for a big-endian target. This is the default for HP-UX@. |
26328 | ||
d77de738 | 26329 | @opindex mlittle-endian |
ddf6fe37 | 26330 | @item -mlittle-endian |
d77de738 ML |
26331 | Generate code for a little-endian target. This is the default for AIX5 |
26332 | and GNU/Linux. | |
26333 | ||
d77de738 ML |
26334 | @opindex mgnu-as |
26335 | @opindex mno-gnu-as | |
ddf6fe37 AA |
26336 | @item -mgnu-as |
26337 | @itemx -mno-gnu-as | |
d77de738 ML |
26338 | Generate (or don't) code for the GNU assembler. This is the default. |
26339 | @c Also, this is the default if the configure option @option{--with-gnu-as} | |
26340 | @c is used. | |
26341 | ||
d77de738 ML |
26342 | @opindex mgnu-ld |
26343 | @opindex mno-gnu-ld | |
ddf6fe37 AA |
26344 | @item -mgnu-ld |
26345 | @itemx -mno-gnu-ld | |
d77de738 ML |
26346 | Generate (or don't) code for the GNU linker. This is the default. |
26347 | @c Also, this is the default if the configure option @option{--with-gnu-ld} | |
26348 | @c is used. | |
26349 | ||
d77de738 | 26350 | @opindex mno-pic |
ddf6fe37 | 26351 | @item -mno-pic |
d77de738 ML |
26352 | Generate code that does not use a global pointer register. The result |
26353 | is not position independent code, and violates the IA-64 ABI@. | |
26354 | ||
d77de738 ML |
26355 | @opindex mvolatile-asm-stop |
26356 | @opindex mno-volatile-asm-stop | |
ddf6fe37 AA |
26357 | @item -mvolatile-asm-stop |
26358 | @itemx -mno-volatile-asm-stop | |
d77de738 ML |
26359 | Generate (or don't) a stop bit immediately before and after volatile asm |
26360 | statements. | |
26361 | ||
d77de738 ML |
26362 | @opindex mregister-names |
26363 | @opindex mno-register-names | |
ddf6fe37 AA |
26364 | @item -mregister-names |
26365 | @itemx -mno-register-names | |
d77de738 ML |
26366 | Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for |
26367 | the stacked registers. This may make assembler output more readable. | |
26368 | ||
d77de738 ML |
26369 | @opindex mno-sdata |
26370 | @opindex msdata | |
ddf6fe37 AA |
26371 | @item -mno-sdata |
26372 | @itemx -msdata | |
d77de738 ML |
26373 | Disable (or enable) optimizations that use the small data section. This may |
26374 | be useful for working around optimizer bugs. | |
26375 | ||
d77de738 | 26376 | @opindex mconstant-gp |
ddf6fe37 | 26377 | @item -mconstant-gp |
d77de738 ML |
26378 | Generate code that uses a single constant global pointer value. This is |
26379 | useful when compiling kernel code. | |
26380 | ||
d77de738 | 26381 | @opindex mauto-pic |
ddf6fe37 | 26382 | @item -mauto-pic |
d77de738 ML |
26383 | Generate code that is self-relocatable. This implies @option{-mconstant-gp}. |
26384 | This is useful when compiling firmware code. | |
26385 | ||
d77de738 | 26386 | @opindex minline-float-divide-min-latency |
ddf6fe37 | 26387 | @item -minline-float-divide-min-latency |
d77de738 ML |
26388 | Generate code for inline divides of floating-point values |
26389 | using the minimum latency algorithm. | |
26390 | ||
d77de738 | 26391 | @opindex minline-float-divide-max-throughput |
ddf6fe37 | 26392 | @item -minline-float-divide-max-throughput |
d77de738 ML |
26393 | Generate code for inline divides of floating-point values |
26394 | using the maximum throughput algorithm. | |
26395 | ||
d77de738 | 26396 | @opindex mno-inline-float-divide |
ddf6fe37 | 26397 | @item -mno-inline-float-divide |
d77de738 ML |
26398 | Do not generate inline code for divides of floating-point values. |
26399 | ||
d77de738 | 26400 | @opindex minline-int-divide-min-latency |
ddf6fe37 | 26401 | @item -minline-int-divide-min-latency |
d77de738 ML |
26402 | Generate code for inline divides of integer values |
26403 | using the minimum latency algorithm. | |
26404 | ||
d77de738 | 26405 | @opindex minline-int-divide-max-throughput |
ddf6fe37 | 26406 | @item -minline-int-divide-max-throughput |
d77de738 ML |
26407 | Generate code for inline divides of integer values |
26408 | using the maximum throughput algorithm. | |
26409 | ||
d77de738 ML |
26410 | @opindex mno-inline-int-divide |
26411 | @opindex minline-int-divide | |
ddf6fe37 | 26412 | @item -mno-inline-int-divide |
d77de738 ML |
26413 | Do not generate inline code for divides of integer values. |
26414 | ||
d77de738 | 26415 | @opindex minline-sqrt-min-latency |
ddf6fe37 | 26416 | @item -minline-sqrt-min-latency |
d77de738 ML |
26417 | Generate code for inline square roots |
26418 | using the minimum latency algorithm. | |
26419 | ||
d77de738 | 26420 | @opindex minline-sqrt-max-throughput |
ddf6fe37 | 26421 | @item -minline-sqrt-max-throughput |
d77de738 ML |
26422 | Generate code for inline square roots |
26423 | using the maximum throughput algorithm. | |
26424 | ||
d77de738 | 26425 | @opindex mno-inline-sqrt |
ddf6fe37 | 26426 | @item -mno-inline-sqrt |
d77de738 ML |
26427 | Do not generate inline code for @code{sqrt}. |
26428 | ||
d77de738 ML |
26429 | @opindex mfused-madd |
26430 | @opindex mno-fused-madd | |
ddf6fe37 AA |
26431 | @item -mfused-madd |
26432 | @itemx -mno-fused-madd | |
d77de738 ML |
26433 | Do (don't) generate code that uses the fused multiply/add or multiply/subtract |
26434 | instructions. The default is to use these instructions. | |
26435 | ||
d77de738 ML |
26436 | @opindex mno-dwarf2-asm |
26437 | @opindex mdwarf2-asm | |
ddf6fe37 AA |
26438 | @item -mno-dwarf2-asm |
26439 | @itemx -mdwarf2-asm | |
d77de738 ML |
26440 | Don't (or do) generate assembler code for the DWARF line number debugging |
26441 | info. This may be useful when not using the GNU assembler. | |
26442 | ||
d77de738 ML |
26443 | @opindex mearly-stop-bits |
26444 | @opindex mno-early-stop-bits | |
ddf6fe37 AA |
26445 | @item -mearly-stop-bits |
26446 | @itemx -mno-early-stop-bits | |
d77de738 ML |
26447 | Allow stop bits to be placed earlier than immediately preceding the |
26448 | instruction that triggered the stop bit. This can improve instruction | |
26449 | scheduling, but does not always do so. | |
26450 | ||
d77de738 | 26451 | @opindex mfixed-range |
ddf6fe37 | 26452 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
26453 | Generate code treating the given register range as fixed registers. |
26454 | A fixed register is one that the register allocator cannot use. This is | |
26455 | useful when compiling kernel code. A register range is specified as | |
26456 | two registers separated by a dash. Multiple register ranges can be | |
26457 | specified separated by a comma. | |
26458 | ||
d77de738 | 26459 | @opindex mtls-size |
ddf6fe37 | 26460 | @item -mtls-size=@var{tls-size} |
d77de738 ML |
26461 | Specify bit size of immediate TLS offsets. Valid values are 14, 22, and |
26462 | 64. | |
26463 | ||
d77de738 | 26464 | @opindex mtune |
ddf6fe37 | 26465 | @item -mtune=@var{cpu-type} |
d77de738 ML |
26466 | Tune the instruction scheduling for a particular CPU, Valid values are |
26467 | @samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2}, | |
26468 | and @samp{mckinley}. | |
26469 | ||
d77de738 ML |
26470 | @opindex milp32 |
26471 | @opindex mlp64 | |
ddf6fe37 AA |
26472 | @item -milp32 |
26473 | @itemx -mlp64 | |
d77de738 ML |
26474 | Generate code for a 32-bit or 64-bit environment. |
26475 | The 32-bit environment sets int, long and pointer to 32 bits. | |
26476 | The 64-bit environment sets int to 32 bits and long and pointer | |
26477 | to 64 bits. These are HP-UX specific flags. | |
26478 | ||
d77de738 ML |
26479 | @opindex mno-sched-br-data-spec |
26480 | @opindex msched-br-data-spec | |
ddf6fe37 AA |
26481 | @item -mno-sched-br-data-spec |
26482 | @itemx -msched-br-data-spec | |
d77de738 ML |
26483 | (Dis/En)able data speculative scheduling before reload. |
26484 | This results in generation of @code{ld.a} instructions and | |
26485 | the corresponding check instructions (@code{ld.c} / @code{chk.a}). | |
26486 | The default setting is disabled. | |
26487 | ||
d77de738 ML |
26488 | @opindex msched-ar-data-spec |
26489 | @opindex mno-sched-ar-data-spec | |
ddf6fe37 AA |
26490 | @item -msched-ar-data-spec |
26491 | @itemx -mno-sched-ar-data-spec | |
d77de738 ML |
26492 | (En/Dis)able data speculative scheduling after reload. |
26493 | This results in generation of @code{ld.a} instructions and | |
26494 | the corresponding check instructions (@code{ld.c} / @code{chk.a}). | |
26495 | The default setting is enabled. | |
26496 | ||
d77de738 ML |
26497 | @opindex mno-sched-control-spec |
26498 | @opindex msched-control-spec | |
ddf6fe37 AA |
26499 | @item -mno-sched-control-spec |
26500 | @itemx -msched-control-spec | |
d77de738 ML |
26501 | (Dis/En)able control speculative scheduling. This feature is |
26502 | available only during region scheduling (i.e.@: before reload). | |
26503 | This results in generation of the @code{ld.s} instructions and | |
26504 | the corresponding check instructions @code{chk.s}. | |
26505 | The default setting is disabled. | |
26506 | ||
d77de738 ML |
26507 | @opindex msched-br-in-data-spec |
26508 | @opindex mno-sched-br-in-data-spec | |
ddf6fe37 AA |
26509 | @item -msched-br-in-data-spec |
26510 | @itemx -mno-sched-br-in-data-spec | |
d77de738 ML |
26511 | (En/Dis)able speculative scheduling of the instructions that |
26512 | are dependent on the data speculative loads before reload. | |
26513 | This is effective only with @option{-msched-br-data-spec} enabled. | |
26514 | The default setting is enabled. | |
26515 | ||
d77de738 ML |
26516 | @opindex msched-ar-in-data-spec |
26517 | @opindex mno-sched-ar-in-data-spec | |
ddf6fe37 AA |
26518 | @item -msched-ar-in-data-spec |
26519 | @itemx -mno-sched-ar-in-data-spec | |
d77de738 ML |
26520 | (En/Dis)able speculative scheduling of the instructions that |
26521 | are dependent on the data speculative loads after reload. | |
26522 | This is effective only with @option{-msched-ar-data-spec} enabled. | |
26523 | The default setting is enabled. | |
26524 | ||
d77de738 ML |
26525 | @opindex msched-in-control-spec |
26526 | @opindex mno-sched-in-control-spec | |
ddf6fe37 AA |
26527 | @item -msched-in-control-spec |
26528 | @itemx -mno-sched-in-control-spec | |
d77de738 ML |
26529 | (En/Dis)able speculative scheduling of the instructions that |
26530 | are dependent on the control speculative loads. | |
26531 | This is effective only with @option{-msched-control-spec} enabled. | |
26532 | The default setting is enabled. | |
26533 | ||
d77de738 ML |
26534 | @opindex mno-sched-prefer-non-data-spec-insns |
26535 | @opindex msched-prefer-non-data-spec-insns | |
ddf6fe37 AA |
26536 | @item -mno-sched-prefer-non-data-spec-insns |
26537 | @itemx -msched-prefer-non-data-spec-insns | |
d77de738 ML |
26538 | If enabled, data-speculative instructions are chosen for schedule |
26539 | only if there are no other choices at the moment. This makes | |
26540 | the use of the data speculation much more conservative. | |
26541 | The default setting is disabled. | |
26542 | ||
d77de738 ML |
26543 | @opindex mno-sched-prefer-non-control-spec-insns |
26544 | @opindex msched-prefer-non-control-spec-insns | |
ddf6fe37 AA |
26545 | @item -mno-sched-prefer-non-control-spec-insns |
26546 | @itemx -msched-prefer-non-control-spec-insns | |
d77de738 ML |
26547 | If enabled, control-speculative instructions are chosen for schedule |
26548 | only if there are no other choices at the moment. This makes | |
26549 | the use of the control speculation much more conservative. | |
26550 | The default setting is disabled. | |
26551 | ||
d77de738 ML |
26552 | @opindex mno-sched-count-spec-in-critical-path |
26553 | @opindex msched-count-spec-in-critical-path | |
ddf6fe37 AA |
26554 | @item -mno-sched-count-spec-in-critical-path |
26555 | @itemx -msched-count-spec-in-critical-path | |
d77de738 ML |
26556 | If enabled, speculative dependencies are considered during |
26557 | computation of the instructions priorities. This makes the use of the | |
26558 | speculation a bit more conservative. | |
26559 | The default setting is disabled. | |
26560 | ||
d77de738 | 26561 | @opindex msched-spec-ldc |
ddf6fe37 | 26562 | @item -msched-spec-ldc |
d77de738 ML |
26563 | Use a simple data speculation check. This option is on by default. |
26564 | ||
d77de738 | 26565 | @opindex msched-spec-ldc |
ddf6fe37 | 26566 | @item -msched-control-spec-ldc |
d77de738 ML |
26567 | Use a simple check for control speculation. This option is on by default. |
26568 | ||
d77de738 | 26569 | @opindex msched-stop-bits-after-every-cycle |
ddf6fe37 | 26570 | @item -msched-stop-bits-after-every-cycle |
d77de738 ML |
26571 | Place a stop bit after every cycle when scheduling. This option is on |
26572 | by default. | |
26573 | ||
d77de738 | 26574 | @opindex msched-fp-mem-deps-zero-cost |
ddf6fe37 | 26575 | @item -msched-fp-mem-deps-zero-cost |
d77de738 ML |
26576 | Assume that floating-point stores and loads are not likely to cause a conflict |
26577 | when placed into the same instruction group. This option is disabled by | |
26578 | default. | |
26579 | ||
d77de738 | 26580 | @opindex msel-sched-dont-check-control-spec |
ddf6fe37 | 26581 | @item -msel-sched-dont-check-control-spec |
d77de738 ML |
26582 | Generate checks for control speculation in selective scheduling. |
26583 | This flag is disabled by default. | |
26584 | ||
d77de738 | 26585 | @opindex msched-max-memory-insns |
ddf6fe37 | 26586 | @item -msched-max-memory-insns=@var{max-insns} |
d77de738 ML |
26587 | Limit on the number of memory insns per instruction group, giving lower |
26588 | priority to subsequent memory insns attempting to schedule in the same | |
26589 | instruction group. Frequently useful to prevent cache bank conflicts. | |
26590 | The default value is 1. | |
26591 | ||
d77de738 | 26592 | @opindex msched-max-memory-insns-hard-limit |
ddf6fe37 | 26593 | @item -msched-max-memory-insns-hard-limit |
d77de738 ML |
26594 | Makes the limit specified by @option{msched-max-memory-insns} a hard limit, |
26595 | disallowing more than that number in an instruction group. | |
26596 | Otherwise, the limit is ``soft'', meaning that non-memory operations | |
26597 | are preferred when the limit is reached, but memory operations may still | |
26598 | be scheduled. | |
26599 | ||
26600 | @end table | |
26601 | ||
26602 | @node LM32 Options | |
26603 | @subsection LM32 Options | |
26604 | @cindex LM32 options | |
26605 | ||
26606 | These @option{-m} options are defined for the LatticeMico32 architecture: | |
26607 | ||
26608 | @table @gcctabopt | |
d77de738 | 26609 | @opindex mbarrel-shift-enabled |
ddf6fe37 | 26610 | @item -mbarrel-shift-enabled |
d77de738 ML |
26611 | Enable barrel-shift instructions. |
26612 | ||
d77de738 | 26613 | @opindex mdivide-enabled |
ddf6fe37 | 26614 | @item -mdivide-enabled |
d77de738 ML |
26615 | Enable divide and modulus instructions. |
26616 | ||
d77de738 | 26617 | @opindex multiply-enabled |
ddf6fe37 | 26618 | @item -mmultiply-enabled |
d77de738 ML |
26619 | Enable multiply instructions. |
26620 | ||
d77de738 | 26621 | @opindex msign-extend-enabled |
ddf6fe37 | 26622 | @item -msign-extend-enabled |
d77de738 ML |
26623 | Enable sign extend instructions. |
26624 | ||
d77de738 | 26625 | @opindex muser-enabled |
ddf6fe37 | 26626 | @item -muser-enabled |
d77de738 ML |
26627 | Enable user-defined instructions. |
26628 | ||
26629 | @end table | |
26630 | ||
26631 | @node LoongArch Options | |
26632 | @subsection LoongArch Options | |
26633 | @cindex LoongArch Options | |
26634 | ||
26635 | These command-line options are defined for LoongArch targets: | |
26636 | ||
26637 | @table @gcctabopt | |
9c19597c | 26638 | @opindex march |
ddf6fe37 | 26639 | @item -march=@var{cpu-type} |
d77de738 ML |
26640 | Generate instructions for the machine type @var{cpu-type}. In contrast to |
26641 | @option{-mtune=@var{cpu-type}}, which merely tunes the generated code | |
26642 | for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC | |
26643 | to generate code that may not run at all on processors other than the one | |
26644 | indicated. Specifying @option{-march=@var{cpu-type}} implies | |
26645 | @option{-mtune=@var{cpu-type}}, except where noted otherwise. | |
26646 | ||
26647 | The choices for @var{cpu-type} are: | |
26648 | ||
26649 | @table @samp | |
26650 | @item native | |
26651 | This selects the CPU to generate code for at compilation time by determining | |
26652 | the processor type of the compiling machine. Using @option{-march=native} | |
26653 | enables all instruction subsets supported by the local machine (hence | |
26654 | the result might not run on different machines). Using @option{-mtune=native} | |
26655 | produces code optimized for the local machine under the constraints | |
26656 | of the selected instruction set. | |
26657 | @item loongarch64 | |
26658 | A generic CPU with 64-bit extensions. | |
26659 | @item la464 | |
26660 | LoongArch LA464 CPU with LBT, LSX, LASX, LVZ. | |
26661 | @end table | |
26662 | ||
d77de738 | 26663 | @opindex mtune |
ddf6fe37 | 26664 | @item -mtune=@var{cpu-type} |
d77de738 ML |
26665 | Optimize the output for the given processor, specified by microarchitecture |
26666 | name. | |
26667 | ||
d77de738 | 26668 | @opindex mabi |
ddf6fe37 | 26669 | @item -mabi=@var{base-abi-type} |
d77de738 ML |
26670 | Generate code for the specified calling convention. |
26671 | @var{base-abi-type} can be one of: | |
26672 | @table @samp | |
26673 | @item lp64d | |
26674 | Uses 64-bit general purpose registers and 32/64-bit floating-point | |
26675 | registers for parameter passing. Data model is LP64, where @samp{int} | |
26676 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
26677 | @item lp64f | |
26678 | Uses 64-bit general purpose registers and 32-bit floating-point | |
26679 | registers for parameter passing. Data model is LP64, where @samp{int} | |
26680 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
26681 | @item lp64s | |
26682 | Uses 64-bit general purpose registers and no floating-point | |
26683 | registers for parameter passing. Data model is LP64, where @samp{int} | |
26684 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
26685 | @end table | |
26686 | ||
d77de738 | 26687 | @opindex mfpu |
ddf6fe37 | 26688 | @item -mfpu=@var{fpu-type} |
d77de738 ML |
26689 | Generate code for the specified FPU type, which can be one of: |
26690 | @table @samp | |
26691 | @item 64 | |
26692 | Allow the use of hardware floating-point instructions for 32-bit | |
26693 | and 64-bit operations. | |
26694 | @item 32 | |
26695 | Allow the use of hardware floating-point instructions for 32-bit | |
26696 | operations. | |
26697 | @item none | |
26698 | @item 0 | |
26699 | Prevent the use of hardware floating-point instructions. | |
26700 | @end table | |
26701 | ||
bb4a8198 YY |
26702 | @opindex msimd |
26703 | @item -msimd=@var{simd-type} | |
26704 | Enable generation of LoongArch SIMD instructions for vectorization | |
26705 | and via builtin functions. The value can be one of: | |
26706 | @table @samp | |
26707 | @item lasx | |
26708 | Enable generating instructions from the 256-bit LoongArch Advanced | |
26709 | SIMD Extension (LASX) and the 128-bit LoongArch SIMD Extension (LSX). | |
26710 | @item lsx | |
26711 | Enable generating instructions from the 128-bit LoongArch SIMD | |
26712 | Extension (LSX). | |
26713 | @item none | |
26714 | No LoongArch SIMD instruction may be generated. | |
26715 | @end table | |
26716 | ||
d77de738 | 26717 | @opindex msoft-float |
ddf6fe37 | 26718 | @item -msoft-float |
d77de738 ML |
26719 | Force @option{-mfpu=none} and prevents the use of floating-point |
26720 | registers for parameter passing. This option may change the target | |
26721 | ABI. | |
26722 | ||
9c19597c | 26723 | @opindex msingle-float |
ddf6fe37 | 26724 | @item -msingle-float |
d77de738 ML |
26725 | Force @option{-mfpu=32} and allow the use of 32-bit floating-point |
26726 | registers for parameter passing. This option may change the target | |
26727 | ABI. | |
26728 | ||
9c19597c | 26729 | @opindex mdouble-float |
ddf6fe37 | 26730 | @item -mdouble-float |
d77de738 ML |
26731 | Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point |
26732 | registers for parameter passing. This option may change the target | |
26733 | ABI. | |
26734 | ||
bb4a8198 YY |
26735 | @opindex ml[a]sx |
26736 | @item -mlasx | |
26737 | @itemx -mno-lasx | |
26738 | @item -mlsx | |
26739 | @itemx -mno-lsx | |
26740 | Incrementally adjust the scope of the SIMD extensions (none / LSX / LASX) | |
26741 | that can be used by the compiler for code generation. Enabling LASX with | |
26742 | @option{mlasx} automatically enables LSX, and diabling LSX with @option{mno-lsx} | |
26743 | automatically disables LASX. These driver-only options act upon the final | |
26744 | @option{msimd} configuration state and make incremental chagnes in the order | |
26745 | they appear on the GCC driver's command line, deriving the final / canonicalized | |
26746 | @option{msimd} option that is passed to the compiler proper. | |
26747 | ||
9c19597c | 26748 | @opindex mbranch-cost |
ddf6fe37 | 26749 | @item -mbranch-cost=@var{n} |
d77de738 ML |
26750 | Set the cost of branches to roughly @var{n} instructions. |
26751 | ||
ddf6fe37 | 26752 | @opindex mcheck-zero-division |
d77de738 ML |
26753 | @item -mcheck-zero-division |
26754 | @itemx -mno-check-zero-divison | |
d77de738 ML |
26755 | Trap (do not trap) on integer division by zero. The default is |
26756 | @option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and | |
26757 | @option{-mno-check-zero-division} for other optimization levels. | |
26758 | ||
ddf6fe37 | 26759 | @opindex mcond-move-int |
d77de738 ML |
26760 | @item -mcond-move-int |
26761 | @itemx -mno-cond-move-int | |
d77de738 ML |
26762 | Conditional moves for integral data in general-purpose registers |
26763 | are enabled (disabled). The default is @option{-mcond-move-int}. | |
26764 | ||
ddf6fe37 | 26765 | @opindex mcond-move-float |
d77de738 ML |
26766 | @item -mcond-move-float |
26767 | @itemx -mno-cond-move-float | |
d77de738 ML |
26768 | Conditional moves for floating-point registers are enabled (disabled). |
26769 | The default is @option{-mcond-move-float}. | |
26770 | ||
ddf6fe37 | 26771 | @opindex mmemcpy |
d77de738 ML |
26772 | @item -mmemcpy |
26773 | @itemx -mno-memcpy | |
d77de738 ML |
26774 | Force (do not force) the use of @code{memcpy} for non-trivial block moves. |
26775 | The default is @option{-mno-memcpy}, which allows GCC to inline most | |
26776 | constant-sized copies. Setting optimization level to @option{-Os} also | |
26777 | forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this | |
26778 | behavior if explicitly specified, regardless of the order these options on | |
26779 | the command line. | |
26780 | ||
ddf6fe37 | 26781 | @opindex mstrict-align |
d77de738 ML |
26782 | @item -mstrict-align |
26783 | @itemx -mno-strict-align | |
d77de738 ML |
26784 | Avoid or allow generating memory accesses that may not be aligned on a natural |
26785 | object boundary as described in the architecture specification. The default is | |
26786 | @option{-mno-strict-align}. | |
26787 | ||
9c19597c | 26788 | @opindex msmall-data-limit |
ddf6fe37 | 26789 | @item -msmall-data-limit=@var{number} |
d77de738 ML |
26790 | Put global and static data smaller than @var{number} bytes into a special |
26791 | section (on some targets). The default value is 0. | |
26792 | ||
9c19597c | 26793 | @opindex mmax-inline-memcpy-size |
ddf6fe37 | 26794 | @item -mmax-inline-memcpy-size=@var{n} |
d77de738 ML |
26795 | Inline all block moves (such as calls to @code{memcpy} or structure copies) |
26796 | less than or equal to @var{n} bytes. The default value of @var{n} is 1024. | |
26797 | ||
26798 | @item -mcmodel=@var{code-model} | |
26799 | Set the code model to one of: | |
26800 | @table @samp | |
26801 | @item tiny-static (Not implemented yet) | |
26802 | @item tiny (Not implemented yet) | |
26803 | ||
26804 | @item normal | |
26805 | The text segment must be within 128MB addressing space. The data segment must | |
26806 | be within 2GB addressing space. | |
26807 | ||
26808 | @item medium | |
26809 | The text segment and data segment must be within 2GB addressing space. | |
26810 | ||
26811 | @item large (Not implemented yet) | |
26812 | ||
26813 | @item extreme | |
26814 | This mode does not limit the size of the code segment and data segment. | |
8c8b40e1 XR |
26815 | The @option{-mcmodel=extreme} option is incompatible with @option{-fplt} |
26816 | and/or @option{-mexplicit-relocs=none}. | |
d77de738 ML |
26817 | @end table |
26818 | The default code model is @code{normal}. | |
26819 | ||
e1b1cba1 XR |
26820 | @item -mexplicit-relocs=@var{style} |
26821 | Set when to use assembler relocation operators when dealing with symbolic | |
d77de738 | 26822 | addresses. The alternative is to use assembler macros instead, which may |
e1b1cba1 XR |
26823 | limit instruction scheduling but allow linker relaxation. |
26824 | with @option{-mexplicit-relocs=none} the assembler macros are always used, | |
26825 | with @option{-mexplicit-relocs=always} the assembler relocation operators | |
26826 | are always used, with @option{-mexplicit-relocs=auto} the compiler will | |
26827 | use the relocation operators where the linker relaxation is impossible to | |
26828 | improve the code quality, and macros elsewhere. The default | |
fe23a2ff XR |
26829 | value for the option is determined with the assembler capability detected |
26830 | during GCC build-time and the setting of @option{-mrelax}: | |
e1b1cba1 XR |
26831 | @option{-mexplicit-relocs=none} if the assembler does not support |
26832 | relocation operators at all, | |
26833 | @option{-mexplicit-relocs=always} if the assembler supports relocation | |
fe23a2ff XR |
26834 | operators but @option{-mrelax} is not enabled, |
26835 | @option{-mexplicit-relocs=auto} if the assembler supports relocation | |
26836 | operators and @option{-mrelax} is enabled. | |
d77de738 | 26837 | |
e1b1cba1 XR |
26838 | @opindex mexplicit-relocs |
26839 | @item -mexplicit-relocs | |
26840 | An alias of @option{-mexplicit-relocs=always} for backward compatibility. | |
26841 | ||
26842 | @opindex mno-explicit-relocs | |
26843 | @item -mno-explicit-relocs | |
26844 | An alias of @option{-mexplicit-relocs=none} for backward compatibility. | |
26845 | ||
ddf6fe37 | 26846 | @opindex mdirect-extern-access |
d77de738 ML |
26847 | @item -mdirect-extern-access |
26848 | @itemx -mno-direct-extern-access | |
d77de738 ML |
26849 | Do not use or use GOT to access external symbols. The default is |
26850 | @option{-mno-direct-extern-access}: GOT is used for external symbols with | |
26851 | default visibility, but not used for other external symbols. | |
26852 | ||
26853 | With @option{-mdirect-extern-access}, GOT is not used and all external | |
26854 | symbols are PC-relatively addressed. It is @strong{only} suitable for | |
26855 | environments where no dynamic link is performed, like firmwares, OS | |
26856 | kernels, executables linked with @option{-static} or @option{-static-pie}. | |
26857 | @option{-mdirect-extern-access} is not compatible with @option{-fPIC} or | |
26858 | @option{-fpic}. | |
8f4bbdc2 | 26859 | |
fe23a2ff XR |
26860 | @item -mrelax |
26861 | @itemx -mno-relax | |
26862 | Take (do not take) advantage of linker relaxations. If | |
26863 | @option{-mpass-mrelax-to-as} is enabled, this option is also passed to | |
26864 | the assembler. The default is determined during GCC build-time by | |
26865 | detecting corresponding assembler support: | |
26866 | @option{-mrelax} if the assembler supports both the @option{-mrelax} | |
26867 | option and the conditional branch relaxation (it's required or the | |
26868 | @code{.align} directives and conditional branch instructions in the | |
26869 | assembly code outputted by GCC may be rejected by the assembler because | |
26870 | of a relocation overflow), @option{-mno-relax} otherwise. | |
26871 | ||
26872 | @item -mpass-mrelax-to-as | |
26873 | @itemx -mno-pass-mrelax-to-as | |
26874 | Pass (do not pass) the @option{-mrelax} or @option{-mno-relax} option | |
26875 | to the assembler. The default is determined during GCC build-time by | |
26876 | detecting corresponding assembler support: | |
26877 | @option{-mpass-mrelax-to-as} if the assembler supports the | |
26878 | @option{-mrelax} option, @option{-mno-pass-mrelax-to-as} otherwise. | |
26879 | This option is mostly useful for debugging, or interoperation with | |
26880 | assemblers different from the build-time one. | |
26881 | ||
9a07bc47 JX |
26882 | @opindex mrecip |
26883 | @item -mrecip | |
26884 | This option enables use of the reciprocal estimate and reciprocal square | |
26885 | root estimate instructions with additional Newton-Raphson steps to increase | |
26886 | precision instead of doing a divide or square root and divide for | |
26887 | floating-point arguments. | |
26888 | These instructions are generated only when @option{-funsafe-math-optimizations} | |
26889 | is enabled together with @option{-ffinite-math-only} and | |
26890 | @option{-fno-trapping-math}. | |
26891 | This option is off by default. Before you can use this option, you must sure the | |
26892 | target CPU supports frecipe and frsqrte instructions. | |
26893 | Note that while the throughput of the sequence is higher than the throughput of | |
26894 | the non-reciprocal instruction, the precision of the sequence can be decreased | |
26895 | by up to 2 ulp (i.e. the inverse of 1.0 equals 0.99999994). | |
26896 | ||
26897 | @opindex mrecip=opt | |
26898 | @item -mrecip=@var{opt} | |
26899 | This option controls which reciprocal estimate instructions | |
26900 | may be used. @var{opt} is a comma-separated list of options, which may | |
26901 | be preceded by a @samp{!} to invert the option: | |
26902 | ||
26903 | @table @samp | |
26904 | @item all | |
26905 | Enable all estimate instructions. | |
26906 | ||
26907 | @item default | |
26908 | Enable the default instructions, equivalent to @option{-mrecip}. | |
26909 | ||
26910 | @item none | |
26911 | Disable all estimate instructions, equivalent to @option{-mno-recip}. | |
26912 | ||
26913 | @item div | |
26914 | Enable the approximation for scalar division. | |
26915 | ||
26916 | @item vec-div | |
26917 | Enable the approximation for vectorized division. | |
26918 | ||
26919 | @item sqrt | |
26920 | Enable the approximation for scalar square root. | |
26921 | ||
26922 | @item vec-sqrt | |
26923 | Enable the approximation for vectorized square root. | |
26924 | ||
26925 | @item rsqrt | |
26926 | Enable the approximation for scalar reciprocal square root. | |
26927 | ||
26928 | @item vec-rsqrt | |
26929 | Enable the approximation for vectorized reciprocal square root. | |
26930 | @end table | |
26931 | ||
26932 | So, for example, @option{-mrecip=all,!sqrt} enables | |
26933 | all of the reciprocal approximations, except for scalar square root. | |
26934 | ||
8f4bbdc2 JX |
26935 | @item loongarch-vect-unroll-limit |
26936 | The vectorizer will use available tuning information to determine whether it | |
26937 | would be beneficial to unroll the main vectorized loop and by how much. This | |
26938 | parameter set's the upper bound of how much the vectorizer will unroll the main | |
26939 | loop. The default value is six. | |
26940 | ||
d77de738 ML |
26941 | @end table |
26942 | ||
bb4a8198 | 26943 | |
d77de738 ML |
26944 | @node M32C Options |
26945 | @subsection M32C Options | |
26946 | @cindex M32C options | |
26947 | ||
26948 | @table @gcctabopt | |
d77de738 | 26949 | @opindex mcpu= |
ddf6fe37 | 26950 | @item -mcpu=@var{name} |
d77de738 ML |
26951 | Select the CPU for which code is generated. @var{name} may be one of |
26952 | @samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to | |
26953 | /60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for | |
26954 | the M32C/80 series. | |
26955 | ||
d77de738 | 26956 | @opindex msim |
ddf6fe37 | 26957 | @item -msim |
d77de738 ML |
26958 | Specifies that the program will be run on the simulator. This causes |
26959 | an alternate runtime library to be linked in which supports, for | |
26960 | example, file I/O@. You must not use this option when generating | |
26961 | programs that will run on real hardware; you must provide your own | |
26962 | runtime library for whatever I/O functions are needed. | |
26963 | ||
d77de738 | 26964 | @opindex memregs= |
ddf6fe37 | 26965 | @item -memregs=@var{number} |
d77de738 ML |
26966 | Specifies the number of memory-based pseudo-registers GCC uses |
26967 | during code generation. These pseudo-registers are used like real | |
26968 | registers, so there is a tradeoff between GCC's ability to fit the | |
26969 | code into available registers, and the performance penalty of using | |
26970 | memory instead of registers. Note that all modules in a program must | |
26971 | be compiled with the same value for this option. Because of that, you | |
26972 | must not use this option with GCC's default runtime libraries. | |
26973 | ||
26974 | @end table | |
26975 | ||
26976 | @node M32R/D Options | |
26977 | @subsection M32R/D Options | |
26978 | @cindex M32R/D options | |
26979 | ||
26980 | These @option{-m} options are defined for Renesas M32R/D architectures: | |
26981 | ||
26982 | @table @gcctabopt | |
d77de738 | 26983 | @opindex m32r2 |
ddf6fe37 | 26984 | @item -m32r2 |
d77de738 ML |
26985 | Generate code for the M32R/2@. |
26986 | ||
d77de738 | 26987 | @opindex m32rx |
ddf6fe37 | 26988 | @item -m32rx |
d77de738 ML |
26989 | Generate code for the M32R/X@. |
26990 | ||
d77de738 | 26991 | @opindex m32r |
ddf6fe37 | 26992 | @item -m32r |
d77de738 ML |
26993 | Generate code for the M32R@. This is the default. |
26994 | ||
d77de738 | 26995 | @opindex mmodel=small |
ddf6fe37 | 26996 | @item -mmodel=small |
d77de738 ML |
26997 | Assume all objects live in the lower 16MB of memory (so that their addresses |
26998 | can be loaded with the @code{ld24} instruction), and assume all subroutines | |
26999 | are reachable with the @code{bl} instruction. | |
27000 | This is the default. | |
27001 | ||
27002 | The addressability of a particular object can be set with the | |
27003 | @code{model} attribute. | |
27004 | ||
d77de738 | 27005 | @opindex mmodel=medium |
ddf6fe37 | 27006 | @item -mmodel=medium |
d77de738 ML |
27007 | Assume objects may be anywhere in the 32-bit address space (the compiler |
27008 | generates @code{seth/add3} instructions to load their addresses), and | |
27009 | assume all subroutines are reachable with the @code{bl} instruction. | |
27010 | ||
d77de738 | 27011 | @opindex mmodel=large |
ddf6fe37 | 27012 | @item -mmodel=large |
d77de738 ML |
27013 | Assume objects may be anywhere in the 32-bit address space (the compiler |
27014 | generates @code{seth/add3} instructions to load their addresses), and | |
27015 | assume subroutines may not be reachable with the @code{bl} instruction | |
27016 | (the compiler generates the much slower @code{seth/add3/jl} | |
27017 | instruction sequence). | |
27018 | ||
d77de738 | 27019 | @opindex msdata=none |
ddf6fe37 | 27020 | @item -msdata=none |
d77de738 ML |
27021 | Disable use of the small data area. Variables are put into |
27022 | one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the | |
27023 | @code{section} attribute has been specified). | |
27024 | This is the default. | |
27025 | ||
27026 | The small data area consists of sections @code{.sdata} and @code{.sbss}. | |
27027 | Objects may be explicitly put in the small data area with the | |
27028 | @code{section} attribute using one of these sections. | |
27029 | ||
d77de738 | 27030 | @opindex msdata=sdata |
ddf6fe37 | 27031 | @item -msdata=sdata |
d77de738 ML |
27032 | Put small global and static data in the small data area, but do not |
27033 | generate special code to reference them. | |
27034 | ||
d77de738 | 27035 | @opindex msdata=use |
ddf6fe37 | 27036 | @item -msdata=use |
d77de738 ML |
27037 | Put small global and static data in the small data area, and generate |
27038 | special instructions to reference them. | |
27039 | ||
d77de738 ML |
27040 | @opindex G |
27041 | @cindex smaller data references | |
f33d7a88 | 27042 | @item -G @var{num} |
d77de738 ML |
27043 | Put global and static objects less than or equal to @var{num} bytes |
27044 | into the small data or BSS sections instead of the normal data or BSS | |
27045 | sections. The default value of @var{num} is 8. | |
27046 | The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use} | |
27047 | for this option to have any effect. | |
27048 | ||
27049 | All modules should be compiled with the same @option{-G @var{num}} value. | |
27050 | Compiling with different values of @var{num} may or may not work; if it | |
27051 | doesn't the linker gives an error message---incorrect code is not | |
27052 | generated. | |
27053 | ||
d77de738 | 27054 | @opindex mdebug |
ddf6fe37 | 27055 | @item -mdebug |
d77de738 ML |
27056 | Makes the M32R-specific code in the compiler display some statistics |
27057 | that might help in debugging programs. | |
27058 | ||
d77de738 | 27059 | @opindex malign-loops |
ddf6fe37 | 27060 | @item -malign-loops |
d77de738 ML |
27061 | Align all loops to a 32-byte boundary. |
27062 | ||
d77de738 | 27063 | @opindex mno-align-loops |
ddf6fe37 | 27064 | @item -mno-align-loops |
d77de738 ML |
27065 | Do not enforce a 32-byte alignment for loops. This is the default. |
27066 | ||
d77de738 | 27067 | @opindex missue-rate=@var{number} |
ddf6fe37 | 27068 | @item -missue-rate=@var{number} |
d77de738 ML |
27069 | Issue @var{number} instructions per cycle. @var{number} can only be 1 |
27070 | or 2. | |
27071 | ||
d77de738 | 27072 | @opindex mbranch-cost=@var{number} |
ddf6fe37 | 27073 | @item -mbranch-cost=@var{number} |
d77de738 ML |
27074 | @var{number} can only be 1 or 2. If it is 1 then branches are |
27075 | preferred over conditional code, if it is 2, then the opposite applies. | |
27076 | ||
d77de738 | 27077 | @opindex mflush-trap=@var{number} |
ddf6fe37 | 27078 | @item -mflush-trap=@var{number} |
d77de738 ML |
27079 | Specifies the trap number to use to flush the cache. The default is |
27080 | 12. Valid numbers are between 0 and 15 inclusive. | |
27081 | ||
d77de738 | 27082 | @opindex mno-flush-trap |
ddf6fe37 | 27083 | @item -mno-flush-trap |
d77de738 ML |
27084 | Specifies that the cache cannot be flushed by using a trap. |
27085 | ||
d77de738 | 27086 | @opindex mflush-func=@var{name} |
ddf6fe37 | 27087 | @item -mflush-func=@var{name} |
d77de738 ML |
27088 | Specifies the name of the operating system function to call to flush |
27089 | the cache. The default is @samp{_flush_cache}, but a function call | |
27090 | is only used if a trap is not available. | |
27091 | ||
d77de738 | 27092 | @opindex mno-flush-func |
ddf6fe37 | 27093 | @item -mno-flush-func |
d77de738 ML |
27094 | Indicates that there is no OS function for flushing the cache. |
27095 | ||
27096 | @end table | |
27097 | ||
27098 | @node M680x0 Options | |
27099 | @subsection M680x0 Options | |
27100 | @cindex M680x0 options | |
27101 | ||
27102 | These are the @samp{-m} options defined for M680x0 and ColdFire processors. | |
27103 | The default settings depend on which architecture was selected when | |
27104 | the compiler was configured; the defaults for the most common choices | |
27105 | are given below. | |
27106 | ||
27107 | @table @gcctabopt | |
d77de738 | 27108 | @opindex march |
ddf6fe37 | 27109 | @item -march=@var{arch} |
d77de738 ML |
27110 | Generate code for a specific M680x0 or ColdFire instruction set |
27111 | architecture. Permissible values of @var{arch} for M680x0 | |
27112 | architectures are: @samp{68000}, @samp{68010}, @samp{68020}, | |
27113 | @samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire | |
27114 | architectures are selected according to Freescale's ISA classification | |
27115 | and the permissible values are: @samp{isaa}, @samp{isaaplus}, | |
27116 | @samp{isab} and @samp{isac}. | |
27117 | ||
27118 | GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating | |
27119 | code for a ColdFire target. The @var{arch} in this macro is one of the | |
27120 | @option{-march} arguments given above. | |
27121 | ||
27122 | When used together, @option{-march} and @option{-mtune} select code | |
27123 | that runs on a family of similar processors but that is optimized | |
27124 | for a particular microarchitecture. | |
27125 | ||
d77de738 | 27126 | @opindex mcpu |
ddf6fe37 | 27127 | @item -mcpu=@var{cpu} |
d77de738 ML |
27128 | Generate code for a specific M680x0 or ColdFire processor. |
27129 | The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020}, | |
27130 | @samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332} | |
27131 | and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table | |
27132 | below, which also classifies the CPUs into families: | |
27133 | ||
27134 | @multitable @columnfractions 0.20 0.80 | |
27135 | @headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments} | |
27136 | @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} | |
27137 | @item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206} | |
27138 | @item @samp{5206e} @tab @samp{5206e} | |
27139 | @item @samp{5208} @tab @samp{5207} @samp{5208} | |
27140 | @item @samp{5211a} @tab @samp{5210a} @samp{5211a} | |
27141 | @item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213} | |
27142 | @item @samp{5216} @tab @samp{5214} @samp{5216} | |
27143 | @item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235} | |
27144 | @item @samp{5225} @tab @samp{5224} @samp{5225} | |
27145 | @item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259} | |
27146 | @item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x} | |
27147 | @item @samp{5249} @tab @samp{5249} | |
27148 | @item @samp{5250} @tab @samp{5250} | |
27149 | @item @samp{5271} @tab @samp{5270} @samp{5271} | |
27150 | @item @samp{5272} @tab @samp{5272} | |
27151 | @item @samp{5275} @tab @samp{5274} @samp{5275} | |
27152 | @item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x} | |
27153 | @item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017} | |
27154 | @item @samp{5307} @tab @samp{5307} | |
27155 | @item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x} | |
27156 | @item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x} | |
27157 | @item @samp{5407} @tab @samp{5407} | |
27158 | @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} | |
27159 | @end multitable | |
27160 | ||
27161 | @option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if | |
27162 | @var{arch} is compatible with @var{cpu}. Other combinations of | |
27163 | @option{-mcpu} and @option{-march} are rejected. | |
27164 | ||
27165 | GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target | |
27166 | @var{cpu} is selected. It also defines @code{__mcf_family_@var{family}}, | |
27167 | where the value of @var{family} is given by the table above. | |
27168 | ||
d77de738 | 27169 | @opindex mtune |
ddf6fe37 | 27170 | @item -mtune=@var{tune} |
d77de738 ML |
27171 | Tune the code for a particular microarchitecture within the |
27172 | constraints set by @option{-march} and @option{-mcpu}. | |
27173 | The M680x0 microarchitectures are: @samp{68000}, @samp{68010}, | |
27174 | @samp{68020}, @samp{68030}, @samp{68040}, @samp{68060} | |
27175 | and @samp{cpu32}. The ColdFire microarchitectures | |
27176 | are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}. | |
27177 | ||
27178 | You can also use @option{-mtune=68020-40} for code that needs | |
27179 | to run relatively well on 68020, 68030 and 68040 targets. | |
27180 | @option{-mtune=68020-60} is similar but includes 68060 targets | |
27181 | as well. These two options select the same tuning decisions as | |
27182 | @option{-m68020-40} and @option{-m68020-60} respectively. | |
27183 | ||
27184 | GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__} | |
27185 | when tuning for 680x0 architecture @var{arch}. It also defines | |
27186 | @code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std} | |
27187 | option is used. If GCC is tuning for a range of architectures, | |
27188 | as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60}, | |
27189 | it defines the macros for every architecture in the range. | |
27190 | ||
27191 | GCC also defines the macro @code{__m@var{uarch}__} when tuning for | |
27192 | ColdFire microarchitecture @var{uarch}, where @var{uarch} is one | |
27193 | of the arguments given above. | |
27194 | ||
d77de738 ML |
27195 | @opindex m68000 |
27196 | @opindex mc68000 | |
ddf6fe37 AA |
27197 | @item -m68000 |
27198 | @itemx -mc68000 | |
d77de738 ML |
27199 | Generate output for a 68000. This is the default |
27200 | when the compiler is configured for 68000-based systems. | |
27201 | It is equivalent to @option{-march=68000}. | |
27202 | ||
27203 | Use this option for microcontrollers with a 68000 or EC000 core, | |
27204 | including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356. | |
27205 | ||
d77de738 | 27206 | @opindex m68010 |
ddf6fe37 | 27207 | @item -m68010 |
d77de738 ML |
27208 | Generate output for a 68010. This is the default |
27209 | when the compiler is configured for 68010-based systems. | |
27210 | It is equivalent to @option{-march=68010}. | |
27211 | ||
d77de738 ML |
27212 | @opindex m68020 |
27213 | @opindex mc68020 | |
ddf6fe37 AA |
27214 | @item -m68020 |
27215 | @itemx -mc68020 | |
d77de738 ML |
27216 | Generate output for a 68020. This is the default |
27217 | when the compiler is configured for 68020-based systems. | |
27218 | It is equivalent to @option{-march=68020}. | |
27219 | ||
d77de738 | 27220 | @opindex m68030 |
ddf6fe37 | 27221 | @item -m68030 |
d77de738 ML |
27222 | Generate output for a 68030. This is the default when the compiler is |
27223 | configured for 68030-based systems. It is equivalent to | |
27224 | @option{-march=68030}. | |
27225 | ||
d77de738 | 27226 | @opindex m68040 |
ddf6fe37 | 27227 | @item -m68040 |
d77de738 ML |
27228 | Generate output for a 68040. This is the default when the compiler is |
27229 | configured for 68040-based systems. It is equivalent to | |
27230 | @option{-march=68040}. | |
27231 | ||
27232 | This option inhibits the use of 68881/68882 instructions that have to be | |
27233 | emulated by software on the 68040. Use this option if your 68040 does not | |
27234 | have code to emulate those instructions. | |
27235 | ||
d77de738 | 27236 | @opindex m68060 |
ddf6fe37 | 27237 | @item -m68060 |
d77de738 ML |
27238 | Generate output for a 68060. This is the default when the compiler is |
27239 | configured for 68060-based systems. It is equivalent to | |
27240 | @option{-march=68060}. | |
27241 | ||
27242 | This option inhibits the use of 68020 and 68881/68882 instructions that | |
27243 | have to be emulated by software on the 68060. Use this option if your 68060 | |
27244 | does not have code to emulate those instructions. | |
27245 | ||
d77de738 | 27246 | @opindex mcpu32 |
ddf6fe37 | 27247 | @item -mcpu32 |
d77de738 ML |
27248 | Generate output for a CPU32. This is the default |
27249 | when the compiler is configured for CPU32-based systems. | |
27250 | It is equivalent to @option{-march=cpu32}. | |
27251 | ||
27252 | Use this option for microcontrollers with a | |
27253 | CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334, | |
27254 | 68336, 68340, 68341, 68349 and 68360. | |
27255 | ||
d77de738 | 27256 | @opindex m5200 |
ddf6fe37 | 27257 | @item -m5200 |
d77de738 ML |
27258 | Generate output for a 520X ColdFire CPU@. This is the default |
27259 | when the compiler is configured for 520X-based systems. | |
27260 | It is equivalent to @option{-mcpu=5206}, and is now deprecated | |
27261 | in favor of that option. | |
27262 | ||
27263 | Use this option for microcontroller with a 5200 core, including | |
27264 | the MCF5202, MCF5203, MCF5204 and MCF5206. | |
27265 | ||
d77de738 | 27266 | @opindex m5206e |
ddf6fe37 | 27267 | @item -m5206e |
d77de738 ML |
27268 | Generate output for a 5206e ColdFire CPU@. The option is now |
27269 | deprecated in favor of the equivalent @option{-mcpu=5206e}. | |
27270 | ||
d77de738 | 27271 | @opindex m528x |
ddf6fe37 | 27272 | @item -m528x |
d77de738 ML |
27273 | Generate output for a member of the ColdFire 528X family. |
27274 | The option is now deprecated in favor of the equivalent | |
27275 | @option{-mcpu=528x}. | |
27276 | ||
d77de738 | 27277 | @opindex m5307 |
ddf6fe37 | 27278 | @item -m5307 |
d77de738 ML |
27279 | Generate output for a ColdFire 5307 CPU@. The option is now deprecated |
27280 | in favor of the equivalent @option{-mcpu=5307}. | |
27281 | ||
d77de738 | 27282 | @opindex m5407 |
ddf6fe37 | 27283 | @item -m5407 |
d77de738 ML |
27284 | Generate output for a ColdFire 5407 CPU@. The option is now deprecated |
27285 | in favor of the equivalent @option{-mcpu=5407}. | |
27286 | ||
d77de738 | 27287 | @opindex mcfv4e |
ddf6fe37 | 27288 | @item -mcfv4e |
d77de738 ML |
27289 | Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x). |
27290 | This includes use of hardware floating-point instructions. | |
27291 | The option is equivalent to @option{-mcpu=547x}, and is now | |
27292 | deprecated in favor of that option. | |
27293 | ||
d77de738 | 27294 | @opindex m68020-40 |
ddf6fe37 | 27295 | @item -m68020-40 |
d77de738 ML |
27296 | Generate output for a 68040, without using any of the new instructions. |
27297 | This results in code that can run relatively efficiently on either a | |
27298 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
27299 | 68881 instructions that are emulated on the 68040. | |
27300 | ||
27301 | The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}. | |
27302 | ||
d77de738 | 27303 | @opindex m68020-60 |
ddf6fe37 | 27304 | @item -m68020-60 |
d77de738 ML |
27305 | Generate output for a 68060, without using any of the new instructions. |
27306 | This results in code that can run relatively efficiently on either a | |
27307 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
27308 | 68881 instructions that are emulated on the 68060. | |
27309 | ||
27310 | The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}. | |
27311 | ||
d77de738 ML |
27312 | @opindex mhard-float |
27313 | @opindex m68881 | |
ddf6fe37 AA |
27314 | @item -mhard-float |
27315 | @itemx -m68881 | |
d77de738 ML |
27316 | Generate floating-point instructions. This is the default for 68020 |
27317 | and above, and for ColdFire devices that have an FPU@. It defines the | |
27318 | macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__} | |
27319 | on ColdFire targets. | |
27320 | ||
d77de738 | 27321 | @opindex msoft-float |
ddf6fe37 | 27322 | @item -msoft-float |
d77de738 ML |
27323 | Do not generate floating-point instructions; use library calls instead. |
27324 | This is the default for 68000, 68010, and 68832 targets. It is also | |
27325 | the default for ColdFire devices that have no FPU. | |
27326 | ||
d77de738 ML |
27327 | @opindex mdiv |
27328 | @opindex mno-div | |
ddf6fe37 AA |
27329 | @item -mdiv |
27330 | @itemx -mno-div | |
d77de738 ML |
27331 | Generate (do not generate) ColdFire hardware divide and remainder |
27332 | instructions. If @option{-march} is used without @option{-mcpu}, | |
27333 | the default is ``on'' for ColdFire architectures and ``off'' for M680x0 | |
27334 | architectures. Otherwise, the default is taken from the target CPU | |
27335 | (either the default CPU, or the one specified by @option{-mcpu}). For | |
27336 | example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for | |
27337 | @option{-mcpu=5206e}. | |
27338 | ||
27339 | GCC defines the macro @code{__mcfhwdiv__} when this option is enabled. | |
27340 | ||
d77de738 | 27341 | @opindex mshort |
ddf6fe37 | 27342 | @item -mshort |
d77de738 ML |
27343 | Consider type @code{int} to be 16 bits wide, like @code{short int}. |
27344 | Additionally, parameters passed on the stack are also aligned to a | |
27345 | 16-bit boundary even on targets whose API mandates promotion to 32-bit. | |
27346 | ||
d77de738 | 27347 | @opindex mno-short |
ddf6fe37 | 27348 | @item -mno-short |
d77de738 ML |
27349 | Do not consider type @code{int} to be 16 bits wide. This is the default. |
27350 | ||
d77de738 ML |
27351 | @opindex mnobitfield |
27352 | @opindex mno-bitfield | |
ddf6fe37 AA |
27353 | @item -mnobitfield |
27354 | @itemx -mno-bitfield | |
d77de738 ML |
27355 | Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32} |
27356 | and @option{-m5200} options imply @w{@option{-mnobitfield}}. | |
27357 | ||
d77de738 | 27358 | @opindex mbitfield |
ddf6fe37 | 27359 | @item -mbitfield |
d77de738 ML |
27360 | Do use the bit-field instructions. The @option{-m68020} option implies |
27361 | @option{-mbitfield}. This is the default if you use a configuration | |
27362 | designed for a 68020. | |
27363 | ||
d77de738 | 27364 | @opindex mrtd |
ddf6fe37 | 27365 | @item -mrtd |
d77de738 ML |
27366 | Use a different function-calling convention, in which functions |
27367 | that take a fixed number of arguments return with the @code{rtd} | |
27368 | instruction, which pops their arguments while returning. This | |
27369 | saves one instruction in the caller since there is no need to pop | |
27370 | the arguments there. | |
27371 | ||
27372 | This calling convention is incompatible with the one normally | |
27373 | used on Unix, so you cannot use it if you need to call libraries | |
27374 | compiled with the Unix compiler. | |
27375 | ||
27376 | Also, you must provide function prototypes for all functions that | |
27377 | take variable numbers of arguments (including @code{printf}); | |
27378 | otherwise incorrect code is generated for calls to those | |
27379 | functions. | |
27380 | ||
27381 | In addition, seriously incorrect code results if you call a | |
27382 | function with too many arguments. (Normally, extra arguments are | |
27383 | harmlessly ignored.) | |
27384 | ||
27385 | The @code{rtd} instruction is supported by the 68010, 68020, 68030, | |
27386 | 68040, 68060 and CPU32 processors, but not by the 68000 or 5200. | |
27387 | ||
27388 | The default is @option{-mno-rtd}. | |
27389 | ||
d77de738 ML |
27390 | @opindex malign-int |
27391 | @opindex mno-align-int | |
ddf6fe37 AA |
27392 | @item -malign-int |
27393 | @itemx -mno-align-int | |
d77de738 ML |
27394 | Control whether GCC aligns @code{int}, @code{long}, @code{long long}, |
27395 | @code{float}, @code{double}, and @code{long double} variables on a 32-bit | |
27396 | boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}). | |
27397 | Aligning variables on 32-bit boundaries produces code that runs somewhat | |
27398 | faster on processors with 32-bit busses at the expense of more memory. | |
27399 | ||
27400 | @strong{Warning:} if you use the @option{-malign-int} switch, GCC | |
27401 | aligns structures containing the above types differently than | |
27402 | most published application binary interface specifications for the m68k. | |
27403 | ||
27404 | @opindex mpcrel | |
27405 | Use the pc-relative addressing mode of the 68000 directly, instead of | |
27406 | using a global offset table. At present, this option implies @option{-fpic}, | |
27407 | allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is | |
27408 | not presently supported with @option{-mpcrel}, though this could be supported for | |
27409 | 68020 and higher processors. | |
27410 | ||
d77de738 ML |
27411 | @opindex mno-strict-align |
27412 | @opindex mstrict-align | |
ddf6fe37 AA |
27413 | @item -mno-strict-align |
27414 | @itemx -mstrict-align | |
d77de738 ML |
27415 | Do not (do) assume that unaligned memory references are handled by |
27416 | the system. | |
27417 | ||
27418 | @item -msep-data | |
27419 | Generate code that allows the data segment to be located in a different | |
27420 | area of memory from the text segment. This allows for execute-in-place in | |
27421 | an environment without virtual memory management. This option implies | |
27422 | @option{-fPIC}. | |
27423 | ||
27424 | @item -mno-sep-data | |
27425 | Generate code that assumes that the data segment follows the text segment. | |
27426 | This is the default. | |
27427 | ||
27428 | @item -mid-shared-library | |
27429 | Generate code that supports shared libraries via the library ID method. | |
27430 | This allows for execute-in-place and shared libraries in an environment | |
27431 | without virtual memory management. This option implies @option{-fPIC}. | |
27432 | ||
27433 | @item -mno-id-shared-library | |
27434 | Generate code that doesn't assume ID-based shared libraries are being used. | |
27435 | This is the default. | |
27436 | ||
27437 | @item -mshared-library-id=n | |
27438 | Specifies the identification number of the ID-based shared library being | |
27439 | compiled. Specifying a value of 0 generates more compact code; specifying | |
27440 | other values forces the allocation of that number to the current | |
27441 | library, but is no more space- or time-efficient than omitting this option. | |
27442 | ||
d77de738 ML |
27443 | @opindex mxgot |
27444 | @opindex mno-xgot | |
ddf6fe37 AA |
27445 | @item -mxgot |
27446 | @itemx -mno-xgot | |
d77de738 ML |
27447 | When generating position-independent code for ColdFire, generate code |
27448 | that works if the GOT has more than 8192 entries. This code is | |
27449 | larger and slower than code generated without this option. On M680x0 | |
27450 | processors, this option is not needed; @option{-fPIC} suffices. | |
27451 | ||
27452 | GCC normally uses a single instruction to load values from the GOT@. | |
27453 | While this is relatively efficient, it only works if the GOT | |
27454 | is smaller than about 64k. Anything larger causes the linker | |
27455 | to report an error such as: | |
27456 | ||
27457 | @cindex relocation truncated to fit (ColdFire) | |
27458 | @smallexample | |
27459 | relocation truncated to fit: R_68K_GOT16O foobar | |
27460 | @end smallexample | |
27461 | ||
27462 | If this happens, you should recompile your code with @option{-mxgot}. | |
27463 | It should then work with very large GOTs. However, code generated with | |
27464 | @option{-mxgot} is less efficient, since it takes 4 instructions to fetch | |
27465 | the value of a global symbol. | |
27466 | ||
27467 | Note that some linkers, including newer versions of the GNU linker, | |
27468 | can create multiple GOTs and sort GOT entries. If you have such a linker, | |
27469 | you should only need to use @option{-mxgot} when compiling a single | |
27470 | object file that accesses more than 8192 GOT entries. Very few do. | |
27471 | ||
27472 | These options have no effect unless GCC is generating | |
27473 | position-independent code. | |
27474 | ||
d77de738 | 27475 | @opindex mlong-jump-table-offsets |
ddf6fe37 | 27476 | @item -mlong-jump-table-offsets |
d77de738 ML |
27477 | Use 32-bit offsets in @code{switch} tables. The default is to use |
27478 | 16-bit offsets. | |
27479 | ||
27480 | @end table | |
27481 | ||
27482 | @node MCore Options | |
27483 | @subsection MCore Options | |
27484 | @cindex MCore options | |
27485 | ||
27486 | These are the @samp{-m} options defined for the Motorola M*Core | |
27487 | processors. | |
27488 | ||
27489 | @table @gcctabopt | |
27490 | ||
d77de738 ML |
27491 | @opindex mhardlit |
27492 | @opindex mno-hardlit | |
ddf6fe37 AA |
27493 | @item -mhardlit |
27494 | @itemx -mno-hardlit | |
d77de738 ML |
27495 | Inline constants into the code stream if it can be done in two |
27496 | instructions or less. | |
27497 | ||
d77de738 ML |
27498 | @opindex mdiv |
27499 | @opindex mno-div | |
ddf6fe37 AA |
27500 | @item -mdiv |
27501 | @itemx -mno-div | |
d77de738 ML |
27502 | Use the divide instruction. (Enabled by default). |
27503 | ||
d77de738 ML |
27504 | @opindex mrelax-immediate |
27505 | @opindex mno-relax-immediate | |
ddf6fe37 AA |
27506 | @item -mrelax-immediate |
27507 | @itemx -mno-relax-immediate | |
d77de738 ML |
27508 | Allow arbitrary-sized immediates in bit operations. |
27509 | ||
d77de738 ML |
27510 | @opindex mwide-bitfields |
27511 | @opindex mno-wide-bitfields | |
ddf6fe37 AA |
27512 | @item -mwide-bitfields |
27513 | @itemx -mno-wide-bitfields | |
d77de738 ML |
27514 | Always treat bit-fields as @code{int}-sized. |
27515 | ||
d77de738 ML |
27516 | @opindex m4byte-functions |
27517 | @opindex mno-4byte-functions | |
ddf6fe37 AA |
27518 | @item -m4byte-functions |
27519 | @itemx -mno-4byte-functions | |
d77de738 ML |
27520 | Force all functions to be aligned to a 4-byte boundary. |
27521 | ||
d77de738 ML |
27522 | @opindex mcallgraph-data |
27523 | @opindex mno-callgraph-data | |
ddf6fe37 AA |
27524 | @item -mcallgraph-data |
27525 | @itemx -mno-callgraph-data | |
d77de738 ML |
27526 | Emit callgraph information. |
27527 | ||
d77de738 ML |
27528 | @opindex mslow-bytes |
27529 | @opindex mno-slow-bytes | |
ddf6fe37 AA |
27530 | @item -mslow-bytes |
27531 | @itemx -mno-slow-bytes | |
d77de738 ML |
27532 | Prefer word access when reading byte quantities. |
27533 | ||
d77de738 ML |
27534 | @opindex mlittle-endian |
27535 | @opindex mbig-endian | |
ddf6fe37 AA |
27536 | @item -mlittle-endian |
27537 | @itemx -mbig-endian | |
d77de738 ML |
27538 | Generate code for a little-endian target. |
27539 | ||
d77de738 ML |
27540 | @opindex m210 |
27541 | @opindex m340 | |
ddf6fe37 AA |
27542 | @item -m210 |
27543 | @itemx -m340 | |
d77de738 ML |
27544 | Generate code for the 210 processor. |
27545 | ||
d77de738 | 27546 | @opindex mno-lsim |
ddf6fe37 | 27547 | @item -mno-lsim |
d77de738 ML |
27548 | Assume that runtime support has been provided and so omit the |
27549 | simulator library (@file{libsim.a)} from the linker command line. | |
27550 | ||
d77de738 | 27551 | @opindex mstack-increment |
ddf6fe37 | 27552 | @item -mstack-increment=@var{size} |
d77de738 ML |
27553 | Set the maximum amount for a single stack increment operation. Large |
27554 | values can increase the speed of programs that contain functions | |
27555 | that need a large amount of stack space, but they can also trigger a | |
27556 | segmentation fault if the stack is extended too much. The default | |
27557 | value is 0x1000. | |
27558 | ||
27559 | @end table | |
27560 | ||
d77de738 ML |
27561 | @node MicroBlaze Options |
27562 | @subsection MicroBlaze Options | |
27563 | @cindex MicroBlaze Options | |
27564 | ||
27565 | @table @gcctabopt | |
27566 | ||
d77de738 | 27567 | @opindex msoft-float |
ddf6fe37 | 27568 | @item -msoft-float |
d77de738 ML |
27569 | Use software emulation for floating point (default). |
27570 | ||
d77de738 | 27571 | @opindex mhard-float |
ddf6fe37 | 27572 | @item -mhard-float |
d77de738 ML |
27573 | Use hardware floating-point instructions. |
27574 | ||
d77de738 | 27575 | @opindex mmemcpy |
ddf6fe37 | 27576 | @item -mmemcpy |
d77de738 ML |
27577 | Do not optimize block moves, use @code{memcpy}. |
27578 | ||
d77de738 | 27579 | @opindex mno-clearbss |
ddf6fe37 | 27580 | @item -mno-clearbss |
d77de738 ML |
27581 | This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead. |
27582 | ||
d77de738 | 27583 | @opindex mcpu= |
ddf6fe37 | 27584 | @item -mcpu=@var{cpu-type} |
d77de738 ML |
27585 | Use features of, and schedule code for, the given CPU. |
27586 | Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}}, | |
27587 | where @var{X} is a major version, @var{YY} is the minor version, and | |
27588 | @var{Z} is compatibility code. Example values are @samp{v3.00.a}, | |
27589 | @samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}. | |
27590 | ||
d77de738 | 27591 | @opindex mxl-soft-mul |
ddf6fe37 | 27592 | @item -mxl-soft-mul |
d77de738 ML |
27593 | Use software multiply emulation (default). |
27594 | ||
d77de738 | 27595 | @opindex mxl-soft-div |
ddf6fe37 | 27596 | @item -mxl-soft-div |
d77de738 ML |
27597 | Use software emulation for divides (default). |
27598 | ||
d77de738 | 27599 | @opindex mxl-barrel-shift |
ddf6fe37 | 27600 | @item -mxl-barrel-shift |
d77de738 ML |
27601 | Use the hardware barrel shifter. |
27602 | ||
d77de738 | 27603 | @opindex mxl-pattern-compare |
ddf6fe37 | 27604 | @item -mxl-pattern-compare |
d77de738 ML |
27605 | Use pattern compare instructions. |
27606 | ||
d77de738 | 27607 | @opindex msmall-divides |
ddf6fe37 | 27608 | @item -msmall-divides |
d77de738 ML |
27609 | Use table lookup optimization for small signed integer divisions. |
27610 | ||
d77de738 | 27611 | @opindex mxl-stack-check |
ddf6fe37 | 27612 | @item -mxl-stack-check |
d77de738 ML |
27613 | This option is deprecated. Use @option{-fstack-check} instead. |
27614 | ||
d77de738 | 27615 | @opindex mxl-gp-opt |
ddf6fe37 | 27616 | @item -mxl-gp-opt |
d77de738 ML |
27617 | Use GP-relative @code{.sdata}/@code{.sbss} sections. |
27618 | ||
d77de738 | 27619 | @opindex mxl-multiply-high |
ddf6fe37 | 27620 | @item -mxl-multiply-high |
d77de738 ML |
27621 | Use multiply high instructions for high part of 32x32 multiply. |
27622 | ||
d77de738 | 27623 | @opindex mxl-float-convert |
ddf6fe37 | 27624 | @item -mxl-float-convert |
d77de738 ML |
27625 | Use hardware floating-point conversion instructions. |
27626 | ||
d77de738 | 27627 | @opindex mxl-float-sqrt |
ddf6fe37 | 27628 | @item -mxl-float-sqrt |
d77de738 ML |
27629 | Use hardware floating-point square root instruction. |
27630 | ||
d77de738 | 27631 | @opindex mbig-endian |
ddf6fe37 | 27632 | @item -mbig-endian |
d77de738 ML |
27633 | Generate code for a big-endian target. |
27634 | ||
d77de738 | 27635 | @opindex mlittle-endian |
ddf6fe37 | 27636 | @item -mlittle-endian |
d77de738 ML |
27637 | Generate code for a little-endian target. |
27638 | ||
d77de738 | 27639 | @opindex mxl-reorder |
ddf6fe37 | 27640 | @item -mxl-reorder |
d77de738 ML |
27641 | Use reorder instructions (swap and byte reversed load/store). |
27642 | ||
27643 | @item -mxl-mode-@var{app-model} | |
27644 | Select application model @var{app-model}. Valid models are | |
27645 | @table @samp | |
27646 | @item executable | |
27647 | normal executable (default), uses startup code @file{crt0.o}. | |
27648 | ||
27649 | @item xmdstub | |
27650 | for use with Xilinx Microprocessor Debugger (XMD) based | |
27651 | software intrusive debug agent called xmdstub. This uses startup file | |
27652 | @file{crt1.o} and sets the start address of the program to 0x800. | |
27653 | ||
27654 | @item bootstrap | |
27655 | for applications that are loaded using a bootloader. | |
27656 | This model uses startup file @file{crt2.o} which does not contain a processor | |
27657 | reset vector handler. This is suitable for transferring control on a | |
27658 | processor reset to the bootloader rather than the application. | |
27659 | ||
27660 | @item novectors | |
27661 | for applications that do not require any of the | |
27662 | MicroBlaze vectors. This option may be useful for applications running | |
27663 | within a monitoring application. This model uses @file{crt3.o} as a startup file. | |
27664 | @end table | |
27665 | ||
27666 | Option @option{-xl-mode-@var{app-model}} is a deprecated alias for | |
27667 | @option{-mxl-mode-@var{app-model}}. | |
27668 | ||
d77de738 | 27669 | @opindex mpic-data-is-text-relative |
ddf6fe37 | 27670 | @item -mpic-data-is-text-relative |
d77de738 ML |
27671 | Assume that the displacement between the text and data segments is fixed |
27672 | at static link time. This allows data to be referenced by offset from start of | |
27673 | text address instead of GOT since PC-relative addressing is not supported. | |
27674 | ||
27675 | @end table | |
27676 | ||
27677 | @node MIPS Options | |
27678 | @subsection MIPS Options | |
27679 | @cindex MIPS options | |
27680 | ||
27681 | @table @gcctabopt | |
27682 | ||
d77de738 | 27683 | @opindex EB |
ddf6fe37 | 27684 | @item -EB |
d77de738 ML |
27685 | Generate big-endian code. |
27686 | ||
d77de738 | 27687 | @opindex EL |
ddf6fe37 | 27688 | @item -EL |
d77de738 ML |
27689 | Generate little-endian code. This is the default for @samp{mips*el-*-*} |
27690 | configurations. | |
27691 | ||
d77de738 | 27692 | @opindex march |
ddf6fe37 | 27693 | @item -march=@var{arch} |
d77de738 ML |
27694 | Generate code that runs on @var{arch}, which can be the name of a |
27695 | generic MIPS ISA, or the name of a particular processor. | |
27696 | The ISA names are: | |
27697 | @samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4}, | |
27698 | @samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5}, | |
27699 | @samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3}, | |
27700 | @samp{mips64r5} and @samp{mips64r6}. | |
27701 | The processor names are: | |
27702 | @samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc}, | |
27703 | @samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd}, | |
27704 | @samp{5kc}, @samp{5kf}, | |
27705 | @samp{20kc}, | |
27706 | @samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1}, | |
27707 | @samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1}, | |
27708 | @samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn}, | |
27709 | @samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2}, | |
27710 | @samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1}, | |
27711 | @samp{i6400}, @samp{i6500}, | |
27712 | @samp{interaptiv}, | |
27713 | @samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464}, | |
27714 | @samp{gs464e}, @samp{gs264e}, | |
27715 | @samp{m4k}, | |
27716 | @samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec}, | |
27717 | @samp{m5100}, @samp{m5101}, | |
27718 | @samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3}, | |
27719 | @samp{orion}, | |
27720 | @samp{p5600}, @samp{p6600}, | |
27721 | @samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400}, | |
27722 | @samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900}, | |
27723 | @samp{r6000}, @samp{r8000}, | |
27724 | @samp{rm7000}, @samp{rm9000}, | |
27725 | @samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000}, | |
27726 | @samp{sb1}, | |
27727 | @samp{sr71000}, | |
27728 | @samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300}, | |
27729 | @samp{vr5000}, @samp{vr5400}, @samp{vr5500}, | |
27730 | @samp{xlr} and @samp{xlp}. | |
27731 | The special value @samp{from-abi} selects the | |
27732 | most compatible architecture for the selected ABI (that is, | |
27733 | @samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@. | |
27734 | ||
27735 | The native Linux/GNU toolchain also supports the value @samp{native}, | |
27736 | which selects the best architecture option for the host processor. | |
27737 | @option{-march=native} has no effect if GCC does not recognize | |
27738 | the processor. | |
27739 | ||
27740 | In processor names, a final @samp{000} can be abbreviated as @samp{k} | |
27741 | (for example, @option{-march=r2k}). Prefixes are optional, and | |
27742 | @samp{vr} may be written @samp{r}. | |
27743 | ||
27744 | Names of the form @samp{@var{n}f2_1} refer to processors with | |
27745 | FPUs clocked at half the rate of the core, names of the form | |
27746 | @samp{@var{n}f1_1} refer to processors with FPUs clocked at the same | |
27747 | rate as the core, and names of the form @samp{@var{n}f3_2} refer to | |
27748 | processors with FPUs clocked a ratio of 3:2 with respect to the core. | |
27749 | For compatibility reasons, @samp{@var{n}f} is accepted as a synonym | |
27750 | for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are | |
27751 | accepted as synonyms for @samp{@var{n}f1_1}. | |
27752 | ||
27753 | GCC defines two macros based on the value of this option. The first | |
27754 | is @code{_MIPS_ARCH}, which gives the name of target architecture, as | |
27755 | a string. The second has the form @code{_MIPS_ARCH_@var{foo}}, | |
27756 | where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@. | |
27757 | For example, @option{-march=r2000} sets @code{_MIPS_ARCH} | |
27758 | to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}. | |
27759 | ||
27760 | Note that the @code{_MIPS_ARCH} macro uses the processor names given | |
27761 | above. In other words, it has the full prefix and does not | |
27762 | abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi}, | |
27763 | the macro names the resolved architecture (either @code{"mips1"} or | |
27764 | @code{"mips3"}). It names the default architecture when no | |
27765 | @option{-march} option is given. | |
27766 | ||
d77de738 | 27767 | @opindex mtune |
ddf6fe37 | 27768 | @item -mtune=@var{arch} |
d77de738 ML |
27769 | Optimize for @var{arch}. Among other things, this option controls |
27770 | the way instructions are scheduled, and the perceived cost of arithmetic | |
27771 | operations. The list of @var{arch} values is the same as for | |
27772 | @option{-march}. | |
27773 | ||
27774 | When this option is not used, GCC optimizes for the processor | |
27775 | specified by @option{-march}. By using @option{-march} and | |
27776 | @option{-mtune} together, it is possible to generate code that | |
27777 | runs on a family of processors, but optimize the code for one | |
27778 | particular member of that family. | |
27779 | ||
27780 | @option{-mtune} defines the macros @code{_MIPS_TUNE} and | |
27781 | @code{_MIPS_TUNE_@var{foo}}, which work in the same way as the | |
27782 | @option{-march} ones described above. | |
27783 | ||
d77de738 | 27784 | @opindex mips1 |
ddf6fe37 | 27785 | @item -mips1 |
d77de738 ML |
27786 | Equivalent to @option{-march=mips1}. |
27787 | ||
d77de738 | 27788 | @opindex mips2 |
ddf6fe37 | 27789 | @item -mips2 |
d77de738 ML |
27790 | Equivalent to @option{-march=mips2}. |
27791 | ||
d77de738 | 27792 | @opindex mips3 |
ddf6fe37 | 27793 | @item -mips3 |
d77de738 ML |
27794 | Equivalent to @option{-march=mips3}. |
27795 | ||
d77de738 | 27796 | @opindex mips4 |
ddf6fe37 | 27797 | @item -mips4 |
d77de738 ML |
27798 | Equivalent to @option{-march=mips4}. |
27799 | ||
d77de738 | 27800 | @opindex mips32 |
ddf6fe37 | 27801 | @item -mips32 |
d77de738 ML |
27802 | Equivalent to @option{-march=mips32}. |
27803 | ||
d77de738 | 27804 | @opindex mips32r3 |
ddf6fe37 | 27805 | @item -mips32r3 |
d77de738 ML |
27806 | Equivalent to @option{-march=mips32r3}. |
27807 | ||
d77de738 | 27808 | @opindex mips32r5 |
ddf6fe37 | 27809 | @item -mips32r5 |
d77de738 ML |
27810 | Equivalent to @option{-march=mips32r5}. |
27811 | ||
d77de738 | 27812 | @opindex mips32r6 |
ddf6fe37 | 27813 | @item -mips32r6 |
d77de738 ML |
27814 | Equivalent to @option{-march=mips32r6}. |
27815 | ||
d77de738 | 27816 | @opindex mips64 |
ddf6fe37 | 27817 | @item -mips64 |
d77de738 ML |
27818 | Equivalent to @option{-march=mips64}. |
27819 | ||
d77de738 | 27820 | @opindex mips64r2 |
ddf6fe37 | 27821 | @item -mips64r2 |
d77de738 ML |
27822 | Equivalent to @option{-march=mips64r2}. |
27823 | ||
d77de738 | 27824 | @opindex mips64r3 |
ddf6fe37 | 27825 | @item -mips64r3 |
d77de738 ML |
27826 | Equivalent to @option{-march=mips64r3}. |
27827 | ||
d77de738 | 27828 | @opindex mips64r5 |
ddf6fe37 | 27829 | @item -mips64r5 |
d77de738 ML |
27830 | Equivalent to @option{-march=mips64r5}. |
27831 | ||
d77de738 | 27832 | @opindex mips64r6 |
ddf6fe37 | 27833 | @item -mips64r6 |
d77de738 ML |
27834 | Equivalent to @option{-march=mips64r6}. |
27835 | ||
d77de738 ML |
27836 | @opindex mips16 |
27837 | @opindex mno-mips16 | |
ddf6fe37 AA |
27838 | @item -mips16 |
27839 | @itemx -mno-mips16 | |
d77de738 ML |
27840 | Generate (do not generate) MIPS16 code. If GCC is targeting a |
27841 | MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@. | |
27842 | ||
27843 | MIPS16 code generation can also be controlled on a per-function basis | |
27844 | by means of @code{mips16} and @code{nomips16} attributes. | |
27845 | @xref{Function Attributes}, for more information. | |
27846 | ||
926f2d09 JM |
27847 | @opindex mmips16e2 |
27848 | @opindex mno-mips16e2 | |
27849 | @item -mmips16e2 | |
27850 | @itemx -mno-mips16e2 | |
27851 | Use (do not use) the MIPS16e2 ASE. This option modifies the behavior | |
27852 | of the @option{-mips16} option such that it targets the MIPS16e2 ASE@. | |
27853 | ||
d77de738 | 27854 | @opindex mflip-mips16 |
ddf6fe37 | 27855 | @item -mflip-mips16 |
d77de738 ML |
27856 | Generate MIPS16 code on alternating functions. This option is provided |
27857 | for regression testing of mixed MIPS16/non-MIPS16 code generation, and is | |
27858 | not intended for ordinary use in compiling user code. | |
27859 | ||
d77de738 ML |
27860 | @opindex minterlink-compressed |
27861 | @opindex mno-interlink-compressed | |
ddf6fe37 AA |
27862 | @item -minterlink-compressed |
27863 | @itemx -mno-interlink-compressed | |
d77de738 ML |
27864 | Require (do not require) that code using the standard (uncompressed) MIPS ISA |
27865 | be link-compatible with MIPS16 and microMIPS code, and vice versa. | |
27866 | ||
27867 | For example, code using the standard ISA encoding cannot jump directly | |
27868 | to MIPS16 or microMIPS code; it must either use a call or an indirect jump. | |
27869 | @option{-minterlink-compressed} therefore disables direct jumps unless GCC | |
27870 | knows that the target of the jump is not compressed. | |
27871 | ||
d77de738 ML |
27872 | @opindex minterlink-mips16 |
27873 | @opindex mno-interlink-mips16 | |
ddf6fe37 AA |
27874 | @item -minterlink-mips16 |
27875 | @itemx -mno-interlink-mips16 | |
d77de738 ML |
27876 | Aliases of @option{-minterlink-compressed} and |
27877 | @option{-mno-interlink-compressed}. These options predate the microMIPS ASE | |
27878 | and are retained for backwards compatibility. | |
27879 | ||
d77de738 ML |
27880 | @opindex mabi=32 |
27881 | @opindex mabi=o64 | |
27882 | @opindex mabi=n32 | |
27883 | @opindex mabi=64 | |
27884 | @opindex mabi=eabi | |
ddf6fe37 AA |
27885 | @item -mabi=32 |
27886 | @itemx -mabi=o64 | |
27887 | @itemx -mabi=n32 | |
27888 | @itemx -mabi=64 | |
27889 | @itemx -mabi=eabi | |
d77de738 ML |
27890 | Generate code for the given ABI@. |
27891 | ||
27892 | Note that the EABI has a 32-bit and a 64-bit variant. GCC normally | |
27893 | generates 64-bit code when you select a 64-bit architecture, but you | |
27894 | can use @option{-mgp32} to get 32-bit code instead. | |
27895 | ||
27896 | For information about the O64 ABI, see | |
27897 | @uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}. | |
27898 | ||
27899 | GCC supports a variant of the o32 ABI in which floating-point registers | |
27900 | are 64 rather than 32 bits wide. You can select this combination with | |
27901 | @option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1} | |
27902 | and @code{mfhc1} instructions and is therefore only supported for | |
27903 | MIPS32R2, MIPS32R3 and MIPS32R5 processors. | |
27904 | ||
27905 | The register assignments for arguments and return values remain the | |
27906 | same, but each scalar value is passed in a single 64-bit register | |
27907 | rather than a pair of 32-bit registers. For example, scalar | |
27908 | floating-point values are returned in @samp{$f0} only, not a | |
27909 | @samp{$f0}/@samp{$f1} pair. The set of call-saved registers also | |
27910 | remains the same in that the even-numbered double-precision registers | |
27911 | are saved. | |
27912 | ||
27913 | Two additional variants of the o32 ABI are supported to enable | |
27914 | a transition from 32-bit to 64-bit registers. These are FPXX | |
27915 | (@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}). | |
27916 | The FPXX extension mandates that all code must execute correctly | |
27917 | when run using 32-bit or 64-bit registers. The code can be interlinked | |
27918 | with either FP32 or FP64, but not both. | |
27919 | The FP64A extension is similar to the FP64 extension but forbids the | |
27920 | use of odd-numbered single-precision registers. This can be used | |
27921 | in conjunction with the @code{FRE} mode of FPUs in MIPS32R5 | |
27922 | processors and allows both FP32 and FP64A code to interlink and | |
27923 | run in the same process without changing FPU modes. | |
27924 | ||
d77de738 ML |
27925 | @opindex mabicalls |
27926 | @opindex mno-abicalls | |
ddf6fe37 AA |
27927 | @item -mabicalls |
27928 | @itemx -mno-abicalls | |
d77de738 ML |
27929 | Generate (do not generate) code that is suitable for SVR4-style |
27930 | dynamic objects. @option{-mabicalls} is the default for SVR4-based | |
27931 | systems. | |
27932 | ||
27933 | @item -mshared | |
27934 | @itemx -mno-shared | |
27935 | Generate (do not generate) code that is fully position-independent, | |
27936 | and that can therefore be linked into shared libraries. This option | |
27937 | only affects @option{-mabicalls}. | |
27938 | ||
27939 | All @option{-mabicalls} code has traditionally been position-independent, | |
27940 | regardless of options like @option{-fPIC} and @option{-fpic}. However, | |
27941 | as an extension, the GNU toolchain allows executables to use absolute | |
27942 | accesses for locally-binding symbols. It can also use shorter GP | |
27943 | initialization sequences and generate direct calls to locally-defined | |
27944 | functions. This mode is selected by @option{-mno-shared}. | |
27945 | ||
27946 | @option{-mno-shared} depends on binutils 2.16 or higher and generates | |
27947 | objects that can only be linked by the GNU linker. However, the option | |
27948 | does not affect the ABI of the final executable; it only affects the ABI | |
27949 | of relocatable objects. Using @option{-mno-shared} generally makes | |
27950 | executables both smaller and quicker. | |
27951 | ||
27952 | @option{-mshared} is the default. | |
27953 | ||
d77de738 ML |
27954 | @opindex mplt |
27955 | @opindex mno-plt | |
ddf6fe37 AA |
27956 | @item -mplt |
27957 | @itemx -mno-plt | |
d77de738 ML |
27958 | Assume (do not assume) that the static and dynamic linkers |
27959 | support PLTs and copy relocations. This option only affects | |
27960 | @option{-mno-shared -mabicalls}. For the n64 ABI, this option | |
27961 | has no effect without @option{-msym32}. | |
27962 | ||
27963 | You can make @option{-mplt} the default by configuring | |
27964 | GCC with @option{--with-mips-plt}. The default is | |
27965 | @option{-mno-plt} otherwise. | |
27966 | ||
d77de738 ML |
27967 | @opindex mxgot |
27968 | @opindex mno-xgot | |
ddf6fe37 AA |
27969 | @item -mxgot |
27970 | @itemx -mno-xgot | |
d77de738 ML |
27971 | Lift (do not lift) the usual restrictions on the size of the global |
27972 | offset table. | |
27973 | ||
27974 | GCC normally uses a single instruction to load values from the GOT@. | |
27975 | While this is relatively efficient, it only works if the GOT | |
27976 | is smaller than about 64k. Anything larger causes the linker | |
27977 | to report an error such as: | |
27978 | ||
27979 | @cindex relocation truncated to fit (MIPS) | |
27980 | @smallexample | |
27981 | relocation truncated to fit: R_MIPS_GOT16 foobar | |
27982 | @end smallexample | |
27983 | ||
27984 | If this happens, you should recompile your code with @option{-mxgot}. | |
27985 | This works with very large GOTs, although the code is also | |
27986 | less efficient, since it takes three instructions to fetch the | |
27987 | value of a global symbol. | |
27988 | ||
27989 | Note that some linkers can create multiple GOTs. If you have such a | |
27990 | linker, you should only need to use @option{-mxgot} when a single object | |
27991 | file accesses more than 64k's worth of GOT entries. Very few do. | |
27992 | ||
27993 | These options have no effect unless GCC is generating position | |
27994 | independent code. | |
27995 | ||
d77de738 | 27996 | @opindex mgp32 |
ddf6fe37 | 27997 | @item -mgp32 |
d77de738 ML |
27998 | Assume that general-purpose registers are 32 bits wide. |
27999 | ||
d77de738 | 28000 | @opindex mgp64 |
ddf6fe37 | 28001 | @item -mgp64 |
d77de738 ML |
28002 | Assume that general-purpose registers are 64 bits wide. |
28003 | ||
d77de738 | 28004 | @opindex mfp32 |
ddf6fe37 | 28005 | @item -mfp32 |
d77de738 ML |
28006 | Assume that floating-point registers are 32 bits wide. |
28007 | ||
d77de738 | 28008 | @opindex mfp64 |
ddf6fe37 | 28009 | @item -mfp64 |
d77de738 ML |
28010 | Assume that floating-point registers are 64 bits wide. |
28011 | ||
d77de738 | 28012 | @opindex mfpxx |
ddf6fe37 | 28013 | @item -mfpxx |
d77de738 ML |
28014 | Do not assume the width of floating-point registers. |
28015 | ||
d77de738 | 28016 | @opindex mhard-float |
ddf6fe37 | 28017 | @item -mhard-float |
d77de738 ML |
28018 | Use floating-point coprocessor instructions. |
28019 | ||
d77de738 | 28020 | @opindex msoft-float |
ddf6fe37 | 28021 | @item -msoft-float |
d77de738 ML |
28022 | Do not use floating-point coprocessor instructions. Implement |
28023 | floating-point calculations using library calls instead. | |
28024 | ||
d77de738 | 28025 | @opindex mno-float |
ddf6fe37 | 28026 | @item -mno-float |
d77de738 ML |
28027 | Equivalent to @option{-msoft-float}, but additionally asserts that the |
28028 | program being compiled does not perform any floating-point operations. | |
28029 | This option is presently supported only by some bare-metal MIPS | |
28030 | configurations, where it may select a special set of libraries | |
28031 | that lack all floating-point support (including, for example, the | |
28032 | floating-point @code{printf} formats). | |
28033 | If code compiled with @option{-mno-float} accidentally contains | |
28034 | floating-point operations, it is likely to suffer a link-time | |
28035 | or run-time failure. | |
28036 | ||
d77de738 | 28037 | @opindex msingle-float |
ddf6fe37 | 28038 | @item -msingle-float |
d77de738 ML |
28039 | Assume that the floating-point coprocessor only supports single-precision |
28040 | operations. | |
28041 | ||
d77de738 | 28042 | @opindex mdouble-float |
ddf6fe37 | 28043 | @item -mdouble-float |
d77de738 ML |
28044 | Assume that the floating-point coprocessor supports double-precision |
28045 | operations. This is the default. | |
28046 | ||
d77de738 ML |
28047 | @opindex modd-spreg |
28048 | @opindex mno-odd-spreg | |
ddf6fe37 AA |
28049 | @item -modd-spreg |
28050 | @itemx -mno-odd-spreg | |
d77de738 ML |
28051 | Enable the use of odd-numbered single-precision floating-point registers |
28052 | for the o32 ABI. This is the default for processors that are known to | |
28053 | support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg} | |
28054 | is set by default. | |
28055 | ||
d77de738 ML |
28056 | @opindex mabs=2008 |
28057 | @opindex mabs=legacy | |
ddf6fe37 AA |
28058 | @item -mabs=2008 |
28059 | @itemx -mabs=legacy | |
d77de738 ML |
28060 | These options control the treatment of the special not-a-number (NaN) |
28061 | IEEE 754 floating-point data with the @code{abs.@i{fmt}} and | |
28062 | @code{neg.@i{fmt}} machine instructions. | |
28063 | ||
28064 | By default or when @option{-mabs=legacy} is used the legacy | |
28065 | treatment is selected. In this case these instructions are considered | |
28066 | arithmetic and avoided where correct operation is required and the | |
28067 | input operand might be a NaN. A longer sequence of instructions that | |
28068 | manipulate the sign bit of floating-point datum manually is used | |
28069 | instead unless the @option{-ffinite-math-only} option has also been | |
28070 | specified. | |
28071 | ||
28072 | The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In | |
28073 | this case these instructions are considered non-arithmetic and therefore | |
28074 | operating correctly in all cases, including in particular where the | |
28075 | input operand is a NaN. These instructions are therefore always used | |
28076 | for the respective operations. | |
28077 | ||
d77de738 ML |
28078 | @opindex mnan=2008 |
28079 | @opindex mnan=legacy | |
ddf6fe37 AA |
28080 | @item -mnan=2008 |
28081 | @itemx -mnan=legacy | |
d77de738 ML |
28082 | These options control the encoding of the special not-a-number (NaN) |
28083 | IEEE 754 floating-point data. | |
28084 | ||
28085 | The @option{-mnan=legacy} option selects the legacy encoding. In this | |
28086 | case quiet NaNs (qNaNs) are denoted by the first bit of their trailing | |
28087 | significand field being 0, whereas signaling NaNs (sNaNs) are denoted | |
28088 | by the first bit of their trailing significand field being 1. | |
28089 | ||
28090 | The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In | |
28091 | this case qNaNs are denoted by the first bit of their trailing | |
28092 | significand field being 1, whereas sNaNs are denoted by the first bit of | |
28093 | their trailing significand field being 0. | |
28094 | ||
28095 | The default is @option{-mnan=legacy} unless GCC has been configured with | |
28096 | @option{--with-nan=2008}. | |
28097 | ||
d77de738 ML |
28098 | @opindex mllsc |
28099 | @opindex mno-llsc | |
ddf6fe37 AA |
28100 | @item -mllsc |
28101 | @itemx -mno-llsc | |
d77de738 ML |
28102 | Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to |
28103 | implement atomic memory built-in functions. When neither option is | |
28104 | specified, GCC uses the instructions if the target architecture | |
28105 | supports them. | |
28106 | ||
28107 | @option{-mllsc} is useful if the runtime environment can emulate the | |
28108 | instructions and @option{-mno-llsc} can be useful when compiling for | |
28109 | nonstandard ISAs. You can make either option the default by | |
28110 | configuring GCC with @option{--with-llsc} and @option{--without-llsc} | |
28111 | respectively. @option{--with-llsc} is the default for some | |
28112 | configurations; see the installation documentation for details. | |
28113 | ||
d77de738 ML |
28114 | @opindex mdsp |
28115 | @opindex mno-dsp | |
ddf6fe37 AA |
28116 | @item -mdsp |
28117 | @itemx -mno-dsp | |
d77de738 ML |
28118 | Use (do not use) revision 1 of the MIPS DSP ASE@. |
28119 | @xref{MIPS DSP Built-in Functions}. This option defines the | |
28120 | preprocessor macro @code{__mips_dsp}. It also defines | |
28121 | @code{__mips_dsp_rev} to 1. | |
28122 | ||
d77de738 ML |
28123 | @opindex mdspr2 |
28124 | @opindex mno-dspr2 | |
ddf6fe37 AA |
28125 | @item -mdspr2 |
28126 | @itemx -mno-dspr2 | |
d77de738 ML |
28127 | Use (do not use) revision 2 of the MIPS DSP ASE@. |
28128 | @xref{MIPS DSP Built-in Functions}. This option defines the | |
28129 | preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}. | |
28130 | It also defines @code{__mips_dsp_rev} to 2. | |
28131 | ||
d77de738 ML |
28132 | @opindex msmartmips |
28133 | @opindex mno-smartmips | |
ddf6fe37 AA |
28134 | @item -msmartmips |
28135 | @itemx -mno-smartmips | |
d77de738 ML |
28136 | Use (do not use) the MIPS SmartMIPS ASE. |
28137 | ||
d77de738 ML |
28138 | @opindex mpaired-single |
28139 | @opindex mno-paired-single | |
ddf6fe37 AA |
28140 | @item -mpaired-single |
28141 | @itemx -mno-paired-single | |
d77de738 ML |
28142 | Use (do not use) paired-single floating-point instructions. |
28143 | @xref{MIPS Paired-Single Support}. This option requires | |
28144 | hardware floating-point support to be enabled. | |
28145 | ||
d77de738 ML |
28146 | @opindex mdmx |
28147 | @opindex mno-mdmx | |
ddf6fe37 AA |
28148 | @item -mdmx |
28149 | @itemx -mno-mdmx | |
d77de738 ML |
28150 | Use (do not use) MIPS Digital Media Extension instructions. |
28151 | This option can only be used when generating 64-bit code and requires | |
28152 | hardware floating-point support to be enabled. | |
28153 | ||
d77de738 ML |
28154 | @opindex mips3d |
28155 | @opindex mno-mips3d | |
ddf6fe37 AA |
28156 | @item -mips3d |
28157 | @itemx -mno-mips3d | |
d77de738 ML |
28158 | Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}. |
28159 | The option @option{-mips3d} implies @option{-mpaired-single}. | |
28160 | ||
d77de738 ML |
28161 | @opindex mmicromips |
28162 | @opindex mno-mmicromips | |
ddf6fe37 AA |
28163 | @item -mmicromips |
28164 | @itemx -mno-micromips | |
d77de738 ML |
28165 | Generate (do not generate) microMIPS code. |
28166 | ||
28167 | MicroMIPS code generation can also be controlled on a per-function basis | |
28168 | by means of @code{micromips} and @code{nomicromips} attributes. | |
28169 | @xref{Function Attributes}, for more information. | |
28170 | ||
d77de738 ML |
28171 | @opindex mmt |
28172 | @opindex mno-mt | |
ddf6fe37 AA |
28173 | @item -mmt |
28174 | @itemx -mno-mt | |
d77de738 ML |
28175 | Use (do not use) MT Multithreading instructions. |
28176 | ||
d77de738 ML |
28177 | @opindex mmcu |
28178 | @opindex mno-mcu | |
ddf6fe37 AA |
28179 | @item -mmcu |
28180 | @itemx -mno-mcu | |
d77de738 ML |
28181 | Use (do not use) the MIPS MCU ASE instructions. |
28182 | ||
d77de738 ML |
28183 | @opindex meva |
28184 | @opindex mno-eva | |
ddf6fe37 AA |
28185 | @item -meva |
28186 | @itemx -mno-eva | |
d77de738 ML |
28187 | Use (do not use) the MIPS Enhanced Virtual Addressing instructions. |
28188 | ||
d77de738 ML |
28189 | @opindex mvirt |
28190 | @opindex mno-virt | |
ddf6fe37 AA |
28191 | @item -mvirt |
28192 | @itemx -mno-virt | |
d77de738 ML |
28193 | Use (do not use) the MIPS Virtualization (VZ) instructions. |
28194 | ||
d77de738 ML |
28195 | @opindex mxpa |
28196 | @opindex mno-xpa | |
ddf6fe37 AA |
28197 | @item -mxpa |
28198 | @itemx -mno-xpa | |
d77de738 ML |
28199 | Use (do not use) the MIPS eXtended Physical Address (XPA) instructions. |
28200 | ||
d77de738 ML |
28201 | @opindex mcrc |
28202 | @opindex mno-crc | |
ddf6fe37 AA |
28203 | @item -mcrc |
28204 | @itemx -mno-crc | |
d77de738 ML |
28205 | Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions. |
28206 | ||
d77de738 ML |
28207 | @opindex mginv |
28208 | @opindex mno-ginv | |
ddf6fe37 AA |
28209 | @item -mginv |
28210 | @itemx -mno-ginv | |
d77de738 ML |
28211 | Use (do not use) the MIPS Global INValidate (GINV) instructions. |
28212 | ||
d77de738 ML |
28213 | @opindex mloongson-mmi |
28214 | @opindex mno-loongson-mmi | |
ddf6fe37 AA |
28215 | @item -mloongson-mmi |
28216 | @itemx -mno-loongson-mmi | |
d77de738 ML |
28217 | Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI). |
28218 | ||
d77de738 ML |
28219 | @opindex mloongson-ext |
28220 | @opindex mno-loongson-ext | |
ddf6fe37 AA |
28221 | @item -mloongson-ext |
28222 | @itemx -mno-loongson-ext | |
d77de738 ML |
28223 | Use (do not use) the MIPS Loongson EXTensions (EXT) instructions. |
28224 | ||
d77de738 ML |
28225 | @opindex mloongson-ext2 |
28226 | @opindex mno-loongson-ext2 | |
ddf6fe37 AA |
28227 | @item -mloongson-ext2 |
28228 | @itemx -mno-loongson-ext2 | |
d77de738 ML |
28229 | Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions. |
28230 | ||
d77de738 | 28231 | @opindex mlong64 |
ddf6fe37 | 28232 | @item -mlong64 |
d77de738 ML |
28233 | Force @code{long} types to be 64 bits wide. See @option{-mlong32} for |
28234 | an explanation of the default and the way that the pointer size is | |
28235 | determined. | |
28236 | ||
d77de738 | 28237 | @opindex mlong32 |
ddf6fe37 | 28238 | @item -mlong32 |
d77de738 ML |
28239 | Force @code{long}, @code{int}, and pointer types to be 32 bits wide. |
28240 | ||
28241 | The default size of @code{int}s, @code{long}s and pointers depends on | |
28242 | the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI | |
28243 | uses 64-bit @code{long}s, as does the 64-bit EABI; the others use | |
28244 | 32-bit @code{long}s. Pointers are the same size as @code{long}s, | |
28245 | or the same size as integer registers, whichever is smaller. | |
28246 | ||
d77de738 ML |
28247 | @opindex msym32 |
28248 | @opindex mno-sym32 | |
ddf6fe37 AA |
28249 | @item -msym32 |
28250 | @itemx -mno-sym32 | |
d77de738 ML |
28251 | Assume (do not assume) that all symbols have 32-bit values, regardless |
28252 | of the selected ABI@. This option is useful in combination with | |
28253 | @option{-mabi=64} and @option{-mno-abicalls} because it allows GCC | |
28254 | to generate shorter and faster references to symbolic addresses. | |
28255 | ||
d77de738 | 28256 | @opindex G |
ddf6fe37 | 28257 | @item -G @var{num} |
d77de738 ML |
28258 | Put definitions of externally-visible data in a small data section |
28259 | if that data is no bigger than @var{num} bytes. GCC can then generate | |
28260 | more efficient accesses to the data; see @option{-mgpopt} for details. | |
28261 | ||
28262 | The default @option{-G} option depends on the configuration. | |
28263 | ||
d77de738 ML |
28264 | @opindex mlocal-sdata |
28265 | @opindex mno-local-sdata | |
ddf6fe37 AA |
28266 | @item -mlocal-sdata |
28267 | @itemx -mno-local-sdata | |
d77de738 ML |
28268 | Extend (do not extend) the @option{-G} behavior to local data too, |
28269 | such as to static variables in C@. @option{-mlocal-sdata} is the | |
28270 | default for all configurations. | |
28271 | ||
28272 | If the linker complains that an application is using too much small data, | |
28273 | you might want to try rebuilding the less performance-critical parts with | |
28274 | @option{-mno-local-sdata}. You might also want to build large | |
28275 | libraries with @option{-mno-local-sdata}, so that the libraries leave | |
28276 | more room for the main program. | |
28277 | ||
d77de738 ML |
28278 | @opindex mextern-sdata |
28279 | @opindex mno-extern-sdata | |
ddf6fe37 AA |
28280 | @item -mextern-sdata |
28281 | @itemx -mno-extern-sdata | |
d77de738 ML |
28282 | Assume (do not assume) that externally-defined data is in |
28283 | a small data section if the size of that data is within the @option{-G} limit. | |
28284 | @option{-mextern-sdata} is the default for all configurations. | |
28285 | ||
28286 | If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G | |
28287 | @var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var} | |
28288 | that is no bigger than @var{num} bytes, you must make sure that @var{Var} | |
28289 | is placed in a small data section. If @var{Var} is defined by another | |
28290 | module, you must either compile that module with a high-enough | |
28291 | @option{-G} setting or attach a @code{section} attribute to @var{Var}'s | |
28292 | definition. If @var{Var} is common, you must link the application | |
28293 | with a high-enough @option{-G} setting. | |
28294 | ||
28295 | The easiest way of satisfying these restrictions is to compile | |
28296 | and link every module with the same @option{-G} option. However, | |
28297 | you may wish to build a library that supports several different | |
28298 | small data limits. You can do this by compiling the library with | |
28299 | the highest supported @option{-G} setting and additionally using | |
28300 | @option{-mno-extern-sdata} to stop the library from making assumptions | |
28301 | about externally-defined data. | |
28302 | ||
d77de738 ML |
28303 | @opindex mgpopt |
28304 | @opindex mno-gpopt | |
ddf6fe37 AA |
28305 | @item -mgpopt |
28306 | @itemx -mno-gpopt | |
d77de738 ML |
28307 | Use (do not use) GP-relative accesses for symbols that are known to be |
28308 | in a small data section; see @option{-G}, @option{-mlocal-sdata} and | |
28309 | @option{-mextern-sdata}. @option{-mgpopt} is the default for all | |
28310 | configurations. | |
28311 | ||
28312 | @option{-mno-gpopt} is useful for cases where the @code{$gp} register | |
28313 | might not hold the value of @code{_gp}. For example, if the code is | |
28314 | part of a library that might be used in a boot monitor, programs that | |
28315 | call boot monitor routines pass an unknown value in @code{$gp}. | |
28316 | (In such situations, the boot monitor itself is usually compiled | |
28317 | with @option{-G0}.) | |
28318 | ||
28319 | @option{-mno-gpopt} implies @option{-mno-local-sdata} and | |
28320 | @option{-mno-extern-sdata}. | |
28321 | ||
d77de738 ML |
28322 | @opindex membedded-data |
28323 | @opindex mno-embedded-data | |
ddf6fe37 AA |
28324 | @item -membedded-data |
28325 | @itemx -mno-embedded-data | |
d77de738 ML |
28326 | Allocate variables to the read-only data section first if possible, then |
28327 | next in the small data section if possible, otherwise in data. This gives | |
28328 | slightly slower code than the default, but reduces the amount of RAM required | |
28329 | when executing, and thus may be preferred for some embedded systems. | |
28330 | ||
d77de738 ML |
28331 | @opindex muninit-const-in-rodata |
28332 | @opindex mno-uninit-const-in-rodata | |
ddf6fe37 AA |
28333 | @item -muninit-const-in-rodata |
28334 | @itemx -mno-uninit-const-in-rodata | |
d77de738 ML |
28335 | Put uninitialized @code{const} variables in the read-only data section. |
28336 | This option is only meaningful in conjunction with @option{-membedded-data}. | |
28337 | ||
d77de738 | 28338 | @opindex mcode-readable |
ddf6fe37 | 28339 | @item -mcode-readable=@var{setting} |
d77de738 ML |
28340 | Specify whether GCC may generate code that reads from executable sections. |
28341 | There are three possible settings: | |
28342 | ||
28343 | @table @gcctabopt | |
28344 | @item -mcode-readable=yes | |
28345 | Instructions may freely access executable sections. This is the | |
28346 | default setting. | |
28347 | ||
28348 | @item -mcode-readable=pcrel | |
28349 | MIPS16 PC-relative load instructions can access executable sections, | |
28350 | but other instructions must not do so. This option is useful on 4KSc | |
28351 | and 4KSd processors when the code TLBs have the Read Inhibit bit set. | |
28352 | It is also useful on processors that can be configured to have a dual | |
28353 | instruction/data SRAM interface and that, like the M4K, automatically | |
28354 | redirect PC-relative loads to the instruction RAM. | |
28355 | ||
28356 | @item -mcode-readable=no | |
28357 | Instructions must not access executable sections. This option can be | |
28358 | useful on targets that are configured to have a dual instruction/data | |
28359 | SRAM interface but that (unlike the M4K) do not automatically redirect | |
28360 | PC-relative loads to the instruction RAM. | |
28361 | @end table | |
28362 | ||
d77de738 ML |
28363 | @opindex msplit-addresses |
28364 | @opindex mno-split-addresses | |
ddf6fe37 AA |
28365 | @item -msplit-addresses |
28366 | @itemx -mno-split-addresses | |
d77de738 ML |
28367 | Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler |
28368 | relocation operators. This option has been superseded by | |
28369 | @option{-mexplicit-relocs} but is retained for backwards compatibility. | |
28370 | ||
d77de738 ML |
28371 | @opindex mexplicit-relocs |
28372 | @opindex mno-explicit-relocs | |
ddf6fe37 AA |
28373 | @item -mexplicit-relocs |
28374 | @itemx -mno-explicit-relocs | |
d77de738 ML |
28375 | Use (do not use) assembler relocation operators when dealing with symbolic |
28376 | addresses. The alternative, selected by @option{-mno-explicit-relocs}, | |
28377 | is to use assembler macros instead. | |
28378 | ||
28379 | @option{-mexplicit-relocs} is the default if GCC was configured | |
28380 | to use an assembler that supports relocation operators. | |
28381 | ||
d77de738 ML |
28382 | @opindex mcheck-zero-division |
28383 | @opindex mno-check-zero-division | |
ddf6fe37 AA |
28384 | @item -mcheck-zero-division |
28385 | @itemx -mno-check-zero-division | |
d77de738 ML |
28386 | Trap (do not trap) on integer division by zero. |
28387 | ||
28388 | The default is @option{-mcheck-zero-division}. | |
28389 | ||
d77de738 ML |
28390 | @opindex mdivide-traps |
28391 | @opindex mdivide-breaks | |
ddf6fe37 AA |
28392 | @item -mdivide-traps |
28393 | @itemx -mdivide-breaks | |
d77de738 ML |
28394 | MIPS systems check for division by zero by generating either a |
28395 | conditional trap or a break instruction. Using traps results in | |
28396 | smaller code, but is only supported on MIPS II and later. Also, some | |
28397 | versions of the Linux kernel have a bug that prevents trap from | |
28398 | generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to | |
28399 | allow conditional traps on architectures that support them and | |
28400 | @option{-mdivide-breaks} to force the use of breaks. | |
28401 | ||
28402 | The default is usually @option{-mdivide-traps}, but this can be | |
28403 | overridden at configure time using @option{--with-divide=breaks}. | |
28404 | Divide-by-zero checks can be completely disabled using | |
28405 | @option{-mno-check-zero-division}. | |
28406 | ||
d77de738 ML |
28407 | @opindex mload-store-pairs |
28408 | @opindex mno-load-store-pairs | |
ddf6fe37 AA |
28409 | @item -mload-store-pairs |
28410 | @itemx -mno-load-store-pairs | |
d77de738 ML |
28411 | Enable (disable) an optimization that pairs consecutive load or store |
28412 | instructions to enable load/store bonding. This option is enabled by | |
28413 | default but only takes effect when the selected architecture is known | |
28414 | to support bonding. | |
28415 | ||
d77de738 ML |
28416 | @opindex munaligned-access |
28417 | @opindex mno-unaligned-access | |
ddf6fe37 AA |
28418 | @item -munaligned-access |
28419 | @itemx -mno-unaligned-access | |
d77de738 ML |
28420 | Enable (disable) direct unaligned access for MIPS Release 6. |
28421 | MIPSr6 requires load/store unaligned-access support, | |
28422 | by hardware or trap&emulate. | |
28423 | So @option{-mno-unaligned-access} may be needed by kernel. | |
28424 | ||
d77de738 ML |
28425 | @opindex mmemcpy |
28426 | @opindex mno-memcpy | |
ddf6fe37 AA |
28427 | @item -mmemcpy |
28428 | @itemx -mno-memcpy | |
d77de738 ML |
28429 | Force (do not force) the use of @code{memcpy} for non-trivial block |
28430 | moves. The default is @option{-mno-memcpy}, which allows GCC to inline | |
28431 | most constant-sized copies. | |
28432 | ||
d77de738 ML |
28433 | @opindex mlong-calls |
28434 | @opindex mno-long-calls | |
ddf6fe37 AA |
28435 | @item -mlong-calls |
28436 | @itemx -mno-long-calls | |
d77de738 ML |
28437 | Disable (do not disable) use of the @code{jal} instruction. Calling |
28438 | functions using @code{jal} is more efficient but requires the caller | |
28439 | and callee to be in the same 256 megabyte segment. | |
28440 | ||
28441 | This option has no effect on abicalls code. The default is | |
28442 | @option{-mno-long-calls}. | |
28443 | ||
d77de738 ML |
28444 | @opindex mmad |
28445 | @opindex mno-mad | |
ddf6fe37 AA |
28446 | @item -mmad |
28447 | @itemx -mno-mad | |
d77de738 ML |
28448 | Enable (disable) use of the @code{mad}, @code{madu} and @code{mul} |
28449 | instructions, as provided by the R4650 ISA@. | |
28450 | ||
d77de738 ML |
28451 | @opindex mimadd |
28452 | @opindex mno-imadd | |
ddf6fe37 AA |
28453 | @item -mimadd |
28454 | @itemx -mno-imadd | |
d77de738 ML |
28455 | Enable (disable) use of the @code{madd} and @code{msub} integer |
28456 | instructions. The default is @option{-mimadd} on architectures | |
28457 | that support @code{madd} and @code{msub} except for the 74k | |
28458 | architecture where it was found to generate slower code. | |
28459 | ||
d77de738 ML |
28460 | @opindex mfused-madd |
28461 | @opindex mno-fused-madd | |
ddf6fe37 AA |
28462 | @item -mfused-madd |
28463 | @itemx -mno-fused-madd | |
d77de738 ML |
28464 | Enable (disable) use of the floating-point multiply-accumulate |
28465 | instructions, when they are available. The default is | |
28466 | @option{-mfused-madd}. | |
28467 | ||
28468 | On the R8000 CPU when multiply-accumulate instructions are used, | |
28469 | the intermediate product is calculated to infinite precision | |
28470 | and is not subject to the FCSR Flush to Zero bit. This may be | |
28471 | undesirable in some circumstances. On other processors the result | |
28472 | is numerically identical to the equivalent computation using | |
28473 | separate multiply, add, subtract and negate instructions. | |
28474 | ||
d77de738 | 28475 | @opindex nocpp |
ddf6fe37 | 28476 | @item -nocpp |
d77de738 ML |
28477 | Tell the MIPS assembler to not run its preprocessor over user |
28478 | assembler files (with a @samp{.s} suffix) when assembling them. | |
28479 | ||
d77de738 ML |
28480 | @opindex mfix-24k |
28481 | @opindex mno-fix-24k | |
ddf6fe37 AA |
28482 | @item -mfix-24k |
28483 | @itemx -mno-fix-24k | |
d77de738 ML |
28484 | Work around the 24K E48 (lost data on stores during refill) errata. |
28485 | The workarounds are implemented by the assembler rather than by GCC@. | |
28486 | ||
d77de738 ML |
28487 | @opindex mfix-r4000 |
28488 | @opindex mno-fix-r4000 | |
ddf6fe37 AA |
28489 | @item -mfix-r4000 |
28490 | @itemx -mno-fix-r4000 | |
d77de738 ML |
28491 | Work around certain R4000 CPU errata: |
28492 | @itemize @minus | |
28493 | @item | |
28494 | A double-word or a variable shift may give an incorrect result if executed | |
28495 | immediately after starting an integer division. | |
28496 | @item | |
28497 | A double-word or a variable shift may give an incorrect result if executed | |
28498 | while an integer multiplication is in progress. | |
28499 | @item | |
28500 | An integer division may give an incorrect result if started in a delay slot | |
28501 | of a taken branch or a jump. | |
28502 | @end itemize | |
28503 | ||
d77de738 ML |
28504 | @opindex mfix-r4400 |
28505 | @opindex mno-fix-r4400 | |
ddf6fe37 AA |
28506 | @item -mfix-r4400 |
28507 | @itemx -mno-fix-r4400 | |
d77de738 ML |
28508 | Work around certain R4400 CPU errata: |
28509 | @itemize @minus | |
28510 | @item | |
28511 | A double-word or a variable shift may give an incorrect result if executed | |
28512 | immediately after starting an integer division. | |
28513 | @end itemize | |
28514 | ||
d77de738 ML |
28515 | @opindex mfix-r10000 |
28516 | @opindex mno-fix-r10000 | |
ddf6fe37 AA |
28517 | @item -mfix-r10000 |
28518 | @itemx -mno-fix-r10000 | |
d77de738 ML |
28519 | Work around certain R10000 errata: |
28520 | @itemize @minus | |
28521 | @item | |
28522 | @code{ll}/@code{sc} sequences may not behave atomically on revisions | |
28523 | prior to 3.0. They may deadlock on revisions 2.6 and earlier. | |
28524 | @end itemize | |
28525 | ||
28526 | This option can only be used if the target architecture supports | |
28527 | branch-likely instructions. @option{-mfix-r10000} is the default when | |
28528 | @option{-march=r10000} is used; @option{-mno-fix-r10000} is the default | |
28529 | otherwise. | |
28530 | ||
ddf6fe37 | 28531 | @opindex mfix-r5900 |
d77de738 ML |
28532 | @item -mfix-r5900 |
28533 | @itemx -mno-fix-r5900 | |
d77de738 ML |
28534 | Do not attempt to schedule the preceding instruction into the delay slot |
28535 | of a branch instruction placed at the end of a short loop of six | |
28536 | instructions or fewer and always schedule a @code{nop} instruction there | |
28537 | instead. The short loop bug under certain conditions causes loops to | |
28538 | execute only once or twice, due to a hardware bug in the R5900 chip. The | |
28539 | workaround is implemented by the assembler rather than by GCC@. | |
28540 | ||
ddf6fe37 | 28541 | @opindex mfix-rm7000 |
d77de738 ML |
28542 | @item -mfix-rm7000 |
28543 | @itemx -mno-fix-rm7000 | |
d77de738 ML |
28544 | Work around the RM7000 @code{dmult}/@code{dmultu} errata. The |
28545 | workarounds are implemented by the assembler rather than by GCC@. | |
28546 | ||
ddf6fe37 | 28547 | @opindex mfix-vr4120 |
d77de738 ML |
28548 | @item -mfix-vr4120 |
28549 | @itemx -mno-fix-vr4120 | |
d77de738 ML |
28550 | Work around certain VR4120 errata: |
28551 | @itemize @minus | |
28552 | @item | |
28553 | @code{dmultu} does not always produce the correct result. | |
28554 | @item | |
28555 | @code{div} and @code{ddiv} do not always produce the correct result if one | |
28556 | of the operands is negative. | |
28557 | @end itemize | |
28558 | The workarounds for the division errata rely on special functions in | |
28559 | @file{libgcc.a}. At present, these functions are only provided by | |
28560 | the @code{mips64vr*-elf} configurations. | |
28561 | ||
28562 | Other VR4120 errata require a NOP to be inserted between certain pairs of | |
28563 | instructions. These errata are handled by the assembler, not by GCC itself. | |
28564 | ||
d77de738 | 28565 | @opindex mfix-vr4130 |
ddf6fe37 | 28566 | @item -mfix-vr4130 |
d77de738 ML |
28567 | Work around the VR4130 @code{mflo}/@code{mfhi} errata. The |
28568 | workarounds are implemented by the assembler rather than by GCC, | |
28569 | although GCC avoids using @code{mflo} and @code{mfhi} if the | |
28570 | VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi} | |
28571 | instructions are available instead. | |
28572 | ||
ddf6fe37 | 28573 | @opindex mfix-sb1 |
d77de738 ML |
28574 | @item -mfix-sb1 |
28575 | @itemx -mno-fix-sb1 | |
d77de738 ML |
28576 | Work around certain SB-1 CPU core errata. |
28577 | (This flag currently works around the SB-1 revision 2 | |
28578 | ``F1'' and ``F2'' floating-point errata.) | |
28579 | ||
d77de738 | 28580 | @opindex mr10k-cache-barrier |
ddf6fe37 | 28581 | @item -mr10k-cache-barrier=@var{setting} |
d77de738 ML |
28582 | Specify whether GCC should insert cache barriers to avoid the |
28583 | side effects of speculation on R10K processors. | |
28584 | ||
28585 | In common with many processors, the R10K tries to predict the outcome | |
28586 | of a conditional branch and speculatively executes instructions from | |
28587 | the ``taken'' branch. It later aborts these instructions if the | |
28588 | predicted outcome is wrong. However, on the R10K, even aborted | |
28589 | instructions can have side effects. | |
28590 | ||
28591 | This problem only affects kernel stores and, depending on the system, | |
28592 | kernel loads. As an example, a speculatively-executed store may load | |
28593 | the target memory into cache and mark the cache line as dirty, even if | |
28594 | the store itself is later aborted. If a DMA operation writes to the | |
28595 | same area of memory before the ``dirty'' line is flushed, the cached | |
28596 | data overwrites the DMA-ed data. See the R10K processor manual | |
28597 | for a full description, including other potential problems. | |
28598 | ||
28599 | One workaround is to insert cache barrier instructions before every memory | |
28600 | access that might be speculatively executed and that might have side | |
28601 | effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}} | |
28602 | controls GCC's implementation of this workaround. It assumes that | |
28603 | aborted accesses to any byte in the following regions does not have | |
28604 | side effects: | |
28605 | ||
28606 | @enumerate | |
28607 | @item | |
28608 | the memory occupied by the current function's stack frame; | |
28609 | ||
28610 | @item | |
28611 | the memory occupied by an incoming stack argument; | |
28612 | ||
28613 | @item | |
28614 | the memory occupied by an object with a link-time-constant address. | |
28615 | @end enumerate | |
28616 | ||
28617 | It is the kernel's responsibility to ensure that speculative | |
28618 | accesses to these regions are indeed safe. | |
28619 | ||
28620 | If the input program contains a function declaration such as: | |
28621 | ||
28622 | @smallexample | |
28623 | void foo (void); | |
28624 | @end smallexample | |
28625 | ||
28626 | then the implementation of @code{foo} must allow @code{j foo} and | |
28627 | @code{jal foo} to be executed speculatively. GCC honors this | |
28628 | restriction for functions it compiles itself. It expects non-GCC | |
28629 | functions (such as hand-written assembly code) to do the same. | |
28630 | ||
28631 | The option has three forms: | |
28632 | ||
28633 | @table @gcctabopt | |
28634 | @item -mr10k-cache-barrier=load-store | |
28635 | Insert a cache barrier before a load or store that might be | |
28636 | speculatively executed and that might have side effects even | |
28637 | if aborted. | |
28638 | ||
28639 | @item -mr10k-cache-barrier=store | |
28640 | Insert a cache barrier before a store that might be speculatively | |
28641 | executed and that might have side effects even if aborted. | |
28642 | ||
28643 | @item -mr10k-cache-barrier=none | |
28644 | Disable the insertion of cache barriers. This is the default setting. | |
28645 | @end table | |
28646 | ||
ddf6fe37 | 28647 | @opindex mflush-func |
d77de738 ML |
28648 | @item -mflush-func=@var{func} |
28649 | @itemx -mno-flush-func | |
d77de738 ML |
28650 | Specifies the function to call to flush the I and D caches, or to not |
28651 | call any such function. If called, the function must take the same | |
28652 | arguments as the common @code{_flush_func}, that is, the address of the | |
28653 | memory range for which the cache is being flushed, the size of the | |
28654 | memory range, and the number 3 (to flush both caches). The default | |
28655 | depends on the target GCC was configured for, but commonly is either | |
28656 | @code{_flush_func} or @code{__cpu_flush}. | |
28657 | ||
d77de738 | 28658 | @opindex mbranch-cost |
ddf6fe37 | 28659 | @item mbranch-cost=@var{num} |
d77de738 ML |
28660 | Set the cost of branches to roughly @var{num} ``simple'' instructions. |
28661 | This cost is only a heuristic and is not guaranteed to produce | |
28662 | consistent results across releases. A zero cost redundantly selects | |
28663 | the default, which is based on the @option{-mtune} setting. | |
28664 | ||
d77de738 ML |
28665 | @opindex mbranch-likely |
28666 | @opindex mno-branch-likely | |
ddf6fe37 AA |
28667 | @item -mbranch-likely |
28668 | @itemx -mno-branch-likely | |
d77de738 ML |
28669 | Enable or disable use of Branch Likely instructions, regardless of the |
28670 | default for the selected architecture. By default, Branch Likely | |
28671 | instructions may be generated if they are supported by the selected | |
28672 | architecture. An exception is for the MIPS32 and MIPS64 architectures | |
28673 | and processors that implement those architectures; for those, Branch | |
28674 | Likely instructions are not be generated by default because the MIPS32 | |
28675 | and MIPS64 architectures specifically deprecate their use. | |
28676 | ||
d77de738 ML |
28677 | @opindex mcompact-branches=never |
28678 | @opindex mcompact-branches=optimal | |
28679 | @opindex mcompact-branches=always | |
ddf6fe37 AA |
28680 | @item -mcompact-branches=never |
28681 | @itemx -mcompact-branches=optimal | |
28682 | @itemx -mcompact-branches=always | |
d77de738 ML |
28683 | These options control which form of branches will be generated. The |
28684 | default is @option{-mcompact-branches=optimal}. | |
28685 | ||
28686 | The @option{-mcompact-branches=never} option ensures that compact branch | |
28687 | instructions will never be generated. | |
28688 | ||
28689 | The @option{-mcompact-branches=always} option ensures that a compact | |
28690 | branch instruction will be generated if available for MIPS Release 6 onwards. | |
28691 | If a compact branch instruction is not available (or pre-R6), | |
28692 | a delay slot form of the branch will be used instead. | |
28693 | ||
28694 | If it is used for MIPS16/microMIPS targets, it will be just ignored now. | |
28695 | The behaviour for MIPS16/microMIPS may change in future, | |
28696 | since they do have some compact branch instructions. | |
28697 | ||
28698 | The @option{-mcompact-branches=optimal} option will cause a delay slot | |
28699 | branch to be used if one is available in the current ISA and the delay | |
28700 | slot is successfully filled. If the delay slot is not filled, a compact | |
28701 | branch will be chosen if one is available. | |
28702 | ||
ddf6fe37 | 28703 | @opindex mfp-exceptions |
d77de738 ML |
28704 | @item -mfp-exceptions |
28705 | @itemx -mno-fp-exceptions | |
d77de738 ML |
28706 | Specifies whether FP exceptions are enabled. This affects how |
28707 | FP instructions are scheduled for some processors. | |
28708 | The default is that FP exceptions are | |
28709 | enabled. | |
28710 | ||
28711 | For instance, on the SB-1, if FP exceptions are disabled, and we are emitting | |
28712 | 64-bit code, then we can use both FP pipes. Otherwise, we can only use one | |
28713 | FP pipe. | |
28714 | ||
ddf6fe37 | 28715 | @opindex mvr4130-align |
d77de738 ML |
28716 | @item -mvr4130-align |
28717 | @itemx -mno-vr4130-align | |
d77de738 ML |
28718 | The VR4130 pipeline is two-way superscalar, but can only issue two |
28719 | instructions together if the first one is 8-byte aligned. When this | |
28720 | option is enabled, GCC aligns pairs of instructions that it | |
28721 | thinks should execute in parallel. | |
28722 | ||
28723 | This option only has an effect when optimizing for the VR4130. | |
28724 | It normally makes code faster, but at the expense of making it bigger. | |
28725 | It is enabled by default at optimization level @option{-O3}. | |
28726 | ||
ddf6fe37 | 28727 | @opindex msynci |
d77de738 ML |
28728 | @item -msynci |
28729 | @itemx -mno-synci | |
d77de738 ML |
28730 | Enable (disable) generation of @code{synci} instructions on |
28731 | architectures that support it. The @code{synci} instructions (if | |
28732 | enabled) are generated when @code{__builtin___clear_cache} is | |
28733 | compiled. | |
28734 | ||
28735 | This option defaults to @option{-mno-synci}, but the default can be | |
28736 | overridden by configuring GCC with @option{--with-synci}. | |
28737 | ||
28738 | When compiling code for single processor systems, it is generally safe | |
28739 | to use @code{synci}. However, on many multi-core (SMP) systems, it | |
28740 | does not invalidate the instruction caches on all cores and may lead | |
28741 | to undefined behavior. | |
28742 | ||
ddf6fe37 | 28743 | @opindex mrelax-pic-calls |
d77de738 ML |
28744 | @item -mrelax-pic-calls |
28745 | @itemx -mno-relax-pic-calls | |
d77de738 ML |
28746 | Try to turn PIC calls that are normally dispatched via register |
28747 | @code{$25} into direct calls. This is only possible if the linker can | |
28748 | resolve the destination at link time and if the destination is within | |
28749 | range for a direct call. | |
28750 | ||
28751 | @option{-mrelax-pic-calls} is the default if GCC was configured to use | |
28752 | an assembler and a linker that support the @code{.reloc} assembly | |
28753 | directive and @option{-mexplicit-relocs} is in effect. With | |
28754 | @option{-mno-explicit-relocs}, this optimization can be performed by the | |
28755 | assembler and the linker alone without help from the compiler. | |
28756 | ||
d77de738 ML |
28757 | @opindex mmcount-ra-address |
28758 | @opindex mno-mcount-ra-address | |
ddf6fe37 AA |
28759 | @item -mmcount-ra-address |
28760 | @itemx -mno-mcount-ra-address | |
d77de738 ML |
28761 | Emit (do not emit) code that allows @code{_mcount} to modify the |
28762 | calling function's return address. When enabled, this option extends | |
28763 | the usual @code{_mcount} interface with a new @var{ra-address} | |
28764 | parameter, which has type @code{intptr_t *} and is passed in register | |
28765 | @code{$12}. @code{_mcount} can then modify the return address by | |
28766 | doing both of the following: | |
28767 | @itemize | |
28768 | @item | |
28769 | Returning the new address in register @code{$31}. | |
28770 | @item | |
28771 | Storing the new address in @code{*@var{ra-address}}, | |
28772 | if @var{ra-address} is nonnull. | |
28773 | @end itemize | |
28774 | ||
28775 | The default is @option{-mno-mcount-ra-address}. | |
28776 | ||
ddf6fe37 | 28777 | @opindex mframe-header-opt |
d77de738 ML |
28778 | @item -mframe-header-opt |
28779 | @itemx -mno-frame-header-opt | |
d77de738 ML |
28780 | Enable (disable) frame header optimization in the o32 ABI. When using the |
28781 | o32 ABI, calling functions will allocate 16 bytes on the stack for the called | |
28782 | function to write out register arguments. When enabled, this optimization | |
28783 | will suppress the allocation of the frame header if it can be determined that | |
28784 | it is unused. | |
28785 | ||
28786 | This optimization is off by default at all optimization levels. | |
28787 | ||
ddf6fe37 | 28788 | @opindex mlxc1-sxc1 |
d77de738 ML |
28789 | @item -mlxc1-sxc1 |
28790 | @itemx -mno-lxc1-sxc1 | |
d77de738 ML |
28791 | When applicable, enable (disable) the generation of @code{lwxc1}, |
28792 | @code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default. | |
28793 | ||
ddf6fe37 | 28794 | @opindex mmadd4 |
d77de738 ML |
28795 | @item -mmadd4 |
28796 | @itemx -mno-madd4 | |
d77de738 ML |
28797 | When applicable, enable (disable) the generation of 4-operand @code{madd.s}, |
28798 | @code{madd.d} and related instructions. Enabled by default. | |
28799 | ||
28800 | @end table | |
28801 | ||
28802 | @node MMIX Options | |
28803 | @subsection MMIX Options | |
28804 | @cindex MMIX Options | |
28805 | ||
28806 | These options are defined for the MMIX: | |
28807 | ||
28808 | @table @gcctabopt | |
d77de738 ML |
28809 | @opindex mlibfuncs |
28810 | @opindex mno-libfuncs | |
ddf6fe37 AA |
28811 | @item -mlibfuncs |
28812 | @itemx -mno-libfuncs | |
d77de738 ML |
28813 | Specify that intrinsic library functions are being compiled, passing all |
28814 | values in registers, no matter the size. | |
28815 | ||
d77de738 ML |
28816 | @opindex mepsilon |
28817 | @opindex mno-epsilon | |
ddf6fe37 AA |
28818 | @item -mepsilon |
28819 | @itemx -mno-epsilon | |
d77de738 ML |
28820 | Generate floating-point comparison instructions that compare with respect |
28821 | to the @code{rE} epsilon register. | |
28822 | ||
d77de738 ML |
28823 | @opindex mabi=mmixware |
28824 | @opindex mabi=gnu | |
ddf6fe37 AA |
28825 | @item -mabi=mmixware |
28826 | @itemx -mabi=gnu | |
d77de738 ML |
28827 | Generate code that passes function parameters and return values that (in |
28828 | the called function) are seen as registers @code{$0} and up, as opposed to | |
28829 | the GNU ABI which uses global registers @code{$231} and up. | |
28830 | ||
d77de738 ML |
28831 | @opindex mzero-extend |
28832 | @opindex mno-zero-extend | |
ddf6fe37 AA |
28833 | @item -mzero-extend |
28834 | @itemx -mno-zero-extend | |
d77de738 ML |
28835 | When reading data from memory in sizes shorter than 64 bits, use (do not |
28836 | use) zero-extending load instructions by default, rather than | |
28837 | sign-extending ones. | |
28838 | ||
d77de738 ML |
28839 | @opindex mknuthdiv |
28840 | @opindex mno-knuthdiv | |
ddf6fe37 AA |
28841 | @item -mknuthdiv |
28842 | @itemx -mno-knuthdiv | |
d77de738 ML |
28843 | Make the result of a division yielding a remainder have the same sign as |
28844 | the divisor. With the default, @option{-mno-knuthdiv}, the sign of the | |
28845 | remainder follows the sign of the dividend. Both methods are | |
28846 | arithmetically valid, the latter being almost exclusively used. | |
28847 | ||
d77de738 ML |
28848 | @opindex mtoplevel-symbols |
28849 | @opindex mno-toplevel-symbols | |
ddf6fe37 AA |
28850 | @item -mtoplevel-symbols |
28851 | @itemx -mno-toplevel-symbols | |
d77de738 ML |
28852 | Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly |
28853 | code can be used with the @code{PREFIX} assembly directive. | |
28854 | ||
d77de738 | 28855 | @opindex melf |
ddf6fe37 | 28856 | @item -melf |
d77de738 ML |
28857 | Generate an executable in the ELF format, rather than the default |
28858 | @samp{mmo} format used by the @command{mmix} simulator. | |
28859 | ||
d77de738 ML |
28860 | @opindex mbranch-predict |
28861 | @opindex mno-branch-predict | |
ddf6fe37 AA |
28862 | @item -mbranch-predict |
28863 | @itemx -mno-branch-predict | |
d77de738 ML |
28864 | Use (do not use) the probable-branch instructions, when static branch |
28865 | prediction indicates a probable branch. | |
28866 | ||
d77de738 ML |
28867 | @opindex mbase-addresses |
28868 | @opindex mno-base-addresses | |
ddf6fe37 AA |
28869 | @item -mbase-addresses |
28870 | @itemx -mno-base-addresses | |
d77de738 ML |
28871 | Generate (do not generate) code that uses @emph{base addresses}. Using a |
28872 | base address automatically generates a request (handled by the assembler | |
28873 | and the linker) for a constant to be set up in a global register. The | |
28874 | register is used for one or more base address requests within the range 0 | |
28875 | to 255 from the value held in the register. The generally leads to short | |
28876 | and fast code, but the number of different data items that can be | |
28877 | addressed is limited. This means that a program that uses lots of static | |
28878 | data may require @option{-mno-base-addresses}. | |
28879 | ||
d77de738 ML |
28880 | @opindex msingle-exit |
28881 | @opindex mno-single-exit | |
ddf6fe37 AA |
28882 | @item -msingle-exit |
28883 | @itemx -mno-single-exit | |
d77de738 ML |
28884 | Force (do not force) generated code to have a single exit point in each |
28885 | function. | |
28886 | @end table | |
28887 | ||
28888 | @node MN10300 Options | |
28889 | @subsection MN10300 Options | |
28890 | @cindex MN10300 options | |
28891 | ||
28892 | These @option{-m} options are defined for Matsushita MN10300 architectures: | |
28893 | ||
28894 | @table @gcctabopt | |
d77de738 | 28895 | @opindex mmult-bug |
ddf6fe37 | 28896 | @item -mmult-bug |
d77de738 ML |
28897 | Generate code to avoid bugs in the multiply instructions for the MN10300 |
28898 | processors. This is the default. | |
28899 | ||
d77de738 | 28900 | @opindex mno-mult-bug |
ddf6fe37 | 28901 | @item -mno-mult-bug |
d77de738 ML |
28902 | Do not generate code to avoid bugs in the multiply instructions for the |
28903 | MN10300 processors. | |
28904 | ||
d77de738 | 28905 | @opindex mam33 |
ddf6fe37 | 28906 | @item -mam33 |
d77de738 ML |
28907 | Generate code using features specific to the AM33 processor. |
28908 | ||
d77de738 | 28909 | @opindex mno-am33 |
ddf6fe37 | 28910 | @item -mno-am33 |
d77de738 ML |
28911 | Do not generate code using features specific to the AM33 processor. This |
28912 | is the default. | |
28913 | ||
d77de738 | 28914 | @opindex mam33-2 |
ddf6fe37 | 28915 | @item -mam33-2 |
d77de738 ML |
28916 | Generate code using features specific to the AM33/2.0 processor. |
28917 | ||
d77de738 | 28918 | @opindex mam34 |
ddf6fe37 | 28919 | @item -mam34 |
d77de738 ML |
28920 | Generate code using features specific to the AM34 processor. |
28921 | ||
d77de738 | 28922 | @opindex mtune |
ddf6fe37 | 28923 | @item -mtune=@var{cpu-type} |
d77de738 ML |
28924 | Use the timing characteristics of the indicated CPU type when |
28925 | scheduling instructions. This does not change the targeted processor | |
28926 | type. The CPU type must be one of @samp{mn10300}, @samp{am33}, | |
28927 | @samp{am33-2} or @samp{am34}. | |
28928 | ||
d77de738 | 28929 | @opindex mreturn-pointer-on-d0 |
ddf6fe37 | 28930 | @item -mreturn-pointer-on-d0 |
d77de738 ML |
28931 | When generating a function that returns a pointer, return the pointer |
28932 | in both @code{a0} and @code{d0}. Otherwise, the pointer is returned | |
28933 | only in @code{a0}, and attempts to call such functions without a prototype | |
28934 | result in errors. Note that this option is on by default; use | |
28935 | @option{-mno-return-pointer-on-d0} to disable it. | |
28936 | ||
d77de738 | 28937 | @opindex mno-crt0 |
ddf6fe37 | 28938 | @item -mno-crt0 |
d77de738 ML |
28939 | Do not link in the C run-time initialization object file. |
28940 | ||
d77de738 | 28941 | @opindex mrelax |
ddf6fe37 | 28942 | @item -mrelax |
d77de738 ML |
28943 | Indicate to the linker that it should perform a relaxation optimization pass |
28944 | to shorten branches, calls and absolute memory addresses. This option only | |
28945 | has an effect when used on the command line for the final link step. | |
28946 | ||
28947 | This option makes symbolic debugging impossible. | |
28948 | ||
d77de738 | 28949 | @opindex mliw |
ddf6fe37 | 28950 | @item -mliw |
d77de738 ML |
28951 | Allow the compiler to generate @emph{Long Instruction Word} |
28952 | instructions if the target is the @samp{AM33} or later. This is the | |
28953 | default. This option defines the preprocessor macro @code{__LIW__}. | |
28954 | ||
d77de738 | 28955 | @opindex mno-liw |
ddf6fe37 | 28956 | @item -mno-liw |
d77de738 ML |
28957 | Do not allow the compiler to generate @emph{Long Instruction Word} |
28958 | instructions. This option defines the preprocessor macro | |
28959 | @code{__NO_LIW__}. | |
28960 | ||
d77de738 | 28961 | @opindex msetlb |
ddf6fe37 | 28962 | @item -msetlb |
d77de738 ML |
28963 | Allow the compiler to generate the @emph{SETLB} and @emph{Lcc} |
28964 | instructions if the target is the @samp{AM33} or later. This is the | |
28965 | default. This option defines the preprocessor macro @code{__SETLB__}. | |
28966 | ||
d77de738 | 28967 | @opindex mno-setlb |
ddf6fe37 | 28968 | @item -mno-setlb |
d77de738 ML |
28969 | Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc} |
28970 | instructions. This option defines the preprocessor macro | |
28971 | @code{__NO_SETLB__}. | |
28972 | ||
28973 | @end table | |
28974 | ||
28975 | @node Moxie Options | |
28976 | @subsection Moxie Options | |
28977 | @cindex Moxie Options | |
28978 | ||
28979 | @table @gcctabopt | |
28980 | ||
d77de738 | 28981 | @opindex meb |
ddf6fe37 | 28982 | @item -meb |
d77de738 ML |
28983 | Generate big-endian code. This is the default for @samp{moxie-*-*} |
28984 | configurations. | |
28985 | ||
d77de738 | 28986 | @opindex mel |
ddf6fe37 | 28987 | @item -mel |
d77de738 ML |
28988 | Generate little-endian code. |
28989 | ||
d77de738 | 28990 | @opindex mmul.x |
ddf6fe37 | 28991 | @item -mmul.x |
d77de738 ML |
28992 | Generate mul.x and umul.x instructions. This is the default for |
28993 | @samp{moxiebox-*-*} configurations. | |
28994 | ||
d77de738 | 28995 | @opindex mno-crt0 |
ddf6fe37 | 28996 | @item -mno-crt0 |
d77de738 ML |
28997 | Do not link in the C run-time initialization object file. |
28998 | ||
28999 | @end table | |
29000 | ||
29001 | @node MSP430 Options | |
29002 | @subsection MSP430 Options | |
29003 | @cindex MSP430 Options | |
29004 | ||
29005 | These options are defined for the MSP430: | |
29006 | ||
29007 | @table @gcctabopt | |
29008 | ||
d77de738 | 29009 | @opindex masm-hex |
ddf6fe37 | 29010 | @item -masm-hex |
d77de738 ML |
29011 | Force assembly output to always use hex constants. Normally such |
29012 | constants are signed decimals, but this option is available for | |
29013 | testsuite and/or aesthetic purposes. | |
29014 | ||
d77de738 | 29015 | @opindex mmcu= |
ddf6fe37 | 29016 | @item -mmcu= |
d77de738 ML |
29017 | Select the MCU to target. This is used to create a C preprocessor |
29018 | symbol based upon the MCU name, converted to upper case and pre- and | |
29019 | post-fixed with @samp{__}. This in turn is used by the | |
29020 | @file{msp430.h} header file to select an MCU-specific supplementary | |
29021 | header file. | |
29022 | ||
29023 | The option also sets the ISA to use. If the MCU name is one that is | |
29024 | known to only support the 430 ISA then that is selected, otherwise the | |
29025 | 430X ISA is selected. A generic MCU name of @samp{msp430} can also be | |
29026 | used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU | |
29027 | name selects the 430X ISA. | |
29028 | ||
29029 | In addition an MCU-specific linker script is added to the linker | |
29030 | command line. The script's name is the name of the MCU with | |
29031 | @file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc} | |
29032 | command line defines the C preprocessor symbol @code{__XXX__} and | |
29033 | cause the linker to search for a script called @file{xxx.ld}. | |
29034 | ||
29035 | The ISA and hardware multiply supported for the different MCUs is hard-coded | |
29036 | into GCC. However, an external @samp{devices.csv} file can be used to | |
29037 | extend device support beyond those that have been hard-coded. | |
29038 | ||
29039 | GCC searches for the @samp{devices.csv} file using the following methods in the | |
29040 | given precedence order, where the first method takes precendence over the | |
29041 | second which takes precedence over the third. | |
29042 | ||
29043 | @table @asis | |
29044 | @item Include path specified with @code{-I} and @code{-L} | |
29045 | @samp{devices.csv} will be searched for in each of the directories specified by | |
29046 | include paths and linker library search paths. | |
29047 | @item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR} | |
29048 | Define the value of the global environment variable | |
29049 | @samp{MSP430_GCC_INCLUDE_DIR} | |
29050 | to the full path to the directory containing devices.csv, and GCC will search | |
29051 | this directory for devices.csv. If devices.csv is found, this directory will | |
29052 | also be registered as an include path, and linker library path. Header files | |
29053 | and linker scripts in this directory can therefore be used without manually | |
29054 | specifying @code{-I} and @code{-L} on the command line. | |
29055 | @item The @samp{msp430-elf@{,bare@}/include/devices} directory | |
29056 | Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the | |
29057 | toolchain root directory. This directory does not exist in a default | |
29058 | installation, but if the user has created it and copied @samp{devices.csv} | |
29059 | there, then the MCU data will be read. As above, this directory will | |
29060 | also be registered as an include path, and linker library path. | |
29061 | ||
29062 | @end table | |
29063 | If none of the above search methods find @samp{devices.csv}, then the | |
29064 | hard-coded MCU data is used. | |
29065 | ||
29066 | ||
d77de738 ML |
29067 | @opindex mwarn-mcu |
29068 | @opindex mno-warn-mcu | |
ddf6fe37 AA |
29069 | @item -mwarn-mcu |
29070 | @itemx -mno-warn-mcu | |
d77de738 ML |
29071 | This option enables or disables warnings about conflicts between the |
29072 | MCU name specified by the @option{-mmcu} option and the ISA set by the | |
29073 | @option{-mcpu} option and/or the hardware multiply support set by the | |
29074 | @option{-mhwmult} option. It also toggles warnings about unrecognized | |
29075 | MCU names. This option is on by default. | |
29076 | ||
d77de738 | 29077 | @opindex mcpu= |
ddf6fe37 | 29078 | @item -mcpu= |
d77de738 ML |
29079 | Specifies the ISA to use. Accepted values are @samp{msp430}, |
29080 | @samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The | |
29081 | @option{-mmcu=} option should be used to select the ISA. | |
29082 | ||
d77de738 | 29083 | @opindex msim |
ddf6fe37 | 29084 | @item -msim |
d77de738 ML |
29085 | Link to the simulator runtime libraries and linker script. Overrides |
29086 | any scripts that would be selected by the @option{-mmcu=} option. | |
29087 | ||
d77de738 | 29088 | @opindex mlarge |
ddf6fe37 | 29089 | @item -mlarge |
d77de738 ML |
29090 | Use large-model addressing (20-bit pointers, 20-bit @code{size_t}). |
29091 | ||
d77de738 | 29092 | @opindex msmall |
ddf6fe37 | 29093 | @item -msmall |
d77de738 ML |
29094 | Use small-model addressing (16-bit pointers, 16-bit @code{size_t}). |
29095 | ||
d77de738 | 29096 | @opindex mrelax |
ddf6fe37 | 29097 | @item -mrelax |
d77de738 ML |
29098 | This option is passed to the assembler and linker, and allows the |
29099 | linker to perform certain optimizations that cannot be done until | |
29100 | the final link. | |
29101 | ||
d77de738 | 29102 | @opindex mhwmult= |
ddf6fe37 | 29103 | @item mhwmult= |
d77de738 ML |
29104 | Describes the type of hardware multiply supported by the target. |
29105 | Accepted values are @samp{none} for no hardware multiply, @samp{16bit} | |
29106 | for the original 16-bit-only multiply supported by early MCUs. | |
29107 | @samp{32bit} for the 16/32-bit multiply supported by later MCUs and | |
29108 | @samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs. | |
29109 | A value of @samp{auto} can also be given. This tells GCC to deduce | |
29110 | the hardware multiply support based upon the MCU name provided by the | |
29111 | @option{-mmcu} option. If no @option{-mmcu} option is specified or if | |
29112 | the MCU name is not recognized then no hardware multiply support is | |
29113 | assumed. @code{auto} is the default setting. | |
29114 | ||
29115 | Hardware multiplies are normally performed by calling a library | |
29116 | routine. This saves space in the generated code. When compiling at | |
29117 | @option{-O3} or higher however the hardware multiplier is invoked | |
29118 | inline. This makes for bigger, but faster code. | |
29119 | ||
29120 | The hardware multiply routines disable interrupts whilst running and | |
29121 | restore the previous interrupt state when they finish. This makes | |
29122 | them safe to use inside interrupt handlers as well as in normal code. | |
29123 | ||
d77de738 | 29124 | @opindex minrt |
ddf6fe37 | 29125 | @item -minrt |
d77de738 ML |
29126 | Enable the use of a minimum runtime environment - no static |
29127 | initializers or constructors. This is intended for memory-constrained | |
29128 | devices. The compiler includes special symbols in some objects | |
29129 | that tell the linker and runtime which code fragments are required. | |
29130 | ||
d77de738 | 29131 | @opindex mtiny-printf |
ddf6fe37 | 29132 | @item -mtiny-printf |
d77de738 ML |
29133 | Enable reduced code size @code{printf} and @code{puts} library functions. |
29134 | The @samp{tiny} implementations of these functions are not reentrant, so | |
29135 | must be used with caution in multi-threaded applications. | |
29136 | ||
29137 | Support for streams has been removed and the string to be printed will | |
29138 | always be sent to stdout via the @code{write} syscall. The string is not | |
29139 | buffered before it is sent to write. | |
29140 | ||
29141 | This option requires Newlib Nano IO, so GCC must be configured with | |
29142 | @samp{--enable-newlib-nano-formatted-io}. | |
29143 | ||
d77de738 | 29144 | @opindex mmax-inline-shift= |
ddf6fe37 | 29145 | @item -mmax-inline-shift= |
d77de738 ML |
29146 | This option takes an integer between 0 and 64 inclusive, and sets |
29147 | the maximum number of inline shift instructions which should be emitted to | |
29148 | perform a shift operation by a constant amount. When this value needs to be | |
29149 | exceeded, an mspabi helper function is used instead. The default value is 4. | |
29150 | ||
29151 | This only affects cases where a shift by multiple positions cannot be | |
29152 | completed with a single instruction (e.g. all shifts >1 on the 430 ISA). | |
29153 | ||
29154 | Shifts of a 32-bit value are at least twice as costly, so the value passed for | |
29155 | this option is divided by 2 and the resulting value used instead. | |
29156 | ||
d77de738 ML |
29157 | @opindex mcode-region |
29158 | @opindex mdata-region | |
ddf6fe37 AA |
29159 | @item -mcode-region= |
29160 | @itemx -mdata-region= | |
d77de738 ML |
29161 | These options tell the compiler where to place functions and data that |
29162 | do not have one of the @code{lower}, @code{upper}, @code{either} or | |
29163 | @code{section} attributes. Possible values are @code{lower}, | |
29164 | @code{upper}, @code{either} or @code{any}. The first three behave | |
29165 | like the corresponding attribute. The fourth possible value - | |
29166 | @code{any} - is the default. It leaves placement entirely up to the | |
29167 | linker script and how it assigns the standard sections | |
29168 | (@code{.text}, @code{.data}, etc) to the memory regions. | |
29169 | ||
d77de738 | 29170 | @opindex msilicon-errata |
ddf6fe37 | 29171 | @item -msilicon-errata= |
d77de738 ML |
29172 | This option passes on a request to assembler to enable the fixes for |
29173 | the named silicon errata. | |
29174 | ||
d77de738 | 29175 | @opindex msilicon-errata-warn |
ddf6fe37 | 29176 | @item -msilicon-errata-warn= |
d77de738 ML |
29177 | This option passes on a request to the assembler to enable warning |
29178 | messages when a silicon errata might need to be applied. | |
29179 | ||
d77de738 ML |
29180 | @opindex mwarn-devices-csv |
29181 | @opindex mno-warn-devices-csv | |
ddf6fe37 AA |
29182 | @item -mwarn-devices-csv |
29183 | @itemx -mno-warn-devices-csv | |
d77de738 ML |
29184 | Warn if @samp{devices.csv} is not found or there are problem parsing it |
29185 | (default: on). | |
29186 | ||
29187 | @end table | |
29188 | ||
29189 | @node NDS32 Options | |
29190 | @subsection NDS32 Options | |
29191 | @cindex NDS32 Options | |
29192 | ||
29193 | These options are defined for NDS32 implementations: | |
29194 | ||
29195 | @table @gcctabopt | |
29196 | ||
d77de738 | 29197 | @opindex mbig-endian |
ddf6fe37 | 29198 | @item -mbig-endian |
d77de738 ML |
29199 | Generate code in big-endian mode. |
29200 | ||
d77de738 | 29201 | @opindex mlittle-endian |
ddf6fe37 | 29202 | @item -mlittle-endian |
d77de738 ML |
29203 | Generate code in little-endian mode. |
29204 | ||
d77de738 | 29205 | @opindex mreduced-regs |
ddf6fe37 | 29206 | @item -mreduced-regs |
d77de738 ML |
29207 | Use reduced-set registers for register allocation. |
29208 | ||
d77de738 | 29209 | @opindex mfull-regs |
ddf6fe37 | 29210 | @item -mfull-regs |
d77de738 ML |
29211 | Use full-set registers for register allocation. |
29212 | ||
d77de738 | 29213 | @opindex mcmov |
ddf6fe37 | 29214 | @item -mcmov |
d77de738 ML |
29215 | Generate conditional move instructions. |
29216 | ||
d77de738 | 29217 | @opindex mno-cmov |
ddf6fe37 | 29218 | @item -mno-cmov |
d77de738 ML |
29219 | Do not generate conditional move instructions. |
29220 | ||
d77de738 | 29221 | @opindex mext-perf |
ddf6fe37 | 29222 | @item -mext-perf |
d77de738 ML |
29223 | Generate performance extension instructions. |
29224 | ||
d77de738 | 29225 | @opindex mno-ext-perf |
ddf6fe37 | 29226 | @item -mno-ext-perf |
d77de738 ML |
29227 | Do not generate performance extension instructions. |
29228 | ||
d77de738 | 29229 | @opindex mext-perf2 |
ddf6fe37 | 29230 | @item -mext-perf2 |
d77de738 ML |
29231 | Generate performance extension 2 instructions. |
29232 | ||
d77de738 | 29233 | @opindex mno-ext-perf2 |
ddf6fe37 | 29234 | @item -mno-ext-perf2 |
d77de738 ML |
29235 | Do not generate performance extension 2 instructions. |
29236 | ||
d77de738 | 29237 | @opindex mext-string |
ddf6fe37 | 29238 | @item -mext-string |
d77de738 ML |
29239 | Generate string extension instructions. |
29240 | ||
d77de738 | 29241 | @opindex mno-ext-string |
ddf6fe37 | 29242 | @item -mno-ext-string |
d77de738 ML |
29243 | Do not generate string extension instructions. |
29244 | ||
d77de738 | 29245 | @opindex mv3push |
ddf6fe37 | 29246 | @item -mv3push |
d77de738 ML |
29247 | Generate v3 push25/pop25 instructions. |
29248 | ||
d77de738 | 29249 | @opindex mno-v3push |
ddf6fe37 | 29250 | @item -mno-v3push |
d77de738 ML |
29251 | Do not generate v3 push25/pop25 instructions. |
29252 | ||
d77de738 | 29253 | @opindex m16-bit |
ddf6fe37 | 29254 | @item -m16-bit |
d77de738 ML |
29255 | Generate 16-bit instructions. |
29256 | ||
d77de738 | 29257 | @opindex mno-16-bit |
ddf6fe37 | 29258 | @item -mno-16-bit |
d77de738 ML |
29259 | Do not generate 16-bit instructions. |
29260 | ||
d77de738 | 29261 | @opindex misr-vector-size |
ddf6fe37 | 29262 | @item -misr-vector-size=@var{num} |
d77de738 ML |
29263 | Specify the size of each interrupt vector, which must be 4 or 16. |
29264 | ||
d77de738 | 29265 | @opindex mcache-block-size |
ddf6fe37 | 29266 | @item -mcache-block-size=@var{num} |
d77de738 ML |
29267 | Specify the size of each cache block, |
29268 | which must be a power of 2 between 4 and 512. | |
29269 | ||
d77de738 | 29270 | @opindex march |
ddf6fe37 | 29271 | @item -march=@var{arch} |
d77de738 ML |
29272 | Specify the name of the target architecture. |
29273 | ||
d77de738 | 29274 | @opindex mcmodel |
ddf6fe37 | 29275 | @item -mcmodel=@var{code-model} |
d77de738 ML |
29276 | Set the code model to one of |
29277 | @table @asis | |
29278 | @item @samp{small} | |
29279 | All the data and read-only data segments must be within 512KB addressing space. | |
29280 | The text segment must be within 16MB addressing space. | |
29281 | @item @samp{medium} | |
29282 | The data segment must be within 512KB while the read-only data segment can be | |
29283 | within 4GB addressing space. The text segment should be still within 16MB | |
29284 | addressing space. | |
29285 | @item @samp{large} | |
29286 | All the text and data segments can be within 4GB addressing space. | |
29287 | @end table | |
29288 | ||
d77de738 | 29289 | @opindex mctor-dtor |
ddf6fe37 | 29290 | @item -mctor-dtor |
d77de738 ML |
29291 | Enable constructor/destructor feature. |
29292 | ||
d77de738 | 29293 | @opindex mrelax |
ddf6fe37 | 29294 | @item -mrelax |
d77de738 ML |
29295 | Guide linker to relax instructions. |
29296 | ||
29297 | @end table | |
29298 | ||
29299 | @node Nios II Options | |
29300 | @subsection Nios II Options | |
29301 | @cindex Nios II options | |
29302 | @cindex Altera Nios II options | |
29303 | ||
29304 | These are the options defined for the Altera Nios II processor. | |
29305 | ||
29306 | @table @gcctabopt | |
29307 | ||
d77de738 ML |
29308 | @opindex G |
29309 | @cindex smaller data references | |
f33d7a88 | 29310 | @item -G @var{num} |
d77de738 ML |
29311 | Put global and static objects less than or equal to @var{num} bytes |
29312 | into the small data or BSS sections instead of the normal data or BSS | |
29313 | sections. The default value of @var{num} is 8. | |
29314 | ||
ddf6fe37 AA |
29315 | @opindex mgpopt |
29316 | @opindex mno-gpopt | |
d77de738 ML |
29317 | @item -mgpopt=@var{option} |
29318 | @itemx -mgpopt | |
29319 | @itemx -mno-gpopt | |
d77de738 ML |
29320 | Generate (do not generate) GP-relative accesses. The following |
29321 | @var{option} names are recognized: | |
29322 | ||
29323 | @table @samp | |
29324 | ||
29325 | @item none | |
29326 | Do not generate GP-relative accesses. | |
29327 | ||
29328 | @item local | |
29329 | Generate GP-relative accesses for small data objects that are not | |
29330 | external, weak, or uninitialized common symbols. | |
29331 | Also use GP-relative addressing for objects that | |
29332 | have been explicitly placed in a small data section via a @code{section} | |
29333 | attribute. | |
29334 | ||
29335 | @item global | |
29336 | As for @samp{local}, but also generate GP-relative accesses for | |
29337 | small data objects that are external, weak, or common. If you use this option, | |
29338 | you must ensure that all parts of your program (including libraries) are | |
29339 | compiled with the same @option{-G} setting. | |
29340 | ||
29341 | @item data | |
29342 | Generate GP-relative accesses for all data objects in the program. If you | |
29343 | use this option, the entire data and BSS segments | |
29344 | of your program must fit in 64K of memory and you must use an appropriate | |
29345 | linker script to allocate them within the addressable range of the | |
29346 | global pointer. | |
29347 | ||
29348 | @item all | |
29349 | Generate GP-relative addresses for function pointers as well as data | |
29350 | pointers. If you use this option, the entire text, data, and BSS segments | |
29351 | of your program must fit in 64K of memory and you must use an appropriate | |
29352 | linker script to allocate them within the addressable range of the | |
29353 | global pointer. | |
29354 | ||
29355 | @end table | |
29356 | ||
29357 | @option{-mgpopt} is equivalent to @option{-mgpopt=local}, and | |
29358 | @option{-mno-gpopt} is equivalent to @option{-mgpopt=none}. | |
29359 | ||
29360 | The default is @option{-mgpopt} except when @option{-fpic} or | |
29361 | @option{-fPIC} is specified to generate position-independent code. | |
29362 | Note that the Nios II ABI does not permit GP-relative accesses from | |
29363 | shared libraries. | |
29364 | ||
29365 | You may need to specify @option{-mno-gpopt} explicitly when building | |
29366 | programs that include large amounts of small data, including large | |
29367 | GOT data sections. In this case, the 16-bit offset for GP-relative | |
29368 | addressing may not be large enough to allow access to the entire | |
29369 | small data section. | |
29370 | ||
d77de738 | 29371 | @opindex mgprel-sec |
ddf6fe37 | 29372 | @item -mgprel-sec=@var{regexp} |
d77de738 ML |
29373 | This option specifies additional section names that can be accessed via |
29374 | GP-relative addressing. It is most useful in conjunction with | |
29375 | @code{section} attributes on variable declarations | |
29376 | (@pxref{Common Variable Attributes}) and a custom linker script. | |
29377 | The @var{regexp} is a POSIX Extended Regular Expression. | |
29378 | ||
29379 | This option does not affect the behavior of the @option{-G} option, and | |
29380 | the specified sections are in addition to the standard @code{.sdata} | |
29381 | and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}. | |
29382 | ||
d77de738 | 29383 | @opindex mr0rel-sec |
ddf6fe37 | 29384 | @item -mr0rel-sec=@var{regexp} |
d77de738 ML |
29385 | This option specifies names of sections that can be accessed via a |
29386 | 16-bit offset from @code{r0}; that is, in the low 32K or high 32K | |
29387 | of the 32-bit address space. It is most useful in conjunction with | |
29388 | @code{section} attributes on variable declarations | |
29389 | (@pxref{Common Variable Attributes}) and a custom linker script. | |
29390 | The @var{regexp} is a POSIX Extended Regular Expression. | |
29391 | ||
29392 | In contrast to the use of GP-relative addressing for small data, | |
29393 | zero-based addressing is never generated by default and there are no | |
29394 | conventional section names used in standard linker scripts for sections | |
29395 | in the low or high areas of memory. | |
29396 | ||
d77de738 ML |
29397 | @opindex mel |
29398 | @opindex meb | |
ddf6fe37 AA |
29399 | @item -mel |
29400 | @itemx -meb | |
d77de738 ML |
29401 | Generate little-endian (default) or big-endian (experimental) code, |
29402 | respectively. | |
29403 | ||
d77de738 | 29404 | @opindex march |
ddf6fe37 | 29405 | @item -march=@var{arch} |
d77de738 ML |
29406 | This specifies the name of the target Nios II architecture. GCC uses this |
29407 | name to determine what kind of instructions it can emit when generating | |
29408 | assembly code. Permissible names are: @samp{r1}, @samp{r2}. | |
29409 | ||
29410 | The preprocessor macro @code{__nios2_arch__} is available to programs, | |
29411 | with value 1 or 2, indicating the targeted ISA level. | |
29412 | ||
d77de738 ML |
29413 | @opindex mno-bypass-cache |
29414 | @opindex mbypass-cache | |
ddf6fe37 AA |
29415 | @item -mbypass-cache |
29416 | @itemx -mno-bypass-cache | |
d77de738 ML |
29417 | Force all load and store instructions to always bypass cache by |
29418 | using I/O variants of the instructions. The default is not to | |
29419 | bypass the cache. | |
29420 | ||
d77de738 ML |
29421 | @opindex mcache-volatile |
29422 | @opindex mno-cache-volatile | |
ddf6fe37 AA |
29423 | @item -mno-cache-volatile |
29424 | @itemx -mcache-volatile | |
d77de738 ML |
29425 | Volatile memory access bypass the cache using the I/O variants of |
29426 | the load and store instructions. The default is not to bypass the cache. | |
29427 | ||
d77de738 ML |
29428 | @opindex mno-fast-sw-div |
29429 | @opindex mfast-sw-div | |
ddf6fe37 AA |
29430 | @item -mno-fast-sw-div |
29431 | @itemx -mfast-sw-div | |
d77de738 ML |
29432 | Do not use table-based fast divide for small numbers. The default |
29433 | is to use the fast divide at @option{-O3} and above. | |
29434 | ||
d77de738 ML |
29435 | @opindex mno-hw-mul |
29436 | @opindex mhw-mul | |
29437 | @opindex mno-hw-mulx | |
29438 | @opindex mhw-mulx | |
29439 | @opindex mno-hw-div | |
29440 | @opindex mhw-div | |
ddf6fe37 AA |
29441 | @item -mno-hw-mul |
29442 | @itemx -mhw-mul | |
29443 | @itemx -mno-hw-mulx | |
29444 | @itemx -mhw-mulx | |
29445 | @itemx -mno-hw-div | |
29446 | @itemx -mhw-div | |
d77de738 ML |
29447 | Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of |
29448 | instructions by the compiler. The default is to emit @code{mul} | |
29449 | and not emit @code{div} and @code{mulx}. | |
29450 | ||
29451 | @item -mbmx | |
29452 | @itemx -mno-bmx | |
29453 | @itemx -mcdx | |
29454 | @itemx -mno-cdx | |
29455 | Enable or disable generation of Nios II R2 BMX (bit manipulation) and | |
29456 | CDX (code density) instructions. Enabling these instructions also | |
29457 | requires @option{-march=r2}. Since these instructions are optional | |
29458 | extensions to the R2 architecture, the default is not to emit them. | |
29459 | ||
d77de738 ML |
29460 | @opindex mcustom-@var{insn} |
29461 | @opindex mno-custom-@var{insn} | |
ddf6fe37 AA |
29462 | @item -mcustom-@var{insn}=@var{N} |
29463 | @itemx -mno-custom-@var{insn} | |
d77de738 ML |
29464 | Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a |
29465 | custom instruction with encoding @var{N} when generating code that uses | |
29466 | @var{insn}. For example, @option{-mcustom-fadds=253} generates custom | |
29467 | instruction 253 for single-precision floating-point add operations instead | |
29468 | of the default behavior of using a library call. | |
29469 | ||
29470 | The following values of @var{insn} are supported. Except as otherwise | |
29471 | noted, floating-point operations are expected to be implemented with | |
29472 | normal IEEE 754 semantics and correspond directly to the C operators or the | |
29473 | equivalent GCC built-in functions (@pxref{Other Builtins}). | |
29474 | ||
29475 | Single-precision floating point: | |
29476 | @table @asis | |
29477 | ||
29478 | @item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls} | |
29479 | Binary arithmetic operations. | |
29480 | ||
29481 | @item @samp{fnegs} | |
29482 | Unary negation. | |
29483 | ||
29484 | @item @samp{fabss} | |
29485 | Unary absolute value. | |
29486 | ||
29487 | @item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes} | |
29488 | Comparison operations. | |
29489 | ||
29490 | @item @samp{fmins}, @samp{fmaxs} | |
29491 | Floating-point minimum and maximum. These instructions are only | |
29492 | generated if @option{-ffinite-math-only} is specified. | |
29493 | ||
29494 | @item @samp{fsqrts} | |
29495 | Unary square root operation. | |
29496 | ||
29497 | @item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs} | |
29498 | Floating-point trigonometric and exponential functions. These instructions | |
29499 | are only generated if @option{-funsafe-math-optimizations} is also specified. | |
29500 | ||
29501 | @end table | |
29502 | ||
29503 | Double-precision floating point: | |
29504 | @table @asis | |
29505 | ||
29506 | @item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld} | |
29507 | Binary arithmetic operations. | |
29508 | ||
29509 | @item @samp{fnegd} | |
29510 | Unary negation. | |
29511 | ||
29512 | @item @samp{fabsd} | |
29513 | Unary absolute value. | |
29514 | ||
29515 | @item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned} | |
29516 | Comparison operations. | |
29517 | ||
29518 | @item @samp{fmind}, @samp{fmaxd} | |
29519 | Double-precision minimum and maximum. These instructions are only | |
29520 | generated if @option{-ffinite-math-only} is specified. | |
29521 | ||
29522 | @item @samp{fsqrtd} | |
29523 | Unary square root operation. | |
29524 | ||
29525 | @item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd} | |
29526 | Double-precision trigonometric and exponential functions. These instructions | |
29527 | are only generated if @option{-funsafe-math-optimizations} is also specified. | |
29528 | ||
29529 | @end table | |
29530 | ||
29531 | Conversions: | |
29532 | @table @asis | |
29533 | @item @samp{fextsd} | |
29534 | Conversion from single precision to double precision. | |
29535 | ||
29536 | @item @samp{ftruncds} | |
29537 | Conversion from double precision to single precision. | |
29538 | ||
29539 | @item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu} | |
29540 | Conversion from floating point to signed or unsigned integer types, with | |
29541 | truncation towards zero. | |
29542 | ||
29543 | @item @samp{round} | |
29544 | Conversion from single-precision floating point to signed integer, | |
29545 | rounding to the nearest integer and ties away from zero. | |
29546 | This corresponds to the @code{__builtin_lroundf} function when | |
29547 | @option{-fno-math-errno} is used. | |
29548 | ||
29549 | @item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud} | |
29550 | Conversion from signed or unsigned integer types to floating-point types. | |
29551 | ||
29552 | @end table | |
29553 | ||
29554 | In addition, all of the following transfer instructions for internal | |
29555 | registers X and Y must be provided to use any of the double-precision | |
29556 | floating-point instructions. Custom instructions taking two | |
29557 | double-precision source operands expect the first operand in the | |
29558 | 64-bit register X. The other operand (or only operand of a unary | |
29559 | operation) is given to the custom arithmetic instruction with the | |
29560 | least significant half in source register @var{src1} and the most | |
29561 | significant half in @var{src2}. A custom instruction that returns a | |
29562 | double-precision result returns the most significant 32 bits in the | |
29563 | destination register and the other half in 32-bit register Y. | |
29564 | GCC automatically generates the necessary code sequences to write | |
29565 | register X and/or read register Y when double-precision floating-point | |
29566 | instructions are used. | |
29567 | ||
29568 | @table @asis | |
29569 | ||
29570 | @item @samp{fwrx} | |
29571 | Write @var{src1} into the least significant half of X and @var{src2} into | |
29572 | the most significant half of X. | |
29573 | ||
29574 | @item @samp{fwry} | |
29575 | Write @var{src1} into Y. | |
29576 | ||
29577 | @item @samp{frdxhi}, @samp{frdxlo} | |
29578 | Read the most or least (respectively) significant half of X and store it in | |
29579 | @var{dest}. | |
29580 | ||
29581 | @item @samp{frdy} | |
29582 | Read the value of Y and store it into @var{dest}. | |
29583 | @end table | |
29584 | ||
29585 | Note that you can gain more local control over generation of Nios II custom | |
29586 | instructions by using the @code{target("custom-@var{insn}=@var{N}")} | |
29587 | and @code{target("no-custom-@var{insn}")} function attributes | |
29588 | (@pxref{Function Attributes}) | |
29589 | or pragmas (@pxref{Function Specific Option Pragmas}). | |
29590 | ||
d77de738 | 29591 | @opindex mcustom-fpu-cfg |
ddf6fe37 | 29592 | @item -mcustom-fpu-cfg=@var{name} |
d77de738 ML |
29593 | |
29594 | This option enables a predefined, named set of custom instruction encodings | |
29595 | (see @option{-mcustom-@var{insn}} above). | |
29596 | Currently, the following sets are defined: | |
29597 | ||
29598 | @option{-mcustom-fpu-cfg=60-1} is equivalent to: | |
43b72ede AA |
29599 | @gccoptlist{-mcustom-fmuls=252 |
29600 | -mcustom-fadds=253 | |
29601 | -mcustom-fsubs=254 | |
d77de738 ML |
29602 | -fsingle-precision-constant} |
29603 | ||
29604 | @option{-mcustom-fpu-cfg=60-2} is equivalent to: | |
43b72ede AA |
29605 | @gccoptlist{-mcustom-fmuls=252 |
29606 | -mcustom-fadds=253 | |
29607 | -mcustom-fsubs=254 | |
29608 | -mcustom-fdivs=255 | |
d77de738 ML |
29609 | -fsingle-precision-constant} |
29610 | ||
29611 | @option{-mcustom-fpu-cfg=72-3} is equivalent to: | |
43b72ede AA |
29612 | @gccoptlist{-mcustom-floatus=243 |
29613 | -mcustom-fixsi=244 | |
29614 | -mcustom-floatis=245 | |
29615 | -mcustom-fcmpgts=246 | |
29616 | -mcustom-fcmples=249 | |
29617 | -mcustom-fcmpeqs=250 | |
29618 | -mcustom-fcmpnes=251 | |
29619 | -mcustom-fmuls=252 | |
29620 | -mcustom-fadds=253 | |
29621 | -mcustom-fsubs=254 | |
29622 | -mcustom-fdivs=255 | |
d77de738 ML |
29623 | -fsingle-precision-constant} |
29624 | ||
29625 | @option{-mcustom-fpu-cfg=fph2} is equivalent to: | |
43b72ede AA |
29626 | @gccoptlist{-mcustom-fabss=224 |
29627 | -mcustom-fnegs=225 | |
29628 | -mcustom-fcmpnes=226 | |
29629 | -mcustom-fcmpeqs=227 | |
29630 | -mcustom-fcmpges=228 | |
29631 | -mcustom-fcmpgts=229 | |
29632 | -mcustom-fcmples=230 | |
29633 | -mcustom-fcmplts=231 | |
29634 | -mcustom-fmaxs=232 | |
29635 | -mcustom-fmins=233 | |
29636 | -mcustom-round=248 | |
29637 | -mcustom-fixsi=249 | |
29638 | -mcustom-floatis=250 | |
29639 | -mcustom-fsqrts=251 | |
29640 | -mcustom-fmuls=252 | |
29641 | -mcustom-fadds=253 | |
29642 | -mcustom-fsubs=254 | |
29643 | -mcustom-fdivs=255} | |
d77de738 ML |
29644 | |
29645 | Custom instruction assignments given by individual | |
29646 | @option{-mcustom-@var{insn}=} options override those given by | |
29647 | @option{-mcustom-fpu-cfg=}, regardless of the | |
29648 | order of the options on the command line. | |
29649 | ||
29650 | Note that you can gain more local control over selection of a FPU | |
29651 | configuration by using the @code{target("custom-fpu-cfg=@var{name}")} | |
29652 | function attribute (@pxref{Function Attributes}) | |
29653 | or pragma (@pxref{Function Specific Option Pragmas}). | |
29654 | ||
29655 | The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point | |
29656 | Hardware 2 Component}. Please note that the custom instructions enabled by | |
29657 | @option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated | |
29658 | if @option{-ffinite-math-only} is specified. The custom instruction enabled by | |
29659 | @option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is | |
29660 | specified. In contrast to the other configurations, | |
29661 | @option{-fsingle-precision-constant} is not set. | |
29662 | ||
29663 | @end table | |
29664 | ||
29665 | These additional @samp{-m} options are available for the Altera Nios II | |
29666 | ELF (bare-metal) target: | |
29667 | ||
29668 | @table @gcctabopt | |
29669 | ||
d77de738 | 29670 | @opindex mhal |
ddf6fe37 | 29671 | @item -mhal |
d77de738 ML |
29672 | Link with HAL BSP. This suppresses linking with the GCC-provided C runtime |
29673 | startup and termination code, and is typically used in conjunction with | |
29674 | @option{-msys-crt0=} to specify the location of the alternate startup code | |
29675 | provided by the HAL BSP. | |
29676 | ||
d77de738 | 29677 | @opindex msmallc |
ddf6fe37 | 29678 | @item -msmallc |
d77de738 ML |
29679 | Link with a limited version of the C library, @option{-lsmallc}, rather than |
29680 | Newlib. | |
29681 | ||
d77de738 | 29682 | @opindex msys-crt0 |
ddf6fe37 | 29683 | @item -msys-crt0=@var{startfile} |
d77de738 ML |
29684 | @var{startfile} is the file name of the startfile (crt0) to use |
29685 | when linking. This option is only useful in conjunction with @option{-mhal}. | |
29686 | ||
d77de738 | 29687 | @opindex msys-lib |
ddf6fe37 | 29688 | @item -msys-lib=@var{systemlib} |
d77de738 ML |
29689 | @var{systemlib} is the library name of the library that provides |
29690 | low-level system calls required by the C library, | |
29691 | e.g.@: @code{read} and @code{write}. | |
29692 | This option is typically used to link with a library provided by a HAL BSP. | |
29693 | ||
29694 | @end table | |
29695 | ||
29696 | @node Nvidia PTX Options | |
29697 | @subsection Nvidia PTX Options | |
29698 | @cindex Nvidia PTX options | |
29699 | @cindex nvptx options | |
29700 | ||
29701 | These options are defined for Nvidia PTX: | |
29702 | ||
29703 | @table @gcctabopt | |
29704 | ||
d77de738 | 29705 | @opindex m64 |
ddf6fe37 | 29706 | @item -m64 |
d77de738 ML |
29707 | Ignored, but preserved for backward compatibility. Only 64-bit ABI is |
29708 | supported. | |
29709 | ||
d77de738 | 29710 | @opindex march |
ddf6fe37 | 29711 | @item -march=@var{architecture-string} |
d77de738 ML |
29712 | Generate code for the specified PTX ISA target architecture |
29713 | (e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30}, | |
29714 | @samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and | |
29715 | @samp{sm_80}. | |
29716 | The default depends on how the compiler has been configured, see | |
29717 | @option{--with-arch}. | |
29718 | ||
29719 | This option sets the value of the preprocessor macro | |
29720 | @code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value | |
29721 | @samp{350}. | |
29722 | ||
d77de738 | 29723 | @opindex misa |
ddf6fe37 | 29724 | @item -misa=@var{architecture-string} |
d77de738 ML |
29725 | Alias of @option{-march=}. |
29726 | ||
d77de738 | 29727 | @opindex march |
ddf6fe37 | 29728 | @item -march-map=@var{architecture-string} |
d77de738 ML |
29729 | Select the closest available @option{-march=} value that is not more |
29730 | capable. For instance, for @option{-march-map=sm_50} select | |
29731 | @option{-march=sm_35}, and for @option{-march-map=sm_53} select | |
29732 | @option{-march=sm_53}. | |
29733 | ||
d77de738 | 29734 | @opindex mptx |
ddf6fe37 | 29735 | @item -mptx=@var{version-string} |
d77de738 ML |
29736 | Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}). |
29737 | Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and | |
29738 | @samp{7.0}. The default PTX ISA version is 6.0, unless a higher | |
29739 | version is required for specified PTX ISA target architecture via | |
29740 | option @option{-march=}. | |
29741 | ||
29742 | This option sets the values of the preprocessor macros | |
29743 | @code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__}; | |
29744 | for instance, for @samp{3.1} the macros have the values @samp{3} and | |
29745 | @samp{1}, respectively. | |
29746 | ||
d77de738 | 29747 | @opindex mmainkernel |
ddf6fe37 | 29748 | @item -mmainkernel |
d77de738 ML |
29749 | Link in code for a __main kernel. This is for stand-alone instead of |
29750 | offloading execution. | |
29751 | ||
d77de738 | 29752 | @opindex moptimize |
ddf6fe37 | 29753 | @item -moptimize |
d77de738 ML |
29754 | Apply partitioned execution optimizations. This is the default when any |
29755 | level of optimization is selected. | |
29756 | ||
d77de738 | 29757 | @opindex msoft-stack |
ddf6fe37 | 29758 | @item -msoft-stack |
d77de738 ML |
29759 | Generate code that does not use @code{.local} memory |
29760 | directly for stack storage. Instead, a per-warp stack pointer is | |
29761 | maintained explicitly. This enables variable-length stack allocation (with | |
29762 | variable-length arrays or @code{alloca}), and when global memory is used for | |
29763 | underlying storage, makes it possible to access automatic variables from other | |
29764 | threads, or with atomic instructions. This code generation variant is used | |
29765 | for OpenMP offloading, but the option is exposed on its own for the purpose | |
29766 | of testing the compiler; to generate code suitable for linking into programs | |
29767 | using OpenMP offloading, use option @option{-mgomp}. | |
29768 | ||
d77de738 | 29769 | @opindex muniform-simt |
ddf6fe37 | 29770 | @item -muniform-simt |
d77de738 ML |
29771 | Switch to code generation variant that allows to execute all threads in each |
29772 | warp, while maintaining memory state and side effects as if only one thread | |
29773 | in each warp was active outside of OpenMP SIMD regions. All atomic operations | |
29774 | and calls to runtime (malloc, free, vprintf) are conditionally executed (iff | |
29775 | current lane index equals the master lane index), and the register being | |
29776 | assigned is copied via a shuffle instruction from the master lane. Outside of | |
29777 | SIMD regions lane 0 is the master; inside, each thread sees itself as the | |
29778 | master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or | |
29779 | all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD | |
29780 | regions). Each thread can bitwise-and the bitmask at position @code{tid.y} | |
29781 | with current lane index to compute the master lane index. | |
29782 | ||
d77de738 | 29783 | @opindex mgomp |
ddf6fe37 | 29784 | @item -mgomp |
d77de738 ML |
29785 | Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and |
29786 | @option{-muniform-simt} options, and selects corresponding multilib variant. | |
29787 | ||
29788 | @end table | |
29789 | ||
29790 | @node OpenRISC Options | |
29791 | @subsection OpenRISC Options | |
29792 | @cindex OpenRISC Options | |
29793 | ||
29794 | These options are defined for OpenRISC: | |
29795 | ||
29796 | @table @gcctabopt | |
29797 | ||
d77de738 | 29798 | @opindex mboard |
ddf6fe37 | 29799 | @item -mboard=@var{name} |
d77de738 ML |
29800 | Configure a board specific runtime. This will be passed to the linker for |
29801 | newlib board library linking. The default is @code{or1ksim}. | |
29802 | ||
d77de738 | 29803 | @opindex mnewlib |
ddf6fe37 | 29804 | @item -mnewlib |
d77de738 ML |
29805 | This option is ignored; it is for compatibility purposes only. This used to |
29806 | select linker and preprocessor options for use with newlib. | |
29807 | ||
d77de738 ML |
29808 | @opindex msoft-div |
29809 | @opindex mhard-div | |
ddf6fe37 AA |
29810 | @item -msoft-div |
29811 | @itemx -mhard-div | |
d77de738 ML |
29812 | Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions. |
29813 | This default is hardware divide. | |
29814 | ||
d77de738 ML |
29815 | @opindex msoft-mul |
29816 | @opindex mhard-mul | |
ddf6fe37 AA |
29817 | @item -msoft-mul |
29818 | @itemx -mhard-mul | |
d77de738 ML |
29819 | Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions. |
29820 | This default is hardware multiply. | |
29821 | ||
d77de738 ML |
29822 | @opindex msoft-float |
29823 | @opindex mhard-float | |
ddf6fe37 AA |
29824 | @item -msoft-float |
29825 | @itemx -mhard-float | |
d77de738 ML |
29826 | Select software or hardware for floating point operations. |
29827 | The default is software. | |
29828 | ||
d77de738 | 29829 | @opindex mdouble-float |
ddf6fe37 | 29830 | @item -mdouble-float |
d77de738 ML |
29831 | When @option{-mhard-float} is selected, enables generation of double-precision |
29832 | floating point instructions. By default functions from @file{libgcc} are used | |
29833 | to perform double-precision floating point operations. | |
29834 | ||
d77de738 | 29835 | @opindex munordered-float |
ddf6fe37 | 29836 | @item -munordered-float |
d77de738 ML |
29837 | When @option{-mhard-float} is selected, enables generation of unordered |
29838 | floating point compare and set flag (@code{lf.sfun*}) instructions. By default | |
29839 | functions from @file{libgcc} are used to perform unordered floating point | |
29840 | compare and set flag operations. | |
29841 | ||
d77de738 | 29842 | @opindex mcmov |
ddf6fe37 | 29843 | @item -mcmov |
d77de738 ML |
29844 | Enable generation of conditional move (@code{l.cmov}) instructions. By |
29845 | default the equivalent will be generated using set and branch. | |
29846 | ||
d77de738 | 29847 | @opindex mror |
ddf6fe37 | 29848 | @item -mror |
d77de738 ML |
29849 | Enable generation of rotate right (@code{l.ror}) instructions. By default |
29850 | functions from @file{libgcc} are used to perform rotate right operations. | |
29851 | ||
d77de738 | 29852 | @opindex mrori |
ddf6fe37 | 29853 | @item -mrori |
d77de738 ML |
29854 | Enable generation of rotate right with immediate (@code{l.rori}) instructions. |
29855 | By default functions from @file{libgcc} are used to perform rotate right with | |
29856 | immediate operations. | |
29857 | ||
d77de738 | 29858 | @opindex msext |
ddf6fe37 | 29859 | @item -msext |
d77de738 ML |
29860 | Enable generation of sign extension (@code{l.ext*}) instructions. By default |
29861 | memory loads are used to perform sign extension. | |
29862 | ||
d77de738 | 29863 | @opindex msfimm |
ddf6fe37 | 29864 | @item -msfimm |
d77de738 ML |
29865 | Enable generation of compare and set flag with immediate (@code{l.sf*i}) |
29866 | instructions. By default extra instructions will be generated to store the | |
29867 | immediate to a register first. | |
29868 | ||
d77de738 | 29869 | @opindex mshftimm |
ddf6fe37 | 29870 | @item -mshftimm |
d77de738 ML |
29871 | Enable generation of shift with immediate (@code{l.srai}, @code{l.srli}, |
29872 | @code{l.slli}) instructions. By default extra instructions will be generated | |
29873 | to store the immediate to a register first. | |
29874 | ||
d77de738 | 29875 | @opindex mcmodel=small |
ddf6fe37 | 29876 | @item -mcmodel=small |
d77de738 ML |
29877 | Generate OpenRISC code for the small model: The GOT is limited to 64k. This is |
29878 | the default model. | |
29879 | ||
d77de738 | 29880 | @opindex mcmodel=large |
ddf6fe37 | 29881 | @item -mcmodel=large |
d77de738 ML |
29882 | Generate OpenRISC code for the large model: The GOT may grow up to 4G in size. |
29883 | ||
29884 | ||
29885 | @end table | |
29886 | ||
29887 | @node PDP-11 Options | |
29888 | @subsection PDP-11 Options | |
29889 | @cindex PDP-11 Options | |
29890 | ||
29891 | These options are defined for the PDP-11: | |
29892 | ||
29893 | @table @gcctabopt | |
d77de738 | 29894 | @opindex mfpu |
ddf6fe37 | 29895 | @item -mfpu |
d77de738 ML |
29896 | Use hardware FPP floating point. This is the default. (FIS floating |
29897 | point on the PDP-11/40 is not supported.) Implies -m45. | |
29898 | ||
d77de738 | 29899 | @opindex msoft-float |
ddf6fe37 | 29900 | @item -msoft-float |
d77de738 ML |
29901 | Do not use hardware floating point. |
29902 | ||
d77de738 | 29903 | @opindex mac0 |
ddf6fe37 | 29904 | @item -mac0 |
d77de738 ML |
29905 | Return floating-point results in ac0 (fr0 in Unix assembler syntax). |
29906 | ||
d77de738 | 29907 | @opindex mno-ac0 |
ddf6fe37 | 29908 | @item -mno-ac0 |
d77de738 ML |
29909 | Return floating-point results in memory. This is the default. |
29910 | ||
d77de738 | 29911 | @opindex m40 |
ddf6fe37 | 29912 | @item -m40 |
d77de738 ML |
29913 | Generate code for a PDP-11/40. Implies -msoft-float -mno-split. |
29914 | ||
d77de738 | 29915 | @opindex m45 |
ddf6fe37 | 29916 | @item -m45 |
d77de738 ML |
29917 | Generate code for a PDP-11/45. This is the default. |
29918 | ||
d77de738 | 29919 | @opindex m10 |
ddf6fe37 | 29920 | @item -m10 |
d77de738 ML |
29921 | Generate code for a PDP-11/10. Implies -msoft-float -mno-split. |
29922 | ||
d77de738 ML |
29923 | @opindex mint16 |
29924 | @opindex mno-int32 | |
ddf6fe37 AA |
29925 | @item -mint16 |
29926 | @itemx -mno-int32 | |
d77de738 ML |
29927 | Use 16-bit @code{int}. This is the default. |
29928 | ||
d77de738 ML |
29929 | @opindex mint32 |
29930 | @opindex mno-int16 | |
ddf6fe37 AA |
29931 | @item -mint32 |
29932 | @itemx -mno-int16 | |
d77de738 ML |
29933 | Use 32-bit @code{int}. |
29934 | ||
d77de738 | 29935 | @opindex msplit |
ddf6fe37 | 29936 | @item -msplit |
d77de738 ML |
29937 | Target has split instruction and data space. Implies -m45. |
29938 | ||
d77de738 | 29939 | @opindex munix-asm |
ddf6fe37 | 29940 | @item -munix-asm |
d77de738 ML |
29941 | Use Unix assembler syntax. |
29942 | ||
d77de738 | 29943 | @opindex mdec-asm |
ddf6fe37 | 29944 | @item -mdec-asm |
d77de738 ML |
29945 | Use DEC assembler syntax. |
29946 | ||
d77de738 | 29947 | @opindex mgnu-asm |
ddf6fe37 | 29948 | @item -mgnu-asm |
d77de738 ML |
29949 | Use GNU assembler syntax. This is the default. |
29950 | ||
d77de738 | 29951 | @opindex mlra |
ddf6fe37 | 29952 | @item -mlra |
d77de738 ML |
29953 | Use the new LRA register allocator. By default, the old ``reload'' |
29954 | allocator is used. | |
29955 | @end table | |
29956 | ||
d77de738 ML |
29957 | @node PowerPC Options |
29958 | @subsection PowerPC Options | |
29959 | @cindex PowerPC options | |
29960 | ||
29961 | These are listed under @xref{RS/6000 and PowerPC Options}. | |
29962 | ||
29963 | @node PRU Options | |
29964 | @subsection PRU Options | |
29965 | @cindex PRU Options | |
29966 | ||
29967 | These command-line options are defined for PRU target: | |
29968 | ||
29969 | @table @gcctabopt | |
d77de738 | 29970 | @opindex minrt |
ddf6fe37 | 29971 | @item -minrt |
d77de738 ML |
29972 | Link with a minimum runtime environment, with no support for static |
29973 | initializers and constructors. Using this option can significantly reduce | |
29974 | the size of the final ELF binary. Beware that the compiler could still | |
29975 | generate code with static initializers and constructors. It is up to the | |
29976 | programmer to ensure that the source program will not use those features. | |
29977 | ||
d77de738 | 29978 | @opindex mmcu |
ddf6fe37 | 29979 | @item -mmcu=@var{mcu} |
d77de738 ML |
29980 | Specify the PRU MCU variant to use. Check Newlib for the exact list of |
29981 | supported MCUs. | |
29982 | ||
d77de738 | 29983 | @opindex mno-relax |
ddf6fe37 | 29984 | @item -mno-relax |
d77de738 ML |
29985 | Make GCC pass the @option{--no-relax} command-line option to the linker |
29986 | instead of the @option{--relax} option. | |
29987 | ||
d77de738 | 29988 | @opindex mloop |
ddf6fe37 | 29989 | @item -mloop |
d77de738 ML |
29990 | Allow (or do not allow) GCC to use the LOOP instruction. |
29991 | ||
d77de738 | 29992 | @opindex mabi |
ddf6fe37 | 29993 | @item -mabi=@var{variant} |
d77de738 ML |
29994 | Specify the ABI variant to output code for. @option{-mabi=ti} selects the |
29995 | unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes | |
29996 | more naturally with certain GCC assumptions. These are the differences: | |
29997 | ||
29998 | @table @samp | |
29999 | @item Function Pointer Size | |
30000 | TI ABI specifies that function (code) pointers are 16-bit, whereas GNU | |
30001 | supports only 32-bit data and code pointers. | |
30002 | ||
30003 | @item Optional Return Value Pointer | |
30004 | Function return values larger than 64 bits are passed by using a hidden | |
30005 | pointer as the first argument of the function. TI ABI, though, mandates that | |
30006 | the pointer can be NULL in case the caller is not using the returned value. | |
30007 | GNU always passes and expects a valid return value pointer. | |
30008 | ||
30009 | @end table | |
30010 | ||
30011 | The current @option{-mabi=ti} implementation simply raises a compile error | |
30012 | when any of the above code constructs is detected. As a consequence | |
30013 | the standard C library cannot be built and it is omitted when linking with | |
30014 | @option{-mabi=ti}. | |
30015 | ||
30016 | Relaxation is a GNU feature and for safety reasons is disabled when using | |
30017 | @option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx | |
30018 | instructions, so the GNU linker cannot adjust them when shortening adjacent | |
30019 | LDI32 pseudo instructions. | |
30020 | ||
30021 | @end table | |
30022 | ||
30023 | @node RISC-V Options | |
30024 | @subsection RISC-V Options | |
30025 | @cindex RISC-V Options | |
30026 | ||
30027 | These command-line options are defined for RISC-V targets: | |
30028 | ||
30029 | @table @gcctabopt | |
d77de738 | 30030 | @opindex mbranch-cost |
ddf6fe37 | 30031 | @item -mbranch-cost=@var{n} |
d77de738 ML |
30032 | Set the cost of branches to roughly @var{n} instructions. |
30033 | ||
ddf6fe37 | 30034 | @opindex plt |
d77de738 ML |
30035 | @item -mplt |
30036 | @itemx -mno-plt | |
d77de738 ML |
30037 | When generating PIC code, do or don't allow the use of PLTs. Ignored for |
30038 | non-PIC. The default is @option{-mplt}. | |
30039 | ||
d77de738 | 30040 | @opindex mabi |
ddf6fe37 | 30041 | @item -mabi=@var{ABI-string} |
d77de738 ML |
30042 | Specify integer and floating-point calling convention. @var{ABI-string} |
30043 | contains two parts: the size of integer types and the registers used for | |
30044 | floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that | |
30045 | @samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be | |
30046 | 32-bit), and that floating-point values up to 64 bits wide are passed in F | |
30047 | registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still | |
30048 | allows the compiler to generate code that uses the F and D extensions but only | |
30049 | allows floating-point values up to 32 bits long to be passed in registers; or | |
30050 | @samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be | |
30051 | passed in registers. | |
30052 | ||
30053 | The default for this argument is system dependent, users who want a specific | |
30054 | calling convention should specify one explicitly. The valid calling | |
30055 | conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64}, | |
30056 | @samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to | |
30057 | implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is | |
30058 | invalid because the ABI requires 64-bit values be passed in F registers, but F | |
006e90e1 TO |
30059 | registers are only 32 bits wide. There are also the @samp{ilp32e} ABI that can |
30060 | only be used with the @samp{rv32e} architecture and the @samp{lp64e} ABI that | |
30061 | can only be used with the @samp{rv64e}. Those ABIs are not well specified at | |
30062 | present, and are subject to change. | |
d77de738 | 30063 | |
ddf6fe37 | 30064 | @opindex mfdiv |
d77de738 ML |
30065 | @item -mfdiv |
30066 | @itemx -mno-fdiv | |
d77de738 ML |
30067 | Do or don't use hardware floating-point divide and square root instructions. |
30068 | This requires the F or D extensions for floating-point registers. The default | |
30069 | is to use them if the specified architecture has these instructions. | |
30070 | ||
ddf6fe37 | 30071 | @opindex mdiv |
d77de738 ML |
30072 | @item -mdiv |
30073 | @itemx -mno-div | |
d77de738 ML |
30074 | Do or don't use hardware instructions for integer division. This requires the |
30075 | M extension. The default is to use them if the specified architecture has | |
30076 | these instructions. | |
30077 | ||
d77de738 | 30078 | @opindex misa-spec |
ddf6fe37 | 30079 | @item -misa-spec=@var{ISA-spec-string} |
d77de738 ML |
30080 | Specify the version of the RISC-V Unprivileged (formerly User-Level) |
30081 | ISA specification to produce code conforming to. The possibilities | |
30082 | for @var{ISA-spec-string} are: | |
30083 | @table @code | |
30084 | @item 2.2 | |
30085 | Produce code conforming to version 2.2. | |
30086 | @item 20190608 | |
30087 | Produce code conforming to version 20190608. | |
30088 | @item 20191213 | |
30089 | Produce code conforming to version 20191213. | |
30090 | @end table | |
30091 | The default is @option{-misa-spec=20191213} unless GCC has been configured | |
30092 | with @option{--with-isa-spec=} specifying a different default version. | |
30093 | ||
d77de738 | 30094 | @opindex march |
ddf6fe37 | 30095 | @item -march=@var{ISA-string} |
d77de738 ML |
30096 | Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be |
30097 | lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and | |
30098 | @samp{rv32imaf}. | |
30099 | ||
30100 | When @option{-march=} is not specified, use the setting from @option{-mcpu}. | |
30101 | ||
30102 | If both @option{-march} and @option{-mcpu=} are not specified, the default for | |
30103 | this argument is system dependent, users who want a specific architecture | |
30104 | extensions should specify one explicitly. | |
30105 | ||
d77de738 | 30106 | @opindex mcpu |
ddf6fe37 | 30107 | @item -mcpu=@var{processor-string} |
d77de738 ML |
30108 | Use architecture of and optimize the output for the given processor, specified |
30109 | by particular CPU name. | |
30110 | Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21}, | |
30111 | @samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76}, | |
30112 | @samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76}, | |
ba94969b | 30113 | @samp{sifive-u54}, @samp{sifive-u74}, and @samp{sifive-x280}. |
d77de738 | 30114 | |
d77de738 | 30115 | @opindex mtune |
ddf6fe37 | 30116 | @item -mtune=@var{processor-string} |
d77de738 ML |
30117 | Optimize the output for the given processor, specified by microarchitecture or |
30118 | particular CPU name. Permissible values for this option are: @samp{rocket}, | |
30119 | @samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series}, | |
aa37a91c | 30120 | @samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}. |
d77de738 ML |
30121 | |
30122 | When @option{-mtune=} is not specified, use the setting from @option{-mcpu}, | |
30123 | the default is @samp{rocket} if both are not specified. | |
30124 | ||
30125 | The @samp{size} choice is not intended for use by end-users. This is used | |
30126 | when @option{-Os} is specified. It overrides the instruction cost info | |
30127 | provided by @option{-mtune=}, but does not override the pipeline info. This | |
30128 | helps reduce code size while still giving good performance. | |
30129 | ||
d77de738 | 30130 | @opindex mpreferred-stack-boundary |
ddf6fe37 | 30131 | @item -mpreferred-stack-boundary=@var{num} |
d77de738 ML |
30132 | Attempt to keep the stack boundary aligned to a 2 raised to @var{num} |
30133 | byte boundary. If @option{-mpreferred-stack-boundary} is not specified, | |
30134 | the default is 4 (16 bytes or 128-bits). | |
30135 | ||
30136 | @strong{Warning:} If you use this switch, then you must build all modules with | |
30137 | the same value, including any libraries. This includes the system libraries | |
30138 | and startup modules. | |
30139 | ||
d77de738 | 30140 | @opindex msmall-data-limit |
ddf6fe37 | 30141 | @item -msmall-data-limit=@var{n} |
d77de738 ML |
30142 | Put global and static data smaller than @var{n} bytes into a special section |
30143 | (on some targets). | |
30144 | ||
ddf6fe37 | 30145 | @opindex msave-restore |
d77de738 ML |
30146 | @item -msave-restore |
30147 | @itemx -mno-save-restore | |
d77de738 ML |
30148 | Do or don't use smaller but slower prologue and epilogue code that uses |
30149 | library function calls. The default is to use fast inline prologues and | |
30150 | epilogues. | |
30151 | ||
dc95b338 MR |
30152 | @opindex mmovcc |
30153 | @item -mmovcc | |
30154 | @itemx -mno-movcc | |
30155 | Do or don't produce branchless conditional-move code sequences even with | |
30156 | targets that do not have specific instructions for conditional operations. | |
30157 | If enabled, sequences of ALU operations are produced using base integer | |
30158 | ISA instructions where profitable. | |
30159 | ||
f797260a PN |
30160 | @opindex minline-atomics |
30161 | @item -minline-atomics | |
30162 | @itemx -mno-inline-atomics | |
30163 | Do or don't use smaller but slower subword atomic emulation code that uses | |
30164 | libatomic function calls. The default is to use fast inline subword atomics | |
30165 | that do not require libatomic. | |
30166 | ||
df48285b CM |
30167 | @opindex minline-strlen |
30168 | @item -minline-strlen | |
30169 | @itemx -mno-inline-strlen | |
30170 | Do or do not attempt to inline strlen calls if possible. | |
30171 | Inlining will only be done if the string is properly aligned | |
30172 | and instructions for accelerated processing are available. | |
30173 | The default is to not inline strlen calls. | |
30174 | ||
949f1ccf CM |
30175 | @opindex minline-strcmp |
30176 | @item -minline-strcmp | |
30177 | @itemx -mno-inline-strcmp | |
30178 | Do or do not attempt to inline strcmp calls if possible. | |
30179 | Inlining will only be done if the strings are properly aligned | |
30180 | and instructions for accelerated processing are available. | |
30181 | The default is to not inline strcmp calls. | |
30182 | ||
82576a6e CM |
30183 | The @option{--param riscv-strcmp-inline-limit=@var{n}} parameter controls |
30184 | the maximum number of bytes compared by the inlined code. | |
30185 | The default value is 64. | |
30186 | ||
949f1ccf CM |
30187 | @opindex minline-strncmp |
30188 | @item -minline-strncmp | |
30189 | @itemx -mno-inline-strncmp | |
30190 | Do or do not attempt to inline strncmp calls if possible. | |
30191 | Inlining will only be done if the strings are properly aligned | |
30192 | and instructions for accelerated processing are available. | |
30193 | The default is to not inline strncmp calls. | |
30194 | ||
82576a6e CM |
30195 | The @option{--param riscv-strcmp-inline-limit=@var{n}} parameter controls |
30196 | the maximum number of bytes compared by the inlined code. | |
30197 | The default value is 64. | |
30198 | ||
ddf6fe37 | 30199 | @opindex mshorten-memrefs |
d77de738 ML |
30200 | @item -mshorten-memrefs |
30201 | @itemx -mno-shorten-memrefs | |
d77de738 ML |
30202 | Do or do not attempt to make more use of compressed load/store instructions by |
30203 | replacing a load/store of 'base register + large offset' with a new load/store | |
30204 | of 'new base + small offset'. If the new base gets stored in a compressed | |
30205 | register, then the new load/store can be compressed. Currently targets 32-bit | |
30206 | integer load/stores only. | |
30207 | ||
ddf6fe37 | 30208 | @opindex mstrict-align |
d77de738 ML |
30209 | @item -mstrict-align |
30210 | @itemx -mno-strict-align | |
d77de738 ML |
30211 | Do not or do generate unaligned memory accesses. The default is set depending |
30212 | on whether the processor we are optimizing for supports fast unaligned access | |
30213 | or not. | |
30214 | ||
d77de738 | 30215 | @opindex mcmodel=medlow |
ddf6fe37 | 30216 | @item -mcmodel=medlow |
d77de738 ML |
30217 | Generate code for the medium-low code model. The program and its statically |
30218 | defined symbols must lie within a single 2 GiB address range and must lie | |
30219 | between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be | |
30220 | statically or dynamically linked. This is the default code model. | |
30221 | ||
d77de738 | 30222 | @opindex mcmodel=medany |
ddf6fe37 | 30223 | @item -mcmodel=medany |
d77de738 ML |
30224 | Generate code for the medium-any code model. The program and its statically |
30225 | defined symbols must be within any single 2 GiB address range. Programs can be | |
30226 | statically or dynamically linked. | |
30227 | ||
30228 | The code generated by the medium-any code model is position-independent, but is | |
30229 | not guaranteed to function correctly when linked into position-independent | |
30230 | executables or libraries. | |
30231 | ||
30232 | @item -mexplicit-relocs | |
30233 | @itemx -mno-exlicit-relocs | |
30234 | Use or do not use assembler relocation operators when dealing with symbolic | |
30235 | addresses. The alternative is to use assembler macros instead, which may | |
30236 | limit optimization. | |
30237 | ||
ddf6fe37 | 30238 | @opindex mrelax |
d77de738 ML |
30239 | @item -mrelax |
30240 | @itemx -mno-relax | |
d77de738 ML |
30241 | Take advantage of linker relaxations to reduce the number of instructions |
30242 | required to materialize symbol addresses. The default is to take advantage of | |
30243 | linker relaxations. | |
30244 | ||
ddf6fe37 | 30245 | @opindex mriscv-attribute |
d77de738 ML |
30246 | @item -mriscv-attribute |
30247 | @itemx -mno-riscv-attribute | |
d77de738 ML |
30248 | Emit (do not emit) RISC-V attribute to record extra information into ELF |
30249 | objects. This feature requires at least binutils 2.32. | |
30250 | ||
ddf6fe37 | 30251 | @opindex mcsr-check |
d77de738 ML |
30252 | @item -mcsr-check |
30253 | @itemx -mno-csr-check | |
d77de738 ML |
30254 | Enables or disables the CSR checking. |
30255 | ||
d77de738 | 30256 | @opindex malign-data |
ddf6fe37 | 30257 | @item -malign-data=@var{type} |
d77de738 ML |
30258 | Control how GCC aligns variables and constants of array, structure, or union |
30259 | types. Supported values for @var{type} are @samp{xlen} which uses x register | |
30260 | width as the alignment value, and @samp{natural} which uses natural alignment. | |
30261 | @samp{xlen} is the default. | |
30262 | ||
d77de738 | 30263 | @opindex mbig-endian |
ddf6fe37 | 30264 | @item -mbig-endian |
d77de738 ML |
30265 | Generate big-endian code. This is the default when GCC is configured for a |
30266 | @samp{riscv64be-*-*} or @samp{riscv32be-*-*} target. | |
30267 | ||
d77de738 | 30268 | @opindex mlittle-endian |
ddf6fe37 | 30269 | @item -mlittle-endian |
d77de738 ML |
30270 | Generate little-endian code. This is the default when GCC is configured for a |
30271 | @samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or | |
30272 | @samp{riscv32be-*-*} target. | |
30273 | ||
d77de738 ML |
30274 | @opindex mstack-protector-guard |
30275 | @opindex mstack-protector-guard-reg | |
30276 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
30277 | @item -mstack-protector-guard=@var{guard} |
30278 | @itemx -mstack-protector-guard-reg=@var{reg} | |
30279 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
30280 | Generate stack protection code using canary at @var{guard}. Supported |
30281 | locations are @samp{global} for a global canary or @samp{tls} for per-thread | |
30282 | canary in the TLS block. | |
30283 | ||
30284 | With the latter choice the options | |
30285 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
30286 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
30287 | which register to use as base register for reading the canary, | |
30288 | and from what offset from that base register. There is no default | |
30289 | register or offset as this is entirely for use within the Linux | |
30290 | kernel. | |
30291 | @end table | |
30292 | ||
30293 | @node RL78 Options | |
30294 | @subsection RL78 Options | |
30295 | @cindex RL78 Options | |
30296 | ||
30297 | @table @gcctabopt | |
30298 | ||
d77de738 | 30299 | @opindex msim |
ddf6fe37 | 30300 | @item -msim |
d77de738 ML |
30301 | Links in additional target libraries to support operation within a |
30302 | simulator. | |
30303 | ||
ddf6fe37 | 30304 | @opindex mmul |
d77de738 ML |
30305 | @item -mmul=none |
30306 | @itemx -mmul=g10 | |
30307 | @itemx -mmul=g13 | |
30308 | @itemx -mmul=g14 | |
30309 | @itemx -mmul=rl78 | |
d77de738 ML |
30310 | Specifies the type of hardware multiplication and division support to |
30311 | be used. The simplest is @code{none}, which uses software for both | |
30312 | multiplication and division. This is the default. The @code{g13} | |
30313 | value is for the hardware multiply/divide peripheral found on the | |
30314 | RL78/G13 (S2 core) targets. The @code{g14} value selects the use of | |
30315 | the multiplication and division instructions supported by the RL78/G14 | |
30316 | (S3 core) parts. The value @code{rl78} is an alias for @code{g14} and | |
30317 | the value @code{mg10} is an alias for @code{none}. | |
30318 | ||
30319 | In addition a C preprocessor macro is defined, based upon the setting | |
30320 | of this option. Possible values are: @code{__RL78_MUL_NONE__}, | |
30321 | @code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}. | |
30322 | ||
ddf6fe37 | 30323 | @opindex mcpu |
d77de738 ML |
30324 | @item -mcpu=g10 |
30325 | @itemx -mcpu=g13 | |
30326 | @itemx -mcpu=g14 | |
30327 | @itemx -mcpu=rl78 | |
d77de738 ML |
30328 | Specifies the RL78 core to target. The default is the G14 core, also |
30329 | known as an S3 core or just RL78. The G13 or S2 core does not have | |
30330 | multiply or divide instructions, instead it uses a hardware peripheral | |
30331 | for these operations. The G10 or S1 core does not have register | |
30332 | banks, so it uses a different calling convention. | |
30333 | ||
30334 | If this option is set it also selects the type of hardware multiply | |
30335 | support to use, unless this is overridden by an explicit | |
30336 | @option{-mmul=none} option on the command line. Thus specifying | |
30337 | @option{-mcpu=g13} enables the use of the G13 hardware multiply | |
30338 | peripheral and specifying @option{-mcpu=g10} disables the use of | |
30339 | hardware multiplications altogether. | |
30340 | ||
30341 | Note, although the RL78/G14 core is the default target, specifying | |
30342 | @option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does | |
30343 | change the behavior of the toolchain since it also enables G14 | |
30344 | hardware multiply support. If these options are not specified on the | |
30345 | command line then software multiplication routines will be used even | |
30346 | though the code targets the RL78 core. This is for backwards | |
30347 | compatibility with older toolchains which did not have hardware | |
30348 | multiply and divide support. | |
30349 | ||
30350 | In addition a C preprocessor macro is defined, based upon the setting | |
30351 | of this option. Possible values are: @code{__RL78_G10__}, | |
30352 | @code{__RL78_G13__} or @code{__RL78_G14__}. | |
30353 | ||
d77de738 ML |
30354 | @opindex mg10 |
30355 | @opindex mg13 | |
30356 | @opindex mg14 | |
30357 | @opindex mrl78 | |
ddf6fe37 AA |
30358 | @item -mg10 |
30359 | @itemx -mg13 | |
30360 | @itemx -mg14 | |
30361 | @itemx -mrl78 | |
d77de738 ML |
30362 | These are aliases for the corresponding @option{-mcpu=} option. They |
30363 | are provided for backwards compatibility. | |
30364 | ||
d77de738 | 30365 | @opindex mallregs |
ddf6fe37 | 30366 | @item -mallregs |
d77de738 ML |
30367 | Allow the compiler to use all of the available registers. By default |
30368 | registers @code{r24..r31} are reserved for use in interrupt handlers. | |
30369 | With this option enabled these registers can be used in ordinary | |
30370 | functions as well. | |
30371 | ||
d77de738 ML |
30372 | @opindex m64bit-doubles |
30373 | @opindex m32bit-doubles | |
ddf6fe37 AA |
30374 | @item -m64bit-doubles |
30375 | @itemx -m32bit-doubles | |
d77de738 ML |
30376 | Make the @code{double} data type be 64 bits (@option{-m64bit-doubles}) |
30377 | or 32 bits (@option{-m32bit-doubles}) in size. The default is | |
30378 | @option{-m32bit-doubles}. | |
30379 | ||
d77de738 ML |
30380 | @opindex msave-mduc-in-interrupts |
30381 | @opindex mno-save-mduc-in-interrupts | |
ddf6fe37 AA |
30382 | @item -msave-mduc-in-interrupts |
30383 | @itemx -mno-save-mduc-in-interrupts | |
d77de738 ML |
30384 | Specifies that interrupt handler functions should preserve the |
30385 | MDUC registers. This is only necessary if normal code might use | |
30386 | the MDUC registers, for example because it performs multiplication | |
30387 | and division operations. The default is to ignore the MDUC registers | |
30388 | as this makes the interrupt handlers faster. The target option -mg13 | |
30389 | needs to be passed for this to work as this feature is only available | |
30390 | on the G13 target (S2 core). The MDUC registers will only be saved | |
30391 | if the interrupt handler performs a multiplication or division | |
30392 | operation or it calls another function. | |
30393 | ||
30394 | @end table | |
30395 | ||
30396 | @node RS/6000 and PowerPC Options | |
30397 | @subsection IBM RS/6000 and PowerPC Options | |
30398 | @cindex RS/6000 and PowerPC Options | |
30399 | @cindex IBM RS/6000 and PowerPC Options | |
30400 | ||
30401 | These @samp{-m} options are defined for the IBM RS/6000 and PowerPC: | |
30402 | @table @gcctabopt | |
30403 | @item -mpowerpc-gpopt | |
30404 | @itemx -mno-powerpc-gpopt | |
30405 | @itemx -mpowerpc-gfxopt | |
30406 | @itemx -mno-powerpc-gfxopt | |
30407 | @need 800 | |
30408 | @itemx -mpowerpc64 | |
30409 | @itemx -mno-powerpc64 | |
30410 | @itemx -mmfcrf | |
30411 | @itemx -mno-mfcrf | |
30412 | @itemx -mpopcntb | |
30413 | @itemx -mno-popcntb | |
30414 | @itemx -mpopcntd | |
30415 | @itemx -mno-popcntd | |
30416 | @itemx -mfprnd | |
30417 | @itemx -mno-fprnd | |
30418 | @need 800 | |
d77de738 ML |
30419 | @opindex mpowerpc-gpopt |
30420 | @opindex mno-powerpc-gpopt | |
30421 | @opindex mpowerpc-gfxopt | |
30422 | @opindex mno-powerpc-gfxopt | |
30423 | @opindex mpowerpc64 | |
30424 | @opindex mno-powerpc64 | |
30425 | @opindex mmfcrf | |
30426 | @opindex mno-mfcrf | |
30427 | @opindex mpopcntb | |
30428 | @opindex mno-popcntb | |
30429 | @opindex mpopcntd | |
30430 | @opindex mno-popcntd | |
30431 | @opindex mfprnd | |
30432 | @opindex mno-fprnd | |
30433 | @opindex mcmpb | |
30434 | @opindex mno-cmpb | |
30435 | @opindex mhard-dfp | |
30436 | @opindex mno-hard-dfp | |
ddf6fe37 AA |
30437 | @itemx -mcmpb |
30438 | @itemx -mno-cmpb | |
30439 | @itemx -mhard-dfp | |
30440 | @itemx -mno-hard-dfp | |
d77de738 ML |
30441 | You use these options to specify which instructions are available on the |
30442 | processor you are using. The default value of these options is | |
30443 | determined when configuring GCC@. Specifying the | |
30444 | @option{-mcpu=@var{cpu_type}} overrides the specification of these | |
30445 | options. We recommend you use the @option{-mcpu=@var{cpu_type}} option | |
30446 | rather than the options listed above. | |
30447 | ||
30448 | Specifying @option{-mpowerpc-gpopt} allows | |
30449 | GCC to use the optional PowerPC architecture instructions in the | |
30450 | General Purpose group, including floating-point square root. Specifying | |
30451 | @option{-mpowerpc-gfxopt} allows GCC to | |
30452 | use the optional PowerPC architecture instructions in the Graphics | |
30453 | group, including floating-point select. | |
30454 | ||
30455 | The @option{-mmfcrf} option allows GCC to generate the move from | |
30456 | condition register field instruction implemented on the POWER4 | |
30457 | processor and other processors that support the PowerPC V2.01 | |
30458 | architecture. | |
30459 | The @option{-mpopcntb} option allows GCC to generate the popcount and | |
30460 | double-precision FP reciprocal estimate instruction implemented on the | |
30461 | POWER5 processor and other processors that support the PowerPC V2.02 | |
30462 | architecture. | |
30463 | The @option{-mpopcntd} option allows GCC to generate the popcount | |
30464 | instruction implemented on the POWER7 processor and other processors | |
30465 | that support the PowerPC V2.06 architecture. | |
30466 | The @option{-mfprnd} option allows GCC to generate the FP round to | |
30467 | integer instructions implemented on the POWER5+ processor and other | |
30468 | processors that support the PowerPC V2.03 architecture. | |
30469 | The @option{-mcmpb} option allows GCC to generate the compare bytes | |
30470 | instruction implemented on the POWER6 processor and other processors | |
30471 | that support the PowerPC V2.05 architecture. | |
30472 | The @option{-mhard-dfp} option allows GCC to generate the decimal | |
30473 | floating-point instructions implemented on some POWER processors. | |
30474 | ||
30475 | The @option{-mpowerpc64} option allows GCC to generate the additional | |
30476 | 64-bit instructions that are found in the full PowerPC64 architecture | |
30477 | and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to | |
30478 | @option{-mno-powerpc64}. | |
30479 | ||
d77de738 | 30480 | @opindex mcpu |
ddf6fe37 | 30481 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
30482 | Set architecture type, register usage, and |
30483 | instruction scheduling parameters for machine type @var{cpu_type}. | |
30484 | Supported values for @var{cpu_type} are @samp{401}, @samp{403}, | |
30485 | @samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp}, | |
30486 | @samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603}, | |
30487 | @samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740}, | |
30488 | @samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823}, | |
30489 | @samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2}, | |
30490 | @samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500}, | |
30491 | @samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5}, | |
30492 | @samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+}, | |
30493 | @samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8}, | |
30494 | @samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64}, | |
30495 | @samp{powerpc64le}, @samp{rs64}, and @samp{native}. | |
30496 | ||
30497 | @option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and | |
30498 | @option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either | |
30499 | endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC | |
30500 | architecture machine types, with an appropriate, generic processor | |
30501 | model assumed for scheduling purposes. | |
30502 | ||
30503 | Specifying @samp{native} as cpu type detects and selects the | |
30504 | architecture option that corresponds to the host processor of the | |
30505 | system performing the compilation. | |
30506 | @option{-mcpu=native} has no effect if GCC does not recognize the | |
30507 | processor. | |
30508 | ||
30509 | The other options specify a specific processor. Code generated under | |
30510 | those options runs best on that processor, and may not run at all on | |
30511 | others. | |
30512 | ||
30513 | The @option{-mcpu} options automatically enable or disable the | |
30514 | following options: | |
30515 | ||
43b72ede AA |
30516 | @gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple |
30517 | -mpopcntb -mpopcntd -mpowerpc64 | |
30518 | -mpowerpc-gpopt -mpowerpc-gfxopt | |
30519 | -mmulhw -mdlmzb -mmfpgpr -mvsx | |
30520 | -mcrypto -mhtm -mpower8-fusion -mpower8-vector | |
30521 | -mquad-memory -mquad-memory-atomic -mfloat128 | |
30522 | -mfloat128-hardware -mprefixed -mpcrel -mmma | |
d77de738 ML |
30523 | -mrop-protect} |
30524 | ||
30525 | The particular options set for any particular CPU varies between | |
30526 | compiler versions, depending on what setting seems to produce optimal | |
30527 | code for that CPU; it doesn't necessarily reflect the actual hardware's | |
30528 | capabilities. If you wish to set an individual option to a particular | |
30529 | value, you may specify it after the @option{-mcpu} option, like | |
30530 | @option{-mcpu=970 -mno-altivec}. | |
30531 | ||
30532 | On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are | |
30533 | not enabled or disabled by the @option{-mcpu} option at present because | |
30534 | AIX does not have full support for these options. You may still | |
30535 | enable or disable them individually if you're sure it'll work in your | |
30536 | environment. | |
30537 | ||
d77de738 | 30538 | @opindex mtune |
ddf6fe37 | 30539 | @item -mtune=@var{cpu_type} |
d77de738 ML |
30540 | Set the instruction scheduling parameters for machine type |
30541 | @var{cpu_type}, but do not set the architecture type or register usage, | |
30542 | as @option{-mcpu=@var{cpu_type}} does. The same | |
30543 | values for @var{cpu_type} are used for @option{-mtune} as for | |
30544 | @option{-mcpu}. If both are specified, the code generated uses the | |
30545 | architecture and registers set by @option{-mcpu}, but the | |
30546 | scheduling parameters set by @option{-mtune}. | |
30547 | ||
d77de738 | 30548 | @opindex mcmodel=small |
ddf6fe37 | 30549 | @item -mcmodel=small |
d77de738 ML |
30550 | Generate PowerPC64 code for the small model: The TOC is limited to |
30551 | 64k. | |
30552 | ||
d77de738 | 30553 | @opindex mcmodel=medium |
ddf6fe37 | 30554 | @item -mcmodel=medium |
d77de738 ML |
30555 | Generate PowerPC64 code for the medium model: The TOC and other static |
30556 | data may be up to a total of 4G in size. This is the default for 64-bit | |
30557 | Linux. | |
30558 | ||
d77de738 | 30559 | @opindex mcmodel=large |
ddf6fe37 | 30560 | @item -mcmodel=large |
d77de738 ML |
30561 | Generate PowerPC64 code for the large model: The TOC may be up to 4G |
30562 | in size. Other data and code is only limited by the 64-bit address | |
30563 | space. | |
30564 | ||
d77de738 ML |
30565 | @opindex maltivec |
30566 | @opindex mno-altivec | |
ddf6fe37 AA |
30567 | @item -maltivec |
30568 | @itemx -mno-altivec | |
d77de738 ML |
30569 | Generate code that uses (does not use) AltiVec instructions, and also |
30570 | enable the use of built-in functions that allow more direct access to | |
30571 | the AltiVec instruction set. You may also need to set | |
30572 | @option{-mabi=altivec} to adjust the current ABI with AltiVec ABI | |
30573 | enhancements. | |
30574 | ||
30575 | When @option{-maltivec} is used, the element order for AltiVec intrinsics | |
30576 | such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert} | |
30577 | match array element order corresponding to the endianness of the | |
30578 | target. That is, element zero identifies the leftmost element in a | |
30579 | vector register when targeting a big-endian platform, and identifies | |
30580 | the rightmost element in a vector register when targeting a | |
30581 | little-endian platform. | |
30582 | ||
d77de738 ML |
30583 | @opindex mvrsave |
30584 | @opindex mno-vrsave | |
ddf6fe37 AA |
30585 | @item -mvrsave |
30586 | @itemx -mno-vrsave | |
d77de738 ML |
30587 | Generate VRSAVE instructions when generating AltiVec code. |
30588 | ||
d77de738 | 30589 | @opindex msecure-plt |
ddf6fe37 | 30590 | @item -msecure-plt |
d77de738 ML |
30591 | Generate code that allows @command{ld} and @command{ld.so} |
30592 | to build executables and shared | |
30593 | libraries with non-executable @code{.plt} and @code{.got} sections. | |
30594 | This is a PowerPC | |
30595 | 32-bit SYSV ABI option. | |
30596 | ||
d77de738 | 30597 | @opindex mbss-plt |
ddf6fe37 | 30598 | @item -mbss-plt |
d77de738 ML |
30599 | Generate code that uses a BSS @code{.plt} section that @command{ld.so} |
30600 | fills in, and | |
30601 | requires @code{.plt} and @code{.got} | |
30602 | sections that are both writable and executable. | |
30603 | This is a PowerPC 32-bit SYSV ABI option. | |
30604 | ||
d77de738 ML |
30605 | @opindex misel |
30606 | @opindex mno-isel | |
ddf6fe37 AA |
30607 | @item -misel |
30608 | @itemx -mno-isel | |
d77de738 ML |
30609 | This switch enables or disables the generation of ISEL instructions. |
30610 | ||
d77de738 ML |
30611 | @opindex mvsx |
30612 | @opindex mno-vsx | |
ddf6fe37 AA |
30613 | @item -mvsx |
30614 | @itemx -mno-vsx | |
d77de738 ML |
30615 | Generate code that uses (does not use) vector/scalar (VSX) |
30616 | instructions, and also enable the use of built-in functions that allow | |
30617 | more direct access to the VSX instruction set. | |
30618 | ||
d77de738 ML |
30619 | @opindex mcrypto |
30620 | @opindex mno-crypto | |
ddf6fe37 AA |
30621 | @item -mcrypto |
30622 | @itemx -mno-crypto | |
d77de738 ML |
30623 | Enable the use (disable) of the built-in functions that allow direct |
30624 | access to the cryptographic instructions that were added in version | |
30625 | 2.07 of the PowerPC ISA. | |
30626 | ||
d77de738 ML |
30627 | @opindex mhtm |
30628 | @opindex mno-htm | |
ddf6fe37 AA |
30629 | @item -mhtm |
30630 | @itemx -mno-htm | |
d77de738 ML |
30631 | Enable (disable) the use of the built-in functions that allow direct |
30632 | access to the Hardware Transactional Memory (HTM) instructions that | |
30633 | were added in version 2.07 of the PowerPC ISA. | |
30634 | ||
d77de738 ML |
30635 | @opindex mpower8-fusion |
30636 | @opindex mno-power8-fusion | |
ddf6fe37 AA |
30637 | @item -mpower8-fusion |
30638 | @itemx -mno-power8-fusion | |
d77de738 ML |
30639 | Generate code that keeps (does not keeps) some integer operations |
30640 | adjacent so that the instructions can be fused together on power8 and | |
30641 | later processors. | |
30642 | ||
d77de738 ML |
30643 | @opindex mpower8-vector |
30644 | @opindex mno-power8-vector | |
ddf6fe37 AA |
30645 | @item -mpower8-vector |
30646 | @itemx -mno-power8-vector | |
d77de738 ML |
30647 | Generate code that uses (does not use) the vector and scalar |
30648 | instructions that were added in version 2.07 of the PowerPC ISA. Also | |
30649 | enable the use of built-in functions that allow more direct access to | |
30650 | the vector instructions. | |
30651 | ||
d77de738 ML |
30652 | @opindex mquad-memory |
30653 | @opindex mno-quad-memory | |
ddf6fe37 AA |
30654 | @item -mquad-memory |
30655 | @itemx -mno-quad-memory | |
d77de738 ML |
30656 | Generate code that uses (does not use) the non-atomic quad word memory |
30657 | instructions. The @option{-mquad-memory} option requires use of | |
30658 | 64-bit mode. | |
30659 | ||
d77de738 ML |
30660 | @opindex mquad-memory-atomic |
30661 | @opindex mno-quad-memory-atomic | |
ddf6fe37 AA |
30662 | @item -mquad-memory-atomic |
30663 | @itemx -mno-quad-memory-atomic | |
d77de738 ML |
30664 | Generate code that uses (does not use) the atomic quad word memory |
30665 | instructions. The @option{-mquad-memory-atomic} option requires use of | |
30666 | 64-bit mode. | |
30667 | ||
d77de738 ML |
30668 | @opindex mfloat128 |
30669 | @opindex mno-float128 | |
ddf6fe37 AA |
30670 | @item -mfloat128 |
30671 | @itemx -mno-float128 | |
d77de738 ML |
30672 | Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point |
30673 | and use either software emulation for IEEE 128-bit floating point or | |
30674 | hardware instructions. | |
30675 | ||
30676 | The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE | |
30677 | 128-bit floating point support. The IEEE 128-bit floating point is only | |
30678 | supported on Linux. | |
30679 | ||
30680 | The default for @option{-mfloat128} is enabled on PowerPC Linux | |
30681 | systems using the VSX instruction set, and disabled on other systems. | |
30682 | ||
30683 | If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or | |
30684 | @option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating | |
30685 | point support will also enable the generation of ISA 3.0 IEEE 128-bit | |
30686 | floating point instructions. Otherwise, if you do not specify to | |
30687 | generate ISA 3.0 instructions or you are targeting a 32-bit big endian | |
30688 | system, IEEE 128-bit floating point will be done with software | |
30689 | emulation. | |
30690 | ||
d77de738 ML |
30691 | @opindex mfloat128-hardware |
30692 | @opindex mno-float128-hardware | |
ddf6fe37 AA |
30693 | @item -mfloat128-hardware |
30694 | @itemx -mno-float128-hardware | |
d77de738 ML |
30695 | Enable/disable using ISA 3.0 hardware instructions to support the |
30696 | @var{__float128} data type. | |
30697 | ||
30698 | The default for @option{-mfloat128-hardware} is enabled on PowerPC | |
30699 | Linux systems using the ISA 3.0 instruction set, and disabled on other | |
30700 | systems. | |
30701 | ||
d77de738 ML |
30702 | @opindex m32 |
30703 | @opindex m64 | |
ddf6fe37 AA |
30704 | @item -m32 |
30705 | @itemx -m64 | |
d77de738 ML |
30706 | Generate code for 32-bit or 64-bit environments of Darwin and SVR4 |
30707 | targets (including GNU/Linux). The 32-bit environment sets int, long | |
30708 | and pointer to 32 bits and generates code that runs on any PowerPC | |
30709 | variant. The 64-bit environment sets int to 32 bits and long and | |
30710 | pointer to 64 bits, and generates code for PowerPC64, as for | |
30711 | @option{-mpowerpc64}. | |
30712 | ||
d77de738 ML |
30713 | @opindex mfull-toc |
30714 | @opindex mno-fp-in-toc | |
30715 | @opindex mno-sum-in-toc | |
30716 | @opindex mminimal-toc | |
ddf6fe37 AA |
30717 | @item -mfull-toc |
30718 | @itemx -mno-fp-in-toc | |
30719 | @itemx -mno-sum-in-toc | |
30720 | @itemx -mminimal-toc | |
d77de738 ML |
30721 | Modify generation of the TOC (Table Of Contents), which is created for |
30722 | every executable file. The @option{-mfull-toc} option is selected by | |
30723 | default. In that case, GCC allocates at least one TOC entry for | |
30724 | each unique non-automatic variable reference in your program. GCC | |
30725 | also places floating-point constants in the TOC@. However, only | |
30726 | 16,384 entries are available in the TOC@. | |
30727 | ||
30728 | If you receive a linker error message that saying you have overflowed | |
30729 | the available TOC space, you can reduce the amount of TOC space used | |
30730 | with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options. | |
30731 | @option{-mno-fp-in-toc} prevents GCC from putting floating-point | |
30732 | constants in the TOC and @option{-mno-sum-in-toc} forces GCC to | |
30733 | generate code to calculate the sum of an address and a constant at | |
30734 | run time instead of putting that sum into the TOC@. You may specify one | |
30735 | or both of these options. Each causes GCC to produce very slightly | |
30736 | slower and larger code at the expense of conserving TOC space. | |
30737 | ||
30738 | If you still run out of space in the TOC even when you specify both of | |
30739 | these options, specify @option{-mminimal-toc} instead. This option causes | |
30740 | GCC to make only one TOC entry for every file. When you specify this | |
30741 | option, GCC produces code that is slower and larger but which | |
30742 | uses extremely little TOC space. You may wish to use this option | |
30743 | only on files that contain less frequently-executed code. | |
30744 | ||
d77de738 ML |
30745 | @opindex maix64 |
30746 | @opindex maix32 | |
ddf6fe37 AA |
30747 | @item -maix64 |
30748 | @itemx -maix32 | |
d77de738 ML |
30749 | Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit |
30750 | @code{long} type, and the infrastructure needed to support them. | |
30751 | Specifying @option{-maix64} implies @option{-mpowerpc64}, | |
30752 | while @option{-maix32} disables the 64-bit ABI and | |
30753 | implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}. | |
30754 | ||
d77de738 ML |
30755 | @opindex mxl-compat |
30756 | @opindex mno-xl-compat | |
ddf6fe37 AA |
30757 | @item -mxl-compat |
30758 | @itemx -mno-xl-compat | |
d77de738 ML |
30759 | Produce code that conforms more closely to IBM XL compiler semantics |
30760 | when using AIX-compatible ABI@. Pass floating-point arguments to | |
30761 | prototyped functions beyond the register save area (RSA) on the stack | |
30762 | in addition to argument FPRs. Do not assume that most significant | |
30763 | double in 128-bit long double value is properly rounded when comparing | |
30764 | values and converting to double. Use XL symbol names for long double | |
30765 | support routines. | |
30766 | ||
30767 | The AIX calling convention was extended but not initially documented to | |
30768 | handle an obscure K&R C case of calling a function that takes the | |
30769 | address of its arguments with fewer arguments than declared. IBM XL | |
30770 | compilers access floating-point arguments that do not fit in the | |
30771 | RSA from the stack when a subroutine is compiled without | |
30772 | optimization. Because always storing floating-point arguments on the | |
30773 | stack is inefficient and rarely needed, this option is not enabled by | |
30774 | default and only is necessary when calling subroutines compiled by IBM | |
30775 | XL compilers without optimization. | |
30776 | ||
d77de738 | 30777 | @opindex mpe |
ddf6fe37 | 30778 | @item -mpe |
d77de738 ML |
30779 | Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an |
30780 | application written to use message passing with special startup code to | |
30781 | enable the application to run. The system must have PE installed in the | |
30782 | standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file | |
30783 | must be overridden with the @option{-specs=} option to specify the | |
30784 | appropriate directory location. The Parallel Environment does not | |
30785 | support threads, so the @option{-mpe} option and the @option{-pthread} | |
30786 | option are incompatible. | |
30787 | ||
d77de738 ML |
30788 | @opindex malign-natural |
30789 | @opindex malign-power | |
ddf6fe37 AA |
30790 | @item -malign-natural |
30791 | @itemx -malign-power | |
d77de738 ML |
30792 | On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option |
30793 | @option{-malign-natural} overrides the ABI-defined alignment of larger | |
30794 | types, such as floating-point doubles, on their natural size-based boundary. | |
30795 | The option @option{-malign-power} instructs GCC to follow the ABI-specified | |
30796 | alignment rules. GCC defaults to the standard alignment defined in the ABI@. | |
30797 | ||
30798 | On 64-bit Darwin, natural alignment is the default, and @option{-malign-power} | |
30799 | is not supported. | |
30800 | ||
d77de738 ML |
30801 | @opindex msoft-float |
30802 | @opindex mhard-float | |
ddf6fe37 AA |
30803 | @item -msoft-float |
30804 | @itemx -mhard-float | |
d77de738 ML |
30805 | Generate code that does not use (uses) the floating-point register set. |
30806 | Software floating-point emulation is provided if you use the | |
30807 | @option{-msoft-float} option, and pass the option to GCC when linking. | |
30808 | ||
d77de738 ML |
30809 | @opindex mmultiple |
30810 | @opindex mno-multiple | |
ddf6fe37 AA |
30811 | @item -mmultiple |
30812 | @itemx -mno-multiple | |
d77de738 ML |
30813 | Generate code that uses (does not use) the load multiple word |
30814 | instructions and the store multiple word instructions. These | |
30815 | instructions are generated by default on POWER systems, and not | |
30816 | generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian | |
30817 | PowerPC systems, since those instructions do not work when the | |
30818 | processor is in little-endian mode. The exceptions are PPC740 and | |
30819 | PPC750 which permit these instructions in little-endian mode. | |
30820 | ||
d77de738 ML |
30821 | @opindex mupdate |
30822 | @opindex mno-update | |
ddf6fe37 AA |
30823 | @item -mupdate |
30824 | @itemx -mno-update | |
d77de738 ML |
30825 | Generate code that uses (does not use) the load or store instructions |
30826 | that update the base register to the address of the calculated memory | |
30827 | location. These instructions are generated by default. If you use | |
30828 | @option{-mno-update}, there is a small window between the time that the | |
30829 | stack pointer is updated and the address of the previous frame is | |
30830 | stored, which means code that walks the stack frame across interrupts or | |
30831 | signals may get corrupted data. | |
30832 | ||
d77de738 ML |
30833 | @opindex mavoid-indexed-addresses |
30834 | @opindex mno-avoid-indexed-addresses | |
ddf6fe37 AA |
30835 | @item -mavoid-indexed-addresses |
30836 | @itemx -mno-avoid-indexed-addresses | |
d77de738 ML |
30837 | Generate code that tries to avoid (not avoid) the use of indexed load |
30838 | or store instructions. These instructions can incur a performance | |
30839 | penalty on Power6 processors in certain situations, such as when | |
30840 | stepping through large arrays that cross a 16M boundary. This option | |
30841 | is enabled by default when targeting Power6 and disabled otherwise. | |
30842 | ||
d77de738 ML |
30843 | @opindex mfused-madd |
30844 | @opindex mno-fused-madd | |
ddf6fe37 AA |
30845 | @item -mfused-madd |
30846 | @itemx -mno-fused-madd | |
d77de738 ML |
30847 | Generate code that uses (does not use) the floating-point multiply and |
30848 | accumulate instructions. These instructions are generated by default | |
30849 | if hardware floating point is used. The machine-dependent | |
30850 | @option{-mfused-madd} option is now mapped to the machine-independent | |
30851 | @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is | |
30852 | mapped to @option{-ffp-contract=off}. | |
30853 | ||
d77de738 ML |
30854 | @opindex mmulhw |
30855 | @opindex mno-mulhw | |
ddf6fe37 AA |
30856 | @item -mmulhw |
30857 | @itemx -mno-mulhw | |
d77de738 ML |
30858 | Generate code that uses (does not use) the half-word multiply and |
30859 | multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors. | |
30860 | These instructions are generated by default when targeting those | |
30861 | processors. | |
30862 | ||
d77de738 ML |
30863 | @opindex mdlmzb |
30864 | @opindex mno-dlmzb | |
ddf6fe37 AA |
30865 | @item -mdlmzb |
30866 | @itemx -mno-dlmzb | |
d77de738 ML |
30867 | Generate code that uses (does not use) the string-search @samp{dlmzb} |
30868 | instruction on the IBM 405, 440, 464 and 476 processors. This instruction is | |
30869 | generated by default when targeting those processors. | |
30870 | ||
d77de738 ML |
30871 | @opindex mno-bit-align |
30872 | @opindex mbit-align | |
ddf6fe37 AA |
30873 | @item -mno-bit-align |
30874 | @itemx -mbit-align | |
d77de738 ML |
30875 | On System V.4 and embedded PowerPC systems do not (do) force structures |
30876 | and unions that contain bit-fields to be aligned to the base type of the | |
30877 | bit-field. | |
30878 | ||
30879 | For example, by default a structure containing nothing but 8 | |
30880 | @code{unsigned} bit-fields of length 1 is aligned to a 4-byte | |
30881 | boundary and has a size of 4 bytes. By using @option{-mno-bit-align}, | |
30882 | the structure is aligned to a 1-byte boundary and is 1 byte in | |
30883 | size. | |
30884 | ||
d77de738 ML |
30885 | @opindex mno-strict-align |
30886 | @opindex mstrict-align | |
ddf6fe37 AA |
30887 | @item -mno-strict-align |
30888 | @itemx -mstrict-align | |
d77de738 ML |
30889 | On System V.4 and embedded PowerPC systems do not (do) assume that |
30890 | unaligned memory references are handled by the system. | |
30891 | ||
d77de738 ML |
30892 | @opindex mrelocatable |
30893 | @opindex mno-relocatable | |
ddf6fe37 AA |
30894 | @item -mrelocatable |
30895 | @itemx -mno-relocatable | |
d77de738 ML |
30896 | Generate code that allows (does not allow) a static executable to be |
30897 | relocated to a different address at run time. A simple embedded | |
30898 | PowerPC system loader should relocate the entire contents of | |
30899 | @code{.got2} and 4-byte locations listed in the @code{.fixup} section, | |
30900 | a table of 32-bit addresses generated by this option. For this to | |
30901 | work, all objects linked together must be compiled with | |
30902 | @option{-mrelocatable} or @option{-mrelocatable-lib}. | |
30903 | @option{-mrelocatable} code aligns the stack to an 8-byte boundary. | |
30904 | ||
d77de738 ML |
30905 | @opindex mrelocatable-lib |
30906 | @opindex mno-relocatable-lib | |
ddf6fe37 AA |
30907 | @item -mrelocatable-lib |
30908 | @itemx -mno-relocatable-lib | |
d77de738 ML |
30909 | Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a |
30910 | @code{.fixup} section to allow static executables to be relocated at | |
30911 | run time, but @option{-mrelocatable-lib} does not use the smaller stack | |
30912 | alignment of @option{-mrelocatable}. Objects compiled with | |
30913 | @option{-mrelocatable-lib} may be linked with objects compiled with | |
30914 | any combination of the @option{-mrelocatable} options. | |
30915 | ||
d77de738 ML |
30916 | @opindex mno-toc |
30917 | @opindex mtoc | |
ddf6fe37 AA |
30918 | @item -mno-toc |
30919 | @itemx -mtoc | |
d77de738 ML |
30920 | On System V.4 and embedded PowerPC systems do not (do) assume that |
30921 | register 2 contains a pointer to a global area pointing to the addresses | |
30922 | used in the program. | |
30923 | ||
d77de738 ML |
30924 | @opindex mlittle |
30925 | @opindex mlittle-endian | |
ddf6fe37 AA |
30926 | @item -mlittle |
30927 | @itemx -mlittle-endian | |
d77de738 ML |
30928 | On System V.4 and embedded PowerPC systems compile code for the |
30929 | processor in little-endian mode. The @option{-mlittle-endian} option is | |
30930 | the same as @option{-mlittle}. | |
30931 | ||
d77de738 ML |
30932 | @opindex mbig |
30933 | @opindex mbig-endian | |
ddf6fe37 AA |
30934 | @item -mbig |
30935 | @itemx -mbig-endian | |
d77de738 ML |
30936 | On System V.4 and embedded PowerPC systems compile code for the |
30937 | processor in big-endian mode. The @option{-mbig-endian} option is | |
30938 | the same as @option{-mbig}. | |
30939 | ||
d77de738 | 30940 | @opindex mdynamic-no-pic |
ddf6fe37 | 30941 | @item -mdynamic-no-pic |
a335cf24 | 30942 | On Darwin / macOS systems, compile code so that it is not |
d77de738 ML |
30943 | relocatable, but that its external references are relocatable. The |
30944 | resulting code is suitable for applications, but not shared | |
30945 | libraries. | |
30946 | ||
d77de738 | 30947 | @opindex msingle-pic-base |
ddf6fe37 | 30948 | @item -msingle-pic-base |
d77de738 ML |
30949 | Treat the register used for PIC addressing as read-only, rather than |
30950 | loading it in the prologue for each function. The runtime system is | |
30951 | responsible for initializing this register with an appropriate value | |
30952 | before execution begins. | |
30953 | ||
d77de738 | 30954 | @opindex mprioritize-restricted-insns |
ddf6fe37 | 30955 | @item -mprioritize-restricted-insns=@var{priority} |
d77de738 ML |
30956 | This option controls the priority that is assigned to |
30957 | dispatch-slot restricted instructions during the second scheduling | |
30958 | pass. The argument @var{priority} takes the value @samp{0}, @samp{1}, | |
30959 | or @samp{2} to assign no, highest, or second-highest (respectively) | |
30960 | priority to dispatch-slot restricted | |
30961 | instructions. | |
30962 | ||
d77de738 | 30963 | @opindex msched-costly-dep |
ddf6fe37 | 30964 | @item -msched-costly-dep=@var{dependence_type} |
d77de738 ML |
30965 | This option controls which dependences are considered costly |
30966 | by the target during instruction scheduling. The argument | |
30967 | @var{dependence_type} takes one of the following values: | |
30968 | ||
30969 | @table @asis | |
30970 | @item @samp{no} | |
30971 | No dependence is costly. | |
30972 | ||
30973 | @item @samp{all} | |
30974 | All dependences are costly. | |
30975 | ||
30976 | @item @samp{true_store_to_load} | |
30977 | A true dependence from store to load is costly. | |
30978 | ||
30979 | @item @samp{store_to_load} | |
30980 | Any dependence from store to load is costly. | |
30981 | ||
30982 | @item @var{number} | |
30983 | Any dependence for which the latency is greater than or equal to | |
30984 | @var{number} is costly. | |
30985 | @end table | |
30986 | ||
d77de738 | 30987 | @opindex minsert-sched-nops |
ddf6fe37 | 30988 | @item -minsert-sched-nops=@var{scheme} |
d77de738 ML |
30989 | This option controls which NOP insertion scheme is used during |
30990 | the second scheduling pass. The argument @var{scheme} takes one of the | |
30991 | following values: | |
30992 | ||
30993 | @table @asis | |
30994 | @item @samp{no} | |
30995 | Don't insert NOPs. | |
30996 | ||
30997 | @item @samp{pad} | |
30998 | Pad with NOPs any dispatch group that has vacant issue slots, | |
30999 | according to the scheduler's grouping. | |
31000 | ||
31001 | @item @samp{regroup_exact} | |
31002 | Insert NOPs to force costly dependent insns into | |
31003 | separate groups. Insert exactly as many NOPs as needed to force an insn | |
31004 | to a new group, according to the estimated processor grouping. | |
31005 | ||
31006 | @item @var{number} | |
31007 | Insert NOPs to force costly dependent insns into | |
31008 | separate groups. Insert @var{number} NOPs to force an insn to a new group. | |
31009 | @end table | |
31010 | ||
d77de738 | 31011 | @opindex mcall-sysv |
ddf6fe37 | 31012 | @item -mcall-sysv |
d77de738 ML |
31013 | On System V.4 and embedded PowerPC systems compile code using calling |
31014 | conventions that adhere to the March 1995 draft of the System V | |
31015 | Application Binary Interface, PowerPC processor supplement. This is the | |
31016 | default unless you configured GCC using @samp{powerpc-*-eabiaix}. | |
31017 | ||
d77de738 ML |
31018 | @opindex mcall-sysv-eabi |
31019 | @opindex mcall-eabi | |
ddf6fe37 AA |
31020 | @item -mcall-sysv-eabi |
31021 | @itemx -mcall-eabi | |
d77de738 ML |
31022 | Specify both @option{-mcall-sysv} and @option{-meabi} options. |
31023 | ||
d77de738 | 31024 | @opindex mcall-sysv-noeabi |
ddf6fe37 | 31025 | @item -mcall-sysv-noeabi |
d77de738 ML |
31026 | Specify both @option{-mcall-sysv} and @option{-mno-eabi} options. |
31027 | ||
d7971cf7 | 31028 | @opindex mcall-aixdesc |
ddf6fe37 | 31029 | @item -mcall-aixdesc |
d77de738 ML |
31030 | On System V.4 and embedded PowerPC systems compile code for the AIX |
31031 | operating system. | |
31032 | ||
d77de738 | 31033 | @opindex mcall-linux |
ddf6fe37 | 31034 | @item -mcall-linux |
d77de738 ML |
31035 | On System V.4 and embedded PowerPC systems compile code for the |
31036 | Linux-based GNU system. | |
31037 | ||
d77de738 | 31038 | @opindex mcall-freebsd |
ddf6fe37 | 31039 | @item -mcall-freebsd |
d77de738 ML |
31040 | On System V.4 and embedded PowerPC systems compile code for the |
31041 | FreeBSD operating system. | |
31042 | ||
d77de738 | 31043 | @opindex mcall-netbsd |
ddf6fe37 | 31044 | @item -mcall-netbsd |
d77de738 ML |
31045 | On System V.4 and embedded PowerPC systems compile code for the |
31046 | NetBSD operating system. | |
31047 | ||
d7971cf7 | 31048 | @opindex mcall-openbsd |
ddf6fe37 | 31049 | @item -mcall-openbsd |
d77de738 ML |
31050 | On System V.4 and embedded PowerPC systems compile code for the |
31051 | OpenBSD operating system. | |
31052 | ||
d77de738 | 31053 | @opindex mtraceback |
ddf6fe37 | 31054 | @item -mtraceback=@var{traceback_type} |
d77de738 ML |
31055 | Select the type of traceback table. Valid values for @var{traceback_type} |
31056 | are @samp{full}, @samp{part}, and @samp{no}. | |
31057 | ||
d77de738 | 31058 | @opindex maix-struct-return |
ddf6fe37 | 31059 | @item -maix-struct-return |
d77de738 ML |
31060 | Return all structures in memory (as specified by the AIX ABI)@. |
31061 | ||
d77de738 | 31062 | @opindex msvr4-struct-return |
ddf6fe37 | 31063 | @item -msvr4-struct-return |
d77de738 ML |
31064 | Return structures smaller than 8 bytes in registers (as specified by the |
31065 | SVR4 ABI)@. | |
31066 | ||
d77de738 | 31067 | @opindex mabi |
ddf6fe37 | 31068 | @item -mabi=@var{abi-type} |
d77de738 ML |
31069 | Extend the current ABI with a particular extension, or remove such extension. |
31070 | Valid values are: @samp{altivec}, @samp{no-altivec}, | |
31071 | @samp{ibmlongdouble}, @samp{ieeelongdouble}, | |
31072 | @samp{elfv1}, @samp{elfv2}, | |
31073 | and for AIX: @samp{vec-extabi}, @samp{vec-default}@. | |
31074 | ||
d77de738 | 31075 | @opindex mabi=ibmlongdouble |
ddf6fe37 | 31076 | @item -mabi=ibmlongdouble |
d77de738 ML |
31077 | Change the current ABI to use IBM extended-precision long double. |
31078 | This is not likely to work if your system defaults to using IEEE | |
31079 | extended-precision long double. If you change the long double type | |
31080 | from IEEE extended-precision, the compiler will issue a warning unless | |
31081 | you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128} | |
31082 | to be enabled. | |
31083 | ||
d77de738 | 31084 | @opindex mabi=ieeelongdouble |
ddf6fe37 | 31085 | @item -mabi=ieeelongdouble |
d77de738 ML |
31086 | Change the current ABI to use IEEE extended-precision long double. |
31087 | This is not likely to work if your system defaults to using IBM | |
31088 | extended-precision long double. If you change the long double type | |
31089 | from IBM extended-precision, the compiler will issue a warning unless | |
31090 | you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128} | |
31091 | to be enabled. | |
31092 | ||
d77de738 | 31093 | @opindex mabi=elfv1 |
ddf6fe37 | 31094 | @item -mabi=elfv1 |
d77de738 ML |
31095 | Change the current ABI to use the ELFv1 ABI. |
31096 | This is the default ABI for big-endian PowerPC 64-bit Linux. | |
31097 | Overriding the default ABI requires special system support and is | |
31098 | likely to fail in spectacular ways. | |
31099 | ||
d77de738 | 31100 | @opindex mabi=elfv2 |
ddf6fe37 | 31101 | @item -mabi=elfv2 |
d77de738 ML |
31102 | Change the current ABI to use the ELFv2 ABI. |
31103 | This is the default ABI for little-endian PowerPC 64-bit Linux. | |
31104 | Overriding the default ABI requires special system support and is | |
31105 | likely to fail in spectacular ways. | |
31106 | ||
d77de738 ML |
31107 | @opindex mgnu-attribute |
31108 | @opindex mno-gnu-attribute | |
ddf6fe37 AA |
31109 | @item -mgnu-attribute |
31110 | @itemx -mno-gnu-attribute | |
d77de738 ML |
31111 | Emit .gnu_attribute assembly directives to set tag/value pairs in a |
31112 | .gnu.attributes section that specify ABI variations in function | |
31113 | parameters or return values. | |
31114 | ||
d77de738 ML |
31115 | @opindex mprototype |
31116 | @opindex mno-prototype | |
ddf6fe37 AA |
31117 | @item -mprototype |
31118 | @itemx -mno-prototype | |
d77de738 ML |
31119 | On System V.4 and embedded PowerPC systems assume that all calls to |
31120 | variable argument functions are properly prototyped. Otherwise, the | |
31121 | compiler must insert an instruction before every non-prototyped call to | |
31122 | set or clear bit 6 of the condition code register (@code{CR}) to | |
31123 | indicate whether floating-point values are passed in the floating-point | |
31124 | registers in case the function takes variable arguments. With | |
31125 | @option{-mprototype}, only calls to prototyped variable argument functions | |
31126 | set or clear the bit. | |
31127 | ||
d77de738 | 31128 | @opindex msim |
ddf6fe37 | 31129 | @item -msim |
d77de738 ML |
31130 | On embedded PowerPC systems, assume that the startup module is called |
31131 | @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and | |
31132 | @file{libc.a}. This is the default for @samp{powerpc-*-eabisim} | |
31133 | configurations. | |
31134 | ||
d77de738 | 31135 | @opindex mmvme |
ddf6fe37 | 31136 | @item -mmvme |
d77de738 ML |
31137 | On embedded PowerPC systems, assume that the startup module is called |
31138 | @file{crt0.o} and the standard C libraries are @file{libmvme.a} and | |
31139 | @file{libc.a}. | |
31140 | ||
d77de738 | 31141 | @opindex mads |
ddf6fe37 | 31142 | @item -mads |
d77de738 ML |
31143 | On embedded PowerPC systems, assume that the startup module is called |
31144 | @file{crt0.o} and the standard C libraries are @file{libads.a} and | |
31145 | @file{libc.a}. | |
31146 | ||
d77de738 | 31147 | @opindex myellowknife |
ddf6fe37 | 31148 | @item -myellowknife |
d77de738 ML |
31149 | On embedded PowerPC systems, assume that the startup module is called |
31150 | @file{crt0.o} and the standard C libraries are @file{libyk.a} and | |
31151 | @file{libc.a}. | |
31152 | ||
d77de738 | 31153 | @opindex mvxworks |
ddf6fe37 | 31154 | @item -mvxworks |
d77de738 ML |
31155 | On System V.4 and embedded PowerPC systems, specify that you are |
31156 | compiling for a VxWorks system. | |
31157 | ||
d77de738 | 31158 | @opindex memb |
ddf6fe37 | 31159 | @item -memb |
d77de738 ML |
31160 | On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags |
31161 | header to indicate that @samp{eabi} extended relocations are used. | |
31162 | ||
d77de738 ML |
31163 | @opindex meabi |
31164 | @opindex mno-eabi | |
ddf6fe37 AA |
31165 | @item -meabi |
31166 | @itemx -mno-eabi | |
d77de738 ML |
31167 | On System V.4 and embedded PowerPC systems do (do not) adhere to the |
31168 | Embedded Applications Binary Interface (EABI), which is a set of | |
31169 | modifications to the System V.4 specifications. Selecting @option{-meabi} | |
31170 | means that the stack is aligned to an 8-byte boundary, a function | |
31171 | @code{__eabi} is called from @code{main} to set up the EABI | |
31172 | environment, and the @option{-msdata} option can use both @code{r2} and | |
31173 | @code{r13} to point to two separate small data areas. Selecting | |
31174 | @option{-mno-eabi} means that the stack is aligned to a 16-byte boundary, | |
31175 | no EABI initialization function is called from @code{main}, and the | |
31176 | @option{-msdata} option only uses @code{r13} to point to a single | |
31177 | small data area. The @option{-meabi} option is on by default if you | |
31178 | configured GCC using one of the @samp{powerpc*-*-eabi*} options. | |
31179 | ||
d77de738 | 31180 | @opindex msdata=eabi |
ddf6fe37 | 31181 | @item -msdata=eabi |
d77de738 ML |
31182 | On System V.4 and embedded PowerPC systems, put small initialized |
31183 | @code{const} global and static data in the @code{.sdata2} section, which | |
31184 | is pointed to by register @code{r2}. Put small initialized | |
31185 | non-@code{const} global and static data in the @code{.sdata} section, | |
31186 | which is pointed to by register @code{r13}. Put small uninitialized | |
31187 | global and static data in the @code{.sbss} section, which is adjacent to | |
31188 | the @code{.sdata} section. The @option{-msdata=eabi} option is | |
31189 | incompatible with the @option{-mrelocatable} option. The | |
31190 | @option{-msdata=eabi} option also sets the @option{-memb} option. | |
31191 | ||
d77de738 | 31192 | @opindex msdata=sysv |
ddf6fe37 | 31193 | @item -msdata=sysv |
d77de738 ML |
31194 | On System V.4 and embedded PowerPC systems, put small global and static |
31195 | data in the @code{.sdata} section, which is pointed to by register | |
31196 | @code{r13}. Put small uninitialized global and static data in the | |
31197 | @code{.sbss} section, which is adjacent to the @code{.sdata} section. | |
31198 | The @option{-msdata=sysv} option is incompatible with the | |
31199 | @option{-mrelocatable} option. | |
31200 | ||
d77de738 ML |
31201 | @opindex msdata=default |
31202 | @opindex msdata | |
ddf6fe37 AA |
31203 | @item -msdata=default |
31204 | @itemx -msdata | |
d77de738 ML |
31205 | On System V.4 and embedded PowerPC systems, if @option{-meabi} is used, |
31206 | compile code the same as @option{-msdata=eabi}, otherwise compile code the | |
31207 | same as @option{-msdata=sysv}. | |
31208 | ||
d77de738 | 31209 | @opindex msdata=data |
ddf6fe37 | 31210 | @item -msdata=data |
d77de738 ML |
31211 | On System V.4 and embedded PowerPC systems, put small global |
31212 | data in the @code{.sdata} section. Put small uninitialized global | |
31213 | data in the @code{.sbss} section. Do not use register @code{r13} | |
31214 | to address small data however. This is the default behavior unless | |
31215 | other @option{-msdata} options are used. | |
31216 | ||
d77de738 ML |
31217 | @opindex msdata=none |
31218 | @opindex mno-sdata | |
ddf6fe37 AA |
31219 | @item -msdata=none |
31220 | @itemx -mno-sdata | |
d77de738 ML |
31221 | On embedded PowerPC systems, put all initialized global and static data |
31222 | in the @code{.data} section, and all uninitialized data in the | |
31223 | @code{.bss} section. | |
31224 | ||
d77de738 ML |
31225 | @opindex mreadonly-in-sdata |
31226 | @opindex mno-readonly-in-sdata | |
ddf6fe37 | 31227 | @item -mreadonly-in-sdata |
d77de738 ML |
31228 | Put read-only objects in the @code{.sdata} section as well. This is the |
31229 | default. | |
31230 | ||
d77de738 | 31231 | @opindex mblock-move-inline-limit |
ddf6fe37 | 31232 | @item -mblock-move-inline-limit=@var{num} |
d77de738 ML |
31233 | Inline all block moves (such as calls to @code{memcpy} or structure |
31234 | copies) less than or equal to @var{num} bytes. The minimum value for | |
31235 | @var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit | |
31236 | targets. The default value is target-specific. | |
31237 | ||
d77de738 | 31238 | @opindex mblock-compare-inline-limit |
ddf6fe37 | 31239 | @item -mblock-compare-inline-limit=@var{num} |
d77de738 ML |
31240 | Generate non-looping inline code for all block compares (such as calls |
31241 | to @code{memcmp} or structure compares) less than or equal to @var{num} | |
31242 | bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of | |
31243 | block compare is disabled. The default value is target-specific. | |
31244 | ||
d77de738 | 31245 | @opindex mblock-compare-inline-loop-limit |
ddf6fe37 | 31246 | @item -mblock-compare-inline-loop-limit=@var{num} |
d77de738 ML |
31247 | Generate an inline expansion using loop code for all block compares that |
31248 | are less than or equal to @var{num} bytes, but greater than the limit | |
31249 | for non-loop inline block compare expansion. If the block length is not | |
31250 | constant, at most @var{num} bytes will be compared before @code{memcmp} | |
31251 | is called to compare the remainder of the block. The default value is | |
31252 | target-specific. | |
31253 | ||
d77de738 | 31254 | @opindex mstring-compare-inline-limit |
ddf6fe37 | 31255 | @item -mstring-compare-inline-limit=@var{num} |
d77de738 ML |
31256 | Compare at most @var{num} string bytes with inline code. |
31257 | If the difference or end of string is not found at the | |
31258 | end of the inline compare a call to @code{strcmp} or @code{strncmp} will | |
31259 | take care of the rest of the comparison. The default is 64 bytes. | |
31260 | ||
d77de738 ML |
31261 | @opindex G |
31262 | @cindex smaller data references (PowerPC) | |
31263 | @cindex .sdata/.sdata2 references (PowerPC) | |
f33d7a88 | 31264 | @item -G @var{num} |
d77de738 ML |
31265 | On embedded PowerPC systems, put global and static items less than or |
31266 | equal to @var{num} bytes into the small data or BSS sections instead of | |
31267 | the normal data or BSS section. By default, @var{num} is 8. The | |
31268 | @option{-G @var{num}} switch is also passed to the linker. | |
31269 | All modules should be compiled with the same @option{-G @var{num}} value. | |
31270 | ||
d77de738 ML |
31271 | @opindex mregnames |
31272 | @opindex mno-regnames | |
ddf6fe37 AA |
31273 | @item -mregnames |
31274 | @itemx -mno-regnames | |
d77de738 ML |
31275 | On System V.4 and embedded PowerPC systems do (do not) emit register |
31276 | names in the assembly language output using symbolic forms. | |
31277 | ||
d77de738 ML |
31278 | @opindex mlongcall |
31279 | @opindex mno-longcall | |
ddf6fe37 AA |
31280 | @item -mlongcall |
31281 | @itemx -mno-longcall | |
d77de738 ML |
31282 | By default assume that all calls are far away so that a longer and more |
31283 | expensive calling sequence is required. This is required for calls | |
31284 | farther than 32 megabytes (33,554,432 bytes) from the current location. | |
31285 | A short call is generated if the compiler knows | |
31286 | the call cannot be that far away. This setting can be overridden by | |
31287 | the @code{shortcall} function attribute, or by @code{#pragma | |
31288 | longcall(0)}. | |
31289 | ||
31290 | Some linkers are capable of detecting out-of-range calls and generating | |
31291 | glue code on the fly. On these systems, long calls are unnecessary and | |
31292 | generate slower code. As of this writing, the AIX linker can do this, | |
31293 | as can the GNU linker for PowerPC/64. It is planned to add this feature | |
31294 | to the GNU linker for 32-bit PowerPC systems as well. | |
31295 | ||
31296 | On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers, | |
31297 | GCC can generate long calls using an inline PLT call sequence (see | |
31298 | @option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64 | |
31299 | ELFv1 (big-endian) do not support inline PLT calls. | |
31300 | ||
31301 | On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr | |
31302 | callee, L42}, plus a @dfn{branch island} (glue code). The two target | |
31303 | addresses represent the callee and the branch island. The | |
31304 | Darwin/PPC linker prefers the first address and generates a @code{bl | |
31305 | callee} if the PPC @code{bl} instruction reaches the callee directly; | |
31306 | otherwise, the linker generates @code{bl L42} to call the branch | |
31307 | island. The branch island is appended to the body of the | |
31308 | calling function; it computes the full 32-bit address of the callee | |
31309 | and jumps to it. | |
31310 | ||
31311 | On Mach-O (Darwin) systems, this option directs the compiler emit to | |
31312 | the glue for every direct call, and the Darwin linker decides whether | |
31313 | to use or discard it. | |
31314 | ||
31315 | In the future, GCC may ignore all longcall specifications | |
31316 | when the linker is known to generate glue. | |
31317 | ||
d77de738 ML |
31318 | @opindex mpltseq |
31319 | @opindex mno-pltseq | |
ddf6fe37 AA |
31320 | @item -mpltseq |
31321 | @itemx -mno-pltseq | |
d77de738 ML |
31322 | Implement (do not implement) -fno-plt and long calls using an inline |
31323 | PLT call sequence that supports lazy linking and long calls to | |
31324 | functions in dlopen'd shared libraries. Inline PLT calls are only | |
31325 | supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU | |
31326 | linkers, and are enabled by default if the support is detected when | |
31327 | configuring GCC, and, in the case of 32-bit PowerPC, if GCC is | |
31328 | configured with @option{--enable-secureplt}. @option{-mpltseq} code | |
31329 | and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be | |
31330 | linked together. | |
31331 | ||
d77de738 ML |
31332 | @opindex mtls-markers |
31333 | @opindex mno-tls-markers | |
ddf6fe37 AA |
31334 | @item -mtls-markers |
31335 | @itemx -mno-tls-markers | |
d77de738 ML |
31336 | Mark (do not mark) calls to @code{__tls_get_addr} with a relocation |
31337 | specifying the function argument. The relocation allows the linker to | |
31338 | reliably associate function call with argument setup instructions for | |
31339 | TLS optimization, which in turn allows GCC to better schedule the | |
31340 | sequence. | |
31341 | ||
ddf6fe37 | 31342 | @opindex mrecip |
d77de738 ML |
31343 | @item -mrecip |
31344 | @itemx -mno-recip | |
d77de738 ML |
31345 | This option enables use of the reciprocal estimate and |
31346 | reciprocal square root estimate instructions with additional | |
31347 | Newton-Raphson steps to increase precision instead of doing a divide or | |
31348 | square root and divide for floating-point arguments. You should use | |
31349 | the @option{-ffast-math} option when using @option{-mrecip} (or at | |
31350 | least @option{-funsafe-math-optimizations}, | |
31351 | @option{-ffinite-math-only}, @option{-freciprocal-math} and | |
31352 | @option{-fno-trapping-math}). Note that while the throughput of the | |
31353 | sequence is generally higher than the throughput of the non-reciprocal | |
31354 | instruction, the precision of the sequence can be decreased by up to 2 | |
31355 | ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square | |
31356 | roots. | |
31357 | ||
d77de738 | 31358 | @opindex mrecip=opt |
ddf6fe37 | 31359 | @item -mrecip=@var{opt} |
d77de738 ML |
31360 | This option controls which reciprocal estimate instructions |
31361 | may be used. @var{opt} is a comma-separated list of options, which may | |
31362 | be preceded by a @code{!} to invert the option: | |
31363 | ||
31364 | @table @samp | |
31365 | ||
31366 | @item all | |
31367 | Enable all estimate instructions. | |
31368 | ||
31369 | @item default | |
31370 | Enable the default instructions, equivalent to @option{-mrecip}. | |
31371 | ||
31372 | @item none | |
31373 | Disable all estimate instructions, equivalent to @option{-mno-recip}. | |
31374 | ||
31375 | @item div | |
31376 | Enable the reciprocal approximation instructions for both | |
31377 | single and double precision. | |
31378 | ||
31379 | @item divf | |
31380 | Enable the single-precision reciprocal approximation instructions. | |
31381 | ||
31382 | @item divd | |
31383 | Enable the double-precision reciprocal approximation instructions. | |
31384 | ||
31385 | @item rsqrt | |
31386 | Enable the reciprocal square root approximation instructions for both | |
31387 | single and double precision. | |
31388 | ||
31389 | @item rsqrtf | |
31390 | Enable the single-precision reciprocal square root approximation instructions. | |
31391 | ||
31392 | @item rsqrtd | |
31393 | Enable the double-precision reciprocal square root approximation instructions. | |
31394 | ||
31395 | @end table | |
31396 | ||
31397 | So, for example, @option{-mrecip=all,!rsqrtd} enables | |
31398 | all of the reciprocal estimate instructions, except for the | |
31399 | @code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions | |
31400 | which handle the double-precision reciprocal square root calculations. | |
31401 | ||
ddf6fe37 | 31402 | @opindex mrecip-precision |
d77de738 ML |
31403 | @item -mrecip-precision |
31404 | @itemx -mno-recip-precision | |
d77de738 ML |
31405 | Assume (do not assume) that the reciprocal estimate instructions |
31406 | provide higher-precision estimates than is mandated by the PowerPC | |
31407 | ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or | |
31408 | @option{-mcpu=power8} automatically selects @option{-mrecip-precision}. | |
31409 | The double-precision square root estimate instructions are not generated by | |
31410 | default on low-precision machines, since they do not provide an | |
31411 | estimate that converges after three steps. | |
31412 | ||
d77de738 | 31413 | @opindex mveclibabi |
ddf6fe37 | 31414 | @item -mveclibabi=@var{type} |
d77de738 ML |
31415 | Specifies the ABI type to use for vectorizing intrinsics using an |
31416 | external library. The only type supported at present is @samp{mass}, | |
31417 | which specifies to use IBM's Mathematical Acceleration Subsystem | |
31418 | (MASS) libraries for vectorizing intrinsics using external libraries. | |
31419 | GCC currently emits calls to @code{acosd2}, @code{acosf4}, | |
31420 | @code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4}, | |
31421 | @code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4}, | |
31422 | @code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4}, | |
31423 | @code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4}, | |
31424 | @code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4}, | |
31425 | @code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4}, | |
31426 | @code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4}, | |
31427 | @code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4}, | |
31428 | @code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4}, | |
31429 | @code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4}, | |
31430 | @code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2}, | |
31431 | @code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2}, | |
31432 | @code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code | |
31433 | for power7. Both @option{-ftree-vectorize} and | |
31434 | @option{-funsafe-math-optimizations} must also be enabled. The MASS | |
31435 | libraries must be specified at link time. | |
31436 | ||
ddf6fe37 | 31437 | @opindex mfriz |
d77de738 ML |
31438 | @item -mfriz |
31439 | @itemx -mno-friz | |
d77de738 ML |
31440 | Generate (do not generate) the @code{friz} instruction when the |
31441 | @option{-funsafe-math-optimizations} option is used to optimize | |
31442 | rounding of floating-point values to 64-bit integer and back to floating | |
31443 | point. The @code{friz} instruction does not return the same value if | |
31444 | the floating-point number is too large to fit in an integer. | |
31445 | ||
ddf6fe37 | 31446 | @opindex mpointers-to-nested-functions |
d77de738 ML |
31447 | @item -mpointers-to-nested-functions |
31448 | @itemx -mno-pointers-to-nested-functions | |
d77de738 ML |
31449 | Generate (do not generate) code to load up the static chain register |
31450 | (@code{r11}) when calling through a pointer on AIX and 64-bit Linux | |
31451 | systems where a function pointer points to a 3-word descriptor giving | |
31452 | the function address, TOC value to be loaded in register @code{r2}, and | |
31453 | static chain value to be loaded in register @code{r11}. The | |
31454 | @option{-mpointers-to-nested-functions} is on by default. You cannot | |
31455 | call through pointers to nested functions or pointers | |
31456 | to functions compiled in other languages that use the static chain if | |
31457 | you use @option{-mno-pointers-to-nested-functions}. | |
31458 | ||
ddf6fe37 | 31459 | @opindex msave-toc-indirect |
d77de738 ML |
31460 | @item -msave-toc-indirect |
31461 | @itemx -mno-save-toc-indirect | |
d77de738 ML |
31462 | Generate (do not generate) code to save the TOC value in the reserved |
31463 | stack location in the function prologue if the function calls through | |
31464 | a pointer on AIX and 64-bit Linux systems. If the TOC value is not | |
31465 | saved in the prologue, it is saved just before the call through the | |
31466 | pointer. The @option{-mno-save-toc-indirect} option is the default. | |
31467 | ||
ddf6fe37 | 31468 | @opindex mcompat-align-parm |
d77de738 ML |
31469 | @item -mcompat-align-parm |
31470 | @itemx -mno-compat-align-parm | |
d77de738 ML |
31471 | Generate (do not generate) code to pass structure parameters with a |
31472 | maximum alignment of 64 bits, for compatibility with older versions | |
31473 | of GCC. | |
31474 | ||
31475 | Older versions of GCC (prior to 4.9.0) incorrectly did not align a | |
31476 | structure parameter on a 128-bit boundary when that structure contained | |
31477 | a member requiring 128-bit alignment. This is corrected in more | |
31478 | recent versions of GCC. This option may be used to generate code | |
31479 | that is compatible with functions compiled with older versions of | |
31480 | GCC. | |
31481 | ||
31482 | The @option{-mno-compat-align-parm} option is the default. | |
31483 | ||
d77de738 ML |
31484 | @opindex mstack-protector-guard |
31485 | @opindex mstack-protector-guard-reg | |
31486 | @opindex mstack-protector-guard-offset | |
31487 | @opindex mstack-protector-guard-symbol | |
ddf6fe37 AA |
31488 | @item -mstack-protector-guard=@var{guard} |
31489 | @itemx -mstack-protector-guard-reg=@var{reg} | |
31490 | @itemx -mstack-protector-guard-offset=@var{offset} | |
31491 | @itemx -mstack-protector-guard-symbol=@var{symbol} | |
d77de738 ML |
31492 | Generate stack protection code using canary at @var{guard}. Supported |
31493 | locations are @samp{global} for global canary or @samp{tls} for per-thread | |
31494 | canary in the TLS block (the default with GNU libc version 2.4 or later). | |
31495 | ||
31496 | With the latter choice the options | |
31497 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
31498 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
31499 | which register to use as base register for reading the canary, and from what | |
31500 | offset from that base register. The default for those is as specified in the | |
31501 | relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides | |
31502 | the offset with a symbol reference to a canary in the TLS block. | |
31503 | ||
d77de738 ML |
31504 | @opindex mpcrel |
31505 | @opindex mno-pcrel | |
ddf6fe37 AA |
31506 | @item -mpcrel |
31507 | @itemx -mno-pcrel | |
d77de738 ML |
31508 | Generate (do not generate) pc-relative addressing. The @option{-mpcrel} |
31509 | option requires that the medium code model (@option{-mcmodel=medium}) | |
31510 | and prefixed addressing (@option{-mprefixed}) options are enabled. | |
31511 | ||
d77de738 ML |
31512 | @opindex mprefixed |
31513 | @opindex mno-prefixed | |
ddf6fe37 AA |
31514 | @item -mprefixed |
31515 | @itemx -mno-prefixed | |
d77de738 ML |
31516 | Generate (do not generate) addressing modes using prefixed load and |
31517 | store instructions. The @option{-mprefixed} option requires that | |
31518 | the option @option{-mcpu=power10} (or later) is enabled. | |
31519 | ||
d77de738 ML |
31520 | @opindex mmma |
31521 | @opindex mno-mma | |
ddf6fe37 AA |
31522 | @item -mmma |
31523 | @itemx -mno-mma | |
d77de738 ML |
31524 | Generate (do not generate) the MMA instructions. The @option{-mma} |
31525 | option requires that the option @option{-mcpu=power10} (or later) | |
31526 | is enabled. | |
31527 | ||
d77de738 ML |
31528 | @opindex mrop-protect |
31529 | @opindex mno-rop-protect | |
ddf6fe37 AA |
31530 | @item -mrop-protect |
31531 | @itemx -mno-rop-protect | |
d77de738 ML |
31532 | Generate (do not generate) ROP protection instructions when the target |
31533 | processor supports them. Currently this option disables the shrink-wrap | |
31534 | optimization (@option{-fshrink-wrap}). | |
31535 | ||
d77de738 ML |
31536 | @opindex mprivileged |
31537 | @opindex mno-privileged | |
ddf6fe37 AA |
31538 | @item -mprivileged |
31539 | @itemx -mno-privileged | |
d77de738 ML |
31540 | Generate (do not generate) code that will run in privileged state. |
31541 | ||
d77de738 ML |
31542 | @opindex block-ops-unaligned-vsx |
31543 | @opindex no-block-ops-unaligned-vsx | |
ddf6fe37 AA |
31544 | @item -mblock-ops-unaligned-vsx |
31545 | @itemx -mno-block-ops-unaligned-vsx | |
d77de738 ML |
31546 | Generate (do not generate) unaligned vsx loads and stores for |
31547 | inline expansion of @code{memcpy} and @code{memmove}. | |
31548 | ||
31549 | @item --param rs6000-vect-unroll-limit= | |
31550 | The vectorizer will check with target information to determine whether it | |
31551 | would be beneficial to unroll the main vectorized loop and by how much. This | |
31552 | parameter sets the upper bound of how much the vectorizer will unroll the main | |
31553 | loop. The default value is four. | |
31554 | ||
31555 | @end table | |
31556 | ||
31557 | @node RX Options | |
31558 | @subsection RX Options | |
31559 | @cindex RX Options | |
31560 | ||
31561 | These command-line options are defined for RX targets: | |
31562 | ||
31563 | @table @gcctabopt | |
d77de738 ML |
31564 | @opindex m64bit-doubles |
31565 | @opindex m32bit-doubles | |
ddf6fe37 AA |
31566 | @item -m64bit-doubles |
31567 | @itemx -m32bit-doubles | |
d77de738 ML |
31568 | Make the @code{double} data type be 64 bits (@option{-m64bit-doubles}) |
31569 | or 32 bits (@option{-m32bit-doubles}) in size. The default is | |
31570 | @option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only | |
31571 | works on 32-bit values, which is why the default is | |
31572 | @option{-m32bit-doubles}. | |
31573 | ||
d77de738 ML |
31574 | @opindex fpu |
31575 | @opindex nofpu | |
ddf6fe37 AA |
31576 | @item -fpu |
31577 | @itemx -nofpu | |
d77de738 ML |
31578 | Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX |
31579 | floating-point hardware. The default is enabled for the RX600 | |
31580 | series and disabled for the RX200 series. | |
31581 | ||
31582 | Floating-point instructions are only generated for 32-bit floating-point | |
31583 | values, however, so the FPU hardware is not used for doubles if the | |
31584 | @option{-m64bit-doubles} option is used. | |
31585 | ||
31586 | @emph{Note} If the @option{-fpu} option is enabled then | |
31587 | @option{-funsafe-math-optimizations} is also enabled automatically. | |
31588 | This is because the RX FPU instructions are themselves unsafe. | |
31589 | ||
d77de738 | 31590 | @opindex mcpu |
ddf6fe37 | 31591 | @item -mcpu=@var{name} |
d77de738 ML |
31592 | Selects the type of RX CPU to be targeted. Currently three types are |
31593 | supported, the generic @samp{RX600} and @samp{RX200} series hardware and | |
31594 | the specific @samp{RX610} CPU. The default is @samp{RX600}. | |
31595 | ||
31596 | The only difference between @samp{RX600} and @samp{RX610} is that the | |
31597 | @samp{RX610} does not support the @code{MVTIPL} instruction. | |
31598 | ||
31599 | The @samp{RX200} series does not have a hardware floating-point unit | |
31600 | and so @option{-nofpu} is enabled by default when this type is | |
31601 | selected. | |
31602 | ||
d77de738 ML |
31603 | @opindex mbig-endian-data |
31604 | @opindex mlittle-endian-data | |
ddf6fe37 AA |
31605 | @item -mbig-endian-data |
31606 | @itemx -mlittle-endian-data | |
d77de738 ML |
31607 | Store data (but not code) in the big-endian format. The default is |
31608 | @option{-mlittle-endian-data}, i.e.@: to store data in the little-endian | |
31609 | format. | |
31610 | ||
d77de738 | 31611 | @opindex msmall-data-limit |
ddf6fe37 | 31612 | @item -msmall-data-limit=@var{N} |
d77de738 ML |
31613 | Specifies the maximum size in bytes of global and static variables |
31614 | which can be placed into the small data area. Using the small data | |
31615 | area can lead to smaller and faster code, but the size of area is | |
31616 | limited and it is up to the programmer to ensure that the area does | |
31617 | not overflow. Also when the small data area is used one of the RX's | |
31618 | registers (usually @code{r13}) is reserved for use pointing to this | |
31619 | area, so it is no longer available for use by the compiler. This | |
31620 | could result in slower and/or larger code if variables are pushed onto | |
31621 | the stack instead of being held in this register. | |
31622 | ||
31623 | Note, common variables (variables that have not been initialized) and | |
31624 | constants are not placed into the small data area as they are assigned | |
31625 | to other sections in the output executable. | |
31626 | ||
31627 | The default value is zero, which disables this feature. Note, this | |
31628 | feature is not enabled by default with higher optimization levels | |
31629 | (@option{-O2} etc) because of the potentially detrimental effects of | |
31630 | reserving a register. It is up to the programmer to experiment and | |
31631 | discover whether this feature is of benefit to their program. See the | |
31632 | description of the @option{-mpid} option for a description of how the | |
31633 | actual register to hold the small data area pointer is chosen. | |
31634 | ||
d77de738 ML |
31635 | @opindex msim |
31636 | @opindex mno-sim | |
ddf6fe37 AA |
31637 | @item -msim |
31638 | @itemx -mno-sim | |
d77de738 ML |
31639 | Use the simulator runtime. The default is to use the libgloss |
31640 | board-specific runtime. | |
31641 | ||
d77de738 ML |
31642 | @opindex mas100-syntax |
31643 | @opindex mno-as100-syntax | |
ddf6fe37 AA |
31644 | @item -mas100-syntax |
31645 | @itemx -mno-as100-syntax | |
d77de738 ML |
31646 | When generating assembler output use a syntax that is compatible with |
31647 | Renesas's AS100 assembler. This syntax can also be handled by the GAS | |
31648 | assembler, but it has some restrictions so it is not generated by default. | |
31649 | ||
d77de738 | 31650 | @opindex mmax-constant-size |
ddf6fe37 | 31651 | @item -mmax-constant-size=@var{N} |
d77de738 ML |
31652 | Specifies the maximum size, in bytes, of a constant that can be used as |
31653 | an operand in a RX instruction. Although the RX instruction set does | |
31654 | allow constants of up to 4 bytes in length to be used in instructions, | |
31655 | a longer value equates to a longer instruction. Thus in some | |
31656 | circumstances it can be beneficial to restrict the size of constants | |
31657 | that are used in instructions. Constants that are too big are instead | |
31658 | placed into a constant pool and referenced via register indirection. | |
31659 | ||
31660 | The value @var{N} can be between 0 and 4. A value of 0 (the default) | |
31661 | or 4 means that constants of any size are allowed. | |
31662 | ||
d77de738 | 31663 | @opindex mrelax |
ddf6fe37 | 31664 | @item -mrelax |
d77de738 ML |
31665 | Enable linker relaxation. Linker relaxation is a process whereby the |
31666 | linker attempts to reduce the size of a program by finding shorter | |
31667 | versions of various instructions. Disabled by default. | |
31668 | ||
d77de738 | 31669 | @opindex mint-register |
ddf6fe37 | 31670 | @item -mint-register=@var{N} |
d77de738 ML |
31671 | Specify the number of registers to reserve for fast interrupt handler |
31672 | functions. The value @var{N} can be between 0 and 4. A value of 1 | |
31673 | means that register @code{r13} is reserved for the exclusive use | |
31674 | of fast interrupt handlers. A value of 2 reserves @code{r13} and | |
31675 | @code{r12}. A value of 3 reserves @code{r13}, @code{r12} and | |
31676 | @code{r11}, and a value of 4 reserves @code{r13} through @code{r10}. | |
31677 | A value of 0, the default, does not reserve any registers. | |
31678 | ||
d77de738 | 31679 | @opindex msave-acc-in-interrupts |
ddf6fe37 | 31680 | @item -msave-acc-in-interrupts |
d77de738 ML |
31681 | Specifies that interrupt handler functions should preserve the |
31682 | accumulator register. This is only necessary if normal code might use | |
31683 | the accumulator register, for example because it performs 64-bit | |
31684 | multiplications. The default is to ignore the accumulator as this | |
31685 | makes the interrupt handlers faster. | |
31686 | ||
d77de738 ML |
31687 | @opindex mpid |
31688 | @opindex mno-pid | |
ddf6fe37 AA |
31689 | @item -mpid |
31690 | @itemx -mno-pid | |
d77de738 ML |
31691 | Enables the generation of position independent data. When enabled any |
31692 | access to constant data is done via an offset from a base address | |
31693 | held in a register. This allows the location of constant data to be | |
31694 | determined at run time without requiring the executable to be | |
31695 | relocated, which is a benefit to embedded applications with tight | |
31696 | memory constraints. Data that can be modified is not affected by this | |
31697 | option. | |
31698 | ||
31699 | Note, using this feature reserves a register, usually @code{r13}, for | |
31700 | the constant data base address. This can result in slower and/or | |
31701 | larger code, especially in complicated functions. | |
31702 | ||
31703 | The actual register chosen to hold the constant data base address | |
31704 | depends upon whether the @option{-msmall-data-limit} and/or the | |
31705 | @option{-mint-register} command-line options are enabled. Starting | |
31706 | with register @code{r13} and proceeding downwards, registers are | |
31707 | allocated first to satisfy the requirements of @option{-mint-register}, | |
31708 | then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it | |
31709 | is possible for the small data area register to be @code{r8} if both | |
31710 | @option{-mint-register=4} and @option{-mpid} are specified on the | |
31711 | command line. | |
31712 | ||
31713 | By default this feature is not enabled. The default can be restored | |
31714 | via the @option{-mno-pid} command-line option. | |
31715 | ||
d77de738 ML |
31716 | @opindex mno-warn-multiple-fast-interrupts |
31717 | @opindex mwarn-multiple-fast-interrupts | |
ddf6fe37 AA |
31718 | @item -mno-warn-multiple-fast-interrupts |
31719 | @itemx -mwarn-multiple-fast-interrupts | |
d77de738 ML |
31720 | Prevents GCC from issuing a warning message if it finds more than one |
31721 | fast interrupt handler when it is compiling a file. The default is to | |
31722 | issue a warning for each extra fast interrupt handler found, as the RX | |
31723 | only supports one such interrupt. | |
31724 | ||
d77de738 ML |
31725 | @opindex mallow-string-insns |
31726 | @opindex mno-allow-string-insns | |
ddf6fe37 AA |
31727 | @item -mallow-string-insns |
31728 | @itemx -mno-allow-string-insns | |
d77de738 ML |
31729 | Enables or disables the use of the string manipulation instructions |
31730 | @code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL} | |
31731 | @code{SWHILE} and also the @code{RMPA} instruction. These | |
31732 | instructions may prefetch data, which is not safe to do if accessing | |
31733 | an I/O register. (See section 12.2.7 of the RX62N Group User's Manual | |
31734 | for more information). | |
31735 | ||
31736 | The default is to allow these instructions, but it is not possible for | |
31737 | GCC to reliably detect all circumstances where a string instruction | |
31738 | might be used to access an I/O register, so their use cannot be | |
31739 | disabled automatically. Instead it is reliant upon the programmer to | |
31740 | use the @option{-mno-allow-string-insns} option if their program | |
31741 | accesses I/O space. | |
31742 | ||
31743 | When the instructions are enabled GCC defines the C preprocessor | |
31744 | symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the | |
31745 | symbol @code{__RX_DISALLOW_STRING_INSNS__}. | |
31746 | ||
d77de738 ML |
31747 | @opindex mjsr |
31748 | @opindex mno-jsr | |
ddf6fe37 AA |
31749 | @item -mjsr |
31750 | @itemx -mno-jsr | |
d77de738 ML |
31751 | Use only (or not only) @code{JSR} instructions to access functions. |
31752 | This option can be used when code size exceeds the range of @code{BSR} | |
31753 | instructions. Note that @option{-mno-jsr} does not mean to not use | |
31754 | @code{JSR} but instead means that any type of branch may be used. | |
31755 | @end table | |
31756 | ||
31757 | @emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}} | |
31758 | has special significance to the RX port when used with the | |
31759 | @code{interrupt} function attribute. This attribute indicates a | |
31760 | function intended to process fast interrupts. GCC ensures | |
31761 | that it only uses the registers @code{r10}, @code{r11}, @code{r12} | |
31762 | and/or @code{r13} and only provided that the normal use of the | |
31763 | corresponding registers have been restricted via the | |
31764 | @option{-ffixed-@var{reg}} or @option{-mint-register} command-line | |
31765 | options. | |
31766 | ||
31767 | @node S/390 and zSeries Options | |
31768 | @subsection S/390 and zSeries Options | |
31769 | @cindex S/390 and zSeries Options | |
31770 | ||
31771 | These are the @samp{-m} options defined for the S/390 and zSeries architecture. | |
31772 | ||
31773 | @table @gcctabopt | |
d77de738 ML |
31774 | @opindex mhard-float |
31775 | @opindex msoft-float | |
ddf6fe37 AA |
31776 | @item -mhard-float |
31777 | @itemx -msoft-float | |
d77de738 ML |
31778 | Use (do not use) the hardware floating-point instructions and registers |
31779 | for floating-point operations. When @option{-msoft-float} is specified, | |
31780 | functions in @file{libgcc.a} are used to perform floating-point | |
31781 | operations. When @option{-mhard-float} is specified, the compiler | |
31782 | generates IEEE floating-point instructions. This is the default. | |
31783 | ||
d77de738 ML |
31784 | @opindex mhard-dfp |
31785 | @opindex mno-hard-dfp | |
ddf6fe37 AA |
31786 | @item -mhard-dfp |
31787 | @itemx -mno-hard-dfp | |
d77de738 ML |
31788 | Use (do not use) the hardware decimal-floating-point instructions for |
31789 | decimal-floating-point operations. When @option{-mno-hard-dfp} is | |
31790 | specified, functions in @file{libgcc.a} are used to perform | |
31791 | decimal-floating-point operations. When @option{-mhard-dfp} is | |
31792 | specified, the compiler generates decimal-floating-point hardware | |
31793 | instructions. This is the default for @option{-march=z9-ec} or higher. | |
31794 | ||
d77de738 ML |
31795 | @opindex mlong-double-64 |
31796 | @opindex mlong-double-128 | |
ddf6fe37 AA |
31797 | @item -mlong-double-64 |
31798 | @itemx -mlong-double-128 | |
d77de738 ML |
31799 | These switches control the size of @code{long double} type. A size |
31800 | of 64 bits makes the @code{long double} type equivalent to the @code{double} | |
31801 | type. This is the default. | |
31802 | ||
d77de738 ML |
31803 | @opindex mbackchain |
31804 | @opindex mno-backchain | |
ddf6fe37 AA |
31805 | @item -mbackchain |
31806 | @itemx -mno-backchain | |
d77de738 ML |
31807 | Store (do not store) the address of the caller's frame as backchain pointer |
31808 | into the callee's stack frame. | |
31809 | A backchain may be needed to allow debugging using tools that do not understand | |
31810 | DWARF call frame information. | |
31811 | When @option{-mno-packed-stack} is in effect, the backchain pointer is stored | |
31812 | at the bottom of the stack frame; when @option{-mpacked-stack} is in effect, | |
31813 | the backchain is placed into the topmost word of the 96/160 byte register | |
31814 | save area. | |
31815 | ||
31816 | In general, code compiled with @option{-mbackchain} is call-compatible with | |
31817 | code compiled with @option{-mno-backchain}; however, use of the backchain | |
31818 | for debugging purposes usually requires that the whole binary is built with | |
31819 | @option{-mbackchain}. Note that the combination of @option{-mbackchain}, | |
31820 | @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order | |
31821 | to build a linux kernel use @option{-msoft-float}. | |
31822 | ||
31823 | The default is to not maintain the backchain. | |
31824 | ||
d77de738 ML |
31825 | @opindex mpacked-stack |
31826 | @opindex mno-packed-stack | |
ddf6fe37 AA |
31827 | @item -mpacked-stack |
31828 | @itemx -mno-packed-stack | |
d77de738 ML |
31829 | Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is |
31830 | specified, the compiler uses the all fields of the 96/160 byte register save | |
31831 | area only for their default purpose; unused fields still take up stack space. | |
31832 | When @option{-mpacked-stack} is specified, register save slots are densely | |
31833 | packed at the top of the register save area; unused space is reused for other | |
31834 | purposes, allowing for more efficient use of the available stack space. | |
31835 | However, when @option{-mbackchain} is also in effect, the topmost word of | |
31836 | the save area is always used to store the backchain, and the return address | |
31837 | register is always saved two words below the backchain. | |
31838 | ||
31839 | As long as the stack frame backchain is not used, code generated with | |
31840 | @option{-mpacked-stack} is call-compatible with code generated with | |
31841 | @option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for | |
31842 | S/390 or zSeries generated code that uses the stack frame backchain at run | |
31843 | time, not just for debugging purposes. Such code is not call-compatible | |
31844 | with code compiled with @option{-mpacked-stack}. Also, note that the | |
31845 | combination of @option{-mbackchain}, | |
31846 | @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order | |
31847 | to build a linux kernel use @option{-msoft-float}. | |
31848 | ||
31849 | The default is to not use the packed stack layout. | |
31850 | ||
d77de738 ML |
31851 | @opindex msmall-exec |
31852 | @opindex mno-small-exec | |
ddf6fe37 AA |
31853 | @item -msmall-exec |
31854 | @itemx -mno-small-exec | |
d77de738 ML |
31855 | Generate (or do not generate) code using the @code{bras} instruction |
31856 | to do subroutine calls. | |
31857 | This only works reliably if the total executable size does not | |
31858 | exceed 64k. The default is to use the @code{basr} instruction instead, | |
31859 | which does not have this limitation. | |
31860 | ||
d77de738 ML |
31861 | @opindex m64 |
31862 | @opindex m31 | |
ddf6fe37 AA |
31863 | @item -m64 |
31864 | @itemx -m31 | |
d77de738 ML |
31865 | When @option{-m31} is specified, generate code compliant to the |
31866 | GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate | |
31867 | code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in | |
31868 | particular to generate 64-bit instructions. For the @samp{s390} | |
31869 | targets, the default is @option{-m31}, while the @samp{s390x} | |
31870 | targets default to @option{-m64}. | |
31871 | ||
d77de738 ML |
31872 | @opindex mzarch |
31873 | @opindex mesa | |
ddf6fe37 AA |
31874 | @item -mzarch |
31875 | @itemx -mesa | |
d77de738 ML |
31876 | When @option{-mzarch} is specified, generate code using the |
31877 | instructions available on z/Architecture. | |
31878 | When @option{-mesa} is specified, generate code using the | |
31879 | instructions available on ESA/390. Note that @option{-mesa} is | |
31880 | not possible with @option{-m64}. | |
31881 | When generating code compliant to the GNU/Linux for S/390 ABI, | |
31882 | the default is @option{-mesa}. When generating code compliant | |
31883 | to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}. | |
31884 | ||
d77de738 ML |
31885 | @opindex mhtm |
31886 | @opindex mno-htm | |
ddf6fe37 AA |
31887 | @item -mhtm |
31888 | @itemx -mno-htm | |
d77de738 ML |
31889 | The @option{-mhtm} option enables a set of builtins making use of |
31890 | instructions available with the transactional execution facility | |
31891 | introduced with the IBM zEnterprise EC12 machine generation | |
31892 | @ref{S/390 System z Built-in Functions}. | |
31893 | @option{-mhtm} is enabled by default when using @option{-march=zEC12}. | |
31894 | ||
d77de738 ML |
31895 | @opindex mvx |
31896 | @opindex mno-vx | |
ddf6fe37 AA |
31897 | @item -mvx |
31898 | @itemx -mno-vx | |
d77de738 ML |
31899 | When @option{-mvx} is specified, generate code using the instructions |
31900 | available with the vector extension facility introduced with the IBM | |
31901 | z13 machine generation. | |
31902 | This option changes the ABI for some vector type values with regard to | |
31903 | alignment and calling conventions. In case vector type values are | |
31904 | being used in an ABI-relevant context a GAS @samp{.gnu_attribute} | |
31905 | command will be added to mark the resulting binary with the ABI used. | |
31906 | @option{-mvx} is enabled by default when using @option{-march=z13}. | |
31907 | ||
d77de738 ML |
31908 | @opindex mzvector |
31909 | @opindex mno-zvector | |
ddf6fe37 AA |
31910 | @item -mzvector |
31911 | @itemx -mno-zvector | |
d77de738 ML |
31912 | The @option{-mzvector} option enables vector language extensions and |
31913 | builtins using instructions available with the vector extension | |
31914 | facility introduced with the IBM z13 machine generation. | |
31915 | This option adds support for @samp{vector} to be used as a keyword to | |
31916 | define vector type variables and arguments. @samp{vector} is only | |
31917 | available when GNU extensions are enabled. It will not be expanded | |
31918 | when requesting strict standard compliance e.g.@: with @option{-std=c99}. | |
31919 | In addition to the GCC low-level builtins @option{-mzvector} enables | |
31920 | a set of builtins added for compatibility with AltiVec-style | |
31921 | implementations like Power and Cell. In order to make use of these | |
31922 | builtins the header file @file{vecintrin.h} needs to be included. | |
31923 | @option{-mzvector} is disabled by default. | |
31924 | ||
d77de738 ML |
31925 | @opindex mmvcle |
31926 | @opindex mno-mvcle | |
ddf6fe37 AA |
31927 | @item -mmvcle |
31928 | @itemx -mno-mvcle | |
d77de738 ML |
31929 | Generate (or do not generate) code using the @code{mvcle} instruction |
31930 | to perform block moves. When @option{-mno-mvcle} is specified, | |
31931 | use a @code{mvc} loop instead. This is the default unless optimizing for | |
31932 | size. | |
31933 | ||
d77de738 ML |
31934 | @opindex mdebug |
31935 | @opindex mno-debug | |
ddf6fe37 AA |
31936 | @item -mdebug |
31937 | @itemx -mno-debug | |
d77de738 ML |
31938 | Print (or do not print) additional debug information when compiling. |
31939 | The default is to not print debug information. | |
31940 | ||
d77de738 | 31941 | @opindex march |
ddf6fe37 | 31942 | @item -march=@var{cpu-type} |
d77de738 ML |
31943 | Generate code that runs on @var{cpu-type}, which is the name of a |
31944 | system representing a certain processor type. Possible values for | |
31945 | @var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6}, | |
31946 | @samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8}, | |
31947 | @samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11}, | |
31948 | @samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13}, | |
31949 | @samp{z16}/@samp{arch14}, and @samp{native}. | |
31950 | ||
31951 | The default is @option{-march=z900}. | |
31952 | ||
31953 | Specifying @samp{native} as cpu type can be used to select the best | |
31954 | architecture option for the host processor. | |
31955 | @option{-march=native} has no effect if GCC does not recognize the | |
31956 | processor. | |
31957 | ||
d77de738 | 31958 | @opindex mtune |
ddf6fe37 | 31959 | @item -mtune=@var{cpu-type} |
d77de738 ML |
31960 | Tune to @var{cpu-type} everything applicable about the generated code, |
31961 | except for the ABI and the set of available instructions. | |
31962 | The list of @var{cpu-type} values is the same as for @option{-march}. | |
31963 | The default is the value used for @option{-march}. | |
31964 | ||
d77de738 ML |
31965 | @opindex mtpf-trace |
31966 | @opindex mno-tpf-trace | |
ddf6fe37 AA |
31967 | @item -mtpf-trace |
31968 | @itemx -mno-tpf-trace | |
d77de738 ML |
31969 | Generate code that adds (does not add) in TPF OS specific branches to trace |
31970 | routines in the operating system. This option is off by default, even | |
31971 | when compiling for the TPF OS@. | |
31972 | ||
d77de738 ML |
31973 | @opindex mtpf-trace-skip |
31974 | @opindex mno-tpf-trace-skip | |
ddf6fe37 AA |
31975 | @item -mtpf-trace-skip |
31976 | @itemx -mno-tpf-trace-skip | |
d77de738 ML |
31977 | Generate code that changes (does not change) the default branch |
31978 | targets enabled by @option{-mtpf-trace} to point to specialized trace | |
31979 | routines providing the ability of selectively skipping function trace | |
31980 | entries for the TPF OS. This option is off by default, even when | |
31981 | compiling for the TPF OS and specifying @option{-mtpf-trace}. | |
31982 | ||
d77de738 ML |
31983 | @opindex mfused-madd |
31984 | @opindex mno-fused-madd | |
ddf6fe37 AA |
31985 | @item -mfused-madd |
31986 | @itemx -mno-fused-madd | |
d77de738 ML |
31987 | Generate code that uses (does not use) the floating-point multiply and |
31988 | accumulate instructions. These instructions are generated by default if | |
31989 | hardware floating point is used. | |
31990 | ||
d77de738 | 31991 | @opindex mwarn-framesize |
ddf6fe37 | 31992 | @item -mwarn-framesize=@var{framesize} |
d77de738 ML |
31993 | Emit a warning if the current function exceeds the given frame size. Because |
31994 | this is a compile-time check it doesn't need to be a real problem when the program | |
31995 | runs. It is intended to identify functions that most probably cause | |
31996 | a stack overflow. It is useful to be used in an environment with limited stack | |
31997 | size e.g.@: the linux kernel. | |
31998 | ||
d77de738 | 31999 | @opindex mwarn-dynamicstack |
ddf6fe37 | 32000 | @item -mwarn-dynamicstack |
d77de738 ML |
32001 | Emit a warning if the function calls @code{alloca} or uses dynamically-sized |
32002 | arrays. This is generally a bad idea with a limited stack size. | |
32003 | ||
d77de738 ML |
32004 | @opindex mstack-guard |
32005 | @opindex mstack-size | |
ddf6fe37 AA |
32006 | @item -mstack-guard=@var{stack-guard} |
32007 | @itemx -mstack-size=@var{stack-size} | |
d77de738 ML |
32008 | If these options are provided the S/390 back end emits additional instructions in |
32009 | the function prologue that trigger a trap if the stack size is @var{stack-guard} | |
32010 | bytes above the @var{stack-size} (remember that the stack on S/390 grows downward). | |
32011 | If the @var{stack-guard} option is omitted the smallest power of 2 larger than | |
32012 | the frame size of the compiled function is chosen. | |
32013 | These options are intended to be used to help debugging stack overflow problems. | |
32014 | The additionally emitted code causes only little overhead and hence can also be | |
32015 | used in production-like systems without greater performance degradation. The given | |
32016 | values have to be exact powers of 2 and @var{stack-size} has to be greater than | |
32017 | @var{stack-guard} without exceeding 64k. | |
32018 | In order to be efficient the extra code makes the assumption that the stack starts | |
32019 | at an address aligned to the value given by @var{stack-size}. | |
32020 | The @var{stack-guard} option can only be used in conjunction with @var{stack-size}. | |
32021 | ||
d77de738 | 32022 | @opindex mhotpatch |
ddf6fe37 | 32023 | @item -mhotpatch=@var{pre-halfwords},@var{post-halfwords} |
d77de738 ML |
32024 | If the hotpatch option is enabled, a ``hot-patching'' function |
32025 | prologue is generated for all functions in the compilation unit. | |
32026 | The funtion label is prepended with the given number of two-byte | |
32027 | NOP instructions (@var{pre-halfwords}, maximum 1000000). After | |
32028 | the label, 2 * @var{post-halfwords} bytes are appended, using the | |
32029 | largest NOP like instructions the architecture allows (maximum | |
32030 | 1000000). | |
32031 | ||
32032 | If both arguments are zero, hotpatching is disabled. | |
32033 | ||
32034 | This option can be overridden for individual functions with the | |
32035 | @code{hotpatch} attribute. | |
32036 | @end table | |
32037 | ||
d77de738 ML |
32038 | @node SH Options |
32039 | @subsection SH Options | |
32040 | ||
32041 | These @samp{-m} options are defined for the SH implementations: | |
32042 | ||
32043 | @table @gcctabopt | |
d77de738 | 32044 | @opindex m1 |
ddf6fe37 | 32045 | @item -m1 |
d77de738 ML |
32046 | Generate code for the SH1. |
32047 | ||
d77de738 | 32048 | @opindex m2 |
ddf6fe37 | 32049 | @item -m2 |
d77de738 ML |
32050 | Generate code for the SH2. |
32051 | ||
32052 | @item -m2e | |
32053 | Generate code for the SH2e. | |
32054 | ||
d77de738 | 32055 | @opindex m2a-nofpu |
ddf6fe37 | 32056 | @item -m2a-nofpu |
d77de738 ML |
32057 | Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way |
32058 | that the floating-point unit is not used. | |
32059 | ||
d77de738 | 32060 | @opindex m2a-single-only |
ddf6fe37 | 32061 | @item -m2a-single-only |
d77de738 ML |
32062 | Generate code for the SH2a-FPU, in such a way that no double-precision |
32063 | floating-point operations are used. | |
32064 | ||
d77de738 | 32065 | @opindex m2a-single |
ddf6fe37 | 32066 | @item -m2a-single |
d77de738 ML |
32067 | Generate code for the SH2a-FPU assuming the floating-point unit is in |
32068 | single-precision mode by default. | |
32069 | ||
d77de738 | 32070 | @opindex m2a |
ddf6fe37 | 32071 | @item -m2a |
d77de738 ML |
32072 | Generate code for the SH2a-FPU assuming the floating-point unit is in |
32073 | double-precision mode by default. | |
32074 | ||
d77de738 | 32075 | @opindex m3 |
ddf6fe37 | 32076 | @item -m3 |
d77de738 ML |
32077 | Generate code for the SH3. |
32078 | ||
d77de738 | 32079 | @opindex m3e |
ddf6fe37 | 32080 | @item -m3e |
d77de738 ML |
32081 | Generate code for the SH3e. |
32082 | ||
d77de738 | 32083 | @opindex m4-nofpu |
ddf6fe37 | 32084 | @item -m4-nofpu |
d77de738 ML |
32085 | Generate code for the SH4 without a floating-point unit. |
32086 | ||
d77de738 | 32087 | @opindex m4-single-only |
ddf6fe37 | 32088 | @item -m4-single-only |
d77de738 ML |
32089 | Generate code for the SH4 with a floating-point unit that only |
32090 | supports single-precision arithmetic. | |
32091 | ||
d77de738 | 32092 | @opindex m4-single |
ddf6fe37 | 32093 | @item -m4-single |
d77de738 ML |
32094 | Generate code for the SH4 assuming the floating-point unit is in |
32095 | single-precision mode by default. | |
32096 | ||
d77de738 | 32097 | @opindex m4 |
ddf6fe37 | 32098 | @item -m4 |
d77de738 ML |
32099 | Generate code for the SH4. |
32100 | ||
d77de738 | 32101 | @opindex m4-100 |
ddf6fe37 | 32102 | @item -m4-100 |
d77de738 ML |
32103 | Generate code for SH4-100. |
32104 | ||
d77de738 | 32105 | @opindex m4-100-nofpu |
ddf6fe37 | 32106 | @item -m4-100-nofpu |
d77de738 ML |
32107 | Generate code for SH4-100 in such a way that the |
32108 | floating-point unit is not used. | |
32109 | ||
d77de738 | 32110 | @opindex m4-100-single |
ddf6fe37 | 32111 | @item -m4-100-single |
d77de738 ML |
32112 | Generate code for SH4-100 assuming the floating-point unit is in |
32113 | single-precision mode by default. | |
32114 | ||
d77de738 | 32115 | @opindex m4-100-single-only |
ddf6fe37 | 32116 | @item -m4-100-single-only |
d77de738 ML |
32117 | Generate code for SH4-100 in such a way that no double-precision |
32118 | floating-point operations are used. | |
32119 | ||
d77de738 | 32120 | @opindex m4-200 |
ddf6fe37 | 32121 | @item -m4-200 |
d77de738 ML |
32122 | Generate code for SH4-200. |
32123 | ||
d77de738 | 32124 | @opindex m4-200-nofpu |
ddf6fe37 | 32125 | @item -m4-200-nofpu |
d77de738 ML |
32126 | Generate code for SH4-200 without in such a way that the |
32127 | floating-point unit is not used. | |
32128 | ||
d77de738 | 32129 | @opindex m4-200-single |
ddf6fe37 | 32130 | @item -m4-200-single |
d77de738 ML |
32131 | Generate code for SH4-200 assuming the floating-point unit is in |
32132 | single-precision mode by default. | |
32133 | ||
d77de738 | 32134 | @opindex m4-200-single-only |
ddf6fe37 | 32135 | @item -m4-200-single-only |
d77de738 ML |
32136 | Generate code for SH4-200 in such a way that no double-precision |
32137 | floating-point operations are used. | |
32138 | ||
d77de738 | 32139 | @opindex m4-300 |
ddf6fe37 | 32140 | @item -m4-300 |
d77de738 ML |
32141 | Generate code for SH4-300. |
32142 | ||
d77de738 | 32143 | @opindex m4-300-nofpu |
ddf6fe37 | 32144 | @item -m4-300-nofpu |
d77de738 ML |
32145 | Generate code for SH4-300 without in such a way that the |
32146 | floating-point unit is not used. | |
32147 | ||
d77de738 | 32148 | @opindex m4-300-single |
ddf6fe37 | 32149 | @item -m4-300-single |
d77de738 ML |
32150 | Generate code for SH4-300 in such a way that no double-precision |
32151 | floating-point operations are used. | |
32152 | ||
d77de738 | 32153 | @opindex m4-300-single-only |
ddf6fe37 | 32154 | @item -m4-300-single-only |
d77de738 ML |
32155 | Generate code for SH4-300 in such a way that no double-precision |
32156 | floating-point operations are used. | |
32157 | ||
d77de738 | 32158 | @opindex m4-340 |
ddf6fe37 | 32159 | @item -m4-340 |
d77de738 ML |
32160 | Generate code for SH4-340 (no MMU, no FPU). |
32161 | ||
d77de738 | 32162 | @opindex m4-500 |
ddf6fe37 | 32163 | @item -m4-500 |
d77de738 ML |
32164 | Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the |
32165 | assembler. | |
32166 | ||
d77de738 | 32167 | @opindex m4a-nofpu |
ddf6fe37 | 32168 | @item -m4a-nofpu |
d77de738 ML |
32169 | Generate code for the SH4al-dsp, or for a SH4a in such a way that the |
32170 | floating-point unit is not used. | |
32171 | ||
d77de738 | 32172 | @opindex m4a-single-only |
ddf6fe37 | 32173 | @item -m4a-single-only |
d77de738 ML |
32174 | Generate code for the SH4a, in such a way that no double-precision |
32175 | floating-point operations are used. | |
32176 | ||
d77de738 | 32177 | @opindex m4a-single |
ddf6fe37 | 32178 | @item -m4a-single |
d77de738 ML |
32179 | Generate code for the SH4a assuming the floating-point unit is in |
32180 | single-precision mode by default. | |
32181 | ||
d77de738 | 32182 | @opindex m4a |
ddf6fe37 | 32183 | @item -m4a |
d77de738 ML |
32184 | Generate code for the SH4a. |
32185 | ||
d77de738 | 32186 | @opindex m4al |
ddf6fe37 | 32187 | @item -m4al |
d77de738 ML |
32188 | Same as @option{-m4a-nofpu}, except that it implicitly passes |
32189 | @option{-dsp} to the assembler. GCC doesn't generate any DSP | |
32190 | instructions at the moment. | |
32191 | ||
d77de738 | 32192 | @opindex mb |
ddf6fe37 | 32193 | @item -mb |
d77de738 ML |
32194 | Compile code for the processor in big-endian mode. |
32195 | ||
d77de738 | 32196 | @opindex ml |
ddf6fe37 | 32197 | @item -ml |
d77de738 ML |
32198 | Compile code for the processor in little-endian mode. |
32199 | ||
d77de738 | 32200 | @opindex mdalign |
ddf6fe37 | 32201 | @item -mdalign |
d77de738 ML |
32202 | Align doubles at 64-bit boundaries. Note that this changes the calling |
32203 | conventions, and thus some functions from the standard C library do | |
32204 | not work unless you recompile it first with @option{-mdalign}. | |
32205 | ||
d77de738 | 32206 | @opindex mrelax |
ddf6fe37 | 32207 | @item -mrelax |
d77de738 ML |
32208 | Shorten some address references at link time, when possible; uses the |
32209 | linker option @option{-relax}. | |
32210 | ||
d77de738 | 32211 | @opindex mbigtable |
ddf6fe37 | 32212 | @item -mbigtable |
d77de738 ML |
32213 | Use 32-bit offsets in @code{switch} tables. The default is to use |
32214 | 16-bit offsets. | |
32215 | ||
d77de738 | 32216 | @opindex mbitops |
ddf6fe37 | 32217 | @item -mbitops |
d77de738 ML |
32218 | Enable the use of bit manipulation instructions on SH2A. |
32219 | ||
d77de738 | 32220 | @opindex mfmovd |
ddf6fe37 | 32221 | @item -mfmovd |
d77de738 ML |
32222 | Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for |
32223 | alignment constraints. | |
32224 | ||
d77de738 | 32225 | @opindex mrenesas |
ddf6fe37 | 32226 | @item -mrenesas |
d77de738 ML |
32227 | Comply with the calling conventions defined by Renesas. |
32228 | ||
d77de738 | 32229 | @opindex mno-renesas |
ddf6fe37 | 32230 | @item -mno-renesas |
d77de738 ML |
32231 | Comply with the calling conventions defined for GCC before the Renesas |
32232 | conventions were available. This option is the default for all | |
32233 | targets of the SH toolchain. | |
32234 | ||
d77de738 | 32235 | @opindex mnomacsave |
ddf6fe37 | 32236 | @item -mnomacsave |
d77de738 ML |
32237 | Mark the @code{MAC} register as call-clobbered, even if |
32238 | @option{-mrenesas} is given. | |
32239 | ||
d77de738 ML |
32240 | @opindex mieee |
32241 | @opindex mno-ieee | |
ddf6fe37 AA |
32242 | @item -mieee |
32243 | @itemx -mno-ieee | |
d77de738 ML |
32244 | Control the IEEE compliance of floating-point comparisons, which affects the |
32245 | handling of cases where the result of a comparison is unordered. By default | |
32246 | @option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is | |
32247 | enabled @option{-mno-ieee} is implicitly set, which results in faster | |
32248 | floating-point greater-equal and less-equal comparisons. The implicit settings | |
32249 | can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}. | |
32250 | ||
d77de738 | 32251 | @opindex minline-ic_invalidate |
ddf6fe37 | 32252 | @item -minline-ic_invalidate |
d77de738 ML |
32253 | Inline code to invalidate instruction cache entries after setting up |
32254 | nested function trampolines. | |
32255 | This option has no effect if @option{-musermode} is in effect and the selected | |
32256 | code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi} | |
32257 | instruction. | |
32258 | If the selected code generation option does not allow the use of the @code{icbi} | |
32259 | instruction, and @option{-musermode} is not in effect, the inlined code | |
32260 | manipulates the instruction cache address array directly with an associative | |
32261 | write. This not only requires privileged mode at run time, but it also | |
32262 | fails if the cache line had been mapped via the TLB and has become unmapped. | |
32263 | ||
d77de738 | 32264 | @opindex misize |
ddf6fe37 | 32265 | @item -misize |
d77de738 ML |
32266 | Dump instruction size and location in the assembly code. |
32267 | ||
d77de738 | 32268 | @opindex mpadstruct |
ddf6fe37 | 32269 | @item -mpadstruct |
d77de738 ML |
32270 | This option is deprecated. It pads structures to multiple of 4 bytes, |
32271 | which is incompatible with the SH ABI@. | |
32272 | ||
d77de738 | 32273 | @opindex matomic-model=@var{model} |
ddf6fe37 | 32274 | @item -matomic-model=@var{model} |
d77de738 ML |
32275 | Sets the model of atomic operations and additional parameters as a comma |
32276 | separated list. For details on the atomic built-in functions see | |
32277 | @ref{__atomic Builtins}. The following models and parameters are supported: | |
32278 | ||
32279 | @table @samp | |
32280 | ||
32281 | @item none | |
32282 | Disable compiler generated atomic sequences and emit library calls for atomic | |
32283 | operations. This is the default if the target is not @code{sh*-*-linux*}. | |
32284 | ||
32285 | @item soft-gusa | |
32286 | Generate GNU/Linux compatible gUSA software atomic sequences for the atomic | |
32287 | built-in functions. The generated atomic sequences require additional support | |
32288 | from the interrupt/exception handling code of the system and are only suitable | |
32289 | for SH3* and SH4* single-core systems. This option is enabled by default when | |
32290 | the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A, | |
32291 | this option also partially utilizes the hardware atomic instructions | |
32292 | @code{movli.l} and @code{movco.l} to create more efficient code, unless | |
32293 | @samp{strict} is specified. | |
32294 | ||
32295 | @item soft-tcb | |
32296 | Generate software atomic sequences that use a variable in the thread control | |
32297 | block. This is a variation of the gUSA sequences which can also be used on | |
32298 | SH1* and SH2* targets. The generated atomic sequences require additional | |
32299 | support from the interrupt/exception handling code of the system and are only | |
32300 | suitable for single-core systems. When using this model, the @samp{gbr-offset=} | |
32301 | parameter has to be specified as well. | |
32302 | ||
32303 | @item soft-imask | |
32304 | Generate software atomic sequences that temporarily disable interrupts by | |
32305 | setting @code{SR.IMASK = 1111}. This model works only when the program runs | |
32306 | in privileged mode and is only suitable for single-core systems. Additional | |
32307 | support from the interrupt/exception handling code of the system is not | |
32308 | required. This model is enabled by default when the target is | |
32309 | @code{sh*-*-linux*} and SH1* or SH2*. | |
32310 | ||
32311 | @item hard-llcs | |
32312 | Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l} | |
32313 | instructions only. This is only available on SH4A and is suitable for | |
32314 | multi-core systems. Since the hardware instructions support only 32 bit atomic | |
32315 | variables access to 8 or 16 bit variables is emulated with 32 bit accesses. | |
32316 | Code compiled with this option is also compatible with other software | |
32317 | atomic model interrupt/exception handling systems if executed on an SH4A | |
32318 | system. Additional support from the interrupt/exception handling code of the | |
32319 | system is not required for this model. | |
32320 | ||
32321 | @item gbr-offset= | |
32322 | This parameter specifies the offset in bytes of the variable in the thread | |
32323 | control block structure that should be used by the generated atomic sequences | |
32324 | when the @samp{soft-tcb} model has been selected. For other models this | |
32325 | parameter is ignored. The specified value must be an integer multiple of four | |
32326 | and in the range 0-1020. | |
32327 | ||
32328 | @item strict | |
32329 | This parameter prevents mixed usage of multiple atomic models, even if they | |
32330 | are compatible, and makes the compiler generate atomic sequences of the | |
32331 | specified model only. | |
32332 | ||
32333 | @end table | |
32334 | ||
d77de738 | 32335 | @opindex mtas |
ddf6fe37 | 32336 | @item -mtas |
d77de738 ML |
32337 | Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}. |
32338 | Notice that depending on the particular hardware and software configuration | |
32339 | this can degrade overall performance due to the operand cache line flushes | |
32340 | that are implied by the @code{tas.b} instruction. On multi-core SH4A | |
32341 | processors the @code{tas.b} instruction must be used with caution since it | |
32342 | can result in data corruption for certain cache configurations. | |
32343 | ||
d77de738 | 32344 | @opindex mprefergot |
ddf6fe37 | 32345 | @item -mprefergot |
d77de738 ML |
32346 | When generating position-independent code, emit function calls using |
32347 | the Global Offset Table instead of the Procedure Linkage Table. | |
32348 | ||
d77de738 ML |
32349 | @opindex musermode |
32350 | @opindex mno-usermode | |
ddf6fe37 AA |
32351 | @item -musermode |
32352 | @itemx -mno-usermode | |
d77de738 ML |
32353 | Don't allow (allow) the compiler generating privileged mode code. Specifying |
32354 | @option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the | |
32355 | inlined code would not work in user mode. @option{-musermode} is the default | |
32356 | when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2* | |
32357 | @option{-musermode} has no effect, since there is no user mode. | |
32358 | ||
d77de738 | 32359 | @opindex multcost=@var{number} |
ddf6fe37 | 32360 | @item -multcost=@var{number} |
d77de738 ML |
32361 | Set the cost to assume for a multiply insn. |
32362 | ||
d77de738 | 32363 | @opindex mdiv=@var{strategy} |
ddf6fe37 | 32364 | @item -mdiv=@var{strategy} |
d77de738 ML |
32365 | Set the division strategy to be used for integer division operations. |
32366 | @var{strategy} can be one of: | |
32367 | ||
32368 | @table @samp | |
32369 | ||
32370 | @item call-div1 | |
32371 | Calls a library function that uses the single-step division instruction | |
32372 | @code{div1} to perform the operation. Division by zero calculates an | |
32373 | unspecified result and does not trap. This is the default except for SH4, | |
32374 | SH2A and SHcompact. | |
32375 | ||
32376 | @item call-fp | |
32377 | Calls a library function that performs the operation in double precision | |
32378 | floating point. Division by zero causes a floating-point exception. This is | |
32379 | the default for SHcompact with FPU. Specifying this for targets that do not | |
32380 | have a double precision FPU defaults to @code{call-div1}. | |
32381 | ||
32382 | @item call-table | |
32383 | Calls a library function that uses a lookup table for small divisors and | |
32384 | the @code{div1} instruction with case distinction for larger divisors. Division | |
32385 | by zero calculates an unspecified result and does not trap. This is the default | |
32386 | for SH4. Specifying this for targets that do not have dynamic shift | |
32387 | instructions defaults to @code{call-div1}. | |
32388 | ||
32389 | @end table | |
32390 | ||
32391 | When a division strategy has not been specified the default strategy is | |
32392 | selected based on the current target. For SH2A the default strategy is to | |
32393 | use the @code{divs} and @code{divu} instructions instead of library function | |
32394 | calls. | |
32395 | ||
d77de738 | 32396 | @opindex maccumulate-outgoing-args |
ddf6fe37 | 32397 | @item -maccumulate-outgoing-args |
d77de738 ML |
32398 | Reserve space once for outgoing arguments in the function prologue rather |
32399 | than around each call. Generally beneficial for performance and size. Also | |
32400 | needed for unwinding to avoid changing the stack frame around conditional code. | |
32401 | ||
d77de738 | 32402 | @opindex mdivsi3_libfunc=@var{name} |
ddf6fe37 | 32403 | @item -mdivsi3_libfunc=@var{name} |
d77de738 ML |
32404 | Set the name of the library function used for 32-bit signed division to |
32405 | @var{name}. | |
32406 | This only affects the name used in the @samp{call} division strategies, and | |
32407 | the compiler still expects the same sets of input/output/clobbered registers as | |
32408 | if this option were not present. | |
32409 | ||
d77de738 | 32410 | @opindex mfixed-range |
ddf6fe37 | 32411 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
32412 | Generate code treating the given register range as fixed registers. |
32413 | A fixed register is one that the register allocator cannot use. This is | |
32414 | useful when compiling kernel code. A register range is specified as | |
32415 | two registers separated by a dash. Multiple register ranges can be | |
32416 | specified separated by a comma. | |
32417 | ||
d77de738 | 32418 | @opindex mbranch-cost=@var{num} |
ddf6fe37 | 32419 | @item -mbranch-cost=@var{num} |
d77de738 ML |
32420 | Assume @var{num} to be the cost for a branch instruction. Higher numbers |
32421 | make the compiler try to generate more branch-free code if possible. | |
32422 | If not specified the value is selected depending on the processor type that | |
32423 | is being compiled for. | |
32424 | ||
d77de738 ML |
32425 | @opindex mzdcbranch |
32426 | @opindex mno-zdcbranch | |
ddf6fe37 AA |
32427 | @item -mzdcbranch |
32428 | @itemx -mno-zdcbranch | |
d77de738 ML |
32429 | Assume (do not assume) that zero displacement conditional branch instructions |
32430 | @code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the | |
32431 | compiler prefers zero displacement branch code sequences. This is | |
32432 | enabled by default when generating code for SH4 and SH4A. It can be explicitly | |
32433 | disabled by specifying @option{-mno-zdcbranch}. | |
32434 | ||
d77de738 | 32435 | @opindex mcbranch-force-delay-slot |
ddf6fe37 | 32436 | @item -mcbranch-force-delay-slot |
d77de738 ML |
32437 | Force the usage of delay slots for conditional branches, which stuffs the delay |
32438 | slot with a @code{nop} if a suitable instruction cannot be found. By default | |
32439 | this option is disabled. It can be enabled to work around hardware bugs as | |
32440 | found in the original SH7055. | |
32441 | ||
d77de738 ML |
32442 | @opindex mfused-madd |
32443 | @opindex mno-fused-madd | |
ddf6fe37 AA |
32444 | @item -mfused-madd |
32445 | @itemx -mno-fused-madd | |
d77de738 ML |
32446 | Generate code that uses (does not use) the floating-point multiply and |
32447 | accumulate instructions. These instructions are generated by default | |
32448 | if hardware floating point is used. The machine-dependent | |
32449 | @option{-mfused-madd} option is now mapped to the machine-independent | |
32450 | @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is | |
32451 | mapped to @option{-ffp-contract=off}. | |
32452 | ||
d77de738 ML |
32453 | @opindex mfsca |
32454 | @opindex mno-fsca | |
ddf6fe37 AA |
32455 | @item -mfsca |
32456 | @itemx -mno-fsca | |
d77de738 ML |
32457 | Allow or disallow the compiler to emit the @code{fsca} instruction for sine |
32458 | and cosine approximations. The option @option{-mfsca} must be used in | |
32459 | combination with @option{-funsafe-math-optimizations}. It is enabled by default | |
32460 | when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine | |
32461 | approximations even if @option{-funsafe-math-optimizations} is in effect. | |
32462 | ||
d77de738 ML |
32463 | @opindex mfsrra |
32464 | @opindex mno-fsrra | |
ddf6fe37 AA |
32465 | @item -mfsrra |
32466 | @itemx -mno-fsrra | |
d77de738 ML |
32467 | Allow or disallow the compiler to emit the @code{fsrra} instruction for |
32468 | reciprocal square root approximations. The option @option{-mfsrra} must be used | |
32469 | in combination with @option{-funsafe-math-optimizations} and | |
32470 | @option{-ffinite-math-only}. It is enabled by default when generating code for | |
32471 | SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations | |
32472 | even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are | |
32473 | in effect. | |
32474 | ||
d77de738 | 32475 | @opindex mpretend-cmove |
ddf6fe37 | 32476 | @item -mpretend-cmove |
d77de738 ML |
32477 | Prefer zero-displacement conditional branches for conditional move instruction |
32478 | patterns. This can result in faster code on the SH4 processor. | |
32479 | ||
d77de738 | 32480 | @opindex fdpic |
ddf6fe37 | 32481 | @item -mfdpic |
d77de738 ML |
32482 | Generate code using the FDPIC ABI. |
32483 | ||
32484 | @end table | |
32485 | ||
32486 | @node Solaris 2 Options | |
32487 | @subsection Solaris 2 Options | |
32488 | @cindex Solaris 2 options | |
32489 | ||
32490 | These @samp{-m} options are supported on Solaris 2: | |
32491 | ||
32492 | @table @gcctabopt | |
d77de738 | 32493 | @opindex mclear-hwcap |
ddf6fe37 | 32494 | @item -mclear-hwcap |
d77de738 ML |
32495 | @option{-mclear-hwcap} tells the compiler to remove the hardware |
32496 | capabilities generated by the Solaris assembler. This is only necessary | |
32497 | when object files use ISA extensions not supported by the current | |
32498 | machine, but check at runtime whether or not to use them. | |
32499 | ||
d77de738 | 32500 | @opindex mimpure-text |
ddf6fe37 | 32501 | @item -mimpure-text |
d77de738 ML |
32502 | @option{-mimpure-text}, used in addition to @option{-shared}, tells |
32503 | the compiler to not pass @option{-z text} to the linker when linking a | |
32504 | shared object. Using this option, you can link position-dependent | |
32505 | code into a shared object. | |
32506 | ||
32507 | @option{-mimpure-text} suppresses the ``relocations remain against | |
32508 | allocatable but non-writable sections'' linker error message. | |
32509 | However, the necessary relocations trigger copy-on-write, and the | |
32510 | shared object is not actually shared across processes. Instead of | |
32511 | using @option{-mimpure-text}, you should compile all source code with | |
32512 | @option{-fpic} or @option{-fPIC}. | |
32513 | ||
32514 | @end table | |
32515 | ||
32516 | These switches are supported in addition to the above on Solaris 2: | |
32517 | ||
32518 | @table @gcctabopt | |
d77de738 | 32519 | @opindex pthreads |
ddf6fe37 | 32520 | @item -pthreads |
d77de738 ML |
32521 | This is a synonym for @option{-pthread}. |
32522 | @end table | |
32523 | ||
32524 | @node SPARC Options | |
32525 | @subsection SPARC Options | |
32526 | @cindex SPARC options | |
32527 | ||
32528 | These @samp{-m} options are supported on the SPARC: | |
32529 | ||
32530 | @table @gcctabopt | |
d77de738 ML |
32531 | @opindex mno-app-regs |
32532 | @opindex mapp-regs | |
ddf6fe37 AA |
32533 | @item -mno-app-regs |
32534 | @itemx -mapp-regs | |
d77de738 ML |
32535 | Specify @option{-mapp-regs} to generate output using the global registers |
32536 | 2 through 4, which the SPARC SVR4 ABI reserves for applications. Like the | |
32537 | global register 1, each global register 2 through 4 is then treated as an | |
32538 | allocable register that is clobbered by function calls. This is the default. | |
32539 | ||
32540 | To be fully SVR4 ABI-compliant at the cost of some performance loss, | |
32541 | specify @option{-mno-app-regs}. You should compile libraries and system | |
32542 | software with this option. | |
32543 | ||
d77de738 ML |
32544 | @opindex mflat |
32545 | @opindex mno-flat | |
ddf6fe37 AA |
32546 | @item -mflat |
32547 | @itemx -mno-flat | |
d77de738 ML |
32548 | With @option{-mflat}, the compiler does not generate save/restore instructions |
32549 | and uses a ``flat'' or single register window model. This model is compatible | |
32550 | with the regular register window model. The local registers and the input | |
32551 | registers (0--5) are still treated as ``call-saved'' registers and are | |
32552 | saved on the stack as needed. | |
32553 | ||
32554 | With @option{-mno-flat} (the default), the compiler generates save/restore | |
32555 | instructions (except for leaf functions). This is the normal operating mode. | |
32556 | ||
d77de738 ML |
32557 | @opindex mfpu |
32558 | @opindex mhard-float | |
ddf6fe37 AA |
32559 | @item -mfpu |
32560 | @itemx -mhard-float | |
d77de738 ML |
32561 | Generate output containing floating-point instructions. This is the |
32562 | default. | |
32563 | ||
d77de738 ML |
32564 | @opindex mno-fpu |
32565 | @opindex msoft-float | |
ddf6fe37 AA |
32566 | @item -mno-fpu |
32567 | @itemx -msoft-float | |
d77de738 ML |
32568 | Generate output containing library calls for floating point. |
32569 | @strong{Warning:} the requisite libraries are not available for all SPARC | |
32570 | targets. Normally the facilities of the machine's usual C compiler are | |
32571 | used, but this cannot be done directly in cross-compilation. You must make | |
32572 | your own arrangements to provide suitable library functions for | |
32573 | cross-compilation. The embedded targets @samp{sparc-*-aout} and | |
32574 | @samp{sparclite-*-*} do provide software floating-point support. | |
32575 | ||
32576 | @option{-msoft-float} changes the calling convention in the output file; | |
32577 | therefore, it is only useful if you compile @emph{all} of a program with | |
32578 | this option. In particular, you need to compile @file{libgcc.a}, the | |
32579 | library that comes with GCC, with @option{-msoft-float} in order for | |
32580 | this to work. | |
32581 | ||
d77de738 | 32582 | @opindex mhard-quad-float |
ddf6fe37 | 32583 | @item -mhard-quad-float |
d77de738 ML |
32584 | Generate output containing quad-word (long double) floating-point |
32585 | instructions. | |
32586 | ||
d77de738 | 32587 | @opindex msoft-quad-float |
ddf6fe37 | 32588 | @item -msoft-quad-float |
d77de738 ML |
32589 | Generate output containing library calls for quad-word (long double) |
32590 | floating-point instructions. The functions called are those specified | |
32591 | in the SPARC ABI@. This is the default. | |
32592 | ||
32593 | As of this writing, there are no SPARC implementations that have hardware | |
32594 | support for the quad-word floating-point instructions. They all invoke | |
32595 | a trap handler for one of these instructions, and then the trap handler | |
32596 | emulates the effect of the instruction. Because of the trap handler overhead, | |
32597 | this is much slower than calling the ABI library routines. Thus the | |
32598 | @option{-msoft-quad-float} option is the default. | |
32599 | ||
d77de738 ML |
32600 | @opindex mno-unaligned-doubles |
32601 | @opindex munaligned-doubles | |
ddf6fe37 AA |
32602 | @item -mno-unaligned-doubles |
32603 | @itemx -munaligned-doubles | |
d77de738 ML |
32604 | Assume that doubles have 8-byte alignment. This is the default. |
32605 | ||
32606 | With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte | |
32607 | alignment only if they are contained in another type, or if they have an | |
32608 | absolute address. Otherwise, it assumes they have 4-byte alignment. | |
32609 | Specifying this option avoids some rare compatibility problems with code | |
32610 | generated by other compilers. It is not the default because it results | |
32611 | in a performance loss, especially for floating-point code. | |
32612 | ||
d77de738 ML |
32613 | @opindex muser-mode |
32614 | @opindex mno-user-mode | |
ddf6fe37 AA |
32615 | @item -muser-mode |
32616 | @itemx -mno-user-mode | |
d77de738 ML |
32617 | Do not generate code that can only run in supervisor mode. This is relevant |
32618 | only for the @code{casa} instruction emitted for the LEON3 processor. This | |
32619 | is the default. | |
32620 | ||
d77de738 ML |
32621 | @opindex mfaster-structs |
32622 | @opindex mno-faster-structs | |
ddf6fe37 AA |
32623 | @item -mfaster-structs |
32624 | @itemx -mno-faster-structs | |
d77de738 ML |
32625 | With @option{-mfaster-structs}, the compiler assumes that structures |
32626 | should have 8-byte alignment. This enables the use of pairs of | |
32627 | @code{ldd} and @code{std} instructions for copies in structure | |
32628 | assignment, in place of twice as many @code{ld} and @code{st} pairs. | |
32629 | However, the use of this changed alignment directly violates the SPARC | |
32630 | ABI@. Thus, it's intended only for use on targets where the developer | |
32631 | acknowledges that their resulting code is not directly in line with | |
32632 | the rules of the ABI@. | |
32633 | ||
d77de738 ML |
32634 | @opindex mstd-struct-return |
32635 | @opindex mno-std-struct-return | |
ddf6fe37 AA |
32636 | @item -mstd-struct-return |
32637 | @itemx -mno-std-struct-return | |
d77de738 ML |
32638 | With @option{-mstd-struct-return}, the compiler generates checking code |
32639 | in functions returning structures or unions to detect size mismatches | |
32640 | between the two sides of function calls, as per the 32-bit ABI@. | |
32641 | ||
32642 | The default is @option{-mno-std-struct-return}. This option has no effect | |
32643 | in 64-bit mode. | |
32644 | ||
d77de738 ML |
32645 | @opindex mlra |
32646 | @opindex mno-lra | |
ddf6fe37 AA |
32647 | @item -mlra |
32648 | @itemx -mno-lra | |
d77de738 ML |
32649 | Enable Local Register Allocation. This is the default for SPARC since GCC 7 |
32650 | so @option{-mno-lra} needs to be passed to get old Reload. | |
32651 | ||
d77de738 | 32652 | @opindex mcpu |
ddf6fe37 | 32653 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
32654 | Set the instruction set, register set, and instruction scheduling parameters |
32655 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
32656 | @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc}, | |
32657 | @samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite}, | |
32658 | @samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701}, | |
32659 | @samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara}, | |
32660 | @samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and | |
32661 | @samp{m8}. | |
32662 | ||
32663 | Native Solaris and GNU/Linux toolchains also support the value @samp{native}, | |
32664 | which selects the best architecture option for the host processor. | |
32665 | @option{-mcpu=native} has no effect if GCC does not recognize | |
32666 | the processor. | |
32667 | ||
32668 | Default instruction scheduling parameters are used for values that select | |
32669 | an architecture and not an implementation. These are @samp{v7}, @samp{v8}, | |
32670 | @samp{sparclite}, @samp{sparclet}, @samp{v9}. | |
32671 | ||
32672 | Here is a list of each supported architecture and their supported | |
32673 | implementations. | |
32674 | ||
32675 | @table @asis | |
32676 | @item v7 | |
32677 | cypress, leon3v7 | |
32678 | ||
32679 | @item v8 | |
32680 | supersparc, hypersparc, leon, leon3, leon5 | |
32681 | ||
32682 | @item sparclite | |
32683 | f930, f934, sparclite86x | |
32684 | ||
32685 | @item sparclet | |
32686 | tsc701 | |
32687 | ||
32688 | @item v9 | |
32689 | ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4, | |
32690 | niagara7, m8 | |
32691 | @end table | |
32692 | ||
32693 | By default (unless configured otherwise), GCC generates code for the V7 | |
32694 | variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler | |
32695 | additionally optimizes it for the Cypress CY7C602 chip, as used in the | |
32696 | SPARCStation/SPARCServer 3xx series. This is also appropriate for the older | |
32697 | SPARCStation 1, 2, IPX etc. | |
32698 | ||
32699 | With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC | |
32700 | architecture. The only difference from V7 code is that the compiler emits | |
32701 | the integer multiply and integer divide instructions which exist in SPARC-V8 | |
32702 | but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally | |
32703 | optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and | |
32704 | 2000 series. | |
32705 | ||
32706 | With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of | |
32707 | the SPARC architecture. This adds the integer multiply, integer divide step | |
32708 | and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7. | |
32709 | With @option{-mcpu=f930}, the compiler additionally optimizes it for the | |
32710 | Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With | |
32711 | @option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu | |
32712 | MB86934 chip, which is the more recent SPARClite with FPU@. | |
32713 | ||
32714 | With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of | |
32715 | the SPARC architecture. This adds the integer multiply, multiply/accumulate, | |
32716 | integer divide step and scan (@code{ffs}) instructions which exist in SPARClet | |
32717 | but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally | |
32718 | optimizes it for the TEMIC SPARClet chip. | |
32719 | ||
32720 | With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC | |
32721 | architecture. This adds 64-bit integer and floating-point move instructions, | |
32722 | 3 additional floating-point condition code registers and conditional move | |
32723 | instructions. With @option{-mcpu=ultrasparc}, the compiler additionally | |
32724 | optimizes it for the Sun UltraSPARC I/II/IIi chips. With | |
32725 | @option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the | |
32726 | Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With | |
32727 | @option{-mcpu=niagara}, the compiler additionally optimizes it for | |
32728 | Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler | |
32729 | additionally optimizes it for Sun UltraSPARC T2 chips. With | |
32730 | @option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun | |
32731 | UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler | |
32732 | additionally optimizes it for Sun UltraSPARC T4 chips. With | |
32733 | @option{-mcpu=niagara7}, the compiler additionally optimizes it for | |
32734 | Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler | |
32735 | additionally optimizes it for Oracle M8 chips. | |
32736 | ||
d77de738 | 32737 | @opindex mtune |
ddf6fe37 | 32738 | @item -mtune=@var{cpu_type} |
d77de738 ML |
32739 | Set the instruction scheduling parameters for machine type |
32740 | @var{cpu_type}, but do not set the instruction set or register set that the | |
32741 | option @option{-mcpu=@var{cpu_type}} does. | |
32742 | ||
32743 | The same values for @option{-mcpu=@var{cpu_type}} can be used for | |
32744 | @option{-mtune=@var{cpu_type}}, but the only useful values are those | |
32745 | that select a particular CPU implementation. Those are | |
32746 | @samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon}, | |
32747 | @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934}, | |
32748 | @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc}, | |
32749 | @samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3}, | |
32750 | @samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris | |
32751 | and GNU/Linux toolchains, @samp{native} can also be used. | |
32752 | ||
d77de738 ML |
32753 | @opindex mv8plus |
32754 | @opindex mno-v8plus | |
ddf6fe37 AA |
32755 | @item -mv8plus |
32756 | @itemx -mno-v8plus | |
d77de738 ML |
32757 | With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The |
32758 | difference from the V8 ABI is that the global and out registers are | |
32759 | considered 64 bits wide. This is enabled by default on Solaris in 32-bit | |
32760 | mode for all SPARC-V9 processors. | |
32761 | ||
d77de738 ML |
32762 | @opindex mvis |
32763 | @opindex mno-vis | |
ddf6fe37 AA |
32764 | @item -mvis |
32765 | @itemx -mno-vis | |
d77de738 ML |
32766 | With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC |
32767 | Visual Instruction Set extensions. The default is @option{-mno-vis}. | |
32768 | ||
d77de738 ML |
32769 | @opindex mvis2 |
32770 | @opindex mno-vis2 | |
ddf6fe37 AA |
32771 | @item -mvis2 |
32772 | @itemx -mno-vis2 | |
d77de738 ML |
32773 | With @option{-mvis2}, GCC generates code that takes advantage of |
32774 | version 2.0 of the UltraSPARC Visual Instruction Set extensions. The | |
32775 | default is @option{-mvis2} when targeting a cpu that supports such | |
32776 | instructions, such as UltraSPARC-III and later. Setting @option{-mvis2} | |
32777 | also sets @option{-mvis}. | |
32778 | ||
d77de738 ML |
32779 | @opindex mvis3 |
32780 | @opindex mno-vis3 | |
ddf6fe37 AA |
32781 | @item -mvis3 |
32782 | @itemx -mno-vis3 | |
d77de738 ML |
32783 | With @option{-mvis3}, GCC generates code that takes advantage of |
32784 | version 3.0 of the UltraSPARC Visual Instruction Set extensions. The | |
32785 | default is @option{-mvis3} when targeting a cpu that supports such | |
32786 | instructions, such as niagara-3 and later. Setting @option{-mvis3} | |
32787 | also sets @option{-mvis2} and @option{-mvis}. | |
32788 | ||
d77de738 ML |
32789 | @opindex mvis4 |
32790 | @opindex mno-vis4 | |
ddf6fe37 AA |
32791 | @item -mvis4 |
32792 | @itemx -mno-vis4 | |
d77de738 ML |
32793 | With @option{-mvis4}, GCC generates code that takes advantage of |
32794 | version 4.0 of the UltraSPARC Visual Instruction Set extensions. The | |
32795 | default is @option{-mvis4} when targeting a cpu that supports such | |
32796 | instructions, such as niagara-7 and later. Setting @option{-mvis4} | |
32797 | also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}. | |
32798 | ||
d77de738 ML |
32799 | @opindex mvis4b |
32800 | @opindex mno-vis4b | |
ddf6fe37 AA |
32801 | @item -mvis4b |
32802 | @itemx -mno-vis4b | |
d77de738 ML |
32803 | With @option{-mvis4b}, GCC generates code that takes advantage of |
32804 | version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus | |
32805 | the additional VIS instructions introduced in the Oracle SPARC | |
32806 | Architecture 2017. The default is @option{-mvis4b} when targeting a | |
32807 | cpu that supports such instructions, such as m8 and later. Setting | |
32808 | @option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3}, | |
32809 | @option{-mvis2} and @option{-mvis}. | |
32810 | ||
d77de738 ML |
32811 | @opindex mcbcond |
32812 | @opindex mno-cbcond | |
ddf6fe37 AA |
32813 | @item -mcbcond |
32814 | @itemx -mno-cbcond | |
d77de738 ML |
32815 | With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC |
32816 | Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond} | |
32817 | when targeting a CPU that supports such instructions, such as Niagara-4 and | |
32818 | later. | |
32819 | ||
d77de738 ML |
32820 | @opindex mfmaf |
32821 | @opindex mno-fmaf | |
ddf6fe37 AA |
32822 | @item -mfmaf |
32823 | @itemx -mno-fmaf | |
d77de738 ML |
32824 | With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC |
32825 | Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf} | |
32826 | when targeting a CPU that supports such instructions, such as Niagara-3 and | |
32827 | later. | |
32828 | ||
d77de738 ML |
32829 | @opindex mfsmuld |
32830 | @opindex mno-fsmuld | |
ddf6fe37 AA |
32831 | @item -mfsmuld |
32832 | @itemx -mno-fsmuld | |
d77de738 ML |
32833 | With @option{-mfsmuld}, GCC generates code that takes advantage of the |
32834 | Floating-point Multiply Single to Double (FsMULd) instruction. The default is | |
32835 | @option{-mfsmuld} when targeting a CPU supporting the architecture versions V8 | |
32836 | or V9 with FPU except @option{-mcpu=leon}. | |
32837 | ||
d77de738 ML |
32838 | @opindex mpopc |
32839 | @opindex mno-popc | |
ddf6fe37 AA |
32840 | @item -mpopc |
32841 | @itemx -mno-popc | |
d77de738 ML |
32842 | With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC |
32843 | Population Count instruction. The default is @option{-mpopc} | |
32844 | when targeting a CPU that supports such an instruction, such as Niagara-2 and | |
32845 | later. | |
32846 | ||
d77de738 ML |
32847 | @opindex msubxc |
32848 | @opindex mno-subxc | |
ddf6fe37 AA |
32849 | @item -msubxc |
32850 | @itemx -mno-subxc | |
d77de738 ML |
32851 | With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC |
32852 | Subtract-Extended-with-Carry instruction. The default is @option{-msubxc} | |
32853 | when targeting a CPU that supports such an instruction, such as Niagara-7 and | |
32854 | later. | |
32855 | ||
d77de738 | 32856 | @opindex mfix-at697f |
ddf6fe37 | 32857 | @item -mfix-at697f |
d77de738 ML |
32858 | Enable the documented workaround for the single erratum of the Atmel AT697F |
32859 | processor (which corresponds to erratum #13 of the AT697E processor). | |
32860 | ||
d77de738 | 32861 | @opindex mfix-ut699 |
ddf6fe37 | 32862 | @item -mfix-ut699 |
d77de738 ML |
32863 | Enable the documented workarounds for the floating-point errata and the data |
32864 | cache nullify errata of the UT699 processor. | |
32865 | ||
d77de738 | 32866 | @opindex mfix-ut700 |
ddf6fe37 | 32867 | @item -mfix-ut700 |
d77de738 ML |
32868 | Enable the documented workaround for the back-to-back store errata of |
32869 | the UT699E/UT700 processor. | |
32870 | ||
d77de738 | 32871 | @opindex mfix-gr712rc |
ddf6fe37 | 32872 | @item -mfix-gr712rc |
d77de738 ML |
32873 | Enable the documented workaround for the back-to-back store errata of |
32874 | the GR712RC processor. | |
32875 | @end table | |
32876 | ||
32877 | These @samp{-m} options are supported in addition to the above | |
32878 | on SPARC-V9 processors in 64-bit environments: | |
32879 | ||
32880 | @table @gcctabopt | |
d77de738 ML |
32881 | @opindex m32 |
32882 | @opindex m64 | |
ddf6fe37 AA |
32883 | @item -m32 |
32884 | @itemx -m64 | |
d77de738 ML |
32885 | Generate code for a 32-bit or 64-bit environment. |
32886 | The 32-bit environment sets int, long and pointer to 32 bits. | |
32887 | The 64-bit environment sets int to 32 bits and long and pointer | |
32888 | to 64 bits. | |
32889 | ||
d77de738 | 32890 | @opindex mcmodel |
ddf6fe37 | 32891 | @item -mcmodel=@var{which} |
d77de738 ML |
32892 | Set the code model to one of |
32893 | ||
32894 | @table @samp | |
32895 | @item medlow | |
32896 | The Medium/Low code model: 64-bit addresses, programs | |
32897 | must be linked in the low 32 bits of memory. Programs can be statically | |
32898 | or dynamically linked. | |
32899 | ||
32900 | @item medmid | |
32901 | The Medium/Middle code model: 64-bit addresses, programs | |
32902 | must be linked in the low 44 bits of memory, the text and data segments must | |
32903 | be less than 2GB in size and the data segment must be located within 2GB of | |
32904 | the text segment. | |
32905 | ||
32906 | @item medany | |
32907 | The Medium/Anywhere code model: 64-bit addresses, programs | |
32908 | may be linked anywhere in memory, the text and data segments must be less | |
32909 | than 2GB in size and the data segment must be located within 2GB of the | |
32910 | text segment. | |
32911 | ||
32912 | @item embmedany | |
32913 | The Medium/Anywhere code model for embedded systems: | |
32914 | 64-bit addresses, the text and data segments must be less than 2GB in | |
32915 | size, both starting anywhere in memory (determined at link time). The | |
32916 | global register %g4 points to the base of the data segment. Programs | |
32917 | are statically linked and PIC is not supported. | |
32918 | @end table | |
32919 | ||
d77de738 | 32920 | @opindex mmemory-model |
ddf6fe37 | 32921 | @item -mmemory-model=@var{mem-model} |
d77de738 ML |
32922 | Set the memory model in force on the processor to one of |
32923 | ||
32924 | @table @samp | |
32925 | @item default | |
32926 | The default memory model for the processor and operating system. | |
32927 | ||
32928 | @item rmo | |
32929 | Relaxed Memory Order | |
32930 | ||
32931 | @item pso | |
32932 | Partial Store Order | |
32933 | ||
32934 | @item tso | |
32935 | Total Store Order | |
32936 | ||
32937 | @item sc | |
32938 | Sequential Consistency | |
32939 | @end table | |
32940 | ||
32941 | These memory models are formally defined in Appendix D of the SPARC-V9 | |
32942 | architecture manual, as set in the processor's @code{PSTATE.MM} field. | |
32943 | ||
d77de738 ML |
32944 | @opindex mstack-bias |
32945 | @opindex mno-stack-bias | |
ddf6fe37 AA |
32946 | @item -mstack-bias |
32947 | @itemx -mno-stack-bias | |
d77de738 ML |
32948 | With @option{-mstack-bias}, GCC assumes that the stack pointer, and |
32949 | frame pointer if present, are offset by @minus{}2047 which must be added back | |
32950 | when making stack frame references. This is the default in 64-bit mode. | |
32951 | Otherwise, assume no such offset is present. | |
32952 | @end table | |
32953 | ||
32954 | @node System V Options | |
32955 | @subsection Options for System V | |
32956 | ||
32957 | These additional options are available on System V Release 4 for | |
32958 | compatibility with other compilers on those systems: | |
32959 | ||
32960 | @table @gcctabopt | |
d77de738 | 32961 | @opindex G |
ddf6fe37 | 32962 | @item -G |
d77de738 ML |
32963 | Create a shared object. |
32964 | It is recommended that @option{-symbolic} or @option{-shared} be used instead. | |
32965 | ||
d77de738 | 32966 | @opindex Qy |
ddf6fe37 | 32967 | @item -Qy |
d77de738 ML |
32968 | Identify the versions of each tool used by the compiler, in a |
32969 | @code{.ident} assembler directive in the output. | |
32970 | ||
d77de738 | 32971 | @opindex Qn |
ddf6fe37 | 32972 | @item -Qn |
d77de738 ML |
32973 | Refrain from adding @code{.ident} directives to the output file (this is |
32974 | the default). | |
32975 | ||
d77de738 | 32976 | @opindex YP |
ddf6fe37 | 32977 | @item -YP,@var{dirs} |
d77de738 ML |
32978 | Search the directories @var{dirs}, and no others, for libraries |
32979 | specified with @option{-l}. | |
32980 | ||
d77de738 | 32981 | @opindex Ym |
ddf6fe37 | 32982 | @item -Ym,@var{dir} |
d77de738 ML |
32983 | Look in the directory @var{dir} to find the M4 preprocessor. |
32984 | The assembler uses this option. | |
32985 | @c This is supposed to go with a -Yd for predefined M4 macro files, but | |
32986 | @c the generic assembler that comes with Solaris takes just -Ym. | |
32987 | @end table | |
32988 | ||
32989 | @node V850 Options | |
32990 | @subsection V850 Options | |
32991 | @cindex V850 Options | |
32992 | ||
32993 | These @samp{-m} options are defined for V850 implementations: | |
32994 | ||
32995 | @table @gcctabopt | |
d77de738 ML |
32996 | @opindex mlong-calls |
32997 | @opindex mno-long-calls | |
ddf6fe37 AA |
32998 | @item -mlong-calls |
32999 | @itemx -mno-long-calls | |
d77de738 ML |
33000 | Treat all calls as being far away (near). If calls are assumed to be |
33001 | far away, the compiler always loads the function's address into a | |
33002 | register, and calls indirect through the pointer. | |
33003 | ||
d77de738 ML |
33004 | @opindex mno-ep |
33005 | @opindex mep | |
ddf6fe37 AA |
33006 | @item -mno-ep |
33007 | @itemx -mep | |
d77de738 ML |
33008 | Do not optimize (do optimize) basic blocks that use the same index |
33009 | pointer 4 or more times to copy pointer into the @code{ep} register, and | |
33010 | use the shorter @code{sld} and @code{sst} instructions. The @option{-mep} | |
33011 | option is on by default if you optimize. | |
33012 | ||
d77de738 ML |
33013 | @opindex mno-prolog-function |
33014 | @opindex mprolog-function | |
ddf6fe37 AA |
33015 | @item -mno-prolog-function |
33016 | @itemx -mprolog-function | |
d77de738 ML |
33017 | Do not use (do use) external functions to save and restore registers |
33018 | at the prologue and epilogue of a function. The external functions | |
33019 | are slower, but use less code space if more than one function saves | |
33020 | the same number of registers. The @option{-mprolog-function} option | |
33021 | is on by default if you optimize. | |
33022 | ||
d77de738 | 33023 | @opindex mspace |
ddf6fe37 | 33024 | @item -mspace |
d77de738 ML |
33025 | Try to make the code as small as possible. At present, this just turns |
33026 | on the @option{-mep} and @option{-mprolog-function} options. | |
33027 | ||
d77de738 | 33028 | @opindex mtda |
ddf6fe37 | 33029 | @item -mtda=@var{n} |
d77de738 ML |
33030 | Put static or global variables whose size is @var{n} bytes or less into |
33031 | the tiny data area that register @code{ep} points to. The tiny data | |
33032 | area can hold up to 256 bytes in total (128 bytes for byte references). | |
33033 | ||
d77de738 | 33034 | @opindex msda |
ddf6fe37 | 33035 | @item -msda=@var{n} |
d77de738 ML |
33036 | Put static or global variables whose size is @var{n} bytes or less into |
33037 | the small data area that register @code{gp} points to. The small data | |
33038 | area can hold up to 64 kilobytes. | |
33039 | ||
d77de738 | 33040 | @opindex mzda |
ddf6fe37 | 33041 | @item -mzda=@var{n} |
d77de738 ML |
33042 | Put static or global variables whose size is @var{n} bytes or less into |
33043 | the first 32 kilobytes of memory. | |
33044 | ||
d77de738 | 33045 | @opindex mv850 |
ddf6fe37 | 33046 | @item -mv850 |
d77de738 ML |
33047 | Specify that the target processor is the V850. |
33048 | ||
d77de738 | 33049 | @opindex mv850e3v5 |
ddf6fe37 | 33050 | @item -mv850e3v5 |
d77de738 ML |
33051 | Specify that the target processor is the V850E3V5. The preprocessor |
33052 | constant @code{__v850e3v5__} is defined if this option is used. | |
33053 | ||
d77de738 | 33054 | @opindex mv850e2v4 |
ddf6fe37 | 33055 | @item -mv850e2v4 |
d77de738 ML |
33056 | Specify that the target processor is the V850E3V5. This is an alias for |
33057 | the @option{-mv850e3v5} option. | |
33058 | ||
d77de738 | 33059 | @opindex mv850e2v3 |
ddf6fe37 | 33060 | @item -mv850e2v3 |
d77de738 ML |
33061 | Specify that the target processor is the V850E2V3. The preprocessor |
33062 | constant @code{__v850e2v3__} is defined if this option is used. | |
33063 | ||
d77de738 | 33064 | @opindex mv850e2 |
ddf6fe37 | 33065 | @item -mv850e2 |
d77de738 ML |
33066 | Specify that the target processor is the V850E2. The preprocessor |
33067 | constant @code{__v850e2__} is defined if this option is used. | |
33068 | ||
d77de738 | 33069 | @opindex mv850e1 |
ddf6fe37 | 33070 | @item -mv850e1 |
d77de738 ML |
33071 | Specify that the target processor is the V850E1. The preprocessor |
33072 | constants @code{__v850e1__} and @code{__v850e__} are defined if | |
33073 | this option is used. | |
33074 | ||
d77de738 | 33075 | @opindex mv850es |
ddf6fe37 | 33076 | @item -mv850es |
d77de738 ML |
33077 | Specify that the target processor is the V850ES. This is an alias for |
33078 | the @option{-mv850e1} option. | |
33079 | ||
d77de738 | 33080 | @opindex mv850e |
ddf6fe37 | 33081 | @item -mv850e |
d77de738 ML |
33082 | Specify that the target processor is the V850E@. The preprocessor |
33083 | constant @code{__v850e__} is defined if this option is used. | |
33084 | ||
33085 | If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1} | |
33086 | nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5} | |
33087 | are defined then a default target processor is chosen and the | |
33088 | relevant @samp{__v850*__} preprocessor constant is defined. | |
33089 | ||
33090 | The preprocessor constants @code{__v850} and @code{__v851__} are always | |
33091 | defined, regardless of which processor variant is the target. | |
33092 | ||
d77de738 ML |
33093 | @opindex mdisable-callt |
33094 | @opindex mno-disable-callt | |
ddf6fe37 AA |
33095 | @item -mdisable-callt |
33096 | @itemx -mno-disable-callt | |
d77de738 ML |
33097 | This option suppresses generation of the @code{CALLT} instruction for the |
33098 | v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850 | |
33099 | architecture. | |
33100 | ||
33101 | This option is enabled by default when the RH850 ABI is | |
33102 | in use (see @option{-mrh850-abi}), and disabled by default when the | |
33103 | GCC ABI is in use. If @code{CALLT} instructions are being generated | |
33104 | then the C preprocessor symbol @code{__V850_CALLT__} is defined. | |
33105 | ||
d77de738 ML |
33106 | @opindex mrelax |
33107 | @opindex mno-relax | |
ddf6fe37 AA |
33108 | @item -mrelax |
33109 | @itemx -mno-relax | |
d77de738 ML |
33110 | Pass on (or do not pass on) the @option{-mrelax} command-line option |
33111 | to the assembler. | |
33112 | ||
d77de738 ML |
33113 | @opindex mlong-jumps |
33114 | @opindex mno-long-jumps | |
ddf6fe37 AA |
33115 | @item -mlong-jumps |
33116 | @itemx -mno-long-jumps | |
d77de738 ML |
33117 | Disable (or re-enable) the generation of PC-relative jump instructions. |
33118 | ||
d77de738 ML |
33119 | @opindex msoft-float |
33120 | @opindex mhard-float | |
ddf6fe37 AA |
33121 | @item -msoft-float |
33122 | @itemx -mhard-float | |
d77de738 ML |
33123 | Disable (or re-enable) the generation of hardware floating point |
33124 | instructions. This option is only significant when the target | |
33125 | architecture is @samp{V850E2V3} or higher. If hardware floating point | |
33126 | instructions are being generated then the C preprocessor symbol | |
33127 | @code{__FPU_OK__} is defined, otherwise the symbol | |
33128 | @code{__NO_FPU__} is defined. | |
33129 | ||
d77de738 | 33130 | @opindex mloop |
ddf6fe37 | 33131 | @item -mloop |
d77de738 ML |
33132 | Enables the use of the e3v5 LOOP instruction. The use of this |
33133 | instruction is not enabled by default when the e3v5 architecture is | |
33134 | selected because its use is still experimental. | |
33135 | ||
d77de738 ML |
33136 | @opindex mrh850-abi |
33137 | @opindex mghs | |
ddf6fe37 AA |
33138 | @item -mrh850-abi |
33139 | @itemx -mghs | |
d77de738 ML |
33140 | Enables support for the RH850 version of the V850 ABI. This is the |
33141 | default. With this version of the ABI the following rules apply: | |
33142 | ||
33143 | @itemize | |
33144 | @item | |
33145 | Integer sized structures and unions are returned via a memory pointer | |
33146 | rather than a register. | |
33147 | ||
33148 | @item | |
33149 | Large structures and unions (more than 8 bytes in size) are passed by | |
33150 | value. | |
33151 | ||
33152 | @item | |
33153 | Functions are aligned to 16-bit boundaries. | |
33154 | ||
33155 | @item | |
33156 | The @option{-m8byte-align} command-line option is supported. | |
33157 | ||
33158 | @item | |
33159 | The @option{-mdisable-callt} command-line option is enabled by | |
33160 | default. The @option{-mno-disable-callt} command-line option is not | |
33161 | supported. | |
33162 | @end itemize | |
33163 | ||
33164 | When this version of the ABI is enabled the C preprocessor symbol | |
33165 | @code{__V850_RH850_ABI__} is defined. | |
33166 | ||
d77de738 | 33167 | @opindex mgcc-abi |
ddf6fe37 | 33168 | @item -mgcc-abi |
d77de738 ML |
33169 | Enables support for the old GCC version of the V850 ABI. With this |
33170 | version of the ABI the following rules apply: | |
33171 | ||
33172 | @itemize | |
33173 | @item | |
33174 | Integer sized structures and unions are returned in register @code{r10}. | |
33175 | ||
33176 | @item | |
33177 | Large structures and unions (more than 8 bytes in size) are passed by | |
33178 | reference. | |
33179 | ||
33180 | @item | |
33181 | Functions are aligned to 32-bit boundaries, unless optimizing for | |
33182 | size. | |
33183 | ||
33184 | @item | |
33185 | The @option{-m8byte-align} command-line option is not supported. | |
33186 | ||
33187 | @item | |
33188 | The @option{-mdisable-callt} command-line option is supported but not | |
33189 | enabled by default. | |
33190 | @end itemize | |
33191 | ||
33192 | When this version of the ABI is enabled the C preprocessor symbol | |
33193 | @code{__V850_GCC_ABI__} is defined. | |
33194 | ||
d77de738 ML |
33195 | @opindex m8byte-align |
33196 | @opindex mno-8byte-align | |
ddf6fe37 AA |
33197 | @item -m8byte-align |
33198 | @itemx -mno-8byte-align | |
d77de738 ML |
33199 | Enables support for @code{double} and @code{long long} types to be |
33200 | aligned on 8-byte boundaries. The default is to restrict the | |
33201 | alignment of all objects to at most 4-bytes. When | |
33202 | @option{-m8byte-align} is in effect the C preprocessor symbol | |
33203 | @code{__V850_8BYTE_ALIGN__} is defined. | |
33204 | ||
d77de738 | 33205 | @opindex mbig-switch |
ddf6fe37 | 33206 | @item -mbig-switch |
d77de738 ML |
33207 | Generate code suitable for big switch tables. Use this option only if |
33208 | the assembler/linker complain about out of range branches within a switch | |
33209 | table. | |
33210 | ||
d77de738 | 33211 | @opindex mapp-regs |
ddf6fe37 | 33212 | @item -mapp-regs |
d77de738 ML |
33213 | This option causes r2 and r5 to be used in the code generated by |
33214 | the compiler. This setting is the default. | |
33215 | ||
d77de738 | 33216 | @opindex mno-app-regs |
ddf6fe37 | 33217 | @item -mno-app-regs |
d77de738 ML |
33218 | This option causes r2 and r5 to be treated as fixed registers. |
33219 | ||
33220 | @end table | |
33221 | ||
33222 | @node VAX Options | |
33223 | @subsection VAX Options | |
33224 | @cindex VAX options | |
33225 | ||
33226 | These @samp{-m} options are defined for the VAX: | |
33227 | ||
33228 | @table @gcctabopt | |
d77de738 | 33229 | @opindex munix |
ddf6fe37 | 33230 | @item -munix |
d77de738 ML |
33231 | Do not output certain jump instructions (@code{aobleq} and so on) |
33232 | that the Unix assembler for the VAX cannot handle across long | |
33233 | ranges. | |
33234 | ||
d77de738 | 33235 | @opindex mgnu |
ddf6fe37 | 33236 | @item -mgnu |
d77de738 ML |
33237 | Do output those jump instructions, on the assumption that the |
33238 | GNU assembler is being used. | |
33239 | ||
d77de738 | 33240 | @opindex mg |
ddf6fe37 | 33241 | @item -mg |
d77de738 ML |
33242 | Output code for G-format floating-point numbers instead of D-format. |
33243 | ||
d77de738 ML |
33244 | @opindex mlra |
33245 | @opindex mno-lra | |
ddf6fe37 AA |
33246 | @item -mlra |
33247 | @itemx -mno-lra | |
d77de738 ML |
33248 | Enable Local Register Allocation. This is still experimental for the VAX, |
33249 | so by default the compiler uses standard reload. | |
33250 | @end table | |
33251 | ||
33252 | @node Visium Options | |
33253 | @subsection Visium Options | |
33254 | @cindex Visium options | |
33255 | ||
33256 | @table @gcctabopt | |
33257 | ||
d77de738 | 33258 | @opindex mdebug |
ddf6fe37 | 33259 | @item -mdebug |
d77de738 ML |
33260 | A program which performs file I/O and is destined to run on an MCM target |
33261 | should be linked with this option. It causes the libraries libc.a and | |
33262 | libdebug.a to be linked. The program should be run on the target under | |
33263 | the control of the GDB remote debugging stub. | |
33264 | ||
d77de738 | 33265 | @opindex msim |
ddf6fe37 | 33266 | @item -msim |
d77de738 ML |
33267 | A program which performs file I/O and is destined to run on the simulator |
33268 | should be linked with option. This causes libraries libc.a and libsim.a to | |
33269 | be linked. | |
33270 | ||
d77de738 ML |
33271 | @opindex mfpu |
33272 | @opindex mhard-float | |
ddf6fe37 AA |
33273 | @item -mfpu |
33274 | @itemx -mhard-float | |
d77de738 ML |
33275 | Generate code containing floating-point instructions. This is the |
33276 | default. | |
33277 | ||
d77de738 ML |
33278 | @opindex mno-fpu |
33279 | @opindex msoft-float | |
ddf6fe37 AA |
33280 | @item -mno-fpu |
33281 | @itemx -msoft-float | |
d77de738 ML |
33282 | Generate code containing library calls for floating-point. |
33283 | ||
33284 | @option{-msoft-float} changes the calling convention in the output file; | |
33285 | therefore, it is only useful if you compile @emph{all} of a program with | |
33286 | this option. In particular, you need to compile @file{libgcc.a}, the | |
33287 | library that comes with GCC, with @option{-msoft-float} in order for | |
33288 | this to work. | |
33289 | ||
d77de738 | 33290 | @opindex mcpu |
ddf6fe37 | 33291 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
33292 | Set the instruction set, register set, and instruction scheduling parameters |
33293 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
33294 | @samp{mcm}, @samp{gr5} and @samp{gr6}. | |
33295 | ||
33296 | @samp{mcm} is a synonym of @samp{gr5} present for backward compatibility. | |
33297 | ||
33298 | By default (unless configured otherwise), GCC generates code for the GR5 | |
33299 | variant of the Visium architecture. | |
33300 | ||
33301 | With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium | |
33302 | architecture. The only difference from GR5 code is that the compiler will | |
33303 | generate block move instructions. | |
33304 | ||
d77de738 | 33305 | @opindex mtune |
ddf6fe37 | 33306 | @item -mtune=@var{cpu_type} |
d77de738 ML |
33307 | Set the instruction scheduling parameters for machine type @var{cpu_type}, |
33308 | but do not set the instruction set or register set that the option | |
33309 | @option{-mcpu=@var{cpu_type}} would. | |
33310 | ||
d77de738 | 33311 | @opindex msv-mode |
ddf6fe37 | 33312 | @item -msv-mode |
d77de738 ML |
33313 | Generate code for the supervisor mode, where there are no restrictions on |
33314 | the access to general registers. This is the default. | |
33315 | ||
d77de738 | 33316 | @opindex muser-mode |
ddf6fe37 | 33317 | @item -muser-mode |
d77de738 ML |
33318 | Generate code for the user mode, where the access to some general registers |
33319 | is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this | |
33320 | mode; on the GR6, only registers r29 to r31 are affected. | |
33321 | @end table | |
33322 | ||
33323 | @node VMS Options | |
33324 | @subsection VMS Options | |
33325 | ||
33326 | These @samp{-m} options are defined for the VMS implementations: | |
33327 | ||
33328 | @table @gcctabopt | |
d77de738 | 33329 | @opindex mvms-return-codes |
ddf6fe37 | 33330 | @item -mvms-return-codes |
d77de738 ML |
33331 | Return VMS condition codes from @code{main}. The default is to return POSIX-style |
33332 | condition (e.g.@: error) codes. | |
33333 | ||
d77de738 | 33334 | @opindex mdebug-main=@var{prefix} |
ddf6fe37 | 33335 | @item -mdebug-main=@var{prefix} |
d77de738 ML |
33336 | Flag the first routine whose name starts with @var{prefix} as the main |
33337 | routine for the debugger. | |
33338 | ||
d77de738 | 33339 | @opindex mmalloc64 |
ddf6fe37 | 33340 | @item -mmalloc64 |
d77de738 ML |
33341 | Default to 64-bit memory allocation routines. |
33342 | ||
d77de738 | 33343 | @opindex mpointer-size=@var{size} |
ddf6fe37 | 33344 | @item -mpointer-size=@var{size} |
d77de738 ML |
33345 | Set the default size of pointers. Possible options for @var{size} are |
33346 | @samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long} | |
33347 | for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers. | |
33348 | The later option disables @code{pragma pointer_size}. | |
33349 | @end table | |
33350 | ||
33351 | @node VxWorks Options | |
33352 | @subsection VxWorks Options | |
33353 | @cindex VxWorks Options | |
33354 | ||
33355 | The options in this section are defined for all VxWorks targets. | |
33356 | Options specific to the target hardware are listed with the other | |
33357 | options for that target. | |
33358 | ||
33359 | @table @gcctabopt | |
d77de738 | 33360 | @opindex mrtp |
ddf6fe37 | 33361 | @item -mrtp |
d77de738 ML |
33362 | GCC can generate code for both VxWorks kernels and real time processes |
33363 | (RTPs). This option switches from the former to the latter. It also | |
33364 | defines the preprocessor macro @code{__RTP__}. | |
33365 | ||
b6f4b000 AO |
33366 | @opindex msmp |
33367 | @item -msmp | |
33368 | Select SMP runtimes for linking. Not available on architectures other | |
33369 | than PowerPC, nor on VxWorks version 7 or later, in which the selection | |
33370 | is part of the VxWorks build configuration and the library paths are the | |
33371 | same for either choice. | |
33372 | ||
d77de738 | 33373 | @opindex non-static |
ddf6fe37 | 33374 | @item -non-static |
d77de738 ML |
33375 | Link an RTP executable against shared libraries rather than static |
33376 | libraries. The options @option{-static} and @option{-shared} can | |
33377 | also be used for RTPs (@pxref{Link Options}); @option{-static} | |
33378 | is the default. | |
33379 | ||
d77de738 ML |
33380 | @opindex Bstatic |
33381 | @opindex Bdynamic | |
ddf6fe37 AA |
33382 | @item -Bstatic |
33383 | @itemx -Bdynamic | |
d77de738 ML |
33384 | These options are passed down to the linker. They are defined for |
33385 | compatibility with Diab. | |
33386 | ||
d77de738 | 33387 | @opindex Xbind-lazy |
ddf6fe37 | 33388 | @item -Xbind-lazy |
d77de738 ML |
33389 | Enable lazy binding of function calls. This option is equivalent to |
33390 | @option{-Wl,-z,now} and is defined for compatibility with Diab. | |
33391 | ||
d77de738 | 33392 | @opindex Xbind-now |
ddf6fe37 | 33393 | @item -Xbind-now |
d77de738 ML |
33394 | Disable lazy binding of function calls. This option is the default and |
33395 | is defined for compatibility with Diab. | |
33396 | @end table | |
33397 | ||
33398 | @node x86 Options | |
33399 | @subsection x86 Options | |
33400 | @cindex x86 Options | |
33401 | ||
33402 | These @samp{-m} options are defined for the x86 family of computers. | |
33403 | ||
33404 | @table @gcctabopt | |
33405 | ||
d77de738 | 33406 | @opindex march |
ddf6fe37 | 33407 | @item -march=@var{cpu-type} |
d77de738 ML |
33408 | Generate instructions for the machine type @var{cpu-type}. In contrast to |
33409 | @option{-mtune=@var{cpu-type}}, which merely tunes the generated code | |
33410 | for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC | |
33411 | to generate code that may not run at all on processors other than the one | |
33412 | indicated. Specifying @option{-march=@var{cpu-type}} implies | |
33413 | @option{-mtune=@var{cpu-type}}, except where noted otherwise. | |
33414 | ||
33415 | The choices for @var{cpu-type} are: | |
33416 | ||
33417 | @table @samp | |
33418 | @item native | |
33419 | This selects the CPU to generate code for at compilation time by determining | |
33420 | the processor type of the compiling machine. Using @option{-march=native} | |
33421 | enables all instruction subsets supported by the local machine (hence | |
33422 | the result might not run on different machines). Using @option{-mtune=native} | |
33423 | produces code optimized for the local machine under the constraints | |
33424 | of the selected instruction set. | |
33425 | ||
33426 | @item x86-64 | |
33427 | A generic CPU with 64-bit extensions. | |
33428 | ||
33429 | @item x86-64-v2 | |
33430 | @itemx x86-64-v3 | |
33431 | @itemx x86-64-v4 | |
33432 | These choices for @var{cpu-type} select the corresponding | |
33433 | micro-architecture level from the x86-64 psABI. On ABIs other than | |
33434 | the x86-64 psABI they select the same CPU features as the x86-64 psABI | |
33435 | documents for the particular micro-architecture level. | |
33436 | ||
33437 | Since these @var{cpu-type} values do not have a corresponding | |
33438 | @option{-mtune} setting, using @option{-march} with these values enables | |
33439 | generic tuning. Specific tuning can be enabled using the | |
33440 | @option{-mtune=@var{other-cpu-type}} option with an appropriate | |
33441 | @var{other-cpu-type} value. | |
33442 | ||
33443 | @item i386 | |
33444 | Original Intel i386 CPU@. | |
33445 | ||
33446 | @item i486 | |
33447 | Intel i486 CPU@. (No scheduling is implemented for this chip.) | |
33448 | ||
33449 | @item i586 | |
33450 | @itemx pentium | |
33451 | Intel Pentium CPU with no MMX support. | |
33452 | ||
33453 | @item lakemont | |
33454 | Intel Lakemont MCU, based on Intel Pentium CPU. | |
33455 | ||
33456 | @item pentium-mmx | |
33457 | Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support. | |
33458 | ||
33459 | @item pentiumpro | |
33460 | Intel Pentium Pro CPU@. | |
33461 | ||
33462 | @item i686 | |
33463 | When used with @option{-march}, the Pentium Pro | |
33464 | instruction set is used, so the code runs on all i686 family chips. | |
33465 | When used with @option{-mtune}, it has the same meaning as @samp{generic}. | |
33466 | ||
33467 | @item pentium2 | |
33468 | Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction | |
33469 | set support. | |
33470 | ||
33471 | @item pentium3 | |
33472 | @itemx pentium3m | |
33473 | Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE | |
33474 | instruction set support. | |
33475 | ||
33476 | @item pentium-m | |
33477 | Intel Pentium M; low-power version of Intel Pentium III CPU | |
33478 | with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino | |
33479 | notebooks. | |
33480 | ||
33481 | @item pentium4 | |
33482 | @itemx pentium4m | |
33483 | Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support. | |
33484 | ||
33485 | @item prescott | |
33486 | Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR | |
33487 | instruction set support. | |
33488 | ||
33489 | @item nocona | |
33490 | Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE, | |
33491 | SSE2, SSE3 and FXSR instruction set support. | |
33492 | ||
33493 | @item core2 | |
33494 | Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16, | |
33495 | SAHF and FXSR instruction set support. | |
33496 | ||
33497 | @item nehalem | |
33498 | Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
33499 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support. | |
33500 | ||
33501 | @item westmere | |
33502 | Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
33503 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support. | |
33504 | ||
33505 | @item sandybridge | |
33506 | Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
33507 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set | |
33508 | support. | |
33509 | ||
33510 | @item ivybridge | |
33511 | Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
33512 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND | |
33513 | and F16C instruction set support. | |
33514 | ||
33515 | @item haswell | |
33516 | Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33517 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33518 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support. | |
33519 | ||
33520 | @item broadwell | |
33521 | Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33522 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33523 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW | |
33524 | instruction set support. | |
33525 | ||
33526 | @item skylake | |
33527 | Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33528 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33529 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
33530 | CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support. | |
33531 | ||
33532 | @item bonnell | |
33533 | Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3 | |
33534 | instruction set support. | |
33535 | ||
33536 | @item silvermont | |
33537 | Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33538 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND | |
33539 | instruction set support. | |
33540 | ||
33541 | @item goldmont | |
33542 | Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33543 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA, | |
33544 | RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction | |
33545 | set support. | |
33546 | ||
33547 | @item goldmont-plus | |
33548 | Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33549 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, | |
33550 | SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, | |
33551 | RDPID and SGX instruction set support. | |
33552 | ||
33553 | @item tremont | |
33554 | Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33555 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA, | |
33556 | RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID, | |
33557 | SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set | |
33558 | support. | |
33559 | ||
33560 | @item sierraforest | |
33561 | Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33562 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
33563 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
33564 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
33565 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
503643e8 LC |
33566 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set |
33567 | support. | |
d77de738 ML |
33568 | |
33569 | @item grandridge | |
33570 | Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33571 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
33572 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
33573 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
33574 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
9b4f535e HJ |
33575 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set |
33576 | support. | |
d77de738 | 33577 | |
7370c479 HJ |
33578 | @item clearwaterforest |
33579 | Intel Clearwater Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, | |
33580 | SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, | |
33581 | XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, | |
33582 | MOVDIRI, MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, | |
33583 | LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
faa0e82b HJ |
33584 | ENQCMD, UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, |
33585 | SHA512, SM3, SM4, USER_MSR and PREFETCHI instruction set support. | |
f019251a | 33586 | |
d77de738 ML |
33587 | @item knl |
33588 | Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33589 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33590 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33591 | AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support. | |
33592 | ||
33593 | @item knm | |
33594 | Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33595 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33596 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33597 | AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW, | |
33598 | AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support. | |
33599 | ||
33600 | @item skylake-avx512 | |
33601 | Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33602 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33603 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33604 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, | |
33605 | AVX512DQ and AVX512CD instruction set support. | |
33606 | ||
33607 | @item cannonlake | |
33608 | Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, | |
33609 | SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, | |
33610 | FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, | |
33611 | PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, | |
33612 | AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set | |
33613 | support. | |
33614 | ||
33615 | @item icelake-client | |
33616 | Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33617 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33618 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33619 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
33620 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 | |
33621 | , VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. | |
33622 | ||
33623 | @item icelake-server | |
33624 | Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33625 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33626 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33627 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
33628 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 | |
33629 | , VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB | |
33630 | instruction set support. | |
33631 | ||
33632 | @item cascadelake | |
33633 | Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33634 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33635 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
33636 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, | |
33637 | AVX512CD and AVX512VNNI instruction set support. | |
33638 | ||
33639 | @item cooperlake | |
33640 | Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33641 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33642 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
33643 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, | |
33644 | AVX512CD, AVX512VNNI and AVX512BF16 instruction set support. | |
33645 | ||
33646 | @item tigerlake | |
33647 | Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33648 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33649 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
33650 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD | |
33651 | PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
33652 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB, | |
33653 | AVX512VP2INTERSECT and KEYLOCKER instruction set support. | |
33654 | ||
33655 | @item sapphirerapids | |
33656 | Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33657 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33658 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33659 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
33660 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
33661 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
33662 | MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, | |
29ecb952 | 33663 | UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16 |
d77de738 ML |
33664 | instruction set support. |
33665 | ||
33666 | @item alderlake | |
33667 | Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33668 | SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES, | |
33669 | XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B, | |
33670 | CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU, | |
33671 | VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set | |
33672 | support. | |
33673 | ||
33674 | @item rocketlake | |
33675 | Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3 | |
33676 | , SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33677 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
33678 | CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD | |
33679 | PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
33680 | VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. | |
33681 | ||
33682 | @item graniterapids | |
33683 | Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33684 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33685 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33686 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
33687 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
33688 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
38daaaa9 HJ |
33689 | MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, |
33690 | UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16, AVX512BF16, AMX-FP16 | |
33691 | and PREFETCHI instruction set support. | |
d77de738 | 33692 | |
a0cb65d3 MZ |
33693 | @item graniterapids-d |
33694 | Intel graniterapids D CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33695 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33696 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33697 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
33698 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
33699 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
38daaaa9 HJ |
33700 | MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, |
33701 | UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16, AVX512BF16, AMX-FP16, | |
33702 | PREFETCHI and AMX-COMPLEX instruction set support. | |
a0cb65d3 | 33703 | |
faa0e82b HJ |
33704 | @item arrowlake |
33705 | Intel Arrow Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33706 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
33707 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
33708 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
33709 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
33710 | UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set | |
33711 | support. | |
33712 | ||
33713 | @item arrowlake-s | |
33714 | Intel Arrow Lake S CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33715 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
33716 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
33717 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
33718 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
33719 | UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, | |
33720 | SM3 and SM4 instruction set support. | |
33721 | ||
33722 | @item pantherlake | |
33723 | Intel Panther Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33724 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
33725 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
33726 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
33727 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
33728 | UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, | |
33729 | SM3, SM4 and PREFETCHI instruction set support. | |
33730 | ||
d77de738 ML |
33731 | @item k6 |
33732 | AMD K6 CPU with MMX instruction set support. | |
33733 | ||
33734 | @item k6-2 | |
33735 | @itemx k6-3 | |
33736 | Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support. | |
33737 | ||
33738 | @item athlon | |
33739 | @itemx athlon-tbird | |
33740 | AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions | |
33741 | support. | |
33742 | ||
33743 | @item athlon-4 | |
33744 | @itemx athlon-xp | |
33745 | @itemx athlon-mp | |
33746 | Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE | |
33747 | instruction set support. | |
33748 | ||
33749 | @item k8 | |
33750 | @itemx opteron | |
33751 | @itemx athlon64 | |
33752 | @itemx athlon-fx | |
33753 | Processors based on the AMD K8 core with x86-64 instruction set support, | |
33754 | including the AMD Opteron, Athlon 64, and Athlon 64 FX processors. | |
33755 | (This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit | |
33756 | instruction set extensions.) | |
33757 | ||
33758 | @item k8-sse3 | |
33759 | @itemx opteron-sse3 | |
33760 | @itemx athlon64-sse3 | |
33761 | Improved versions of AMD K8 cores with SSE3 instruction set support. | |
33762 | ||
33763 | @item amdfam10 | |
33764 | @itemx barcelona | |
33765 | CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This | |
33766 | supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit | |
33767 | instruction set extensions.) | |
33768 | ||
33769 | @item bdver1 | |
33770 | CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This | |
33771 | supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, | |
33772 | SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.) | |
33773 | ||
33774 | @item bdver2 | |
33775 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
33776 | supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, | |
33777 | SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set | |
33778 | extensions.) | |
33779 | ||
33780 | @item bdver3 | |
33781 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
33782 | supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES, | |
33783 | PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and | |
33784 | 64-bit instruction set extensions.) | |
33785 | ||
33786 | @item bdver4 | |
33787 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
33788 | supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP, | |
33789 | AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, | |
33790 | SSE4.2, ABM and 64-bit instruction set extensions.) | |
33791 | ||
33792 | @item znver1 | |
33793 | AMD Family 17h core based CPUs with x86-64 instruction set support. (This | |
33794 | supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX, | |
33795 | SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, | |
33796 | SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit | |
33797 | instruction set extensions.) | |
33798 | ||
33799 | @item znver2 | |
33800 | AMD Family 17h core based CPUs with x86-64 instruction set support. (This | |
33801 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
33802 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
33803 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
33804 | WBNOINVD, and 64-bit instruction set extensions.) | |
33805 | ||
33806 | @item znver3 | |
33807 | AMD Family 19h core based CPUs with x86-64 instruction set support. (This | |
33808 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
33809 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
33810 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
33811 | WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.) | |
33812 | ||
33813 | @item znver4 | |
33814 | AMD Family 19h core based CPUs with x86-64 instruction set support. (This | |
33815 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
33816 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
33817 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
33818 | WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD, | |
33819 | AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI, | |
33820 | AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.) | |
33821 | ||
33822 | @item btver1 | |
33823 | CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This | |
33824 | supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit | |
33825 | instruction set extensions.) | |
33826 | ||
33827 | @item btver2 | |
33828 | CPUs based on AMD Family 16h cores with x86-64 instruction set support. This | |
33829 | includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM, | |
33830 | SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions. | |
33831 | ||
33832 | @item winchip-c6 | |
33833 | IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction | |
33834 | set support. | |
33835 | ||
33836 | @item winchip2 | |
33837 | IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@: | |
33838 | instruction set support. | |
33839 | ||
33840 | @item c3 | |
33841 | VIA C3 CPU with MMX and 3DNow!@: instruction set support. | |
33842 | (No scheduling is implemented for this chip.) | |
33843 | ||
33844 | @item c3-2 | |
33845 | VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support. | |
33846 | (No scheduling is implemented for this chip.) | |
33847 | ||
33848 | @item c7 | |
33849 | VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support. | |
33850 | (No scheduling is implemented for this chip.) | |
33851 | ||
33852 | @item samuel-2 | |
33853 | VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support. | |
33854 | (No scheduling is implemented for this chip.) | |
33855 | ||
33856 | @item nehemiah | |
33857 | VIA Eden Nehemiah CPU with MMX and SSE instruction set support. | |
33858 | (No scheduling is implemented for this chip.) | |
33859 | ||
33860 | @item esther | |
33861 | VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support. | |
33862 | (No scheduling is implemented for this chip.) | |
33863 | ||
33864 | @item eden-x2 | |
33865 | VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support. | |
33866 | (No scheduling is implemented for this chip.) | |
33867 | ||
33868 | @item eden-x4 | |
33869 | VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, | |
33870 | AVX and AVX2 instruction set support. | |
33871 | (No scheduling is implemented for this chip.) | |
33872 | ||
33873 | @item nano | |
33874 | Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
33875 | instruction set support. | |
33876 | (No scheduling is implemented for this chip.) | |
33877 | ||
33878 | @item nano-1000 | |
33879 | VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
33880 | instruction set support. | |
33881 | (No scheduling is implemented for this chip.) | |
33882 | ||
33883 | @item nano-2000 | |
33884 | VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
33885 | instruction set support. | |
33886 | (No scheduling is implemented for this chip.) | |
33887 | ||
33888 | @item nano-3000 | |
33889 | VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
33890 | instruction set support. | |
33891 | (No scheduling is implemented for this chip.) | |
33892 | ||
33893 | @item nano-x2 | |
33894 | VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
33895 | instruction set support. | |
33896 | (No scheduling is implemented for this chip.) | |
33897 | ||
33898 | @item nano-x4 | |
33899 | VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
33900 | instruction set support. | |
33901 | (No scheduling is implemented for this chip.) | |
33902 | ||
33903 | @item lujiazui | |
33904 | ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, | |
33905 | SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16, | |
33906 | ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support. | |
33907 | ||
94c0b26f M |
33908 | @item yongfeng |
33909 | ZHAOXIN yongfeng CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, | |
33910 | SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16, | |
33911 | ABM, BMI, BMI2, F16C, FXSR, RDSEED, AVX2, FMA, SHA, LZCNT | |
33912 | instruction set support. | |
33913 | ||
d77de738 ML |
33914 | @item geode |
33915 | AMD Geode embedded processor with MMX and 3DNow!@: instruction set support. | |
33916 | @end table | |
33917 | ||
d77de738 | 33918 | @opindex mtune |
ddf6fe37 | 33919 | @item -mtune=@var{cpu-type} |
d77de738 ML |
33920 | Tune to @var{cpu-type} everything applicable about the generated code, except |
33921 | for the ABI and the set of available instructions. | |
33922 | While picking a specific @var{cpu-type} schedules things appropriately | |
33923 | for that particular chip, the compiler does not generate any code that | |
33924 | cannot run on the default machine type unless you use a | |
33925 | @option{-march=@var{cpu-type}} option. | |
33926 | For example, if GCC is configured for i686-pc-linux-gnu | |
33927 | then @option{-mtune=pentium4} generates code that is tuned for Pentium 4 | |
33928 | but still runs on i686 machines. | |
33929 | ||
33930 | The choices for @var{cpu-type} are the same as for @option{-march}. | |
33931 | In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}: | |
33932 | ||
33933 | @table @samp | |
33934 | @item generic | |
33935 | Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors. | |
33936 | If you know the CPU on which your code will run, then you should use | |
33937 | the corresponding @option{-mtune} or @option{-march} option instead of | |
33938 | @option{-mtune=generic}. But, if you do not know exactly what CPU users | |
33939 | of your application will have, then you should use this option. | |
33940 | ||
33941 | As new processors are deployed in the marketplace, the behavior of this | |
33942 | option will change. Therefore, if you upgrade to a newer version of | |
33943 | GCC, code generation controlled by this option will change to reflect | |
33944 | the processors | |
33945 | that are most common at the time that version of GCC is released. | |
33946 | ||
33947 | There is no @option{-march=generic} option because @option{-march} | |
33948 | indicates the instruction set the compiler can use, and there is no | |
33949 | generic instruction set applicable to all processors. In contrast, | |
33950 | @option{-mtune} indicates the processor (or, in this case, collection of | |
33951 | processors) for which the code is optimized. | |
33952 | ||
33953 | @item intel | |
33954 | Produce code optimized for the most current Intel processors, which are | |
33955 | Haswell and Silvermont for this version of GCC. If you know the CPU | |
33956 | on which your code will run, then you should use the corresponding | |
33957 | @option{-mtune} or @option{-march} option instead of @option{-mtune=intel}. | |
33958 | But, if you want your application performs better on both Haswell and | |
33959 | Silvermont, then you should use this option. | |
33960 | ||
33961 | As new Intel processors are deployed in the marketplace, the behavior of | |
33962 | this option will change. Therefore, if you upgrade to a newer version of | |
33963 | GCC, code generation controlled by this option will change to reflect | |
33964 | the most current Intel processors at the time that version of GCC is | |
33965 | released. | |
33966 | ||
33967 | There is no @option{-march=intel} option because @option{-march} indicates | |
33968 | the instruction set the compiler can use, and there is no common | |
33969 | instruction set applicable to all processors. In contrast, | |
33970 | @option{-mtune} indicates the processor (or, in this case, collection of | |
33971 | processors) for which the code is optimized. | |
33972 | @end table | |
33973 | ||
d77de738 | 33974 | @opindex mcpu |
ddf6fe37 | 33975 | @item -mcpu=@var{cpu-type} |
d77de738 ML |
33976 | A deprecated synonym for @option{-mtune}. |
33977 | ||
d77de738 | 33978 | @opindex mfpmath |
ddf6fe37 | 33979 | @item -mfpmath=@var{unit} |
d77de738 ML |
33980 | Generate floating-point arithmetic for selected unit @var{unit}. The choices |
33981 | for @var{unit} are: | |
33982 | ||
33983 | @table @samp | |
33984 | @item 387 | |
33985 | Use the standard 387 floating-point coprocessor present on the majority of chips and | |
33986 | emulated otherwise. Code compiled with this option runs almost everywhere. | |
33987 | The temporary results are computed in 80-bit precision instead of the precision | |
33988 | specified by the type, resulting in slightly different results compared to most | |
33989 | of other chips. See @option{-ffloat-store} for more detailed description. | |
33990 | ||
33991 | This is the default choice for non-Darwin x86-32 targets. | |
33992 | ||
33993 | @item sse | |
33994 | Use scalar floating-point instructions present in the SSE instruction set. | |
33995 | This instruction set is supported by Pentium III and newer chips, | |
33996 | and in the AMD line | |
33997 | by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE | |
33998 | instruction set supports only single-precision arithmetic, thus the double and | |
33999 | extended-precision arithmetic are still done using 387. A later version, present | |
34000 | only in Pentium 4 and AMD x86-64 chips, supports double-precision | |
34001 | arithmetic too. | |
34002 | ||
34003 | For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse} | |
34004 | or @option{-msse2} switches to enable SSE extensions and make this option | |
34005 | effective. For the x86-64 compiler, these extensions are enabled by default. | |
34006 | ||
34007 | The resulting code should be considerably faster in the majority of cases and avoid | |
34008 | the numerical instability problems of 387 code, but may break some existing | |
34009 | code that expects temporaries to be 80 bits. | |
34010 | ||
34011 | This is the default choice for the x86-64 compiler, Darwin x86-32 targets, | |
34012 | and the default choice for x86-32 targets with the SSE2 instruction set | |
34013 | when @option{-ffast-math} is enabled. | |
34014 | ||
34015 | @item sse,387 | |
34016 | @itemx sse+387 | |
34017 | @itemx both | |
34018 | Attempt to utilize both instruction sets at once. This effectively doubles the | |
34019 | amount of available registers, and on chips with separate execution units for | |
34020 | 387 and SSE the execution resources too. Use this option with care, as it is | |
34021 | still experimental, because the GCC register allocator does not model separate | |
34022 | functional units well, resulting in unstable performance. | |
34023 | @end table | |
34024 | ||
d77de738 | 34025 | @opindex masm=@var{dialect} |
ddf6fe37 | 34026 | @item -masm=@var{dialect} |
d77de738 ML |
34027 | Output assembly instructions using selected @var{dialect}. Also affects |
34028 | which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and | |
34029 | extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect | |
34030 | order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does | |
34031 | not support @samp{intel}. | |
34032 | ||
d77de738 ML |
34033 | @opindex mieee-fp |
34034 | @opindex mno-ieee-fp | |
ddf6fe37 AA |
34035 | @item -mieee-fp |
34036 | @itemx -mno-ieee-fp | |
d77de738 ML |
34037 | Control whether or not the compiler uses IEEE floating-point |
34038 | comparisons. These correctly handle the case where the result of a | |
34039 | comparison is unordered. | |
34040 | ||
30348d30 | 34041 | @opindex m80387 |
d77de738 | 34042 | @opindex mhard-float |
ddf6fe37 AA |
34043 | @item -m80387 |
34044 | @itemx -mhard-float | |
d77de738 ML |
34045 | Generate output containing 80387 instructions for floating point. |
34046 | ||
d77de738 ML |
34047 | @opindex no-80387 |
34048 | @opindex msoft-float | |
ddf6fe37 AA |
34049 | @item -mno-80387 |
34050 | @itemx -msoft-float | |
d77de738 ML |
34051 | Generate output containing library calls for floating point. |
34052 | ||
34053 | @strong{Warning:} the requisite libraries are not part of GCC@. | |
34054 | Normally the facilities of the machine's usual C compiler are used, but | |
34055 | this cannot be done directly in cross-compilation. You must make your | |
34056 | own arrangements to provide suitable library functions for | |
34057 | cross-compilation. | |
34058 | ||
34059 | On machines where a function returns floating-point results in the 80387 | |
34060 | register stack, some floating-point opcodes may be emitted even if | |
34061 | @option{-msoft-float} is used. | |
34062 | ||
d77de738 ML |
34063 | @opindex mno-fp-ret-in-387 |
34064 | @opindex mfp-ret-in-387 | |
ddf6fe37 | 34065 | @item -mno-fp-ret-in-387 |
d77de738 ML |
34066 | Do not use the FPU registers for return values of functions. |
34067 | ||
34068 | The usual calling convention has functions return values of types | |
34069 | @code{float} and @code{double} in an FPU register, even if there | |
34070 | is no FPU@. The idea is that the operating system should emulate | |
34071 | an FPU@. | |
34072 | ||
34073 | The option @option{-mno-fp-ret-in-387} causes such values to be returned | |
34074 | in ordinary CPU registers instead. | |
34075 | ||
d77de738 ML |
34076 | @opindex mno-fancy-math-387 |
34077 | @opindex mfancy-math-387 | |
ddf6fe37 | 34078 | @item -mno-fancy-math-387 |
d77de738 ML |
34079 | Some 387 emulators do not support the @code{sin}, @code{cos} and |
34080 | @code{sqrt} instructions for the 387. Specify this option to avoid | |
34081 | generating those instructions. | |
34082 | This option is overridden when @option{-march} | |
34083 | indicates that the target CPU always has an FPU and so the | |
34084 | instruction does not need emulation. These | |
34085 | instructions are not generated unless you also use the | |
34086 | @option{-funsafe-math-optimizations} switch. | |
34087 | ||
d77de738 ML |
34088 | @opindex malign-double |
34089 | @opindex mno-align-double | |
ddf6fe37 AA |
34090 | @item -malign-double |
34091 | @itemx -mno-align-double | |
d77de738 ML |
34092 | Control whether GCC aligns @code{double}, @code{long double}, and |
34093 | @code{long long} variables on a two-word boundary or a one-word | |
34094 | boundary. Aligning @code{double} variables on a two-word boundary | |
34095 | produces code that runs somewhat faster on a Pentium at the | |
34096 | expense of more memory. | |
34097 | ||
34098 | On x86-64, @option{-malign-double} is enabled by default. | |
34099 | ||
34100 | @strong{Warning:} if you use the @option{-malign-double} switch, | |
34101 | structures containing the above types are aligned differently than | |
34102 | the published application binary interface specifications for the x86-32 | |
34103 | and are not binary compatible with structures in code compiled | |
34104 | without that switch. | |
34105 | ||
d77de738 ML |
34106 | @opindex m96bit-long-double |
34107 | @opindex m128bit-long-double | |
ddf6fe37 AA |
34108 | @item -m96bit-long-double |
34109 | @itemx -m128bit-long-double | |
d77de738 ML |
34110 | These switches control the size of @code{long double} type. The x86-32 |
34111 | application binary interface specifies the size to be 96 bits, | |
34112 | so @option{-m96bit-long-double} is the default in 32-bit mode. | |
34113 | ||
34114 | Modern architectures (Pentium and newer) prefer @code{long double} | |
34115 | to be aligned to an 8- or 16-byte boundary. In arrays or structures | |
34116 | conforming to the ABI, this is not possible. So specifying | |
34117 | @option{-m128bit-long-double} aligns @code{long double} | |
34118 | to a 16-byte boundary by padding the @code{long double} with an additional | |
34119 | 32-bit zero. | |
34120 | ||
34121 | In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as | |
34122 | its ABI specifies that @code{long double} is aligned on 16-byte boundary. | |
34123 | ||
34124 | Notice that neither of these options enable any extra precision over the x87 | |
34125 | standard of 80 bits for a @code{long double}. | |
34126 | ||
34127 | @strong{Warning:} if you override the default value for your target ABI, this | |
34128 | changes the size of | |
34129 | structures and arrays containing @code{long double} variables, | |
34130 | as well as modifying the function calling convention for functions taking | |
34131 | @code{long double}. Hence they are not binary-compatible | |
34132 | with code compiled without that switch. | |
34133 | ||
d77de738 ML |
34134 | @opindex mlong-double-64 |
34135 | @opindex mlong-double-80 | |
34136 | @opindex mlong-double-128 | |
ddf6fe37 AA |
34137 | @item -mlong-double-64 |
34138 | @itemx -mlong-double-80 | |
34139 | @itemx -mlong-double-128 | |
d77de738 ML |
34140 | These switches control the size of @code{long double} type. A size |
34141 | of 64 bits makes the @code{long double} type equivalent to the @code{double} | |
34142 | type. This is the default for 32-bit Bionic C library. A size | |
34143 | of 128 bits makes the @code{long double} type equivalent to the | |
34144 | @code{__float128} type. This is the default for 64-bit Bionic C library. | |
34145 | ||
34146 | @strong{Warning:} if you override the default value for your target ABI, this | |
34147 | changes the size of | |
34148 | structures and arrays containing @code{long double} variables, | |
34149 | as well as modifying the function calling convention for functions taking | |
34150 | @code{long double}. Hence they are not binary-compatible | |
34151 | with code compiled without that switch. | |
34152 | ||
d77de738 | 34153 | @opindex malign-data |
ddf6fe37 | 34154 | @item -malign-data=@var{type} |
d77de738 ML |
34155 | Control how GCC aligns variables. Supported values for @var{type} are |
34156 | @samp{compat} uses increased alignment value compatible uses GCC 4.8 | |
34157 | and earlier, @samp{abi} uses alignment value as specified by the | |
34158 | psABI, and @samp{cacheline} uses increased alignment value to match | |
34159 | the cache line size. @samp{compat} is the default. | |
34160 | ||
d77de738 | 34161 | @opindex mlarge-data-threshold |
ddf6fe37 | 34162 | @item -mlarge-data-threshold=@var{threshold} |
1a64156c UB |
34163 | When @option{-mcmodel=medium} or @option{-mcmodel=large} is specified, data |
34164 | objects larger than @var{threshold} are placed in large data sections. The | |
34165 | default is 65535. | |
d77de738 | 34166 | |
d77de738 | 34167 | @opindex mrtd |
ddf6fe37 | 34168 | @item -mrtd |
d77de738 ML |
34169 | Use a different function-calling convention, in which functions that |
34170 | take a fixed number of arguments return with the @code{ret @var{num}} | |
34171 | instruction, which pops their arguments while returning. This saves one | |
34172 | instruction in the caller since there is no need to pop the arguments | |
34173 | there. | |
34174 | ||
34175 | You can specify that an individual function is called with this calling | |
34176 | sequence with the function attribute @code{stdcall}. You can also | |
34177 | override the @option{-mrtd} option by using the function attribute | |
34178 | @code{cdecl}. @xref{Function Attributes}. | |
34179 | ||
34180 | @strong{Warning:} this calling convention is incompatible with the one | |
34181 | normally used on Unix, so you cannot use it if you need to call | |
34182 | libraries compiled with the Unix compiler. | |
34183 | ||
34184 | Also, you must provide function prototypes for all functions that | |
34185 | take variable numbers of arguments (including @code{printf}); | |
34186 | otherwise incorrect code is generated for calls to those | |
34187 | functions. | |
34188 | ||
34189 | In addition, seriously incorrect code results if you call a | |
34190 | function with too many arguments. (Normally, extra arguments are | |
34191 | harmlessly ignored.) | |
34192 | ||
d77de738 | 34193 | @opindex mregparm |
ddf6fe37 | 34194 | @item -mregparm=@var{num} |
d77de738 ML |
34195 | Control how many registers are used to pass integer arguments. By |
34196 | default, no registers are used to pass arguments, and at most 3 | |
34197 | registers can be used. You can control this behavior for a specific | |
34198 | function by using the function attribute @code{regparm}. | |
34199 | @xref{Function Attributes}. | |
34200 | ||
34201 | @strong{Warning:} if you use this switch, and | |
34202 | @var{num} is nonzero, then you must build all modules with the same | |
34203 | value, including any libraries. This includes the system libraries and | |
34204 | startup modules. | |
34205 | ||
d77de738 | 34206 | @opindex msseregparm |
ddf6fe37 | 34207 | @item -msseregparm |
d77de738 ML |
34208 | Use SSE register passing conventions for float and double arguments |
34209 | and return values. You can control this behavior for a specific | |
34210 | function by using the function attribute @code{sseregparm}. | |
34211 | @xref{Function Attributes}. | |
34212 | ||
34213 | @strong{Warning:} if you use this switch then you must build all | |
34214 | modules with the same value, including any libraries. This includes | |
34215 | the system libraries and startup modules. | |
34216 | ||
d77de738 | 34217 | @opindex mvect8-ret-in-mem |
ddf6fe37 | 34218 | @item -mvect8-ret-in-mem |
d77de738 ML |
34219 | Return 8-byte vectors in memory instead of MMX registers. This is the |
34220 | default on VxWorks to match the ABI of the Sun Studio compilers until | |
34221 | version 12. @emph{Only} use this option if you need to remain | |
34222 | compatible with existing code produced by those previous compiler | |
34223 | versions or older versions of GCC@. | |
34224 | ||
d77de738 ML |
34225 | @opindex mpc32 |
34226 | @opindex mpc64 | |
34227 | @opindex mpc80 | |
ddf6fe37 AA |
34228 | @item -mpc32 |
34229 | @itemx -mpc64 | |
34230 | @itemx -mpc80 | |
d77de738 ML |
34231 | |
34232 | Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32} | |
34233 | is specified, the significands of results of floating-point operations are | |
34234 | rounded to 24 bits (single precision); @option{-mpc64} rounds the | |
34235 | significands of results of floating-point operations to 53 bits (double | |
34236 | precision) and @option{-mpc80} rounds the significands of results of | |
34237 | floating-point operations to 64 bits (extended double precision), which is | |
34238 | the default. When this option is used, floating-point operations in higher | |
34239 | precisions are not available to the programmer without setting the FPU | |
34240 | control word explicitly. | |
34241 | ||
34242 | Setting the rounding of floating-point operations to less than the default | |
34243 | 80 bits can speed some programs by 2% or more. Note that some mathematical | |
34244 | libraries assume that extended-precision (80-bit) floating-point operations | |
34245 | are enabled by default; routines in such libraries could suffer significant | |
34246 | loss of accuracy, typically through so-called ``catastrophic cancellation'', | |
34247 | when this option is used to set the precision to less than extended precision. | |
34248 | ||
e54375d8 | 34249 | @opindex mdaz-ftz |
ddf6fe37 | 34250 | @item -mdaz-ftz |
e54375d8 | 34251 | |
34252 | The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register | |
34253 | are used to control floating-point calculations.SSE and AVX instructions | |
34254 | including scalar and vector instructions could benefit from enabling the FTZ | |
34255 | and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags | |
34256 | when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz} | |
34257 | will set FTZ/DAZ flags even with @option{-shared}. | |
34258 | ||
d77de738 | 34259 | @opindex mstackrealign |
ddf6fe37 | 34260 | @item -mstackrealign |
d77de738 ML |
34261 | Realign the stack at entry. On the x86, the @option{-mstackrealign} |
34262 | option generates an alternate prologue and epilogue that realigns the | |
34263 | run-time stack if necessary. This supports mixing legacy codes that keep | |
34264 | 4-byte stack alignment with modern codes that keep 16-byte stack alignment for | |
34265 | SSE compatibility. See also the attribute @code{force_align_arg_pointer}, | |
34266 | applicable to individual functions. | |
34267 | ||
d77de738 | 34268 | @opindex mpreferred-stack-boundary |
ddf6fe37 | 34269 | @item -mpreferred-stack-boundary=@var{num} |
d77de738 ML |
34270 | Attempt to keep the stack boundary aligned to a 2 raised to @var{num} |
34271 | byte boundary. If @option{-mpreferred-stack-boundary} is not specified, | |
34272 | the default is 4 (16 bytes or 128 bits). | |
34273 | ||
34274 | @strong{Warning:} When generating code for the x86-64 architecture with | |
34275 | SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be | |
34276 | used to keep the stack boundary aligned to 8 byte boundary. Since | |
34277 | x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and | |
34278 | intended to be used in controlled environment where stack space is | |
34279 | important limitation. This option leads to wrong code when functions | |
34280 | compiled with 16 byte stack alignment (such as functions from a standard | |
34281 | library) are called with misaligned stack. In this case, SSE | |
34282 | instructions may lead to misaligned memory access traps. In addition, | |
34283 | variable arguments are handled incorrectly for 16 byte aligned | |
34284 | objects (including x87 long double and __int128), leading to wrong | |
34285 | results. You must build all modules with | |
34286 | @option{-mpreferred-stack-boundary=3}, including any libraries. This | |
34287 | includes the system libraries and startup modules. | |
34288 | ||
d77de738 | 34289 | @opindex mincoming-stack-boundary |
ddf6fe37 | 34290 | @item -mincoming-stack-boundary=@var{num} |
d77de738 ML |
34291 | Assume the incoming stack is aligned to a 2 raised to @var{num} byte |
34292 | boundary. If @option{-mincoming-stack-boundary} is not specified, | |
34293 | the one specified by @option{-mpreferred-stack-boundary} is used. | |
34294 | ||
34295 | On Pentium and Pentium Pro, @code{double} and @code{long double} values | |
34296 | should be aligned to an 8-byte boundary (see @option{-malign-double}) or | |
34297 | suffer significant run time performance penalties. On Pentium III, the | |
34298 | Streaming SIMD Extension (SSE) data type @code{__m128} may not work | |
34299 | properly if it is not 16-byte aligned. | |
34300 | ||
34301 | To ensure proper alignment of this values on the stack, the stack boundary | |
34302 | must be as aligned as that required by any value stored on the stack. | |
34303 | Further, every function must be generated such that it keeps the stack | |
34304 | aligned. Thus calling a function compiled with a higher preferred | |
34305 | stack boundary from a function compiled with a lower preferred stack | |
34306 | boundary most likely misaligns the stack. It is recommended that | |
34307 | libraries that use callbacks always use the default setting. | |
34308 | ||
34309 | This extra alignment does consume extra stack space, and generally | |
34310 | increases code size. Code that is sensitive to stack space usage, such | |
34311 | as embedded systems and operating system kernels, may want to reduce the | |
34312 | preferred alignment to @option{-mpreferred-stack-boundary=2}. | |
34313 | ||
34314 | @need 200 | |
d77de738 | 34315 | @opindex mmmx |
ddf6fe37 | 34316 | @item -mmmx |
d77de738 | 34317 | @need 200 |
d77de738 | 34318 | @opindex msse |
ddf6fe37 | 34319 | @itemx -msse |
d77de738 | 34320 | @need 200 |
d77de738 | 34321 | @opindex msse2 |
ddf6fe37 | 34322 | @itemx -msse2 |
d77de738 | 34323 | @need 200 |
d77de738 | 34324 | @opindex msse3 |
ddf6fe37 | 34325 | @itemx -msse3 |
d77de738 | 34326 | @need 200 |
d77de738 | 34327 | @opindex mssse3 |
ddf6fe37 | 34328 | @itemx -mssse3 |
d77de738 | 34329 | @need 200 |
d77de738 | 34330 | @opindex msse4 |
ddf6fe37 | 34331 | @itemx -msse4 |
d77de738 | 34332 | @need 200 |
d77de738 | 34333 | @opindex msse4a |
ddf6fe37 | 34334 | @itemx -msse4a |
d77de738 | 34335 | @need 200 |
d77de738 | 34336 | @opindex msse4.1 |
ddf6fe37 | 34337 | @itemx -msse4.1 |
d77de738 | 34338 | @need 200 |
d77de738 | 34339 | @opindex msse4.2 |
ddf6fe37 | 34340 | @itemx -msse4.2 |
d77de738 | 34341 | @need 200 |
d77de738 | 34342 | @opindex mavx |
ddf6fe37 | 34343 | @itemx -mavx |
d77de738 | 34344 | @need 200 |
d77de738 | 34345 | @opindex mavx2 |
ddf6fe37 | 34346 | @itemx -mavx2 |
d77de738 | 34347 | @need 200 |
d77de738 | 34348 | @opindex mavx512f |
ddf6fe37 | 34349 | @itemx -mavx512f |
d77de738 | 34350 | @need 200 |
d77de738 | 34351 | @opindex mavx512pf |
ddf6fe37 | 34352 | @itemx -mavx512pf |
d77de738 | 34353 | @need 200 |
d77de738 | 34354 | @opindex mavx512er |
ddf6fe37 | 34355 | @itemx -mavx512er |
d77de738 | 34356 | @need 200 |
d77de738 | 34357 | @opindex mavx512cd |
ddf6fe37 | 34358 | @itemx -mavx512cd |
d77de738 | 34359 | @need 200 |
d77de738 | 34360 | @opindex mavx512vl |
ddf6fe37 | 34361 | @itemx -mavx512vl |
d77de738 | 34362 | @need 200 |
d77de738 | 34363 | @opindex mavx512bw |
ddf6fe37 | 34364 | @itemx -mavx512bw |
d77de738 | 34365 | @need 200 |
d77de738 | 34366 | @opindex mavx512dq |
ddf6fe37 | 34367 | @itemx -mavx512dq |
d77de738 | 34368 | @need 200 |
d77de738 | 34369 | @opindex mavx512ifma |
ddf6fe37 | 34370 | @itemx -mavx512ifma |
d77de738 | 34371 | @need 200 |
d77de738 | 34372 | @opindex mavx512vbmi |
ddf6fe37 | 34373 | @itemx -mavx512vbmi |
d77de738 | 34374 | @need 200 |
d77de738 | 34375 | @opindex msha |
ddf6fe37 | 34376 | @itemx -msha |
d77de738 | 34377 | @need 200 |
d77de738 | 34378 | @opindex maes |
ddf6fe37 | 34379 | @itemx -maes |
d77de738 | 34380 | @need 200 |
d77de738 | 34381 | @opindex mpclmul |
ddf6fe37 | 34382 | @itemx -mpclmul |
d77de738 | 34383 | @need 200 |
d77de738 | 34384 | @opindex mclflushopt |
ddf6fe37 | 34385 | @itemx -mclflushopt |
d77de738 | 34386 | @need 200 |
d77de738 | 34387 | @opindex mclwb |
ddf6fe37 | 34388 | @itemx -mclwb |
d77de738 | 34389 | @need 200 |
d77de738 | 34390 | @opindex mfsgsbase |
ddf6fe37 | 34391 | @itemx -mfsgsbase |
d77de738 | 34392 | @need 200 |
d77de738 | 34393 | @opindex mptwrite |
ddf6fe37 | 34394 | @itemx -mptwrite |
d77de738 | 34395 | @need 200 |
d77de738 | 34396 | @opindex mrdrnd |
ddf6fe37 | 34397 | @itemx -mrdrnd |
d77de738 | 34398 | @need 200 |
d77de738 | 34399 | @opindex mf16c |
ddf6fe37 | 34400 | @itemx -mf16c |
d77de738 | 34401 | @need 200 |
d77de738 | 34402 | @opindex mfma |
ddf6fe37 | 34403 | @itemx -mfma |
d77de738 | 34404 | @need 200 |
d77de738 | 34405 | @opindex mpconfig |
ddf6fe37 | 34406 | @itemx -mpconfig |
d77de738 | 34407 | @need 200 |
d77de738 | 34408 | @opindex mwbnoinvd |
ddf6fe37 | 34409 | @itemx -mwbnoinvd |
d77de738 | 34410 | @need 200 |
d77de738 | 34411 | @opindex mfma4 |
ddf6fe37 | 34412 | @itemx -mfma4 |
d77de738 | 34413 | @need 200 |
d77de738 | 34414 | @opindex mprfchw |
ddf6fe37 | 34415 | @itemx -mprfchw |
d77de738 | 34416 | @need 200 |
d77de738 | 34417 | @opindex mrdpid |
ddf6fe37 | 34418 | @itemx -mrdpid |
d77de738 | 34419 | @need 200 |
d77de738 | 34420 | @opindex mprefetchwt1 |
ddf6fe37 | 34421 | @itemx -mprefetchwt1 |
d77de738 | 34422 | @need 200 |
d77de738 | 34423 | @opindex mrdseed |
ddf6fe37 | 34424 | @itemx -mrdseed |
d77de738 | 34425 | @need 200 |
d77de738 | 34426 | @opindex msgx |
ddf6fe37 | 34427 | @itemx -msgx |
d77de738 | 34428 | @need 200 |
d77de738 | 34429 | @opindex mxop |
ddf6fe37 | 34430 | @itemx -mxop |
d77de738 | 34431 | @need 200 |
d77de738 | 34432 | @opindex mlwp |
ddf6fe37 | 34433 | @itemx -mlwp |
d77de738 | 34434 | @need 200 |
d77de738 | 34435 | @opindex m3dnow |
ddf6fe37 | 34436 | @itemx -m3dnow |
d77de738 | 34437 | @need 200 |
d77de738 | 34438 | @opindex m3dnowa |
ddf6fe37 | 34439 | @itemx -m3dnowa |
d77de738 | 34440 | @need 200 |
d77de738 | 34441 | @opindex mpopcnt |
ddf6fe37 | 34442 | @itemx -mpopcnt |
d77de738 | 34443 | @need 200 |
d77de738 | 34444 | @opindex mabm |
ddf6fe37 | 34445 | @itemx -mabm |
d77de738 | 34446 | @need 200 |
d77de738 | 34447 | @opindex madx |
ddf6fe37 | 34448 | @itemx -madx |
d77de738 | 34449 | @need 200 |
d77de738 | 34450 | @opindex mbmi |
ddf6fe37 | 34451 | @itemx -mbmi |
d77de738 | 34452 | @need 200 |
d77de738 | 34453 | @opindex mbmi2 |
ddf6fe37 | 34454 | @itemx -mbmi2 |
d77de738 | 34455 | @need 200 |
d77de738 | 34456 | @opindex mlzcnt |
ddf6fe37 | 34457 | @itemx -mlzcnt |
d77de738 | 34458 | @need 200 |
d77de738 | 34459 | @opindex mfxsr |
ddf6fe37 | 34460 | @itemx -mfxsr |
d77de738 | 34461 | @need 200 |
d77de738 | 34462 | @opindex mxsave |
ddf6fe37 | 34463 | @itemx -mxsave |
d77de738 | 34464 | @need 200 |
d77de738 | 34465 | @opindex mxsaveopt |
ddf6fe37 | 34466 | @itemx -mxsaveopt |
d77de738 | 34467 | @need 200 |
d77de738 | 34468 | @opindex mxsavec |
ddf6fe37 | 34469 | @itemx -mxsavec |
d77de738 | 34470 | @need 200 |
d77de738 | 34471 | @opindex mxsaves |
ddf6fe37 | 34472 | @itemx -mxsaves |
d77de738 | 34473 | @need 200 |
d77de738 | 34474 | @opindex mrtm |
ddf6fe37 | 34475 | @itemx -mrtm |
d77de738 | 34476 | @need 200 |
d77de738 | 34477 | @opindex mhle |
ddf6fe37 | 34478 | @itemx -mhle |
d77de738 | 34479 | @need 200 |
d77de738 | 34480 | @opindex mtbm |
ddf6fe37 | 34481 | @itemx -mtbm |
d77de738 | 34482 | @need 200 |
d77de738 | 34483 | @opindex mmwaitx |
ddf6fe37 | 34484 | @itemx -mmwaitx |
d77de738 | 34485 | @need 200 |
d77de738 | 34486 | @opindex mclzero |
ddf6fe37 | 34487 | @itemx -mclzero |
d77de738 | 34488 | @need 200 |
d77de738 | 34489 | @opindex mpku |
ddf6fe37 | 34490 | @itemx -mpku |
d77de738 | 34491 | @need 200 |
d77de738 | 34492 | @opindex mavx512vbmi2 |
ddf6fe37 | 34493 | @itemx -mavx512vbmi2 |
d77de738 | 34494 | @need 200 |
d77de738 | 34495 | @opindex mavx512bf16 |
ddf6fe37 | 34496 | @itemx -mavx512bf16 |
d77de738 | 34497 | @need 200 |
d77de738 | 34498 | @opindex mavx512fp16 |
ddf6fe37 | 34499 | @itemx -mavx512fp16 |
d77de738 | 34500 | @need 200 |
d77de738 | 34501 | @opindex mgfni |
ddf6fe37 | 34502 | @itemx -mgfni |
d77de738 | 34503 | @need 200 |
d77de738 | 34504 | @opindex mvaes |
ddf6fe37 | 34505 | @itemx -mvaes |
d77de738 | 34506 | @need 200 |
d77de738 | 34507 | @opindex mwaitpkg |
ddf6fe37 | 34508 | @itemx -mwaitpkg |
d77de738 | 34509 | @need 200 |
d77de738 | 34510 | @opindex mvpclmulqdq |
ddf6fe37 | 34511 | @itemx -mvpclmulqdq |
d77de738 | 34512 | @need 200 |
d77de738 | 34513 | @opindex mavx512bitalg |
ddf6fe37 | 34514 | @itemx -mavx512bitalg |
d77de738 | 34515 | @need 200 |
d77de738 | 34516 | @opindex mmovdiri |
ddf6fe37 | 34517 | @itemx -mmovdiri |
d77de738 | 34518 | @need 200 |
d77de738 | 34519 | @opindex mmovdir64b |
ddf6fe37 | 34520 | @itemx -mmovdir64b |
d77de738 | 34521 | @need 200 |
d77de738 | 34522 | @opindex menqcmd |
d77de738 | 34523 | @opindex muintr |
ddf6fe37 AA |
34524 | @itemx -menqcmd |
34525 | @itemx -muintr | |
d77de738 | 34526 | @need 200 |
d77de738 | 34527 | @opindex mtsxldtrk |
ddf6fe37 | 34528 | @itemx -mtsxldtrk |
d77de738 | 34529 | @need 200 |
d77de738 | 34530 | @opindex mavx512vpopcntdq |
ddf6fe37 | 34531 | @itemx -mavx512vpopcntdq |
d77de738 | 34532 | @need 200 |
d77de738 | 34533 | @opindex mavx512vp2intersect |
ddf6fe37 | 34534 | @itemx -mavx512vp2intersect |
d77de738 | 34535 | @need 200 |
d77de738 | 34536 | @opindex mavx5124fmaps |
ddf6fe37 | 34537 | @itemx -mavx5124fmaps |
d77de738 | 34538 | @need 200 |
d77de738 | 34539 | @opindex mavx512vnni |
ddf6fe37 | 34540 | @itemx -mavx512vnni |
d77de738 | 34541 | @need 200 |
d77de738 | 34542 | @opindex mavxvnni |
ddf6fe37 | 34543 | @itemx -mavxvnni |
d77de738 | 34544 | @need 200 |
d77de738 | 34545 | @opindex mavx5124vnniw |
ddf6fe37 | 34546 | @itemx -mavx5124vnniw |
d77de738 | 34547 | @need 200 |
d77de738 | 34548 | @opindex mcldemote |
ddf6fe37 | 34549 | @itemx -mcldemote |
d77de738 | 34550 | @need 200 |
d77de738 | 34551 | @opindex mserialize |
ddf6fe37 | 34552 | @itemx -mserialize |
d77de738 | 34553 | @need 200 |
d77de738 | 34554 | @opindex mamx-tile |
ddf6fe37 | 34555 | @itemx -mamx-tile |
d77de738 | 34556 | @need 200 |
d77de738 | 34557 | @opindex mamx-int8 |
ddf6fe37 | 34558 | @itemx -mamx-int8 |
d77de738 | 34559 | @need 200 |
d77de738 | 34560 | @opindex mamx-bf16 |
ddf6fe37 | 34561 | @itemx -mamx-bf16 |
d77de738 | 34562 | @need 200 |
d77de738 | 34563 | @opindex mhreset |
d77de738 | 34564 | @opindex mkl |
ddf6fe37 AA |
34565 | @itemx -mhreset |
34566 | @itemx -mkl | |
d77de738 | 34567 | @need 200 |
d77de738 | 34568 | @opindex mwidekl |
ddf6fe37 | 34569 | @itemx -mwidekl |
d77de738 | 34570 | @need 200 |
d77de738 | 34571 | @opindex mavxifma |
ddf6fe37 | 34572 | @itemx -mavxifma |
d77de738 | 34573 | @need 200 |
d77de738 | 34574 | @opindex mavxvnniint8 |
ddf6fe37 | 34575 | @itemx -mavxvnniint8 |
d77de738 | 34576 | @need 200 |
d77de738 | 34577 | @opindex mavxneconvert |
ddf6fe37 | 34578 | @itemx -mavxneconvert |
d77de738 | 34579 | @need 200 |
d77de738 | 34580 | @opindex mcmpccxadd |
ddf6fe37 | 34581 | @itemx -mcmpccxadd |
d77de738 | 34582 | @need 200 |
d77de738 | 34583 | @opindex mamx-fp16 |
ddf6fe37 | 34584 | @itemx -mamx-fp16 |
d77de738 | 34585 | @need 200 |
d77de738 | 34586 | @opindex mprefetchi |
ddf6fe37 | 34587 | @itemx -mprefetchi |
d77de738 | 34588 | @need 200 |
d77de738 | 34589 | @opindex mraoint |
ddf6fe37 | 34590 | @itemx -mraoint |
efa6a82b HJ |
34591 | @need 200 |
34592 | @opindex mamx-complex | |
34593 | @itemx -mamx-complex | |
1dbc1081 KL |
34594 | @need 200 |
34595 | @opindex mavxvnniint16 | |
34596 | @itemx -mavxvnniint16 | |
8643bcba HJ |
34597 | @need 200 |
34598 | @opindex msm3 | |
34599 | @itemx -msm3 | |
86446132 HJ |
34600 | @need 200 |
34601 | @opindex msha512 | |
34602 | @itemx -msha512 | |
37bdeb8f HJ |
34603 | @need 200 |
34604 | @opindex msm4 | |
34605 | @itemx -msm4 | |
e686416b KL |
34606 | @need 200 |
34607 | @opindex mapxf | |
34608 | @itemx -mapxf | |
5fbd91b1 HL |
34609 | @need 200 |
34610 | @opindex musermsr | |
34611 | @itemx -musermsr | |
2f8f7ee2 HJ |
34612 | @need 200 |
34613 | @opindex mavx10.1 | |
34614 | @itemx -mavx10.1 | |
34615 | @need 200 | |
34616 | @opindex mavx10.1-256 | |
34617 | @itemx -mavx10.1-256 | |
34618 | @need 200 | |
34619 | @opindex mavx10.1-512 | |
34620 | @itemx -mavx10.1-512 | |
d77de738 | 34621 | These switches enable the use of instructions in the MMX, SSE, |
d77de738 ML |
34622 | AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA, |
34623 | AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG, | |
34624 | WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP, | |
34625 | 3DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE, | |
34626 | XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2, | |
34627 | GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16, | |
34628 | ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE, | |
29ecb952 | 34629 | UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16, |
efa6a82b | 34630 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT, |
2f8f7ee2 HJ |
34631 | AMX-COMPLEX, AVXVNNIINT16, SM3, SHA512, SM4, APX_F, USER_MSR, AVX10.1 or |
34632 | CLDEMOTE extended instruction sets. Each has a corresponding @option{-mno-} | |
34633 | option to disable use of these instructions. | |
d77de738 ML |
34634 | |
34635 | These extensions are also available as built-in functions: see | |
34636 | @ref{x86 Built-in Functions}, for details of the functions enabled and | |
34637 | disabled by these switches. | |
34638 | ||
34639 | To generate SSE/SSE2 instructions automatically from floating-point | |
34640 | code (as opposed to 387 instructions), see @option{-mfpmath=sse}. | |
34641 | ||
34642 | GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it | |
34643 | generates new AVX instructions or AVX equivalence for all SSEx instructions | |
34644 | when needed. | |
34645 | ||
34646 | These options enable GCC to use these extended instructions in | |
34647 | generated code, even without @option{-mfpmath=sse}. Applications that | |
34648 | perform run-time CPU detection must compile separate files for each | |
34649 | supported architecture, using the appropriate flags. In particular, | |
34650 | the file containing the CPU detection code should be compiled without | |
34651 | these options. | |
34652 | ||
d77de738 | 34653 | @opindex mdump-tune-features |
ddf6fe37 | 34654 | @item -mdump-tune-features |
d77de738 ML |
34655 | This option instructs GCC to dump the names of the x86 performance |
34656 | tuning features and default settings. The names can be used in | |
34657 | @option{-mtune-ctrl=@var{feature-list}}. | |
34658 | ||
d77de738 | 34659 | @opindex mtune-ctrl=@var{feature-list} |
ddf6fe37 | 34660 | @item -mtune-ctrl=@var{feature-list} |
d77de738 ML |
34661 | This option is used to do fine grain control of x86 code generation features. |
34662 | @var{feature-list} is a comma separated list of @var{feature} names. See also | |
34663 | @option{-mdump-tune-features}. When specified, the @var{feature} is turned | |
34664 | on if it is not preceded with @samp{^}, otherwise, it is turned off. | |
34665 | @option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC | |
34666 | developers. Using it may lead to code paths not covered by testing and can | |
34667 | potentially result in compiler ICEs or runtime errors. | |
34668 | ||
d77de738 | 34669 | @opindex mno-default |
ddf6fe37 | 34670 | @item -mno-default |
d77de738 ML |
34671 | This option instructs GCC to turn off all tunable features. See also |
34672 | @option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}. | |
34673 | ||
d77de738 | 34674 | @opindex mcld |
ddf6fe37 | 34675 | @item -mcld |
d77de738 ML |
34676 | This option instructs GCC to emit a @code{cld} instruction in the prologue |
34677 | of functions that use string instructions. String instructions depend on | |
34678 | the DF flag to select between autoincrement or autodecrement mode. While the | |
34679 | ABI specifies the DF flag to be cleared on function entry, some operating | |
34680 | systems violate this specification by not clearing the DF flag in their | |
34681 | exception dispatchers. The exception handler can be invoked with the DF flag | |
34682 | set, which leads to wrong direction mode when string instructions are used. | |
34683 | This option can be enabled by default on 32-bit x86 targets by configuring | |
34684 | GCC with the @option{--enable-cld} configure option. Generation of @code{cld} | |
34685 | instructions can be suppressed with the @option{-mno-cld} compiler option | |
34686 | in this case. | |
34687 | ||
d77de738 | 34688 | @opindex mvzeroupper |
ddf6fe37 | 34689 | @item -mvzeroupper |
d77de738 ML |
34690 | This option instructs GCC to emit a @code{vzeroupper} instruction |
34691 | before a transfer of control flow out of the function to minimize | |
34692 | the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper} | |
34693 | intrinsics. | |
34694 | ||
d77de738 | 34695 | @opindex mprefer-avx128 |
ddf6fe37 | 34696 | @item -mprefer-avx128 |
d77de738 ML |
34697 | This option instructs GCC to use 128-bit AVX instructions instead of |
34698 | 256-bit AVX instructions in the auto-vectorizer. | |
34699 | ||
d77de738 | 34700 | @opindex mprefer-vector-width |
ddf6fe37 | 34701 | @item -mprefer-vector-width=@var{opt} |
d77de738 ML |
34702 | This option instructs GCC to use @var{opt}-bit vector width in instructions |
34703 | instead of default on the selected platform. | |
34704 | ||
ad5b757d UB |
34705 | @opindex mpartial-vector-fp-math |
34706 | @item -mpartial-vector-fp-math | |
34707 | This option enables GCC to generate floating-point operations that might | |
34708 | affect the set of floating-point status flags on partial vectors, where | |
34709 | vector elements reside in the low part of the 128-bit SSE register. Unless | |
34710 | @option{-fno-trapping-math} is specified, the compiler guarantees correct | |
34711 | behavior by sanitizing all input operands to have zeroes in the unused | |
34712 | upper part of the vector register. Note that by using built-in functions | |
34713 | or inline assembly with partial vector arguments, NaNs, denormal or invalid | |
34714 | values can leak into the upper part of the vector, causing possible | |
34715 | performance issues when @option{-fno-trapping-math} is in effect. These | |
34716 | issues can be mitigated by manually sanitizing the upper part of the partial | |
34717 | vector argument register or by using @option{-mdaz-ftz} to set | |
34718 | denormals-are-zero (DAZ) flag in the MXCSR register. | |
34719 | ||
34720 | This option is enabled by default. | |
34721 | ||
d77de738 | 34722 | @opindex mmove-max |
ddf6fe37 | 34723 | @item -mmove-max=@var{bits} |
d77de738 ML |
34724 | This option instructs GCC to set the maximum number of bits can be |
34725 | moved from memory to memory efficiently to @var{bits}. The valid | |
34726 | @var{bits} are 128, 256 and 512. | |
34727 | ||
d77de738 | 34728 | @opindex mstore-max |
ddf6fe37 | 34729 | @item -mstore-max=@var{bits} |
d77de738 ML |
34730 | This option instructs GCC to set the maximum number of bits can be |
34731 | stored to memory efficiently to @var{bits}. The valid @var{bits} are | |
34732 | 128, 256 and 512. | |
34733 | ||
34734 | @table @samp | |
34735 | @item none | |
34736 | No extra limitations applied to GCC other than defined by the selected platform. | |
34737 | ||
34738 | @item 128 | |
34739 | Prefer 128-bit vector width for instructions. | |
34740 | ||
34741 | @item 256 | |
34742 | Prefer 256-bit vector width for instructions. | |
34743 | ||
34744 | @item 512 | |
34745 | Prefer 512-bit vector width for instructions. | |
34746 | @end table | |
34747 | ||
d77de738 | 34748 | @opindex mcx16 |
ddf6fe37 | 34749 | @item -mcx16 |
d77de738 ML |
34750 | This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit |
34751 | code to implement compare-and-exchange operations on 16-byte aligned 128-bit | |
34752 | objects. This is useful for atomic updates of data structures exceeding one | |
34753 | machine word in size. The compiler uses this instruction to implement | |
34754 | @ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on | |
34755 | 128-bit integers, a library call is always used. | |
34756 | ||
d77de738 | 34757 | @opindex msahf |
ddf6fe37 | 34758 | @item -msahf |
d77de738 ML |
34759 | This option enables generation of @code{SAHF} instructions in 64-bit code. |
34760 | Early Intel Pentium 4 CPUs with Intel 64 support, | |
34761 | prior to the introduction of Pentium 4 G1 step in December 2005, | |
34762 | lacked the @code{LAHF} and @code{SAHF} instructions | |
34763 | which are supported by AMD64. | |
34764 | These are load and store instructions, respectively, for certain status flags. | |
34765 | In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod}, | |
34766 | @code{drem}, and @code{remainder} built-in functions; | |
34767 | see @ref{Other Builtins} for details. | |
34768 | ||
d77de738 | 34769 | @opindex mmovbe |
ddf6fe37 | 34770 | @item -mmovbe |
4b358f9b RB |
34771 | This option enables use of the @code{movbe} instruction to optimize |
34772 | byte swapping of four and eight byte entities. | |
d77de738 | 34773 | |
d77de738 | 34774 | @opindex mshstk |
ddf6fe37 | 34775 | @item -mshstk |
d77de738 ML |
34776 | The @option{-mshstk} option enables shadow stack built-in functions |
34777 | from x86 Control-flow Enforcement Technology (CET). | |
34778 | ||
d77de738 | 34779 | @opindex mcrc32 |
ddf6fe37 | 34780 | @item -mcrc32 |
d77de738 ML |
34781 | This option enables built-in functions @code{__builtin_ia32_crc32qi}, |
34782 | @code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and | |
34783 | @code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction. | |
34784 | ||
d77de738 | 34785 | @opindex mmwait |
ddf6fe37 | 34786 | @item -mmwait |
d77de738 ML |
34787 | This option enables built-in functions @code{__builtin_ia32_monitor}, |
34788 | and @code{__builtin_ia32_mwait} to generate the @code{monitor} and | |
34789 | @code{mwait} machine instructions. | |
34790 | ||
d77de738 | 34791 | @opindex mrecip |
ddf6fe37 | 34792 | @item -mrecip |
d77de738 ML |
34793 | This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions |
34794 | (and their vectorized variants @code{RCPPS} and @code{RSQRTPS}) | |
34795 | with an additional Newton-Raphson step | |
34796 | to increase precision instead of @code{DIVSS} and @code{SQRTSS} | |
34797 | (and their vectorized | |
34798 | variants) for single-precision floating-point arguments. These instructions | |
34799 | are generated only when @option{-funsafe-math-optimizations} is enabled | |
34800 | together with @option{-ffinite-math-only} and @option{-fno-trapping-math}. | |
34801 | Note that while the throughput of the sequence is higher than the throughput | |
34802 | of the non-reciprocal instruction, the precision of the sequence can be | |
34803 | decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994). | |
34804 | ||
34805 | Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS} | |
34806 | (or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option | |
34807 | combination), and doesn't need @option{-mrecip}. | |
34808 | ||
34809 | Also note that GCC emits the above sequence with additional Newton-Raphson step | |
34810 | for vectorized single-float division and vectorized @code{sqrtf(@var{x})} | |
34811 | already with @option{-ffast-math} (or the above option combination), and | |
34812 | doesn't need @option{-mrecip}. | |
34813 | ||
d77de738 | 34814 | @opindex mrecip=opt |
ddf6fe37 | 34815 | @item -mrecip=@var{opt} |
d77de738 ML |
34816 | This option controls which reciprocal estimate instructions |
34817 | may be used. @var{opt} is a comma-separated list of options, which may | |
34818 | be preceded by a @samp{!} to invert the option: | |
34819 | ||
34820 | @table @samp | |
34821 | @item all | |
34822 | Enable all estimate instructions. | |
34823 | ||
34824 | @item default | |
34825 | Enable the default instructions, equivalent to @option{-mrecip}. | |
34826 | ||
34827 | @item none | |
34828 | Disable all estimate instructions, equivalent to @option{-mno-recip}. | |
34829 | ||
34830 | @item div | |
34831 | Enable the approximation for scalar division. | |
34832 | ||
34833 | @item vec-div | |
34834 | Enable the approximation for vectorized division. | |
34835 | ||
34836 | @item sqrt | |
34837 | Enable the approximation for scalar square root. | |
34838 | ||
34839 | @item vec-sqrt | |
34840 | Enable the approximation for vectorized square root. | |
34841 | @end table | |
34842 | ||
34843 | So, for example, @option{-mrecip=all,!sqrt} enables | |
34844 | all of the reciprocal approximations, except for square root. | |
34845 | ||
d77de738 | 34846 | @opindex mveclibabi |
ddf6fe37 | 34847 | @item -mveclibabi=@var{type} |
d77de738 ML |
34848 | Specifies the ABI type to use for vectorizing intrinsics using an |
34849 | external library. Supported values for @var{type} are @samp{svml} | |
34850 | for the Intel short | |
34851 | vector math library and @samp{acml} for the AMD math core library. | |
34852 | To use this option, both @option{-ftree-vectorize} and | |
34853 | @option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML | |
34854 | ABI-compatible library must be specified at link time. | |
34855 | ||
34856 | GCC currently emits calls to @code{vmldExp2}, | |
34857 | @code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2}, | |
34858 | @code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2}, | |
34859 | @code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2}, | |
34860 | @code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2}, | |
34861 | @code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4}, | |
34862 | @code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4}, | |
34863 | @code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4}, | |
34864 | @code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4}, | |
34865 | @code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding | |
34866 | function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin}, | |
34867 | @code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2}, | |
34868 | @code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf}, | |
34869 | @code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f}, | |
34870 | @code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type | |
34871 | when @option{-mveclibabi=acml} is used. | |
34872 | ||
d77de738 | 34873 | @opindex mabi |
ddf6fe37 | 34874 | @item -mabi=@var{name} |
d77de738 ML |
34875 | Generate code for the specified calling convention. Permissible values |
34876 | are @samp{sysv} for the ABI used on GNU/Linux and other systems, and | |
34877 | @samp{ms} for the Microsoft ABI. The default is to use the Microsoft | |
34878 | ABI when targeting Microsoft Windows and the SysV ABI on all other systems. | |
34879 | You can control this behavior for specific functions by | |
34880 | using the function attributes @code{ms_abi} and @code{sysv_abi}. | |
34881 | @xref{Function Attributes}. | |
34882 | ||
d77de738 | 34883 | @opindex mforce-indirect-call |
ddf6fe37 | 34884 | @item -mforce-indirect-call |
d77de738 ML |
34885 | Force all calls to functions to be indirect. This is useful |
34886 | when using Intel Processor Trace where it generates more precise timing | |
34887 | information for function calls. | |
34888 | ||
d77de738 | 34889 | @opindex mmanual-endbr |
ddf6fe37 | 34890 | @item -mmanual-endbr |
d77de738 ML |
34891 | Insert ENDBR instruction at function entry only via the @code{cf_check} |
34892 | function attribute. This is useful when used with the option | |
34893 | @option{-fcf-protection=branch} to control ENDBR insertion at the | |
34894 | function entry. | |
34895 | ||
d77de738 | 34896 | @opindex mcet-switch |
ddf6fe37 | 34897 | @item -mcet-switch |
d77de738 ML |
34898 | By default, CET instrumentation is turned off on switch statements that |
34899 | use a jump table and indirect branch track is disabled. Since jump | |
34900 | tables are stored in read-only memory, this does not result in a direct | |
34901 | loss of hardening. But if the jump table index is attacker-controlled, | |
34902 | the indirect jump may not be constrained by CET. This option turns on | |
34903 | CET instrumentation to enable indirect branch track for switch statements | |
34904 | with jump tables which leads to the jump targets reachable via any indirect | |
34905 | jumps. | |
34906 | ||
d77de738 ML |
34907 | @opindex mcall-ms2sysv-xlogues |
34908 | @opindex mno-call-ms2sysv-xlogues | |
ddf6fe37 | 34909 | @item -mcall-ms2sysv-xlogues |
d77de738 ML |
34910 | Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a |
34911 | System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By | |
34912 | default, the code for saving and restoring these registers is emitted inline, | |
34913 | resulting in fairly lengthy prologues and epilogues. Using | |
34914 | @option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that | |
34915 | use stubs in the static portion of libgcc to perform these saves and restores, | |
34916 | thus reducing function size at the cost of a few extra instructions. | |
34917 | ||
d77de738 | 34918 | @opindex mtls-dialect |
ddf6fe37 | 34919 | @item -mtls-dialect=@var{type} |
d77de738 ML |
34920 | Generate code to access thread-local storage using the @samp{gnu} or |
34921 | @samp{gnu2} conventions. @samp{gnu} is the conservative default; | |
34922 | @samp{gnu2} is more efficient, but it may add compile- and run-time | |
34923 | requirements that cannot be satisfied on all systems. | |
34924 | ||
d77de738 ML |
34925 | @opindex mpush-args |
34926 | @opindex mno-push-args | |
ddf6fe37 AA |
34927 | @item -mpush-args |
34928 | @itemx -mno-push-args | |
d77de738 ML |
34929 | Use PUSH operations to store outgoing parameters. This method is shorter |
34930 | and usually equally fast as method using SUB/MOV operations and is enabled | |
34931 | by default. In some cases disabling it may improve performance because of | |
34932 | improved scheduling and reduced dependencies. | |
34933 | ||
d77de738 | 34934 | @opindex maccumulate-outgoing-args |
ddf6fe37 | 34935 | @item -maccumulate-outgoing-args |
d77de738 ML |
34936 | If enabled, the maximum amount of space required for outgoing arguments is |
34937 | computed in the function prologue. This is faster on most modern CPUs | |
34938 | because of reduced dependencies, improved scheduling and reduced stack usage | |
34939 | when the preferred stack boundary is not equal to 2. The drawback is a notable | |
34940 | increase in code size. This switch implies @option{-mno-push-args}. | |
34941 | ||
d77de738 | 34942 | @opindex mthreads |
ddf6fe37 | 34943 | @item -mthreads |
d77de738 ML |
34944 | Support thread-safe exception handling on MinGW. Programs that rely |
34945 | on thread-safe exception handling must compile and link all code with the | |
34946 | @option{-mthreads} option. When compiling, @option{-mthreads} defines | |
34947 | @option{-D_MT}; when linking, it links in a special thread helper library | |
34948 | @option{-lmingwthrd} which cleans up per-thread exception-handling data. | |
34949 | ||
d77de738 ML |
34950 | @opindex mms-bitfields |
34951 | @opindex mno-ms-bitfields | |
ddf6fe37 AA |
34952 | @item -mms-bitfields |
34953 | @itemx -mno-ms-bitfields | |
d77de738 ML |
34954 | |
34955 | Enable/disable bit-field layout compatible with the native Microsoft | |
34956 | Windows compiler. | |
34957 | ||
34958 | If @code{packed} is used on a structure, or if bit-fields are used, | |
34959 | it may be that the Microsoft ABI lays out the structure differently | |
34960 | than the way GCC normally does. Particularly when moving packed | |
34961 | data between functions compiled with GCC and the native Microsoft compiler | |
34962 | (either via function call or as data in a file), it may be necessary to access | |
34963 | either format. | |
34964 | ||
34965 | This option is enabled by default for Microsoft Windows | |
34966 | targets. This behavior can also be controlled locally by use of variable | |
34967 | or type attributes. For more information, see @ref{x86 Variable Attributes} | |
34968 | and @ref{x86 Type Attributes}. | |
34969 | ||
34970 | The Microsoft structure layout algorithm is fairly simple with the exception | |
34971 | of the bit-field packing. | |
34972 | The padding and alignment of members of structures and whether a bit-field | |
34973 | can straddle a storage-unit boundary are determine by these rules: | |
34974 | ||
34975 | @enumerate | |
34976 | @item Structure members are stored sequentially in the order in which they are | |
34977 | declared: the first member has the lowest memory address and the last member | |
34978 | the highest. | |
34979 | ||
34980 | @item Every data object has an alignment requirement. The alignment requirement | |
34981 | for all data except structures, unions, and arrays is either the size of the | |
34982 | object or the current packing size (specified with either the | |
34983 | @code{aligned} attribute or the @code{pack} pragma), | |
34984 | whichever is less. For structures, unions, and arrays, | |
34985 | the alignment requirement is the largest alignment requirement of its members. | |
34986 | Every object is allocated an offset so that: | |
34987 | ||
34988 | @smallexample | |
34989 | offset % alignment_requirement == 0 | |
34990 | @end smallexample | |
34991 | ||
34992 | @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation | |
34993 | unit if the integral types are the same size and if the next bit-field fits | |
34994 | into the current allocation unit without crossing the boundary imposed by the | |
34995 | common alignment requirements of the bit-fields. | |
34996 | @end enumerate | |
34997 | ||
34998 | MSVC interprets zero-length bit-fields in the following ways: | |
34999 | ||
35000 | @enumerate | |
35001 | @item If a zero-length bit-field is inserted between two bit-fields that | |
35002 | are normally coalesced, the bit-fields are not coalesced. | |
35003 | ||
35004 | For example: | |
35005 | ||
35006 | @smallexample | |
35007 | struct | |
35008 | @{ | |
35009 | unsigned long bf_1 : 12; | |
35010 | unsigned long : 0; | |
35011 | unsigned long bf_2 : 12; | |
35012 | @} t1; | |
35013 | @end smallexample | |
35014 | ||
35015 | @noindent | |
35016 | The size of @code{t1} is 8 bytes with the zero-length bit-field. If the | |
35017 | zero-length bit-field were removed, @code{t1}'s size would be 4 bytes. | |
35018 | ||
35019 | @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the | |
35020 | alignment of the zero-length bit-field is greater than the member that follows it, | |
35021 | @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field. | |
35022 | ||
35023 | For example: | |
35024 | ||
35025 | @smallexample | |
35026 | struct | |
35027 | @{ | |
35028 | char foo : 4; | |
35029 | short : 0; | |
35030 | char bar; | |
35031 | @} t2; | |
35032 | ||
35033 | struct | |
35034 | @{ | |
35035 | char foo : 4; | |
35036 | short : 0; | |
35037 | double bar; | |
35038 | @} t3; | |
35039 | @end smallexample | |
35040 | ||
35041 | @noindent | |
35042 | For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1. | |
35043 | Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length | |
35044 | bit-field does not affect the alignment of @code{bar} or, as a result, the size | |
35045 | of the structure. | |
35046 | ||
35047 | Taking this into account, it is important to note the following: | |
35048 | ||
35049 | @enumerate | |
35050 | @item If a zero-length bit-field follows a normal bit-field, the type of the | |
35051 | zero-length bit-field may affect the alignment of the structure as whole. For | |
35052 | example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a | |
35053 | normal bit-field, and is of type short. | |
35054 | ||
35055 | @item Even if a zero-length bit-field is not followed by a normal bit-field, it may | |
35056 | still affect the alignment of the structure: | |
35057 | ||
35058 | @smallexample | |
35059 | struct | |
35060 | @{ | |
35061 | char foo : 6; | |
35062 | long : 0; | |
35063 | @} t4; | |
35064 | @end smallexample | |
35065 | ||
35066 | @noindent | |
35067 | Here, @code{t4} takes up 4 bytes. | |
35068 | @end enumerate | |
35069 | ||
35070 | @item Zero-length bit-fields following non-bit-field members are ignored: | |
35071 | ||
35072 | @smallexample | |
35073 | struct | |
35074 | @{ | |
35075 | char foo; | |
35076 | long : 0; | |
35077 | char bar; | |
35078 | @} t5; | |
35079 | @end smallexample | |
35080 | ||
35081 | @noindent | |
35082 | Here, @code{t5} takes up 2 bytes. | |
35083 | @end enumerate | |
35084 | ||
35085 | ||
d77de738 ML |
35086 | @opindex mno-align-stringops |
35087 | @opindex malign-stringops | |
ddf6fe37 | 35088 | @item -mno-align-stringops |
d77de738 ML |
35089 | Do not align the destination of inlined string operations. This switch reduces |
35090 | code size and improves performance in case the destination is already aligned, | |
35091 | but GCC doesn't know about it. | |
35092 | ||
d77de738 | 35093 | @opindex minline-all-stringops |
ddf6fe37 | 35094 | @item -minline-all-stringops |
d77de738 ML |
35095 | By default GCC inlines string operations only when the destination is |
35096 | known to be aligned to least a 4-byte boundary. | |
35097 | This enables more inlining and increases code | |
35098 | size, but may improve performance of code that depends on fast | |
35099 | @code{memcpy} and @code{memset} for short lengths. | |
35100 | The option enables inline expansion of @code{strlen} for all | |
35101 | pointer alignments. | |
35102 | ||
d77de738 | 35103 | @opindex minline-stringops-dynamically |
ddf6fe37 | 35104 | @item -minline-stringops-dynamically |
d77de738 ML |
35105 | For string operations of unknown size, use run-time checks with |
35106 | inline code for small blocks and a library call for large blocks. | |
35107 | ||
d77de738 | 35108 | @opindex mstringop-strategy=@var{alg} |
ddf6fe37 | 35109 | @item -mstringop-strategy=@var{alg} |
d77de738 ML |
35110 | Override the internal decision heuristic for the particular algorithm to use |
35111 | for inlining string operations. The allowed values for @var{alg} are: | |
35112 | ||
35113 | @table @samp | |
35114 | @item rep_byte | |
35115 | @itemx rep_4byte | |
35116 | @itemx rep_8byte | |
35117 | Expand using i386 @code{rep} prefix of the specified size. | |
35118 | ||
35119 | @item byte_loop | |
35120 | @itemx loop | |
35121 | @itemx unrolled_loop | |
35122 | Expand into an inline loop. | |
35123 | ||
35124 | @item libcall | |
35125 | Always use a library call. | |
35126 | @end table | |
35127 | ||
d77de738 | 35128 | @opindex mmemcpy-strategy=@var{strategy} |
ddf6fe37 | 35129 | @item -mmemcpy-strategy=@var{strategy} |
d77de738 ML |
35130 | Override the internal decision heuristic to decide if @code{__builtin_memcpy} |
35131 | should be inlined and what inline algorithm to use when the expected size | |
35132 | of the copy operation is known. @var{strategy} | |
35133 | is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets. | |
35134 | @var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies | |
35135 | the max byte size with which inline algorithm @var{alg} is allowed. For the last | |
35136 | triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets | |
35137 | in the list must be specified in increasing order. The minimal byte size for | |
35138 | @var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the | |
35139 | preceding range. | |
35140 | ||
d77de738 | 35141 | @opindex mmemset-strategy=@var{strategy} |
ddf6fe37 | 35142 | @item -mmemset-strategy=@var{strategy} |
d77de738 ML |
35143 | The option is similar to @option{-mmemcpy-strategy=} except that it is to control |
35144 | @code{__builtin_memset} expansion. | |
35145 | ||
d77de738 | 35146 | @opindex momit-leaf-frame-pointer |
ddf6fe37 | 35147 | @item -momit-leaf-frame-pointer |
d77de738 ML |
35148 | Don't keep the frame pointer in a register for leaf functions. This |
35149 | avoids the instructions to save, set up, and restore frame pointers and | |
35150 | makes an extra register available in leaf functions. The option | |
35151 | @option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions, | |
35152 | which might make debugging harder. | |
35153 | ||
ddf6fe37 | 35154 | @opindex mtls-direct-seg-refs |
d77de738 ML |
35155 | @item -mtls-direct-seg-refs |
35156 | @itemx -mno-tls-direct-seg-refs | |
d77de738 ML |
35157 | Controls whether TLS variables may be accessed with offsets from the |
35158 | TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit), | |
35159 | or whether the thread base pointer must be added. Whether or not this | |
35160 | is valid depends on the operating system, and whether it maps the | |
35161 | segment to cover the entire TLS area. | |
35162 | ||
35163 | For systems that use the GNU C Library, the default is on. | |
35164 | ||
ddf6fe37 | 35165 | @opindex msse2avx |
d77de738 ML |
35166 | @item -msse2avx |
35167 | @itemx -mno-sse2avx | |
d77de738 ML |
35168 | Specify that the assembler should encode SSE instructions with VEX |
35169 | prefix. The option @option{-mavx} turns this on by default. | |
35170 | ||
ddf6fe37 | 35171 | @opindex mfentry |
d77de738 ML |
35172 | @item -mfentry |
35173 | @itemx -mno-fentry | |
d77de738 ML |
35174 | If profiling is active (@option{-pg}), put the profiling |
35175 | counter call before the prologue. | |
35176 | Note: On x86 architectures the attribute @code{ms_hook_prologue} | |
35177 | isn't possible at the moment for @option{-mfentry} and @option{-pg}. | |
35178 | ||
ddf6fe37 | 35179 | @opindex mrecord-mcount |
d77de738 ML |
35180 | @item -mrecord-mcount |
35181 | @itemx -mno-record-mcount | |
d77de738 ML |
35182 | If profiling is active (@option{-pg}), generate a __mcount_loc section |
35183 | that contains pointers to each profiling call. This is useful for | |
35184 | automatically patching and out calls. | |
35185 | ||
ddf6fe37 | 35186 | @opindex mnop-mcount |
d77de738 ML |
35187 | @item -mnop-mcount |
35188 | @itemx -mno-nop-mcount | |
d77de738 ML |
35189 | If profiling is active (@option{-pg}), generate the calls to |
35190 | the profiling functions as NOPs. This is useful when they | |
35191 | should be patched in later dynamically. This is likely only | |
35192 | useful together with @option{-mrecord-mcount}. | |
35193 | ||
d77de738 | 35194 | @opindex minstrument-return |
ddf6fe37 | 35195 | @item -minstrument-return=@var{type} |
d77de738 ML |
35196 | Instrument function exit in -pg -mfentry instrumented functions with |
35197 | call to specified function. This only instruments true returns ending | |
35198 | with ret, but not sibling calls ending with jump. Valid types | |
35199 | are @var{none} to not instrument, @var{call} to generate a call to __return__, | |
35200 | or @var{nop5} to generate a 5 byte nop. | |
35201 | ||
ddf6fe37 | 35202 | @opindex mrecord-return |
d77de738 ML |
35203 | @item -mrecord-return |
35204 | @itemx -mno-record-return | |
d77de738 ML |
35205 | Generate a __return_loc section pointing to all return instrumentation code. |
35206 | ||
d77de738 | 35207 | @opindex mfentry-name |
ddf6fe37 | 35208 | @item -mfentry-name=@var{name} |
d77de738 ML |
35209 | Set name of __fentry__ symbol called at function entry for -pg -mfentry functions. |
35210 | ||
d77de738 | 35211 | @opindex mfentry-section |
ddf6fe37 | 35212 | @item -mfentry-section=@var{name} |
d77de738 ML |
35213 | Set name of section to record -mrecord-mcount calls (default __mcount_loc). |
35214 | ||
ddf6fe37 | 35215 | @opindex mskip-rax-setup |
d77de738 ML |
35216 | @item -mskip-rax-setup |
35217 | @itemx -mno-skip-rax-setup | |
d77de738 ML |
35218 | When generating code for the x86-64 architecture with SSE extensions |
35219 | disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX | |
35220 | register when there are no variable arguments passed in vector registers. | |
35221 | ||
35222 | @strong{Warning:} Since RAX register is used to avoid unnecessarily | |
35223 | saving vector registers on stack when passing variable arguments, the | |
35224 | impacts of this option are callees may waste some stack space, | |
35225 | misbehave or jump to a random location. GCC 4.4 or newer don't have | |
35226 | those issues, regardless the RAX register value. | |
35227 | ||
ddf6fe37 | 35228 | @opindex m8bit-idiv |
d77de738 ML |
35229 | @item -m8bit-idiv |
35230 | @itemx -mno-8bit-idiv | |
d77de738 ML |
35231 | On some processors, like Intel Atom, 8-bit unsigned integer divide is |
35232 | much faster than 32-bit/64-bit integer divide. This option generates a | |
35233 | run-time check. If both dividend and divisor are within range of 0 | |
35234 | to 255, 8-bit unsigned integer divide is used instead of | |
35235 | 32-bit/64-bit integer divide. | |
35236 | ||
d77de738 ML |
35237 | @opindex mavx256-split-unaligned-load |
35238 | @opindex mavx256-split-unaligned-store | |
ddf6fe37 AA |
35239 | @item -mavx256-split-unaligned-load |
35240 | @itemx -mavx256-split-unaligned-store | |
d77de738 ML |
35241 | Split 32-byte AVX unaligned load and store. |
35242 | ||
d77de738 ML |
35243 | @opindex mstack-protector-guard |
35244 | @opindex mstack-protector-guard-reg | |
35245 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
35246 | @item -mstack-protector-guard=@var{guard} |
35247 | @itemx -mstack-protector-guard-reg=@var{reg} | |
35248 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
35249 | Generate stack protection code using canary at @var{guard}. Supported |
35250 | locations are @samp{global} for global canary or @samp{tls} for per-thread | |
35251 | canary in the TLS block (the default). This option has effect only when | |
35252 | @option{-fstack-protector} or @option{-fstack-protector-all} is specified. | |
35253 | ||
35254 | With the latter choice the options | |
35255 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
35256 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
35257 | which segment register (@code{%fs} or @code{%gs}) to use as base register | |
35258 | for reading the canary, and from what offset from that base register. | |
35259 | The default for those is as specified in the relevant ABI. | |
35260 | ||
d77de738 | 35261 | @opindex mgeneral-regs-only |
ddf6fe37 | 35262 | @item -mgeneral-regs-only |
d77de738 ML |
35263 | Generate code that uses only the general-purpose registers. This |
35264 | prevents the compiler from using floating-point, vector, mask and bound | |
35265 | registers. | |
35266 | ||
d77de738 | 35267 | @opindex mrelax-cmpxchg-loop |
ddf6fe37 | 35268 | @item -mrelax-cmpxchg-loop |
85966f0d AM |
35269 | When emitting a compare-and-swap loop for @ref{__sync Builtins} |
35270 | and @ref{__atomic Builtins} lacking a native instruction, optimize | |
35271 | for the highly contended case by issuing an atomic load before the | |
35272 | @code{CMPXCHG} instruction, and using the @code{PAUSE} instruction | |
35273 | to save CPU power when restarting the loop. | |
d77de738 | 35274 | |
d77de738 | 35275 | @opindex mindirect-branch |
ddf6fe37 | 35276 | @item -mindirect-branch=@var{choice} |
d77de738 ML |
35277 | Convert indirect call and jump with @var{choice}. The default is |
35278 | @samp{keep}, which keeps indirect call and jump unmodified. | |
35279 | @samp{thunk} converts indirect call and jump to call and return thunk. | |
35280 | @samp{thunk-inline} converts indirect call and jump to inlined call | |
35281 | and return thunk. @samp{thunk-extern} converts indirect call and jump | |
35282 | to external call and return thunk provided in a separate object file. | |
35283 | You can control this behavior for a specific function by using the | |
35284 | function attribute @code{indirect_branch}. @xref{Function Attributes}. | |
35285 | ||
35286 | Note that @option{-mcmodel=large} is incompatible with | |
35287 | @option{-mindirect-branch=thunk} and | |
35288 | @option{-mindirect-branch=thunk-extern} since the thunk function may | |
35289 | not be reachable in the large code model. | |
35290 | ||
35291 | Note that @option{-mindirect-branch=thunk-extern} is compatible with | |
35292 | @option{-fcf-protection=branch} since the external thunk can be made | |
35293 | to enable control-flow check. | |
35294 | ||
d77de738 | 35295 | @opindex mfunction-return |
ddf6fe37 | 35296 | @item -mfunction-return=@var{choice} |
d77de738 ML |
35297 | Convert function return with @var{choice}. The default is @samp{keep}, |
35298 | which keeps function return unmodified. @samp{thunk} converts function | |
35299 | return to call and return thunk. @samp{thunk-inline} converts function | |
35300 | return to inlined call and return thunk. @samp{thunk-extern} converts | |
35301 | function return to external call and return thunk provided in a separate | |
35302 | object file. You can control this behavior for a specific function by | |
35303 | using the function attribute @code{function_return}. | |
35304 | @xref{Function Attributes}. | |
35305 | ||
35306 | Note that @option{-mindirect-return=thunk-extern} is compatible with | |
35307 | @option{-fcf-protection=branch} since the external thunk can be made | |
35308 | to enable control-flow check. | |
35309 | ||
35310 | Note that @option{-mcmodel=large} is incompatible with | |
35311 | @option{-mfunction-return=thunk} and | |
35312 | @option{-mfunction-return=thunk-extern} since the thunk function may | |
35313 | not be reachable in the large code model. | |
35314 | ||
35315 | ||
d77de738 | 35316 | @opindex mindirect-branch-register |
ddf6fe37 | 35317 | @item -mindirect-branch-register |
d77de738 ML |
35318 | Force indirect call and jump via register. |
35319 | ||
d77de738 | 35320 | @opindex mharden-sls |
ddf6fe37 | 35321 | @item -mharden-sls=@var{choice} |
d77de738 ML |
35322 | Generate code to mitigate against straight line speculation (SLS) with |
35323 | @var{choice}. The default is @samp{none} which disables all SLS | |
35324 | hardening. @samp{return} enables SLS hardening for function returns. | |
35325 | @samp{indirect-jmp} enables SLS hardening for indirect jumps. | |
35326 | @samp{all} enables all SLS hardening. | |
35327 | ||
d77de738 | 35328 | @opindex mindirect-branch-cs-prefix |
ddf6fe37 | 35329 | @item -mindirect-branch-cs-prefix |
d77de738 ML |
35330 | Add CS prefix to call and jmp to indirect thunk with branch target in |
35331 | r8-r15 registers so that the call and jmp instruction length is 6 bytes | |
35332 | to allow them to be replaced with @samp{lfence; call *%r8-r15} or | |
35333 | @samp{lfence; jmp *%r8-r15} at run-time. | |
35334 | ||
7de5bb64 HW |
35335 | @opindex mapx-inline-asm-use-gpr32 |
35336 | @item -mapx-inline-asm-use-gpr32 | |
35337 | For inline asm support with APX, by default the EGPR feature was | |
35338 | disabled to prevent potential illegal instruction with EGPR occurs. | |
35339 | To invoke egpr usage in inline asm, use new compiler option | |
35340 | -mapx-inline-asm-use-gpr32 and user should ensure the instruction | |
35341 | supports EGPR. | |
35342 | ||
49a14ee4 HJ |
35343 | @opindex mevex512 |
35344 | @item -mevex512 | |
35345 | @itemx -mno-evex512 | |
35346 | Enables/disables 512-bit vector. It will be default on if AVX512F is enabled. | |
35347 | ||
d77de738 ML |
35348 | @end table |
35349 | ||
35350 | These @samp{-m} switches are supported in addition to the above | |
35351 | on x86-64 processors in 64-bit environments. | |
35352 | ||
35353 | @table @gcctabopt | |
d77de738 ML |
35354 | @opindex m32 |
35355 | @opindex m64 | |
35356 | @opindex mx32 | |
35357 | @opindex m16 | |
35358 | @opindex miamcu | |
ddf6fe37 AA |
35359 | @item -m32 |
35360 | @itemx -m64 | |
35361 | @itemx -mx32 | |
35362 | @itemx -m16 | |
35363 | @itemx -miamcu | |
d77de738 ML |
35364 | Generate code for a 16-bit, 32-bit or 64-bit environment. |
35365 | The @option{-m32} option sets @code{int}, @code{long}, and pointer types | |
35366 | to 32 bits, and | |
eeb92704 | 35367 | generates code that runs in 32-bit mode. |
d77de738 ML |
35368 | |
35369 | The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer | |
35370 | types to 64 bits, and generates code for the x86-64 architecture. | |
35371 | For Darwin only the @option{-m64} option also turns off the @option{-fno-pic} | |
35372 | and @option{-mdynamic-no-pic} options. | |
35373 | ||
35374 | The @option{-mx32} option sets @code{int}, @code{long}, and pointer types | |
35375 | to 32 bits, and | |
35376 | generates code for the x86-64 architecture. | |
35377 | ||
35378 | The @option{-m16} option is the same as @option{-m32}, except for that | |
35379 | it outputs the @code{.code16gcc} assembly directive at the beginning of | |
35380 | the assembly output so that the binary can run in 16-bit mode. | |
35381 | ||
35382 | The @option{-miamcu} option generates code which conforms to Intel MCU | |
35383 | psABI. It requires the @option{-m32} option to be turned on. | |
35384 | ||
d77de738 ML |
35385 | @opindex mno-red-zone |
35386 | @opindex mred-zone | |
ddf6fe37 | 35387 | @item -mno-red-zone |
d77de738 ML |
35388 | Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated |
35389 | by the x86-64 ABI; it is a 128-byte area beyond the location of the | |
35390 | stack pointer that is not modified by signal or interrupt handlers | |
35391 | and therefore can be used for temporary data without adjusting the stack | |
35392 | pointer. The flag @option{-mno-red-zone} disables this red zone. | |
35393 | ||
d77de738 | 35394 | @opindex mcmodel=small |
ddf6fe37 | 35395 | @item -mcmodel=small |
d77de738 ML |
35396 | Generate code for the small code model: the program and its symbols must |
35397 | be linked in the lower 2 GB of the address space. Pointers are 64 bits. | |
35398 | Programs can be statically or dynamically linked. This is the default | |
35399 | code model. | |
35400 | ||
d77de738 | 35401 | @opindex mcmodel=kernel |
ddf6fe37 | 35402 | @item -mcmodel=kernel |
d77de738 ML |
35403 | Generate code for the kernel code model. The kernel runs in the |
35404 | negative 2 GB of the address space. | |
35405 | This model has to be used for Linux kernel code. | |
35406 | ||
d77de738 | 35407 | @opindex mcmodel=medium |
ddf6fe37 | 35408 | @item -mcmodel=medium |
d77de738 ML |
35409 | Generate code for the medium model: the program is linked in the lower 2 |
35410 | GB of the address space. Small symbols are also placed there. Symbols | |
35411 | with sizes larger than @option{-mlarge-data-threshold} are put into | |
35412 | large data or BSS sections and can be located above 2GB. Programs can | |
35413 | be statically or dynamically linked. | |
35414 | ||
d77de738 | 35415 | @opindex mcmodel=large |
ddf6fe37 | 35416 | @item -mcmodel=large |
d77de738 ML |
35417 | Generate code for the large model. This model makes no assumptions |
35418 | about addresses and sizes of sections. | |
35419 | ||
d77de738 | 35420 | @opindex maddress-mode=long |
ddf6fe37 | 35421 | @item -maddress-mode=long |
d77de738 ML |
35422 | Generate code for long address mode. This is only supported for 64-bit |
35423 | and x32 environments. It is the default address mode for 64-bit | |
35424 | environments. | |
35425 | ||
d77de738 | 35426 | @opindex maddress-mode=short |
ddf6fe37 | 35427 | @item -maddress-mode=short |
d77de738 ML |
35428 | Generate code for short address mode. This is only supported for 32-bit |
35429 | and x32 environments. It is the default address mode for 32-bit and | |
35430 | x32 environments. | |
35431 | ||
ddf6fe37 | 35432 | @opindex mneeded |
d77de738 ML |
35433 | @item -mneeded |
35434 | @itemx -mno-needed | |
d77de738 ML |
35435 | Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to |
35436 | indicate the micro-architecture ISA level required to execute the binary. | |
35437 | ||
d77de738 ML |
35438 | @opindex mno-direct-extern-access |
35439 | @opindex mdirect-extern-access | |
ddf6fe37 | 35440 | @item -mno-direct-extern-access |
d77de738 ML |
35441 | Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer |
35442 | to access external symbols. With @option{-fpic} or @option{-fPIC}, | |
35443 | treat access to protected symbols as local symbols. The default is | |
35444 | @option{-mdirect-extern-access}. | |
35445 | ||
35446 | @strong{Warning:} shared libraries compiled with | |
35447 | @option{-mno-direct-extern-access} and executable compiled with | |
35448 | @option{-mdirect-extern-access} may not be binary compatible if | |
35449 | protected symbols are used in shared libraries and executable. | |
ce51e843 | 35450 | |
ce51e843 ML |
35451 | @opindex munroll-only-small-loops |
35452 | @opindex mno-unroll-only-small-loops | |
ddf6fe37 | 35453 | @item -munroll-only-small-loops |
ce51e843 ML |
35454 | Controls conservative small loop unrolling. It is default enabled by |
35455 | O2, and unrolls loop with less than 4 insns by 1 time. Explicit | |
35456 | -f[no-]unroll-[all-]loops would disable this flag to avoid any | |
35457 | unintended unrolling behavior that user does not want. | |
bb576017 | 35458 | |
bb576017 | 35459 | @opindex mlam |
ddf6fe37 | 35460 | @item -mlam=@var{choice} |
bb576017 | 35461 | LAM(linear-address masking) allows special bits in the pointer to be used |
35462 | for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in | |
35463 | positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in | |
35464 | positions 62:57 can be used for metadata. | |
d77de738 ML |
35465 | @end table |
35466 | ||
35467 | @node x86 Windows Options | |
35468 | @subsection x86 Windows Options | |
35469 | @cindex x86 Windows Options | |
35470 | @cindex Windows Options for x86 | |
35471 | ||
35472 | These additional options are available for Microsoft Windows targets: | |
35473 | ||
35474 | @table @gcctabopt | |
d77de738 | 35475 | @opindex mconsole |
ddf6fe37 | 35476 | @item -mconsole |
d77de738 ML |
35477 | This option |
35478 | specifies that a console application is to be generated, by | |
35479 | instructing the linker to set the PE header subsystem type | |
35480 | required for console applications. | |
35481 | This option is available for Cygwin and MinGW targets and is | |
35482 | enabled by default on those targets. | |
35483 | ||
453cb585 PR |
35484 | @opindex mcrtdll |
35485 | @item -mcrtdll=@var{library} | |
35486 | Preprocess, compile or link with specified C RunTime DLL @var{library}. | |
35487 | This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__} | |
35488 | and @code{__MSVCRT_VERSION__} for specified CRT @var{library}, choose | |
35489 | start file for CRT @var{library} and link with CRT @var{library}. | |
35490 | Recognized CRT library names for proprocessor are: | |
35491 | @code{crtdll}, @code{msvcrt10}, @code{msvcrt20}, @code{msvcrt40}, | |
35492 | @code{msvcrt-os}, @code{msvcr70}, @code{msvcr80}, @code{msvcr90}, | |
35493 | @code{msvcr100}, @code{msvcr110}, @code{msvcr120} and @code{ucrt}. | |
35494 | If this options is not specified then the default MinGW import library | |
35495 | @code{msvcrt} is used for linking and no other adjustment for | |
35496 | preprocessor is done. MinGW import library @code{msvcrt} is just a | |
35497 | symlink to (or a copy of) another MinGW CRT import library | |
35498 | chosen during MinGW compilation. MinGW import library @code{msvcrt-os} | |
35499 | is for Windows system CRT DLL library @code{msvcrt.dll} and | |
35500 | in most cases is the default MinGW import library. | |
35501 | Generally speaking, changing the CRT DLL requires recompiling | |
35502 | the entire MinGW CRT. This option is for experimental and testing | |
35503 | purposes only. | |
35504 | This option is available for MinGW targets. | |
35505 | ||
d77de738 | 35506 | @opindex mdll |
ddf6fe37 | 35507 | @item -mdll |
d77de738 ML |
35508 | This option is available for Cygwin and MinGW targets. It |
35509 | specifies that a DLL---a dynamic link library---is to be | |
35510 | generated, enabling the selection of the required runtime | |
35511 | startup object and entry point. | |
35512 | ||
d77de738 | 35513 | @opindex mnop-fun-dllimport |
ddf6fe37 | 35514 | @item -mnop-fun-dllimport |
d77de738 ML |
35515 | This option is available for Cygwin and MinGW targets. It |
35516 | specifies that the @code{dllimport} attribute should be ignored. | |
35517 | ||
d77de738 | 35518 | @opindex mthreads |
ddf6fe37 | 35519 | @item -mthreads |
d77de738 ML |
35520 | This option is available for MinGW targets. It specifies |
35521 | that MinGW-specific thread support is to be used. | |
35522 | ||
d77de738 | 35523 | @opindex municode |
ddf6fe37 | 35524 | @item -municode |
d77de738 ML |
35525 | This option is available for MinGW-w64 targets. It causes |
35526 | the @code{UNICODE} preprocessor macro to be predefined, and | |
35527 | chooses Unicode-capable runtime startup code. | |
35528 | ||
d77de738 | 35529 | @opindex mwin32 |
ddf6fe37 | 35530 | @item -mwin32 |
d77de738 ML |
35531 | This option is available for Cygwin and MinGW targets. It |
35532 | specifies that the typical Microsoft Windows predefined macros are to | |
35533 | be set in the pre-processor, but does not influence the choice | |
35534 | of runtime library/startup code. | |
35535 | ||
d77de738 | 35536 | @opindex mwindows |
ddf6fe37 | 35537 | @item -mwindows |
d77de738 ML |
35538 | This option is available for Cygwin and MinGW targets. It |
35539 | specifies that a GUI application is to be generated by | |
35540 | instructing the linker to set the PE header subsystem type | |
35541 | appropriately. | |
35542 | ||
d77de738 ML |
35543 | @opindex fno-set-stack-executable |
35544 | @opindex fset-stack-executable | |
ddf6fe37 | 35545 | @item -fno-set-stack-executable |
d77de738 ML |
35546 | This option is available for MinGW targets. It specifies that |
35547 | the executable flag for the stack used by nested functions isn't | |
35548 | set. This is necessary for binaries running in kernel mode of | |
35549 | Microsoft Windows, as there the User32 API, which is used to set executable | |
35550 | privileges, isn't available. | |
35551 | ||
d77de738 ML |
35552 | @opindex fno-writable-relocated-rdata |
35553 | @opindex fwritable-relocated-rdata | |
ddf6fe37 | 35554 | @item -fwritable-relocated-rdata |
d77de738 ML |
35555 | This option is available for MinGW and Cygwin targets. It specifies |
35556 | that relocated-data in read-only section is put into the @code{.data} | |
35557 | section. This is a necessary for older runtimes not supporting | |
35558 | modification of @code{.rdata} sections for pseudo-relocation. | |
35559 | ||
d77de738 | 35560 | @opindex mpe-aligned-commons |
ddf6fe37 | 35561 | @item -mpe-aligned-commons |
d77de738 ML |
35562 | This option is available for Cygwin and MinGW targets. It |
35563 | specifies that the GNU extension to the PE file format that | |
35564 | permits the correct alignment of COMMON variables should be | |
35565 | used when generating code. It is enabled by default if | |
35566 | GCC detects that the target assembler found during configuration | |
35567 | supports the feature. | |
35568 | @end table | |
35569 | ||
35570 | See also under @ref{x86 Options} for standard options. | |
35571 | ||
35572 | @node Xstormy16 Options | |
35573 | @subsection Xstormy16 Options | |
35574 | @cindex Xstormy16 Options | |
35575 | ||
35576 | These options are defined for Xstormy16: | |
35577 | ||
35578 | @table @gcctabopt | |
d77de738 | 35579 | @opindex msim |
ddf6fe37 | 35580 | @item -msim |
d77de738 ML |
35581 | Choose startup files and linker script suitable for the simulator. |
35582 | @end table | |
35583 | ||
35584 | @node Xtensa Options | |
35585 | @subsection Xtensa Options | |
35586 | @cindex Xtensa Options | |
35587 | ||
35588 | These options are supported for Xtensa targets: | |
35589 | ||
35590 | @table @gcctabopt | |
d77de738 ML |
35591 | @opindex mconst16 |
35592 | @opindex mno-const16 | |
ddf6fe37 AA |
35593 | @item -mconst16 |
35594 | @itemx -mno-const16 | |
d77de738 ML |
35595 | Enable or disable use of @code{CONST16} instructions for loading |
35596 | constant values. The @code{CONST16} instruction is currently not a | |
35597 | standard option from Tensilica. When enabled, @code{CONST16} | |
35598 | instructions are always used in place of the standard @code{L32R} | |
35599 | instructions. The use of @code{CONST16} is enabled by default only if | |
35600 | the @code{L32R} instruction is not available. | |
35601 | ||
d77de738 ML |
35602 | @opindex mfused-madd |
35603 | @opindex mno-fused-madd | |
ddf6fe37 AA |
35604 | @item -mfused-madd |
35605 | @itemx -mno-fused-madd | |
d77de738 ML |
35606 | Enable or disable use of fused multiply/add and multiply/subtract |
35607 | instructions in the floating-point option. This has no effect if the | |
35608 | floating-point option is not also enabled. Disabling fused multiply/add | |
35609 | and multiply/subtract instructions forces the compiler to use separate | |
35610 | instructions for the multiply and add/subtract operations. This may be | |
35611 | desirable in some cases where strict IEEE 754-compliant results are | |
35612 | required: the fused multiply add/subtract instructions do not round the | |
35613 | intermediate result, thereby producing results with @emph{more} bits of | |
35614 | precision than specified by the IEEE standard. Disabling fused multiply | |
35615 | add/subtract instructions also ensures that the program output is not | |
35616 | sensitive to the compiler's ability to combine multiply and add/subtract | |
35617 | operations. | |
35618 | ||
d77de738 ML |
35619 | @opindex mserialize-volatile |
35620 | @opindex mno-serialize-volatile | |
ddf6fe37 AA |
35621 | @item -mserialize-volatile |
35622 | @itemx -mno-serialize-volatile | |
d77de738 ML |
35623 | When this option is enabled, GCC inserts @code{MEMW} instructions before |
35624 | @code{volatile} memory references to guarantee sequential consistency. | |
35625 | The default is @option{-mserialize-volatile}. Use | |
35626 | @option{-mno-serialize-volatile} to omit the @code{MEMW} instructions. | |
35627 | ||
d77de738 | 35628 | @opindex mforce-no-pic |
ddf6fe37 | 35629 | @item -mforce-no-pic |
d77de738 ML |
35630 | For targets, like GNU/Linux, where all user-mode Xtensa code must be |
35631 | position-independent code (PIC), this option disables PIC for compiling | |
35632 | kernel code. | |
35633 | ||
d77de738 ML |
35634 | @opindex mtext-section-literals |
35635 | @opindex mno-text-section-literals | |
ddf6fe37 AA |
35636 | @item -mtext-section-literals |
35637 | @itemx -mno-text-section-literals | |
d77de738 ML |
35638 | These options control the treatment of literal pools. The default is |
35639 | @option{-mno-text-section-literals}, which places literals in a separate | |
35640 | section in the output file. This allows the literal pool to be placed | |
35641 | in a data RAM/ROM, and it also allows the linker to combine literal | |
35642 | pools from separate object files to remove redundant literals and | |
35643 | improve code size. With @option{-mtext-section-literals}, the literals | |
35644 | are interspersed in the text section in order to keep them as close as | |
35645 | possible to their references. This may be necessary for large assembly | |
35646 | files. Literals for each function are placed right before that function. | |
35647 | ||
d77de738 ML |
35648 | @opindex mauto-litpools |
35649 | @opindex mno-auto-litpools | |
ddf6fe37 AA |
35650 | @item -mauto-litpools |
35651 | @itemx -mno-auto-litpools | |
d77de738 ML |
35652 | These options control the treatment of literal pools. The default is |
35653 | @option{-mno-auto-litpools}, which places literals in a separate | |
35654 | section in the output file unless @option{-mtext-section-literals} is | |
35655 | used. With @option{-mauto-litpools} the literals are interspersed in | |
35656 | the text section by the assembler. Compiler does not produce explicit | |
35657 | @code{.literal} directives and loads literals into registers with | |
35658 | @code{MOVI} instructions instead of @code{L32R} to let the assembler | |
35659 | do relaxation and place literals as necessary. This option allows | |
35660 | assembler to create several literal pools per function and assemble | |
35661 | very big functions, which may not be possible with | |
35662 | @option{-mtext-section-literals}. | |
35663 | ||
d77de738 ML |
35664 | @opindex mtarget-align |
35665 | @opindex mno-target-align | |
ddf6fe37 AA |
35666 | @item -mtarget-align |
35667 | @itemx -mno-target-align | |
d77de738 ML |
35668 | When this option is enabled, GCC instructs the assembler to |
35669 | automatically align instructions to reduce branch penalties at the | |
35670 | expense of some code density. The assembler attempts to widen density | |
35671 | instructions to align branch targets and the instructions following call | |
35672 | instructions. If there are not enough preceding safe density | |
35673 | instructions to align a target, no widening is performed. The | |
35674 | default is @option{-mtarget-align}. These options do not affect the | |
35675 | treatment of auto-aligned instructions like @code{LOOP}, which the | |
35676 | assembler always aligns, either by widening density instructions or | |
35677 | by inserting NOP instructions. | |
35678 | ||
d77de738 ML |
35679 | @opindex mlongcalls |
35680 | @opindex mno-longcalls | |
ddf6fe37 AA |
35681 | @item -mlongcalls |
35682 | @itemx -mno-longcalls | |
d77de738 ML |
35683 | When this option is enabled, GCC instructs the assembler to translate |
35684 | direct calls to indirect calls unless it can determine that the target | |
35685 | of a direct call is in the range allowed by the call instruction. This | |
35686 | translation typically occurs for calls to functions in other source | |
35687 | files. Specifically, the assembler translates a direct @code{CALL} | |
35688 | instruction into an @code{L32R} followed by a @code{CALLX} instruction. | |
35689 | The default is @option{-mno-longcalls}. This option should be used in | |
35690 | programs where the call target can potentially be out of range. This | |
35691 | option is implemented in the assembler, not the compiler, so the | |
35692 | assembly code generated by GCC still shows direct call | |
35693 | instructions---look at the disassembled object code to see the actual | |
35694 | instructions. Note that the assembler uses an indirect call for | |
35695 | every cross-file call, not just those that really are out of range. | |
35696 | ||
d77de738 | 35697 | @opindex mabi |
ddf6fe37 | 35698 | @item -mabi=@var{name} |
d77de738 ML |
35699 | Generate code for the specified ABI@. Permissible values are: @samp{call0}, |
35700 | @samp{windowed}. Default ABI is chosen by the Xtensa core configuration. | |
35701 | ||
d77de738 | 35702 | @opindex mabi=call0 |
ddf6fe37 | 35703 | @item -mabi=call0 |
d77de738 ML |
35704 | When this option is enabled function parameters are passed in registers |
35705 | @code{a2} through @code{a7}, registers @code{a12} through @code{a15} are | |
35706 | caller-saved, and register @code{a15} may be used as a frame pointer. | |
35707 | When this version of the ABI is enabled the C preprocessor symbol | |
35708 | @code{__XTENSA_CALL0_ABI__} is defined. | |
35709 | ||
d77de738 | 35710 | @opindex mabi=windowed |
ddf6fe37 | 35711 | @item -mabi=windowed |
d77de738 ML |
35712 | When this option is enabled function parameters are passed in registers |
35713 | @code{a10} through @code{a15}, and called function rotates register window | |
35714 | by 8 registers on entry so that its arguments are found in registers | |
35715 | @code{a2} through @code{a7}. Register @code{a7} may be used as a frame | |
35716 | pointer. Register window is rotated 8 registers back upon return. | |
35717 | When this version of the ABI is enabled the C preprocessor symbol | |
35718 | @code{__XTENSA_WINDOWED_ABI__} is defined. | |
35719 | ||
d77de738 | 35720 | @opindex mextra-l32r-costs |
ddf6fe37 | 35721 | @item -mextra-l32r-costs=@var{n} |
d77de738 ML |
35722 | Specify an extra cost of instruction RAM/ROM access for @code{L32R} |
35723 | instructions, in clock cycles. This affects, when optimizing for speed, | |
35724 | whether loading a constant from literal pool using @code{L32R} or | |
35725 | synthesizing the constant from a small one with a couple of arithmetic | |
35726 | instructions. The default value is 0. | |
675b390e MF |
35727 | |
35728 | @opindex mstrict-align | |
35729 | @opindex mno-strict-align | |
35730 | @item -mstrict-align | |
35731 | @itemx -mno-strict-align | |
35732 | Avoid or allow generating memory accesses that may not be aligned on a natural | |
35733 | object boundary as described in the architecture specification. | |
35734 | The default is @option{-mno-strict-align} for cores that support both | |
35735 | unaligned loads and stores in hardware and @option{-mstrict-align} for all | |
35736 | other cores. | |
35737 | ||
d77de738 ML |
35738 | @end table |
35739 | ||
35740 | @node zSeries Options | |
35741 | @subsection zSeries Options | |
35742 | @cindex zSeries options | |
35743 | ||
35744 | These are listed under @xref{S/390 and zSeries Options}. | |
35745 | ||
35746 | ||
35747 | @c man end | |
35748 | ||
35749 | @node Spec Files | |
35750 | @section Specifying Subprocesses and the Switches to Pass to Them | |
35751 | @cindex Spec Files | |
35752 | ||
35753 | @command{gcc} is a driver program. It performs its job by invoking a | |
35754 | sequence of other programs to do the work of compiling, assembling and | |
35755 | linking. GCC interprets its command-line parameters and uses these to | |
35756 | deduce which programs it should invoke, and which command-line options | |
35757 | it ought to place on their command lines. This behavior is controlled | |
35758 | by @dfn{spec strings}. In most cases there is one spec string for each | |
35759 | program that GCC can invoke, but a few programs have multiple spec | |
35760 | strings to control their behavior. The spec strings built into GCC can | |
35761 | be overridden by using the @option{-specs=} command-line switch to specify | |
35762 | a spec file. | |
35763 | ||
35764 | @dfn{Spec files} are plain-text files that are used to construct spec | |
35765 | strings. They consist of a sequence of directives separated by blank | |
35766 | lines. The type of directive is determined by the first non-whitespace | |
35767 | character on the line, which can be one of the following: | |
35768 | ||
35769 | @table @code | |
35770 | @item %@var{command} | |
35771 | Issues a @var{command} to the spec file processor. The commands that can | |
35772 | appear here are: | |
35773 | ||
35774 | @table @code | |
d77de738 | 35775 | @cindex @code{%include} |
f33d7a88 | 35776 | @item %include <@var{file}> |
d77de738 ML |
35777 | Search for @var{file} and insert its text at the current point in the |
35778 | specs file. | |
35779 | ||
d77de738 | 35780 | @cindex @code{%include_noerr} |
f33d7a88 | 35781 | @item %include_noerr <@var{file}> |
d77de738 ML |
35782 | Just like @samp{%include}, but do not generate an error message if the include |
35783 | file cannot be found. | |
35784 | ||
d77de738 | 35785 | @cindex @code{%rename} |
f33d7a88 | 35786 | @item %rename @var{old_name} @var{new_name} |
d77de738 ML |
35787 | Rename the spec string @var{old_name} to @var{new_name}. |
35788 | ||
35789 | @end table | |
35790 | ||
35791 | @item *[@var{spec_name}]: | |
35792 | This tells the compiler to create, override or delete the named spec | |
35793 | string. All lines after this directive up to the next directive or | |
35794 | blank line are considered to be the text for the spec string. If this | |
35795 | results in an empty string then the spec is deleted. (Or, if the | |
35796 | spec did not exist, then nothing happens.) Otherwise, if the spec | |
35797 | does not currently exist a new spec is created. If the spec does | |
35798 | exist then its contents are overridden by the text of this | |
35799 | directive, unless the first character of that text is the @samp{+} | |
35800 | character, in which case the text is appended to the spec. | |
35801 | ||
35802 | @item [@var{suffix}]: | |
35803 | Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive | |
35804 | and up to the next directive or blank line are considered to make up the | |
35805 | spec string for the indicated suffix. When the compiler encounters an | |
35806 | input file with the named suffix, it processes the spec string in | |
35807 | order to work out how to compile that file. For example: | |
35808 | ||
35809 | @smallexample | |
35810 | .ZZ: | |
35811 | z-compile -input %i | |
35812 | @end smallexample | |
35813 | ||
35814 | This says that any input file whose name ends in @samp{.ZZ} should be | |
35815 | passed to the program @samp{z-compile}, which should be invoked with the | |
35816 | command-line switch @option{-input} and with the result of performing the | |
35817 | @samp{%i} substitution. (See below.) | |
35818 | ||
35819 | As an alternative to providing a spec string, the text following a | |
35820 | suffix directive can be one of the following: | |
35821 | ||
35822 | @table @code | |
35823 | @item @@@var{language} | |
35824 | This says that the suffix is an alias for a known @var{language}. This is | |
35825 | similar to using the @option{-x} command-line switch to GCC to specify a | |
35826 | language explicitly. For example: | |
35827 | ||
35828 | @smallexample | |
35829 | .ZZ: | |
35830 | @@c++ | |
35831 | @end smallexample | |
35832 | ||
35833 | Says that .ZZ files are, in fact, C++ source files. | |
35834 | ||
35835 | @item #@var{name} | |
35836 | This causes an error messages saying: | |
35837 | ||
35838 | @smallexample | |
35839 | @var{name} compiler not installed on this system. | |
35840 | @end smallexample | |
35841 | @end table | |
35842 | ||
35843 | GCC already has an extensive list of suffixes built into it. | |
35844 | This directive adds an entry to the end of the list of suffixes, but | |
35845 | since the list is searched from the end backwards, it is effectively | |
35846 | possible to override earlier entries using this technique. | |
35847 | ||
35848 | @end table | |
35849 | ||
35850 | GCC has the following spec strings built into it. Spec files can | |
35851 | override these strings or create their own. Note that individual | |
35852 | targets can also add their own spec strings to this list. | |
35853 | ||
35854 | @smallexample | |
35855 | asm Options to pass to the assembler | |
35856 | asm_final Options to pass to the assembler post-processor | |
35857 | cpp Options to pass to the C preprocessor | |
35858 | cc1 Options to pass to the C compiler | |
35859 | cc1plus Options to pass to the C++ compiler | |
35860 | endfile Object files to include at the end of the link | |
35861 | link Options to pass to the linker | |
35862 | lib Libraries to include on the command line to the linker | |
35863 | libgcc Decides which GCC support library to pass to the linker | |
35864 | linker Sets the name of the linker | |
35865 | predefines Defines to be passed to the C preprocessor | |
35866 | signed_char Defines to pass to CPP to say whether @code{char} is signed | |
35867 | by default | |
35868 | startfile Object files to include at the start of the link | |
35869 | @end smallexample | |
35870 | ||
35871 | Here is a small example of a spec file: | |
35872 | ||
35873 | @smallexample | |
35874 | %rename lib old_lib | |
35875 | ||
35876 | *lib: | |
35877 | --start-group -lgcc -lc -leval1 --end-group %(old_lib) | |
35878 | @end smallexample | |
35879 | ||
35880 | This example renames the spec called @samp{lib} to @samp{old_lib} and | |
35881 | then overrides the previous definition of @samp{lib} with a new one. | |
35882 | The new definition adds in some extra command-line options before | |
35883 | including the text of the old definition. | |
35884 | ||
35885 | @dfn{Spec strings} are a list of command-line options to be passed to their | |
35886 | corresponding program. In addition, the spec strings can contain | |
35887 | @samp{%}-prefixed sequences to substitute variable text or to | |
35888 | conditionally insert text into the command line. Using these constructs | |
35889 | it is possible to generate quite complex command lines. | |
35890 | ||
35891 | Here is a table of all defined @samp{%}-sequences for spec | |
35892 | strings. Note that spaces are not generated automatically around the | |
35893 | results of expanding these sequences. Therefore you can concatenate them | |
35894 | together or combine them with constant text in a single argument. | |
35895 | ||
35896 | @table @code | |
35897 | @item %% | |
35898 | Substitute one @samp{%} into the program name or argument. | |
35899 | ||
35900 | @item %" | |
35901 | Substitute an empty argument. | |
35902 | ||
35903 | @item %i | |
35904 | Substitute the name of the input file being processed. | |
35905 | ||
35906 | @item %b | |
35907 | Substitute the basename for outputs related with the input file being | |
35908 | processed. This is often the substring up to (and not including) the | |
35909 | last period and not including the directory but, unless %w is active, it | |
35910 | expands to the basename for auxiliary outputs, which may be influenced | |
35911 | by an explicit output name, and by various other options that control | |
35912 | how auxiliary outputs are named. | |
35913 | ||
35914 | @item %B | |
35915 | This is the same as @samp{%b}, but include the file suffix (text after | |
35916 | the last period). Without %w, it expands to the basename for dump | |
35917 | outputs. | |
35918 | ||
35919 | @item %d | |
35920 | Marks the argument containing or following the @samp{%d} as a | |
35921 | temporary file name, so that that file is deleted if GCC exits | |
35922 | successfully. Unlike @samp{%g}, this contributes no text to the | |
35923 | argument. | |
35924 | ||
35925 | @item %g@var{suffix} | |
35926 | Substitute a file name that has suffix @var{suffix} and is chosen | |
35927 | once per compilation, and mark the argument in the same way as | |
35928 | @samp{%d}. To reduce exposure to denial-of-service attacks, the file | |
35929 | name is now chosen in a way that is hard to predict even when previously | |
35930 | chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s} | |
35931 | might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches | |
35932 | the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is | |
35933 | treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g} | |
35934 | was simply substituted with a file name chosen once per compilation, | |
35935 | without regard to any appended suffix (which was therefore treated | |
35936 | just like ordinary text), making such attacks more likely to succeed. | |
35937 | ||
35938 | @item %u@var{suffix} | |
35939 | Like @samp{%g}, but generates a new temporary file name | |
35940 | each time it appears instead of once per compilation. | |
35941 | ||
35942 | @item %U@var{suffix} | |
35943 | Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a | |
35944 | new one if there is no such last file name. In the absence of any | |
35945 | @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share | |
35946 | the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s} | |
35947 | involves the generation of two distinct file names, one | |
35948 | for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was | |
35949 | simply substituted with a file name chosen for the previous @samp{%u}, | |
35950 | without regard to any appended suffix. | |
35951 | ||
35952 | @item %j@var{suffix} | |
35953 | Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is | |
35954 | writable, and if @option{-save-temps} is not used; | |
35955 | otherwise, substitute the name | |
35956 | of a temporary file, just like @samp{%u}. This temporary file is not | |
35957 | meant for communication between processes, but rather as a junk | |
35958 | disposal mechanism. | |
35959 | ||
35960 | @item %|@var{suffix} | |
35961 | @itemx %m@var{suffix} | |
35962 | Like @samp{%g}, except if @option{-pipe} is in effect. In that case | |
35963 | @samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at | |
35964 | all. These are the two most common ways to instruct a program that it | |
35965 | should read from standard input or write to standard output. If you | |
35966 | need something more elaborate you can use an @samp{%@{pipe:@code{X}@}} | |
35967 | construct: see for example @file{gcc/fortran/lang-specs.h}. | |
35968 | ||
35969 | @item %.@var{SUFFIX} | |
35970 | Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args | |
35971 | when it is subsequently output with @samp{%*}. @var{SUFFIX} is | |
35972 | terminated by the next space or %. | |
35973 | ||
35974 | @item %w | |
35975 | Marks the argument containing or following the @samp{%w} as the | |
35976 | designated output file of this compilation. This puts the argument | |
35977 | into the sequence of arguments that @samp{%o} substitutes. | |
35978 | ||
35979 | @item %V | |
35980 | Indicates that this compilation produces no output file. | |
35981 | ||
35982 | @item %o | |
35983 | Substitutes the names of all the output files, with spaces | |
35984 | automatically placed around them. You should write spaces | |
35985 | around the @samp{%o} as well or the results are undefined. | |
35986 | @samp{%o} is for use in the specs for running the linker. | |
35987 | Input files whose names have no recognized suffix are not compiled | |
35988 | at all, but they are included among the output files, so they are | |
35989 | linked. | |
35990 | ||
35991 | @item %O | |
35992 | Substitutes the suffix for object files. Note that this is | |
35993 | handled specially when it immediately follows @samp{%g, %u, or %U}, | |
35994 | because of the need for those to form complete file names. The | |
35995 | handling is such that @samp{%O} is treated exactly as if it had already | |
35996 | been substituted, except that @samp{%g, %u, and %U} do not currently | |
35997 | support additional @var{suffix} characters following @samp{%O} as they do | |
35998 | following, for example, @samp{.o}. | |
35999 | ||
36000 | @item %I | |
36001 | Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}), | |
36002 | @option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}), | |
36003 | @option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options) | |
36004 | and @option{-imultilib} as necessary. | |
36005 | ||
36006 | @item %s | |
36007 | Current argument is the name of a library or startup file of some sort. | |
36008 | Search for that file in a standard list of directories and substitute | |
36009 | the full name found. The current working directory is included in the | |
36010 | list of directories scanned. | |
36011 | ||
36012 | @item %T | |
36013 | Current argument is the name of a linker script. Search for that file | |
36014 | in the current list of directories to scan for libraries. If the file | |
36015 | is located insert a @option{--script} option into the command line | |
36016 | followed by the full path name found. If the file is not found then | |
36017 | generate an error message. Note: the current working directory is not | |
36018 | searched. | |
36019 | ||
36020 | @item %e@var{str} | |
36021 | Print @var{str} as an error message. @var{str} is terminated by a newline. | |
36022 | Use this when inconsistent options are detected. | |
36023 | ||
36024 | @item %n@var{str} | |
36025 | Print @var{str} as a notice. @var{str} is terminated by a newline. | |
36026 | ||
36027 | @item %(@var{name}) | |
36028 | Substitute the contents of spec string @var{name} at this point. | |
36029 | ||
36030 | @item %x@{@var{option}@} | |
36031 | Accumulate an option for @samp{%X}. | |
36032 | ||
36033 | @item %X | |
36034 | Output the accumulated linker options specified by a @samp{%x} spec string. | |
36035 | ||
36036 | @item %Y | |
36037 | Output the accumulated assembler options specified by @option{-Wa}. | |
36038 | ||
36039 | @item %Z | |
36040 | Output the accumulated preprocessor options specified by @option{-Wp}. | |
36041 | ||
36042 | @item %M | |
36043 | Output @code{multilib_os_dir}. | |
36044 | ||
36045 | @item %R | |
36046 | Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}. | |
36047 | ||
36048 | @item %a | |
36049 | Process the @code{asm} spec. This is used to compute the | |
36050 | switches to be passed to the assembler. | |
36051 | ||
36052 | @item %A | |
36053 | Process the @code{asm_final} spec. This is a spec string for | |
36054 | passing switches to an assembler post-processor, if such a program is | |
36055 | needed. | |
36056 | ||
36057 | @item %l | |
36058 | Process the @code{link} spec. This is the spec for computing the | |
36059 | command line passed to the linker. Typically it makes use of the | |
36060 | @samp{%L %G %S %D and %E} sequences. | |
36061 | ||
36062 | @item %D | |
36063 | Dump out a @option{-L} option for each directory that GCC believes might | |
36064 | contain startup files. If the target supports multilibs then the | |
36065 | current multilib directory is prepended to each of these paths. | |
36066 | ||
36067 | @item %L | |
36068 | Process the @code{lib} spec. This is a spec string for deciding which | |
36069 | libraries are included on the command line to the linker. | |
36070 | ||
36071 | @item %G | |
36072 | Process the @code{libgcc} spec. This is a spec string for deciding | |
36073 | which GCC support library is included on the command line to the linker. | |
36074 | ||
36075 | @item %S | |
36076 | Process the @code{startfile} spec. This is a spec for deciding which | |
36077 | object files are the first ones passed to the linker. Typically | |
36078 | this might be a file named @file{crt0.o}. | |
36079 | ||
36080 | @item %E | |
36081 | Process the @code{endfile} spec. This is a spec string that specifies | |
36082 | the last object files that are passed to the linker. | |
36083 | ||
36084 | @item %C | |
36085 | Process the @code{cpp} spec. This is used to construct the arguments | |
36086 | to be passed to the C preprocessor. | |
36087 | ||
36088 | @item %1 | |
36089 | Process the @code{cc1} spec. This is used to construct the options to be | |
36090 | passed to the actual C compiler (@command{cc1}). | |
36091 | ||
36092 | @item %2 | |
36093 | Process the @code{cc1plus} spec. This is used to construct the options to be | |
36094 | passed to the actual C++ compiler (@command{cc1plus}). | |
36095 | ||
36096 | @item %* | |
36097 | Substitute the variable part of a matched option. See below. | |
36098 | Note that each comma in the substituted string is replaced by | |
36099 | a single space. | |
36100 | ||
36101 | @item %<S | |
36102 | Remove all occurrences of @code{-S} from the command line. Note---this | |
36103 | command is position dependent. @samp{%} commands in the spec string | |
36104 | before this one see @code{-S}, @samp{%} commands in the spec string | |
36105 | after this one do not. | |
36106 | ||
36107 | @item %<S* | |
36108 | Similar to @samp{%<S}, but match all switches beginning with @code{-S}. | |
36109 | ||
36110 | @item %>S | |
36111 | Similar to @samp{%<S}, but keep @code{-S} in the GCC command line. | |
36112 | ||
36113 | @item %:@var{function}(@var{args}) | |
36114 | Call the named function @var{function}, passing it @var{args}. | |
36115 | @var{args} is first processed as a nested spec string, then split | |
36116 | into an argument vector in the usual fashion. The function returns | |
36117 | a string which is processed as if it had appeared literally as part | |
36118 | of the current spec. | |
36119 | ||
36120 | The following built-in spec functions are provided: | |
36121 | ||
36122 | @table @code | |
36123 | @item @code{getenv} | |
36124 | The @code{getenv} spec function takes two arguments: an environment | |
36125 | variable name and a string. If the environment variable is not | |
36126 | defined, a fatal error is issued. Otherwise, the return value is the | |
36127 | value of the environment variable concatenated with the string. For | |
36128 | example, if @env{TOPDIR} is defined as @file{/path/to/top}, then: | |
36129 | ||
36130 | @smallexample | |
36131 | %:getenv(TOPDIR /include) | |
36132 | @end smallexample | |
36133 | ||
36134 | expands to @file{/path/to/top/include}. | |
36135 | ||
36136 | @item @code{if-exists} | |
36137 | The @code{if-exists} spec function takes one argument, an absolute | |
36138 | pathname to a file. If the file exists, @code{if-exists} returns the | |
36139 | pathname. Here is a small example of its usage: | |
36140 | ||
36141 | @smallexample | |
36142 | *startfile: | |
36143 | crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s | |
36144 | @end smallexample | |
36145 | ||
36146 | @item @code{if-exists-else} | |
36147 | The @code{if-exists-else} spec function is similar to the @code{if-exists} | |
36148 | spec function, except that it takes two arguments. The first argument is | |
36149 | an absolute pathname to a file. If the file exists, @code{if-exists-else} | |
36150 | returns the pathname. If it does not exist, it returns the second argument. | |
36151 | This way, @code{if-exists-else} can be used to select one file or another, | |
36152 | based on the existence of the first. Here is a small example of its usage: | |
36153 | ||
36154 | @smallexample | |
36155 | *startfile: | |
36156 | crt0%O%s %:if-exists(crti%O%s) \ | |
36157 | %:if-exists-else(crtbeginT%O%s crtbegin%O%s) | |
36158 | @end smallexample | |
36159 | ||
36160 | @item @code{if-exists-then-else} | |
36161 | The @code{if-exists-then-else} spec function takes at least two arguments | |
36162 | and an optional third one. The first argument is an absolute pathname to a | |
36163 | file. If the file exists, the function returns the second argument. | |
36164 | If the file does not exist, the function returns the third argument if there | |
36165 | is one, or NULL otherwise. This can be used to expand one text, or optionally | |
36166 | another, based on the existence of a file. Here is a small example of its | |
36167 | usage: | |
36168 | ||
36169 | @smallexample | |
36170 | -l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net) | |
36171 | @end smallexample | |
36172 | ||
36173 | @item @code{sanitize} | |
36174 | The @code{sanitize} spec function takes no arguments. It returns non-NULL if | |
36175 | any address, thread or undefined behavior sanitizers are active. | |
36176 | ||
36177 | @smallexample | |
36178 | %@{%:sanitize(address):-funwind-tables@} | |
36179 | @end smallexample | |
36180 | ||
36181 | @item @code{replace-outfile} | |
36182 | The @code{replace-outfile} spec function takes two arguments. It looks for the | |
36183 | first argument in the outfiles array and replaces it with the second argument. Here | |
36184 | is a small example of its usage: | |
36185 | ||
36186 | @smallexample | |
36187 | %@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@} | |
36188 | @end smallexample | |
36189 | ||
36190 | @item @code{remove-outfile} | |
36191 | The @code{remove-outfile} spec function takes one argument. It looks for the | |
36192 | first argument in the outfiles array and removes it. Here is a small example | |
36193 | its usage: | |
36194 | ||
36195 | @smallexample | |
36196 | %:remove-outfile(-lm) | |
36197 | @end smallexample | |
36198 | ||
36199 | @item @code{version-compare} | |
36200 | The @code{version-compare} spec function takes four or five arguments of the following | |
36201 | form: | |
36202 | ||
36203 | @smallexample | |
36204 | <comparison-op> <arg1> [<arg2>] <switch> <result> | |
36205 | @end smallexample | |
36206 | ||
36207 | It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't. | |
36208 | The supported @code{comparison-op} values are: | |
36209 | ||
36210 | @table @code | |
36211 | @item >= | |
36212 | True if @code{switch} is a later (or same) version than @code{arg1} | |
36213 | ||
36214 | @item !> | |
36215 | Opposite of @code{>=} | |
36216 | ||
36217 | @item < | |
36218 | True if @code{switch} is an earlier version than @code{arg1} | |
36219 | ||
36220 | @item !< | |
36221 | Opposite of @code{<} | |
36222 | ||
36223 | @item >< | |
36224 | True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2} | |
36225 | ||
36226 | @item <> | |
36227 | True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later | |
36228 | @end table | |
36229 | ||
36230 | If the @code{switch} is not present at all, the condition is false unless the first character | |
36231 | of the @code{comparison-op} is @code{!}. | |
36232 | ||
36233 | @smallexample | |
36234 | %:version-compare(>= 10.3 mmacosx-version-min= -lmx) | |
36235 | @end smallexample | |
36236 | ||
36237 | The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was | |
36238 | passed. | |
36239 | ||
36240 | @item @code{include} | |
36241 | The @code{include} spec function behaves much like @code{%include}, with the advantage | |
36242 | that it can be nested inside a spec and thus be conditionalized. It takes one argument, | |
36243 | the filename, and looks for it in the startfile path. It always returns NULL. | |
36244 | ||
36245 | @smallexample | |
36246 | %@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@} | |
36247 | @end smallexample | |
36248 | ||
36249 | @item @code{pass-through-libs} | |
36250 | The @code{pass-through-libs} spec function takes any number of arguments. It | |
36251 | finds any @option{-l} options and any non-options ending in @file{.a} (which it | |
36252 | assumes are the names of linker input library archive files) and returns a | |
36253 | result containing all the found arguments each prepended by | |
36254 | @option{-plugin-opt=-pass-through=} and joined by spaces. This list is | |
36255 | intended to be passed to the LTO linker plugin. | |
36256 | ||
36257 | @smallexample | |
36258 | %:pass-through-libs(%G %L %G) | |
36259 | @end smallexample | |
36260 | ||
36261 | @item @code{print-asm-header} | |
36262 | The @code{print-asm-header} function takes no arguments and simply | |
36263 | prints a banner like: | |
36264 | ||
36265 | @smallexample | |
36266 | Assembler options | |
36267 | ================= | |
36268 | ||
36269 | Use "-Wa,OPTION" to pass "OPTION" to the assembler. | |
36270 | @end smallexample | |
36271 | ||
36272 | It is used to separate compiler options from assembler options | |
36273 | in the @option{--target-help} output. | |
36274 | ||
36275 | @item @code{gt} | |
36276 | The @code{gt} spec function takes two or more arguments. It returns @code{""} (the | |
36277 | empty string) if the second-to-last argument is greater than the last argument, and NULL | |
36278 | otherwise. The following example inserts the @code{link_gomp} spec if the last | |
36279 | @option{-ftree-parallelize-loops=} option given on the command line is greater than 1: | |
36280 | ||
36281 | @smallexample | |
36282 | %@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@} | |
36283 | @end smallexample | |
36284 | ||
36285 | @item @code{debug-level-gt} | |
36286 | The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the | |
36287 | empty string) if @code{debug_info_level} is greater than the specified number, and NULL | |
36288 | otherwise. | |
36289 | ||
36290 | @smallexample | |
36291 | %@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@} | |
36292 | @end smallexample | |
36293 | @end table | |
36294 | ||
36295 | @item %@{S@} | |
36296 | Substitutes the @code{-S} switch, if that switch is given to GCC@. | |
36297 | If that switch is not specified, this substitutes nothing. Note that | |
36298 | the leading dash is omitted when specifying this option, and it is | |
36299 | automatically inserted if the substitution is performed. Thus the spec | |
36300 | string @samp{%@{foo@}} matches the command-line option @option{-foo} | |
36301 | and outputs the command-line option @option{-foo}. | |
36302 | ||
36303 | @item %W@{S@} | |
36304 | Like %@{@code{S}@} but mark last argument supplied within as a file to be | |
36305 | deleted on failure. | |
36306 | ||
36307 | @item %@@@{S@} | |
36308 | Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes | |
36309 | @code{@@FILE} if an @code{@@file} argument has been supplied. | |
36310 | ||
36311 | @item %@{S*@} | |
36312 | Substitutes all the switches specified to GCC whose names start | |
36313 | with @code{-S}, but which also take an argument. This is used for | |
36314 | switches like @option{-o}, @option{-D}, @option{-I}, etc. | |
36315 | GCC considers @option{-o foo} as being | |
36316 | one switch whose name starts with @samp{o}. %@{o*@} substitutes this | |
36317 | text, including the space. Thus two arguments are generated. | |
36318 | ||
36319 | @item %@{S*&T*@} | |
36320 | Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options | |
36321 | (the order of @code{S} and @code{T} in the spec is not significant). | |
36322 | There can be any number of ampersand-separated variables; for each the | |
36323 | wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}. | |
36324 | ||
36325 | @item %@{S:X@} | |
36326 | Substitutes @code{X}, if the @option{-S} switch is given to GCC@. | |
36327 | ||
36328 | @item %@{!S:X@} | |
36329 | Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@. | |
36330 | ||
36331 | @item %@{S*:X@} | |
36332 | Substitutes @code{X} if one or more switches whose names start with | |
36333 | @code{-S} are specified to GCC@. Normally @code{X} is substituted only | |
36334 | once, no matter how many such switches appeared. However, if @code{%*} | |
36335 | appears somewhere in @code{X}, then @code{X} is substituted once | |
36336 | for each matching switch, with the @code{%*} replaced by the part of | |
36337 | that switch matching the @code{*}. | |
36338 | ||
36339 | If @code{%*} appears as the last part of a spec sequence then a space | |
36340 | is added after the end of the last substitution. If there is more | |
36341 | text in the sequence, however, then a space is not generated. This | |
36342 | allows the @code{%*} substitution to be used as part of a larger | |
36343 | string. For example, a spec string like this: | |
36344 | ||
36345 | @smallexample | |
36346 | %@{mcu=*:--script=%*/memory.ld@} | |
36347 | @end smallexample | |
36348 | ||
36349 | @noindent | |
36350 | when matching an option like @option{-mcu=newchip} produces: | |
36351 | ||
36352 | @smallexample | |
36353 | --script=newchip/memory.ld | |
36354 | @end smallexample | |
36355 | ||
36356 | @item %@{.S:X@} | |
36357 | Substitutes @code{X}, if processing a file with suffix @code{S}. | |
36358 | ||
36359 | @item %@{!.S:X@} | |
36360 | Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}. | |
36361 | ||
36362 | @item %@{,S:X@} | |
36363 | Substitutes @code{X}, if processing a file for language @code{S}. | |
36364 | ||
36365 | @item %@{!,S:X@} | |
36366 | Substitutes @code{X}, if not processing a file for language @code{S}. | |
36367 | ||
36368 | @item %@{S|P:X@} | |
36369 | Substitutes @code{X} if either @code{-S} or @code{-P} is given to | |
36370 | GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and | |
36371 | @code{*} sequences as well, although they have a stronger binding than | |
36372 | the @samp{|}. If @code{%*} appears in @code{X}, all of the | |
36373 | alternatives must be starred, and only the first matching alternative | |
36374 | is substituted. | |
36375 | ||
36376 | For example, a spec string like this: | |
36377 | ||
36378 | @smallexample | |
36379 | %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@} | |
36380 | @end smallexample | |
36381 | ||
36382 | @noindent | |
36383 | outputs the following command-line options from the following input | |
36384 | command-line options: | |
36385 | ||
36386 | @smallexample | |
36387 | fred.c -foo -baz | |
36388 | jim.d -bar -boggle | |
36389 | -d fred.c -foo -baz -boggle | |
36390 | -d jim.d -bar -baz -boggle | |
36391 | @end smallexample | |
36392 | ||
36393 | @item %@{%:@var{function}(@var{args}):X@} | |
36394 | ||
36395 | Call function named @var{function} with args @var{args}. If the | |
36396 | function returns non-NULL, then @code{X} is substituted, if it returns | |
36397 | NULL, it isn't substituted. | |
36398 | ||
36399 | @item %@{S:X; T:Y; :D@} | |
36400 | ||
36401 | If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is | |
36402 | given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can | |
36403 | be as many clauses as you need. This may be combined with @code{.}, | |
36404 | @code{,}, @code{!}, @code{|}, and @code{*} as needed. | |
36405 | ||
36406 | ||
36407 | @end table | |
36408 | ||
36409 | The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}} | |
36410 | or similar construct can use a backslash to ignore the special meaning | |
36411 | of the character following it, thus allowing literal matching of a | |
36412 | character that is otherwise specially treated. For example, | |
36413 | @samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the | |
36414 | @option{-std=iso9899:1999} option is given. | |
36415 | ||
36416 | The conditional text @code{X} in a @samp{%@{S:X@}} or similar | |
36417 | construct may contain other nested @samp{%} constructs or spaces, or | |
36418 | even newlines. They are processed as usual, as described above. | |
36419 | Trailing white space in @code{X} is ignored. White space may also | |
36420 | appear anywhere on the left side of the colon in these constructs, | |
36421 | except between @code{.} or @code{*} and the corresponding word. | |
36422 | ||
36423 | The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are | |
36424 | handled specifically in these constructs. If another value of | |
36425 | @option{-O} or the negated form of a @option{-f}, @option{-m}, or | |
36426 | @option{-W} switch is found later in the command line, the earlier | |
36427 | switch value is ignored, except with @{@code{S}*@} where @code{S} is | |
36428 | just one letter, which passes all matching options. | |
36429 | ||
36430 | The character @samp{|} at the beginning of the predicate text is used to | |
36431 | indicate that a command should be piped to the following command, but | |
36432 | only if @option{-pipe} is specified. | |
36433 | ||
36434 | It is built into GCC which switches take arguments and which do not. | |
36435 | (You might think it would be useful to generalize this to allow each | |
36436 | compiler's spec to say which switches take arguments. But this cannot | |
36437 | be done in a consistent fashion. GCC cannot even decide which input | |
36438 | files have been specified without knowing which switches take arguments, | |
36439 | and it must know which input files to compile in order to tell which | |
36440 | compilers to run). | |
36441 | ||
36442 | GCC also knows implicitly that arguments starting in @option{-l} are to be | |
36443 | treated as compiler output files, and passed to the linker in their | |
36444 | proper position among the other output files. | |
36445 | ||
36446 | @node Environment Variables | |
36447 | @section Environment Variables Affecting GCC | |
36448 | @cindex environment variables | |
36449 | ||
36450 | @c man begin ENVIRONMENT | |
36451 | This section describes several environment variables that affect how GCC | |
36452 | operates. Some of them work by specifying directories or prefixes to use | |
36453 | when searching for various kinds of files. Some are used to specify other | |
36454 | aspects of the compilation environment. | |
36455 | ||
36456 | Note that you can also specify places to search using options such as | |
36457 | @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These | |
36458 | take precedence over places specified using environment variables, which | |
36459 | in turn take precedence over those specified by the configuration of GCC@. | |
36460 | @xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint, | |
36461 | GNU Compiler Collection (GCC) Internals}. | |
36462 | ||
36463 | @table @env | |
f33d7a88 AA |
36464 | @vindex LANG |
36465 | @vindex LC_CTYPE | |
36466 | @c @vindex LC_COLLATE | |
36467 | @vindex LC_MESSAGES | |
36468 | @c @vindex LC_MONETARY | |
36469 | @c @vindex LC_NUMERIC | |
36470 | @c @vindex LC_TIME | |
36471 | @vindex LC_ALL | |
36472 | @cindex locale | |
d77de738 ML |
36473 | @item LANG |
36474 | @itemx LC_CTYPE | |
36475 | @c @itemx LC_COLLATE | |
36476 | @itemx LC_MESSAGES | |
36477 | @c @itemx LC_MONETARY | |
36478 | @c @itemx LC_NUMERIC | |
36479 | @c @itemx LC_TIME | |
36480 | @itemx LC_ALL | |
d77de738 ML |
36481 | These environment variables control the way that GCC uses |
36482 | localization information which allows GCC to work with different | |
36483 | national conventions. GCC inspects the locale categories | |
36484 | @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do | |
36485 | so. These locale categories can be set to any value supported by your | |
36486 | installation. A typical value is @samp{en_GB.UTF-8} for English in the United | |
36487 | Kingdom encoded in UTF-8. | |
36488 | ||
36489 | The @env{LC_CTYPE} environment variable specifies character | |
36490 | classification. GCC uses it to determine the character boundaries in | |
36491 | a string; this is needed for some multibyte encodings that contain quote | |
36492 | and escape characters that are otherwise interpreted as a string | |
36493 | end or escape. | |
36494 | ||
36495 | The @env{LC_MESSAGES} environment variable specifies the language to | |
36496 | use in diagnostic messages. | |
36497 | ||
36498 | If the @env{LC_ALL} environment variable is set, it overrides the value | |
36499 | of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE} | |
36500 | and @env{LC_MESSAGES} default to the value of the @env{LANG} | |
36501 | environment variable. If none of these variables are set, GCC | |
36502 | defaults to traditional C English behavior. | |
36503 | ||
f33d7a88 | 36504 | @vindex TMPDIR |
d77de738 | 36505 | @item TMPDIR |
d77de738 ML |
36506 | If @env{TMPDIR} is set, it specifies the directory to use for temporary |
36507 | files. GCC uses temporary files to hold the output of one stage of | |
36508 | compilation which is to be used as input to the next stage: for example, | |
36509 | the output of the preprocessor, which is the input to the compiler | |
36510 | proper. | |
36511 | ||
f33d7a88 | 36512 | @vindex GCC_COMPARE_DEBUG |
d77de738 | 36513 | @item GCC_COMPARE_DEBUG |
d77de738 ML |
36514 | Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing |
36515 | @option{-fcompare-debug} to the compiler driver. See the documentation | |
36516 | of this option for more details. | |
36517 | ||
f33d7a88 | 36518 | @vindex GCC_EXEC_PREFIX |
d77de738 | 36519 | @item GCC_EXEC_PREFIX |
d77de738 ML |
36520 | If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the |
36521 | names of the subprograms executed by the compiler. No slash is added | |
36522 | when this prefix is combined with the name of a subprogram, but you can | |
36523 | specify a prefix that ends with a slash if you wish. | |
36524 | ||
36525 | If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out | |
36526 | an appropriate prefix to use based on the pathname it is invoked with. | |
36527 | ||
36528 | If GCC cannot find the subprogram using the specified prefix, it | |
36529 | tries looking in the usual places for the subprogram. | |
36530 | ||
36531 | The default value of @env{GCC_EXEC_PREFIX} is | |
36532 | @file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to | |
36533 | the installed compiler. In many cases @var{prefix} is the value | |
36534 | of @code{prefix} when you ran the @file{configure} script. | |
36535 | ||
36536 | Other prefixes specified with @option{-B} take precedence over this prefix. | |
36537 | ||
36538 | This prefix is also used for finding files such as @file{crt0.o} that are | |
36539 | used for linking. | |
36540 | ||
36541 | In addition, the prefix is used in an unusual way in finding the | |
36542 | directories to search for header files. For each of the standard | |
36543 | directories whose name normally begins with @samp{/usr/local/lib/gcc} | |
36544 | (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries | |
36545 | replacing that beginning with the specified prefix to produce an | |
36546 | alternate directory name. Thus, with @option{-Bfoo/}, GCC searches | |
36547 | @file{foo/bar} just before it searches the standard directory | |
36548 | @file{/usr/local/lib/bar}. | |
36549 | If a standard directory begins with the configured | |
36550 | @var{prefix} then the value of @var{prefix} is replaced by | |
36551 | @env{GCC_EXEC_PREFIX} when looking for header files. | |
36552 | ||
f33d7a88 | 36553 | @vindex COMPILER_PATH |
d77de738 | 36554 | @item COMPILER_PATH |
d77de738 ML |
36555 | The value of @env{COMPILER_PATH} is a colon-separated list of |
36556 | directories, much like @env{PATH}. GCC tries the directories thus | |
36557 | specified when searching for subprograms, if it cannot find the | |
36558 | subprograms using @env{GCC_EXEC_PREFIX}. | |
36559 | ||
f33d7a88 | 36560 | @vindex LIBRARY_PATH |
d77de738 | 36561 | @item LIBRARY_PATH |
d77de738 ML |
36562 | The value of @env{LIBRARY_PATH} is a colon-separated list of |
36563 | directories, much like @env{PATH}. When configured as a native compiler, | |
36564 | GCC tries the directories thus specified when searching for special | |
36565 | linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking | |
36566 | using GCC also uses these directories when searching for ordinary | |
36567 | libraries for the @option{-l} option (but directories specified with | |
36568 | @option{-L} come first). | |
36569 | ||
f33d7a88 | 36570 | @vindex LANG |
d77de738 | 36571 | @cindex locale definition |
f33d7a88 | 36572 | @item LANG |
d77de738 ML |
36573 | This variable is used to pass locale information to the compiler. One way in |
36574 | which this information is used is to determine the character set to be used | |
36575 | when character literals, string literals and comments are parsed in C and C++. | |
36576 | When the compiler is configured to allow multibyte characters, | |
36577 | the following values for @env{LANG} are recognized: | |
36578 | ||
36579 | @table @samp | |
36580 | @item C-JIS | |
36581 | Recognize JIS characters. | |
36582 | @item C-SJIS | |
36583 | Recognize SJIS characters. | |
36584 | @item C-EUCJP | |
36585 | Recognize EUCJP characters. | |
36586 | @end table | |
36587 | ||
36588 | If @env{LANG} is not defined, or if it has some other value, then the | |
36589 | compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to | |
36590 | recognize and translate multibyte characters. | |
36591 | ||
f33d7a88 | 36592 | @vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT |
d77de738 | 36593 | @item GCC_EXTRA_DIAGNOSTIC_OUTPUT |
d77de738 ML |
36594 | If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values, |
36595 | then additional text will be emitted to stderr when fix-it hints are | |
36596 | emitted. @option{-fdiagnostics-parseable-fixits} and | |
36597 | @option{-fno-diagnostics-parseable-fixits} take precedence over this | |
36598 | environment variable. | |
36599 | ||
36600 | @table @samp | |
36601 | @item fixits-v1 | |
36602 | Emit parseable fix-it hints, equivalent to | |
36603 | @option{-fdiagnostics-parseable-fixits}. In particular, columns are | |
36604 | expressed as a count of bytes, starting at byte 1 for the initial column. | |
36605 | ||
36606 | @item fixits-v2 | |
36607 | As @code{fixits-v1}, but columns are expressed as display columns, | |
36608 | as per @option{-fdiagnostics-column-unit=display}. | |
36609 | @end table | |
36610 | ||
36611 | @end table | |
36612 | ||
36613 | @noindent | |
36614 | Some additional environment variables affect the behavior of the | |
36615 | preprocessor. | |
36616 | ||
36617 | @include cppenv.texi | |
36618 | ||
36619 | @c man end | |
36620 | ||
36621 | @node Precompiled Headers | |
36622 | @section Using Precompiled Headers | |
36623 | @cindex precompiled headers | |
36624 | @cindex speed of compilation | |
36625 | ||
36626 | Often large projects have many header files that are included in every | |
36627 | source file. The time the compiler takes to process these header files | |
36628 | over and over again can account for nearly all of the time required to | |
36629 | build the project. To make builds faster, GCC allows you to | |
36630 | @dfn{precompile} a header file. | |
36631 | ||
36632 | To create a precompiled header file, simply compile it as you would any | |
36633 | other file, if necessary using the @option{-x} option to make the driver | |
36634 | treat it as a C or C++ header file. You may want to use a | |
36635 | tool like @command{make} to keep the precompiled header up-to-date when | |
36636 | the headers it contains change. | |
36637 | ||
36638 | A precompiled header file is searched for when @code{#include} is | |
36639 | seen in the compilation. As it searches for the included file | |
36640 | (@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the | |
36641 | compiler looks for a precompiled header in each directory just before it | |
36642 | looks for the include file in that directory. The name searched for is | |
36643 | the name specified in the @code{#include} with @samp{.gch} appended. If | |
36644 | the precompiled header file cannot be used, it is ignored. | |
36645 | ||
36646 | For instance, if you have @code{#include "all.h"}, and you have | |
36647 | @file{all.h.gch} in the same directory as @file{all.h}, then the | |
36648 | precompiled header file is used if possible, and the original | |
36649 | header is used otherwise. | |
36650 | ||
36651 | Alternatively, you might decide to put the precompiled header file in a | |
36652 | directory and use @option{-I} to ensure that directory is searched | |
36653 | before (or instead of) the directory containing the original header. | |
36654 | Then, if you want to check that the precompiled header file is always | |
36655 | used, you can put a file of the same name as the original header in this | |
36656 | directory containing an @code{#error} command. | |
36657 | ||
36658 | This also works with @option{-include}. So yet another way to use | |
36659 | precompiled headers, good for projects not designed with precompiled | |
36660 | header files in mind, is to simply take most of the header files used by | |
36661 | a project, include them from another header file, precompile that header | |
36662 | file, and @option{-include} the precompiled header. If the header files | |
36663 | have guards against multiple inclusion, they are skipped because | |
36664 | they've already been included (in the precompiled header). | |
36665 | ||
36666 | If you need to precompile the same header file for different | |
36667 | languages, targets, or compiler options, you can instead make a | |
36668 | @emph{directory} named like @file{all.h.gch}, and put each precompiled | |
36669 | header in the directory, perhaps using @option{-o}. It doesn't matter | |
36670 | what you call the files in the directory; every precompiled header in | |
36671 | the directory is considered. The first precompiled header | |
36672 | encountered in the directory that is valid for this compilation is | |
36673 | used; they're searched in no particular order. | |
36674 | ||
36675 | There are many other possibilities, limited only by your imagination, | |
36676 | good sense, and the constraints of your build system. | |
36677 | ||
36678 | A precompiled header file can be used only when these conditions apply: | |
36679 | ||
36680 | @itemize | |
36681 | @item | |
36682 | Only one precompiled header can be used in a particular compilation. | |
36683 | ||
36684 | @item | |
36685 | A precompiled header cannot be used once the first C token is seen. You | |
36686 | can have preprocessor directives before a precompiled header; you cannot | |
36687 | include a precompiled header from inside another header. | |
36688 | ||
36689 | @item | |
36690 | The precompiled header file must be produced for the same language as | |
36691 | the current compilation. You cannot use a C precompiled header for a C++ | |
36692 | compilation. | |
36693 | ||
36694 | @item | |
36695 | The precompiled header file must have been produced by the same compiler | |
36696 | binary as the current compilation is using. | |
36697 | ||
36698 | @item | |
36699 | Any macros defined before the precompiled header is included must | |
36700 | either be defined in the same way as when the precompiled header was | |
36701 | generated, or must not affect the precompiled header, which usually | |
36702 | means that they don't appear in the precompiled header at all. | |
36703 | ||
36704 | The @option{-D} option is one way to define a macro before a | |
36705 | precompiled header is included; using a @code{#define} can also do it. | |
36706 | There are also some options that define macros implicitly, like | |
36707 | @option{-O} and @option{-Wdeprecated}; the same rule applies to macros | |
36708 | defined this way. | |
36709 | ||
36710 | @item If debugging information is output when using the precompiled | |
36711 | header, using @option{-g} or similar, the same kind of debugging information | |
36712 | must have been output when building the precompiled header. However, | |
36713 | a precompiled header built using @option{-g} can be used in a compilation | |
36714 | when no debugging information is being output. | |
36715 | ||
36716 | @item The same @option{-m} options must generally be used when building | |
36717 | and using the precompiled header. @xref{Submodel Options}, | |
36718 | for any cases where this rule is relaxed. | |
36719 | ||
36720 | @item Each of the following options must be the same when building and using | |
36721 | the precompiled header: | |
36722 | ||
36723 | @gccoptlist{-fexceptions} | |
36724 | ||
36725 | @item | |
36726 | Some other command-line options starting with @option{-f}, | |
36727 | @option{-p}, or @option{-O} must be defined in the same way as when | |
36728 | the precompiled header was generated. At present, it's not clear | |
36729 | which options are safe to change and which are not; the safest choice | |
36730 | is to use exactly the same options when generating and using the | |
36731 | precompiled header. The following are known to be safe: | |
36732 | ||
43b72ede AA |
36733 | @gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock |
36734 | -fsched-spec -fsched-spec-load -fsched-spec-load-dangerous | |
36735 | -fsched-verbose=@var{number} -fschedule-insns -fvisibility= | |
d77de738 ML |
36736 | -pedantic-errors} |
36737 | ||
36738 | @item Address space layout randomization (ASLR) can lead to not binary identical | |
36739 | PCH files. If you rely on stable PCH file contents disable ASLR when generating | |
36740 | PCH files. | |
36741 | ||
36742 | @end itemize | |
36743 | ||
36744 | For all of these except the last, the compiler automatically | |
36745 | ignores the precompiled header if the conditions aren't met. If you | |
36746 | find an option combination that doesn't work and doesn't cause the | |
36747 | precompiled header to be ignored, please consider filing a bug report, | |
36748 | see @ref{Bugs}. | |
36749 | ||
36750 | If you do use differing options when generating and using the | |
36751 | precompiled header, the actual behavior is a mixture of the | |
36752 | behavior for the options. For instance, if you use @option{-g} to | |
36753 | generate the precompiled header but not when using it, you may or may | |
36754 | not get debugging information for routines in the precompiled header. | |
36755 | ||
36756 | @node C++ Modules | |
36757 | @section C++ Modules | |
36758 | @cindex speed of compilation | |
36759 | ||
36760 | Modules are a C++20 language feature. As the name suggests, they | |
36761 | provides a modular compilation system, intending to provide both | |
36762 | faster builds and better library isolation. The ``Merging Modules'' | |
36763 | paper @uref{https://wg21.link/p1103}, provides the easiest to read set | |
36764 | of changes to the standard, although it does not capture later | |
36765 | changes. | |
36766 | ||
36767 | @emph{G++'s modules support is not complete.} Other than bugs, the | |
36768 | known missing pieces are: | |
36769 | ||
36770 | @table @emph | |
36771 | ||
36772 | @item Private Module Fragment | |
36773 | The Private Module Fragment is recognized, but an error is emitted. | |
36774 | ||
36775 | @item Partition definition visibility rules | |
36776 | Entities may be defined in implementation partitions, and those | |
36777 | definitions are not available outside of the module. This is not | |
36778 | implemented, and the definitions are available to extra-module use. | |
36779 | ||
36780 | @item Textual merging of reachable GM entities | |
36781 | Entities may be multiply defined across different header-units. | |
36782 | These must be de-duplicated, and this is implemented across imports, | |
36783 | or when an import redefines a textually-defined entity. However the | |
36784 | reverse is not implemented---textually redefining an entity that has | |
36785 | been defined in an imported header-unit. A redefinition error is | |
36786 | emitted. | |
36787 | ||
36788 | @item Translation-Unit local referencing rules | |
36789 | Papers p1815 (@uref{https://wg21.link/p1815}) and p2003 | |
36790 | (@uref{https://wg21.link/p2003}) add limitations on which entities an | |
36791 | exported region may reference (for instance, the entities an exported | |
36792 | template definition may reference). These are not fully implemented. | |
36793 | ||
36794 | @item Standard Library Header Units | |
36795 | The Standard Library is not provided as importable header units. If | |
36796 | you want to import such units, you must explicitly build them first. | |
36797 | If you do not do this with care, you may have multiple declarations, | |
36798 | which the module machinery must merge---compiler resource usage can be | |
36799 | affected by how you partition header files into header units. | |
36800 | ||
36801 | @end table | |
36802 | ||
36803 | Modular compilation is @emph{not} enabled with just the | |
36804 | @option{-std=c++20} option. You must explicitly enable it with the | |
36805 | @option{-fmodules-ts} option. It is independent of the language | |
36806 | version selected, although in pre-C++20 versions, it is of course an | |
36807 | extension. | |
36808 | ||
36809 | No new source file suffixes are required or supported. If you wish to | |
36810 | use a non-standard suffix (@pxref{Overall Options}), you also need | |
36811 | to provide a @option{-x c++} option too.@footnote{Some users like to | |
36812 | distinguish module interface files with a new suffix, such as naming | |
36813 | the source @code{module.cppm}, which involves | |
36814 | teaching all tools about the new suffix. A different scheme, such as | |
36815 | naming @code{module-m.cpp} would be less invasive.} | |
36816 | ||
36817 | Compiling a module interface unit produces an additional output (to | |
36818 | the assembly or object file), called a Compiled Module Interface | |
36819 | (CMI). This encodes the exported declarations of the module. | |
36820 | Importing a module reads in the CMI. The import graph is a Directed | |
36821 | Acyclic Graph (DAG). You must build imports before the importer. | |
36822 | ||
36823 | Header files may themselves be compiled to header units, which are a | |
36824 | transitional ability aiming at faster compilation. The | |
36825 | @option{-fmodule-header} option is used to enable this, and implies | |
36826 | the @option{-fmodules-ts} option. These CMIs are named by the fully | |
36827 | resolved underlying header file, and thus may be a complete pathname | |
36828 | containing subdirectories. If the header file is found at an absolute | |
36829 | pathname, the CMI location is still relative to a CMI root directory. | |
36830 | ||
36831 | As header files often have no suffix, you commonly have to specify a | |
36832 | @option{-x} option to tell the compiler the source is a header file. | |
36833 | You may use @option{-x c++-header}, @option{-x c++-user-header} or | |
36834 | @option{-x c++-system-header}. When used in conjunction with | |
36835 | @option{-fmodules-ts}, these all imply an appropriate | |
36836 | @option{-fmodule-header} option. The latter two variants use the | |
36837 | user or system include path to search for the file specified. This | |
36838 | allows you to, for instance, compile standard library header files as | |
36839 | header units, without needing to know exactly where they are | |
36840 | installed. Specifying the language as one of these variants also | |
36841 | inhibits output of the object file, as header files have no associated | |
36842 | object file. | |
36843 | ||
36844 | The @option{-fmodule-only} option disables generation of the | |
36845 | associated object file for compiling a module interface. Only the CMI | |
36846 | is generated. This option is implied when using the | |
36847 | @option{-fmodule-header} option. | |
36848 | ||
36849 | The @option{-flang-info-include-translate} and | |
36850 | @option{-flang-info-include-translate-not} options notes whether | |
36851 | include translation occurs or not. With no argument, the first will | |
36852 | note all include translation. The second will note all | |
36853 | non-translations of include files not known to intentionally be | |
36854 | textual. With an argument, queries about include translation of a | |
36855 | header files with that particular trailing pathname are noted. You | |
36856 | may repeat this form to cover several different header files. This | |
36857 | option may be helpful in determining whether include translation is | |
36858 | happening---if it is working correctly, it behaves as if it isn't | |
36859 | there at all. | |
36860 | ||
36861 | The @option{-flang-info-module-cmi} option can be used to determine | |
36862 | where the compiler is reading a CMI from. Without the option, the | |
36863 | compiler is silent when such a read is successful. This option has an | |
36864 | optional argument, which will restrict the notification to just the | |
36865 | set of named modules or header units specified. | |
36866 | ||
36867 | The @option{-Winvalid-imported-macros} option causes all imported macros | |
36868 | to be resolved at the end of compilation. Without this, imported | |
36869 | macros are only resolved when expanded or (re)defined. This option | |
36870 | detects conflicting import definitions for all macros. | |
36871 | ||
36872 | For details of the @option{-fmodule-mapper} family of options, | |
36873 | @pxref{C++ Module Mapper}. | |
36874 | ||
36875 | @menu | |
36876 | * C++ Module Mapper:: Module Mapper | |
36877 | * C++ Module Preprocessing:: Module Preprocessing | |
36878 | * C++ Compiled Module Interface:: Compiled Module Interface | |
36879 | @end menu | |
36880 | ||
36881 | @node C++ Module Mapper | |
36882 | @subsection Module Mapper | |
36883 | @cindex C++ Module Mapper | |
36884 | ||
36885 | A module mapper provides a server or file that the compiler queries to | |
36886 | determine the mapping between module names and CMI files. It is also | |
36887 | used to build CMIs on demand. @emph{Mapper functionality is in its | |
36888 | infancy and is intended for experimentation with build system | |
36889 | interactions.} | |
36890 | ||
36891 | You can specify a mapper with the @option{-fmodule-mapper=@var{val}} | |
36892 | option or @env{CXX_MODULE_MAPPER} environment variable. The value may | |
36893 | have one of the following forms: | |
36894 | ||
36895 | @table @gcctabopt | |
36896 | ||
36897 | @item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]} | |
36898 | An optional hostname and a numeric port number to connect to. If the | |
36899 | hostname is omitted, the loopback address is used. If the hostname | |
36900 | corresponds to multiple IPV6 addresses, these are tried in turn, until | |
36901 | one is successful. If your host lacks IPv6, this form is | |
36902 | non-functional. If you must use IPv4 use | |
36903 | @option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}. | |
36904 | ||
36905 | @item =@var{socket}@r{[}?@var{ident}@r{]} | |
36906 | A local domain socket. If your host lacks local domain sockets, this | |
36907 | form is non-functional. | |
36908 | ||
36909 | @item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]} | |
36910 | A program to spawn, and communicate with on its stdin/stdout streams. | |
36911 | Your @var{PATH} environment variable is searched for the program. | |
36912 | Arguments are separated by space characters, (it is not possible for | |
36913 | one of the arguments delivered to the program to contain a space). An | |
36914 | exception is if @var{program} begins with @@. In that case | |
36915 | @var{program} (sans @@) is looked for in the compiler's internal | |
36916 | binary directory. Thus the sample mapper-server can be specified | |
36917 | with @code{@@g++-mapper-server}. | |
36918 | ||
36919 | @item <>@r{[}?@var{ident}@r{]} | |
36920 | @item <>@var{inout}@r{[}?@var{ident}@r{]} | |
36921 | @item <@var{in}>@var{out}@r{[}?@var{ident}@r{]} | |
36922 | Named pipes or file descriptors to communicate over. The first form, | |
36923 | @option{<>}, communicates over stdin and stdout. The other forms | |
36924 | allow you to specify a file descriptor or name a pipe. A numeric value | |
36925 | is interpreted as a file descriptor, otherwise named pipe is opened. | |
36926 | The second form specifies a bidirectional pipe and the last form | |
36927 | allows specifying two independent pipes. Using file descriptors | |
36928 | directly in this manner is fragile in general, as it can require the | |
36929 | cooperation of intermediate processes. In particular using stdin & | |
36930 | stdout is fraught with danger as other compiler options might also | |
36931 | cause the compiler to read stdin or write stdout, and it can have | |
36932 | unfortunate interactions with signal delivery from the terminal. | |
36933 | ||
36934 | @item @var{file}@r{[}?@var{ident}@r{]} | |
36935 | A mapping file consisting of space-separated module-name, filename | |
36936 | pairs, one per line. Only the mappings for the direct imports and any | |
36937 | module export name need be provided. If other mappings are provided, | |
36938 | they override those stored in any imported CMI files. A repository | |
36939 | root may be specified in the mapping file by using @samp{$root} as the | |
36940 | module name in the first active line. Use of this option will disable | |
36941 | any default module->CMI name mapping. | |
36942 | ||
36943 | @end table | |
36944 | ||
36945 | As shown, an optional @var{ident} may suffix the first word of the | |
36946 | option, indicated by a @samp{?} prefix. The value is used in the | |
36947 | initial handshake with the module server, or to specify a prefix on | |
36948 | mapping file lines. In the server case, the main source file name is | |
36949 | used if no @var{ident} is specified. In the file case, all non-blank | |
36950 | lines are significant, unless a value is specified, in which case only | |
36951 | lines beginning with @var{ident} are significant. The @var{ident} | |
36952 | must be separated by whitespace from the module name. Be aware that | |
36953 | @samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often | |
36954 | significant to the shell, and therefore may need quoting. | |
36955 | ||
36956 | The mapper is connected to or loaded lazily, when the first module | |
36957 | mapping is required. The networking protocols are only supported on | |
36958 | hosts that provide networking. If no mapper is specified a default is | |
36959 | provided. | |
36960 | ||
36961 | A project-specific mapper is expected to be provided by the build | |
36962 | system that invokes the compiler. It is not expected that a | |
36963 | general-purpose server is provided for all compilations. As such, the | |
36964 | server will know the build configuration, the compiler it invoked, and | |
36965 | the environment (such as working directory) in which that is | |
36966 | operating. As it may parallelize builds, several compilations may | |
36967 | connect to the same socket. | |
36968 | ||
36969 | The default mapper generates CMI files in a @samp{gcm.cache} | |
36970 | directory. CMI files have a @samp{.gcm} suffix. The module unit name | |
36971 | is used directly to provide the basename. Header units construct a | |
36972 | relative path using the underlying header file name. If the path is | |
36973 | already relative, a @samp{,} directory is prepended. Internal | |
36974 | @samp{..} components are translated to @samp{,,}. No attempt is made | |
36975 | to canonicalize these filenames beyond that done by the preprocessor's | |
36976 | include search algorithm, as in general it is ambiguous when symbolic | |
36977 | links are present. | |
36978 | ||
36979 | The mapper protocol was published as ``A Module Mapper'' | |
36980 | @uref{https://wg21.link/p1184}. The implementation is provided by | |
36981 | @command{libcody}, @uref{https://github.com/urnathan/libcody}, | |
36982 | which specifies the canonical protocol definition. A proof of concept | |
36983 | server implementation embedded in @command{make} was described in | |
36984 | ''Make Me A Module'', @uref{https://wg21.link/p1602}. | |
36985 | ||
36986 | @node C++ Module Preprocessing | |
36987 | @subsection Module Preprocessing | |
36988 | @cindex C++ Module Preprocessing | |
36989 | ||
36990 | Modules affect preprocessing because of header units and include | |
36991 | translation. Some uses of the preprocessor as a separate step either | |
36992 | do not produce a correct output, or require CMIs to be available. | |
36993 | ||
36994 | Header units import macros. These macros can affect later conditional | |
36995 | inclusion, which therefore can cascade to differing import sets. When | |
36996 | preprocessing, it is necessary to load the CMI. If a header unit is | |
36997 | unavailable, the preprocessor issues a warning and continue (when | |
36998 | not just preprocessing, an error is emitted). Detecting such imports | |
36999 | requires preprocessor tokenization of the input stream to phase 4 | |
37000 | (macro expansion). | |
37001 | ||
37002 | Include translation converts @code{#include}, @code{#include_next} and | |
37003 | @code{#import} directives to internal @code{import} declarations. | |
37004 | Whether a particular directive is translated is controlled by the | |
37005 | module mapper. Header unit names are canonicalized during | |
37006 | preprocessing. | |
37007 | ||
37008 | Dependency information can be emitted for macro import, extending the | |
37009 | functionality of @option{-MD} and @option{-MMD} options. Detection of | |
37010 | import declarations also requires phase 4 preprocessing, and thus | |
37011 | requires full preprocessing (or compilation). | |
37012 | ||
37013 | The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt | |
37014 | preprocessing before phase 4. | |
37015 | ||
37016 | The @option{-save-temps} option uses @option{-fdirectives-only} for | |
37017 | preprocessing, and preserve the macro definitions in the preprocessed | |
37018 | output. Usually you also want to use this option when explicitly | |
37019 | preprocessing a header-unit, or consuming such preprocessed output: | |
37020 | ||
37021 | @smallexample | |
37022 | g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii | |
37023 | g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii | |
37024 | @end smallexample | |
37025 | ||
37026 | @node C++ Compiled Module Interface | |
37027 | @subsection Compiled Module Interface | |
37028 | @cindex C++ Compiled Module Interface | |
37029 | ||
37030 | CMIs are an additional artifact when compiling named module | |
37031 | interfaces, partitions or header units. These are read when | |
37032 | importing. CMI contents are implementation-specific, and in GCC's | |
37033 | case tied to the compiler version. Consider them a rebuildable cache | |
37034 | artifact, not a distributable object. | |
37035 | ||
37036 | When creating an output CMI, any missing directory components are | |
37037 | created in a manner that is safe for concurrent builds creating | |
37038 | multiple, different, CMIs within a common subdirectory tree. | |
37039 | ||
37040 | CMI contents are written to a temporary file, which is then atomically | |
37041 | renamed. Observers either see old contents (if there is an | |
37042 | existing file), or complete new contents. They do not observe the | |
37043 | CMI during its creation. This is unlike object file writing, which | |
37044 | may be observed by an external process. | |
37045 | ||
37046 | CMIs are read in lazily, if the host OS provides @code{mmap} | |
37047 | functionality. Generally blocks are read when name lookup or template | |
37048 | instantiation occurs. To inhibit this, the @option{-fno-module-lazy} | |
37049 | option may be used. | |
37050 | ||
37051 | The @option{--param lazy-modules=@var{n}} parameter controls the limit | |
37052 | on the number of concurrently open module files during lazy loading. | |
37053 | Should more modules be imported, an LRU algorithm is used to determine | |
37054 | which files to close---until that file is needed again. This limit | |
37055 | may be exceeded with deep module dependency hierarchies. With large | |
37056 | code bases there may be more imports than the process limit of file | |
37057 | descriptors. By default, the limit is a few less than the per-process | |
37058 | file descriptor hard limit, if that is determinable.@footnote{Where | |
37059 | applicable the soft limit is incremented as needed towards the hard limit.} | |
37060 | ||
37061 | GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism. | |
37062 | You may use @command{readelf} to inspect them, although section | |
37063 | contents are largely undecipherable. There is a section named | |
37064 | @code{.gnu.c++.README}, which contains human-readable text. Other | |
37065 | than the first line, each line consists of @code{@var{tag}: @code{value}} | |
37066 | tuples. | |
37067 | ||
37068 | @smallexample | |
37069 | > @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm} | |
37070 | ||
37071 | String dump of section '.gnu.c++.README': | |
37072 | [ 0] GNU C++ primary module interface | |
37073 | [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454] | |
37074 | [ 6f] version: 2020/11/16-04:54 | |
37075 | [ 89] module: foo | |
37076 | [ 95] source: c_b.ii | |
37077 | [ a4] dialect: C++20/coroutines | |
37078 | [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc | |
37079 | [ ee] repository: gcm.cache | |
37080 | [ 104] buildtime: 2020/11/16 15:03:21 UTC | |
37081 | [ 127] localtime: 2020/11/16 07:03:21 PST | |
37082 | [ 14a] export: foo:part1 foo-part1.gcm | |
37083 | @end smallexample | |
37084 | ||
37085 | Amongst other things, this lists the source that was built, C++ | |
37086 | dialect used and imports of the module.@footnote{The precise contents | |
37087 | of this output may change.} The timestamp is the same value as that | |
37088 | provided by the @code{__DATE__} & @code{__TIME__} macros, and may be | |
37089 | explicitly specified with the environment variable | |
37090 | @code{SOURCE_DATE_EPOCH}. For further details | |
37091 | @pxref{Environment Variables}. | |
37092 | ||
37093 | A set of related CMIs may be copied, provided the relative pathnames | |
37094 | are preserved. | |
37095 | ||
37096 | The @code{.gnu.c++.README} contents do not affect CMI integrity, and | |
37097 | it may be removed or altered. The section numbering of the sections | |
37098 | whose names do not begin with @code{.gnu.c++.}, or are not the string | |
37099 | section is significant and must not be altered. |