]>
Commit | Line | Data |
---|---|---|
83ffe9cd | 1 | @c Copyright (C) 1988-2023 Free Software Foundation, Inc. |
d77de738 ML |
2 | @c This is part of the GCC manual. |
3 | @c For copying conditions, see the file gcc.texi. | |
4 | ||
5 | @ignore | |
6 | @c man begin INCLUDE | |
7 | @include gcc-vers.texi | |
8 | @c man end | |
9 | ||
10 | @c man begin COPYRIGHT | |
74d5206f | 11 | Copyright @copyright{} 1988-2023 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 | |
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 | |
222 | -fno-implicit-templates | |
223 | -fno-implicit-inline-templates | |
224 | -fno-implement-inlines | |
225 | -fmodule-header@r{[}=@var{kind}@r{]} -fmodule-only -fmodules-ts | |
226 | -fmodule-implicit-inline | |
227 | -fno-module-lazy | |
228 | -fmodule-mapper=@var{specification} | |
229 | -fmodule-version-ignore | |
230 | -fms-extensions | |
231 | -fnew-inheriting-ctors | |
232 | -fnew-ttp-matching | |
233 | -fno-nonansi-builtins -fnothrow-opt -fno-operator-names | |
ef10cb86 | 234 | -fno-optional-diags |
43b72ede AA |
235 | -fno-pretty-templates |
236 | -fno-rtti -fsized-deallocation | |
237 | -ftemplate-backtrace-limit=@var{n} | |
238 | -ftemplate-depth=@var{n} | |
239 | -fno-threadsafe-statics -fuse-cxa-atexit | |
240 | -fno-weak -nostdinc++ | |
241 | -fvisibility-inlines-hidden | |
242 | -fvisibility-ms-compat | |
243 | -fext-numeric-literals | |
244 | -flang-info-include-translate@r{[}=@var{header}@r{]} | |
245 | -flang-info-include-translate-not | |
246 | -flang-info-module-cmi@r{[}=@var{module}@r{]} | |
247 | -stdlib=@var{libstdc++,libc++} | |
248 | -Wabi-tag -Wcatch-value -Wcatch-value=@var{n} | |
249 | -Wno-class-conversion -Wclass-memaccess | |
250 | -Wcomma-subscript -Wconditionally-supported | |
251 | -Wno-conversion-null -Wctad-maybe-unsupported | |
252 | -Wctor-dtor-privacy -Wdangling-reference | |
253 | -Wno-delete-incomplete | |
254 | -Wdelete-non-virtual-dtor -Wno-deprecated-array-compare | |
255 | -Wdeprecated-copy -Wdeprecated-copy-dtor | |
256 | -Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion | |
b106f11d AC |
257 | -Weffc++ -Wno-elaborated-enum-base |
258 | -Wno-exceptions -Wextra-semi -Wno-inaccessible-base | |
43b72ede AA |
259 | -Wno-inherited-variadic-ctor -Wno-init-list-lifetime |
260 | -Winvalid-constexpr -Winvalid-imported-macros | |
261 | -Wno-invalid-offsetof -Wno-literal-suffix | |
262 | -Wmismatched-new-delete -Wmismatched-tags | |
263 | -Wmultiple-inheritance -Wnamespaces -Wnarrowing | |
264 | -Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor | |
265 | -Wpessimizing-move -Wno-placement-new -Wplacement-new=@var{n} | |
266 | -Wrange-loop-construct -Wredundant-move -Wredundant-tags | |
267 | -Wreorder -Wregister | |
268 | -Wstrict-null-sentinel -Wno-subobject-linkage -Wtemplates | |
269 | -Wno-non-template-friend -Wold-style-cast | |
270 | -Woverloaded-virtual -Wno-pmf-conversions -Wself-move -Wsign-promo | |
271 | -Wsized-deallocation -Wsuggest-final-methods | |
272 | -Wsuggest-final-types -Wsuggest-override | |
273 | -Wno-terminate -Wuseless-cast -Wno-vexing-parse | |
274 | -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{]} | |
308 | -fno-diagnostics-show-option -fno-diagnostics-show-caret | |
309 | -fno-diagnostics-show-labels -fno-diagnostics-show-line-numbers | |
310 | -fno-diagnostics-show-cwe | |
311 | -fno-diagnostics-show-rule | |
312 | -fdiagnostics-minimum-margin-width=@var{width} | |
313 | -fdiagnostics-parseable-fixits -fdiagnostics-generate-patch | |
314 | -fdiagnostics-show-template-tree -fno-elide-type | |
315 | -fdiagnostics-path-format=@r{[}none@r{|}separate-events@r{|}inline-events@r{]} | |
316 | -fdiagnostics-show-path-depths | |
317 | -fno-show-column | |
318 | -fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]} | |
319 | -fdiagnostics-column-origin=@var{origin} | |
4f01ae37 DM |
320 | -fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]} |
321 | -fdiagnostics-text-art-charset=@r{[}none@r{|}ascii@r{|}unicode@r{|}emoji@r{]}} | |
d77de738 ML |
322 | |
323 | @item Warning Options | |
324 | @xref{Warning Options,,Options to Request or Suppress Warnings}. | |
43b72ede | 325 | @gccoptlist{-fsyntax-only -fmax-errors=@var{n} -Wpedantic |
ef10cb86 | 326 | -pedantic-errors -fpermissive |
43b72ede AA |
327 | -w -Wextra -Wall -Wabi=@var{n} |
328 | -Waddress -Wno-address-of-packed-member -Waggregate-return | |
329 | -Walloc-size-larger-than=@var{byte-size} -Walloc-zero | |
330 | -Walloca -Walloca-larger-than=@var{byte-size} | |
331 | -Wno-aggressive-loop-optimizations | |
332 | -Warith-conversion | |
333 | -Warray-bounds -Warray-bounds=@var{n} -Warray-compare | |
334 | -Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias | |
335 | -Wno-attribute-warning | |
336 | -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]} | |
337 | -Wbool-compare -Wbool-operation | |
338 | -Wno-builtin-declaration-mismatch | |
339 | -Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat | |
fad61bf7 | 340 | -Wc11-c23-compat |
43b72ede AA |
341 | -Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat |
342 | -Wc++20-compat | |
343 | -Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions | |
344 | -Wno-c++20-extensions -Wno-c++23-extensions | |
345 | -Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual | |
346 | -Wchar-subscripts | |
347 | -Wclobbered -Wcomment | |
e1f45bea | 348 | -Wcompare-distinct-pointer-types |
43b72ede AA |
349 | -Wno-complain-wrong-lang |
350 | -Wconversion -Wno-coverage-mismatch -Wno-cpp | |
351 | -Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n} | |
352 | -Wdate-time | |
353 | -Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init | |
354 | -Wdisabled-optimization | |
355 | -Wno-discarded-array-qualifiers -Wno-discarded-qualifiers | |
356 | -Wno-div-by-zero -Wdouble-promotion | |
357 | -Wduplicated-branches -Wduplicated-cond | |
358 | -Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion | |
359 | -Wenum-int-mismatch | |
360 | -Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors | |
44e3f39a | 361 | -Wflex-array-member-not-at-end |
43b72ede AA |
362 | -Wfloat-conversion -Wfloat-equal -Wformat -Wformat=2 |
363 | -Wno-format-contains-nul -Wno-format-extra-args | |
364 | -Wformat-nonliteral -Wformat-overflow=@var{n} | |
365 | -Wformat-security -Wformat-signedness -Wformat-truncation=@var{n} | |
366 | -Wformat-y2k -Wframe-address | |
367 | -Wframe-larger-than=@var{byte-size} -Wno-free-nonheap-object | |
368 | -Wno-if-not-aligned -Wno-ignored-attributes | |
369 | -Wignored-qualifiers -Wno-incompatible-pointer-types | |
370 | -Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=@var{n} | |
371 | -Wno-implicit-function-declaration -Wno-implicit-int | |
372 | -Winfinite-recursion | |
373 | -Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context | |
374 | -Wno-int-to-pointer-cast -Wno-invalid-memory-model | |
375 | -Winvalid-pch -Winvalid-utf8 -Wno-unicode -Wjump-misses-init | |
376 | -Wlarger-than=@var{byte-size} -Wlogical-not-parentheses -Wlogical-op | |
377 | -Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized | |
378 | -Wmemset-elt-size -Wmemset-transposed-args | |
379 | -Wmisleading-indentation -Wmissing-attributes -Wmissing-braces | |
380 | -Wmissing-field-initializers -Wmissing-format-attribute | |
381 | -Wmissing-include-dirs -Wmissing-noreturn -Wno-missing-profile | |
382 | -Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare | |
383 | -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} | |
384 | -Wnull-dereference -Wno-odr | |
385 | -Wopenacc-parallelism | |
386 | -Wopenmp-simd | |
387 | -Wno-overflow -Woverlength-strings -Wno-override-init-side-effects | |
388 | -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded | |
389 | -Wparentheses -Wno-pedantic-ms-format | |
390 | -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast | |
391 | -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls | |
392 | -Wrestrict -Wno-return-local-addr -Wreturn-type | |
393 | -Wno-scalar-storage-order -Wsequence-point | |
394 | -Wshadow -Wshadow=global -Wshadow=local -Wshadow=compatible-local | |
395 | -Wno-shadow-ivar | |
396 | -Wno-shift-count-negative -Wno-shift-count-overflow -Wshift-negative-value | |
397 | -Wno-shift-overflow -Wshift-overflow=@var{n} | |
398 | -Wsign-compare -Wsign-conversion | |
399 | -Wno-sizeof-array-argument | |
400 | -Wsizeof-array-div | |
401 | -Wsizeof-pointer-div -Wsizeof-pointer-memaccess | |
402 | -Wstack-protector -Wstack-usage=@var{byte-size} -Wstrict-aliasing | |
403 | -Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n} | |
404 | -Wstring-compare | |
405 | -Wno-stringop-overflow -Wno-stringop-overread | |
406 | -Wno-stringop-truncation -Wstrict-flex-arrays | |
407 | -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}malloc@r{]} | |
408 | -Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum | |
409 | -Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand | |
410 | -Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs | |
411 | -Wtrivial-auto-var-init -Wtsan -Wtype-limits -Wundef | |
412 | -Wuninitialized -Wunknown-pragmas | |
413 | -Wunsuffixed-float-constants -Wunused | |
414 | -Wunused-but-set-parameter -Wunused-but-set-variable | |
415 | -Wunused-const-variable -Wunused-const-variable=@var{n} | |
416 | -Wunused-function -Wunused-label -Wunused-local-typedefs | |
417 | -Wunused-macros | |
418 | -Wunused-parameter -Wno-unused-result | |
419 | -Wunused-value -Wunused-variable | |
420 | -Wno-varargs -Wvariadic-macros | |
421 | -Wvector-operation-performance | |
422 | -Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than | |
423 | -Wvolatile-register-var -Wwrite-strings | |
424 | -Wxor-used-as-pow | |
d77de738 ML |
425 | -Wzero-length-bounds} |
426 | ||
427 | @item Static Analyzer Options | |
428 | @gccoptlist{ | |
43b72ede AA |
429 | -fanalyzer |
430 | -fanalyzer-call-summaries | |
431 | -fanalyzer-checker=@var{name} | |
432 | -fno-analyzer-feasibility | |
433 | -fanalyzer-fine-grained | |
ce8cdf5b | 434 | -fanalyzer-show-events-in-system-headers |
43b72ede AA |
435 | -fno-analyzer-state-merge |
436 | -fno-analyzer-state-purge | |
437 | -fno-analyzer-suppress-followups | |
438 | -fanalyzer-transitivity | |
439 | -fno-analyzer-undo-inlining | |
440 | -fanalyzer-verbose-edges | |
441 | -fanalyzer-verbose-state-changes | |
442 | -fanalyzer-verbosity=@var{level} | |
443 | -fdump-analyzer | |
444 | -fdump-analyzer-callgraph | |
445 | -fdump-analyzer-exploded-graph | |
446 | -fdump-analyzer-exploded-nodes | |
447 | -fdump-analyzer-exploded-nodes-2 | |
448 | -fdump-analyzer-exploded-nodes-3 | |
449 | -fdump-analyzer-exploded-paths | |
450 | -fdump-analyzer-feasibility | |
841008d3 | 451 | -fdump-analyzer-infinite-loop |
43b72ede AA |
452 | -fdump-analyzer-json |
453 | -fdump-analyzer-state-purge | |
454 | -fdump-analyzer-stderr | |
455 | -fdump-analyzer-supergraph | |
456 | -fdump-analyzer-untracked | |
457 | -Wno-analyzer-double-fclose | |
458 | -Wno-analyzer-double-free | |
459 | -Wno-analyzer-exposure-through-output-file | |
460 | -Wno-analyzer-exposure-through-uninit-copy | |
461 | -Wno-analyzer-fd-access-mode-mismatch | |
462 | -Wno-analyzer-fd-double-close | |
463 | -Wno-analyzer-fd-leak | |
464 | -Wno-analyzer-fd-phase-mismatch | |
465 | -Wno-analyzer-fd-type-mismatch | |
466 | -Wno-analyzer-fd-use-after-close | |
467 | -Wno-analyzer-fd-use-without-check | |
468 | -Wno-analyzer-file-leak | |
469 | -Wno-analyzer-free-of-non-heap | |
470 | -Wno-analyzer-imprecise-fp-arithmetic | |
841008d3 | 471 | -Wno-analyzer-infinite-loop |
43b72ede AA |
472 | -Wno-analyzer-infinite-recursion |
473 | -Wno-analyzer-jump-through-null | |
474 | -Wno-analyzer-malloc-leak | |
475 | -Wno-analyzer-mismatching-deallocation | |
476 | -Wno-analyzer-null-argument | |
477 | -Wno-analyzer-null-dereference | |
478 | -Wno-analyzer-out-of-bounds | |
034d99e8 | 479 | -Wno-analyzer-overlapping-buffers |
43b72ede AA |
480 | -Wno-analyzer-possible-null-argument |
481 | -Wno-analyzer-possible-null-dereference | |
482 | -Wno-analyzer-putenv-of-auto-var | |
483 | -Wno-analyzer-shift-count-negative | |
484 | -Wno-analyzer-shift-count-overflow | |
485 | -Wno-analyzer-stale-setjmp-buffer | |
486 | -Wno-analyzer-tainted-allocation-size | |
487 | -Wno-analyzer-tainted-assertion | |
488 | -Wno-analyzer-tainted-array-index | |
489 | -Wno-analyzer-tainted-divisor | |
490 | -Wno-analyzer-tainted-offset | |
491 | -Wno-analyzer-tainted-size | |
492 | -Wanalyzer-too-complex | |
f65f63c4 | 493 | -Wno-analyzer-undefined-behavior-strtok |
43b72ede AA |
494 | -Wno-analyzer-unsafe-call-within-signal-handler |
495 | -Wno-analyzer-use-after-free | |
496 | -Wno-analyzer-use-of-pointer-in-stale-stack-frame | |
497 | -Wno-analyzer-use-of-uninitialized-value | |
498 | -Wno-analyzer-va-arg-type-mismatch | |
499 | -Wno-analyzer-va-list-exhausted | |
500 | -Wno-analyzer-va-list-leak | |
501 | -Wno-analyzer-va-list-use-after-va-end | |
502 | -Wno-analyzer-write-to-const | |
503 | -Wno-analyzer-write-to-string-literal | |
d77de738 ML |
504 | } |
505 | ||
506 | @item C and Objective-C-only Warning Options | |
43b72ede | 507 | @gccoptlist{-Wbad-function-cast -Wmissing-declarations |
ffc74822 HM |
508 | -Wmissing-parameter-type -Wmissing-prototypes -Wmissing-variable-declarations |
509 | -Wnested-externs -Wold-style-declaration -Wold-style-definition | |
43b72ede | 510 | -Wstrict-prototypes -Wtraditional -Wtraditional-conversion |
d77de738 ML |
511 | -Wdeclaration-after-statement -Wpointer-sign} |
512 | ||
513 | @item Debugging Options | |
514 | @xref{Debugging Options,,Options for Debugging Your Program}. | |
43b72ede AA |
515 | @gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version} |
516 | -gbtf -gctf -gctf@var{level} | |
517 | -ggdb -grecord-gcc-switches -gno-record-gcc-switches | |
518 | -gstrict-dwarf -gno-strict-dwarf | |
519 | -gas-loc-support -gno-as-loc-support | |
520 | -gas-locview-support -gno-as-locview-support | |
3eeb4801 | 521 | -gcodeview |
43b72ede AA |
522 | -gcolumn-info -gno-column-info -gdwarf32 -gdwarf64 |
523 | -gstatement-frontiers -gno-statement-frontiers | |
524 | -gvariable-location-views -gno-variable-location-views | |
525 | -ginternal-reset-location-views -gno-internal-reset-location-views | |
526 | -ginline-points -gno-inline-points | |
527 | -gvms -gz@r{[}=@var{type}@r{]} | |
528 | -gsplit-dwarf -gdescribe-dies -gno-describe-dies | |
529 | -fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section | |
530 | -fno-eliminate-unused-debug-types | |
531 | -femit-struct-debug-baseonly -femit-struct-debug-reduced | |
532 | -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} | |
533 | -fno-eliminate-unused-debug-symbols -femit-class-debug-always | |
534 | -fno-merge-debug-strings -fno-dwarf2-cfi-asm | |
d77de738 ML |
535 | -fvar-tracking -fvar-tracking-assignments} |
536 | ||
537 | @item Optimization Options | |
538 | @xref{Optimize Options,,Options that Control Optimization}. | |
43b72ede AA |
539 | @gccoptlist{-faggressive-loop-optimizations |
540 | -falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
541 | -falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
542 | -falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
543 | -falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
544 | -fno-allocation-dce -fallow-store-data-races | |
545 | -fassociative-math -fauto-profile -fauto-profile[=@var{path}] | |
546 | -fauto-inc-dec -fbranch-probabilities | |
547 | -fcaller-saves | |
548 | -fcombine-stack-adjustments -fconserve-stack | |
04c9cf5c | 549 | -ffold-mem-offsets |
43b72ede AA |
550 | -fcompare-elim -fcprop-registers -fcrossjumping |
551 | -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules | |
552 | -fcx-limited-range | |
553 | -fdata-sections -fdce -fdelayed-branch | |
554 | -fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively | |
555 | -fdevirtualize-at-ltrans -fdse | |
556 | -fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects | |
557 | -ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style} | |
558 | -ffinite-loops | |
559 | -fforward-propagate -ffp-contract=@var{style} -ffunction-sections | |
560 | -fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity | |
561 | -fgcse-sm -fhoist-adjacent-loads -fif-conversion | |
562 | -fif-conversion2 -findirect-inlining | |
563 | -finline-functions -finline-functions-called-once -finline-limit=@var{n} | |
564 | -finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone | |
565 | -fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const | |
566 | -fipa-reference -fipa-reference-addressable | |
567 | -fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm} | |
568 | -flive-patching=@var{level} | |
569 | -fira-region=@var{region} -fira-hoist-pressure | |
570 | -fira-loop-pressure -fno-ira-share-save-slots | |
571 | -fno-ira-share-spill-slots | |
572 | -fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute | |
573 | -fivopts -fkeep-inline-functions -fkeep-static-functions | |
574 | -fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage | |
575 | -floop-block -floop-interchange -floop-strip-mine | |
576 | -floop-unroll-and-jam -floop-nest-optimize | |
577 | -floop-parallelize-all -flra-remat -flto -flto-compression-level | |
578 | -flto-partition=@var{alg} -fmerge-all-constants | |
579 | -fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves | |
580 | -fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg | |
581 | -fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse | |
582 | -fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole | |
583 | -fno-peephole2 -fno-printf-return-value -fno-sched-interblock | |
584 | -fno-sched-spec -fno-signed-zeros | |
585 | -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss | |
586 | -fomit-frame-pointer -foptimize-sibling-calls | |
587 | -fpartial-inlining -fpeel-loops -fpredictive-commoning | |
588 | -fprefetch-loop-arrays | |
589 | -fprofile-correction | |
590 | -fprofile-use -fprofile-use=@var{path} -fprofile-partial-training | |
591 | -fprofile-values -fprofile-reorder-functions | |
592 | -freciprocal-math -free -frename-registers -freorder-blocks | |
593 | -freorder-blocks-algorithm=@var{algorithm} | |
594 | -freorder-blocks-and-partition -freorder-functions | |
595 | -frerun-cse-after-loop -freschedule-modulo-scheduled-loops | |
596 | -frounding-math -fsave-optimization-record | |
597 | -fsched2-use-superblocks -fsched-pressure | |
598 | -fsched-spec-load -fsched-spec-load-dangerous | |
599 | -fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}] | |
600 | -fsched-group-heuristic -fsched-critical-path-heuristic | |
601 | -fsched-spec-insn-heuristic -fsched-rank-heuristic | |
602 | -fsched-last-insn-heuristic -fsched-dep-count-heuristic | |
603 | -fschedule-fusion | |
604 | -fschedule-insns -fschedule-insns2 -fsection-anchors | |
605 | -fselective-scheduling -fselective-scheduling2 | |
606 | -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops | |
607 | -fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate | |
608 | -fsignaling-nans | |
609 | -fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops | |
610 | -fsplit-paths | |
611 | -fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt | |
612 | -fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing | |
613 | -fthread-jumps -ftracer -ftree-bit-ccp | |
614 | -ftree-builtin-call-dce -ftree-ccp -ftree-ch | |
615 | -ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts | |
616 | -ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting | |
617 | -ftree-loop-if-convert -ftree-loop-im | |
618 | -ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns | |
619 | -ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize | |
620 | -ftree-loop-vectorize | |
621 | -ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta | |
622 | -ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra | |
623 | -ftree-switch-conversion -ftree-tail-merge | |
624 | -ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init | |
625 | -funconstrained-commons -funit-at-a-time -funroll-all-loops | |
626 | -funroll-loops -funsafe-math-optimizations -funswitch-loops | |
627 | -fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt | |
628 | -fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs | |
d77de738 ML |
629 | --param @var{name}=@var{value} |
630 | -O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz} | |
631 | ||
632 | @item Program Instrumentation Options | |
633 | @xref{Instrumentation Options,,Program Instrumentation Options}. | |
43b72ede AA |
634 | @gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage |
635 | -fprofile-abs-path | |
636 | -fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path} | |
637 | -fprofile-info-section -fprofile-info-section=@var{name} | |
638 | -fprofile-note=@var{path} -fprofile-prefix-path=@var{path} | |
639 | -fprofile-update=@var{method} -fprofile-filter-files=@var{regex} | |
640 | -fprofile-exclude-files=@var{regex} | |
641 | -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} | |
642 | -fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} | |
643 | -fsanitize-trap -fsanitize-trap=@var{style} | |
644 | -fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... | |
645 | -fsanitize-undefined-trap-on-error -fbounds-check | |
646 | -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} | |
647 | -fharden-compares -fharden-conditional-branches | |
551935d1 AO |
648 | -fharden-control-flow-redundancy -fhardcfr-skip-leaf |
649 | -fhardcfr-check-exceptions -fhardcfr-check-returning-calls | |
650 | -fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]} | |
43b72ede AA |
651 | -fstack-protector -fstack-protector-all -fstack-protector-strong |
652 | -fstack-protector-explicit -fstack-check | |
653 | -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} | |
654 | -fno-stack-limit -fsplit-stack | |
655 | -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} | |
656 | -fvtv-counts -fvtv-debug | |
657 | -finstrument-functions -finstrument-functions-once | |
658 | -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} | |
659 | -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{} | |
b42dd137 M |
660 | -fprofile-prefix-map=@var{old}=@var{new} |
661 | -fpatchable-function-entry=@var{N}@r{[},@var{M}@r{]}} | |
d77de738 ML |
662 | |
663 | @item Preprocessor Options | |
664 | @xref{Preprocessor Options,,Options Controlling the Preprocessor}. | |
43b72ede AA |
665 | @gccoptlist{-A@var{question}=@var{answer} |
666 | -A-@var{question}@r{[}=@var{answer}@r{]} | |
667 | -C -CC -D@var{macro}@r{[}=@var{defn}@r{]} | |
668 | -dD -dI -dM -dN -dU | |
669 | -fdebug-cpp -fdirectives-only -fdollars-in-identifiers | |
670 | -fexec-charset=@var{charset} -fextended-identifiers | |
671 | -finput-charset=@var{charset} -flarge-source-files | |
672 | -fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth} | |
673 | -fno-canonical-system-headers -fpch-deps -fpch-preprocess | |
674 | -fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion | |
675 | -fwide-exec-charset=@var{charset} -fworking-directory | |
676 | -H -imacros @var{file} -include @var{file} | |
677 | -M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules | |
678 | -no-integrated-cpp -P -pthread -remap | |
679 | -traditional -traditional-cpp -trigraphs | |
680 | -U@var{macro} -undef | |
d77de738 ML |
681 | -Wp,@var{option} -Xpreprocessor @var{option}} |
682 | ||
683 | @item Assembler Options | |
684 | @xref{Assembler Options,,Passing Options to the Assembler}. | |
685 | @gccoptlist{-Wa,@var{option} -Xassembler @var{option}} | |
686 | ||
687 | @item Linker Options | |
688 | @xref{Link Options,,Options for Linking}. | |
43b72ede AA |
689 | @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} |
690 | -nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++ | |
691 | -e @var{entry} --entry=@var{entry} | |
692 | -pie -pthread -r -rdynamic | |
693 | -s -static -static-pie -static-libgcc -static-libstdc++ | |
694 | -static-libasan -static-libtsan -static-liblsan -static-libubsan | |
695 | -shared -shared-libgcc -symbolic | |
696 | -T @var{script} -Wl,@var{option} -Xlinker @var{option} | |
d77de738 ML |
697 | -u @var{symbol} -z @var{keyword}} |
698 | ||
699 | @item Directory Options | |
700 | @xref{Directory Options,,Options for Directory Search}. | |
43b72ede AA |
701 | @gccoptlist{-B@var{prefix} -I@var{dir} -I- |
702 | -idirafter @var{dir} | |
703 | -imacros @var{file} -imultilib @var{dir} | |
704 | -iplugindir=@var{dir} -iprefix @var{file} | |
705 | -iquote @var{dir} -isysroot @var{dir} -isystem @var{dir} | |
706 | -iwithprefix @var{dir} -iwithprefixbefore @var{dir} | |
707 | -L@var{dir} -no-canonical-prefixes --no-sysroot-suffix | |
d77de738 ML |
708 | -nostdinc -nostdinc++ --sysroot=@var{dir}} |
709 | ||
710 | @item Code Generation Options | |
711 | @xref{Code Gen Options,,Options for Code Generation Conventions}. | |
43b72ede AA |
712 | @gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} |
713 | -ffixed-@var{reg} -fexceptions | |
714 | -fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables | |
715 | -fasynchronous-unwind-tables | |
716 | -fno-gnu-unique | |
717 | -finhibit-size-directive -fcommon -fno-ident | |
718 | -fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt | |
719 | -fno-jump-tables -fno-bit-tests | |
720 | -frecord-gcc-switches | |
721 | -freg-struct-return -fshort-enums -fshort-wchar | |
722 | -fverbose-asm -fpack-struct[=@var{n}] | |
723 | -fleading-underscore -ftls-model=@var{model} | |
724 | -fstack-reuse=@var{reuse_level} | |
28d8c680 AB |
725 | -ftrampolines -ftrampoline-impl=@r{[}stack@r{|}heap@r{]} |
726 | -ftrapv -fwrapv | |
43b72ede | 727 | -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} |
d77de738 ML |
728 | -fstrict-volatile-bitfields -fsync-libcalls} |
729 | ||
730 | @item Developer Options | |
731 | @xref{Developer Options,,GCC Developer Options}. | |
43b72ede | 732 | @gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion |
d77de738 | 733 | -dumpfullversion -fcallgraph-info@r{[}=su,da@r{]} |
43b72ede AA |
734 | -fchecking -fchecking=@var{n} |
735 | -fdbg-cnt-list -fdbg-cnt=@var{counter-value-list} | |
736 | -fdisable-ipa-@var{pass_name} | |
737 | -fdisable-rtl-@var{pass_name} | |
738 | -fdisable-rtl-@var{pass-name}=@var{range-list} | |
739 | -fdisable-tree-@var{pass_name} | |
740 | -fdisable-tree-@var{pass-name}=@var{range-list} | |
741 | -fdump-debug -fdump-earlydebug | |
742 | -fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links | |
743 | -fdump-final-insns@r{[}=@var{file}@r{]} | |
744 | -fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline | |
745 | -fdump-lang-all | |
746 | -fdump-lang-@var{switch} | |
747 | -fdump-lang-@var{switch}-@var{options} | |
748 | -fdump-lang-@var{switch}-@var{options}=@var{filename} | |
749 | -fdump-passes | |
750 | -fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename} | |
751 | -fdump-statistics | |
752 | -fdump-tree-all | |
753 | -fdump-tree-@var{switch} | |
754 | -fdump-tree-@var{switch}-@var{options} | |
755 | -fdump-tree-@var{switch}-@var{options}=@var{filename} | |
756 | -fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second | |
757 | -fenable-@var{kind}-@var{pass} | |
758 | -fenable-@var{kind}-@var{pass}=@var{range-list} | |
759 | -fira-verbose=@var{n} | |
760 | -flto-report -flto-report-wpa -fmem-report-wpa | |
761 | -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report | |
762 | -fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]} | |
763 | -fmultiflags -fprofile-report | |
764 | -frandom-seed=@var{string} -fsched-verbose=@var{n} | |
765 | -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose | |
766 | -fstats -fstack-usage -ftime-report -ftime-report-details | |
767 | -fvar-tracking-assignments-toggle -gtoggle | |
768 | -print-file-name=@var{library} -print-libgcc-file-name | |
769 | -print-multi-directory -print-multi-lib -print-multi-os-directory | |
770 | -print-prog-name=@var{program} -print-search-dirs -Q | |
771 | -print-sysroot -print-sysroot-headers-suffix | |
d77de738 ML |
772 | -save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}} |
773 | ||
774 | @item Machine-Dependent Options | |
775 | @xref{Submodel Options,,Machine-Dependent Options}. | |
776 | @c This list is ordered alphanumerically by subsection name. | |
777 | @c Try and put the significant identifier (CPU or system) first, | |
778 | @c so users have a clue at guessing where the ones they want will be. | |
779 | ||
780 | @emph{AArch64 Options} | |
43b72ede AA |
781 | @gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian |
782 | -mgeneral-regs-only | |
783 | -mcmodel=tiny -mcmodel=small -mcmodel=large | |
784 | -mstrict-align -mno-strict-align | |
785 | -momit-leaf-frame-pointer | |
786 | -mtls-dialect=desc -mtls-dialect=traditional | |
787 | -mtls-size=@var{size} | |
788 | -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 | |
789 | -mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div | |
790 | -mpc-relative-literal-loads | |
791 | -msign-return-address=@var{scope} | |
d77de738 | 792 | -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf} |
43b72ede AA |
793 | +@var{b-key}]|@var{bti} |
794 | -mharden-sls=@var{opts} | |
795 | -march=@var{name} -mcpu=@var{name} -mtune=@var{name} | |
796 | -moverride=@var{string} -mverbose-cost-dump | |
797 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg} | |
798 | -mstack-protector-guard-offset=@var{offset} -mtrack-speculation | |
d77de738 ML |
799 | -moutline-atomics } |
800 | ||
801 | @emph{Adapteva Epiphany Options} | |
43b72ede AA |
802 | @gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs |
803 | -mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf | |
804 | -msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num} | |
805 | -mround-nearest -mlong-calls -mshort-calls -msmall16 | |
806 | -mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num} | |
d77de738 ML |
807 | -msplit-vecmove-early -m1reg-@var{reg}} |
808 | ||
809 | @emph{AMD GCN Options} | |
810 | @gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}} | |
811 | ||
812 | @emph{ARC Options} | |
43b72ede AA |
813 | @gccoptlist{-mbarrel-shifter -mjli-always |
814 | -mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700 | |
815 | -mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr | |
816 | -mea -mno-mpy -mmul32x16 -mmul64 -matomic | |
817 | -mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap | |
818 | -mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape | |
819 | -mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof | |
820 | -mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved | |
821 | -mrgf-banked-regs -mlpc-width=@var{width} -G @var{num} | |
822 | -mvolatile-cache -mtp-regno=@var{regno} | |
823 | -malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc | |
824 | -mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi | |
825 | -mexpand-adddi -mindexed-loads -mlra -mlra-priority-none | |
826 | -mlra-priority-compact -mlra-priority-noncompact -mmillicode | |
827 | -mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level} | |
828 | -mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame | |
829 | -munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo} | |
d77de738 ML |
830 | -mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index} |
831 | ||
832 | @emph{ARM Options} | |
43b72ede AA |
833 | @gccoptlist{-mapcs-frame -mno-apcs-frame |
834 | -mabi=@var{name} | |
835 | -mapcs-stack-check -mno-apcs-stack-check | |
836 | -mapcs-reentrant -mno-apcs-reentrant | |
837 | -mgeneral-regs-only | |
838 | -msched-prolog -mno-sched-prolog | |
839 | -mlittle-endian -mbig-endian | |
840 | -mbe8 -mbe32 | |
841 | -mfloat-abi=@var{name} | |
d77de738 | 842 | -mfp16-format=@var{name} |
43b72ede AA |
843 | -mthumb-interwork -mno-thumb-interwork |
844 | -mcpu=@var{name} -march=@var{name} -mfpu=@var{name} | |
845 | -mtune=@var{name} -mprint-tune-info | |
846 | -mstructure-size-boundary=@var{n} | |
847 | -mabort-on-noreturn | |
848 | -mlong-calls -mno-long-calls | |
849 | -msingle-pic-base -mno-single-pic-base | |
850 | -mpic-register=@var{reg} | |
851 | -mnop-fun-dllimport | |
852 | -mpoke-function-name | |
853 | -mthumb -marm -mflip-thumb | |
854 | -mtpcs-frame -mtpcs-leaf-frame | |
855 | -mcaller-super-interworking -mcallee-super-interworking | |
856 | -mtp=@var{name} -mtls-dialect=@var{dialect} | |
857 | -mword-relocations | |
858 | -mfix-cortex-m3-ldrd | |
859 | -mfix-cortex-a57-aes-1742098 | |
860 | -mfix-cortex-a72-aes-1655431 | |
861 | -munaligned-access | |
862 | -mneon-for-64bits | |
863 | -mslow-flash-data | |
864 | -masm-syntax-unified | |
865 | -mrestrict-it | |
866 | -mverbose-cost-dump | |
867 | -mpure-code | |
868 | -mcmse | |
869 | -mfix-cmse-cve-2021-35465 | |
870 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset} | |
871 | -mfdpic | |
14fab5fb AC |
872 | -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}] |
873 | [+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]} | |
d77de738 ML |
874 | |
875 | @emph{AVR Options} | |
43b72ede AA |
876 | @gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args |
877 | -mbranch-cost=@var{cost} | |
878 | -mcall-prologues -mgas-isr-prologues -mint8 | |
879 | -mdouble=@var{bits} -mlong-double=@var{bits} | |
880 | -mn_flash=@var{size} -mno-interrupts | |
881 | -mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack | |
882 | -mfract-convert-truncate | |
883 | -mshort-calls -nodevicelib -nodevicespecs | |
d77de738 ML |
884 | -Waddr-space-convert -Wmisspelled-isr} |
885 | ||
886 | @emph{Blackfin Options} | |
43b72ede AA |
887 | @gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} |
888 | -msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer | |
889 | -mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly | |
890 | -mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library | |
891 | -mno-id-shared-library -mshared-library-id=@var{n} | |
892 | -mleaf-id-shared-library -mno-leaf-id-shared-library | |
893 | -msep-data -mno-sep-data -mlong-calls -mno-long-calls | |
894 | -mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram | |
d77de738 ML |
895 | -micplb} |
896 | ||
897 | @emph{C6X Options} | |
43b72ede | 898 | @gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu} |
d77de738 ML |
899 | -msim -msdata=@var{sdata-type}} |
900 | ||
901 | @emph{CRIS Options} | |
902 | @gccoptlist{-mcpu=@var{cpu} -march=@var{cpu} | |
43b72ede AA |
903 | -mtune=@var{cpu} -mmax-stack-frame=@var{n} |
904 | -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects | |
905 | -mstack-align -mdata-align -mconst-align | |
906 | -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue | |
907 | -melf -maout -sim -sim2 | |
d77de738 ML |
908 | -mmul-bug-workaround -mno-mul-bug-workaround} |
909 | ||
910 | @emph{C-SKY Options} | |
43b72ede AA |
911 | @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} |
912 | -mbig-endian -EB -mlittle-endian -EL | |
913 | -mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu | |
914 | -mfloat-abi=@var{name} | |
915 | -melrw -mistack -mmp -mcp -mcache -msecurity -mtrust | |
916 | -mdsp -medsp -mvdsp | |
917 | -mdiv -msmart -mhigh-registers -manchor | |
918 | -mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt | |
d77de738 ML |
919 | -mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim} |
920 | ||
921 | @emph{Darwin Options} | |
43b72ede AA |
922 | @gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal |
923 | -arch_only -bind_at_load -bundle -bundle_loader | |
924 | -client_name -compatibility_version -current_version | |
925 | -dead_strip | |
926 | -dependency-file -dylib_file -dylinker_install_name | |
927 | -dynamic -dynamiclib -exported_symbols_list | |
928 | -filelist -flat_namespace -force_cpusubtype_ALL | |
929 | -force_flat_namespace -headerpad_max_install_names | |
930 | -iframework | |
931 | -image_base -init -install_name -keep_private_externs | |
932 | -multi_module -multiply_defined -multiply_defined_unused | |
47b634a3 | 933 | -noall_load -no_dead_strip_inits_and_terms -nodefaultrpaths |
43b72ede AA |
934 | -nofixprebinding -nomultidefs -noprebind -noseglinkedit |
935 | -pagezero_size -prebind -prebind_all_twolevel_modules | |
936 | -private_bundle -read_only_relocs -sectalign | |
937 | -sectobjectsymbols -whyload -seg1addr | |
938 | -sectcreate -sectobjectsymbols -sectorder | |
939 | -segaddr -segs_read_only_addr -segs_read_write_addr | |
940 | -seg_addr_table -seg_addr_table_filename -seglinkedit | |
941 | -segprot -segs_read_only_addr -segs_read_write_addr | |
942 | -single_module -static -sub_library -sub_umbrella | |
943 | -twolevel_namespace -umbrella -undefined | |
944 | -unexported_symbols_list -weak_reference_mismatches | |
945 | -whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version} | |
d77de738 ML |
946 | -mkernel -mone-byte-bool} |
947 | ||
948 | @emph{DEC Alpha Options} | |
43b72ede AA |
949 | @gccoptlist{-mno-fp-regs -msoft-float |
950 | -mieee -mieee-with-inexact -mieee-conformant | |
951 | -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} | |
952 | -mtrap-precision=@var{mode} -mbuild-constants | |
953 | -mcpu=@var{cpu-type} -mtune=@var{cpu-type} | |
954 | -mbwx -mmax -mfix -mcix | |
955 | -mfloat-vax -mfloat-ieee | |
956 | -mexplicit-relocs -msmall-data -mlarge-data | |
957 | -msmall-text -mlarge-text | |
d77de738 ML |
958 | -mmemory-latency=@var{time}} |
959 | ||
960 | @emph{eBPF Options} | |
9cbf4286 | 961 | @gccoptlist{-mbig-endian -mlittle-endian |
77d0f9ec | 962 | -mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re -mjmpext |
14dab1a1 | 963 | -mjmp32 -malu32 -mv3-atomics -mbswap -msdiv -msmov -mcpu=@var{version} |
9cbf4286 | 964 | -masm=@var{dialect}} |
d77de738 ML |
965 | |
966 | @emph{FR30 Options} | |
967 | @gccoptlist{-msmall-model -mno-lsim} | |
968 | ||
969 | @emph{FT32 Options} | |
970 | @gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm} | |
971 | ||
972 | @emph{FRV Options} | |
43b72ede AA |
973 | @gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 |
974 | -mhard-float -msoft-float | |
975 | -malloc-cc -mfixed-cc -mdword -mno-dword | |
976 | -mdouble -mno-double | |
977 | -mmedia -mno-media -mmuladd -mno-muladd | |
978 | -mfdpic -minline-plt -mgprel-ro -multilib-library-pic | |
979 | -mlinked-fp -mlong-calls -malign-labels | |
980 | -mlibrary-pic -macc-4 -macc-8 | |
981 | -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move | |
982 | -moptimize-membar -mno-optimize-membar | |
983 | -mscc -mno-scc -mcond-exec -mno-cond-exec | |
984 | -mvliw-branch -mno-vliw-branch | |
985 | -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec | |
986 | -mno-nested-cond-exec -mtomcat-stats | |
987 | -mTLS -mtls | |
d77de738 ML |
988 | -mcpu=@var{cpu}} |
989 | ||
990 | @emph{GNU/Linux Options} | |
43b72ede | 991 | @gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid |
d77de738 ML |
992 | -tno-android-cc -tno-android-ld} |
993 | ||
994 | @emph{H8/300 Options} | |
995 | @gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300} | |
996 | ||
997 | @emph{HPPA Options} | |
43b72ede AA |
998 | @gccoptlist{-march=@var{architecture-type} |
999 | -matomic-libcalls -mbig-switch | |
1000 | -mcaller-copies -mdisable-fpregs -mdisable-indexing | |
1001 | -mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld | |
1002 | -mfixed-range=@var{register-range} | |
1003 | -mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls | |
1004 | -mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs | |
1005 | -mno-disable-indexing -mno-fast-indirect-calls -mno-gas | |
1006 | -mno-jump-in-delay -mno-long-load-store | |
1007 | -mno-portable-runtime -mno-soft-float | |
1008 | -mno-space-regs -msoft-float -mpa-risc-1-0 | |
1009 | -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime | |
1010 | -mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio | |
d77de738 ML |
1011 | -munix=@var{unix-std} -nolibdld -static -threads} |
1012 | ||
1013 | @emph{IA-64 Options} | |
43b72ede AA |
1014 | @gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic |
1015 | -mvolatile-asm-stop -mregister-names -msdata -mno-sdata | |
1016 | -mconstant-gp -mauto-pic -mfused-madd | |
1017 | -minline-float-divide-min-latency | |
1018 | -minline-float-divide-max-throughput | |
1019 | -mno-inline-float-divide | |
1020 | -minline-int-divide-min-latency | |
1021 | -minline-int-divide-max-throughput | |
1022 | -mno-inline-int-divide | |
1023 | -minline-sqrt-min-latency -minline-sqrt-max-throughput | |
1024 | -mno-inline-sqrt | |
1025 | -mdwarf2-asm -mearly-stop-bits | |
1026 | -mfixed-range=@var{register-range} -mtls-size=@var{tls-size} | |
1027 | -mtune=@var{cpu-type} -milp32 -mlp64 | |
1028 | -msched-br-data-spec -msched-ar-data-spec -msched-control-spec | |
1029 | -msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec | |
1030 | -msched-spec-ldc -msched-spec-control-ldc | |
1031 | -msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns | |
1032 | -msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path | |
1033 | -msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost | |
d77de738 ML |
1034 | -msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}} |
1035 | ||
1036 | @emph{LM32 Options} | |
43b72ede | 1037 | @gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled |
d77de738 ML |
1038 | -msign-extend-enabled -muser-enabled} |
1039 | ||
1040 | @emph{LoongArch Options} | |
43b72ede | 1041 | @gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type} |
bb4a8198 YY |
1042 | -mfpu=@var{fpu-type} -msimd=@var{simd-type} |
1043 | -msoft-float -msingle-float -mdouble-float -mlsx -mno-lsx -mlasx -mno-lasx | |
43b72ede AA |
1044 | -mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division |
1045 | -mcond-move-int -mno-cond-move-int | |
1046 | -mcond-move-float -mno-cond-move-float | |
1047 | -memcpy -mno-memcpy -mstrict-align -mno-strict-align | |
1048 | -mmax-inline-memcpy-size=@var{n} | |
e1b1cba1 | 1049 | -mexplicit-relocs=@var{style} -mexplicit-relocs -mno-explicit-relocs |
43b72ede | 1050 | -mdirect-extern-access -mno-direct-extern-access |
fe23a2ff | 1051 | -mcmodel=@var{code-model} -mrelax -mpass-mrelax-to-as} |
d77de738 ML |
1052 | |
1053 | @emph{M32R/D Options} | |
43b72ede AA |
1054 | @gccoptlist{-m32r2 -m32rx -m32r |
1055 | -mdebug | |
1056 | -malign-loops -mno-align-loops | |
1057 | -missue-rate=@var{number} | |
1058 | -mbranch-cost=@var{number} | |
1059 | -mmodel=@var{code-size-model-type} | |
1060 | -msdata=@var{sdata-type} | |
1061 | -mno-flush-func -mflush-func=@var{name} | |
1062 | -mno-flush-trap -mflush-trap=@var{number} | |
d77de738 ML |
1063 | -G @var{num}} |
1064 | ||
1065 | @emph{M32C Options} | |
1066 | @gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}} | |
1067 | ||
1068 | @emph{M680x0 Options} | |
43b72ede AA |
1069 | @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune} |
1070 | -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 | |
1071 | -m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407 | |
1072 | -mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020 | |
1073 | -mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort | |
1074 | -mno-short -mhard-float -m68881 -msoft-float -mpcrel | |
1075 | -malign-int -mstrict-align -msep-data -mno-sep-data | |
1076 | -mshared-library-id=n -mid-shared-library -mno-id-shared-library | |
d77de738 ML |
1077 | -mxgot -mno-xgot -mlong-jump-table-offsets} |
1078 | ||
1079 | @emph{MCore Options} | |
43b72ede AA |
1080 | @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates |
1081 | -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields | |
1082 | -m4byte-functions -mno-4byte-functions -mcallgraph-data | |
1083 | -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim | |
d77de738 ML |
1084 | -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment} |
1085 | ||
d77de738 | 1086 | @emph{MicroBlaze Options} |
43b72ede AA |
1087 | @gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu} |
1088 | -mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift | |
1089 | -mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss | |
1090 | -mxl-multiply-high -mxl-float-convert -mxl-float-sqrt | |
1091 | -mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model} | |
d77de738 ML |
1092 | -mpic-data-is-text-relative} |
1093 | ||
1094 | @emph{MIPS Options} | |
43b72ede AA |
1095 | @gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} |
1096 | -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5 | |
1097 | -mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6 | |
1098 | -mips16 -mno-mips16 -mflip-mips16 | |
1099 | -minterlink-compressed -mno-interlink-compressed | |
1100 | -minterlink-mips16 -mno-interlink-mips16 | |
1101 | -mabi=@var{abi} -mabicalls -mno-abicalls | |
1102 | -mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot | |
1103 | -mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float | |
1104 | -mno-float -msingle-float -mdouble-float | |
1105 | -modd-spreg -mno-odd-spreg | |
1106 | -mabs=@var{mode} -mnan=@var{encoding} | |
1107 | -mdsp -mno-dsp -mdspr2 -mno-dspr2 | |
1108 | -mmcu -mmno-mcu | |
1109 | -meva -mno-eva | |
1110 | -mvirt -mno-virt | |
1111 | -mxpa -mno-xpa | |
1112 | -mcrc -mno-crc | |
1113 | -mginv -mno-ginv | |
1114 | -mmicromips -mno-micromips | |
1115 | -mmsa -mno-msa | |
1116 | -mloongson-mmi -mno-loongson-mmi | |
1117 | -mloongson-ext -mno-loongson-ext | |
1118 | -mloongson-ext2 -mno-loongson-ext2 | |
1119 | -mfpu=@var{fpu-type} | |
1120 | -msmartmips -mno-smartmips | |
1121 | -mpaired-single -mno-paired-single -mdmx -mno-mdmx | |
1122 | -mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc | |
1123 | -mlong64 -mlong32 -msym32 -mno-sym32 | |
1124 | -G@var{num} -mlocal-sdata -mno-local-sdata | |
1125 | -mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt | |
1126 | -membedded-data -mno-embedded-data | |
1127 | -muninit-const-in-rodata -mno-uninit-const-in-rodata | |
1128 | -mcode-readable=@var{setting} | |
1129 | -msplit-addresses -mno-split-addresses | |
1130 | -mexplicit-relocs -mno-explicit-relocs | |
1131 | -mcheck-zero-division -mno-check-zero-division | |
1132 | -mdivide-traps -mdivide-breaks | |
1133 | -mload-store-pairs -mno-load-store-pairs | |
1134 | -munaligned-access -mno-unaligned-access | |
1135 | -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls | |
1136 | -mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp | |
1137 | -mfix-24k -mno-fix-24k | |
1138 | -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 | |
1139 | -mfix-r5900 -mno-fix-r5900 | |
1140 | -mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000 | |
1141 | -mfix-vr4120 -mno-fix-vr4120 | |
1142 | -mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1 | |
1143 | -mflush-func=@var{func} -mno-flush-func | |
1144 | -mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely | |
1145 | -mcompact-branches=@var{policy} | |
1146 | -mfp-exceptions -mno-fp-exceptions | |
1147 | -mvr4130-align -mno-vr4130-align -msynci -mno-synci | |
1148 | -mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4 | |
1149 | -mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address | |
d77de738 ML |
1150 | -mframe-header-opt -mno-frame-header-opt} |
1151 | ||
1152 | @emph{MMIX Options} | |
43b72ede AA |
1153 | @gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu |
1154 | -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols | |
1155 | -melf -mbranch-predict -mno-branch-predict -mbase-addresses | |
d77de738 ML |
1156 | -mno-base-addresses -msingle-exit -mno-single-exit} |
1157 | ||
1158 | @emph{MN10300 Options} | |
43b72ede AA |
1159 | @gccoptlist{-mmult-bug -mno-mult-bug |
1160 | -mno-am33 -mam33 -mam33-2 -mam34 | |
1161 | -mtune=@var{cpu-type} | |
1162 | -mreturn-pointer-on-d0 | |
d77de738 ML |
1163 | -mno-crt0 -mrelax -mliw -msetlb} |
1164 | ||
1165 | @emph{Moxie Options} | |
1166 | @gccoptlist{-meb -mel -mmul.x -mno-crt0} | |
1167 | ||
1168 | @emph{MSP430 Options} | |
43b72ede AA |
1169 | @gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax |
1170 | -mwarn-mcu | |
1171 | -mcode-region= -mdata-region= | |
1172 | -msilicon-errata= -msilicon-errata-warn= | |
d77de738 ML |
1173 | -mhwmult= -minrt -mtiny-printf -mmax-inline-shift=} |
1174 | ||
1175 | @emph{NDS32 Options} | |
43b72ede AA |
1176 | @gccoptlist{-mbig-endian -mlittle-endian |
1177 | -mreduced-regs -mfull-regs | |
1178 | -mcmov -mno-cmov | |
1179 | -mext-perf -mno-ext-perf | |
1180 | -mext-perf2 -mno-ext-perf2 | |
1181 | -mext-string -mno-ext-string | |
1182 | -mv3push -mno-v3push | |
1183 | -m16bit -mno-16bit | |
1184 | -misr-vector-size=@var{num} | |
1185 | -mcache-block-size=@var{num} | |
1186 | -march=@var{arch} | |
1187 | -mcmodel=@var{code-model} | |
d77de738 ML |
1188 | -mctor-dtor -mrelax} |
1189 | ||
1190 | @emph{Nios II Options} | |
43b72ede AA |
1191 | @gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt |
1192 | -mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp} | |
1193 | -mel -meb | |
1194 | -mno-bypass-cache -mbypass-cache | |
1195 | -mno-cache-volatile -mcache-volatile | |
1196 | -mno-fast-sw-div -mfast-sw-div | |
1197 | -mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div | |
1198 | -mcustom-@var{insn}=@var{N} -mno-custom-@var{insn} | |
1199 | -mcustom-fpu-cfg=@var{name} | |
1200 | -mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name} | |
d77de738 ML |
1201 | -march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx} |
1202 | ||
1203 | @emph{Nvidia PTX Options} | |
1204 | @gccoptlist{-m64 -mmainkernel -moptimize} | |
1205 | ||
1206 | @emph{OpenRISC Options} | |
43b72ede AA |
1207 | @gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div |
1208 | -msoft-mul -msoft-div | |
1209 | -msoft-float -mhard-float -mdouble-float -munordered-float | |
1210 | -mcmov -mror -mrori -msext -msfimm -mshftimm | |
d77de738 ML |
1211 | -mcmodel=@var{code-model}} |
1212 | ||
1213 | @emph{PDP-11 Options} | |
43b72ede AA |
1214 | @gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 |
1215 | -mint32 -mno-int16 -mint16 -mno-int32 | |
d77de738 ML |
1216 | -msplit -munix-asm -mdec-asm -mgnu-asm -mlra} |
1217 | ||
d77de738 ML |
1218 | @emph{PowerPC Options} |
1219 | See RS/6000 and PowerPC Options. | |
1220 | ||
1221 | @emph{PRU Options} | |
43b72ede | 1222 | @gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop |
f58e6d42 | 1223 | -mabi=@var{variant}} |
d77de738 ML |
1224 | |
1225 | @emph{RISC-V Options} | |
43b72ede AA |
1226 | @gccoptlist{-mbranch-cost=@var{N-instruction} |
1227 | -mplt -mno-plt | |
1228 | -mabi=@var{ABI-string} | |
1229 | -mfdiv -mno-fdiv | |
1230 | -mdiv -mno-div | |
1231 | -misa-spec=@var{ISA-spec-string} | |
1232 | -march=@var{ISA-string} | |
1233 | -mtune=@var{processor-string} | |
1234 | -mpreferred-stack-boundary=@var{num} | |
1235 | -msmall-data-limit=@var{N-bytes} | |
1236 | -msave-restore -mno-save-restore | |
1237 | -mshorten-memrefs -mno-shorten-memrefs | |
1238 | -mstrict-align -mno-strict-align | |
1239 | -mcmodel=medlow -mcmodel=medany | |
1240 | -mexplicit-relocs -mno-explicit-relocs | |
1241 | -mrelax -mno-relax | |
1242 | -mriscv-attribute -mno-riscv-attribute | |
1243 | -malign-data=@var{type} | |
1244 | -mbig-endian -mlittle-endian | |
1245 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} | |
1246 | -mstack-protector-guard-offset=@var{offset} | |
f797260a | 1247 | -mcsr-check -mno-csr-check |
df48285b | 1248 | -minline-atomics -mno-inline-atomics |
949f1ccf CM |
1249 | -minline-strlen -mno-inline-strlen |
1250 | -minline-strcmp -mno-inline-strcmp | |
1251 | -minline-strncmp -mno-inline-strncmp} | |
d77de738 ML |
1252 | |
1253 | @emph{RL78 Options} | |
43b72ede AA |
1254 | @gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs |
1255 | -mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14 | |
d77de738 ML |
1256 | -m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts} |
1257 | ||
1258 | @emph{RS/6000 and PowerPC Options} | |
43b72ede AA |
1259 | @gccoptlist{-mcpu=@var{cpu-type} |
1260 | -mtune=@var{cpu-type} | |
1261 | -mcmodel=@var{code-model} | |
1262 | -mpowerpc64 | |
1263 | -maltivec -mno-altivec | |
1264 | -mpowerpc-gpopt -mno-powerpc-gpopt | |
1265 | -mpowerpc-gfxopt -mno-powerpc-gfxopt | |
1266 | -mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd | |
1267 | -mfprnd -mno-fprnd | |
1268 | -mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp | |
1269 | -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc | |
1270 | -m64 -m32 -mxl-compat -mno-xl-compat -mpe | |
1271 | -malign-power -malign-natural | |
1272 | -msoft-float -mhard-float -mmultiple -mno-multiple | |
1273 | -mupdate -mno-update | |
1274 | -mavoid-indexed-addresses -mno-avoid-indexed-addresses | |
1275 | -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align | |
1276 | -mstrict-align -mno-strict-align -mrelocatable | |
1277 | -mno-relocatable -mrelocatable-lib -mno-relocatable-lib | |
1278 | -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian | |
1279 | -mdynamic-no-pic -mswdiv -msingle-pic-base | |
1280 | -mprioritize-restricted-insns=@var{priority} | |
1281 | -msched-costly-dep=@var{dependence_type} | |
1282 | -minsert-sched-nops=@var{scheme} | |
1283 | -mcall-aixdesc -mcall-eabi -mcall-freebsd | |
1284 | -mcall-linux -mcall-netbsd -mcall-openbsd | |
1285 | -mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi | |
1286 | -mtraceback=@var{traceback_type} | |
1287 | -maix-struct-return -msvr4-struct-return | |
1288 | -mabi=@var{abi-type} -msecure-plt -mbss-plt | |
1289 | -mlongcall -mno-longcall -mpltseq -mno-pltseq | |
1290 | -mblock-move-inline-limit=@var{num} | |
1291 | -mblock-compare-inline-limit=@var{num} | |
1292 | -mblock-compare-inline-loop-limit=@var{num} | |
1293 | -mno-block-ops-unaligned-vsx | |
1294 | -mstring-compare-inline-limit=@var{num} | |
1295 | -misel -mno-isel | |
1296 | -mvrsave -mno-vrsave | |
1297 | -mmulhw -mno-mulhw | |
1298 | -mdlmzb -mno-dlmzb | |
1299 | -mprototype -mno-prototype | |
1300 | -msim -mmvme -mads -myellowknife -memb -msdata | |
1301 | -msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num} | |
1302 | -mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision | |
1303 | -mno-recip-precision | |
1304 | -mveclibabi=@var{type} -mfriz -mno-friz | |
1305 | -mpointers-to-nested-functions -mno-pointers-to-nested-functions | |
1306 | -msave-toc-indirect -mno-save-toc-indirect | |
1307 | -mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector | |
1308 | -mcrypto -mno-crypto -mhtm -mno-htm | |
1309 | -mquad-memory -mno-quad-memory | |
1310 | -mquad-memory-atomic -mno-quad-memory-atomic | |
1311 | -mcompat-align-parm -mno-compat-align-parm | |
1312 | -mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware | |
1313 | -mgnu-attribute -mno-gnu-attribute | |
1314 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} | |
1315 | -mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed | |
1316 | -mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect | |
d77de738 ML |
1317 | -mprivileged -mno-privileged} |
1318 | ||
1319 | @emph{RX Options} | |
43b72ede AA |
1320 | @gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu |
1321 | -mcpu= | |
1322 | -mbig-endian-data -mlittle-endian-data | |
1323 | -msmall-data | |
1324 | -msim -mno-sim | |
1325 | -mas100-syntax -mno-as100-syntax | |
1326 | -mrelax | |
1327 | -mmax-constant-size= | |
1328 | -mint-register= | |
1329 | -mpid | |
1330 | -mallow-string-insns -mno-allow-string-insns | |
1331 | -mjsr | |
1332 | -mno-warn-multiple-fast-interrupts | |
d77de738 ML |
1333 | -msave-acc-in-interrupts} |
1334 | ||
1335 | @emph{S/390 and zSeries Options} | |
43b72ede AA |
1336 | @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} |
1337 | -mhard-float -msoft-float -mhard-dfp -mno-hard-dfp | |
1338 | -mlong-double-64 -mlong-double-128 | |
1339 | -mbackchain -mno-backchain -mpacked-stack -mno-packed-stack | |
1340 | -msmall-exec -mno-small-exec -mmvcle -mno-mvcle | |
1341 | -m64 -m31 -mdebug -mno-debug -mesa -mzarch | |
1342 | -mhtm -mvx -mzvector | |
1343 | -mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip | |
1344 | -mfused-madd -mno-fused-madd | |
1345 | -mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard | |
d77de738 ML |
1346 | -mhotpatch=@var{halfwords},@var{halfwords}} |
1347 | ||
d77de738 | 1348 | @emph{SH Options} |
43b72ede AA |
1349 | @gccoptlist{-m1 -m2 -m2e |
1350 | -m2a-nofpu -m2a-single-only -m2a-single -m2a | |
1351 | -m3 -m3e | |
1352 | -m4-nofpu -m4-single-only -m4-single -m4 | |
1353 | -m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al | |
1354 | -mb -ml -mdalign -mrelax | |
1355 | -mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave | |
1356 | -mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct | |
1357 | -mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy} | |
1358 | -mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} | |
1359 | -maccumulate-outgoing-args | |
1360 | -matomic-model=@var{atomic-model} | |
1361 | -mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch | |
1362 | -mcbranch-force-delay-slot | |
1363 | -mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra | |
d77de738 ML |
1364 | -mpretend-cmove -mtas} |
1365 | ||
1366 | @emph{Solaris 2 Options} | |
43b72ede | 1367 | @gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text |
d77de738 ML |
1368 | -pthreads} |
1369 | ||
1370 | @emph{SPARC Options} | |
43b72ede AA |
1371 | @gccoptlist{-mcpu=@var{cpu-type} |
1372 | -mtune=@var{cpu-type} | |
1373 | -mcmodel=@var{code-model} | |
1374 | -mmemory-model=@var{mem-model} | |
1375 | -m32 -m64 -mapp-regs -mno-app-regs | |
1376 | -mfaster-structs -mno-faster-structs -mflat -mno-flat | |
1377 | -mfpu -mno-fpu -mhard-float -msoft-float | |
1378 | -mhard-quad-float -msoft-quad-float | |
1379 | -mstack-bias -mno-stack-bias | |
1380 | -mstd-struct-return -mno-std-struct-return | |
1381 | -munaligned-doubles -mno-unaligned-doubles | |
1382 | -muser-mode -mno-user-mode | |
1383 | -mv8plus -mno-v8plus -mvis -mno-vis | |
1384 | -mvis2 -mno-vis2 -mvis3 -mno-vis3 | |
1385 | -mvis4 -mno-vis4 -mvis4b -mno-vis4b | |
1386 | -mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld | |
1387 | -mpopc -mno-popc -msubxc -mno-subxc | |
1388 | -mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc | |
d77de738 ML |
1389 | -mlra -mno-lra} |
1390 | ||
1391 | @emph{System V Options} | |
1392 | @gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}} | |
1393 | ||
1394 | @emph{V850 Options} | |
43b72ede AA |
1395 | @gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep |
1396 | -mprolog-function -mno-prolog-function -mspace | |
1397 | -mtda=@var{n} -msda=@var{n} -mzda=@var{n} | |
1398 | -mapp-regs -mno-app-regs | |
1399 | -mdisable-callt -mno-disable-callt | |
1400 | -mv850e2v3 -mv850e2 -mv850e1 -mv850es | |
1401 | -mv850e -mv850 -mv850e3v5 | |
1402 | -mloop | |
1403 | -mrelax | |
1404 | -mlong-jumps | |
1405 | -msoft-float | |
1406 | -mhard-float | |
1407 | -mgcc-abi | |
1408 | -mrh850-abi | |
d77de738 ML |
1409 | -mbig-switch} |
1410 | ||
1411 | @emph{VAX Options} | |
1412 | @gccoptlist{-mg -mgnu -munix -mlra} | |
1413 | ||
1414 | @emph{Visium Options} | |
43b72ede | 1415 | @gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float |
d77de738 ML |
1416 | -mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode} |
1417 | ||
1418 | @emph{VMS Options} | |
43b72ede | 1419 | @gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64 |
d77de738 ML |
1420 | -mpointer-size=@var{size}} |
1421 | ||
1422 | @emph{VxWorks Options} | |
b6f4b000 | 1423 | @gccoptlist{-mrtp -msmp -non-static -Bstatic -Bdynamic |
d77de738 ML |
1424 | -Xbind-lazy -Xbind-now} |
1425 | ||
1426 | @emph{x86 Options} | |
43b72ede AA |
1427 | @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} |
1428 | -mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default | |
1429 | -mfpmath=@var{unit} | |
1430 | -masm=@var{dialect} -mno-fancy-math-387 | |
1431 | -mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float | |
1432 | -mno-wide-multiply -mrtd -malign-double | |
1433 | -mpreferred-stack-boundary=@var{num} | |
1434 | -mincoming-stack-boundary=@var{num} | |
1435 | -mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait | |
1436 | -mrecip -mrecip=@var{opt} | |
1437 | -mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt} | |
ad5b757d | 1438 | -mpartial-vector-fp-math |
43b72ede AA |
1439 | -mmove-max=@var{bits} -mstore-max=@var{bits} |
1440 | -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx | |
1441 | -mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl | |
1442 | -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes | |
1443 | -mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd | |
1444 | -mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves | |
1445 | -msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop | |
1446 | -madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp | |
1447 | -mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg | |
1448 | -mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call | |
1449 | -mavx512vbmi2 -mavx512bf16 -menqcmd | |
1450 | -mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq | |
1451 | -mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid | |
1452 | -mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk | |
1453 | -mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni | |
1454 | -mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16 | |
e686416b | 1455 | -mprefetchi -mraoint -mamx-complex -mavxvnniint16 -msm3 -msha512 -msm4 -mapxf |
2f8f7ee2 | 1456 | -musermsr -mavx10.1 -mavx10.1-256 -mavx10.1-512 |
43b72ede AA |
1457 | -mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops |
1458 | -minline-stringops-dynamically -mstringop-strategy=@var{alg} | |
1459 | -mkl -mwidekl | |
1460 | -mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy} | |
1461 | -mpush-args -maccumulate-outgoing-args -m128bit-long-double | |
1462 | -m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128 | |
1463 | -mregparm=@var{num} -msseregparm | |
1464 | -mveclibabi=@var{type} -mvect8-ret-in-mem | |
1465 | -mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign | |
1466 | -momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs | |
1467 | -mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} | |
1468 | -m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num} | |
1469 | -msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv | |
1470 | -minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name} | |
1471 | -mavx256-split-unaligned-load -mavx256-split-unaligned-store | |
1472 | -malign-data=@var{type} -mstack-protector-guard=@var{guard} | |
1473 | -mstack-protector-guard-reg=@var{reg} | |
1474 | -mstack-protector-guard-offset=@var{offset} | |
1475 | -mstack-protector-guard-symbol=@var{symbol} | |
1476 | -mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop | |
1477 | -mindirect-branch=@var{choice} -mfunction-return=@var{choice} | |
1478 | -mindirect-branch-register -mharden-sls=@var{choice} | |
1479 | -mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access | |
bb576017 | 1480 | -munroll-only-small-loops -mlam=@var{choice}} |
d77de738 ML |
1481 | |
1482 | @emph{x86 Windows Options} | |
453cb585 | 1483 | @gccoptlist{-mconsole -mcrtdll=@var{library} -mcygwin -mno-cygwin -mdll |
43b72ede | 1484 | -mnop-fun-dllimport -mthread |
d77de738 ML |
1485 | -municode -mwin32 -mwindows -fno-set-stack-executable} |
1486 | ||
1487 | @emph{Xstormy16 Options} | |
1488 | @gccoptlist{-msim} | |
1489 | ||
1490 | @emph{Xtensa Options} | |
43b72ede AA |
1491 | @gccoptlist{-mconst16 -mno-const16 |
1492 | -mfused-madd -mno-fused-madd | |
1493 | -mforce-no-pic | |
1494 | -mserialize-volatile -mno-serialize-volatile | |
1495 | -mtext-section-literals -mno-text-section-literals | |
1496 | -mauto-litpools -mno-auto-litpools | |
1497 | -mtarget-align -mno-target-align | |
1498 | -mlongcalls -mno-longcalls | |
1499 | -mabi=@var{abi-type} | |
675b390e MF |
1500 | -mextra-l32r-costs=@var{cycles} |
1501 | -mstrict-align -mno-strict-align} | |
d77de738 ML |
1502 | |
1503 | @emph{zSeries Options} | |
1504 | See S/390 and zSeries Options. | |
1505 | @end table | |
1506 | ||
1507 | ||
1508 | @node Overall Options | |
1509 | @section Options Controlling the Kind of Output | |
1510 | ||
1511 | Compilation can involve up to four stages: preprocessing, compilation | |
1512 | proper, assembly and linking, always in that order. GCC is capable of | |
1513 | preprocessing and compiling several files either into several | |
1514 | assembler input files, or into one assembler input file; then each | |
1515 | assembler input file produces an object file, and linking combines all | |
1516 | the object files (those newly compiled, and those specified as input) | |
1517 | into an executable file. | |
1518 | ||
1519 | @cindex file name suffix | |
1520 | For any given input file, the file name suffix determines what kind of | |
1521 | compilation is done: | |
1522 | ||
1523 | @table @gcctabopt | |
1524 | @item @var{file}.c | |
1525 | C source code that must be preprocessed. | |
1526 | ||
1527 | @item @var{file}.i | |
1528 | C source code that should not be preprocessed. | |
1529 | ||
1530 | @item @var{file}.ii | |
1531 | C++ source code that should not be preprocessed. | |
1532 | ||
1533 | @item @var{file}.m | |
1534 | Objective-C source code. Note that you must link with the @file{libobjc} | |
1535 | library to make an Objective-C program work. | |
1536 | ||
1537 | @item @var{file}.mi | |
1538 | Objective-C source code that should not be preprocessed. | |
1539 | ||
1540 | @item @var{file}.mm | |
1541 | @itemx @var{file}.M | |
1542 | Objective-C++ source code. Note that you must link with the @file{libobjc} | |
1543 | library to make an Objective-C++ program work. Note that @samp{.M} refers | |
1544 | to a literal capital M@. | |
1545 | ||
1546 | @item @var{file}.mii | |
1547 | Objective-C++ source code that should not be preprocessed. | |
1548 | ||
1549 | @item @var{file}.h | |
1550 | C, C++, Objective-C or Objective-C++ header file to be turned into a | |
1551 | precompiled header (default), or C, C++ header file to be turned into an | |
1552 | Ada spec (via the @option{-fdump-ada-spec} switch). | |
1553 | ||
1554 | @item @var{file}.cc | |
1555 | @itemx @var{file}.cp | |
1556 | @itemx @var{file}.cxx | |
1557 | @itemx @var{file}.cpp | |
1558 | @itemx @var{file}.CPP | |
1559 | @itemx @var{file}.c++ | |
1560 | @itemx @var{file}.C | |
1561 | C++ source code that must be preprocessed. Note that in @samp{.cxx}, | |
1562 | the last two letters must both be literally @samp{x}. Likewise, | |
1563 | @samp{.C} refers to a literal capital C@. | |
1564 | ||
1565 | @item @var{file}.mm | |
1566 | @itemx @var{file}.M | |
1567 | Objective-C++ source code that must be preprocessed. | |
1568 | ||
1569 | @item @var{file}.mii | |
1570 | Objective-C++ source code that should not be preprocessed. | |
1571 | ||
1572 | @item @var{file}.hh | |
1573 | @itemx @var{file}.H | |
1574 | @itemx @var{file}.hp | |
1575 | @itemx @var{file}.hxx | |
1576 | @itemx @var{file}.hpp | |
1577 | @itemx @var{file}.HPP | |
1578 | @itemx @var{file}.h++ | |
1579 | @itemx @var{file}.tcc | |
1580 | C++ header file to be turned into a precompiled header or Ada spec. | |
1581 | ||
1582 | @item @var{file}.f | |
1583 | @itemx @var{file}.for | |
1584 | @itemx @var{file}.ftn | |
1585 | Fixed form Fortran source code that should not be preprocessed. | |
1586 | ||
1587 | @item @var{file}.F | |
1588 | @itemx @var{file}.FOR | |
1589 | @itemx @var{file}.fpp | |
1590 | @itemx @var{file}.FPP | |
1591 | @itemx @var{file}.FTN | |
1592 | Fixed form Fortran source code that must be preprocessed (with the traditional | |
1593 | preprocessor). | |
1594 | ||
1595 | @item @var{file}.f90 | |
1596 | @itemx @var{file}.f95 | |
1597 | @itemx @var{file}.f03 | |
1598 | @itemx @var{file}.f08 | |
1599 | Free form Fortran source code that should not be preprocessed. | |
1600 | ||
1601 | @item @var{file}.F90 | |
1602 | @itemx @var{file}.F95 | |
1603 | @itemx @var{file}.F03 | |
1604 | @itemx @var{file}.F08 | |
1605 | Free form Fortran source code that must be preprocessed (with the | |
1606 | traditional preprocessor). | |
1607 | ||
1608 | @item @var{file}.go | |
1609 | Go source code. | |
1610 | ||
1611 | @item @var{file}.d | |
1612 | D source code. | |
1613 | ||
1614 | @item @var{file}.di | |
1615 | D interface file. | |
1616 | ||
1617 | @item @var{file}.dd | |
1618 | D documentation code (Ddoc). | |
1619 | ||
1620 | @item @var{file}.ads | |
1621 | Ada source code file that contains a library unit declaration (a | |
1622 | declaration of a package, subprogram, or generic, or a generic | |
1623 | instantiation), or a library unit renaming declaration (a package, | |
1624 | generic, or subprogram renaming declaration). Such files are also | |
1625 | called @dfn{specs}. | |
1626 | ||
1627 | @item @var{file}.adb | |
1628 | Ada source code file containing a library unit body (a subprogram or | |
1629 | package body). Such files are also called @dfn{bodies}. | |
1630 | ||
1631 | @c GCC also knows about some suffixes for languages not yet included: | |
1632 | @c Ratfor: | |
1633 | @c @var{file}.r | |
1634 | ||
1635 | @item @var{file}.s | |
1636 | Assembler code. | |
1637 | ||
1638 | @item @var{file}.S | |
1639 | @itemx @var{file}.sx | |
1640 | Assembler code that must be preprocessed. | |
1641 | ||
1642 | @item @var{other} | |
1643 | An object file to be fed straight into linking. | |
1644 | Any file name with no recognized suffix is treated this way. | |
1645 | @end table | |
1646 | ||
1647 | @opindex x | |
1648 | You can specify the input language explicitly with the @option{-x} option: | |
1649 | ||
1650 | @table @gcctabopt | |
1651 | @item -x @var{language} | |
1652 | Specify explicitly the @var{language} for the following input files | |
1653 | (rather than letting the compiler choose a default based on the file | |
1654 | name suffix). This option applies to all following input files until | |
1655 | the next @option{-x} option. Possible values for @var{language} are: | |
1656 | @smallexample | |
1657 | c c-header cpp-output | |
1658 | c++ c++-header c++-system-header c++-user-header c++-cpp-output | |
1659 | objective-c objective-c-header objective-c-cpp-output | |
1660 | objective-c++ objective-c++-header objective-c++-cpp-output | |
1661 | assembler assembler-with-cpp | |
1662 | ada | |
1663 | d | |
1664 | f77 f77-cpp-input f95 f95-cpp-input | |
1665 | go | |
1666 | @end smallexample | |
1667 | ||
1668 | @item -x none | |
1669 | Turn off any specification of a language, so that subsequent files are | |
1670 | handled according to their file name suffixes (as they are if @option{-x} | |
1671 | has not been used at all). | |
1672 | @end table | |
1673 | ||
1674 | If you only want some of the stages of compilation, you can use | |
1675 | @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and | |
1676 | one of the options @option{-c}, @option{-S}, or @option{-E} to say where | |
1677 | @command{gcc} is to stop. Note that some combinations (for example, | |
1678 | @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all. | |
1679 | ||
1680 | @table @gcctabopt | |
d77de738 | 1681 | @opindex c |
ddf6fe37 | 1682 | @item -c |
d77de738 ML |
1683 | Compile or assemble the source files, but do not link. The linking |
1684 | stage simply is not done. The ultimate output is in the form of an | |
1685 | object file for each source file. | |
1686 | ||
1687 | By default, the object file name for a source file is made by replacing | |
1688 | the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}. | |
1689 | ||
1690 | Unrecognized input files, not requiring compilation or assembly, are | |
1691 | ignored. | |
1692 | ||
d77de738 | 1693 | @opindex S |
ddf6fe37 | 1694 | @item -S |
d77de738 ML |
1695 | Stop after the stage of compilation proper; do not assemble. The output |
1696 | is in the form of an assembler code file for each non-assembler input | |
1697 | file specified. | |
1698 | ||
1699 | By default, the assembler file name for a source file is made by | |
1700 | replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}. | |
1701 | ||
1702 | Input files that don't require compilation are ignored. | |
1703 | ||
d77de738 | 1704 | @opindex E |
ddf6fe37 | 1705 | @item -E |
d77de738 ML |
1706 | Stop after the preprocessing stage; do not run the compiler proper. The |
1707 | output is in the form of preprocessed source code, which is sent to the | |
1708 | standard output. | |
1709 | ||
1710 | Input files that don't require preprocessing are ignored. | |
1711 | ||
1712 | @cindex output file option | |
d77de738 | 1713 | @opindex o |
ddf6fe37 | 1714 | @item -o @var{file} |
d77de738 ML |
1715 | Place the primary output in file @var{file}. This applies to whatever |
1716 | sort of output is being produced, whether it be an executable file, an | |
1717 | object file, an assembler file or preprocessed C code. | |
1718 | ||
1719 | If @option{-o} is not specified, the default is to put an executable | |
1720 | file in @file{a.out}, the object file for | |
1721 | @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its | |
1722 | assembler file in @file{@var{source}.s}, a precompiled header file in | |
1723 | @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on | |
1724 | standard output. | |
1725 | ||
1726 | Though @option{-o} names only the primary output, it also affects the | |
1727 | naming of auxiliary and dump outputs. See the examples below. Unless | |
1728 | overridden, both auxiliary outputs and dump outputs are placed in the | |
1729 | same directory as the primary output. In auxiliary outputs, the suffix | |
1730 | of the input file is replaced with that of the auxiliary output file | |
1731 | type; in dump outputs, the suffix of the dump file is appended to the | |
1732 | input file suffix. In compilation commands, the base name of both | |
1733 | auxiliary and dump outputs is that of the primary output; in compile and | |
1734 | link commands, the primary output name, minus the executable suffix, is | |
1735 | combined with the input file name. If both share the same base name, | |
1736 | disregarding the suffix, the result of the combination is that base | |
1737 | name, otherwise, they are concatenated, separated by a dash. | |
1738 | ||
1739 | @smallexample | |
1740 | gcc -c foo.c ... | |
1741 | @end smallexample | |
1742 | ||
1743 | will use @file{foo.o} as the primary output, and place aux outputs and | |
1744 | dumps next to it, e.g., aux file @file{foo.dwo} for | |
1745 | @option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for | |
1746 | @option{-fdump-rtl-final}. | |
1747 | ||
1748 | If a non-linker output file is explicitly specified, aux and dump files | |
1749 | by default take the same base name: | |
1750 | ||
1751 | @smallexample | |
1752 | gcc -c foo.c -o dir/foobar.o ... | |
1753 | @end smallexample | |
1754 | ||
1755 | will name aux outputs @file{dir/foobar.*} and dump outputs | |
1756 | @file{dir/foobar.c.*}. | |
1757 | ||
1758 | A linker output will instead prefix aux and dump outputs: | |
1759 | ||
1760 | @smallexample | |
1761 | gcc foo.c bar.c -o dir/foobar ... | |
1762 | @end smallexample | |
1763 | ||
1764 | will generally name aux outputs @file{dir/foobar-foo.*} and | |
1765 | @file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and | |
1766 | @file{dir/foobar-bar.c.*}. | |
1767 | ||
1768 | The one exception to the above is when the executable shares the base | |
1769 | name with the single input: | |
1770 | ||
1771 | @smallexample | |
1772 | gcc foo.c -o dir/foo ... | |
1773 | @end smallexample | |
1774 | ||
1775 | in which case aux outputs are named @file{dir/foo.*} and dump outputs | |
1776 | named @file{dir/foo.c.*}. | |
1777 | ||
1778 | The location and the names of auxiliary and dump outputs can be adjusted | |
1779 | by the options @option{-dumpbase}, @option{-dumpbase-ext}, | |
1780 | @option{-dumpdir}, @option{-save-temps=cwd}, and | |
1781 | @option{-save-temps=obj}. | |
1782 | ||
1783 | ||
d77de738 | 1784 | @opindex dumpbase |
ddf6fe37 | 1785 | @item -dumpbase @var{dumpbase} |
d77de738 ML |
1786 | This option sets the base name for auxiliary and dump output files. It |
1787 | does not affect the name of the primary output file. Intermediate | |
1788 | outputs, when preserved, are not regarded as primary outputs, but as | |
1789 | auxiliary outputs: | |
1790 | ||
1791 | @smallexample | |
1792 | gcc -save-temps -S foo.c | |
1793 | @end smallexample | |
1794 | ||
1795 | saves the (no longer) temporary preprocessed file in @file{foo.i}, and | |
1796 | then compiles to the (implied) output file @file{foo.s}, whereas: | |
1797 | ||
1798 | @smallexample | |
1799 | gcc -save-temps -dumpbase save-foo -c foo.c | |
1800 | @end smallexample | |
1801 | ||
1802 | preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now | |
1803 | an intermediate, thus auxiliary output), and then assembles to the | |
1804 | (implied) output file @file{foo.o}. | |
1805 | ||
1806 | Absent this option, dump and aux files take their names from the input | |
1807 | file, or from the (non-linker) output file, if one is explicitly | |
1808 | specified: dump output files (e.g. those requested by @option{-fdump-*} | |
1809 | options) with the input name suffix, and aux output files (those | |
1810 | requested by other non-dump options, e.g. @code{-save-temps}, | |
1811 | @code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it. | |
1812 | ||
1813 | Similar suffix differentiation of dump and aux outputs can be attained | |
1814 | for explicitly-given @option{-dumpbase basename.suf} by also specifying | |
1815 | @option{-dumpbase-ext .suf}. | |
1816 | ||
1817 | If @var{dumpbase} is explicitly specified with any directory component, | |
1818 | any @var{dumppfx} specification (e.g. @option{-dumpdir} or | |
1819 | @option{-save-temps=*}) is ignored, and instead of appending to it, | |
1820 | @var{dumpbase} fully overrides it: | |
1821 | ||
1822 | @smallexample | |
1823 | gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \ | |
1824 | -dumpdir pfx- -save-temps=cwd ... | |
1825 | @end smallexample | |
1826 | ||
1827 | creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding | |
1828 | @file{dir/} in @option{-o}, the @file{./} prefix implied by | |
1829 | @option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}. | |
1830 | ||
1831 | When @option{-dumpbase} is specified in a command that compiles multiple | |
1832 | inputs, or that compiles and then links, it may be combined with | |
1833 | @var{dumppfx}, as specified under @option{-dumpdir}. Then, each input | |
1834 | file is compiled using the combined @var{dumppfx}, and default values | |
1835 | for @var{dumpbase} and @var{auxdropsuf} are computed for each input | |
1836 | file: | |
1837 | ||
1838 | @smallexample | |
1839 | gcc foo.c bar.c -c -dumpbase main ... | |
1840 | @end smallexample | |
1841 | ||
1842 | creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids | |
1843 | overwriting the auxiliary and dump outputs by using the @var{dumpbase} | |
1844 | as a prefix, creating auxiliary and dump outputs named @file{main-foo.*} | |
1845 | and @file{main-bar.*}. | |
1846 | ||
1847 | An empty string specified as @var{dumpbase} avoids the influence of the | |
1848 | output basename in the naming of auxiliary and dump outputs during | |
1849 | compilation, computing default values : | |
1850 | ||
1851 | @smallexample | |
1852 | gcc -c foo.c -o dir/foobar.o -dumpbase '' ... | |
1853 | @end smallexample | |
1854 | ||
1855 | will name aux outputs @file{dir/foo.*} and dump outputs | |
1856 | @file{dir/foo.c.*}. Note how their basenames are taken from the input | |
1857 | name, but the directory still defaults to that of the output. | |
1858 | ||
1859 | The empty-string dumpbase does not prevent the use of the output | |
1860 | basename for outputs during linking: | |
1861 | ||
1862 | @smallexample | |
1863 | gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ... | |
1864 | @end smallexample | |
1865 | ||
1866 | The compilation of the source files will name auxiliary outputs | |
1867 | @file{dir/foo.*} and @file{dir/bar.*}, and dump outputs | |
1868 | @file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during | |
1869 | linking will use @file{dir/foobar.} as the prefix for dumps and | |
1870 | auxiliary files. | |
1871 | ||
1872 | ||
d77de738 | 1873 | @opindex dumpbase-ext |
ddf6fe37 | 1874 | @item -dumpbase-ext @var{auxdropsuf} |
d77de738 ML |
1875 | When forming the name of an auxiliary (but not a dump) output file, drop |
1876 | trailing @var{auxdropsuf} from @var{dumpbase} before appending any | |
1877 | suffixes. If not specified, this option defaults to the suffix of a | |
1878 | default @var{dumpbase}, i.e., the suffix of the input file when | |
1879 | @option{-dumpbase} is not present in the command line, or @var{dumpbase} | |
1880 | is combined with @var{dumppfx}. | |
1881 | ||
1882 | @smallexample | |
1883 | gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ... | |
1884 | @end smallexample | |
1885 | ||
1886 | creates @file{dir/foo.o} as the main output, and generates auxiliary | |
1887 | outputs in @file{dir/x-foo.*}, taking the location of the primary | |
1888 | output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump | |
1889 | outputs retain the suffix: @file{dir/x-foo.c.*}. | |
1890 | ||
1891 | This option is disregarded if it does not match the suffix of a | |
1892 | specified @var{dumpbase}, except as an alternative to the executable | |
1893 | suffix when appending the linker output base name to @var{dumppfx}, as | |
1894 | specified below: | |
1895 | ||
1896 | @smallexample | |
1897 | gcc foo.c bar.c -o main.out -dumpbase-ext .out ... | |
1898 | @end smallexample | |
1899 | ||
1900 | creates @file{main.out} as the primary output, and avoids overwriting | |
1901 | the auxiliary and dump outputs by using the executable name minus | |
1902 | @var{auxdropsuf} as a prefix, creating auxiliary outputs named | |
1903 | @file{main-foo.*} and @file{main-bar.*} and dump outputs named | |
1904 | @file{main-foo.c.*} and @file{main-bar.c.*}. | |
1905 | ||
1906 | ||
d77de738 | 1907 | @opindex dumpdir |
ddf6fe37 | 1908 | @item -dumpdir @var{dumppfx} |
d77de738 ML |
1909 | When forming the name of an auxiliary or dump output file, use |
1910 | @var{dumppfx} as a prefix: | |
1911 | ||
1912 | @smallexample | |
1913 | gcc -dumpdir pfx- -c foo.c ... | |
1914 | @end smallexample | |
1915 | ||
1916 | creates @file{foo.o} as the primary output, and auxiliary outputs named | |
1917 | @file{pfx-foo.*}, combining the given @var{dumppfx} with the default | |
1918 | @var{dumpbase} derived from the default primary output, derived in turn | |
1919 | from the input name. Dump outputs also take the input name suffix: | |
1920 | @file{pfx-foo.c.*}. | |
1921 | ||
1922 | If @var{dumppfx} is to be used as a directory name, it must end with a | |
1923 | directory separator: | |
1924 | ||
1925 | @smallexample | |
1926 | gcc -dumpdir dir/ -c foo.c -o obj/bar.o ... | |
1927 | @end smallexample | |
1928 | ||
1929 | creates @file{obj/bar.o} as the primary output, and auxiliary outputs | |
1930 | named @file{dir/bar.*}, combining the given @var{dumppfx} with the | |
1931 | default @var{dumpbase} derived from the primary output name. Dump | |
1932 | outputs also take the input name suffix: @file{dir/bar.c.*}. | |
1933 | ||
1934 | It defaults to the location of the output file, unless the output | |
1935 | file is a special file like @code{/dev/null}. Options | |
1936 | @option{-save-temps=cwd} and @option{-save-temps=obj} override this | |
1937 | default, just like an explicit @option{-dumpdir} option. In case | |
1938 | multiple such options are given, the last one prevails: | |
1939 | ||
1940 | @smallexample | |
1941 | gcc -dumpdir pfx- -c foo.c -save-temps=obj ... | |
1942 | @end smallexample | |
1943 | ||
1944 | outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because | |
1945 | @option{-save-temps=*} overrides the @var{dumppfx} given by the earlier | |
1946 | @option{-dumpdir} option. It does not matter that @option{=obj} is the | |
1947 | default for @option{-save-temps}, nor that the output directory is | |
1948 | implicitly the current directory. Dump outputs are named | |
1949 | @file{foo.c.*}. | |
1950 | ||
1951 | When compiling from multiple input files, if @option{-dumpbase} is | |
1952 | specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash | |
1953 | are appended to (or override, if containing any directory components) an | |
1954 | explicit or defaulted @var{dumppfx}, so that each of the multiple | |
1955 | compilations gets differently-named aux and dump outputs. | |
1956 | ||
1957 | @smallexample | |
1958 | gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ... | |
1959 | @end smallexample | |
1960 | ||
1961 | outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and | |
1962 | @file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}. | |
1963 | Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*} | |
1964 | and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the | |
1965 | single-input compilation: | |
1966 | ||
1967 | @smallexample | |
1968 | gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ... | |
1969 | @end smallexample | |
1970 | ||
1971 | that, applying @option{-dumpbase} to a single source, does not compute | |
1972 | and append a separate @var{dumpbase} per input file. Its auxiliary and | |
1973 | dump outputs go in @file{dir/pfx-main.*}. | |
1974 | ||
1975 | When compiling and then linking from multiple input files, a defaulted | |
1976 | or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}- | |
1977 | transformation above (e.g. the compilation of @file{foo.c} and | |
1978 | @file{bar.c} above, but without @option{-c}). If neither | |
1979 | @option{-dumpdir} nor @option{-dumpbase} are given, the linker output | |
1980 | base name, minus @var{auxdropsuf}, if specified, or the executable | |
1981 | suffix otherwise, plus a dash is appended to the default @var{dumppfx} | |
1982 | instead. Note, however, that unlike earlier cases of linking: | |
1983 | ||
1984 | @smallexample | |
1985 | gcc foo.c bar.c -dumpdir dir/pfx- -o main ... | |
1986 | @end smallexample | |
1987 | ||
1988 | does not append the output name @file{main} to @var{dumppfx}, because | |
1989 | @option{-dumpdir} is explicitly specified. The goal is that the | |
1990 | explicitly-specified @var{dumppfx} may contain the specified output name | |
1991 | as part of the prefix, if desired; only an explicitly-specified | |
1992 | @option{-dumpbase} would be combined with it, in order to avoid simply | |
1993 | discarding a meaningful option. | |
1994 | ||
1995 | When compiling and then linking from a single input file, the linker | |
1996 | output base name will only be appended to the default @var{dumppfx} as | |
1997 | above if it does not share the base name with the single input file | |
1998 | name. This has been covered in single-input linking cases above, but | |
1999 | not with an explicit @option{-dumpdir} that inhibits the combination, | |
2000 | even if overridden by @option{-save-temps=*}: | |
2001 | ||
2002 | @smallexample | |
2003 | gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ... | |
2004 | @end smallexample | |
2005 | ||
2006 | Auxiliary outputs are named @file{foo.*}, and dump outputs | |
2007 | @file{foo.c.*}, in the current working directory as ultimately requested | |
2008 | by @option{-save-temps=cwd}. | |
2009 | ||
2010 | Summing it all up for an intuitive though slightly imprecise data flow: | |
2011 | the primary output name is broken into a directory part and a basename | |
2012 | part; @var{dumppfx} is set to the former, unless overridden by | |
2013 | @option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set | |
2014 | to the latter, unless overriden by @option{-dumpbase}. If there are | |
2015 | multiple inputs or linking, this @var{dumpbase} may be combined with | |
2016 | @var{dumppfx} and taken from each input file. Auxiliary output names | |
2017 | for each input are formed by combining @var{dumppfx}, @var{dumpbase} | |
2018 | minus suffix, and the auxiliary output suffix; dump output names are | |
2019 | only different in that the suffix from @var{dumpbase} is retained. | |
2020 | ||
2021 | When it comes to auxiliary and dump outputs created during LTO | |
2022 | recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as | |
2023 | given or as derived from the linker output name but not from inputs, | |
2024 | even in cases in which this combination would not otherwise be used as | |
2025 | such, is passed down with a trailing period replacing the compiler-added | |
2026 | dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper}; | |
2027 | being involved in linking, this program does not normally get any | |
2028 | @option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them. | |
2029 | ||
2030 | When running sub-compilers, @command{lto-wrapper} appends LTO stage | |
2031 | names to the received @var{dumppfx}, ensures it contains a directory | |
2032 | component so that it overrides any @option{-dumpdir}, and passes that as | |
2033 | @option{-dumpbase} to sub-compilers. | |
2034 | ||
d77de738 | 2035 | @opindex v |
ddf6fe37 | 2036 | @item -v |
d77de738 ML |
2037 | Print (on standard error output) the commands executed to run the stages |
2038 | of compilation. Also print the version number of the compiler driver | |
2039 | program and of the preprocessor and the compiler proper. | |
2040 | ||
d77de738 | 2041 | @opindex ### |
ddf6fe37 | 2042 | @item -### |
d77de738 ML |
2043 | Like @option{-v} except the commands are not executed and arguments |
2044 | are quoted unless they contain only alphanumeric characters or @code{./-_}. | |
2045 | This is useful for shell scripts to capture the driver-generated command lines. | |
2046 | ||
d77de738 | 2047 | @opindex help |
ddf6fe37 | 2048 | @item --help |
d77de738 ML |
2049 | Print (on the standard output) a description of the command-line options |
2050 | understood by @command{gcc}. If the @option{-v} option is also specified | |
2051 | then @option{--help} is also passed on to the various processes | |
2052 | invoked by @command{gcc}, so that they can display the command-line options | |
2053 | they accept. If the @option{-Wextra} option has also been specified | |
2054 | (prior to the @option{--help} option), then command-line options that | |
2055 | have no documentation associated with them are also displayed. | |
2056 | ||
d77de738 | 2057 | @opindex target-help |
ddf6fe37 | 2058 | @item --target-help |
d77de738 ML |
2059 | Print (on the standard output) a description of target-specific command-line |
2060 | options for each tool. For some targets extra target-specific | |
2061 | information may also be printed. | |
2062 | ||
2063 | @item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]} | |
2064 | Print (on the standard output) a description of the command-line | |
2065 | options understood by the compiler that fit into all specified classes | |
2066 | and qualifiers. These are the supported classes: | |
2067 | ||
2068 | @table @asis | |
2069 | @item @samp{optimizers} | |
2070 | Display all of the optimization options supported by the | |
2071 | compiler. | |
2072 | ||
2073 | @item @samp{warnings} | |
2074 | Display all of the options controlling warning messages | |
2075 | produced by the compiler. | |
2076 | ||
2077 | @item @samp{target} | |
2078 | Display target-specific options. Unlike the | |
2079 | @option{--target-help} option however, target-specific options of the | |
2080 | linker and assembler are not displayed. This is because those | |
2081 | tools do not currently support the extended @option{--help=} syntax. | |
2082 | ||
2083 | @item @samp{params} | |
2084 | Display the values recognized by the @option{--param} | |
2085 | option. | |
2086 | ||
2087 | @item @var{language} | |
2088 | Display the options supported for @var{language}, where | |
2089 | @var{language} is the name of one of the languages supported in this | |
2090 | version of GCC@. If an option is supported by all languages, one needs | |
2091 | to select @samp{common} class. | |
2092 | ||
2093 | @item @samp{common} | |
2094 | Display the options that are common to all languages. | |
2095 | @end table | |
2096 | ||
2097 | These are the supported qualifiers: | |
2098 | ||
2099 | @table @asis | |
2100 | @item @samp{undocumented} | |
2101 | Display only those options that are undocumented. | |
2102 | ||
2103 | @item @samp{joined} | |
2104 | Display options taking an argument that appears after an equal | |
2105 | sign in the same continuous piece of text, such as: | |
2106 | @samp{--help=target}. | |
2107 | ||
2108 | @item @samp{separate} | |
2109 | Display options taking an argument that appears as a separate word | |
2110 | following the original option, such as: @samp{-o output-file}. | |
2111 | @end table | |
2112 | ||
2113 | Thus for example to display all the undocumented target-specific | |
2114 | switches supported by the compiler, use: | |
2115 | ||
2116 | @smallexample | |
2117 | --help=target,undocumented | |
2118 | @end smallexample | |
2119 | ||
2120 | The sense of a qualifier can be inverted by prefixing it with the | |
2121 | @samp{^} character, so for example to display all binary warning | |
2122 | options (i.e., ones that are either on or off and that do not take an | |
2123 | argument) that have a description, use: | |
2124 | ||
2125 | @smallexample | |
2126 | --help=warnings,^joined,^undocumented | |
2127 | @end smallexample | |
2128 | ||
2129 | The argument to @option{--help=} should not consist solely of inverted | |
2130 | qualifiers. | |
2131 | ||
2132 | Combining several classes is possible, although this usually | |
2133 | restricts the output so much that there is nothing to display. One | |
2134 | case where it does work, however, is when one of the classes is | |
2135 | @var{target}. For example, to display all the target-specific | |
2136 | optimization options, use: | |
2137 | ||
2138 | @smallexample | |
2139 | --help=target,optimizers | |
2140 | @end smallexample | |
2141 | ||
2142 | The @option{--help=} option can be repeated on the command line. Each | |
2143 | successive use displays its requested class of options, skipping | |
2144 | those that have already been displayed. If @option{--help} is also | |
2145 | specified anywhere on the command line then this takes precedence | |
2146 | over any @option{--help=} option. | |
2147 | ||
2148 | If the @option{-Q} option appears on the command line before the | |
2149 | @option{--help=} option, then the descriptive text displayed by | |
2150 | @option{--help=} is changed. Instead of describing the displayed | |
2151 | options, an indication is given as to whether the option is enabled, | |
2152 | disabled or set to a specific value (assuming that the compiler | |
2153 | knows this at the point where the @option{--help=} option is used). | |
2154 | ||
2155 | Here is a truncated example from the ARM port of @command{gcc}: | |
2156 | ||
2157 | @smallexample | |
2158 | % gcc -Q -mabi=2 --help=target -c | |
2159 | The following options are target specific: | |
2160 | -mabi= 2 | |
2161 | -mabort-on-noreturn [disabled] | |
2162 | -mapcs [disabled] | |
2163 | @end smallexample | |
2164 | ||
2165 | The output is sensitive to the effects of previous command-line | |
2166 | options, so for example it is possible to find out which optimizations | |
2167 | are enabled at @option{-O2} by using: | |
2168 | ||
2169 | @smallexample | |
2170 | -Q -O2 --help=optimizers | |
2171 | @end smallexample | |
2172 | ||
2173 | Alternatively you can discover which binary optimizations are enabled | |
2174 | by @option{-O3} by using: | |
2175 | ||
2176 | @smallexample | |
2177 | gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts | |
2178 | gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts | |
2179 | diff /tmp/O2-opts /tmp/O3-opts | grep enabled | |
2180 | @end smallexample | |
2181 | ||
d77de738 | 2182 | @opindex version |
ddf6fe37 | 2183 | @item --version |
d77de738 ML |
2184 | Display the version number and copyrights of the invoked GCC@. |
2185 | ||
d77de738 | 2186 | @opindex pass-exit-codes |
ddf6fe37 | 2187 | @item -pass-exit-codes |
d77de738 ML |
2188 | Normally the @command{gcc} program exits with the code of 1 if any |
2189 | phase of the compiler returns a non-success return code. If you specify | |
2190 | @option{-pass-exit-codes}, the @command{gcc} program instead returns with | |
2191 | the numerically highest error produced by any phase returning an error | |
2192 | indication. The C, C++, and Fortran front ends return 4 if an internal | |
2193 | compiler error is encountered. | |
2194 | ||
d77de738 | 2195 | @opindex pipe |
ddf6fe37 | 2196 | @item -pipe |
d77de738 ML |
2197 | Use pipes rather than temporary files for communication between the |
2198 | various stages of compilation. This fails to work on some systems where | |
2199 | the assembler is unable to read from a pipe; but the GNU assembler has | |
2200 | no trouble. | |
2201 | ||
d77de738 | 2202 | @opindex specs |
ddf6fe37 | 2203 | @item -specs=@var{file} |
d77de738 ML |
2204 | Process @var{file} after the compiler reads in the standard @file{specs} |
2205 | file, in order to override the defaults which the @command{gcc} driver | |
2206 | program uses when determining what switches to pass to @command{cc1}, | |
2207 | @command{cc1plus}, @command{as}, @command{ld}, etc. More than one | |
2208 | @option{-specs=@var{file}} can be specified on the command line, and they | |
2209 | are processed in order, from left to right. @xref{Spec Files}, for | |
2210 | information about the format of the @var{file}. | |
2211 | ||
d77de738 | 2212 | @opindex wrapper |
ddf6fe37 | 2213 | @item -wrapper |
d77de738 ML |
2214 | Invoke all subcommands under a wrapper program. The name of the |
2215 | wrapper program and its parameters are passed as a comma separated | |
2216 | list. | |
2217 | ||
2218 | @smallexample | |
2219 | gcc -c t.c -wrapper gdb,--args | |
2220 | @end smallexample | |
2221 | ||
2222 | @noindent | |
2223 | This invokes all subprograms of @command{gcc} under | |
2224 | @samp{gdb --args}, thus the invocation of @command{cc1} is | |
2225 | @samp{gdb --args cc1 @dots{}}. | |
2226 | ||
d77de738 | 2227 | @opindex ffile-prefix-map |
ddf6fe37 | 2228 | @item -ffile-prefix-map=@var{old}=@var{new} |
d77de738 ML |
2229 | When compiling files residing in directory @file{@var{old}}, record |
2230 | any references to them in the result of the compilation as if the | |
2231 | files resided in directory @file{@var{new}} instead. Specifying this | |
2232 | option is equivalent to specifying all the individual | |
2233 | @option{-f*-prefix-map} options. This can be used to make reproducible | |
11543b27 | 2234 | builds that are location independent. Directories referenced by |
2eb0191a JJ |
2235 | directives are not affected by these options. See also |
2236 | @option{-fmacro-prefix-map}, @option{-fdebug-prefix-map}, | |
2237 | @option{-fprofile-prefix-map} and @option{-fcanon-prefix-map}. | |
2238 | ||
2eb0191a | 2239 | @opindex fcanon-prefix-map |
e54b01a1 | 2240 | @item -fcanon-prefix-map |
2eb0191a JJ |
2241 | For the @option{-f*-prefix-map} options normally comparison |
2242 | of @file{@var{old}} prefix against the filename that would be normally | |
2243 | referenced in the result of the compilation is done using textual | |
2244 | comparison of the prefixes, or ignoring character case for case insensitive | |
2245 | filesystems and considering slashes and backslashes as equal on DOS based | |
2246 | filesystems. The @option{-fcanon-prefix-map} causes such comparisons | |
2247 | to be done on canonicalized paths of @file{@var{old}} | |
2248 | and the referenced filename. | |
d77de738 | 2249 | |
d77de738 | 2250 | @opindex fplugin |
ddf6fe37 | 2251 | @item -fplugin=@var{name}.so |
d77de738 ML |
2252 | Load the plugin code in file @var{name}.so, assumed to be a |
2253 | shared object to be dlopen'd by the compiler. The base name of | |
2254 | the shared object file is used to identify the plugin for the | |
2255 | purposes of argument parsing (See | |
2256 | @option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below). | |
2257 | Each plugin should define the callback functions specified in the | |
2258 | Plugins API. | |
2259 | ||
d77de738 | 2260 | @opindex fplugin-arg |
ddf6fe37 | 2261 | @item -fplugin-arg-@var{name}-@var{key}=@var{value} |
d77de738 ML |
2262 | Define an argument called @var{key} with a value of @var{value} |
2263 | for the plugin called @var{name}. | |
2264 | ||
d77de738 | 2265 | @opindex fdump-ada-spec |
ddf6fe37 | 2266 | @item -fdump-ada-spec@r{[}-slim@r{]} |
d77de738 ML |
2267 | For C and C++ source and include files, generate corresponding Ada specs. |
2268 | @xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn, | |
2269 | GNAT User's Guide}, which provides detailed documentation on this feature. | |
2270 | ||
d77de738 | 2271 | @opindex fada-spec-parent |
ddf6fe37 | 2272 | @item -fada-spec-parent=@var{unit} |
d77de738 ML |
2273 | In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate |
2274 | Ada specs as child units of parent @var{unit}. | |
2275 | ||
d77de738 | 2276 | @opindex fdump-go-spec |
ddf6fe37 | 2277 | @item -fdump-go-spec=@var{file} |
d77de738 ML |
2278 | For input files in any language, generate corresponding Go |
2279 | declarations in @var{file}. This generates Go @code{const}, | |
2280 | @code{type}, @code{var}, and @code{func} declarations which may be a | |
2281 | useful way to start writing a Go interface to code written in some | |
2282 | other language. | |
2283 | ||
2284 | @include @value{srcdir}/../libiberty/at-file.texi | |
2285 | @end table | |
2286 | ||
2287 | @node Invoking G++ | |
2288 | @section Compiling C++ Programs | |
2289 | ||
2290 | @cindex suffixes for C++ source | |
2291 | @cindex C++ source file suffixes | |
2292 | C++ source files conventionally use one of the suffixes @samp{.C}, | |
2293 | @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or | |
2294 | @samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp}, | |
2295 | @samp{.H}, or (for shared template code) @samp{.tcc}; and | |
2296 | preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes | |
2297 | files with these names and compiles them as C++ programs even if you | |
2298 | call the compiler the same way as for compiling C programs (usually | |
2299 | with the name @command{gcc}). | |
2300 | ||
2301 | @findex g++ | |
2302 | @findex c++ | |
2303 | However, the use of @command{gcc} does not add the C++ library. | |
2304 | @command{g++} is a program that calls GCC and automatically specifies linking | |
2305 | against the C++ library. It treats @samp{.c}, | |
2306 | @samp{.h} and @samp{.i} files as C++ source files instead of C source | |
2307 | files unless @option{-x} is used. This program is also useful when | |
2308 | precompiling a C header file with a @samp{.h} extension for use in C++ | |
2309 | compilations. On many systems, @command{g++} is also installed with | |
2310 | the name @command{c++}. | |
2311 | ||
2312 | @cindex invoking @command{g++} | |
2313 | When you compile C++ programs, you may specify many of the same | |
2314 | command-line options that you use for compiling programs in any | |
2315 | language; or command-line options meaningful for C and related | |
2316 | languages; or options that are meaningful only for C++ programs. | |
2317 | @xref{C Dialect Options,,Options Controlling C Dialect}, for | |
2318 | explanations of options for languages related to C@. | |
2319 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for | |
2320 | explanations of options that are meaningful only for C++ programs. | |
2321 | ||
2322 | @node C Dialect Options | |
2323 | @section Options Controlling C Dialect | |
2324 | @cindex dialect options | |
2325 | @cindex language dialect options | |
2326 | @cindex options, dialect | |
2327 | ||
2328 | The following options control the dialect of C (or languages derived | |
2329 | from C, such as C++, Objective-C and Objective-C++) that the compiler | |
2330 | accepts: | |
2331 | ||
2332 | @table @gcctabopt | |
2333 | @cindex ANSI support | |
2334 | @cindex ISO support | |
d77de738 | 2335 | @opindex ansi |
ddf6fe37 | 2336 | @item -ansi |
d77de738 ML |
2337 | In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is |
2338 | equivalent to @option{-std=c++98}. | |
2339 | ||
2340 | This turns off certain features of GCC that are incompatible with ISO | |
2341 | C90 (when compiling C code), or of standard C++ (when compiling C++ code), | |
2342 | such as the @code{asm} and @code{typeof} keywords, and | |
2343 | predefined macros such as @code{unix} and @code{vax} that identify the | |
2344 | type of system you are using. It also enables the undesirable and | |
2345 | rarely used ISO trigraph feature. For the C compiler, | |
2346 | it disables recognition of C++ style @samp{//} comments as well as | |
2347 | the @code{inline} keyword. | |
2348 | ||
2349 | The alternate keywords @code{__asm__}, @code{__extension__}, | |
2350 | @code{__inline__} and @code{__typeof__} continue to work despite | |
2351 | @option{-ansi}. You would not want to use them in an ISO C program, of | |
2352 | course, but it is useful to put them in header files that might be included | |
2353 | in compilations done with @option{-ansi}. Alternate predefined macros | |
2354 | such as @code{__unix__} and @code{__vax__} are also available, with or | |
2355 | without @option{-ansi}. | |
2356 | ||
2357 | The @option{-ansi} option does not cause non-ISO programs to be | |
2358 | rejected gratuitously. For that, @option{-Wpedantic} is required in | |
2359 | addition to @option{-ansi}. @xref{Warning Options}. | |
2360 | ||
2361 | The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi} | |
2362 | option is used. Some header files may notice this macro and refrain | |
2363 | from declaring certain functions or defining certain macros that the | |
2364 | ISO standard doesn't call for; this is to avoid interfering with any | |
2365 | programs that might use these names for other things. | |
2366 | ||
2367 | Functions that are normally built in but do not have semantics | |
2368 | defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in | |
2369 | functions when @option{-ansi} is used. @xref{Other Builtins,,Other | |
2370 | built-in functions provided by GCC}, for details of the functions | |
2371 | affected. | |
2372 | ||
d77de738 | 2373 | @opindex std |
ddf6fe37 | 2374 | @item -std= |
d77de738 ML |
2375 | Determine the language standard. @xref{Standards,,Language Standards |
2376 | Supported by GCC}, for details of these standard versions. This option | |
2377 | is currently only supported when compiling C or C++. | |
2378 | ||
2379 | The compiler can accept several base standards, such as @samp{c90} or | |
2380 | @samp{c++98}, and GNU dialects of those standards, such as | |
2381 | @samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the | |
2382 | compiler accepts all programs following that standard plus those | |
2383 | using GNU extensions that do not contradict it. For example, | |
2384 | @option{-std=c90} turns off certain features of GCC that are | |
2385 | incompatible with ISO C90, such as the @code{asm} and @code{typeof} | |
2386 | keywords, but not other GNU extensions that do not have a meaning in | |
2387 | ISO C90, such as omitting the middle term of a @code{?:} | |
2388 | expression. On the other hand, when a GNU dialect of a standard is | |
2389 | specified, all features supported by the compiler are enabled, even when | |
2390 | those features change the meaning of the base standard. As a result, some | |
2391 | strict-conforming programs may be rejected. The particular standard | |
2392 | is used by @option{-Wpedantic} to identify which features are GNU | |
2393 | extensions given that version of the standard. For example | |
2394 | @option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//} | |
2395 | comments, while @option{-std=gnu99 -Wpedantic} does not. | |
2396 | ||
2397 | A value for this option must be provided; possible values are | |
2398 | ||
2399 | @table @samp | |
2400 | @item c90 | |
2401 | @itemx c89 | |
2402 | @itemx iso9899:1990 | |
2403 | Support all ISO C90 programs (certain GNU extensions that conflict | |
2404 | with ISO C90 are disabled). Same as @option{-ansi} for C code. | |
2405 | ||
2406 | @item iso9899:199409 | |
2407 | ISO C90 as modified in amendment 1. | |
2408 | ||
2409 | @item c99 | |
2410 | @itemx c9x | |
2411 | @itemx iso9899:1999 | |
2412 | @itemx iso9899:199x | |
2413 | ISO C99. This standard is substantially completely supported, modulo | |
2414 | bugs and floating-point issues | |
2415 | (mainly but not entirely relating to optional C99 features from | |
2416 | Annexes F and G). See | |
2417 | @w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The | |
2418 | names @samp{c9x} and @samp{iso9899:199x} are deprecated. | |
2419 | ||
2420 | @item c11 | |
2421 | @itemx c1x | |
2422 | @itemx iso9899:2011 | |
2423 | ISO C11, the 2011 revision of the ISO C standard. This standard is | |
2424 | substantially completely supported, modulo bugs, floating-point issues | |
2425 | (mainly but not entirely relating to optional C11 features from | |
2426 | Annexes F and G) and the optional Annexes K (Bounds-checking | |
2427 | interfaces) and L (Analyzability). The name @samp{c1x} is deprecated. | |
2428 | ||
2429 | @item c17 | |
2430 | @itemx c18 | |
2431 | @itemx iso9899:2017 | |
2432 | @itemx iso9899:2018 | |
2433 | ISO C17, the 2017 revision of the ISO C standard | |
2434 | (published in 2018). This standard is | |
2435 | same as C11 except for corrections of defects (all of which are also | |
2436 | applied with @option{-std=c11}) and a new value of | |
2437 | @code{__STDC_VERSION__}, and so is supported to the same extent as C11. | |
2438 | ||
fad61bf7 JM |
2439 | @item c23 |
2440 | @itemx c2x | |
2441 | @itemx iso9899:2024 | |
2442 | ISO C23, the 2023 revision of the ISO C standard (expected to be | |
2443 | published in 2024). The support for this version is experimental and | |
2444 | incomplete. The name @samp{c2x} is deprecated. | |
d77de738 ML |
2445 | |
2446 | @item gnu90 | |
2447 | @itemx gnu89 | |
2448 | GNU dialect of ISO C90 (including some C99 features). | |
2449 | ||
2450 | @item gnu99 | |
2451 | @itemx gnu9x | |
2452 | GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated. | |
2453 | ||
2454 | @item gnu11 | |
2455 | @itemx gnu1x | |
2456 | GNU dialect of ISO C11. | |
2457 | The name @samp{gnu1x} is deprecated. | |
2458 | ||
2459 | @item gnu17 | |
2460 | @itemx gnu18 | |
2461 | GNU dialect of ISO C17. This is the default for C code. | |
2462 | ||
fad61bf7 JM |
2463 | @item gnu23 |
2464 | @itemx gnu2x | |
d77de738 ML |
2465 | The next version of the ISO C standard, still under development, plus |
2466 | GNU extensions. The support for this version is experimental and | |
fad61bf7 | 2467 | incomplete. The name @samp{gnu2x} is deprecated. |
d77de738 ML |
2468 | |
2469 | @item c++98 | |
2470 | @itemx c++03 | |
2471 | The 1998 ISO C++ standard plus the 2003 technical corrigendum and some | |
2472 | additional defect reports. Same as @option{-ansi} for C++ code. | |
2473 | ||
2474 | @item gnu++98 | |
2475 | @itemx gnu++03 | |
2476 | GNU dialect of @option{-std=c++98}. | |
2477 | ||
2478 | @item c++11 | |
2479 | @itemx c++0x | |
2480 | The 2011 ISO C++ standard plus amendments. | |
2481 | The name @samp{c++0x} is deprecated. | |
2482 | ||
2483 | @item gnu++11 | |
2484 | @itemx gnu++0x | |
2485 | GNU dialect of @option{-std=c++11}. | |
2486 | The name @samp{gnu++0x} is deprecated. | |
2487 | ||
2488 | @item c++14 | |
2489 | @itemx c++1y | |
2490 | The 2014 ISO C++ standard plus amendments. | |
2491 | The name @samp{c++1y} is deprecated. | |
2492 | ||
2493 | @item gnu++14 | |
2494 | @itemx gnu++1y | |
2495 | GNU dialect of @option{-std=c++14}. | |
2496 | The name @samp{gnu++1y} is deprecated. | |
2497 | ||
2498 | @item c++17 | |
2499 | @itemx c++1z | |
2500 | The 2017 ISO C++ standard plus amendments. | |
2501 | The name @samp{c++1z} is deprecated. | |
2502 | ||
2503 | @item gnu++17 | |
2504 | @itemx gnu++1z | |
2505 | GNU dialect of @option{-std=c++17}. | |
2506 | This is the default for C++ code. | |
2507 | The name @samp{gnu++1z} is deprecated. | |
2508 | ||
2509 | @item c++20 | |
2510 | @itemx c++2a | |
2511 | The 2020 ISO C++ standard plus amendments. | |
2512 | Support is experimental, and could change in incompatible ways in | |
2513 | future releases. | |
2514 | The name @samp{c++2a} is deprecated. | |
2515 | ||
2516 | @item gnu++20 | |
2517 | @itemx gnu++2a | |
2518 | GNU dialect of @option{-std=c++20}. | |
2519 | Support is experimental, and could change in incompatible ways in | |
2520 | future releases. | |
2521 | The name @samp{gnu++2a} is deprecated. | |
2522 | ||
2523 | @item c++2b | |
2524 | @itemx c++23 | |
2525 | The next revision of the ISO C++ standard, planned for | |
2526 | 2023. Support is highly experimental, and will almost certainly | |
2527 | change in incompatible ways in future releases. | |
2528 | ||
2529 | @item gnu++2b | |
2530 | @itemx gnu++23 | |
2531 | GNU dialect of @option{-std=c++2b}. Support is highly experimental, | |
2532 | and will almost certainly change in incompatible ways in future | |
2533 | releases. | |
5388a43f MP |
2534 | |
2535 | @item c++2c | |
2536 | @itemx c++26 | |
2537 | The next revision of the ISO C++ standard, planned for | |
2538 | 2026. Support is highly experimental, and will almost certainly | |
2539 | change in incompatible ways in future releases. | |
2540 | ||
2541 | @item gnu++2c | |
2542 | @itemx gnu++26 | |
2543 | GNU dialect of @option{-std=c++2c}. Support is highly experimental, | |
2544 | and will almost certainly change in incompatible ways in future | |
2545 | releases. | |
d77de738 ML |
2546 | @end table |
2547 | ||
d77de738 | 2548 | @opindex aux-info |
ddf6fe37 | 2549 | @item -aux-info @var{filename} |
d77de738 ML |
2550 | Output to the given filename prototyped declarations for all functions |
2551 | declared and/or defined in a translation unit, including those in header | |
2552 | files. This option is silently ignored in any language other than C@. | |
2553 | ||
2554 | Besides declarations, the file indicates, in comments, the origin of | |
2555 | each declaration (source file and line), whether the declaration was | |
2556 | implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or | |
2557 | @samp{O} for old, respectively, in the first character after the line | |
2558 | number and the colon), and whether it came from a declaration or a | |
2559 | definition (@samp{C} or @samp{F}, respectively, in the following | |
2560 | character). In the case of function definitions, a K&R-style list of | |
2561 | arguments followed by their declarations is also provided, inside | |
2562 | comments, after the declaration. | |
2563 | ||
d77de738 ML |
2564 | @opindex fno-asm |
2565 | @opindex fasm | |
ddf6fe37 | 2566 | @item -fno-asm |
d77de738 ML |
2567 | Do not recognize @code{asm}, @code{inline} or @code{typeof} as a |
2568 | keyword, so that code can use these words as identifiers. You can use | |
2569 | the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__} | |
2570 | instead. In C, @option{-ansi} implies @option{-fno-asm}. | |
2571 | ||
2572 | In C++, @code{inline} is a standard keyword and is not affected by | |
2573 | this switch. You may want to use the @option{-fno-gnu-keywords} flag | |
2574 | instead, which disables @code{typeof} but not @code{asm} and | |
2575 | @code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), | |
2576 | this switch only affects the @code{asm} and @code{typeof} keywords, | |
fad61bf7 JM |
2577 | since @code{inline} is a standard keyword in ISO C99. In C23 mode |
2578 | (@option{-std=c23} or @option{-std=gnu23}), this switch only affects | |
d77de738 | 2579 | the @code{asm} keyword, since @code{typeof} is a standard keyword in |
fad61bf7 | 2580 | ISO C23. |
d77de738 | 2581 | |
d77de738 ML |
2582 | @opindex fno-builtin |
2583 | @opindex fbuiltin | |
f33d7a88 | 2584 | @cindex built-in functions |
ddf6fe37 AA |
2585 | @item -fno-builtin |
2586 | @itemx -fno-builtin-@var{function} | |
d77de738 ML |
2587 | Don't recognize built-in functions that do not begin with |
2588 | @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in | |
2589 | functions provided by GCC}, for details of the functions affected, | |
2590 | including those which are not built-in functions when @option{-ansi} or | |
2591 | @option{-std} options for strict ISO C conformance are used because they | |
2592 | do not have an ISO standard meaning. | |
2593 | ||
2594 | GCC normally generates special code to handle certain built-in functions | |
2595 | more efficiently; for instance, calls to @code{alloca} may become single | |
2596 | instructions which adjust the stack directly, and calls to @code{memcpy} | |
2597 | may become inline copy loops. The resulting code is often both smaller | |
2598 | and faster, but since the function calls no longer appear as such, you | |
2599 | cannot set a breakpoint on those calls, nor can you change the behavior | |
2600 | of the functions by linking with a different library. In addition, | |
2601 | when a function is recognized as a built-in function, GCC may use | |
2602 | information about that function to warn about problems with calls to | |
2603 | that function, or to generate more efficient code, even if the | |
2604 | resulting code still contains calls to that function. For example, | |
2605 | warnings are given with @option{-Wformat} for bad calls to | |
2606 | @code{printf} when @code{printf} is built in and @code{strlen} is | |
2607 | known not to modify global memory. | |
2608 | ||
2609 | With the @option{-fno-builtin-@var{function}} option | |
2610 | only the built-in function @var{function} is | |
2611 | disabled. @var{function} must not begin with @samp{__builtin_}. If a | |
2612 | function is named that is not built-in in this version of GCC, this | |
2613 | option is ignored. There is no corresponding | |
2614 | @option{-fbuiltin-@var{function}} option; if you wish to enable | |
2615 | built-in functions selectively when using @option{-fno-builtin} or | |
2616 | @option{-ffreestanding}, you may define macros such as: | |
2617 | ||
2618 | @smallexample | |
2619 | #define abs(n) __builtin_abs ((n)) | |
2620 | #define strcpy(d, s) __builtin_strcpy ((d), (s)) | |
2621 | @end smallexample | |
2622 | ||
d77de738 | 2623 | @opindex fcond-mismatch |
ddf6fe37 | 2624 | @item -fcond-mismatch |
d77de738 ML |
2625 | Allow conditional expressions with mismatched types in the second and |
2626 | third arguments. The value of such an expression is void. This option | |
2627 | is not supported for C++. | |
2628 | ||
d77de738 ML |
2629 | @opindex ffreestanding |
2630 | @cindex hosted environment | |
f33d7a88 | 2631 | @item -ffreestanding |
d77de738 ML |
2632 | |
2633 | Assert that compilation targets a freestanding environment. This | |
2634 | implies @option{-fno-builtin}. A freestanding environment | |
2635 | is one in which the standard library may not exist, and program startup may | |
2636 | not necessarily be at @code{main}. The most obvious example is an OS kernel. | |
2637 | This is equivalent to @option{-fno-hosted}. | |
2638 | ||
2639 | @xref{Standards,,Language Standards Supported by GCC}, for details of | |
2640 | freestanding and hosted environments. | |
2641 | ||
d77de738 | 2642 | @opindex fgimple |
ddf6fe37 | 2643 | @item -fgimple |
d77de738 ML |
2644 | |
2645 | Enable parsing of function definitions marked with @code{__GIMPLE}. | |
2646 | This is an experimental feature that allows unit testing of GIMPLE | |
2647 | passes. | |
2648 | ||
d77de738 | 2649 | @opindex fgnu-tm |
ddf6fe37 | 2650 | @item -fgnu-tm |
d77de738 ML |
2651 | When the option @option{-fgnu-tm} is specified, the compiler |
2652 | generates code for the Linux variant of Intel's current Transactional | |
2653 | Memory ABI specification document (Revision 1.1, May 6 2009). This is | |
2654 | an experimental feature whose interface may change in future versions | |
2655 | of GCC, as the official specification changes. Please note that not | |
2656 | all architectures are supported for this feature. | |
2657 | ||
2658 | For more information on GCC's support for transactional memory, | |
2659 | @xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU | |
2660 | Transactional Memory Library}. | |
2661 | ||
2662 | Note that the transactional memory feature is not supported with | |
2663 | non-call exceptions (@option{-fnon-call-exceptions}). | |
2664 | ||
d77de738 | 2665 | @opindex fgnu89-inline |
ddf6fe37 | 2666 | @item -fgnu89-inline |
d77de738 ML |
2667 | The option @option{-fgnu89-inline} tells GCC to use the traditional |
2668 | GNU semantics for @code{inline} functions when in C99 mode. | |
2669 | @xref{Inline,,An Inline Function is As Fast As a Macro}. | |
2670 | Using this option is roughly equivalent to adding the | |
2671 | @code{gnu_inline} function attribute to all inline functions | |
2672 | (@pxref{Function Attributes}). | |
2673 | ||
2674 | The option @option{-fno-gnu89-inline} explicitly tells GCC to use the | |
2675 | C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it | |
2676 | specifies the default behavior). | |
2677 | This option is not supported in @option{-std=c90} or | |
2678 | @option{-std=gnu90} mode. | |
2679 | ||
2680 | The preprocessor macros @code{__GNUC_GNU_INLINE__} and | |
2681 | @code{__GNUC_STDC_INLINE__} may be used to check which semantics are | |
2682 | in effect for @code{inline} functions. @xref{Common Predefined | |
2683 | Macros,,,cpp,The C Preprocessor}. | |
2684 | ||
d77de738 ML |
2685 | @opindex fhosted |
2686 | @cindex hosted environment | |
f33d7a88 | 2687 | @item -fhosted |
d77de738 ML |
2688 | |
2689 | Assert that compilation targets a hosted environment. This implies | |
2690 | @option{-fbuiltin}. A hosted environment is one in which the | |
2691 | entire standard library is available, and in which @code{main} has a return | |
2692 | type of @code{int}. Examples are nearly everything except a kernel. | |
2693 | This is equivalent to @option{-fno-freestanding}. | |
2694 | ||
d77de738 | 2695 | @opindex flax-vector-conversions |
ddf6fe37 | 2696 | @item -flax-vector-conversions |
d77de738 ML |
2697 | Allow implicit conversions between vectors with differing numbers of |
2698 | elements and/or incompatible element types. This option should not be | |
2699 | used for new code. | |
2700 | ||
d77de738 | 2701 | @opindex fms-extensions |
ddf6fe37 | 2702 | @item -fms-extensions |
d77de738 ML |
2703 | Accept some non-standard constructs used in Microsoft header files. |
2704 | ||
2705 | In C++ code, this allows member names in structures to be similar | |
2706 | to previous types declarations. | |
2707 | ||
2708 | @smallexample | |
2709 | typedef int UOW; | |
2710 | struct ABC @{ | |
2711 | UOW UOW; | |
2712 | @}; | |
2713 | @end smallexample | |
2714 | ||
2715 | Some cases of unnamed fields in structures and unions are only | |
2716 | accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union | |
2717 | fields within structs/unions}, for details. | |
2718 | ||
2719 | Note that this option is off for all targets except for x86 | |
2720 | targets using ms-abi. | |
2721 | ||
ddf6fe37 | 2722 | @opindex foffload |
d77de738 ML |
2723 | @cindex Offloading targets |
2724 | @cindex OpenACC offloading targets | |
2725 | @cindex OpenMP offloading targets | |
f33d7a88 AA |
2726 | @item -foffload=disable |
2727 | @itemx -foffload=default | |
2728 | @itemx -foffload=@var{target-list} | |
d77de738 ML |
2729 | Specify for which OpenMP and OpenACC offload targets code should be generated. |
2730 | The default behavior, equivalent to @option{-foffload=default}, is to generate | |
2731 | code for all supported offload targets. The @option{-foffload=disable} form | |
2732 | generates code only for the host fallback, while | |
2733 | @option{-foffload=@var{target-list}} generates code only for the specified | |
2734 | comma-separated list of offload targets. | |
2735 | ||
2736 | Offload targets are specified in GCC's internal target-triplet format. You can | |
2737 | run the compiler with @option{-v} to show the list of configured offload targets | |
2738 | under @code{OFFLOAD_TARGET_NAMES}. | |
2739 | ||
ddf6fe37 | 2740 | @opindex foffload-options |
d77de738 ML |
2741 | @cindex Offloading options |
2742 | @cindex OpenACC offloading options | |
2743 | @cindex OpenMP offloading options | |
f33d7a88 AA |
2744 | @item -foffload-options=@var{options} |
2745 | @itemx -foffload-options=@var{target-triplet-list}=@var{options} | |
d77de738 ML |
2746 | |
2747 | With @option{-foffload-options=@var{options}}, GCC passes the specified | |
2748 | @var{options} to the compilers for all enabled offloading targets. You can | |
2749 | specify options that apply only to a specific target or targets by using | |
2750 | the @option{-foffload-options=@var{target-list}=@var{options}} form. The | |
2751 | @var{target-list} is a comma-separated list in the same format as for the | |
2752 | @option{-foffload=} option. | |
2753 | ||
2754 | Typical command lines are | |
2755 | ||
2756 | @smallexample | |
4bcb46b3 | 2757 | -foffload-options='-fno-math-errno -ffinite-math-only' -foffload-options=nvptx-none=-latomic |
e9c1679c | 2758 | -foffload-options=amdgcn-amdhsa=-march=gfx906 |
d77de738 ML |
2759 | @end smallexample |
2760 | ||
d77de738 ML |
2761 | @opindex fopenacc |
2762 | @cindex OpenACC accelerator programming | |
f33d7a88 | 2763 | @item -fopenacc |
643a5223 TB |
2764 | Enable handling of OpenACC directives @samp{#pragma acc} in C/C++ and |
2765 | @samp{!$acc} in free-form Fortran and @samp{!$acc}, @samp{c$acc} and | |
2766 | @samp{*$acc} in fixed-form Fortran. When @option{-fopenacc} is specified, | |
2767 | the compiler generates accelerated code according to the OpenACC Application | |
d77de738 ML |
2768 | Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option |
2769 | implies @option{-pthread}, and thus is only supported on targets that | |
2770 | have support for @option{-pthread}. | |
2771 | ||
d77de738 ML |
2772 | @opindex fopenacc-dim |
2773 | @cindex OpenACC accelerator programming | |
f33d7a88 | 2774 | @item -fopenacc-dim=@var{geom} |
d77de738 ML |
2775 | Specify default compute dimensions for parallel offload regions that do |
2776 | not explicitly specify. The @var{geom} value is a triple of | |
2777 | ':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size | |
2778 | can be omitted, to use a target-specific default value. | |
2779 | ||
d77de738 ML |
2780 | @opindex fopenmp |
2781 | @cindex OpenMP parallel | |
f33d7a88 | 2782 | @item -fopenmp |
75e5a467 | 2783 | Enable handling of OpenMP directives @samp{#pragma omp}, |
643a5223 | 2784 | @samp{[[omp::directive(...)]]}, @samp{[[omp::sequence(...)]]} and |
75e5a467 | 2785 | @samp{[[omp::decl(...)]]} in C/C++ and @samp{!$omp} in Fortran. It |
643a5223 TB |
2786 | additionally enables the conditional compilation sentinel @samp{!$} in |
2787 | Fortran. In fixed source form Fortran, the sentinels can also start with | |
2788 | @samp{c} or @samp{*}. When @option{-fopenmp} is specified, the | |
d77de738 ML |
2789 | compiler generates parallel code according to the OpenMP Application |
2790 | Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option | |
2791 | implies @option{-pthread}, and thus is only supported on targets that | |
2792 | have support for @option{-pthread}. @option{-fopenmp} implies | |
2793 | @option{-fopenmp-simd}. | |
2794 | ||
d77de738 ML |
2795 | @opindex fopenmp-simd |
2796 | @cindex OpenMP SIMD | |
2797 | @cindex SIMD | |
f33d7a88 | 2798 | @item -fopenmp-simd |
d77de738 | 2799 | Enable handling of OpenMP's @code{simd}, @code{declare simd}, |
1fab441d TB |
2800 | @code{declare reduction}, @code{assume}, @code{ordered}, @code{scan} |
2801 | and @code{loop} directive, and of combined or composite directives with | |
75e5a467 | 2802 | @code{simd} as constituent with @code{#pragma omp}, |
1fab441d | 2803 | @code{[[omp::directive(...)]]}, @code{[[omp::sequence(...)]]} and |
75e5a467 | 2804 | @code{[[omp::decl(...)]]} in C/C++ and @code{!$omp} in Fortran. It |
643a5223 TB |
2805 | additionally enables the conditional compilation sentinel @samp{!$} in |
2806 | Fortran. In fixed source form Fortran, the sentinels can also start with | |
2807 | @samp{c} or @samp{*}. Other OpenMP directives are ignored. Unless | |
2808 | @option{-fopenmp} is additionally specified, the @code{loop} region binds | |
2809 | to the current task region, independent of the specified @code{bind} clause. | |
d77de738 | 2810 | |
ddf6fe37 | 2811 | @opindex fopenmp-target-simd-clone |
f33d7a88 | 2812 | @cindex OpenMP target SIMD clone |
309e2d95 SL |
2813 | @item -fopenmp-target-simd-clone |
2814 | @item -fopenmp-target-simd-clone=@var{device-type} | |
309e2d95 SL |
2815 | In addition to generating SIMD clones for functions marked with the |
2816 | @code{declare simd} directive, GCC also generates clones | |
2817 | for functions marked with the OpenMP @code{declare target} directive | |
2818 | that are suitable for vectorization when this option is in effect. The | |
2819 | @var{device-type} may be one of @code{none}, @code{host}, @code{nohost}, | |
2820 | and @code{any}, which correspond to keywords for the @code{device_type} | |
2821 | clause of the @code{declare target} directive; clones are generated for | |
2822 | the intersection of devices specified. | |
2823 | @option{-fopenmp-target-simd-clone} is equivalent to | |
2824 | @option{-fopenmp-target-simd-clone=any} and | |
2825 | @option{-fno-openmp-target-simd-clone} is equivalent to | |
2826 | @option{-fopenmp-target-simd-clone=none}. | |
2827 | ||
2828 | At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this | |
2829 | optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise | |
2830 | it is disabled by default. | |
2831 | ||
d77de738 ML |
2832 | @opindex fpermitted-flt-eval-methods |
2833 | @opindex fpermitted-flt-eval-methods=c11 | |
2834 | @opindex fpermitted-flt-eval-methods=ts-18661-3 | |
ddf6fe37 | 2835 | @item -fpermitted-flt-eval-methods=@var{style} |
d77de738 ML |
2836 | ISO/IEC TS 18661-3 defines new permissible values for |
2837 | @code{FLT_EVAL_METHOD} that indicate that operations and constants with | |
2838 | a semantic type that is an interchange or extended format should be | |
2839 | evaluated to the precision and range of that type. These new values are | |
2840 | a superset of those permitted under C99/C11, which does not specify the | |
2841 | meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code | |
2842 | conforming to C11 may not have been written expecting the possibility of | |
2843 | the new values. | |
2844 | ||
2845 | @option{-fpermitted-flt-eval-methods} specifies whether the compiler | |
2846 | should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11, | |
2847 | or the extended set of values specified in ISO/IEC TS 18661-3. | |
2848 | ||
2849 | @var{style} is either @code{c11} or @code{ts-18661-3} as appropriate. | |
2850 | ||
2851 | The default when in a standards compliant mode (@option{-std=c11} or similar) | |
2852 | is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU | |
2853 | dialect (@option{-std=gnu11} or similar) is | |
2854 | @option{-fpermitted-flt-eval-methods=ts-18661-3}. | |
2855 | ||
024f135a BB |
2856 | @opindex fdeps- |
2857 | The @samp{-fdeps-*} options are used to extract structured dependency | |
2858 | information for a source. This involves determining what resources provided by | |
2859 | other source files will be required to compile the source as well as what | |
2860 | resources are provided by the source. This information can be used to add | |
2861 | required dependencies between compilation rules of dependent sources based on | |
2862 | their contents rather than requiring such information be reflected within the | |
2863 | build tools as well. | |
2864 | ||
2865 | @opindex fdeps-file | |
2866 | @item -fdeps-file=@var{file} | |
2867 | Where to write structured dependency information. | |
2868 | ||
2869 | @opindex fdeps-format | |
2870 | @item -fdeps-format=@var{format} | |
2871 | The format to use for structured dependency information. @samp{p1689r5} is the | |
2872 | only supported format right now. Note that when this argument is specified, the | |
2873 | output of @samp{-MF} is stripped of some information (namely C++ modules) so | |
2874 | that it does not use extended makefile syntax not understood by most tools. | |
2875 | ||
2876 | @opindex fdeps-target | |
2877 | @item -fdeps-target=@var{file} | |
2878 | Analogous to @option{-MT} but for structured dependency information. This | |
2879 | indicates the target which will ultimately need any required resources and | |
2880 | provide any resources extracted from the source that may be required by other | |
2881 | sources. | |
2882 | ||
d77de738 | 2883 | @opindex fplan9-extensions |
ddf6fe37 | 2884 | @item -fplan9-extensions |
d77de738 ML |
2885 | Accept some non-standard constructs used in Plan 9 code. |
2886 | ||
2887 | This enables @option{-fms-extensions}, permits passing pointers to | |
2888 | structures with anonymous fields to functions that expect pointers to | |
2889 | elements of the type of the field, and permits referring to anonymous | |
2890 | fields declared using a typedef. @xref{Unnamed Fields,,Unnamed | |
2891 | struct/union fields within structs/unions}, for details. This is only | |
2892 | supported for C, not C++. | |
2893 | ||
d77de738 ML |
2894 | @opindex fsigned-bitfields |
2895 | @opindex funsigned-bitfields | |
2896 | @opindex fno-signed-bitfields | |
2897 | @opindex fno-unsigned-bitfields | |
ddf6fe37 AA |
2898 | @item -fsigned-bitfields |
2899 | @itemx -funsigned-bitfields | |
2900 | @itemx -fno-signed-bitfields | |
2901 | @itemx -fno-unsigned-bitfields | |
d77de738 ML |
2902 | These options control whether a bit-field is signed or unsigned, when the |
2903 | declaration does not use either @code{signed} or @code{unsigned}. By | |
2904 | default, such a bit-field is signed, because this is consistent: the | |
2905 | basic integer types such as @code{int} are signed types. | |
2906 | ||
d77de738 | 2907 | @opindex fsigned-char |
ddf6fe37 | 2908 | @item -fsigned-char |
d77de738 ML |
2909 | Let the type @code{char} be signed, like @code{signed char}. |
2910 | ||
2911 | Note that this is equivalent to @option{-fno-unsigned-char}, which is | |
2912 | the negative form of @option{-funsigned-char}. Likewise, the option | |
2913 | @option{-fno-signed-char} is equivalent to @option{-funsigned-char}. | |
2914 | ||
d77de738 | 2915 | @opindex funsigned-char |
ddf6fe37 | 2916 | @item -funsigned-char |
d77de738 ML |
2917 | Let the type @code{char} be unsigned, like @code{unsigned char}. |
2918 | ||
2919 | Each kind of machine has a default for what @code{char} should | |
2920 | be. It is either like @code{unsigned char} by default or like | |
2921 | @code{signed char} by default. | |
2922 | ||
2923 | Ideally, a portable program should always use @code{signed char} or | |
2924 | @code{unsigned char} when it depends on the signedness of an object. | |
2925 | But many programs have been written to use plain @code{char} and | |
2926 | expect it to be signed, or expect it to be unsigned, depending on the | |
2927 | machines they were written for. This option, and its inverse, let you | |
2928 | make such a program work with the opposite default. | |
2929 | ||
2930 | The type @code{char} is always a distinct type from each of | |
2931 | @code{signed char} or @code{unsigned char}, even though its behavior | |
2932 | is always just like one of those two. | |
2933 | ||
d77de738 ML |
2934 | @opindex fstrict-flex-arrays |
2935 | @opindex fno-strict-flex-arrays | |
ddf6fe37 | 2936 | @item -fstrict-flex-arrays |
d77de738 ML |
2937 | Control when to treat the trailing array of a structure as a flexible array |
2938 | member for the purpose of accessing the elements of such an array. | |
2939 | The positive form is equivalent to @option{-fstrict-flex-arrays=3}, which is the | |
2940 | strictest. A trailing array is treated as a flexible array member only when it | |
2941 | is declared as a flexible array member per C99 standard onwards. | |
2942 | The negative form is equivalent to @option{-fstrict-flex-arrays=0}, which is the | |
2943 | least strict. All trailing arrays of structures are treated as flexible array | |
2944 | members. | |
2945 | ||
d77de738 | 2946 | @opindex fstrict-flex-arrays=@var{level} |
ddf6fe37 | 2947 | @item -fstrict-flex-arrays=@var{level} |
d77de738 ML |
2948 | Control when to treat the trailing array of a structure as a flexible array |
2949 | member for the purpose of accessing the elements of such an array. The value | |
2950 | of @var{level} controls the level of strictness. | |
2951 | ||
2952 | The possible values of @var{level} are the same as for the | |
2953 | @code{strict_flex_array} attribute (@pxref{Variable Attributes}). | |
2954 | ||
2955 | You can control this behavior for a specific trailing array field of a | |
2956 | structure by using the variable attribute @code{strict_flex_array} attribute | |
2957 | (@pxref{Variable Attributes}). | |
2958 | ||
d77de738 | 2959 | @opindex fsso-struct |
ddf6fe37 | 2960 | @item -fsso-struct=@var{endianness} |
d77de738 ML |
2961 | Set the default scalar storage order of structures and unions to the |
2962 | specified endianness. The accepted values are @samp{big-endian}, | |
2963 | @samp{little-endian} and @samp{native} for the native endianness of | |
2964 | the target (the default). This option is not supported for C++. | |
2965 | ||
2966 | @strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate | |
2967 | code that is not binary compatible with code generated without it if the | |
2968 | specified endianness is not the native endianness of the target. | |
2969 | @end table | |
2970 | ||
2971 | @node C++ Dialect Options | |
2972 | @section Options Controlling C++ Dialect | |
2973 | ||
2974 | @cindex compiler options, C++ | |
2975 | @cindex C++ options, command-line | |
2976 | @cindex options, C++ | |
2977 | This section describes the command-line options that are only meaningful | |
2978 | for C++ programs. You can also use most of the GNU compiler options | |
2979 | regardless of what language your program is in. For example, you | |
2980 | might compile a file @file{firstClass.C} like this: | |
2981 | ||
2982 | @smallexample | |
2983 | g++ -g -fstrict-enums -O -c firstClass.C | |
2984 | @end smallexample | |
2985 | ||
2986 | @noindent | |
2987 | In this example, only @option{-fstrict-enums} is an option meant | |
2988 | only for C++ programs; you can use the other options with any | |
2989 | language supported by GCC@. | |
2990 | ||
2991 | Some options for compiling C programs, such as @option{-std}, are also | |
2992 | relevant for C++ programs. | |
2993 | @xref{C Dialect Options,,Options Controlling C Dialect}. | |
2994 | ||
2995 | Here is a list of options that are @emph{only} for compiling C++ programs: | |
2996 | ||
2997 | @table @gcctabopt | |
2998 | ||
d77de738 | 2999 | @opindex fabi-version |
ddf6fe37 | 3000 | @item -fabi-version=@var{n} |
d77de738 ML |
3001 | Use version @var{n} of the C++ ABI@. The default is version 0. |
3002 | ||
3003 | Version 0 refers to the version conforming most closely to | |
3004 | the C++ ABI specification. Therefore, the ABI obtained using version 0 | |
3005 | will change in different versions of G++ as ABI bugs are fixed. | |
3006 | ||
3007 | Version 1 is the version of the C++ ABI that first appeared in G++ 3.2. | |
3008 | ||
3009 | Version 2 is the version of the C++ ABI that first appeared in G++ | |
3010 | 3.4, and was the default through G++ 4.9. | |
3011 | ||
3012 | Version 3 corrects an error in mangling a constant address as a | |
3013 | template argument. | |
3014 | ||
3015 | Version 4, which first appeared in G++ 4.5, implements a standard | |
3016 | mangling for vector types. | |
3017 | ||
3018 | Version 5, which first appeared in G++ 4.6, corrects the mangling of | |
3019 | attribute const/volatile on function pointer types, decltype of a | |
3020 | plain decl, and use of a function parameter in the declaration of | |
3021 | another parameter. | |
3022 | ||
3023 | Version 6, which first appeared in G++ 4.7, corrects the promotion | |
3024 | behavior of C++11 scoped enums and the mangling of template argument | |
3025 | packs, const/static_cast, prefix ++ and --, and a class scope function | |
3026 | used as a template argument. | |
3027 | ||
3028 | Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a | |
3029 | builtin type and corrects the mangling of lambdas in default argument | |
3030 | scope. | |
3031 | ||
3032 | Version 8, which first appeared in G++ 4.9, corrects the substitution | |
3033 | behavior of function types with function-cv-qualifiers. | |
3034 | ||
3035 | Version 9, which first appeared in G++ 5.2, corrects the alignment of | |
3036 | @code{nullptr_t}. | |
3037 | ||
3038 | Version 10, which first appeared in G++ 6.1, adds mangling of | |
3039 | attributes that affect type identity, such as ia32 calling convention | |
3040 | attributes (e.g.@: @samp{stdcall}). | |
3041 | ||
3042 | Version 11, which first appeared in G++ 7, corrects the mangling of | |
3043 | sizeof... expressions and operator names. For multiple entities with | |
3044 | the same name within a function, that are declared in different scopes, | |
3045 | the mangling now changes starting with the twelfth occurrence. It also | |
3046 | implies @option{-fnew-inheriting-ctors}. | |
3047 | ||
3048 | Version 12, which first appeared in G++ 8, corrects the calling | |
3049 | conventions for empty classes on the x86_64 target and for classes | |
3050 | with only deleted copy/move constructors. It accidentally changes the | |
3051 | calling convention for classes with a deleted copy constructor and a | |
3052 | trivial move constructor. | |
3053 | ||
3054 | Version 13, which first appeared in G++ 8.2, fixes the accidental | |
3055 | change in version 12. | |
3056 | ||
3057 | Version 14, which first appeared in G++ 10, corrects the mangling of | |
3058 | the nullptr expression. | |
3059 | ||
3060 | Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI | |
3061 | tag regression. | |
3062 | ||
3063 | Version 16, which first appeared in G++ 11, changes the mangling of | |
3064 | @code{__alignof__} to be distinct from that of @code{alignof}, and | |
3065 | dependent operator names. | |
3066 | ||
3067 | Version 17, which first appeared in G++ 12, fixes layout of classes | |
3068 | that inherit from aggregate classes with default member initializers | |
3069 | in C++14 and up. | |
3070 | ||
3071 | Version 18, which first appeard in G++ 13, fixes manglings of lambdas | |
3072 | that have additional context. | |
3073 | ||
cd37325b JJ |
3074 | Version 19, which first appeard in G++ 14, fixes manglings of structured |
3075 | bindings to include ABI tags. | |
3076 | ||
d77de738 ML |
3077 | See also @option{-Wabi}. |
3078 | ||
d77de738 | 3079 | @opindex fabi-compat-version |
ddf6fe37 | 3080 | @item -fabi-compat-version=@var{n} |
d77de738 ML |
3081 | On targets that support strong aliases, G++ |
3082 | works around mangling changes by creating an alias with the correct | |
3083 | mangled name when defining a symbol with an incorrect mangled name. | |
3084 | This switch specifies which ABI version to use for the alias. | |
3085 | ||
3086 | With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2 | |
3087 | compatibility). If another ABI version is explicitly selected, this | |
3088 | defaults to 0. For compatibility with GCC versions 3.2 through 4.9, | |
3089 | use @option{-fabi-compat-version=2}. | |
3090 | ||
3091 | If this option is not provided but @option{-Wabi=@var{n}} is, that | |
3092 | version is used for compatibility aliases. If this option is provided | |
3093 | along with @option{-Wabi} (without the version), the version from this | |
3094 | option is used for the warning. | |
3095 | ||
d77de738 ML |
3096 | @opindex fno-access-control |
3097 | @opindex faccess-control | |
ddf6fe37 | 3098 | @item -fno-access-control |
d77de738 ML |
3099 | Turn off all access checking. This switch is mainly useful for working |
3100 | around bugs in the access control code. | |
3101 | ||
d77de738 | 3102 | @opindex faligned-new |
ddf6fe37 | 3103 | @item -faligned-new |
d77de738 ML |
3104 | Enable support for C++17 @code{new} of types that require more |
3105 | alignment than @code{void* ::operator new(std::size_t)} provides. A | |
3106 | numeric argument such as @code{-faligned-new=32} can be used to | |
3107 | specify how much alignment (in bytes) is provided by that function, | |
3108 | but few users will need to override the default of | |
3109 | @code{alignof(std::max_align_t)}. | |
3110 | ||
3111 | This flag is enabled by default for @option{-std=c++17}. | |
3112 | ||
d77de738 ML |
3113 | @opindex fchar8_t |
3114 | @opindex fno-char8_t | |
ddf6fe37 AA |
3115 | @item -fchar8_t |
3116 | @itemx -fno-char8_t | |
d77de738 ML |
3117 | Enable support for @code{char8_t} as adopted for C++20. This includes |
3118 | the addition of a new @code{char8_t} fundamental type, changes to the | |
3119 | types of UTF-8 string and character literals, new signatures for | |
3120 | user-defined literals, associated standard library updates, and new | |
3121 | @code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros. | |
3122 | ||
3123 | This option enables functions to be overloaded for ordinary and UTF-8 | |
3124 | strings: | |
3125 | ||
3126 | @smallexample | |
3127 | int f(const char *); // #1 | |
3128 | int f(const char8_t *); // #2 | |
3129 | int v1 = f("text"); // Calls #1 | |
3130 | int v2 = f(u8"text"); // Calls #2 | |
3131 | @end smallexample | |
3132 | ||
3133 | @noindent | |
3134 | and introduces new signatures for user-defined literals: | |
3135 | ||
3136 | @smallexample | |
3137 | int operator""_udl1(char8_t); | |
3138 | int v3 = u8'x'_udl1; | |
3139 | int operator""_udl2(const char8_t*, std::size_t); | |
3140 | int v4 = u8"text"_udl2; | |
3141 | template<typename T, T...> int operator""_udl3(); | |
3142 | int v5 = u8"text"_udl3; | |
3143 | @end smallexample | |
3144 | ||
3145 | @noindent | |
3146 | The change to the types of UTF-8 string and character literals introduces | |
3147 | incompatibilities with ISO C++11 and later standards. For example, the | |
3148 | following code is well-formed under ISO C++11, but is ill-formed when | |
3149 | @option{-fchar8_t} is specified. | |
3150 | ||
3151 | @smallexample | |
d77de738 ML |
3152 | const char *cp = u8"xx";// error: invalid conversion from |
3153 | // `const char8_t*' to `const char*' | |
3154 | int f(const char*); | |
3155 | auto v = f(u8"xx"); // error: invalid conversion from | |
3156 | // `const char8_t*' to `const char*' | |
3157 | std::string s@{u8"xx"@}; // error: no matching function for call to | |
3158 | // `std::basic_string<char>::basic_string()' | |
3159 | using namespace std::literals; | |
3160 | s = u8"xx"s; // error: conversion from | |
3161 | // `basic_string<char8_t>' to non-scalar | |
3162 | // type `basic_string<char>' requested | |
3163 | @end smallexample | |
3164 | ||
d77de738 | 3165 | @opindex fcheck-new |
ddf6fe37 | 3166 | @item -fcheck-new |
d77de738 ML |
3167 | Check that the pointer returned by @code{operator new} is non-null |
3168 | before attempting to modify the storage allocated. This check is | |
3169 | normally unnecessary because the C++ standard specifies that | |
3170 | @code{operator new} only returns @code{0} if it is declared | |
3171 | @code{throw()}, in which case the compiler always checks the | |
3172 | return value even without this option. In all other cases, when | |
3173 | @code{operator new} has a non-empty exception specification, memory | |
3174 | exhaustion is signalled by throwing @code{std::bad_alloc}. See also | |
3175 | @samp{new (nothrow)}. | |
3176 | ||
d77de738 ML |
3177 | @opindex fconcepts |
3178 | @opindex fconcepts-ts | |
ddf6fe37 AA |
3179 | @item -fconcepts |
3180 | @itemx -fconcepts-ts | |
d77de738 ML |
3181 | Enable support for the C++ Concepts feature for constraining template |
3182 | arguments. With @option{-std=c++20} and above, Concepts are part of | |
3183 | the language standard, so @option{-fconcepts} defaults to on. | |
3184 | ||
3185 | Some constructs that were allowed by the earlier C++ Extensions for | |
3186 | Concepts Technical Specification, ISO 19217 (2015), but didn't make it | |
3187 | into the standard, can additionally be enabled by | |
3188 | @option{-fconcepts-ts}. | |
3189 | ||
d77de738 | 3190 | @opindex fconstexpr-depth |
ddf6fe37 | 3191 | @item -fconstexpr-depth=@var{n} |
d77de738 ML |
3192 | Set the maximum nested evaluation depth for C++11 constexpr functions |
3193 | to @var{n}. A limit is needed to detect endless recursion during | |
3194 | constant expression evaluation. The minimum specified by the standard | |
3195 | is 512. | |
3196 | ||
d77de738 | 3197 | @opindex fconstexpr-cache-depth |
ddf6fe37 | 3198 | @item -fconstexpr-cache-depth=@var{n} |
d77de738 ML |
3199 | Set the maximum level of nested evaluation depth for C++11 constexpr |
3200 | functions that will be cached to @var{n}. This is a heuristic that | |
3201 | trades off compilation speed (when the cache avoids repeated | |
3202 | calculations) against memory consumption (when the cache grows very | |
3203 | large from highly recursive evaluations). The default is 8. Very few | |
3204 | users are likely to want to adjust it, but if your code does heavy | |
3205 | constexpr calculations you might want to experiment to find which | |
3206 | value works best for you. | |
3207 | ||
d77de738 | 3208 | @opindex fconstexpr-fp-except |
ddf6fe37 | 3209 | @item -fconstexpr-fp-except |
d77de738 ML |
3210 | Annex F of the C standard specifies that IEC559 floating point |
3211 | exceptions encountered at compile time should not stop compilation. | |
3212 | C++ compilers have historically not followed this guidance, instead | |
3213 | treating floating point division by zero as non-constant even though | |
3214 | it has a well defined value. This flag tells the compiler to give | |
3215 | Annex F priority over other rules saying that a particular operation | |
3216 | is undefined. | |
3217 | ||
3218 | @smallexample | |
3219 | constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except | |
3220 | @end smallexample | |
3221 | ||
d77de738 | 3222 | @opindex fconstexpr-loop-limit |
ddf6fe37 | 3223 | @item -fconstexpr-loop-limit=@var{n} |
d77de738 ML |
3224 | Set the maximum number of iterations for a loop in C++14 constexpr functions |
3225 | to @var{n}. A limit is needed to detect infinite loops during | |
3226 | constant expression evaluation. The default is 262144 (1<<18). | |
3227 | ||
d77de738 | 3228 | @opindex fconstexpr-ops-limit |
ddf6fe37 | 3229 | @item -fconstexpr-ops-limit=@var{n} |
d77de738 ML |
3230 | Set the maximum number of operations during a single constexpr evaluation. |
3231 | Even when number of iterations of a single loop is limited with the above limit, | |
3232 | if there are several nested loops and each of them has many iterations but still | |
3233 | smaller than the above limit, or if in a body of some loop or even outside | |
3234 | of a loop too many expressions need to be evaluated, the resulting constexpr | |
3235 | evaluation might take too long. | |
3236 | The default is 33554432 (1<<25). | |
3237 | ||
2efb237f | 3238 | @opindex fcontracts |
ddf6fe37 | 3239 | @item -fcontracts |
2efb237f JCI |
3240 | Enable experimental support for the C++ Contracts feature, as briefly |
3241 | added to and then removed from the C++20 working paper (N4820). The | |
3242 | implementation also includes proposed enhancements from papers P1290, | |
3243 | P1332, and P1429. This functionality is intended mostly for those | |
3244 | interested in experimentation towards refining the feature to get it | |
3245 | into shape for a future C++ standard. | |
3246 | ||
3247 | On violation of a checked contract, the violation handler is called. | |
3248 | Users can replace the violation handler by defining | |
3249 | @smallexample | |
4ace81b6 SL |
3250 | void |
3251 | handle_contract_violation (const std::experimental::contract_violation&); | |
2efb237f JCI |
3252 | @end smallexample |
3253 | ||
3254 | There are different sets of additional flags that can be used together | |
3255 | to specify which contracts will be checked and how, for N4820 | |
3256 | contracts, P1332 contracts, or P1429 contracts; these sets cannot be | |
3257 | used together. | |
3258 | ||
3259 | @table @gcctabopt | |
2efb237f | 3260 | @opindex fcontract-mode |
ddf6fe37 | 3261 | @item -fcontract-mode=[on|off] |
2efb237f JCI |
3262 | Control whether any contracts have any semantics at all. Defaults to on. |
3263 | ||
2efb237f | 3264 | @opindex fcontract-assumption-mode |
ddf6fe37 | 3265 | @item -fcontract-assumption-mode=[on|off] |
2efb237f JCI |
3266 | [N4820] Control whether contracts with level @samp{axiom} |
3267 | should have the assume semantic. Defaults to on. | |
3268 | ||
2efb237f | 3269 | @opindex fcontract-build-level |
ddf6fe37 | 3270 | @item -fcontract-build-level=[off|default|audit] |
2efb237f JCI |
3271 | [N4820] Specify which level of contracts to generate checks |
3272 | for. Defaults to @samp{default}. | |
3273 | ||
2efb237f | 3274 | @opindex fcontract-continuation-mode |
ddf6fe37 | 3275 | @item -fcontract-continuation-mode=[on|off] |
2efb237f JCI |
3276 | [N4820] Control whether to allow the program to continue executing |
3277 | after a contract violation. That is, do checked contracts have the | |
3278 | @samp{maybe} semantic described below rather than the @samp{never} | |
3279 | semantic. Defaults to off. | |
3280 | ||
2efb237f | 3281 | @opindex fcontract-role |
ddf6fe37 | 3282 | @item -fcontract-role=<name>:<default>,<audit>,<axiom> |
2efb237f JCI |
3283 | [P1332] Specify the concrete semantics for each contract level |
3284 | of a particular contract role. | |
3285 | ||
3286 | @item -fcontract-semantic=[default|audit|axiom]:<semantic> | |
3287 | [P1429] Specify the concrete semantic for a particular | |
3288 | contract level. | |
3289 | ||
2efb237f | 3290 | @opindex fcontract-strict-declarations |
ddf6fe37 | 3291 | @item -fcontract-strict-declarations=[on|off] |
2efb237f JCI |
3292 | Control whether to reject adding contracts to a function after its |
3293 | first declaration. Defaults to off. | |
3294 | @end table | |
3295 | ||
3296 | The possible concrete semantics for that can be specified with | |
3297 | @samp{-fcontract-role} or @samp{-fcontract-semantic} are: | |
3298 | ||
3299 | @table @code | |
3300 | @item ignore | |
3301 | This contract has no effect. | |
3302 | ||
3303 | @item assume | |
3304 | This contract is treated like C++23 @code{[[assume]]}. | |
3305 | ||
3306 | @item check_never_continue | |
3307 | @itemx never | |
3308 | @itemx abort | |
3309 | This contract is checked. If it fails, the violation handler is | |
3310 | called. If the handler returns, @code{std::terminate} is called. | |
3311 | ||
3312 | @item check_maybe_continue | |
3313 | @itemx maybe | |
3314 | This contract is checked. If it fails, the violation handler is | |
3315 | called. If the handler returns, execution continues normally. | |
3316 | @end table | |
3317 | ||
d77de738 | 3318 | @opindex fcoroutines |
ddf6fe37 | 3319 | @item -fcoroutines |
d77de738 ML |
3320 | Enable support for the C++ coroutines extension (experimental). |
3321 | ||
d77de738 ML |
3322 | @opindex fno-elide-constructors |
3323 | @opindex felide-constructors | |
ddf6fe37 | 3324 | @item -fno-elide-constructors |
d77de738 ML |
3325 | The C++ standard allows an implementation to omit creating a temporary |
3326 | that is only used to initialize another object of the same type. | |
3327 | Specifying this option disables that optimization, and forces G++ to | |
3328 | call the copy constructor in all cases. This option also causes G++ | |
3329 | to call trivial member functions which otherwise would be expanded inline. | |
3330 | ||
3331 | In C++17, the compiler is required to omit these temporaries, but this | |
3332 | option still affects trivial member functions. | |
3333 | ||
d77de738 ML |
3334 | @opindex fno-enforce-eh-specs |
3335 | @opindex fenforce-eh-specs | |
ddf6fe37 | 3336 | @item -fno-enforce-eh-specs |
d77de738 ML |
3337 | Don't generate code to check for violation of exception specifications |
3338 | at run time. This option violates the C++ standard, but may be useful | |
3339 | for reducing code size in production builds, much like defining | |
3340 | @code{NDEBUG}. This does not give user code permission to throw | |
3341 | exceptions in violation of the exception specifications; the compiler | |
3342 | still optimizes based on the specifications, so throwing an | |
3343 | unexpected exception results in undefined behavior at run time. | |
3344 | ||
d77de738 ML |
3345 | @opindex fextern-tls-init |
3346 | @opindex fno-extern-tls-init | |
ddf6fe37 AA |
3347 | @item -fextern-tls-init |
3348 | @itemx -fno-extern-tls-init | |
d77de738 ML |
3349 | The C++11 and OpenMP standards allow @code{thread_local} and |
3350 | @code{threadprivate} variables to have dynamic (runtime) | |
3351 | initialization. To support this, any use of such a variable goes | |
3352 | through a wrapper function that performs any necessary initialization. | |
3353 | When the use and definition of the variable are in the same | |
3354 | translation unit, this overhead can be optimized away, but when the | |
3355 | use is in a different translation unit there is significant overhead | |
3356 | even if the variable doesn't actually need dynamic initialization. If | |
3357 | the programmer can be sure that no use of the variable in a | |
3358 | non-defining TU needs to trigger dynamic initialization (either | |
3359 | because the variable is statically initialized, or a use of the | |
3360 | variable in the defining TU will be executed before any uses in | |
3361 | another TU), they can avoid this overhead with the | |
3362 | @option{-fno-extern-tls-init} option. | |
3363 | ||
3364 | On targets that support symbol aliases, the default is | |
3365 | @option{-fextern-tls-init}. On targets that do not support symbol | |
3366 | aliases, the default is @option{-fno-extern-tls-init}. | |
3367 | ||
d77de738 ML |
3368 | @opindex ffold-simple-inlines |
3369 | @opindex fno-fold-simple-inlines | |
ddf6fe37 AA |
3370 | @item -ffold-simple-inlines |
3371 | @itemx -fno-fold-simple-inlines | |
d77de738 ML |
3372 | Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward}, |
3373 | @code{std::addressof} and @code{std::as_const}. In contrast to inlining, this | |
3374 | means no debug information will be generated for such calls. Since these | |
3375 | functions are rarely interesting to debug, this flag is enabled by default | |
3376 | unless @option{-fno-inline} is active. | |
3377 | ||
d77de738 ML |
3378 | @opindex fno-gnu-keywords |
3379 | @opindex fgnu-keywords | |
ddf6fe37 | 3380 | @item -fno-gnu-keywords |
d77de738 ML |
3381 | Do not recognize @code{typeof} as a keyword, so that code can use this |
3382 | word as an identifier. You can use the keyword @code{__typeof__} instead. | |
3383 | This option is implied by the strict ISO C++ dialects: @option{-ansi}, | |
3384 | @option{-std=c++98}, @option{-std=c++11}, etc. | |
3385 | ||
d77de738 | 3386 | @opindex fimplicit-constexpr |
ddf6fe37 | 3387 | @item -fimplicit-constexpr |
d77de738 ML |
3388 | Make inline functions implicitly constexpr, if they satisfy the |
3389 | requirements for a constexpr function. This option can be used in | |
3390 | C++14 mode or later. This can result in initialization changing from | |
3391 | dynamic to static and other optimizations. | |
3392 | ||
d77de738 ML |
3393 | @opindex fno-implicit-templates |
3394 | @opindex fimplicit-templates | |
ddf6fe37 | 3395 | @item -fno-implicit-templates |
d77de738 ML |
3396 | Never emit code for non-inline templates that are instantiated |
3397 | implicitly (i.e.@: by use); only emit code for explicit instantiations. | |
3398 | If you use this option, you must take care to structure your code to | |
3399 | include all the necessary explicit instantiations to avoid getting | |
3400 | undefined symbols at link time. | |
3401 | @xref{Template Instantiation}, for more information. | |
3402 | ||
d77de738 ML |
3403 | @opindex fno-implicit-inline-templates |
3404 | @opindex fimplicit-inline-templates | |
ddf6fe37 | 3405 | @item -fno-implicit-inline-templates |
d77de738 ML |
3406 | Don't emit code for implicit instantiations of inline templates, either. |
3407 | The default is to handle inlines differently so that compiles with and | |
3408 | without optimization need the same set of explicit instantiations. | |
3409 | ||
d77de738 ML |
3410 | @opindex fno-implement-inlines |
3411 | @opindex fimplement-inlines | |
ddf6fe37 | 3412 | @item -fno-implement-inlines |
d77de738 ML |
3413 | To save space, do not emit out-of-line copies of inline functions |
3414 | controlled by @code{#pragma implementation}. This causes linker | |
3415 | errors if these functions are not inlined everywhere they are called. | |
3416 | ||
d77de738 ML |
3417 | @opindex fmodules-ts |
3418 | @opindex fno-modules-ts | |
ddf6fe37 AA |
3419 | @item -fmodules-ts |
3420 | @itemx -fno-modules-ts | |
d77de738 ML |
3421 | Enable support for C++20 modules (@pxref{C++ Modules}). The |
3422 | @option{-fno-modules-ts} is usually not needed, as that is the | |
3423 | default. Even though this is a C++20 feature, it is not currently | |
3424 | implicitly enabled by selecting that standard version. | |
3425 | ||
ddf6fe37 | 3426 | @opindex fmodule-header |
d77de738 ML |
3427 | @item -fmodule-header |
3428 | @itemx -fmodule-header=user | |
3429 | @itemx -fmodule-header=system | |
d77de738 ML |
3430 | Compile a header file to create an importable header unit. |
3431 | ||
d77de738 | 3432 | @opindex fmodule-implicit-inline |
ddf6fe37 | 3433 | @item -fmodule-implicit-inline |
d77de738 ML |
3434 | Member functions defined in their class definitions are not implicitly |
3435 | inline for modular code. This is different to traditional C++ | |
3436 | behavior, for good reasons. However, it may result in a difficulty | |
3437 | during code porting. This option makes such function definitions | |
3438 | implicitly inline. It does however generate an ABI incompatibility, | |
3439 | so you must use it everywhere or nowhere. (Such definitions outside | |
3440 | of a named module remain implicitly inline, regardless.) | |
3441 | ||
d77de738 ML |
3442 | @opindex fno-module-lazy |
3443 | @opindex fmodule-lazy | |
ddf6fe37 | 3444 | @item -fno-module-lazy |
d77de738 ML |
3445 | Disable lazy module importing and module mapper creation. |
3446 | ||
f33d7a88 AA |
3447 | @vindex CXX_MODULE_MAPPER @r{environment variable} |
3448 | @opindex fmodule-mapper | |
d77de738 ML |
3449 | @item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]} |
3450 | @itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...} | |
3451 | @itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]} | |
3452 | @itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]} | |
3453 | @itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]} | |
3454 | @itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]} | |
d77de738 ML |
3455 | An oracle to query for module name to filename mappings. If |
3456 | unspecified the @env{CXX_MODULE_MAPPER} environment variable is used, | |
3457 | and if that is unset, an in-process default is provided. | |
3458 | ||
d77de738 | 3459 | @opindex fmodule-only |
ddf6fe37 | 3460 | @item -fmodule-only |
d77de738 ML |
3461 | Only emit the Compiled Module Interface, inhibiting any object file. |
3462 | ||
d77de738 | 3463 | @opindex fms-extensions |
ddf6fe37 | 3464 | @item -fms-extensions |
d77de738 ML |
3465 | Disable Wpedantic warnings about constructs used in MFC, such as implicit |
3466 | int and getting a pointer to member function via non-standard syntax. | |
3467 | ||
d77de738 | 3468 | @opindex fnew-inheriting-ctors |
ddf6fe37 | 3469 | @item -fnew-inheriting-ctors |
d77de738 ML |
3470 | Enable the P0136 adjustment to the semantics of C++11 constructor |
3471 | inheritance. This is part of C++17 but also considered to be a Defect | |
3472 | Report against C++11 and C++14. This flag is enabled by default | |
3473 | unless @option{-fabi-version=10} or lower is specified. | |
3474 | ||
d77de738 | 3475 | @opindex fnew-ttp-matching |
ddf6fe37 | 3476 | @item -fnew-ttp-matching |
d77de738 ML |
3477 | Enable the P0522 resolution to Core issue 150, template template |
3478 | parameters and default arguments: this allows a template with default | |
3479 | template arguments as an argument for a template template parameter | |
3480 | with fewer template parameters. This flag is enabled by default for | |
3481 | @option{-std=c++17}. | |
3482 | ||
d77de738 ML |
3483 | @opindex fno-nonansi-builtins |
3484 | @opindex fnonansi-builtins | |
ddf6fe37 | 3485 | @item -fno-nonansi-builtins |
d77de738 ML |
3486 | Disable built-in declarations of functions that are not mandated by |
3487 | ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit}, | |
3488 | @code{index}, @code{bzero}, @code{conjf}, and other related functions. | |
3489 | ||
d77de738 | 3490 | @opindex fnothrow-opt |
ddf6fe37 | 3491 | @item -fnothrow-opt |
d77de738 ML |
3492 | Treat a @code{throw()} exception specification as if it were a |
3493 | @code{noexcept} specification to reduce or eliminate the text size | |
3494 | overhead relative to a function with no exception specification. If | |
3495 | the function has local variables of types with non-trivial | |
3496 | destructors, the exception specification actually makes the | |
3497 | function smaller because the EH cleanups for those variables can be | |
3498 | optimized away. The semantic effect is that an exception thrown out of | |
3499 | a function with such an exception specification results in a call | |
3500 | to @code{terminate} rather than @code{unexpected}. | |
3501 | ||
d77de738 ML |
3502 | @opindex fno-operator-names |
3503 | @opindex foperator-names | |
ddf6fe37 | 3504 | @item -fno-operator-names |
d77de738 ML |
3505 | Do not treat the operator name keywords @code{and}, @code{bitand}, |
3506 | @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as | |
3507 | synonyms as keywords. | |
3508 | ||
d77de738 ML |
3509 | @opindex fno-optional-diags |
3510 | @opindex foptional-diags | |
ddf6fe37 | 3511 | @item -fno-optional-diags |
d77de738 ML |
3512 | Disable diagnostics that the standard says a compiler does not need to |
3513 | issue. Currently, the only such diagnostic issued by G++ is the one for | |
3514 | a name having multiple meanings within a class. | |
3515 | ||
d77de738 ML |
3516 | @opindex fno-pretty-templates |
3517 | @opindex fpretty-templates | |
ddf6fe37 | 3518 | @item -fno-pretty-templates |
d77de738 ML |
3519 | When an error message refers to a specialization of a function |
3520 | template, the compiler normally prints the signature of the | |
3521 | template followed by the template arguments and any typedefs or | |
3522 | typenames in the signature (e.g.@: @code{void f(T) [with T = int]} | |
3523 | rather than @code{void f(int)}) so that it's clear which template is | |
3524 | involved. When an error message refers to a specialization of a class | |
3525 | template, the compiler omits any template arguments that match | |
3526 | the default template arguments for that template. If either of these | |
3527 | behaviors make it harder to understand the error message rather than | |
3528 | easier, you can use @option{-fno-pretty-templates} to disable them. | |
3529 | ||
d77de738 ML |
3530 | @opindex fno-rtti |
3531 | @opindex frtti | |
ddf6fe37 | 3532 | @item -fno-rtti |
d77de738 ML |
3533 | Disable generation of information about every class with virtual |
3534 | functions for use by the C++ run-time type identification features | |
3535 | (@code{dynamic_cast} and @code{typeid}). If you don't use those parts | |
3536 | of the language, you can save some space by using this flag. Note that | |
3537 | exception handling uses the same information, but G++ generates it as | |
3538 | needed. The @code{dynamic_cast} operator can still be used for casts that | |
3539 | do not require run-time type information, i.e.@: casts to @code{void *} or to | |
3540 | unambiguous base classes. | |
3541 | ||
3542 | Mixing code compiled with @option{-frtti} with that compiled with | |
3543 | @option{-fno-rtti} may not work. For example, programs may | |
3544 | fail to link if a class compiled with @option{-fno-rtti} is used as a base | |
3545 | for a class compiled with @option{-frtti}. | |
3546 | ||
d77de738 | 3547 | @opindex fsized-deallocation |
ddf6fe37 | 3548 | @item -fsized-deallocation |
d77de738 ML |
3549 | Enable the built-in global declarations |
3550 | @smallexample | |
3551 | void operator delete (void *, std::size_t) noexcept; | |
3552 | void operator delete[] (void *, std::size_t) noexcept; | |
3553 | @end smallexample | |
3554 | as introduced in C++14. This is useful for user-defined replacement | |
3555 | deallocation functions that, for example, use the size of the object | |
3556 | to make deallocation faster. Enabled by default under | |
3557 | @option{-std=c++14} and above. The flag @option{-Wsized-deallocation} | |
3558 | warns about places that might want to add a definition. | |
3559 | ||
d77de738 | 3560 | @opindex fstrict-enums |
ddf6fe37 | 3561 | @item -fstrict-enums |
d77de738 ML |
3562 | Allow the compiler to optimize using the assumption that a value of |
3563 | enumerated type can only be one of the values of the enumeration (as | |
3564 | defined in the C++ standard; basically, a value that can be | |
3565 | represented in the minimum number of bits needed to represent all the | |
3566 | enumerators). This assumption may not be valid if the program uses a | |
3567 | cast to convert an arbitrary integer value to the enumerated type. | |
d8a656d5 JW |
3568 | This option has no effect for an enumeration type with a fixed underlying |
3569 | type. | |
d77de738 | 3570 | |
d77de738 | 3571 | @opindex fstrong-eval-order |
ddf6fe37 | 3572 | @item -fstrong-eval-order |
d77de738 ML |
3573 | Evaluate member access, array subscripting, and shift expressions in |
3574 | left-to-right order, and evaluate assignment in right-to-left order, | |
3575 | as adopted for C++17. Enabled by default with @option{-std=c++17}. | |
3576 | @option{-fstrong-eval-order=some} enables just the ordering of member | |
3577 | access and shift expressions, and is the default without | |
3578 | @option{-std=c++17}. | |
3579 | ||
d77de738 | 3580 | @opindex ftemplate-backtrace-limit |
ddf6fe37 | 3581 | @item -ftemplate-backtrace-limit=@var{n} |
d77de738 ML |
3582 | Set the maximum number of template instantiation notes for a single |
3583 | warning or error to @var{n}. The default value is 10. | |
3584 | ||
d77de738 | 3585 | @opindex ftemplate-depth |
ddf6fe37 | 3586 | @item -ftemplate-depth=@var{n} |
d77de738 ML |
3587 | Set the maximum instantiation depth for template classes to @var{n}. |
3588 | A limit on the template instantiation depth is needed to detect | |
3589 | endless recursions during template class instantiation. ANSI/ISO C++ | |
3590 | conforming programs must not rely on a maximum depth greater than 17 | |
3591 | (changed to 1024 in C++11). The default value is 900, as the compiler | |
3592 | can run out of stack space before hitting 1024 in some situations. | |
3593 | ||
d77de738 ML |
3594 | @opindex fno-threadsafe-statics |
3595 | @opindex fthreadsafe-statics | |
ddf6fe37 | 3596 | @item -fno-threadsafe-statics |
d77de738 ML |
3597 | Do not emit the extra code to use the routines specified in the C++ |
3598 | ABI for thread-safe initialization of local statics. You can use this | |
3599 | option to reduce code size slightly in code that doesn't need to be | |
3600 | thread-safe. | |
3601 | ||
d77de738 | 3602 | @opindex fuse-cxa-atexit |
ddf6fe37 | 3603 | @item -fuse-cxa-atexit |
d77de738 ML |
3604 | Register destructors for objects with static storage duration with the |
3605 | @code{__cxa_atexit} function rather than the @code{atexit} function. | |
3606 | This option is required for fully standards-compliant handling of static | |
3607 | destructors, but only works if your C library supports | |
3608 | @code{__cxa_atexit}. | |
3609 | ||
d77de738 ML |
3610 | @opindex fno-use-cxa-get-exception-ptr |
3611 | @opindex fuse-cxa-get-exception-ptr | |
ddf6fe37 | 3612 | @item -fno-use-cxa-get-exception-ptr |
d77de738 ML |
3613 | Don't use the @code{__cxa_get_exception_ptr} runtime routine. This |
3614 | causes @code{std::uncaught_exception} to be incorrect, but is necessary | |
3615 | if the runtime routine is not available. | |
3616 | ||
d77de738 | 3617 | @opindex fvisibility-inlines-hidden |
ddf6fe37 | 3618 | @item -fvisibility-inlines-hidden |
d77de738 ML |
3619 | This switch declares that the user does not attempt to compare |
3620 | pointers to inline functions or methods where the addresses of the two functions | |
3621 | are taken in different shared objects. | |
3622 | ||
3623 | The effect of this is that GCC may, effectively, mark inline methods with | |
3624 | @code{__attribute__ ((visibility ("hidden")))} so that they do not | |
3625 | appear in the export table of a DSO and do not require a PLT indirection | |
3626 | when used within the DSO@. Enabling this option can have a dramatic effect | |
3627 | on load and link times of a DSO as it massively reduces the size of the | |
3628 | dynamic export table when the library makes heavy use of templates. | |
3629 | ||
3630 | The behavior of this switch is not quite the same as marking the | |
3631 | methods as hidden directly, because it does not affect static variables | |
3632 | local to the function or cause the compiler to deduce that | |
3633 | the function is defined in only one shared object. | |
3634 | ||
3635 | You may mark a method as having a visibility explicitly to negate the | |
3636 | effect of the switch for that method. For example, if you do want to | |
3637 | compare pointers to a particular inline method, you might mark it as | |
3638 | having default visibility. Marking the enclosing class with explicit | |
3639 | visibility has no effect. | |
3640 | ||
3641 | Explicitly instantiated inline methods are unaffected by this option | |
3642 | as their linkage might otherwise cross a shared library boundary. | |
3643 | @xref{Template Instantiation}. | |
3644 | ||
d77de738 | 3645 | @opindex fvisibility-ms-compat |
ddf6fe37 | 3646 | @item -fvisibility-ms-compat |
d77de738 ML |
3647 | This flag attempts to use visibility settings to make GCC's C++ |
3648 | linkage model compatible with that of Microsoft Visual Studio. | |
3649 | ||
3650 | The flag makes these changes to GCC's linkage model: | |
3651 | ||
3652 | @enumerate | |
3653 | @item | |
3654 | It sets the default visibility to @code{hidden}, like | |
3655 | @option{-fvisibility=hidden}. | |
3656 | ||
3657 | @item | |
3658 | Types, but not their members, are not hidden by default. | |
3659 | ||
3660 | @item | |
3661 | The One Definition Rule is relaxed for types without explicit | |
3662 | visibility specifications that are defined in more than one | |
3663 | shared object: those declarations are permitted if they are | |
3664 | permitted when this option is not used. | |
3665 | @end enumerate | |
3666 | ||
3667 | In new code it is better to use @option{-fvisibility=hidden} and | |
3668 | export those classes that are intended to be externally visible. | |
3669 | Unfortunately it is possible for code to rely, perhaps accidentally, | |
3670 | on the Visual Studio behavior. | |
3671 | ||
3672 | Among the consequences of these changes are that static data members | |
3673 | of the same type with the same name but defined in different shared | |
3674 | objects are different, so changing one does not change the other; | |
3675 | and that pointers to function members defined in different shared | |
3676 | objects may not compare equal. When this flag is given, it is a | |
3677 | violation of the ODR to define types with the same name differently. | |
3678 | ||
d77de738 ML |
3679 | @opindex fno-weak |
3680 | @opindex fweak | |
ddf6fe37 | 3681 | @item -fno-weak |
d77de738 ML |
3682 | Do not use weak symbol support, even if it is provided by the linker. |
3683 | By default, G++ uses weak symbols if they are available. This | |
3684 | option exists only for testing, and should not be used by end-users; | |
3685 | it results in inferior code and has no benefits. This option may | |
3686 | be removed in a future release of G++. | |
3687 | ||
d77de738 ML |
3688 | @opindex fext-numeric-literals |
3689 | @opindex fno-ext-numeric-literals | |
ddf6fe37 | 3690 | @item -fext-numeric-literals @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3691 | Accept imaginary, fixed-point, or machine-defined |
3692 | literal number suffixes as GNU extensions. | |
3693 | When this option is turned off these suffixes are treated | |
3694 | as C++11 user-defined literal numeric suffixes. | |
3695 | This is on by default for all pre-C++11 dialects and all GNU dialects: | |
3696 | @option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11}, | |
3697 | @option{-std=gnu++14}. | |
3698 | This option is off by default | |
3699 | for ISO C++11 onwards (@option{-std=c++11}, ...). | |
3700 | ||
d77de738 | 3701 | @opindex nostdinc++ |
ddf6fe37 | 3702 | @item -nostdinc++ |
d77de738 ML |
3703 | Do not search for header files in the standard directories specific to |
3704 | C++, but do still search the other standard directories. (This option | |
3705 | is used when building the C++ library.) | |
3706 | ||
ddf6fe37 AA |
3707 | @opindex flang-info-include-translate |
3708 | @opindex flang-info-include-translate-not | |
d77de738 ML |
3709 | @item -flang-info-include-translate |
3710 | @itemx -flang-info-include-translate-not | |
3711 | @itemx -flang-info-include-translate=@var{header} | |
d77de738 ML |
3712 | Inform of include translation events. The first will note accepted |
3713 | include translations, the second will note declined include | |
3714 | translations. The @var{header} form will inform of include | |
3715 | translations relating to that specific header. If @var{header} is of | |
3716 | the form @code{"user"} or @code{<system>} it will be resolved to a | |
3717 | specific user or system header using the include path. | |
3718 | ||
ddf6fe37 | 3719 | @opindex flang-info-module-cmi |
d77de738 ML |
3720 | @item -flang-info-module-cmi |
3721 | @itemx -flang-info-module-cmi=@var{module} | |
d77de738 ML |
3722 | Inform of Compiled Module Interface pathnames. The first will note |
3723 | all read CMI pathnames. The @var{module} form will not reading a | |
3724 | specific module's CMI. @var{module} may be a named module or a | |
3725 | header-unit (the latter indicated by either being a pathname containing | |
3726 | directory separators or enclosed in @code{<>} or @code{""}). | |
3727 | ||
d77de738 | 3728 | @opindex stdlib |
ddf6fe37 | 3729 | @item -stdlib=@var{libstdc++,libc++} |
d77de738 ML |
3730 | When G++ is configured to support this option, it allows specification of |
3731 | alternate C++ runtime libraries. Two options are available: @var{libstdc++} | |
3732 | (the default, native C++ runtime for G++) and @var{libc++} which is the | |
3733 | C++ runtime installed on some operating systems (e.g. Darwin versions from | |
3734 | Darwin11 onwards). The option switches G++ to use the headers from the | |
3735 | specified library and to emit @code{-lstdc++} or @code{-lc++} respectively, | |
3736 | when a C++ runtime is required for linking. | |
3737 | @end table | |
3738 | ||
3739 | In addition, these warning options have meanings only for C++ programs: | |
3740 | ||
3741 | @table @gcctabopt | |
d77de738 | 3742 | @opindex Wabi-tag |
ddf6fe37 | 3743 | @item -Wabi-tag @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3744 | Warn when a type with an ABI tag is used in a context that does not |
3745 | have that ABI tag. See @ref{C++ Attributes} for more information | |
3746 | about ABI tags. | |
3747 | ||
d77de738 ML |
3748 | @opindex Wcomma-subscript |
3749 | @opindex Wno-comma-subscript | |
ddf6fe37 | 3750 | @item -Wcomma-subscript @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3751 | Warn about uses of a comma expression within a subscripting expression. |
3752 | This usage was deprecated in C++20 and is going to be removed in C++23. | |
3753 | However, a comma expression wrapped in @code{( )} is not deprecated. Example: | |
3754 | ||
3755 | @smallexample | |
3756 | @group | |
3757 | void f(int *a, int b, int c) @{ | |
3758 | a[b,c]; // deprecated in C++20, invalid in C++23 | |
3759 | a[(b,c)]; // OK | |
3760 | @} | |
3761 | @end group | |
3762 | @end smallexample | |
3763 | ||
3764 | In C++23 it is valid to have comma separated expressions in a subscript | |
3765 | when an overloaded subscript operator is found and supports the right | |
3766 | number and types of arguments. G++ will accept the formerly valid syntax | |
3767 | for code that is not valid in C++23 but used to be valid but deprecated | |
3768 | in C++20 with a pedantic warning that can be disabled with | |
3769 | @option{-Wno-comma-subscript}. | |
3770 | ||
3771 | Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated}, | |
3772 | and with @option{-std=c++23} regardless of @option{-Wno-deprecated}. | |
3773 | ||
5fccebdb JM |
3774 | This warning is upgraded to an error by @option{-pedantic-errors} in |
3775 | C++23 mode or later. | |
3776 | ||
d77de738 ML |
3777 | @opindex Wctad-maybe-unsupported |
3778 | @opindex Wno-ctad-maybe-unsupported | |
ddf6fe37 | 3779 | @item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3780 | Warn when performing class template argument deduction (CTAD) on a type with |
3781 | no explicitly written deduction guides. This warning will point out cases | |
3782 | where CTAD succeeded only because the compiler synthesized the implicit | |
3783 | deduction guides, which might not be what the programmer intended. Certain | |
3784 | style guides allow CTAD only on types that specifically "opt-in"; i.e., on | |
3785 | types that are designed to support CTAD. This warning can be suppressed with | |
3786 | the following pattern: | |
3787 | ||
3788 | @smallexample | |
3789 | struct allow_ctad_t; // any name works | |
3790 | template <typename T> struct S @{ | |
3791 | S(T) @{ @} | |
3792 | @}; | |
4ace81b6 SL |
3793 | // Guide with incomplete parameter type will never be considered. |
3794 | S(allow_ctad_t) -> S<void>; | |
d77de738 ML |
3795 | @end smallexample |
3796 | ||
d77de738 ML |
3797 | @opindex Wctor-dtor-privacy |
3798 | @opindex Wno-ctor-dtor-privacy | |
ddf6fe37 | 3799 | @item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3800 | Warn when a class seems unusable because all the constructors or |
3801 | destructors in that class are private, and it has neither friends nor | |
3802 | public static member functions. Also warn if there are no non-private | |
3803 | methods, and there's at least one private member function that isn't | |
3804 | a constructor or destructor. | |
3805 | ||
d77de738 ML |
3806 | @opindex Wdangling-reference |
3807 | @opindex Wno-dangling-reference | |
ddf6fe37 | 3808 | @item -Wdangling-reference @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3809 | Warn when a reference is bound to a temporary whose lifetime has ended. |
3810 | For example: | |
3811 | ||
3812 | @smallexample | |
3813 | int n = 1; | |
3814 | const int& r = std::max(n - 1, n + 1); // r is dangling | |
3815 | @end smallexample | |
3816 | ||
3817 | In the example above, two temporaries are created, one for each | |
3818 | argument, and a reference to one of the temporaries is returned. | |
3819 | However, both temporaries are destroyed at the end of the full | |
3820 | expression, so the reference @code{r} is dangling. This warning | |
3821 | also detects dangling references in member initializer lists: | |
3822 | ||
3823 | @smallexample | |
3824 | const int& f(const int& i) @{ return i; @} | |
3825 | struct S @{ | |
3826 | const int &r; // r is dangling | |
3827 | S() : r(f(10)) @{ @} | |
3828 | @}; | |
3829 | @end smallexample | |
3830 | ||
3831 | Member functions are checked as well, but only their object argument: | |
3832 | ||
3833 | @smallexample | |
3834 | struct S @{ | |
3835 | const S& self () @{ return *this; @} | |
3836 | @}; | |
3837 | const S& s = S().self(); // s is dangling | |
3838 | @end smallexample | |
3839 | ||
3840 | Certain functions are safe in this respect, for example @code{std::use_facet}: | |
3841 | they take and return a reference, but they don't return one of its arguments, | |
3842 | which can fool the warning. Such functions can be excluded from the warning | |
3843 | by wrapping them in a @code{#pragma}: | |
3844 | ||
3845 | @smallexample | |
3846 | #pragma GCC diagnostic push | |
3847 | #pragma GCC diagnostic ignored "-Wdangling-reference" | |
3848 | const T& foo (const T&) @{ @dots{} @} | |
3849 | #pragma GCC diagnostic pop | |
3850 | @end smallexample | |
3851 | ||
ce51e843 ML |
3852 | @option{-Wdangling-reference} also warns about code like |
3853 | ||
3854 | @smallexample | |
3855 | auto p = std::minmax(1, 2); | |
3856 | @end smallexample | |
3857 | ||
3858 | where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and | |
3859 | both references dangle after the end of the full expression that contains | |
3860 | the call to @code{std::minmax}. | |
3861 | ||
d77de738 ML |
3862 | This warning is enabled by @option{-Wall}. |
3863 | ||
d77de738 ML |
3864 | @opindex Wdelete-non-virtual-dtor |
3865 | @opindex Wno-delete-non-virtual-dtor | |
ddf6fe37 | 3866 | @item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3867 | Warn when @code{delete} is used to destroy an instance of a class that |
3868 | has virtual functions and non-virtual destructor. It is unsafe to delete | |
3869 | an instance of a derived class through a pointer to a base class if the | |
3870 | base class does not have a virtual destructor. This warning is enabled | |
3871 | by @option{-Wall}. | |
3872 | ||
d77de738 ML |
3873 | @opindex Wdeprecated-copy |
3874 | @opindex Wno-deprecated-copy | |
ddf6fe37 | 3875 | @item -Wdeprecated-copy @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3876 | Warn that the implicit declaration of a copy constructor or copy |
3877 | assignment operator is deprecated if the class has a user-provided | |
3878 | copy constructor or copy assignment operator, in C++11 and up. This | |
3879 | warning is enabled by @option{-Wextra}. With | |
3880 | @option{-Wdeprecated-copy-dtor}, also deprecate if the class has a | |
3881 | user-provided destructor. | |
3882 | ||
d77de738 ML |
3883 | @opindex Wdeprecated-enum-enum-conversion |
3884 | @opindex Wno-deprecated-enum-enum-conversion | |
ddf6fe37 | 3885 | @item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3886 | Disable the warning about the case when the usual arithmetic conversions |
3887 | are applied on operands where one is of enumeration type and the other is | |
3888 | of a different enumeration type. This conversion was deprecated in C++20. | |
3889 | For example: | |
3890 | ||
3891 | @smallexample | |
3892 | enum E1 @{ e @}; | |
3893 | enum E2 @{ f @}; | |
3894 | int k = f - e; | |
3895 | @end smallexample | |
3896 | ||
3897 | @option{-Wdeprecated-enum-enum-conversion} is enabled by default with | |
3898 | @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled | |
3899 | by @option{-Wenum-conversion}. | |
3900 | ||
d77de738 ML |
3901 | @opindex Wdeprecated-enum-float-conversion |
3902 | @opindex Wno-deprecated-enum-float-conversion | |
ddf6fe37 | 3903 | @item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3904 | Disable the warning about the case when the usual arithmetic conversions |
3905 | are applied on operands where one is of enumeration type and the other is | |
3906 | of a floating-point type. This conversion was deprecated in C++20. For | |
3907 | example: | |
3908 | ||
3909 | @smallexample | |
3910 | enum E1 @{ e @}; | |
3911 | enum E2 @{ f @}; | |
3912 | bool b = e <= 3.7; | |
3913 | @end smallexample | |
3914 | ||
3915 | @option{-Wdeprecated-enum-float-conversion} is enabled by default with | |
3916 | @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled | |
3917 | by @option{-Wenum-conversion}. | |
3918 | ||
b106f11d AC |
3919 | @opindex Welaborated-enum-base |
3920 | @opindex Wno-elaborated-enum-base | |
3921 | @item -Wno-elaborated-enum-base | |
3922 | For C++11 and above, warn if an (invalid) additional enum-base is used | |
3923 | in an elaborated-type-specifier. That is, if an enum with given | |
3924 | underlying type and no enumerator list is used in a declaration other | |
3925 | than just a standalone declaration of the enum. Enabled by default. This | |
3926 | warning is upgraded to an error with -pedantic-errors. | |
3927 | ||
d77de738 ML |
3928 | @opindex Winit-list-lifetime |
3929 | @opindex Wno-init-list-lifetime | |
ddf6fe37 | 3930 | @item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3931 | Do not warn about uses of @code{std::initializer_list} that are likely |
3932 | to result in dangling pointers. Since the underlying array for an | |
3933 | @code{initializer_list} is handled like a normal C++ temporary object, | |
3934 | it is easy to inadvertently keep a pointer to the array past the end | |
3935 | of the array's lifetime. For example: | |
3936 | ||
3937 | @itemize @bullet | |
3938 | @item | |
3939 | If a function returns a temporary @code{initializer_list}, or a local | |
3940 | @code{initializer_list} variable, the array's lifetime ends at the end | |
3941 | of the return statement, so the value returned has a dangling pointer. | |
3942 | ||
3943 | @item | |
3944 | If a new-expression creates an @code{initializer_list}, the array only | |
3945 | lives until the end of the enclosing full-expression, so the | |
3946 | @code{initializer_list} in the heap has a dangling pointer. | |
3947 | ||
3948 | @item | |
3949 | When an @code{initializer_list} variable is assigned from a | |
3950 | brace-enclosed initializer list, the temporary array created for the | |
3951 | right side of the assignment only lives until the end of the | |
3952 | full-expression, so at the next statement the @code{initializer_list} | |
3953 | variable has a dangling pointer. | |
3954 | ||
3955 | @smallexample | |
3956 | // li's initial underlying array lives as long as li | |
3957 | std::initializer_list<int> li = @{ 1,2,3 @}; | |
3958 | // assignment changes li to point to a temporary array | |
3959 | li = @{ 4, 5 @}; | |
3960 | // now the temporary is gone and li has a dangling pointer | |
3961 | int i = li.begin()[0] // undefined behavior | |
3962 | @end smallexample | |
3963 | ||
3964 | @item | |
3965 | When a list constructor stores the @code{begin} pointer from the | |
3966 | @code{initializer_list} argument, this doesn't extend the lifetime of | |
3967 | the array, so if a class variable is constructed from a temporary | |
3968 | @code{initializer_list}, the pointer is left dangling by the end of | |
3969 | the variable declaration statement. | |
3970 | ||
3971 | @end itemize | |
3972 | ||
c85f8dbb MP |
3973 | @opindex Winvalid-constexpr |
3974 | @opindex Wno-invalid-constexpr | |
ddf6fe37 | 3975 | @item -Winvalid-constexpr |
c85f8dbb MP |
3976 | |
3977 | Warn when a function never produces a constant expression. In C++20 | |
3978 | and earlier, for every @code{constexpr} function and function template, | |
3979 | there must be at least one set of function arguments in at least one | |
3980 | instantiation such that an invocation of the function or constructor | |
3981 | could be an evaluated subexpression of a core constant expression. | |
3982 | C++23 removed this restriction, so it's possible to have a function | |
3983 | or a function template marked @code{constexpr} for which no invocation | |
3984 | satisfies the requirements of a core constant expression. | |
3985 | ||
3986 | This warning is enabled as a pedantic warning by default in C++20 and | |
3987 | earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in | |
3988 | which case it will be an ordinary warning. For example: | |
3989 | ||
3990 | @smallexample | |
3991 | void f (int& i); | |
3992 | constexpr void | |
3993 | g (int& i) | |
3994 | @{ | |
4ace81b6 SL |
3995 | // Warns by default in C++20, in C++23 only with -Winvalid-constexpr. |
3996 | f(i); | |
c85f8dbb MP |
3997 | @} |
3998 | @end smallexample | |
3999 | ||
d77de738 ML |
4000 | @opindex Winvalid-imported-macros |
4001 | @opindex Wno-invalid-imported-macros | |
ddf6fe37 | 4002 | @item -Winvalid-imported-macros |
d77de738 ML |
4003 | Verify all imported macro definitions are valid at the end of |
4004 | compilation. This is not enabled by default, as it requires | |
4005 | additional processing to determine. It may be useful when preparing | |
4006 | sets of header-units to ensure consistent macros. | |
4007 | ||
d77de738 ML |
4008 | @opindex Wliteral-suffix |
4009 | @opindex Wno-literal-suffix | |
ddf6fe37 | 4010 | @item -Wno-literal-suffix @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4011 | Do not warn when a string or character literal is followed by a |
4012 | ud-suffix which does not begin with an underscore. As a conforming | |
4013 | extension, GCC treats such suffixes as separate preprocessing tokens | |
4014 | in order to maintain backwards compatibility with code that uses | |
4015 | formatting macros from @code{<inttypes.h>}. For example: | |
4016 | ||
4017 | @smallexample | |
4018 | #define __STDC_FORMAT_MACROS | |
4019 | #include <inttypes.h> | |
4020 | #include <stdio.h> | |
4021 | ||
4022 | int main() @{ | |
4023 | int64_t i64 = 123; | |
4024 | printf("My int64: %" PRId64"\n", i64); | |
4025 | @} | |
4026 | @end smallexample | |
4027 | ||
4028 | In this case, @code{PRId64} is treated as a separate preprocessing token. | |
4029 | ||
4030 | This option also controls warnings when a user-defined literal | |
4031 | operator is declared with a literal suffix identifier that doesn't | |
4032 | begin with an underscore. Literal suffix identifiers that don't begin | |
4033 | with an underscore are reserved for future standardization. | |
4034 | ||
4035 | These warnings are enabled by default. | |
4036 | ||
d77de738 ML |
4037 | @opindex Wnarrowing |
4038 | @opindex Wno-narrowing | |
ddf6fe37 | 4039 | @item -Wno-narrowing @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4040 | For C++11 and later standards, narrowing conversions are diagnosed by default, |
4041 | as required by the standard. A narrowing conversion from a constant produces | |
4042 | an error, and a narrowing conversion from a non-constant produces a warning, | |
4043 | but @option{-Wno-narrowing} suppresses the diagnostic. | |
4044 | Note that this does not affect the meaning of well-formed code; | |
4045 | narrowing conversions are still considered ill-formed in SFINAE contexts. | |
4046 | ||
4047 | With @option{-Wnarrowing} in C++98, warn when a narrowing | |
4048 | conversion prohibited by C++11 occurs within | |
4049 | @samp{@{ @}}, e.g. | |
4050 | ||
4051 | @smallexample | |
4052 | int i = @{ 2.2 @}; // error: narrowing from double to int | |
4053 | @end smallexample | |
4054 | ||
4055 | This flag is included in @option{-Wall} and @option{-Wc++11-compat}. | |
4056 | ||
d77de738 ML |
4057 | @opindex Wnoexcept |
4058 | @opindex Wno-noexcept | |
ddf6fe37 | 4059 | @item -Wnoexcept @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4060 | Warn when a noexcept-expression evaluates to false because of a call |
4061 | to a function that does not have a non-throwing exception | |
4062 | specification (i.e. @code{throw()} or @code{noexcept}) but is known by | |
4063 | the compiler to never throw an exception. | |
4064 | ||
d77de738 ML |
4065 | @opindex Wnoexcept-type |
4066 | @opindex Wno-noexcept-type | |
ddf6fe37 | 4067 | @item -Wnoexcept-type @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4068 | Warn if the C++17 feature making @code{noexcept} part of a function |
4069 | type changes the mangled name of a symbol relative to C++14. Enabled | |
4070 | by @option{-Wabi} and @option{-Wc++17-compat}. | |
4071 | ||
4072 | As an example: | |
4073 | ||
4074 | @smallexample | |
4075 | template <class T> void f(T t) @{ t(); @}; | |
4076 | void g() noexcept; | |
4077 | void h() @{ f(g); @} | |
4078 | @end smallexample | |
4079 | ||
4080 | @noindent | |
4081 | In C++14, @code{f} calls @code{f<void(*)()>}, but in | |
4082 | C++17 it calls @code{f<void(*)()noexcept>}. | |
4083 | ||
d77de738 ML |
4084 | @opindex Wclass-memaccess |
4085 | @opindex Wno-class-memaccess | |
ddf6fe37 | 4086 | @item -Wclass-memaccess @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4087 | Warn when the destination of a call to a raw memory function such as |
4088 | @code{memset} or @code{memcpy} is an object of class type, and when writing | |
4089 | into such an object might bypass the class non-trivial or deleted constructor | |
4090 | or copy assignment, violate const-correctness or encapsulation, or corrupt | |
4091 | virtual table pointers. Modifying the representation of such objects may | |
4092 | violate invariants maintained by member functions of the class. For example, | |
4093 | the call to @code{memset} below is undefined because it modifies a non-trivial | |
4094 | class object and is, therefore, diagnosed. The safe way to either initialize | |
4095 | or clear the storage of objects of such types is by using the appropriate | |
4096 | constructor or assignment operator, if one is available. | |
4097 | @smallexample | |
4098 | std::string str = "abc"; | |
4099 | memset (&str, 0, sizeof str); | |
4100 | @end smallexample | |
4101 | The @option{-Wclass-memaccess} option is enabled by @option{-Wall}. | |
4102 | Explicitly casting the pointer to the class object to @code{void *} or | |
4103 | to a type that can be safely accessed by the raw memory function suppresses | |
4104 | the warning. | |
4105 | ||
d77de738 ML |
4106 | @opindex Wnon-virtual-dtor |
4107 | @opindex Wno-non-virtual-dtor | |
ddf6fe37 | 4108 | @item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4109 | Warn when a class has virtual functions and an accessible non-virtual |
4110 | destructor itself or in an accessible polymorphic base class, in which | |
4111 | case it is possible but unsafe to delete an instance of a derived | |
4112 | class through a pointer to the class itself or base class. This | |
4113 | warning is automatically enabled if @option{-Weffc++} is specified. | |
51f28e3a JW |
4114 | The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall}) |
4115 | should be preferred because it warns about the unsafe cases without false | |
4116 | positives. | |
d77de738 | 4117 | |
d77de738 ML |
4118 | @opindex Wregister |
4119 | @opindex Wno-register | |
ddf6fe37 | 4120 | @item -Wregister @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4121 | Warn on uses of the @code{register} storage class specifier, except |
4122 | when it is part of the GNU @ref{Explicit Register Variables} extension. | |
4123 | The use of the @code{register} keyword as storage class specifier has | |
4124 | been deprecated in C++11 and removed in C++17. | |
4125 | Enabled by default with @option{-std=c++17}. | |
4126 | ||
d77de738 ML |
4127 | @opindex Wreorder |
4128 | @opindex Wno-reorder | |
4129 | @cindex reordering, warning | |
4130 | @cindex warning for reordering of member initializers | |
f33d7a88 | 4131 | @item -Wreorder @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4132 | Warn when the order of member initializers given in the code does not |
4133 | match the order in which they must be executed. For instance: | |
4134 | ||
4135 | @smallexample | |
4136 | struct A @{ | |
4137 | int i; | |
4138 | int j; | |
4139 | A(): j (0), i (1) @{ @} | |
4140 | @}; | |
4141 | @end smallexample | |
4142 | ||
4143 | @noindent | |
4144 | The compiler rearranges the member initializers for @code{i} | |
4145 | and @code{j} to match the declaration order of the members, emitting | |
4146 | a warning to that effect. This warning is enabled by @option{-Wall}. | |
4147 | ||
d77de738 ML |
4148 | @opindex Wpessimizing-move |
4149 | @opindex Wno-pessimizing-move | |
ddf6fe37 | 4150 | @item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4151 | This warning warns when a call to @code{std::move} prevents copy |
4152 | elision. A typical scenario when copy elision can occur is when returning in | |
4153 | a function with a class return type, when the expression being returned is the | |
4154 | name of a non-volatile automatic object, and is not a function parameter, and | |
4155 | has the same type as the function return type. | |
4156 | ||
4157 | @smallexample | |
4158 | struct T @{ | |
4159 | @dots{} | |
4160 | @}; | |
4161 | T fn() | |
4162 | @{ | |
4163 | T t; | |
4164 | @dots{} | |
4165 | return std::move (t); | |
4166 | @} | |
4167 | @end smallexample | |
4168 | ||
4169 | But in this example, the @code{std::move} call prevents copy elision. | |
4170 | ||
4171 | This warning is enabled by @option{-Wall}. | |
4172 | ||
d77de738 ML |
4173 | @opindex Wredundant-move |
4174 | @opindex Wno-redundant-move | |
ddf6fe37 | 4175 | @item -Wno-redundant-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4176 | This warning warns about redundant calls to @code{std::move}; that is, when |
4177 | a move operation would have been performed even without the @code{std::move} | |
4178 | call. This happens because the compiler is forced to treat the object as if | |
4179 | it were an rvalue in certain situations such as returning a local variable, | |
4180 | where copy elision isn't applicable. Consider: | |
4181 | ||
4182 | @smallexample | |
4183 | struct T @{ | |
4184 | @dots{} | |
4185 | @}; | |
4186 | T fn(T t) | |
4187 | @{ | |
4188 | @dots{} | |
4189 | return std::move (t); | |
4190 | @} | |
4191 | @end smallexample | |
4192 | ||
4193 | Here, the @code{std::move} call is redundant. Because G++ implements Core | |
4194 | Issue 1579, another example is: | |
4195 | ||
4196 | @smallexample | |
4197 | struct T @{ // convertible to U | |
4198 | @dots{} | |
4199 | @}; | |
4200 | struct U @{ | |
4201 | @dots{} | |
4202 | @}; | |
4203 | U fn() | |
4204 | @{ | |
4205 | T t; | |
4206 | @dots{} | |
4207 | return std::move (t); | |
4208 | @} | |
4209 | @end smallexample | |
4210 | In this example, copy elision isn't applicable because the type of the | |
4211 | expression being returned and the function return type differ, yet G++ | |
4212 | treats the return value as if it were designated by an rvalue. | |
4213 | ||
4214 | This warning is enabled by @option{-Wextra}. | |
4215 | ||
d77de738 ML |
4216 | @opindex Wrange-loop-construct |
4217 | @opindex Wno-range-loop-construct | |
ddf6fe37 | 4218 | @item -Wrange-loop-construct @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4219 | This warning warns when a C++ range-based for-loop is creating an unnecessary |
4220 | copy. This can happen when the range declaration is not a reference, but | |
4221 | probably should be. For example: | |
4222 | ||
4223 | @smallexample | |
4224 | struct S @{ char arr[128]; @}; | |
4225 | void fn () @{ | |
4226 | S arr[5]; | |
4227 | for (const auto x : arr) @{ @dots{} @} | |
4228 | @} | |
4229 | @end smallexample | |
4230 | ||
4231 | It does not warn when the type being copied is a trivially-copyable type whose | |
4232 | size is less than 64 bytes. | |
4233 | ||
4234 | This warning also warns when a loop variable in a range-based for-loop is | |
4235 | initialized with a value of a different type resulting in a copy. For example: | |
4236 | ||
4237 | @smallexample | |
4238 | void fn() @{ | |
4239 | int arr[10]; | |
4240 | for (const double &x : arr) @{ @dots{} @} | |
4241 | @} | |
4242 | @end smallexample | |
4243 | ||
4244 | In the example above, in every iteration of the loop a temporary value of | |
4245 | type @code{double} is created and destroyed, to which the reference | |
4246 | @code{const double &} is bound. | |
4247 | ||
4248 | This warning is enabled by @option{-Wall}. | |
4249 | ||
d77de738 ML |
4250 | @opindex Wredundant-tags |
4251 | @opindex Wno-redundant-tags | |
ddf6fe37 | 4252 | @item -Wredundant-tags @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4253 | Warn about redundant class-key and enum-key in references to class types |
4254 | and enumerated types in contexts where the key can be eliminated without | |
4255 | causing an ambiguity. For example: | |
4256 | ||
4257 | @smallexample | |
4258 | struct foo; | |
4259 | struct foo *p; // warn that keyword struct can be eliminated | |
4260 | @end smallexample | |
4261 | ||
4262 | @noindent | |
4263 | On the other hand, in this example there is no warning: | |
4264 | ||
4265 | @smallexample | |
4266 | struct foo; | |
4267 | void foo (); // "hides" struct foo | |
4268 | void bar (struct foo&); // no warning, keyword struct is necessary | |
4269 | @end smallexample | |
4270 | ||
d77de738 ML |
4271 | @opindex Wsubobject-linkage |
4272 | @opindex Wno-subobject-linkage | |
ddf6fe37 | 4273 | @item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4274 | Do not warn |
4275 | if a class type has a base or a field whose type uses the anonymous | |
4276 | namespace or depends on a type with no linkage. If a type A depends on | |
4277 | a type B with no or internal linkage, defining it in multiple | |
4278 | translation units would be an ODR violation because the meaning of B | |
4279 | is different in each translation unit. If A only appears in a single | |
4280 | translation unit, the best way to silence the warning is to give it | |
4281 | internal linkage by putting it in an anonymous namespace as well. The | |
4282 | compiler doesn't give this warning for types defined in the main .C | |
4283 | file, as those are unlikely to have multiple definitions. | |
4284 | @option{-Wsubobject-linkage} is enabled by default. | |
4285 | ||
d77de738 ML |
4286 | @opindex Weffc++ |
4287 | @opindex Wno-effc++ | |
ddf6fe37 | 4288 | @item -Weffc++ @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4289 | Warn about violations of the following style guidelines from Scott Meyers' |
4290 | @cite{Effective C++} series of books: | |
4291 | ||
4292 | @itemize @bullet | |
4293 | @item | |
4294 | Define a copy constructor and an assignment operator for classes | |
4295 | with dynamically-allocated memory. | |
4296 | ||
4297 | @item | |
4298 | Prefer initialization to assignment in constructors. | |
4299 | ||
4300 | @item | |
4301 | Have @code{operator=} return a reference to @code{*this}. | |
4302 | ||
4303 | @item | |
4304 | Don't try to return a reference when you must return an object. | |
4305 | ||
4306 | @item | |
4307 | Distinguish between prefix and postfix forms of increment and | |
4308 | decrement operators. | |
4309 | ||
4310 | @item | |
4311 | Never overload @code{&&}, @code{||}, or @code{,}. | |
4312 | ||
4313 | @end itemize | |
4314 | ||
4315 | This option also enables @option{-Wnon-virtual-dtor}, which is also | |
4316 | one of the effective C++ recommendations. However, the check is | |
4317 | extended to warn about the lack of virtual destructor in accessible | |
4318 | non-polymorphic bases classes too. | |
4319 | ||
4320 | When selecting this option, be aware that the standard library | |
4321 | headers do not obey all of these guidelines; use @samp{grep -v} | |
4322 | to filter out those warnings. | |
4323 | ||
d77de738 ML |
4324 | @opindex Wexceptions |
4325 | @opindex Wno-exceptions | |
ddf6fe37 | 4326 | @item -Wno-exceptions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4327 | Disable the warning about the case when an exception handler is shadowed by |
4328 | another handler, which can point out a wrong ordering of exception handlers. | |
4329 | ||
d77de738 ML |
4330 | @opindex Wstrict-null-sentinel |
4331 | @opindex Wno-strict-null-sentinel | |
ddf6fe37 | 4332 | @item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4333 | Warn about the use of an uncasted @code{NULL} as sentinel. When |
4334 | compiling only with GCC this is a valid sentinel, as @code{NULL} is defined | |
4335 | to @code{__null}. Although it is a null pointer constant rather than a | |
4336 | null pointer, it is guaranteed to be of the same size as a pointer. | |
4337 | But this use is not portable across different compilers. | |
4338 | ||
d77de738 ML |
4339 | @opindex Wno-non-template-friend |
4340 | @opindex Wnon-template-friend | |
ddf6fe37 | 4341 | @item -Wno-non-template-friend @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4342 | Disable warnings when non-template friend functions are declared |
4343 | within a template. In very old versions of GCC that predate implementation | |
4344 | of the ISO standard, declarations such as | |
4345 | @samp{friend int foo(int)}, where the name of the friend is an unqualified-id, | |
4346 | could be interpreted as a particular specialization of a template | |
4347 | function; the warning exists to diagnose compatibility problems, | |
4348 | and is enabled by default. | |
4349 | ||
d77de738 ML |
4350 | @opindex Wold-style-cast |
4351 | @opindex Wno-old-style-cast | |
ddf6fe37 | 4352 | @item -Wold-style-cast @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4353 | Warn if an old-style (C-style) cast to a non-void type is used within |
4354 | a C++ program. The new-style casts (@code{dynamic_cast}, | |
4355 | @code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are | |
4356 | less vulnerable to unintended effects and much easier to search for. | |
4357 | ||
d77de738 ML |
4358 | @opindex Woverloaded-virtual |
4359 | @opindex Wno-overloaded-virtual | |
4360 | @cindex overloaded virtual function, warning | |
4361 | @cindex warning for overloaded virtual function | |
f33d7a88 AA |
4362 | @item -Woverloaded-virtual @r{(C++ and Objective-C++ only)} |
4363 | @itemx -Woverloaded-virtual=@var{n} | |
d77de738 ML |
4364 | Warn when a function declaration hides virtual functions from a |
4365 | base class. For example, in: | |
4366 | ||
4367 | @smallexample | |
4368 | struct A @{ | |
4369 | virtual void f(); | |
4370 | @}; | |
4371 | ||
4372 | struct B: public A @{ | |
4373 | void f(int); // does not override | |
4374 | @}; | |
4375 | @end smallexample | |
4376 | ||
4377 | the @code{A} class version of @code{f} is hidden in @code{B}, and code | |
4378 | like: | |
4379 | ||
4380 | @smallexample | |
4381 | B* b; | |
4382 | b->f(); | |
4383 | @end smallexample | |
4384 | ||
4385 | @noindent | |
4386 | fails to compile. | |
4387 | ||
d82490d5 JW |
4388 | In cases where the different signatures are not an accident, the |
4389 | simplest solution is to add a using-declaration to the derived class | |
4390 | to un-hide the base function, e.g. add @code{using A::f;} to @code{B}. | |
4391 | ||
d77de738 ML |
4392 | The optional level suffix controls the behavior when all the |
4393 | declarations in the derived class override virtual functions in the | |
4394 | base class, even if not all of the base functions are overridden: | |
4395 | ||
4396 | @smallexample | |
4397 | struct C @{ | |
4398 | virtual void f(); | |
4399 | virtual void f(int); | |
4400 | @}; | |
4401 | ||
4402 | struct D: public C @{ | |
4403 | void f(int); // does override | |
4404 | @} | |
4405 | @end smallexample | |
4406 | ||
4407 | This pattern is less likely to be a mistake; if D is only used | |
4408 | virtually, the user might have decided that the base class semantics | |
4409 | for some of the overloads are fine. | |
4410 | ||
4411 | At level 1, this case does not warn; at level 2, it does. | |
4412 | @option{-Woverloaded-virtual} by itself selects level 2. Level 1 is | |
4413 | included in @option{-Wall}. | |
4414 | ||
d77de738 ML |
4415 | @opindex Wno-pmf-conversions |
4416 | @opindex Wpmf-conversions | |
ddf6fe37 | 4417 | @item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4418 | Disable the diagnostic for converting a bound pointer to member function |
4419 | to a plain pointer. | |
4420 | ||
d77de738 ML |
4421 | @opindex Wsign-promo |
4422 | @opindex Wno-sign-promo | |
ddf6fe37 | 4423 | @item -Wsign-promo @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4424 | Warn when overload resolution chooses a promotion from unsigned or |
4425 | enumerated type to a signed type, over a conversion to an unsigned type of | |
4426 | the same size. Previous versions of G++ tried to preserve | |
4427 | unsignedness, but the standard mandates the current behavior. | |
4428 | ||
d77de738 ML |
4429 | @opindex Wtemplates |
4430 | @opindex Wno-templates | |
ddf6fe37 | 4431 | @item -Wtemplates @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4432 | Warn when a primary template declaration is encountered. Some coding |
4433 | rules disallow templates, and this may be used to enforce that rule. | |
4434 | The warning is inactive inside a system header file, such as the STL, so | |
4435 | one can still use the STL. One may also instantiate or specialize | |
4436 | templates. | |
4437 | ||
d77de738 ML |
4438 | @opindex Wmismatched-new-delete |
4439 | @opindex Wno-mismatched-new-delete | |
ddf6fe37 | 4440 | @item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4441 | Warn for mismatches between calls to @code{operator new} or @code{operator |
4442 | delete} and the corresponding call to the allocation or deallocation function. | |
4443 | This includes invocations of C++ @code{operator delete} with pointers | |
4444 | returned from either mismatched forms of @code{operator new}, or from other | |
4445 | functions that allocate objects for which the @code{operator delete} isn't | |
4446 | a suitable deallocator, as well as calls to other deallocation functions | |
4447 | with pointers returned from @code{operator new} for which the deallocation | |
4448 | function isn't suitable. | |
4449 | ||
4450 | For example, the @code{delete} expression in the function below is diagnosed | |
4451 | because it doesn't match the array form of the @code{new} expression | |
4452 | the pointer argument was returned from. Similarly, the call to @code{free} | |
4453 | is also diagnosed. | |
4454 | ||
4455 | @smallexample | |
4456 | void f () | |
4457 | @{ | |
4458 | int *a = new int[n]; | |
4459 | delete a; // warning: mismatch in array forms of expressions | |
4460 | ||
4461 | char *p = new char[n]; | |
4462 | free (p); // warning: mismatch between new and free | |
4463 | @} | |
4464 | @end smallexample | |
4465 | ||
4466 | The related option @option{-Wmismatched-dealloc} diagnoses mismatches | |
4467 | involving allocation and deallocation functions other than @code{operator | |
4468 | new} and @code{operator delete}. | |
4469 | ||
4470 | @option{-Wmismatched-new-delete} is included in @option{-Wall}. | |
4471 | ||
d77de738 ML |
4472 | @opindex Wmismatched-tags |
4473 | @opindex Wno-mismatched-tags | |
ddf6fe37 | 4474 | @item -Wmismatched-tags @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4475 | Warn for declarations of structs, classes, and class templates and their |
4476 | specializations with a class-key that does not match either the definition | |
4477 | or the first declaration if no definition is provided. | |
4478 | ||
4479 | For example, the declaration of @code{struct Object} in the argument list | |
4480 | of @code{draw} triggers the warning. To avoid it, either remove the redundant | |
4481 | class-key @code{struct} or replace it with @code{class} to match its definition. | |
4482 | @smallexample | |
4483 | class Object @{ | |
4484 | public: | |
4485 | virtual ~Object () = 0; | |
4486 | @}; | |
4487 | void draw (struct Object*); | |
4488 | @end smallexample | |
4489 | ||
4490 | It is not wrong to declare a class with the class-key @code{struct} as | |
4491 | the example above shows. The @option{-Wmismatched-tags} option is intended | |
4492 | to help achieve a consistent style of class declarations. In code that is | |
4493 | intended to be portable to Windows-based compilers the warning helps prevent | |
4494 | unresolved references due to the difference in the mangling of symbols | |
4495 | declared with different class-keys. The option can be used either on its | |
4496 | own or in conjunction with @option{-Wredundant-tags}. | |
4497 | ||
d77de738 ML |
4498 | @opindex Wmultiple-inheritance |
4499 | @opindex Wno-multiple-inheritance | |
ddf6fe37 | 4500 | @item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4501 | Warn when a class is defined with multiple direct base classes. Some |
4502 | coding rules disallow multiple inheritance, and this may be used to | |
4503 | enforce that rule. The warning is inactive inside a system header file, | |
4504 | such as the STL, so one can still use the STL. One may also define | |
4505 | classes that indirectly use multiple inheritance. | |
4506 | ||
d77de738 ML |
4507 | @opindex Wvirtual-inheritance |
4508 | @opindex Wno-virtual-inheritance | |
ddf6fe37 | 4509 | @item -Wvirtual-inheritance |
d77de738 ML |
4510 | Warn when a class is defined with a virtual direct base class. Some |
4511 | coding rules disallow multiple inheritance, and this may be used to | |
4512 | enforce that rule. The warning is inactive inside a system header file, | |
4513 | such as the STL, so one can still use the STL. One may also define | |
4514 | classes that indirectly use virtual inheritance. | |
4515 | ||
d77de738 ML |
4516 | @opindex Wvirtual-move-assign |
4517 | @opindex Wno-virtual-move-assign | |
ddf6fe37 | 4518 | @item -Wno-virtual-move-assign |
d77de738 ML |
4519 | Suppress warnings about inheriting from a virtual base with a |
4520 | non-trivial C++11 move assignment operator. This is dangerous because | |
4521 | if the virtual base is reachable along more than one path, it is | |
4522 | moved multiple times, which can mean both objects end up in the | |
4523 | moved-from state. If the move assignment operator is written to avoid | |
4524 | moving from a moved-from object, this warning can be disabled. | |
4525 | ||
d77de738 ML |
4526 | @opindex Wnamespaces |
4527 | @opindex Wno-namespaces | |
ddf6fe37 | 4528 | @item -Wnamespaces |
d77de738 ML |
4529 | Warn when a namespace definition is opened. Some coding rules disallow |
4530 | namespaces, and this may be used to enforce that rule. The warning is | |
4531 | inactive inside a system header file, such as the STL, so one can still | |
4532 | use the STL. One may also use using directives and qualified names. | |
4533 | ||
d77de738 ML |
4534 | @opindex Wterminate |
4535 | @opindex Wno-terminate | |
ddf6fe37 | 4536 | @item -Wno-terminate @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4537 | Disable the warning about a throw-expression that will immediately |
4538 | result in a call to @code{terminate}. | |
4539 | ||
d77de738 ML |
4540 | @opindex Wvexing-parse |
4541 | @opindex Wno-vexing-parse | |
ddf6fe37 | 4542 | @item -Wno-vexing-parse @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4543 | Warn about the most vexing parse syntactic ambiguity. This warns about |
4544 | the cases when a declaration looks like a variable definition, but the | |
4545 | C++ language requires it to be interpreted as a function declaration. | |
4546 | For instance: | |
4547 | ||
4548 | @smallexample | |
4549 | void f(double a) @{ | |
4550 | int i(); // extern int i (void); | |
4551 | int n(int(a)); // extern int n (int); | |
4552 | @} | |
4553 | @end smallexample | |
4554 | ||
4555 | Another example: | |
4556 | ||
4557 | @smallexample | |
4558 | struct S @{ S(int); @}; | |
4559 | void f(double a) @{ | |
4560 | S x(int(a)); // extern struct S x (int); | |
4561 | S y(int()); // extern struct S y (int (*) (void)); | |
4562 | S z(); // extern struct S z (void); | |
4563 | @} | |
4564 | @end smallexample | |
4565 | ||
4566 | The warning will suggest options how to deal with such an ambiguity; e.g., | |
4567 | it can suggest removing the parentheses or using braces instead. | |
4568 | ||
4569 | This warning is enabled by default. | |
4570 | ||
d77de738 ML |
4571 | @opindex Wno-class-conversion |
4572 | @opindex Wclass-conversion | |
ddf6fe37 | 4573 | @item -Wno-class-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4574 | Do not warn when a conversion function converts an |
4575 | object to the same type, to a base class of that type, or to void; such | |
4576 | a conversion function will never be called. | |
4577 | ||
d77de738 ML |
4578 | @opindex Wvolatile |
4579 | @opindex Wno-volatile | |
ddf6fe37 | 4580 | @item -Wvolatile @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4581 | Warn about deprecated uses of the @code{volatile} qualifier. This includes |
4582 | postfix and prefix @code{++} and @code{--} expressions of | |
4583 | @code{volatile}-qualified types, using simple assignments where the left | |
4584 | operand is a @code{volatile}-qualified non-class type for their value, | |
4585 | compound assignments where the left operand is a @code{volatile}-qualified | |
4586 | non-class type, @code{volatile}-qualified function return type, | |
4587 | @code{volatile}-qualified parameter type, and structured bindings of a | |
4588 | @code{volatile}-qualified type. This usage was deprecated in C++20. | |
4589 | ||
4590 | Enabled by default with @option{-std=c++20}. | |
4591 | ||
d77de738 ML |
4592 | @opindex Wzero-as-null-pointer-constant |
4593 | @opindex Wno-zero-as-null-pointer-constant | |
ddf6fe37 | 4594 | @item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4595 | Warn when a literal @samp{0} is used as null pointer constant. This can |
4596 | be useful to facilitate the conversion to @code{nullptr} in C++11. | |
4597 | ||
d77de738 ML |
4598 | @opindex Waligned-new |
4599 | @opindex Wno-aligned-new | |
ddf6fe37 | 4600 | @item -Waligned-new |
d77de738 ML |
4601 | Warn about a new-expression of a type that requires greater alignment |
4602 | than the @code{alignof(std::max_align_t)} but uses an allocation | |
4603 | function without an explicit alignment parameter. This option is | |
4604 | enabled by @option{-Wall}. | |
4605 | ||
4606 | Normally this only warns about global allocation functions, but | |
4607 | @option{-Waligned-new=all} also warns about class member allocation | |
4608 | functions. | |
4609 | ||
d77de738 ML |
4610 | @opindex Wplacement-new |
4611 | @opindex Wno-placement-new | |
ddf6fe37 AA |
4612 | @item -Wno-placement-new |
4613 | @itemx -Wplacement-new=@var{n} | |
d77de738 ML |
4614 | Warn about placement new expressions with undefined behavior, such as |
4615 | constructing an object in a buffer that is smaller than the type of | |
4616 | the object. For example, the placement new expression below is diagnosed | |
4617 | because it attempts to construct an array of 64 integers in a buffer only | |
4618 | 64 bytes large. | |
4619 | @smallexample | |
4620 | char buf [64]; | |
4621 | new (buf) int[64]; | |
4622 | @end smallexample | |
4623 | This warning is enabled by default. | |
4624 | ||
4625 | @table @gcctabopt | |
4626 | @item -Wplacement-new=1 | |
4627 | This is the default warning level of @option{-Wplacement-new}. At this | |
4628 | level the warning is not issued for some strictly undefined constructs that | |
4629 | GCC allows as extensions for compatibility with legacy code. For example, | |
4630 | the following @code{new} expression is not diagnosed at this level even | |
4631 | though it has undefined behavior according to the C++ standard because | |
4632 | it writes past the end of the one-element array. | |
4633 | @smallexample | |
4634 | struct S @{ int n, a[1]; @}; | |
4635 | S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]); | |
4636 | new (s->a)int [32](); | |
4637 | @end smallexample | |
4638 | ||
4639 | @item -Wplacement-new=2 | |
4640 | At this level, in addition to diagnosing all the same constructs as at level | |
4641 | 1, a diagnostic is also issued for placement new expressions that construct | |
4642 | an object in the last member of structure whose type is an array of a single | |
4643 | element and whose size is less than the size of the object being constructed. | |
4644 | While the previous example would be diagnosed, the following construct makes | |
4645 | use of the flexible member array extension to avoid the warning at level 2. | |
4646 | @smallexample | |
4647 | struct S @{ int n, a[]; @}; | |
4648 | S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]); | |
4649 | new (s->a)int [32](); | |
4650 | @end smallexample | |
4651 | ||
4652 | @end table | |
4653 | ||
d77de738 ML |
4654 | @opindex Wcatch-value |
4655 | @opindex Wno-catch-value | |
ddf6fe37 AA |
4656 | @item -Wcatch-value |
4657 | @itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)} | |
d77de738 ML |
4658 | Warn about catch handlers that do not catch via reference. |
4659 | With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short) | |
4660 | warn about polymorphic class types that are caught by value. | |
4661 | With @option{-Wcatch-value=2} warn about all class types that are caught | |
4662 | by value. With @option{-Wcatch-value=3} warn about all types that are | |
4663 | not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}. | |
4664 | ||
d77de738 ML |
4665 | @opindex Wconditionally-supported |
4666 | @opindex Wno-conditionally-supported | |
ddf6fe37 | 4667 | @item -Wconditionally-supported @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4668 | Warn for conditionally-supported (C++11 [intro.defs]) constructs. |
4669 | ||
d77de738 ML |
4670 | @opindex Wdelete-incomplete |
4671 | @opindex Wno-delete-incomplete | |
ddf6fe37 | 4672 | @item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4673 | Do not warn when deleting a pointer to incomplete type, which may cause |
4674 | undefined behavior at runtime. This warning is enabled by default. | |
4675 | ||
d77de738 ML |
4676 | @opindex Wextra-semi |
4677 | @opindex Wno-extra-semi | |
ddf6fe37 | 4678 | @item -Wextra-semi @r{(C++, Objective-C++ only)} |
d77de738 ML |
4679 | Warn about redundant semicolons after in-class function definitions. |
4680 | ||
d77de738 ML |
4681 | @opindex Winaccessible-base |
4682 | @opindex Wno-inaccessible-base | |
ddf6fe37 | 4683 | @item -Wno-inaccessible-base @r{(C++, Objective-C++ only)} |
d77de738 ML |
4684 | This option controls warnings |
4685 | when a base class is inaccessible in a class derived from it due to | |
4686 | ambiguity. The warning is enabled by default. | |
4687 | Note that the warning for ambiguous virtual | |
4688 | bases is enabled by the @option{-Wextra} option. | |
4689 | @smallexample | |
4690 | @group | |
4691 | struct A @{ int a; @}; | |
4692 | ||
4693 | struct B : A @{ @}; | |
4694 | ||
4695 | struct C : B, A @{ @}; | |
4696 | @end group | |
4697 | @end smallexample | |
4698 | ||
d77de738 ML |
4699 | @opindex Winherited-variadic-ctor |
4700 | @opindex Wno-inherited-variadic-ctor | |
ddf6fe37 | 4701 | @item -Wno-inherited-variadic-ctor |
d77de738 ML |
4702 | Suppress warnings about use of C++11 inheriting constructors when the |
4703 | base class inherited from has a C variadic constructor; the warning is | |
4704 | on by default because the ellipsis is not inherited. | |
4705 | ||
d77de738 ML |
4706 | @opindex Wno-invalid-offsetof |
4707 | @opindex Winvalid-offsetof | |
ddf6fe37 | 4708 | @item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4709 | Suppress warnings from applying the @code{offsetof} macro to a non-POD |
4710 | type. According to the 2014 ISO C++ standard, applying @code{offsetof} | |
4711 | to a non-standard-layout type is undefined. In existing C++ implementations, | |
4712 | however, @code{offsetof} typically gives meaningful results. | |
4713 | This flag is for users who are aware that they are | |
4714 | writing nonportable code and who have deliberately chosen to ignore the | |
4715 | warning about it. | |
4716 | ||
4717 | The restrictions on @code{offsetof} may be relaxed in a future version | |
4718 | of the C++ standard. | |
4719 | ||
d77de738 ML |
4720 | @opindex Wsized-deallocation |
4721 | @opindex Wno-sized-deallocation | |
ddf6fe37 | 4722 | @item -Wsized-deallocation @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4723 | Warn about a definition of an unsized deallocation function |
4724 | @smallexample | |
4725 | void operator delete (void *) noexcept; | |
4726 | void operator delete[] (void *) noexcept; | |
4727 | @end smallexample | |
4728 | without a definition of the corresponding sized deallocation function | |
4729 | @smallexample | |
4730 | void operator delete (void *, std::size_t) noexcept; | |
4731 | void operator delete[] (void *, std::size_t) noexcept; | |
4732 | @end smallexample | |
4733 | or vice versa. Enabled by @option{-Wextra} along with | |
4734 | @option{-fsized-deallocation}. | |
4735 | ||
d77de738 ML |
4736 | @opindex Wno-suggest-final-types |
4737 | @opindex Wsuggest-final-types | |
ddf6fe37 | 4738 | @item -Wsuggest-final-types |
d77de738 ML |
4739 | Warn about types with virtual methods where code quality would be improved |
4740 | if the type were declared with the C++11 @code{final} specifier, | |
4741 | or, if possible, | |
4742 | declared in an anonymous namespace. This allows GCC to more aggressively | |
4743 | devirtualize the polymorphic calls. This warning is more effective with | |
4744 | link-time optimization, | |
4745 | where the information about the class hierarchy graph is | |
4746 | more complete. | |
4747 | ||
d77de738 ML |
4748 | @opindex Wno-suggest-final-methods |
4749 | @opindex Wsuggest-final-methods | |
ddf6fe37 | 4750 | @item -Wsuggest-final-methods |
d77de738 ML |
4751 | Warn about virtual methods where code quality would be improved if the method |
4752 | were declared with the C++11 @code{final} specifier, | |
4753 | or, if possible, its type were | |
4754 | declared in an anonymous namespace or with the @code{final} specifier. | |
4755 | This warning is | |
4756 | more effective with link-time optimization, where the information about the | |
4757 | class hierarchy graph is more complete. It is recommended to first consider | |
4758 | suggestions of @option{-Wsuggest-final-types} and then rebuild with new | |
4759 | annotations. | |
4760 | ||
d77de738 ML |
4761 | @opindex Wsuggest-override |
4762 | @opindex Wno-suggest-override | |
ddf6fe37 | 4763 | @item -Wsuggest-override |
d77de738 ML |
4764 | Warn about overriding virtual functions that are not marked with the |
4765 | @code{override} keyword. | |
4766 | ||
d77de738 ML |
4767 | @opindex Wuse-after-free |
4768 | @opindex Wno-use-after-free | |
ddf6fe37 AA |
4769 | @item -Wuse-after-free |
4770 | @itemx -Wuse-after-free=@var{n} | |
d77de738 ML |
4771 | Warn about uses of pointers to dynamically allocated objects that have |
4772 | been rendered indeterminate by a call to a deallocation function. | |
4773 | The warning is enabled at all optimization levels but may yield different | |
4774 | results with optimization than without. | |
4775 | ||
4776 | @table @gcctabopt | |
4777 | @item -Wuse-after-free=1 | |
4778 | At level 1 the warning attempts to diagnose only unconditional uses | |
4779 | of pointers made indeterminate by a deallocation call or a successful | |
4780 | call to @code{realloc}, regardless of whether or not the call resulted | |
4781 | in an actual reallocatio of memory. This includes double-@code{free} | |
4782 | calls as well as uses in arithmetic and relational expressions. Although | |
4783 | undefined, uses of indeterminate pointers in equality (or inequality) | |
4784 | expressions are not diagnosed at this level. | |
4785 | @item -Wuse-after-free=2 | |
4786 | At level 2, in addition to unconditional uses, the warning also diagnoses | |
4787 | conditional uses of pointers made indeterminate by a deallocation call. | |
4788 | As at level 2, uses in equality (or inequality) expressions are not | |
4789 | diagnosed. For example, the second call to @code{free} in the following | |
4790 | function is diagnosed at this level: | |
4791 | @smallexample | |
4792 | struct A @{ int refcount; void *data; @}; | |
4793 | ||
4794 | void release (struct A *p) | |
4795 | @{ | |
4796 | int refcount = --p->refcount; | |
4797 | free (p); | |
4798 | if (refcount == 0) | |
4799 | free (p->data); // warning: p may be used after free | |
4800 | @} | |
4801 | @end smallexample | |
4802 | @item -Wuse-after-free=3 | |
4803 | At level 3, the warning also diagnoses uses of indeterminate pointers in | |
4804 | equality expressions. All uses of indeterminate pointers are undefined | |
4805 | but equality tests sometimes appear after calls to @code{realloc} as | |
4806 | an attempt to determine whether the call resulted in relocating the object | |
4807 | to a different address. They are diagnosed at a separate level to aid | |
4808 | legacy code gradually transition to safe alternatives. For example, | |
4809 | the equality test in the function below is diagnosed at this level: | |
4810 | @smallexample | |
4811 | void adjust_pointers (int**, int); | |
4812 | ||
4813 | void grow (int **p, int n) | |
4814 | @{ | |
4815 | int **q = (int**)realloc (p, n *= 2); | |
4816 | if (q == p) | |
4817 | return; | |
4818 | adjust_pointers ((int**)q, n); | |
4819 | @} | |
4820 | @end smallexample | |
4821 | To avoid the warning at this level, store offsets into allocated memory | |
4822 | instead of pointers. This approach obviates needing to adjust the stored | |
4823 | pointers after reallocation. | |
4824 | @end table | |
4825 | ||
4826 | @option{-Wuse-after-free=2} is included in @option{-Wall}. | |
4827 | ||
d77de738 ML |
4828 | @opindex Wuseless-cast |
4829 | @opindex Wno-useless-cast | |
68783211 | 4830 | @item -Wuseless-cast @r{(C, Objective-C, C++ and Objective-C++ only)} |
d77de738 ML |
4831 | Warn when an expression is cast to its own type. This warning does not |
4832 | occur when a class object is converted to a non-reference type as that | |
4833 | is a way to create a temporary: | |
4834 | ||
4835 | @smallexample | |
4836 | struct S @{ @}; | |
4837 | void g (S&&); | |
4838 | void f (S&& arg) | |
4839 | @{ | |
4840 | g (S(arg)); // make arg prvalue so that it can bind to S&& | |
4841 | @} | |
4842 | @end smallexample | |
4843 | ||
d77de738 ML |
4844 | @opindex Wconversion-null |
4845 | @opindex Wno-conversion-null | |
ddf6fe37 | 4846 | @item -Wno-conversion-null @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4847 | Do not warn for conversions between @code{NULL} and non-pointer |
4848 | types. @option{-Wconversion-null} is enabled by default. | |
4849 | ||
4850 | @end table | |
4851 | ||
4852 | @node Objective-C and Objective-C++ Dialect Options | |
4853 | @section Options Controlling Objective-C and Objective-C++ Dialects | |
4854 | ||
4855 | @cindex compiler options, Objective-C and Objective-C++ | |
4856 | @cindex Objective-C and Objective-C++ options, command-line | |
4857 | @cindex options, Objective-C and Objective-C++ | |
4858 | (NOTE: This manual does not describe the Objective-C and Objective-C++ | |
4859 | languages themselves. @xref{Standards,,Language Standards | |
4860 | Supported by GCC}, for references.) | |
4861 | ||
4862 | This section describes the command-line options that are only meaningful | |
4863 | for Objective-C and Objective-C++ programs. You can also use most of | |
4864 | the language-independent GNU compiler options. | |
4865 | For example, you might compile a file @file{some_class.m} like this: | |
4866 | ||
4867 | @smallexample | |
4868 | gcc -g -fgnu-runtime -O -c some_class.m | |
4869 | @end smallexample | |
4870 | ||
4871 | @noindent | |
4872 | In this example, @option{-fgnu-runtime} is an option meant only for | |
4873 | Objective-C and Objective-C++ programs; you can use the other options with | |
4874 | any language supported by GCC@. | |
4875 | ||
4876 | Note that since Objective-C is an extension of the C language, Objective-C | |
4877 | compilations may also use options specific to the C front-end (e.g., | |
4878 | @option{-Wtraditional}). Similarly, Objective-C++ compilations may use | |
4879 | C++-specific options (e.g., @option{-Wabi}). | |
4880 | ||
4881 | Here is a list of options that are @emph{only} for compiling Objective-C | |
4882 | and Objective-C++ programs: | |
4883 | ||
4884 | @table @gcctabopt | |
d77de738 | 4885 | @opindex fconstant-string-class |
ddf6fe37 | 4886 | @item -fconstant-string-class=@var{class-name} |
d77de738 ML |
4887 | Use @var{class-name} as the name of the class to instantiate for each |
4888 | literal string specified with the syntax @code{@@"@dots{}"}. The default | |
4889 | class name is @code{NXConstantString} if the GNU runtime is being used, and | |
cdd4b3c0 | 4890 | @code{NSConstantString} if the NeXT runtime is being used (see below). On |
a335cf24 | 4891 | Darwin / macOS platforms, the @option{-fconstant-cfstrings} option, if |
cdd4b3c0 IS |
4892 | also present, overrides the @option{-fconstant-string-class} setting and cause |
4893 | @code{@@"@dots{}"} literals to be laid out as constant CoreFoundation strings. | |
4894 | Note that @option{-fconstant-cfstrings} is an alias for the target-specific | |
4895 | @option{-mconstant-cfstrings} equivalent. | |
d77de738 | 4896 | |
d77de738 | 4897 | @opindex fgnu-runtime |
ddf6fe37 | 4898 | @item -fgnu-runtime |
d77de738 ML |
4899 | Generate object code compatible with the standard GNU Objective-C |
4900 | runtime. This is the default for most types of systems. | |
4901 | ||
d77de738 | 4902 | @opindex fnext-runtime |
ddf6fe37 | 4903 | @item -fnext-runtime |
d77de738 | 4904 | Generate output compatible with the NeXT runtime. This is the default |
a335cf24 | 4905 | for NeXT-based systems, including Darwin / macOS. The macro |
d77de738 ML |
4906 | @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is |
4907 | used. | |
4908 | ||
d77de738 ML |
4909 | @opindex fno-nil-receivers |
4910 | @opindex fnil-receivers | |
ddf6fe37 | 4911 | @item -fno-nil-receivers |
d77de738 ML |
4912 | Assume that all Objective-C message dispatches (@code{[receiver |
4913 | message:arg]}) in this translation unit ensure that the receiver is | |
4914 | not @code{nil}. This allows for more efficient entry points in the | |
4915 | runtime to be used. This option is only available in conjunction with | |
4916 | the NeXT runtime and ABI version 0 or 1. | |
4917 | ||
d77de738 | 4918 | @opindex fobjc-abi-version |
ddf6fe37 | 4919 | @item -fobjc-abi-version=@var{n} |
d77de738 ML |
4920 | Use version @var{n} of the Objective-C ABI for the selected runtime. |
4921 | This option is currently supported only for the NeXT runtime. In that | |
4922 | case, Version 0 is the traditional (32-bit) ABI without support for | |
4923 | properties and other Objective-C 2.0 additions. Version 1 is the | |
4924 | traditional (32-bit) ABI with support for properties and other | |
4925 | Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If | |
4926 | nothing is specified, the default is Version 0 on 32-bit target | |
4927 | machines, and Version 2 on 64-bit target machines. | |
4928 | ||
d77de738 | 4929 | @opindex fobjc-call-cxx-cdtors |
ddf6fe37 | 4930 | @item -fobjc-call-cxx-cdtors |
d77de738 ML |
4931 | For each Objective-C class, check if any of its instance variables is a |
4932 | C++ object with a non-trivial default constructor. If so, synthesize a | |
4933 | special @code{- (id) .cxx_construct} instance method which runs | |
4934 | non-trivial default constructors on any such instance variables, in order, | |
4935 | and then return @code{self}. Similarly, check if any instance variable | |
4936 | is a C++ object with a non-trivial destructor, and if so, synthesize a | |
4937 | special @code{- (void) .cxx_destruct} method which runs | |
4938 | all such default destructors, in reverse order. | |
4939 | ||
4940 | The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct} | |
4941 | methods thusly generated only operate on instance variables | |
4942 | declared in the current Objective-C class, and not those inherited | |
4943 | from superclasses. It is the responsibility of the Objective-C | |
4944 | runtime to invoke all such methods in an object's inheritance | |
4945 | hierarchy. The @code{- (id) .cxx_construct} methods are invoked | |
4946 | by the runtime immediately after a new object instance is allocated; | |
4947 | the @code{- (void) .cxx_destruct} methods are invoked immediately | |
4948 | before the runtime deallocates an object instance. | |
4949 | ||
4950 | As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has | |
4951 | support for invoking the @code{- (id) .cxx_construct} and | |
4952 | @code{- (void) .cxx_destruct} methods. | |
4953 | ||
d77de738 | 4954 | @opindex fobjc-direct-dispatch |
ddf6fe37 | 4955 | @item -fobjc-direct-dispatch |
d77de738 ML |
4956 | Allow fast jumps to the message dispatcher. On Darwin this is |
4957 | accomplished via the comm page. | |
4958 | ||
d77de738 | 4959 | @opindex fobjc-exceptions |
ddf6fe37 | 4960 | @item -fobjc-exceptions |
d77de738 ML |
4961 | Enable syntactic support for structured exception handling in |
4962 | Objective-C, similar to what is offered by C++. This option | |
4963 | is required to use the Objective-C keywords @code{@@try}, | |
4964 | @code{@@throw}, @code{@@catch}, @code{@@finally} and | |
4965 | @code{@@synchronized}. This option is available with both the GNU | |
4966 | runtime and the NeXT runtime (but not available in conjunction with | |
4967 | the NeXT runtime on Mac OS X 10.2 and earlier). | |
4968 | ||
d77de738 | 4969 | @opindex fobjc-gc |
ddf6fe37 | 4970 | @item -fobjc-gc |
d77de738 ML |
4971 | Enable garbage collection (GC) in Objective-C and Objective-C++ |
4972 | programs. This option is only available with the NeXT runtime; the | |
4973 | GNU runtime has a different garbage collection implementation that | |
4974 | does not require special compiler flags. | |
4975 | ||
d77de738 | 4976 | @opindex fobjc-nilcheck |
ddf6fe37 | 4977 | @item -fobjc-nilcheck |
d77de738 ML |
4978 | For the NeXT runtime with version 2 of the ABI, check for a nil |
4979 | receiver in method invocations before doing the actual method call. | |
4980 | This is the default and can be disabled using | |
4981 | @option{-fno-objc-nilcheck}. Class methods and super calls are never | |
4982 | checked for nil in this way no matter what this flag is set to. | |
4983 | Currently this flag does nothing when the GNU runtime, or an older | |
4984 | version of the NeXT runtime ABI, is used. | |
4985 | ||
d77de738 | 4986 | @opindex fobjc-std |
ddf6fe37 | 4987 | @item -fobjc-std=objc1 |
d77de738 ML |
4988 | Conform to the language syntax of Objective-C 1.0, the language |
4989 | recognized by GCC 4.0. This only affects the Objective-C additions to | |
4990 | the C/C++ language; it does not affect conformance to C/C++ standards, | |
4991 | which is controlled by the separate C/C++ dialect option flags. When | |
4992 | this option is used with the Objective-C or Objective-C++ compiler, | |
4993 | any Objective-C syntax that is not recognized by GCC 4.0 is rejected. | |
4994 | This is useful if you need to make sure that your Objective-C code can | |
4995 | be compiled with older versions of GCC@. | |
4996 | ||
d77de738 | 4997 | @opindex freplace-objc-classes |
ddf6fe37 | 4998 | @item -freplace-objc-classes |
d77de738 ML |
4999 | Emit a special marker instructing @command{ld(1)} not to statically link in |
5000 | the resulting object file, and allow @command{dyld(1)} to load it in at | |
5001 | run time instead. This is used in conjunction with the Fix-and-Continue | |
5002 | debugging mode, where the object file in question may be recompiled and | |
5003 | dynamically reloaded in the course of program execution, without the need | |
5004 | to restart the program itself. Currently, Fix-and-Continue functionality | |
5005 | is only available in conjunction with the NeXT runtime on Mac OS X 10.3 | |
5006 | and later. | |
5007 | ||
d77de738 | 5008 | @opindex fzero-link |
ddf6fe37 | 5009 | @item -fzero-link |
d77de738 ML |
5010 | When compiling for the NeXT runtime, the compiler ordinarily replaces calls |
5011 | to @code{objc_getClass("@dots{}")} (when the name of the class is known at | |
5012 | compile time) with static class references that get initialized at load time, | |
5013 | which improves run-time performance. Specifying the @option{-fzero-link} flag | |
5014 | suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")} | |
5015 | to be retained. This is useful in Zero-Link debugging mode, since it allows | |
5016 | for individual class implementations to be modified during program execution. | |
5017 | The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")} | |
5018 | regardless of command-line options. | |
5019 | ||
d77de738 ML |
5020 | @opindex fno-local-ivars |
5021 | @opindex flocal-ivars | |
ddf6fe37 | 5022 | @item -fno-local-ivars |
d77de738 ML |
5023 | By default instance variables in Objective-C can be accessed as if |
5024 | they were local variables from within the methods of the class they're | |
5025 | declared in. This can lead to shadowing between instance variables | |
5026 | and other variables declared either locally inside a class method or | |
5027 | globally with the same name. Specifying the @option{-fno-local-ivars} | |
5028 | flag disables this behavior thus avoiding variable shadowing issues. | |
5029 | ||
d77de738 | 5030 | @opindex fivar-visibility |
ddf6fe37 | 5031 | @item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]} |
d77de738 ML |
5032 | Set the default instance variable visibility to the specified option |
5033 | so that instance variables declared outside the scope of any access | |
5034 | modifier directives default to the specified visibility. | |
5035 | ||
d77de738 | 5036 | @opindex gen-decls |
ddf6fe37 | 5037 | @item -gen-decls |
d77de738 ML |
5038 | Dump interface declarations for all classes seen in the source file to a |
5039 | file named @file{@var{sourcename}.decl}. | |
5040 | ||
d77de738 ML |
5041 | @opindex Wassign-intercept |
5042 | @opindex Wno-assign-intercept | |
ddf6fe37 | 5043 | @item -Wassign-intercept @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5044 | Warn whenever an Objective-C assignment is being intercepted by the |
5045 | garbage collector. | |
5046 | ||
d77de738 ML |
5047 | @opindex Wproperty-assign-default |
5048 | @opindex Wno-property-assign-default | |
ddf6fe37 | 5049 | @item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5050 | Do not warn if a property for an Objective-C object has no assign |
5051 | semantics specified. | |
5052 | ||
d77de738 ML |
5053 | @opindex Wno-protocol |
5054 | @opindex Wprotocol | |
ddf6fe37 | 5055 | @item -Wno-protocol @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5056 | If a class is declared to implement a protocol, a warning is issued for |
5057 | every method in the protocol that is not implemented by the class. The | |
5058 | default behavior is to issue a warning for every method not explicitly | |
5059 | implemented in the class, even if a method implementation is inherited | |
5060 | from the superclass. If you use the @option{-Wno-protocol} option, then | |
5061 | methods inherited from the superclass are considered to be implemented, | |
5062 | and no warning is issued for them. | |
5063 | ||
d77de738 | 5064 | @opindex Wobjc-root-class |
ddf6fe37 | 5065 | @item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5066 | Warn if a class interface lacks a superclass. Most classes will inherit |
5067 | from @code{NSObject} (or @code{Object}) for example. When declaring | |
5068 | classes intended to be root classes, the warning can be suppressed by | |
5069 | marking their interfaces with @code{__attribute__((objc_root_class))}. | |
5070 | ||
d77de738 ML |
5071 | @opindex Wselector |
5072 | @opindex Wno-selector | |
ddf6fe37 | 5073 | @item -Wselector @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5074 | Warn if multiple methods of different types for the same selector are |
5075 | found during compilation. The check is performed on the list of methods | |
5076 | in the final stage of compilation. Additionally, a check is performed | |
5077 | for each selector appearing in a @code{@@selector(@dots{})} | |
5078 | expression, and a corresponding method for that selector has been found | |
5079 | during compilation. Because these checks scan the method table only at | |
5080 | the end of compilation, these warnings are not produced if the final | |
5081 | stage of compilation is not reached, for example because an error is | |
5082 | found during compilation, or because the @option{-fsyntax-only} option is | |
5083 | being used. | |
5084 | ||
d77de738 ML |
5085 | @opindex Wstrict-selector-match |
5086 | @opindex Wno-strict-selector-match | |
ddf6fe37 | 5087 | @item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5088 | Warn if multiple methods with differing argument and/or return types are |
5089 | found for a given selector when attempting to send a message using this | |
5090 | selector to a receiver of type @code{id} or @code{Class}. When this flag | |
5091 | is off (which is the default behavior), the compiler omits such warnings | |
5092 | if any differences found are confined to types that share the same size | |
5093 | and alignment. | |
5094 | ||
d77de738 ML |
5095 | @opindex Wundeclared-selector |
5096 | @opindex Wno-undeclared-selector | |
ddf6fe37 | 5097 | @item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5098 | Warn if a @code{@@selector(@dots{})} expression referring to an |
5099 | undeclared selector is found. A selector is considered undeclared if no | |
5100 | method with that name has been declared before the | |
5101 | @code{@@selector(@dots{})} expression, either explicitly in an | |
5102 | @code{@@interface} or @code{@@protocol} declaration, or implicitly in | |
5103 | an @code{@@implementation} section. This option always performs its | |
5104 | checks as soon as a @code{@@selector(@dots{})} expression is found, | |
5105 | while @option{-Wselector} only performs its checks in the final stage of | |
5106 | compilation. This also enforces the coding style convention | |
5107 | that methods and selectors must be declared before being used. | |
5108 | ||
d77de738 | 5109 | @opindex print-objc-runtime-info |
ddf6fe37 | 5110 | @item -print-objc-runtime-info |
d77de738 ML |
5111 | Generate C header describing the largest structure that is passed by |
5112 | value, if any. | |
5113 | ||
5114 | @end table | |
5115 | ||
5116 | @node Diagnostic Message Formatting Options | |
5117 | @section Options to Control Diagnostic Messages Formatting | |
5118 | @cindex options to control diagnostics formatting | |
5119 | @cindex diagnostic messages | |
5120 | @cindex message formatting | |
5121 | ||
5122 | Traditionally, diagnostic messages have been formatted irrespective of | |
5123 | the output device's aspect (e.g.@: its width, @dots{}). You can use the | |
5124 | options described below | |
5125 | to control the formatting algorithm for diagnostic messages, | |
5126 | e.g.@: how many characters per line, how often source location | |
5127 | information should be reported. Note that some language front ends may not | |
5128 | honor these options. | |
5129 | ||
5130 | @table @gcctabopt | |
d77de738 | 5131 | @opindex fmessage-length |
ddf6fe37 | 5132 | @item -fmessage-length=@var{n} |
d77de738 ML |
5133 | Try to format error messages so that they fit on lines of about |
5134 | @var{n} characters. If @var{n} is zero, then no line-wrapping is | |
5135 | done; each error message appears on a single line. This is the | |
5136 | default for all front ends. | |
5137 | ||
5138 | Note - this option also affects the display of the @samp{#error} and | |
5139 | @samp{#warning} pre-processor directives, and the @samp{deprecated} | |
5140 | function/type/variable attribute. It does not however affect the | |
5141 | @samp{pragma GCC warning} and @samp{pragma GCC error} pragmas. | |
5142 | ||
5143 | @item -fdiagnostics-plain-output | |
5144 | This option requests that diagnostic output look as plain as possible, which | |
5145 | may be useful when running @command{dejagnu} or other utilities that need to | |
5146 | parse diagnostics output and prefer that it remain more stable over time. | |
5147 | @option{-fdiagnostics-plain-output} is currently equivalent to the following | |
5148 | options: | |
43b72ede AA |
5149 | @gccoptlist{-fno-diagnostics-show-caret |
5150 | -fno-diagnostics-show-line-numbers | |
5151 | -fdiagnostics-color=never | |
5152 | -fdiagnostics-urls=never | |
4f01ae37 DM |
5153 | -fdiagnostics-path-format=separate-events |
5154 | -fdiagnostics-text-art-charset=none} | |
d77de738 ML |
5155 | In the future, if GCC changes the default appearance of its diagnostics, the |
5156 | corresponding option to disable the new behavior will be added to this list. | |
5157 | ||
d77de738 | 5158 | @opindex fdiagnostics-show-location |
ddf6fe37 | 5159 | @item -fdiagnostics-show-location=once |
d77de738 ML |
5160 | Only meaningful in line-wrapping mode. Instructs the diagnostic messages |
5161 | reporter to emit source location information @emph{once}; that is, in | |
5162 | case the message is too long to fit on a single physical line and has to | |
5163 | be wrapped, the source location won't be emitted (as prefix) again, | |
5164 | over and over, in subsequent continuation lines. This is the default | |
5165 | behavior. | |
5166 | ||
5167 | @item -fdiagnostics-show-location=every-line | |
5168 | Only meaningful in line-wrapping mode. Instructs the diagnostic | |
5169 | messages reporter to emit the same source location information (as | |
5170 | prefix) for physical lines that result from the process of breaking | |
5171 | a message which is too long to fit on a single line. | |
5172 | ||
ddf6fe37 | 5173 | @opindex fdiagnostics-color |
d77de738 ML |
5174 | @cindex highlight, color |
5175 | @vindex GCC_COLORS @r{environment variable} | |
f33d7a88 AA |
5176 | @item -fdiagnostics-color[=@var{WHEN}] |
5177 | @itemx -fno-diagnostics-color | |
d77de738 ML |
5178 | Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always}, |
5179 | or @samp{auto}. The default depends on how the compiler has been configured, | |
5180 | it can be any of the above @var{WHEN} options or also @samp{never} | |
5181 | if @env{GCC_COLORS} environment variable isn't present in the environment, | |
5182 | and @samp{auto} otherwise. | |
5183 | @samp{auto} makes GCC use color only when the standard error is a terminal, | |
5184 | and when not executing in an emacs shell. | |
5185 | The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are | |
5186 | aliases for @option{-fdiagnostics-color=always} and | |
5187 | @option{-fdiagnostics-color=never}, respectively. | |
5188 | ||
5189 | The colors are defined by the environment variable @env{GCC_COLORS}. | |
5190 | Its value is a colon-separated list of capabilities and Select Graphic | |
5191 | Rendition (SGR) substrings. SGR commands are interpreted by the | |
5192 | terminal or terminal emulator. (See the section in the documentation | |
5193 | of your text terminal for permitted values and their meanings as | |
5194 | character attributes.) These substring values are integers in decimal | |
5195 | representation and can be concatenated with semicolons. | |
5196 | Common values to concatenate include | |
5197 | @samp{1} for bold, | |
5198 | @samp{4} for underline, | |
5199 | @samp{5} for blink, | |
5200 | @samp{7} for inverse, | |
5201 | @samp{39} for default foreground color, | |
5202 | @samp{30} to @samp{37} for foreground colors, | |
5203 | @samp{90} to @samp{97} for 16-color mode foreground colors, | |
5204 | @samp{38;5;0} to @samp{38;5;255} | |
5205 | for 88-color and 256-color modes foreground colors, | |
5206 | @samp{49} for default background color, | |
5207 | @samp{40} to @samp{47} for background colors, | |
5208 | @samp{100} to @samp{107} for 16-color mode background colors, | |
5209 | and @samp{48;5;0} to @samp{48;5;255} | |
5210 | for 88-color and 256-color modes background colors. | |
5211 | ||
5212 | The default @env{GCC_COLORS} is | |
5213 | @smallexample | |
5214 | error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\ | |
5215 | quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\ | |
5216 | diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\ | |
5217 | type-diff=01;32:fnname=01;32:targs=35 | |
5218 | @end smallexample | |
5219 | @noindent | |
5220 | where @samp{01;31} is bold red, @samp{01;35} is bold magenta, | |
5221 | @samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue, | |
5222 | @samp{01} is bold, and @samp{31} is red. | |
5223 | Setting @env{GCC_COLORS} to the empty string disables colors. | |
5224 | Supported capabilities are as follows. | |
5225 | ||
5226 | @table @code | |
d77de738 | 5227 | @vindex error GCC_COLORS @r{capability} |
f33d7a88 | 5228 | @item error= |
d77de738 ML |
5229 | SGR substring for error: markers. |
5230 | ||
d77de738 | 5231 | @vindex warning GCC_COLORS @r{capability} |
f33d7a88 | 5232 | @item warning= |
d77de738 ML |
5233 | SGR substring for warning: markers. |
5234 | ||
d77de738 | 5235 | @vindex note GCC_COLORS @r{capability} |
f33d7a88 | 5236 | @item note= |
d77de738 ML |
5237 | SGR substring for note: markers. |
5238 | ||
d77de738 | 5239 | @vindex path GCC_COLORS @r{capability} |
f33d7a88 | 5240 | @item path= |
d77de738 ML |
5241 | SGR substring for colorizing paths of control-flow events as printed |
5242 | via @option{-fdiagnostics-path-format=}, such as the identifiers of | |
5243 | individual events and lines indicating interprocedural calls and returns. | |
5244 | ||
d77de738 | 5245 | @vindex range1 GCC_COLORS @r{capability} |
f33d7a88 | 5246 | @item range1= |
d77de738 ML |
5247 | SGR substring for first additional range. |
5248 | ||
d77de738 | 5249 | @vindex range2 GCC_COLORS @r{capability} |
f33d7a88 | 5250 | @item range2= |
d77de738 ML |
5251 | SGR substring for second additional range. |
5252 | ||
d77de738 | 5253 | @vindex locus GCC_COLORS @r{capability} |
f33d7a88 | 5254 | @item locus= |
d77de738 ML |
5255 | SGR substring for location information, @samp{file:line} or |
5256 | @samp{file:line:column} etc. | |
5257 | ||
d77de738 | 5258 | @vindex quote GCC_COLORS @r{capability} |
f33d7a88 | 5259 | @item quote= |
d77de738 ML |
5260 | SGR substring for information printed within quotes. |
5261 | ||
d77de738 | 5262 | @vindex fnname GCC_COLORS @r{capability} |
f33d7a88 | 5263 | @item fnname= |
d77de738 ML |
5264 | SGR substring for names of C++ functions. |
5265 | ||
d77de738 | 5266 | @vindex targs GCC_COLORS @r{capability} |
f33d7a88 | 5267 | @item targs= |
d77de738 ML |
5268 | SGR substring for C++ function template parameter bindings. |
5269 | ||
d77de738 | 5270 | @vindex fixit-insert GCC_COLORS @r{capability} |
f33d7a88 | 5271 | @item fixit-insert= |
d77de738 ML |
5272 | SGR substring for fix-it hints suggesting text to |
5273 | be inserted or replaced. | |
5274 | ||
d77de738 | 5275 | @vindex fixit-delete GCC_COLORS @r{capability} |
f33d7a88 | 5276 | @item fixit-delete= |
d77de738 ML |
5277 | SGR substring for fix-it hints suggesting text to |
5278 | be deleted. | |
5279 | ||
d77de738 | 5280 | @vindex diff-filename GCC_COLORS @r{capability} |
f33d7a88 | 5281 | @item diff-filename= |
d77de738 ML |
5282 | SGR substring for filename headers within generated patches. |
5283 | ||
d77de738 | 5284 | @vindex diff-hunk GCC_COLORS @r{capability} |
f33d7a88 | 5285 | @item diff-hunk= |
d77de738 ML |
5286 | SGR substring for the starts of hunks within generated patches. |
5287 | ||
d77de738 | 5288 | @vindex diff-delete GCC_COLORS @r{capability} |
f33d7a88 | 5289 | @item diff-delete= |
d77de738 ML |
5290 | SGR substring for deleted lines within generated patches. |
5291 | ||
d77de738 | 5292 | @vindex diff-insert GCC_COLORS @r{capability} |
f33d7a88 | 5293 | @item diff-insert= |
d77de738 ML |
5294 | SGR substring for inserted lines within generated patches. |
5295 | ||
d77de738 | 5296 | @vindex type-diff GCC_COLORS @r{capability} |
f33d7a88 | 5297 | @item type-diff= |
d77de738 ML |
5298 | SGR substring for highlighting mismatching types within template |
5299 | arguments in the C++ frontend. | |
5300 | @end table | |
5301 | ||
d77de738 ML |
5302 | @opindex fdiagnostics-urls |
5303 | @cindex urls | |
5304 | @vindex GCC_URLS @r{environment variable} | |
5305 | @vindex TERM_URLS @r{environment variable} | |
f33d7a88 | 5306 | @item -fdiagnostics-urls[=@var{WHEN}] |
d77de738 ML |
5307 | Use escape sequences to embed URLs in diagnostics. For example, when |
5308 | @option{-fdiagnostics-show-option} emits text showing the command-line | |
5309 | option controlling a diagnostic, embed a URL for documentation of that | |
5310 | option. | |
5311 | ||
5312 | @var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}. | |
5313 | @samp{auto} makes GCC use URL escape sequences only when the standard error | |
5314 | is a terminal, and when not executing in an emacs shell or any graphical | |
5315 | terminal which is known to be incompatible with this feature, see below. | |
5316 | ||
5317 | The default depends on how the compiler has been configured. | |
5318 | It can be any of the above @var{WHEN} options. | |
5319 | ||
5320 | GCC can also be configured (via the | |
5321 | @option{--with-diagnostics-urls=auto-if-env} configure-time option) | |
5322 | so that the default is affected by environment variables. | |
5323 | Under such a configuration, GCC defaults to using @samp{auto} | |
5324 | if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are | |
5325 | present and non-empty in the environment of the compiler, or @samp{never} | |
5326 | if neither are. | |
5327 | ||
5328 | However, even with @option{-fdiagnostics-urls=always} the behavior is | |
5329 | dependent on those environment variables: | |
5330 | If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in | |
5331 | diagnostics. If set to @samp{st}, URLs use ST escape sequences. | |
5332 | If set to @samp{bel}, the default, URLs use BEL escape sequences. | |
5333 | Any other non-empty value enables the feature. | |
5334 | If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback. | |
5335 | Note: ST is an ANSI escape sequence, string terminator @samp{ESC \}, | |
5336 | BEL is an ASCII character, CTRL-G that usually sounds like a beep. | |
5337 | ||
5338 | At this time GCC tries to detect also a few terminals that are known to | |
5339 | not implement the URL feature, and have bugs or at least had bugs in | |
5340 | some versions that are still in use, where the URL escapes are likely | |
5341 | to misbehave, i.e. print garbage on the screen. | |
5342 | That list is currently xfce4-terminal, certain known to be buggy | |
5343 | gnome-terminal versions, the linux console, and mingw. | |
5344 | This check can be skipped with the @option{-fdiagnostics-urls=always}. | |
5345 | ||
d77de738 ML |
5346 | @opindex fno-diagnostics-show-option |
5347 | @opindex fdiagnostics-show-option | |
ddf6fe37 | 5348 | @item -fno-diagnostics-show-option |
d77de738 ML |
5349 | By default, each diagnostic emitted includes text indicating the |
5350 | command-line option that directly controls the diagnostic (if such an | |
5351 | option is known to the diagnostic machinery). Specifying the | |
5352 | @option{-fno-diagnostics-show-option} flag suppresses that behavior. | |
5353 | ||
d77de738 ML |
5354 | @opindex fno-diagnostics-show-caret |
5355 | @opindex fdiagnostics-show-caret | |
ddf6fe37 | 5356 | @item -fno-diagnostics-show-caret |
d77de738 ML |
5357 | By default, each diagnostic emitted includes the original source line |
5358 | and a caret @samp{^} indicating the column. This option suppresses this | |
5359 | information. The source line is truncated to @var{n} characters, if | |
5360 | the @option{-fmessage-length=n} option is given. When the output is done | |
5361 | to the terminal, the width is limited to the width given by the | |
5362 | @env{COLUMNS} environment variable or, if not set, to the terminal width. | |
5363 | ||
d77de738 ML |
5364 | @opindex fno-diagnostics-show-labels |
5365 | @opindex fdiagnostics-show-labels | |
ddf6fe37 | 5366 | @item -fno-diagnostics-show-labels |
d77de738 ML |
5367 | By default, when printing source code (via @option{-fdiagnostics-show-caret}), |
5368 | diagnostics can label ranges of source code with pertinent information, such | |
5369 | as the types of expressions: | |
5370 | ||
5371 | @smallexample | |
5372 | printf ("foo %s bar", long_i + long_j); | |
5373 | ~^ ~~~~~~~~~~~~~~~ | |
5374 | | | | |
5375 | char * long int | |
5376 | @end smallexample | |
5377 | ||
5378 | This option suppresses the printing of these labels (in the example above, | |
5379 | the vertical bars and the ``char *'' and ``long int'' text). | |
5380 | ||
d77de738 ML |
5381 | @opindex fno-diagnostics-show-cwe |
5382 | @opindex fdiagnostics-show-cwe | |
ddf6fe37 | 5383 | @item -fno-diagnostics-show-cwe |
d77de738 ML |
5384 | Diagnostic messages can optionally have an associated |
5385 | @uref{https://cwe.mitre.org/index.html, CWE} identifier. | |
5386 | GCC itself only provides such metadata for some of the @option{-fanalyzer} | |
5387 | diagnostics. GCC plugins may also provide diagnostics with such metadata. | |
5388 | By default, if this information is present, it will be printed with | |
5389 | the diagnostic. This option suppresses the printing of this metadata. | |
5390 | ||
d77de738 ML |
5391 | @opindex fno-diagnostics-show-rules |
5392 | @opindex fdiagnostics-show-rules | |
ddf6fe37 | 5393 | @item -fno-diagnostics-show-rules |
d77de738 ML |
5394 | Diagnostic messages can optionally have rules associated with them, such |
5395 | as from a coding standard, or a specification. | |
5396 | GCC itself does not do this for any of its diagnostics, but plugins may do so. | |
5397 | By default, if this information is present, it will be printed with | |
5398 | the diagnostic. This option suppresses the printing of this metadata. | |
5399 | ||
d77de738 ML |
5400 | @opindex fno-diagnostics-show-line-numbers |
5401 | @opindex fdiagnostics-show-line-numbers | |
ddf6fe37 | 5402 | @item -fno-diagnostics-show-line-numbers |
d77de738 ML |
5403 | By default, when printing source code (via @option{-fdiagnostics-show-caret}), |
5404 | a left margin is printed, showing line numbers. This option suppresses this | |
5405 | left margin. | |
5406 | ||
d77de738 | 5407 | @opindex fdiagnostics-minimum-margin-width |
ddf6fe37 | 5408 | @item -fdiagnostics-minimum-margin-width=@var{width} |
d77de738 ML |
5409 | This option controls the minimum width of the left margin printed by |
5410 | @option{-fdiagnostics-show-line-numbers}. It defaults to 6. | |
5411 | ||
d77de738 | 5412 | @opindex fdiagnostics-parseable-fixits |
ddf6fe37 | 5413 | @item -fdiagnostics-parseable-fixits |
d77de738 ML |
5414 | Emit fix-it hints in a machine-parseable format, suitable for consumption |
5415 | by IDEs. For each fix-it, a line will be printed after the relevant | |
5416 | diagnostic, starting with the string ``fix-it:''. For example: | |
5417 | ||
5418 | @smallexample | |
5419 | fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all" | |
5420 | @end smallexample | |
5421 | ||
5422 | The location is expressed as a half-open range, expressed as a count of | |
5423 | bytes, starting at byte 1 for the initial column. In the above example, | |
5424 | bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the | |
5425 | given string: | |
5426 | ||
5427 | @smallexample | |
5428 | 00000000011111111112222222222 | |
5429 | 12345678901234567890123456789 | |
5430 | gtk_widget_showall (dlg); | |
5431 | ^^^^^^^^^^^^^^^^^^ | |
5432 | gtk_widget_show_all | |
5433 | @end smallexample | |
5434 | ||
5435 | The filename and replacement string escape backslash as ``\\", tab as ``\t'', | |
5436 | newline as ``\n'', double quotes as ``\"'', non-printable characters as octal | |
5437 | (e.g. vertical tab as ``\013''). | |
5438 | ||
5439 | An empty replacement string indicates that the given range is to be removed. | |
5440 | An empty range (e.g. ``45:3-45:3'') indicates that the string is to | |
5441 | be inserted at the given position. | |
5442 | ||
d77de738 | 5443 | @opindex fdiagnostics-generate-patch |
ddf6fe37 | 5444 | @item -fdiagnostics-generate-patch |
d77de738 ML |
5445 | Print fix-it hints to stderr in unified diff format, after any diagnostics |
5446 | are printed. For example: | |
5447 | ||
5448 | @smallexample | |
5449 | --- test.c | |
5450 | +++ test.c | |
5451 | @@ -42,5 +42,5 @@ | |
5452 | ||
5453 | void show_cb(GtkDialog *dlg) | |
5454 | @{ | |
5455 | - gtk_widget_showall(dlg); | |
5456 | + gtk_widget_show_all(dlg); | |
5457 | @} | |
5458 | ||
5459 | @end smallexample | |
5460 | ||
5461 | The diff may or may not be colorized, following the same rules | |
5462 | as for diagnostics (see @option{-fdiagnostics-color}). | |
5463 | ||
d77de738 | 5464 | @opindex fdiagnostics-show-template-tree |
ddf6fe37 | 5465 | @item -fdiagnostics-show-template-tree |
d77de738 ML |
5466 | |
5467 | In the C++ frontend, when printing diagnostics showing mismatching | |
5468 | template types, such as: | |
5469 | ||
5470 | @smallexample | |
5471 | could not convert 'std::map<int, std::vector<double> >()' | |
5472 | from 'map<[...],vector<double>>' to 'map<[...],vector<float>> | |
5473 | @end smallexample | |
5474 | ||
5475 | the @option{-fdiagnostics-show-template-tree} flag enables printing a | |
5476 | tree-like structure showing the common and differing parts of the types, | |
5477 | such as: | |
5478 | ||
5479 | @smallexample | |
5480 | map< | |
5481 | [...], | |
5482 | vector< | |
5483 | [double != float]>> | |
5484 | @end smallexample | |
5485 | ||
5486 | The parts that differ are highlighted with color (``double'' and | |
5487 | ``float'' in this case). | |
5488 | ||
d77de738 ML |
5489 | @opindex fno-elide-type |
5490 | @opindex felide-type | |
ddf6fe37 | 5491 | @item -fno-elide-type |
d77de738 ML |
5492 | By default when the C++ frontend prints diagnostics showing mismatching |
5493 | template types, common parts of the types are printed as ``[...]'' to | |
5494 | simplify the error message. For example: | |
5495 | ||
5496 | @smallexample | |
5497 | could not convert 'std::map<int, std::vector<double> >()' | |
5498 | from 'map<[...],vector<double>>' to 'map<[...],vector<float>> | |
5499 | @end smallexample | |
5500 | ||
5501 | Specifying the @option{-fno-elide-type} flag suppresses that behavior. | |
5502 | This flag also affects the output of the | |
5503 | @option{-fdiagnostics-show-template-tree} flag. | |
5504 | ||
d77de738 | 5505 | @opindex fdiagnostics-path-format |
ddf6fe37 | 5506 | @item -fdiagnostics-path-format=@var{KIND} |
d77de738 ML |
5507 | Specify how to print paths of control-flow events for diagnostics that |
5508 | have such a path associated with them. | |
5509 | ||
5510 | @var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events}, | |
5511 | the default. | |
5512 | ||
5513 | @samp{none} means to not print diagnostic paths. | |
5514 | ||
5515 | @samp{separate-events} means to print a separate ``note'' diagnostic for | |
5516 | each event within the diagnostic. For example: | |
5517 | ||
5518 | @smallexample | |
5519 | test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter | |
5520 | test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL | |
5521 | test.c:27:3: note: (2) when 'i < count' | |
5522 | test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1 | |
5523 | @end smallexample | |
5524 | ||
5525 | @samp{inline-events} means to print the events ``inline'' within the source | |
5526 | code. This view attempts to consolidate the events into runs of | |
5527 | sufficiently-close events, printing them as labelled ranges within the source. | |
5528 | ||
5529 | For example, the same events as above might be printed as: | |
5530 | ||
5531 | @smallexample | |
5532 | 'test': events 1-3 | |
5533 | | | |
5534 | | 25 | list = PyList_New(0); | |
5535 | | | ^~~~~~~~~~~~~ | |
5536 | | | | | |
5537 | | | (1) when 'PyList_New' fails, returning NULL | |
5538 | | 26 | | |
5539 | | 27 | for (i = 0; i < count; i++) @{ | |
5540 | | | ~~~ | |
5541 | | | | | |
5542 | | | (2) when 'i < count' | |
5543 | | 28 | item = PyLong_FromLong(random()); | |
5544 | | 29 | PyList_Append(list, item); | |
5545 | | | ~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5546 | | | | | |
5547 | | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1 | |
5548 | | | |
5549 | @end smallexample | |
5550 | ||
5551 | Interprocedural control flow is shown by grouping the events by stack frame, | |
5552 | and using indentation to show how stack frames are nested, pushed, and popped. | |
5553 | ||
5554 | For example: | |
5555 | ||
5556 | @smallexample | |
5557 | 'test': events 1-2 | |
5558 | | | |
5559 | | 133 | @{ | |
5560 | | | ^ | |
5561 | | | | | |
5562 | | | (1) entering 'test' | |
5563 | | 134 | boxed_int *obj = make_boxed_int (i); | |
5564 | | | ~~~~~~~~~~~~~~~~~~ | |
5565 | | | | | |
5566 | | | (2) calling 'make_boxed_int' | |
5567 | | | |
5568 | +--> 'make_boxed_int': events 3-4 | |
5569 | | | |
5570 | | 120 | @{ | |
5571 | | | ^ | |
5572 | | | | | |
5573 | | | (3) entering 'make_boxed_int' | |
5574 | | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int)); | |
5575 | | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5576 | | | | | |
5577 | | | (4) calling 'wrapped_malloc' | |
5578 | | | |
5579 | +--> 'wrapped_malloc': events 5-6 | |
5580 | | | |
5581 | | 7 | @{ | |
5582 | | | ^ | |
5583 | | | | | |
5584 | | | (5) entering 'wrapped_malloc' | |
5585 | | 8 | return malloc (size); | |
5586 | | | ~~~~~~~~~~~~~ | |
5587 | | | | | |
5588 | | | (6) calling 'malloc' | |
5589 | | | |
5590 | <-------------+ | |
5591 | | | |
5592 | 'test': event 7 | |
5593 | | | |
5594 | | 138 | free_boxed_int (obj); | |
5595 | | | ^~~~~~~~~~~~~~~~~~~~ | |
5596 | | | | | |
5597 | | | (7) calling 'free_boxed_int' | |
5598 | | | |
5599 | (etc) | |
5600 | @end smallexample | |
5601 | ||
d77de738 | 5602 | @opindex fdiagnostics-show-path-depths |
ddf6fe37 | 5603 | @item -fdiagnostics-show-path-depths |
d77de738 ML |
5604 | This option provides additional information when printing control-flow paths |
5605 | associated with a diagnostic. | |
5606 | ||
5607 | If this is option is provided then the stack depth will be printed for | |
5608 | each run of events within @option{-fdiagnostics-path-format=inline-events}. | |
5609 | If provided with @option{-fdiagnostics-path-format=separate-events}, then | |
5610 | the stack depth and function declaration will be appended when printing | |
5611 | each event. | |
5612 | ||
5613 | This is intended for use by GCC developers and plugin developers when | |
5614 | debugging diagnostics that report interprocedural control flow. | |
5615 | ||
d77de738 ML |
5616 | @opindex fno-show-column |
5617 | @opindex fshow-column | |
ddf6fe37 | 5618 | @item -fno-show-column |
d77de738 ML |
5619 | Do not print column numbers in diagnostics. This may be necessary if |
5620 | diagnostics are being scanned by a program that does not understand the | |
5621 | column numbers, such as @command{dejagnu}. | |
5622 | ||
d77de738 | 5623 | @opindex fdiagnostics-column-unit |
ddf6fe37 | 5624 | @item -fdiagnostics-column-unit=@var{UNIT} |
d77de738 ML |
5625 | Select the units for the column number. This affects traditional diagnostics |
5626 | (in the absence of @option{-fno-show-column}), as well as JSON format | |
5627 | diagnostics if requested. | |
5628 | ||
5629 | The default @var{UNIT}, @samp{display}, considers the number of display | |
5630 | columns occupied by each character. This may be larger than the number | |
5631 | of bytes required to encode the character, in the case of tab | |
5632 | characters, or it may be smaller, in the case of multibyte characters. | |
5633 | For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one | |
5634 | display column, and its UTF-8 encoding requires two bytes; the character | |
5635 | ``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and | |
5636 | its UTF-8 encoding requires four bytes. | |
5637 | ||
5638 | Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte | |
5639 | count in all cases, as was traditionally output by GCC prior to version 11.1.0. | |
5640 | ||
d77de738 | 5641 | @opindex fdiagnostics-column-origin |
ddf6fe37 | 5642 | @item -fdiagnostics-column-origin=@var{ORIGIN} |
d77de738 ML |
5643 | Select the origin for column numbers, i.e. the column number assigned to the |
5644 | first column. The default value of 1 corresponds to traditional GCC | |
5645 | behavior and to the GNU style guide. Some utilities may perform better with an | |
5646 | origin of 0; any non-negative value may be specified. | |
5647 | ||
d77de738 | 5648 | @opindex fdiagnostics-escape-format |
ddf6fe37 | 5649 | @item -fdiagnostics-escape-format=@var{FORMAT} |
d77de738 ML |
5650 | When GCC prints pertinent source lines for a diagnostic it normally attempts |
5651 | to print the source bytes directly. However, some diagnostics relate to encoding | |
5652 | issues in the source file, such as malformed UTF-8, or issues with Unicode | |
5653 | normalization. These diagnostics are flagged so that GCC will escape bytes | |
5654 | that are not printable ASCII when printing their pertinent source lines. | |
5655 | ||
5656 | This option controls how such bytes should be escaped. | |
5657 | ||
5658 | The default @var{FORMAT}, @samp{unicode} displays Unicode characters that | |
5659 | are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not | |
5660 | correspond to a Unicode character validly-encoded in UTF-8-encoded will be | |
5661 | displayed as hexadecimal in the form @samp{<XX>}. | |
5662 | ||
5663 | For example, a source line containing the string @samp{before} followed by the | |
5664 | Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding | |
5665 | 0xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by | |
5666 | the string @samp{after} will be printed for such a diagnostic as: | |
5667 | ||
5668 | @smallexample | |
5669 | before<U+03C0><BF>after | |
5670 | @end smallexample | |
5671 | ||
5672 | Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes | |
5673 | in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII | |
5674 | Unicode characters. For the example above, the following will be printed: | |
5675 | ||
5676 | @smallexample | |
5677 | before<CF><80><BF>after | |
5678 | @end smallexample | |
5679 | ||
4f01ae37 DM |
5680 | @opindex fdiagnostics-text-art-charset |
5681 | @item -fdiagnostics-text-art-charset=@var{CHARSET} | |
5682 | Some diagnostics can contain ``text art'' diagrams: visualizations created | |
5683 | from text, intended to be viewed in a monospaced font. | |
5684 | ||
5685 | This option selects which characters should be used for printing such | |
5686 | diagrams, if any. @var{CHARSET} is @samp{none}, @samp{ascii}, @samp{unicode}, | |
5687 | or @samp{emoji}. | |
5688 | ||
5689 | The @samp{none} value suppresses the printing of such diagrams. | |
5690 | The @samp{ascii} value will ensure that such diagrams are pure ASCII | |
5691 | (``ASCII art''). The @samp{unicode} value will allow for conservative use of | |
5692 | unicode drawing characters (such as box-drawing characters). The @samp{emoji} | |
5693 | value further adds the possibility of emoji in the output (such as emitting | |
5694 | U+26A0 WARNING SIGN followed by U+FE0F VARIATION SELECTOR-16 to select the | |
5695 | emoji variant of the character). | |
5696 | ||
04013e44 DM |
5697 | The default is @samp{emoji}, except when the environment variable @env{LANG} |
5698 | is set to @samp{C}, in which case the default is @samp{ascii}. | |
4f01ae37 | 5699 | |
d77de738 | 5700 | @opindex fdiagnostics-format |
ddf6fe37 | 5701 | @item -fdiagnostics-format=@var{FORMAT} |
d77de738 ML |
5702 | Select a different format for printing diagnostics. |
5703 | @var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file}, | |
5704 | @samp{json}, @samp{json-stderr}, or @samp{json-file}. | |
5705 | ||
5706 | The default is @samp{text}. | |
5707 | ||
5708 | The @samp{sarif-stderr} and @samp{sarif-file} formats both emit | |
5709 | diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file | |
5710 | named @file{@var{source}.sarif}, respectively. | |
5711 | ||
5712 | The @samp{json} format is a synonym for @samp{json-stderr}. | |
5713 | The @samp{json-stderr} and @samp{json-file} formats are identical, apart from | |
5714 | where the JSON is emitted to - with the former, the JSON is emitted to stderr, | |
5715 | whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}. | |
5716 | ||
5717 | The emitted JSON consists of a top-level JSON array containing JSON objects | |
5718 | representing the diagnostics. The JSON is emitted as one line, without | |
5719 | formatting; the examples below have been formatted for clarity. | |
5720 | ||
5721 | Diagnostics can have child diagnostics. For example, this error and note: | |
5722 | ||
5723 | @smallexample | |
5724 | misleading-indentation.c:15:3: warning: this 'if' clause does not | |
5725 | guard... [-Wmisleading-indentation] | |
5726 | 15 | if (flag) | |
5727 | | ^~ | |
5728 | misleading-indentation.c:17:5: note: ...this statement, but the latter | |
5729 | is misleadingly indented as if it were guarded by the 'if' | |
5730 | 17 | y = 2; | |
5731 | | ^ | |
5732 | @end smallexample | |
5733 | ||
5734 | @noindent | |
5735 | might be printed in JSON form (after formatting) like this: | |
5736 | ||
5737 | @smallexample | |
5738 | [ | |
5739 | @{ | |
5740 | "kind": "warning", | |
5741 | "locations": [ | |
5742 | @{ | |
5743 | "caret": @{ | |
5744 | "display-column": 3, | |
5745 | "byte-column": 3, | |
5746 | "column": 3, | |
5747 | "file": "misleading-indentation.c", | |
5748 | "line": 15 | |
5749 | @}, | |
5750 | "finish": @{ | |
5751 | "display-column": 4, | |
5752 | "byte-column": 4, | |
5753 | "column": 4, | |
5754 | "file": "misleading-indentation.c", | |
5755 | "line": 15 | |
5756 | @} | |
5757 | @} | |
5758 | ], | |
5759 | "message": "this \u2018if\u2019 clause does not guard...", | |
5760 | "option": "-Wmisleading-indentation", | |
5761 | "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation", | |
5762 | "children": [ | |
5763 | @{ | |
5764 | "kind": "note", | |
5765 | "locations": [ | |
5766 | @{ | |
5767 | "caret": @{ | |
5768 | "display-column": 5, | |
5769 | "byte-column": 5, | |
5770 | "column": 5, | |
5771 | "file": "misleading-indentation.c", | |
5772 | "line": 17 | |
5773 | @} | |
5774 | @} | |
5775 | ], | |
5776 | "escape-source": false, | |
5777 | "message": "...this statement, but the latter is @dots{}" | |
5778 | @} | |
5779 | ] | |
5780 | "escape-source": false, | |
5781 | "column-origin": 1, | |
5782 | @} | |
5783 | ] | |
5784 | @end smallexample | |
5785 | ||
5786 | @noindent | |
5787 | where the @code{note} is a child of the @code{warning}. | |
5788 | ||
5789 | A diagnostic has a @code{kind}. If this is @code{warning}, then there is | |
5790 | an @code{option} key describing the command-line option controlling the | |
5791 | warning. | |
5792 | ||
5793 | A diagnostic can contain zero or more locations. Each location has an | |
5794 | optional @code{label} string and up to three positions within it: a | |
5795 | @code{caret} position and optional @code{start} and @code{finish} positions. | |
5796 | A position is described by a @code{file} name, a @code{line} number, and | |
5797 | three numbers indicating a column position: | |
5798 | @itemize @bullet | |
5799 | ||
5800 | @item | |
5801 | @code{display-column} counts display columns, accounting for tabs and | |
5802 | multibyte characters. | |
5803 | ||
5804 | @item | |
5805 | @code{byte-column} counts raw bytes. | |
5806 | ||
5807 | @item | |
5808 | @code{column} is equal to one of | |
5809 | the previous two, as dictated by the @option{-fdiagnostics-column-unit} | |
5810 | option. | |
5811 | ||
5812 | @end itemize | |
5813 | All three columns are relative to the origin specified by | |
5814 | @option{-fdiagnostics-column-origin}, which is typically equal to 1 but may | |
5815 | be set, for instance, to 0 for compatibility with other utilities that | |
5816 | number columns from 0. The column origin is recorded in the JSON output in | |
5817 | the @code{column-origin} tag. In the remaining examples below, the extra | |
5818 | column number outputs have been omitted for brevity. | |
5819 | ||
5820 | For example, this error: | |
5821 | ||
5822 | @smallexample | |
5823 | bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka | |
5824 | 'struct s'@} and 'T' @{aka 'struct t'@}) | |
5825 | 64 | return callee_4a () + callee_4b (); | |
5826 | | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ | |
5827 | | | | | |
5828 | | | T @{aka struct t@} | |
5829 | | S @{aka struct s@} | |
5830 | @end smallexample | |
5831 | ||
5832 | @noindent | |
5833 | has three locations. Its primary location is at the ``+'' token at column | |
5834 | 23. It has two secondary locations, describing the left and right-hand sides | |
5835 | of the expression, which have labels. It might be printed in JSON form as: | |
5836 | ||
5837 | @smallexample | |
5838 | @{ | |
5839 | "children": [], | |
5840 | "kind": "error", | |
5841 | "locations": [ | |
5842 | @{ | |
5843 | "caret": @{ | |
5844 | "column": 23, "file": "bad-binary-ops.c", "line": 64 | |
5845 | @} | |
5846 | @}, | |
5847 | @{ | |
5848 | "caret": @{ | |
5849 | "column": 10, "file": "bad-binary-ops.c", "line": 64 | |
5850 | @}, | |
5851 | "finish": @{ | |
5852 | "column": 21, "file": "bad-binary-ops.c", "line": 64 | |
5853 | @}, | |
5854 | "label": "S @{aka struct s@}" | |
5855 | @}, | |
5856 | @{ | |
5857 | "caret": @{ | |
5858 | "column": 25, "file": "bad-binary-ops.c", "line": 64 | |
5859 | @}, | |
5860 | "finish": @{ | |
5861 | "column": 36, "file": "bad-binary-ops.c", "line": 64 | |
5862 | @}, | |
5863 | "label": "T @{aka struct t@}" | |
5864 | @} | |
5865 | ], | |
5866 | "escape-source": false, | |
5867 | "message": "invalid operands to binary + @dots{}" | |
5868 | @} | |
5869 | @end smallexample | |
5870 | ||
5871 | If a diagnostic contains fix-it hints, it has a @code{fixits} array, | |
5872 | consisting of half-open intervals, similar to the output of | |
5873 | @option{-fdiagnostics-parseable-fixits}. For example, this diagnostic | |
5874 | with a replacement fix-it hint: | |
5875 | ||
5876 | @smallexample | |
5877 | demo.c:8:15: error: 'struct s' has no member named 'colour'; did you | |
5878 | mean 'color'? | |
5879 | 8 | return ptr->colour; | |
5880 | | ^~~~~~ | |
5881 | | color | |
5882 | @end smallexample | |
5883 | ||
5884 | @noindent | |
5885 | might be printed in JSON form as: | |
5886 | ||
5887 | @smallexample | |
5888 | @{ | |
5889 | "children": [], | |
5890 | "fixits": [ | |
5891 | @{ | |
5892 | "next": @{ | |
5893 | "column": 21, | |
5894 | "file": "demo.c", | |
5895 | "line": 8 | |
5896 | @}, | |
5897 | "start": @{ | |
5898 | "column": 15, | |
5899 | "file": "demo.c", | |
5900 | "line": 8 | |
5901 | @}, | |
5902 | "string": "color" | |
5903 | @} | |
5904 | ], | |
5905 | "kind": "error", | |
5906 | "locations": [ | |
5907 | @{ | |
5908 | "caret": @{ | |
5909 | "column": 15, | |
5910 | "file": "demo.c", | |
5911 | "line": 8 | |
5912 | @}, | |
5913 | "finish": @{ | |
5914 | "column": 20, | |
5915 | "file": "demo.c", | |
5916 | "line": 8 | |
5917 | @} | |
5918 | @} | |
5919 | ], | |
5920 | "escape-source": false, | |
5921 | "message": "\u2018struct s\u2019 has no member named @dots{}" | |
5922 | @} | |
5923 | @end smallexample | |
5924 | ||
5925 | @noindent | |
5926 | where the fix-it hint suggests replacing the text from @code{start} up | |
5927 | to but not including @code{next} with @code{string}'s value. Deletions | |
5928 | are expressed via an empty value for @code{string}, insertions by | |
5929 | having @code{start} equal @code{next}. | |
5930 | ||
5931 | If the diagnostic has a path of control-flow events associated with it, | |
5932 | it has a @code{path} array of objects representing the events. Each | |
5933 | event object has a @code{description} string, a @code{location} object, | |
5934 | along with a @code{function} string and a @code{depth} number for | |
5935 | representing interprocedural paths. The @code{function} represents the | |
5936 | current function at that event, and the @code{depth} represents the | |
5937 | stack depth relative to some baseline: the higher, the more frames are | |
5938 | within the stack. | |
5939 | ||
5940 | For example, the intraprocedural example shown for | |
5941 | @option{-fdiagnostics-path-format=} might have this JSON for its path: | |
5942 | ||
5943 | @smallexample | |
5944 | "path": [ | |
5945 | @{ | |
5946 | "depth": 0, | |
5947 | "description": "when 'PyList_New' fails, returning NULL", | |
5948 | "function": "test", | |
5949 | "location": @{ | |
5950 | "column": 10, | |
5951 | "file": "test.c", | |
5952 | "line": 25 | |
5953 | @} | |
5954 | @}, | |
5955 | @{ | |
5956 | "depth": 0, | |
5957 | "description": "when 'i < count'", | |
5958 | "function": "test", | |
5959 | "location": @{ | |
5960 | "column": 3, | |
5961 | "file": "test.c", | |
5962 | "line": 27 | |
5963 | @} | |
5964 | @}, | |
5965 | @{ | |
5966 | "depth": 0, | |
5967 | "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1", | |
5968 | "function": "test", | |
5969 | "location": @{ | |
5970 | "column": 5, | |
5971 | "file": "test.c", | |
5972 | "line": 29 | |
5973 | @} | |
5974 | @} | |
5975 | ] | |
5976 | @end smallexample | |
5977 | ||
5978 | Diagnostics have a boolean attribute @code{escape-source}, hinting whether | |
5979 | non-ASCII bytes should be escaped when printing the pertinent lines of | |
5980 | source code (@code{true} for diagnostics involving source encoding issues). | |
5981 | ||
5982 | @end table | |
5983 | ||
5984 | @node Warning Options | |
5985 | @section Options to Request or Suppress Warnings | |
5986 | @cindex options to control warnings | |
5987 | @cindex warning messages | |
5988 | @cindex messages, warning | |
5989 | @cindex suppressing warnings | |
5990 | ||
5991 | Warnings are diagnostic messages that report constructions that | |
5992 | are not inherently erroneous but that are risky or suggest there | |
5993 | may have been an error. | |
5994 | ||
5995 | The following language-independent options do not enable specific | |
5996 | warnings but control the kinds of diagnostics produced by GCC@. | |
5997 | ||
5998 | @table @gcctabopt | |
5999 | @cindex syntax checking | |
d77de738 | 6000 | @opindex fsyntax-only |
ddf6fe37 | 6001 | @item -fsyntax-only |
d77de738 ML |
6002 | Check the code for syntax errors, but don't do anything beyond that. |
6003 | ||
d77de738 | 6004 | @opindex fmax-errors |
ddf6fe37 | 6005 | @item -fmax-errors=@var{n} |
d77de738 ML |
6006 | Limits the maximum number of error messages to @var{n}, at which point |
6007 | GCC bails out rather than attempting to continue processing the source | |
6008 | code. If @var{n} is 0 (the default), there is no limit on the number | |
6009 | of error messages produced. If @option{-Wfatal-errors} is also | |
6010 | specified, then @option{-Wfatal-errors} takes precedence over this | |
6011 | option. | |
6012 | ||
d77de738 | 6013 | @opindex w |
ddf6fe37 | 6014 | @item -w |
d77de738 ML |
6015 | Inhibit all warning messages. |
6016 | ||
d77de738 ML |
6017 | @opindex Werror |
6018 | @opindex Wno-error | |
ddf6fe37 | 6019 | @item -Werror |
d77de738 ML |
6020 | Make all warnings into errors. |
6021 | ||
d77de738 ML |
6022 | @opindex Werror= |
6023 | @opindex Wno-error= | |
ddf6fe37 | 6024 | @item -Werror= |
d77de738 ML |
6025 | Make the specified warning into an error. The specifier for a warning |
6026 | is appended; for example @option{-Werror=switch} turns the warnings | |
6027 | controlled by @option{-Wswitch} into errors. This switch takes a | |
6028 | negative form, to be used to negate @option{-Werror} for specific | |
6029 | warnings; for example @option{-Wno-error=switch} makes | |
6030 | @option{-Wswitch} warnings not be errors, even when @option{-Werror} | |
6031 | is in effect. | |
6032 | ||
6033 | The warning message for each controllable warning includes the | |
6034 | option that controls the warning. That option can then be used with | |
6035 | @option{-Werror=} and @option{-Wno-error=} as described above. | |
6036 | (Printing of the option in the warning message can be disabled using the | |
6037 | @option{-fno-diagnostics-show-option} flag.) | |
6038 | ||
6039 | Note that specifying @option{-Werror=}@var{foo} automatically implies | |
6040 | @option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not | |
6041 | imply anything. | |
6042 | ||
d77de738 ML |
6043 | @opindex Wfatal-errors |
6044 | @opindex Wno-fatal-errors | |
ddf6fe37 | 6045 | @item -Wfatal-errors |
d77de738 ML |
6046 | This option causes the compiler to abort compilation on the first error |
6047 | occurred rather than trying to keep going and printing further error | |
6048 | messages. | |
6049 | ||
6050 | @end table | |
6051 | ||
6052 | You can request many specific warnings with options beginning with | |
6053 | @samp{-W}, for example @option{-Wimplicit} to request warnings on | |
6054 | implicit declarations. Each of these specific warning options also | |
6055 | has a negative form beginning @samp{-Wno-} to turn off warnings; for | |
6056 | example, @option{-Wno-implicit}. This manual lists only one of the | |
6057 | two forms, whichever is not the default. For further | |
6058 | language-specific options also refer to @ref{C++ Dialect Options} and | |
6059 | @ref{Objective-C and Objective-C++ Dialect Options}. | |
6060 | Additional warnings can be produced by enabling the static analyzer; | |
6061 | @xref{Static Analyzer Options}. | |
6062 | ||
6063 | Some options, such as @option{-Wall} and @option{-Wextra}, turn on other | |
6064 | options, such as @option{-Wunused}, which may turn on further options, | |
6065 | such as @option{-Wunused-value}. The combined effect of positive and | |
6066 | negative forms is that more specific options have priority over less | |
6067 | specific ones, independently of their position in the command-line. For | |
6068 | options of the same specificity, the last one takes effect. Options | |
6069 | enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect | |
6070 | as if they appeared at the end of the command-line. | |
6071 | ||
6072 | When an unrecognized warning option is requested (e.g., | |
6073 | @option{-Wunknown-warning}), GCC emits a diagnostic stating | |
6074 | that the option is not recognized. However, if the @option{-Wno-} form | |
6075 | is used, the behavior is slightly different: no diagnostic is | |
6076 | produced for @option{-Wno-unknown-warning} unless other diagnostics | |
6077 | are being produced. This allows the use of new @option{-Wno-} options | |
6078 | with old compilers, but if something goes wrong, the compiler | |
6079 | warns that an unrecognized option is present. | |
6080 | ||
6081 | The effectiveness of some warnings depends on optimizations also being | |
6082 | enabled. For example @option{-Wsuggest-final-types} is more effective | |
6083 | with link-time optimization and some instances of other warnings may | |
6084 | not be issued at all unless optimization is enabled. While optimization | |
6085 | in general improves the efficacy of control and data flow sensitive | |
6086 | warnings, in some cases it may also cause false positives. | |
6087 | ||
6088 | @table @gcctabopt | |
d77de738 ML |
6089 | @opindex pedantic |
6090 | @opindex Wpedantic | |
6091 | @opindex Wno-pedantic | |
ddf6fe37 AA |
6092 | @item -Wpedantic |
6093 | @itemx -pedantic | |
d77de738 | 6094 | Issue all the warnings demanded by strict ISO C and ISO C++; |
5fccebdb JM |
6095 | diagnose all programs that use forbidden extensions, and some other |
6096 | programs that do not follow ISO C and ISO C++. This follows the version | |
6097 | of the ISO C or C++ standard specified by any @option{-std} option used. | |
d77de738 ML |
6098 | |
6099 | Valid ISO C and ISO C++ programs should compile properly with or without | |
6100 | this option (though a rare few require @option{-ansi} or a | |
5fccebdb | 6101 | @option{-std} option specifying the version of the standard)@. However, |
d77de738 | 6102 | without this option, certain GNU extensions and traditional C and C++ |
5fccebdb JM |
6103 | features are supported as well. With this option, they are diagnosed |
6104 | (or rejected with @option{-pedantic-errors}). | |
d77de738 ML |
6105 | |
6106 | @option{-Wpedantic} does not cause warning messages for use of the | |
6107 | alternate keywords whose names begin and end with @samp{__}. This alternate | |
6108 | format can also be used to disable warnings for non-ISO @samp{__intN} types, | |
6109 | i.e. @samp{__intN__}. | |
6110 | Pedantic warnings are also disabled in the expression that follows | |
6111 | @code{__extension__}. However, only system header files should use | |
6112 | these escape routes; application programs should avoid them. | |
6113 | @xref{Alternate Keywords}. | |
6114 | ||
5fccebdb JM |
6115 | Some warnings about non-conforming programs are controlled by options |
6116 | other than @option{-Wpedantic}; in many cases they are implied by | |
6117 | @option{-Wpedantic} but can be disabled separately by their specific | |
6118 | option, e.g. @option{-Wpedantic -Wno-pointer-sign}. | |
d77de738 ML |
6119 | |
6120 | Where the standard specified with @option{-std} represents a GNU | |
6121 | extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a | |
6122 | corresponding @dfn{base standard}, the version of ISO C on which the GNU | |
6123 | extended dialect is based. Warnings from @option{-Wpedantic} are given | |
6124 | where they are required by the base standard. (It does not make sense | |
6125 | for such warnings to be given only for features not in the specified GNU | |
6126 | C dialect, since by definition the GNU dialects of C include all | |
6127 | features the compiler supports with the given option, and there would be | |
6128 | nothing to warn about.) | |
6129 | ||
d77de738 | 6130 | @opindex pedantic-errors |
ddf6fe37 | 6131 | @item -pedantic-errors |
d77de738 ML |
6132 | Give an error whenever the @dfn{base standard} (see @option{-Wpedantic}) |
6133 | requires a diagnostic, in some cases where there is undefined behavior | |
6134 | at compile-time and in some other cases that do not prevent compilation | |
6135 | of programs that are valid according to the standard. This is not | |
5fccebdb JM |
6136 | equivalent to @option{-Werror=pedantic}: the latter option is unlikely to be |
6137 | useful, as it only makes errors of the diagnostics that are controlled by | |
6138 | @option{-Wpedantic}, whereas this option also affects required diagnostics that | |
6139 | are always enabled or controlled by options other than @option{-Wpedantic}. | |
6140 | ||
6141 | If you want the required diagnostics that are warnings by default to | |
6142 | be errors instead, but don't also want to enable the @option{-Wpedantic} | |
6143 | diagnostics, you can specify @option{-pedantic-errors -Wno-pedantic} | |
6144 | (or @option{-pedantic-errors -Wno-error=pedantic} to enable them but | |
6145 | only as warnings). | |
6146 | ||
6147 | Some required diagnostics are errors by default, but can be reduced to | |
6148 | warnings using @option{-fpermissive} or their specific warning option, | |
6149 | e.g. @option{-Wno-error=narrowing}. | |
6150 | ||
6151 | Some diagnostics for non-ISO practices are controlled by specific | |
6152 | warning options other than @option{-Wpedantic}, but are also made | |
6153 | errors by @option{-pedantic-errors}. For instance: | |
6154 | ||
6155 | @gccoptlist{ | |
6156 | -Wattributes @r{(for standard attributes)} | |
6157 | -Wchanges-meaning @r{(C++)} | |
6158 | -Wcomma-subscript @r{(C++23 or later)} | |
6159 | -Wdeclaration-after-statement @r{(C90 or earlier)} | |
b106f11d | 6160 | -Welaborated-enum-base @r{(C++11 or later)} |
5fccebdb JM |
6161 | -Wimplicit-int @r{(C99 or later)} |
6162 | -Wimplicit-function-declaration @r{(C99 or later)} | |
6163 | -Wincompatible-pointer-types | |
6164 | -Wint-conversion | |
6165 | -Wlong-long @r{(C90 or earlier)} | |
6166 | -Wmain | |
6167 | -Wnarrowing @r{(C++11 or later)} | |
6168 | -Wpointer-arith | |
6169 | -Wpointer-sign | |
6170 | -Wincompatible-pointer-types | |
6171 | -Wregister @r{(C++17 or later)} | |
6172 | -Wvla @r{(C90 or earlier)} | |
6173 | -Wwrite-strings @r{(C++11 or later)} | |
6174 | } | |
d77de738 | 6175 | |
ef10cb86 JM |
6176 | @opindex fpermissive |
6177 | @item -fpermissive | |
6178 | Downgrade some required diagnostics about nonconformant code from | |
6179 | errors to warnings. Thus, using @option{-fpermissive} allows some | |
6180 | nonconforming code to compile. Some C++ diagnostics are controlled | |
da4315f5 FW |
6181 | only by this flag, but it also downgrades some C and C++ diagnostics |
6182 | that have their own flag: | |
ef10cb86 JM |
6183 | |
6184 | @gccoptlist{ | |
6185 | -Wnarrowing @r{(C++)} | |
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 ML |
6854 | This option controls warnings when a declaration does not specify a type. |
6855 | This warning is enabled by default in C99 and later dialects of C, | |
6856 | and also by @option{-Wall}. | |
6857 | ||
5fccebdb JM |
6858 | This warning is upgraded to an error by @option{-pedantic-errors}. |
6859 | ||
d77de738 ML |
6860 | @opindex Wimplicit-function-declaration |
6861 | @opindex Wno-implicit-function-declaration | |
ddf6fe37 | 6862 | @item -Wno-implicit-function-declaration @r{(C and Objective-C only)} |
d77de738 ML |
6863 | This option controls warnings when a function is used before being declared. |
6864 | This warning is enabled by default in C99 and later dialects of C, | |
6865 | and also by @option{-Wall}. | |
5fccebdb JM |
6866 | |
6867 | This warning is upgraded to an error by @option{-pedantic-errors}. | |
d77de738 | 6868 | |
d77de738 ML |
6869 | @opindex Wimplicit |
6870 | @opindex Wno-implicit | |
ddf6fe37 | 6871 | @item -Wimplicit @r{(C and Objective-C only)} |
d77de738 ML |
6872 | Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}. |
6873 | This warning is enabled by @option{-Wall}. | |
6874 | ||
d77de738 ML |
6875 | @opindex Wimplicit-fallthrough |
6876 | @opindex Wno-implicit-fallthrough | |
ddf6fe37 | 6877 | @item -Wimplicit-fallthrough |
d77de738 ML |
6878 | @option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3} |
6879 | and @option{-Wno-implicit-fallthrough} is the same as | |
6880 | @option{-Wimplicit-fallthrough=0}. | |
6881 | ||
d77de738 | 6882 | @opindex Wimplicit-fallthrough= |
ddf6fe37 | 6883 | @item -Wimplicit-fallthrough=@var{n} |
d77de738 ML |
6884 | Warn when a switch case falls through. For example: |
6885 | ||
6886 | @smallexample | |
6887 | @group | |
6888 | switch (cond) | |
6889 | @{ | |
6890 | case 1: | |
6891 | a = 1; | |
6892 | break; | |
6893 | case 2: | |
6894 | a = 2; | |
6895 | case 3: | |
6896 | a = 3; | |
6897 | break; | |
6898 | @} | |
6899 | @end group | |
6900 | @end smallexample | |
6901 | ||
6902 | This warning does not warn when the last statement of a case cannot | |
6903 | fall through, e.g. when there is a return statement or a call to function | |
6904 | declared with the noreturn attribute. @option{-Wimplicit-fallthrough=} | |
6905 | also takes into account control flow statements, such as ifs, and only | |
6906 | warns when appropriate. E.g.@: | |
6907 | ||
6908 | @smallexample | |
6909 | @group | |
6910 | switch (cond) | |
6911 | @{ | |
6912 | case 1: | |
6913 | if (i > 3) @{ | |
6914 | bar (5); | |
6915 | break; | |
6916 | @} else if (i < 1) @{ | |
6917 | bar (0); | |
6918 | @} else | |
6919 | return; | |
6920 | default: | |
6921 | @dots{} | |
6922 | @} | |
6923 | @end group | |
6924 | @end smallexample | |
6925 | ||
6926 | Since there are occasions where a switch case fall through is desirable, | |
6927 | GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is | |
6928 | to be used along with a null statement to suppress this warning that | |
6929 | would normally occur: | |
6930 | ||
6931 | @smallexample | |
6932 | @group | |
6933 | switch (cond) | |
6934 | @{ | |
6935 | case 1: | |
6936 | bar (0); | |
6937 | __attribute__ ((fallthrough)); | |
6938 | default: | |
6939 | @dots{} | |
6940 | @} | |
6941 | @end group | |
6942 | @end smallexample | |
6943 | ||
6944 | C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough} | |
6945 | warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11 | |
6946 | or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension. | |
6947 | Instead of these attributes, it is also possible to add a fallthrough comment | |
6948 | to silence the warning. The whole body of the C or C++ style comment should | |
6949 | match the given regular expressions listed below. The option argument @var{n} | |
6950 | specifies what kind of comments are accepted: | |
6951 | ||
6952 | @itemize @bullet | |
6953 | ||
6954 | @item @option{-Wimplicit-fallthrough=0} disables the warning altogether. | |
6955 | ||
6956 | @item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular | |
6957 | expression, any comment is used as fallthrough comment. | |
6958 | ||
6959 | @item @option{-Wimplicit-fallthrough=2} case insensitively matches | |
6960 | @code{.*falls?[ \t-]*thr(ough|u).*} regular expression. | |
6961 | ||
6962 | @item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the | |
6963 | following regular expressions: | |
6964 | ||
6965 | @itemize @bullet | |
6966 | ||
6967 | @item @code{-fallthrough} | |
6968 | ||
6969 | @item @code{@@fallthrough@@} | |
6970 | ||
6971 | @item @code{lint -fallthrough[ \t]*} | |
6972 | ||
6973 | @item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?} | |
6974 | ||
6975 | @item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?} | |
6976 | ||
6977 | @item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?} | |
6978 | ||
6979 | @end itemize | |
6980 | ||
6981 | @item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the | |
6982 | following regular expressions: | |
6983 | ||
6984 | @itemize @bullet | |
6985 | ||
6986 | @item @code{-fallthrough} | |
6987 | ||
6988 | @item @code{@@fallthrough@@} | |
6989 | ||
6990 | @item @code{lint -fallthrough[ \t]*} | |
6991 | ||
6992 | @item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*} | |
6993 | ||
6994 | @end itemize | |
6995 | ||
6996 | @item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as | |
6997 | fallthrough comments, only attributes disable the warning. | |
6998 | ||
6999 | @end itemize | |
7000 | ||
7001 | The comment needs to be followed after optional whitespace and other comments | |
7002 | by @code{case} or @code{default} keywords or by a user label that precedes some | |
7003 | @code{case} or @code{default} label. | |
7004 | ||
7005 | @smallexample | |
7006 | @group | |
7007 | switch (cond) | |
7008 | @{ | |
7009 | case 1: | |
7010 | bar (0); | |
7011 | /* FALLTHRU */ | |
7012 | default: | |
7013 | @dots{} | |
7014 | @} | |
7015 | @end group | |
7016 | @end smallexample | |
7017 | ||
7018 | The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}. | |
7019 | ||
d77de738 ML |
7020 | @opindex Wif-not-aligned |
7021 | @opindex Wno-if-not-aligned | |
ddf6fe37 | 7022 | @item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
7023 | Control if warnings triggered by the @code{warn_if_not_aligned} attribute |
7024 | should be issued. These warnings are enabled by default. | |
7025 | ||
d77de738 ML |
7026 | @opindex Wignored-qualifiers |
7027 | @opindex Wno-ignored-qualifiers | |
ddf6fe37 | 7028 | @item -Wignored-qualifiers @r{(C and C++ only)} |
d77de738 ML |
7029 | Warn if the return type of a function has a type qualifier |
7030 | such as @code{const}. For ISO C such a type qualifier has no effect, | |
7031 | since the value returned by a function is not an lvalue. | |
7032 | For C++, the warning is only emitted for scalar types or @code{void}. | |
7033 | ISO C prohibits qualified @code{void} return types on function | |
7034 | definitions, so such return types always receive a warning | |
7035 | even without this option. | |
7036 | ||
7037 | This warning is also enabled by @option{-Wextra}. | |
7038 | ||
d77de738 ML |
7039 | @opindex Wignored-attributes |
7040 | @opindex Wno-ignored-attributes | |
ddf6fe37 | 7041 | @item -Wno-ignored-attributes @r{(C and C++ only)} |
d77de738 ML |
7042 | This option controls warnings when an attribute is ignored. |
7043 | This is different from the | |
7044 | @option{-Wattributes} option in that it warns whenever the compiler decides | |
7045 | to drop an attribute, not that the attribute is either unknown, used in a | |
7046 | wrong place, etc. This warning is enabled by default. | |
7047 | ||
d77de738 ML |
7048 | @opindex Wmain |
7049 | @opindex Wno-main | |
ddf6fe37 | 7050 | @item -Wmain |
d77de738 ML |
7051 | Warn if the type of @code{main} is suspicious. @code{main} should be |
7052 | a function with external linkage, returning int, taking either zero | |
7053 | arguments, two, or three arguments of appropriate types. This warning | |
7054 | is enabled by default in C++ and is enabled by either @option{-Wall} | |
7055 | or @option{-Wpedantic}. | |
7056 | ||
5fccebdb JM |
7057 | This warning is upgraded to an error by @option{-pedantic-errors}. |
7058 | ||
d77de738 ML |
7059 | @opindex Wmisleading-indentation |
7060 | @opindex Wno-misleading-indentation | |
ddf6fe37 | 7061 | @item -Wmisleading-indentation @r{(C and C++ only)} |
d77de738 ML |
7062 | Warn when the indentation of the code does not reflect the block structure. |
7063 | Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and | |
7064 | @code{for} clauses with a guarded statement that does not use braces, | |
7065 | followed by an unguarded statement with the same indentation. | |
7066 | ||
7067 | In the following example, the call to ``bar'' is misleadingly indented as | |
7068 | if it were guarded by the ``if'' conditional. | |
7069 | ||
7070 | @smallexample | |
7071 | if (some_condition ()) | |
7072 | foo (); | |
7073 | bar (); /* Gotcha: this is not guarded by the "if". */ | |
7074 | @end smallexample | |
7075 | ||
7076 | In the case of mixed tabs and spaces, the warning uses the | |
7077 | @option{-ftabstop=} option to determine if the statements line up | |
7078 | (defaulting to 8). | |
7079 | ||
7080 | The warning is not issued for code involving multiline preprocessor logic | |
7081 | such as the following example. | |
7082 | ||
7083 | @smallexample | |
7084 | if (flagA) | |
7085 | foo (0); | |
7086 | #if SOME_CONDITION_THAT_DOES_NOT_HOLD | |
7087 | if (flagB) | |
7088 | #endif | |
7089 | foo (1); | |
7090 | @end smallexample | |
7091 | ||
7092 | The warning is not issued after a @code{#line} directive, since this | |
7093 | typically indicates autogenerated code, and no assumptions can be made | |
7094 | about the layout of the file that the directive references. | |
7095 | ||
7096 | This warning is enabled by @option{-Wall} in C and C++. | |
7097 | ||
d77de738 ML |
7098 | @opindex Wmissing-attributes |
7099 | @opindex Wno-missing-attributes | |
ddf6fe37 | 7100 | @item -Wmissing-attributes |
d77de738 ML |
7101 | Warn when a declaration of a function is missing one or more attributes |
7102 | that a related function is declared with and whose absence may adversely | |
7103 | affect the correctness or efficiency of generated code. For example, | |
7104 | the warning is issued for declarations of aliases that use attributes | |
7105 | to specify less restrictive requirements than those of their targets. | |
7106 | This typically represents a potential optimization opportunity. | |
7107 | By contrast, the @option{-Wattribute-alias=2} option controls warnings | |
7108 | issued when the alias is more restrictive than the target, which could | |
7109 | lead to incorrect code generation. | |
7110 | Attributes considered include @code{alloc_align}, @code{alloc_size}, | |
7111 | @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc}, | |
7112 | @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure}, | |
7113 | @code{returns_nonnull}, and @code{returns_twice}. | |
7114 | ||
7115 | In C++, the warning is issued when an explicit specialization of a primary | |
7116 | template declared with attribute @code{alloc_align}, @code{alloc_size}, | |
7117 | @code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc}, | |
7118 | or @code{nonnull} is declared without it. Attributes @code{deprecated}, | |
7119 | @code{error}, and @code{warning} suppress the warning. | |
7120 | (@pxref{Function Attributes}). | |
7121 | ||
7122 | You can use the @code{copy} attribute to apply the same | |
7123 | set of attributes to a declaration as that on another declaration without | |
7124 | explicitly enumerating the attributes. This attribute can be applied | |
7125 | to declarations of functions (@pxref{Common Function Attributes}), | |
7126 | variables (@pxref{Common Variable Attributes}), or types | |
7127 | (@pxref{Common Type Attributes}). | |
7128 | ||
7129 | @option{-Wmissing-attributes} is enabled by @option{-Wall}. | |
7130 | ||
7131 | For example, since the declaration of the primary function template | |
7132 | below makes use of both attribute @code{malloc} and @code{alloc_size} | |
7133 | the declaration of the explicit specialization of the template is | |
7134 | diagnosed because it is missing one of the attributes. | |
7135 | ||
7136 | @smallexample | |
7137 | template <class T> | |
7138 | T* __attribute__ ((malloc, alloc_size (1))) | |
7139 | allocate (size_t); | |
7140 | ||
7141 | template <> | |
7142 | void* __attribute__ ((malloc)) // missing alloc_size | |
7143 | allocate<void> (size_t); | |
7144 | @end smallexample | |
7145 | ||
d77de738 ML |
7146 | @opindex Wmissing-braces |
7147 | @opindex Wno-missing-braces | |
ddf6fe37 | 7148 | @item -Wmissing-braces |
d77de738 ML |
7149 | Warn if an aggregate or union initializer is not fully bracketed. In |
7150 | the following example, the initializer for @code{a} is not fully | |
7151 | bracketed, but that for @code{b} is fully bracketed. | |
7152 | ||
7153 | @smallexample | |
7154 | int a[2][2] = @{ 0, 1, 2, 3 @}; | |
7155 | int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @}; | |
7156 | @end smallexample | |
7157 | ||
7158 | This warning is enabled by @option{-Wall}. | |
7159 | ||
d77de738 ML |
7160 | @opindex Wmissing-include-dirs |
7161 | @opindex Wno-missing-include-dirs | |
ddf6fe37 | 7162 | @item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)} |
72cfa0f7 | 7163 | Warn if a user-supplied include directory does not exist. This option is disabled |
d77de738 ML |
7164 | by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially |
7165 | enabled by default by warning for -I and -J, only. | |
7166 | ||
d77de738 ML |
7167 | @opindex Wmissing-profile |
7168 | @opindex Wno-missing-profile | |
ddf6fe37 | 7169 | @item -Wno-missing-profile |
d77de738 ML |
7170 | This option controls warnings if feedback profiles are missing when using the |
7171 | @option{-fprofile-use} option. | |
7172 | This option diagnoses those cases where a new function or a new file is added | |
7173 | between compiling with @option{-fprofile-generate} and with | |
7174 | @option{-fprofile-use}, without regenerating the profiles. | |
7175 | In these cases, the profile feedback data files do not contain any | |
7176 | profile feedback information for | |
7177 | the newly added function or file respectively. Also, in the case when profile | |
7178 | count data (.gcda) files are removed, GCC cannot use any profile feedback | |
7179 | information. In all these cases, warnings are issued to inform you that a | |
7180 | profile generation step is due. | |
7181 | Ignoring the warning can result in poorly optimized code. | |
7182 | @option{-Wno-missing-profile} can be used to | |
7183 | disable the warning, but this is not recommended and should be done only | |
7184 | when non-existent profile data is justified. | |
7185 | ||
d77de738 ML |
7186 | @opindex Wmismatched-dealloc |
7187 | @opindex Wno-mismatched-dealloc | |
ddf6fe37 | 7188 | @item -Wmismatched-dealloc |
d77de738 ML |
7189 | |
7190 | Warn for calls to deallocation functions with pointer arguments returned | |
7191 | from from allocations functions for which the former isn't a suitable | |
7192 | deallocator. A pair of functions can be associated as matching allocators | |
7193 | and deallocators by use of attribute @code{malloc}. Unless disabled by | |
7194 | the @option{-fno-builtin} option the standard functions @code{calloc}, | |
7195 | @code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding | |
7196 | forms of C++ @code{operator new} and @code{operator delete} are implicitly | |
7197 | associated as matching allocators and deallocators. In the following | |
7198 | example @code{mydealloc} is the deallocator for pointers returned from | |
7199 | @code{myalloc}. | |
7200 | ||
7201 | @smallexample | |
7202 | void mydealloc (void*); | |
7203 | ||
7204 | __attribute__ ((malloc (mydealloc, 1))) void* | |
7205 | myalloc (size_t); | |
7206 | ||
7207 | void f (void) | |
7208 | @{ | |
7209 | void *p = myalloc (32); | |
7210 | // @dots{}use p@dots{} | |
7211 | free (p); // warning: not a matching deallocator for myalloc | |
7212 | mydealloc (p); // ok | |
7213 | @} | |
7214 | @end smallexample | |
7215 | ||
7216 | In C++, the related option @option{-Wmismatched-new-delete} diagnoses | |
7217 | mismatches involving either @code{operator new} or @code{operator delete}. | |
7218 | ||
7219 | Option @option{-Wmismatched-dealloc} is included in @option{-Wall}. | |
7220 | ||
d77de738 ML |
7221 | @opindex Wmultistatement-macros |
7222 | @opindex Wno-multistatement-macros | |
ddf6fe37 | 7223 | @item -Wmultistatement-macros |
d77de738 ML |
7224 | Warn about unsafe multiple statement macros that appear to be guarded |
7225 | by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or | |
7226 | @code{while}, in which only the first statement is actually guarded after | |
7227 | the macro is expanded. | |
7228 | ||
7229 | For example: | |
7230 | ||
7231 | @smallexample | |
7232 | #define DOIT x++; y++ | |
7233 | if (c) | |
7234 | DOIT; | |
7235 | @end smallexample | |
7236 | ||
7237 | will increment @code{y} unconditionally, not just when @code{c} holds. | |
7238 | The can usually be fixed by wrapping the macro in a do-while loop: | |
7239 | @smallexample | |
7240 | #define DOIT do @{ x++; y++; @} while (0) | |
7241 | if (c) | |
7242 | DOIT; | |
7243 | @end smallexample | |
7244 | ||
7245 | This warning is enabled by @option{-Wall} in C and C++. | |
7246 | ||
d77de738 ML |
7247 | @opindex Wparentheses |
7248 | @opindex Wno-parentheses | |
ddf6fe37 | 7249 | @item -Wparentheses |
d77de738 ML |
7250 | Warn if parentheses are omitted in certain contexts, such |
7251 | as when there is an assignment in a context where a truth value | |
7252 | is expected, or when operators are nested whose precedence people | |
7253 | often get confused about. | |
7254 | ||
7255 | Also warn if a comparison like @code{x<=y<=z} appears; this is | |
7256 | equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different | |
7257 | interpretation from that of ordinary mathematical notation. | |
7258 | ||
7259 | Also warn for dangerous uses of the GNU extension to | |
7260 | @code{?:} with omitted middle operand. When the condition | |
7261 | in the @code{?}: operator is a boolean expression, the omitted value is | |
7262 | always 1. Often programmers expect it to be a value computed | |
7263 | inside the conditional expression instead. | |
7264 | ||
7265 | For C++ this also warns for some cases of unnecessary parentheses in | |
7266 | declarations, which can indicate an attempt at a function call instead | |
7267 | of a declaration: | |
7268 | @smallexample | |
7269 | @{ | |
7270 | // Declares a local variable called mymutex. | |
7271 | std::unique_lock<std::mutex> (mymutex); | |
7272 | // User meant std::unique_lock<std::mutex> lock (mymutex); | |
7273 | @} | |
7274 | @end smallexample | |
7275 | ||
7276 | This warning is enabled by @option{-Wall}. | |
7277 | ||
d77de738 ML |
7278 | @opindex Wself-move |
7279 | @opindex Wno-self-move | |
ddf6fe37 | 7280 | @item -Wno-self-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
7281 | This warning warns when a value is moved to itself with @code{std::move}. |
7282 | Such a @code{std::move} typically has no effect. | |
7283 | ||
7284 | @smallexample | |
7285 | struct T @{ | |
7286 | @dots{} | |
7287 | @}; | |
7288 | void fn() | |
7289 | @{ | |
7290 | T t; | |
7291 | @dots{} | |
7292 | t = std::move (t); | |
7293 | @} | |
7294 | @end smallexample | |
7295 | ||
7296 | This warning is enabled by @option{-Wall}. | |
7297 | ||
d77de738 ML |
7298 | @opindex Wsequence-point |
7299 | @opindex Wno-sequence-point | |
ddf6fe37 | 7300 | @item -Wsequence-point |
d77de738 ML |
7301 | Warn about code that may have undefined semantics because of violations |
7302 | of sequence point rules in the C and C++ standards. | |
7303 | ||
7304 | The C and C++ standards define the order in which expressions in a C/C++ | |
7305 | program are evaluated in terms of @dfn{sequence points}, which represent | |
7306 | a partial ordering between the execution of parts of the program: those | |
7307 | executed before the sequence point, and those executed after it. These | |
7308 | occur after the evaluation of a full expression (one which is not part | |
7309 | of a larger expression), after the evaluation of the first operand of a | |
7310 | @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a | |
7311 | function is called (but after the evaluation of its arguments and the | |
7312 | expression denoting the called function), and in certain other places. | |
7313 | Other than as expressed by the sequence point rules, the order of | |
7314 | evaluation of subexpressions of an expression is not specified. All | |
7315 | these rules describe only a partial order rather than a total order, | |
7316 | since, for example, if two functions are called within one expression | |
7317 | with no sequence point between them, the order in which the functions | |
7318 | are called is not specified. However, the standards committee have | |
7319 | ruled that function calls do not overlap. | |
7320 | ||
7321 | It is not specified when between sequence points modifications to the | |
7322 | values of objects take effect. Programs whose behavior depends on this | |
7323 | have undefined behavior; the C and C++ standards specify that ``Between | |
7324 | the previous and next sequence point an object shall have its stored | |
7325 | value modified at most once by the evaluation of an expression. | |
7326 | Furthermore, the prior value shall be read only to determine the value | |
7327 | to be stored.''. If a program breaks these rules, the results on any | |
7328 | particular implementation are entirely unpredictable. | |
7329 | ||
7330 | Examples of code with undefined behavior are @code{a = a++;}, @code{a[n] | |
7331 | = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not | |
7332 | diagnosed by this option, and it may give an occasional false positive | |
7333 | result, but in general it has been found fairly effective at detecting | |
7334 | this sort of problem in programs. | |
7335 | ||
7336 | The C++17 standard will define the order of evaluation of operands in | |
7337 | more cases: in particular it requires that the right-hand side of an | |
7338 | assignment be evaluated before the left-hand side, so the above | |
7339 | examples are no longer undefined. But this option will still warn | |
7340 | about them, to help people avoid writing code that is undefined in C | |
7341 | and earlier revisions of C++. | |
7342 | ||
7343 | The standard is worded confusingly, therefore there is some debate | |
7344 | over the precise meaning of the sequence point rules in subtle cases. | |
7345 | Links to discussions of the problem, including proposed formal | |
7346 | definitions, may be found on the GCC readings page, at | |
7347 | @uref{https://gcc.gnu.org/@/readings.html}. | |
7348 | ||
7349 | This warning is enabled by @option{-Wall} for C and C++. | |
7350 | ||
d77de738 ML |
7351 | @opindex Wno-return-local-addr |
7352 | @opindex Wreturn-local-addr | |
ddf6fe37 | 7353 | @item -Wno-return-local-addr |
d77de738 ML |
7354 | Do not warn about returning a pointer (or in C++, a reference) to a |
7355 | variable that goes out of scope after the function returns. | |
7356 | ||
6e312b2b FW |
7357 | @opindex Wreturn-mismatch |
7358 | @opindex Wno-return-mismatch | |
7359 | @item -Wreturn-mismatch | |
7360 | Warn about return statements without an expressions in functions which | |
7361 | do not return @code{void}. Also warn about a @code{return} statement | |
7362 | with an expression in a function whose return type is @code{void}, | |
7363 | unless the expression type is also @code{void}. As a GNU extension, the | |
7364 | latter case is accepted without a warning unless @option{-Wpedantic} is | |
7365 | used. | |
7366 | ||
7367 | Attempting to use the return value of a non-@code{void} function other | |
7368 | than @code{main} that flows off the end by reaching the closing curly | |
7369 | brace that terminates the function is undefined. | |
7370 | ||
7371 | This warning is specific to C and enabled by default. | |
7372 | ||
d77de738 ML |
7373 | @opindex Wreturn-type |
7374 | @opindex Wno-return-type | |
ddf6fe37 | 7375 | @item -Wreturn-type |
6e312b2b FW |
7376 | Warn whenever a function is defined with a return type that defaults to |
7377 | @code{int} (unless @option{-Wimplicit-int} is active, which takes | |
7378 | precedence). Also warn if execution may reach the end of the function | |
7379 | body, or if the function does not contain any return statement at all. | |
7380 | ||
7381 | Attempting to use the return value of a non-@code{void} function other | |
7382 | than @code{main} that flows off the end by reaching the closing curly | |
7383 | brace that terminates the function is undefined. | |
d77de738 ML |
7384 | |
7385 | Unlike in C, in C++, flowing off the end of a non-@code{void} function other | |
7386 | than @code{main} results in undefined behavior even when the value of | |
7387 | the function is not used. | |
7388 | ||
7389 | This warning is enabled by default in C++ and by @option{-Wall} otherwise. | |
7390 | ||
d77de738 ML |
7391 | @opindex Wshift-count-negative |
7392 | @opindex Wno-shift-count-negative | |
ddf6fe37 | 7393 | @item -Wno-shift-count-negative |
d77de738 ML |
7394 | Controls warnings if a shift count is negative. |
7395 | This warning is enabled by default. | |
7396 | ||
d77de738 ML |
7397 | @opindex Wshift-count-overflow |
7398 | @opindex Wno-shift-count-overflow | |
ddf6fe37 | 7399 | @item -Wno-shift-count-overflow |
d77de738 ML |
7400 | Controls warnings if a shift count is greater than or equal to the bit width |
7401 | of the type. This warning is enabled by default. | |
7402 | ||
d77de738 ML |
7403 | @opindex Wshift-negative-value |
7404 | @opindex Wno-shift-negative-value | |
ddf6fe37 | 7405 | @item -Wshift-negative-value |
d77de738 ML |
7406 | Warn if left shifting a negative value. This warning is enabled by |
7407 | @option{-Wextra} in C99 (and newer) and C++11 to C++17 modes. | |
7408 | ||
d77de738 ML |
7409 | @opindex Wshift-overflow |
7410 | @opindex Wno-shift-overflow | |
ddf6fe37 AA |
7411 | @item -Wno-shift-overflow |
7412 | @itemx -Wshift-overflow=@var{n} | |
d77de738 ML |
7413 | These options control warnings about left shift overflows. |
7414 | ||
7415 | @table @gcctabopt | |
7416 | @item -Wshift-overflow=1 | |
7417 | This is the warning level of @option{-Wshift-overflow} and is enabled | |
7418 | by default in C99 and C++11 modes (and newer). This warning level does | |
7419 | not warn about left-shifting 1 into the sign bit. (However, in C, such | |
7420 | an overflow is still rejected in contexts where an integer constant expression | |
7421 | is required.) No warning is emitted in C++20 mode (and newer), as signed left | |
7422 | shifts always wrap. | |
7423 | ||
7424 | @item -Wshift-overflow=2 | |
7425 | This warning level also warns about left-shifting 1 into the sign bit, | |
7426 | unless C++14 mode (or newer) is active. | |
7427 | @end table | |
7428 | ||
d77de738 ML |
7429 | @opindex Wswitch |
7430 | @opindex Wno-switch | |
ddf6fe37 | 7431 | @item -Wswitch |
d77de738 ML |
7432 | Warn whenever a @code{switch} statement has an index of enumerated type |
7433 | and lacks a @code{case} for one or more of the named codes of that | |
7434 | enumeration. (The presence of a @code{default} label prevents this | |
7435 | warning.) @code{case} labels outside the enumeration range also | |
7436 | provoke warnings when this option is used (even if there is a | |
7437 | @code{default} label). | |
7438 | This warning is enabled by @option{-Wall}. | |
7439 | ||
d77de738 ML |
7440 | @opindex Wswitch-default |
7441 | @opindex Wno-switch-default | |
ddf6fe37 | 7442 | @item -Wswitch-default |
d77de738 ML |
7443 | Warn whenever a @code{switch} statement does not have a @code{default} |
7444 | case. | |
7445 | ||
d77de738 ML |
7446 | @opindex Wswitch-enum |
7447 | @opindex Wno-switch-enum | |
ddf6fe37 | 7448 | @item -Wswitch-enum |
d77de738 ML |
7449 | Warn whenever a @code{switch} statement has an index of enumerated type |
7450 | and lacks a @code{case} for one or more of the named codes of that | |
7451 | enumeration. @code{case} labels outside the enumeration range also | |
7452 | provoke warnings when this option is used. The only difference | |
7453 | between @option{-Wswitch} and this option is that this option gives a | |
7454 | warning about an omitted enumeration code even if there is a | |
7455 | @code{default} label. | |
7456 | ||
d77de738 ML |
7457 | @opindex Wswitch-bool |
7458 | @opindex Wno-switch-bool | |
ddf6fe37 | 7459 | @item -Wno-switch-bool |
d77de738 ML |
7460 | Do not warn when a @code{switch} statement has an index of boolean type |
7461 | and the case values are outside the range of a boolean type. | |
7462 | It is possible to suppress this warning by casting the controlling | |
7463 | expression to a type other than @code{bool}. For example: | |
7464 | @smallexample | |
7465 | @group | |
7466 | switch ((int) (a == 4)) | |
7467 | @{ | |
7468 | @dots{} | |
7469 | @} | |
7470 | @end group | |
7471 | @end smallexample | |
7472 | This warning is enabled by default for C and C++ programs. | |
7473 | ||
d77de738 ML |
7474 | @opindex Wswitch-outside-range |
7475 | @opindex Wno-switch-outside-range | |
ddf6fe37 | 7476 | @item -Wno-switch-outside-range |
d77de738 ML |
7477 | This option controls warnings when a @code{switch} case has a value |
7478 | that is outside of its | |
7479 | respective type range. This warning is enabled by default for | |
7480 | C and C++ programs. | |
7481 | ||
d77de738 ML |
7482 | @opindex Wswitch-unreachable |
7483 | @opindex Wno-switch-unreachable | |
ddf6fe37 | 7484 | @item -Wno-switch-unreachable |
d77de738 ML |
7485 | Do not warn when a @code{switch} statement contains statements between the |
7486 | controlling expression and the first case label, which will never be | |
7487 | executed. For example: | |
7488 | @smallexample | |
7489 | @group | |
7490 | switch (cond) | |
7491 | @{ | |
7492 | i = 15; | |
7493 | @dots{} | |
7494 | case 5: | |
7495 | @dots{} | |
7496 | @} | |
7497 | @end group | |
7498 | @end smallexample | |
7499 | @option{-Wswitch-unreachable} does not warn if the statement between the | |
7500 | controlling expression and the first case label is just a declaration: | |
7501 | @smallexample | |
7502 | @group | |
7503 | switch (cond) | |
7504 | @{ | |
7505 | int i; | |
7506 | @dots{} | |
7507 | case 5: | |
7508 | i = 5; | |
7509 | @dots{} | |
7510 | @} | |
7511 | @end group | |
7512 | @end smallexample | |
7513 | This warning is enabled by default for C and C++ programs. | |
7514 | ||
d77de738 ML |
7515 | @opindex Wsync-nand |
7516 | @opindex Wno-sync-nand | |
ddf6fe37 | 7517 | @item -Wsync-nand @r{(C and C++ only)} |
d77de738 ML |
7518 | Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch} |
7519 | built-in functions are used. These functions changed semantics in GCC 4.4. | |
7520 | ||
d77de738 ML |
7521 | @opindex Wtrivial-auto-var-init |
7522 | @opindex Wno-trivial-auto-var-init | |
ddf6fe37 | 7523 | @item -Wtrivial-auto-var-init |
d77de738 ML |
7524 | Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic |
7525 | variable. A common situation is an automatic variable that is declared | |
7526 | between the controlling expression and the first case label of a @code{switch} | |
7527 | statement. | |
7528 | ||
d77de738 ML |
7529 | @opindex Wunused-but-set-parameter |
7530 | @opindex Wno-unused-but-set-parameter | |
ddf6fe37 | 7531 | @item -Wunused-but-set-parameter |
d77de738 ML |
7532 | Warn whenever a function parameter is assigned to, but otherwise unused |
7533 | (aside from its declaration). | |
7534 | ||
7535 | To suppress this warning use the @code{unused} attribute | |
7536 | (@pxref{Variable Attributes}). | |
7537 | ||
7538 | This warning is also enabled by @option{-Wunused} together with | |
7539 | @option{-Wextra}. | |
7540 | ||
d77de738 ML |
7541 | @opindex Wunused-but-set-variable |
7542 | @opindex Wno-unused-but-set-variable | |
ddf6fe37 | 7543 | @item -Wunused-but-set-variable |
d77de738 ML |
7544 | Warn whenever a local variable is assigned to, but otherwise unused |
7545 | (aside from its declaration). | |
7546 | This warning is enabled by @option{-Wall}. | |
7547 | ||
7548 | To suppress this warning use the @code{unused} attribute | |
7549 | (@pxref{Variable Attributes}). | |
7550 | ||
7551 | This warning is also enabled by @option{-Wunused}, which is enabled | |
7552 | by @option{-Wall}. | |
7553 | ||
d77de738 ML |
7554 | @opindex Wunused-function |
7555 | @opindex Wno-unused-function | |
ddf6fe37 | 7556 | @item -Wunused-function |
d77de738 ML |
7557 | Warn whenever a static function is declared but not defined or a |
7558 | non-inline static function is unused. | |
7559 | This warning is enabled by @option{-Wall}. | |
7560 | ||
d77de738 ML |
7561 | @opindex Wunused-label |
7562 | @opindex Wno-unused-label | |
ddf6fe37 | 7563 | @item -Wunused-label |
d77de738 ML |
7564 | Warn whenever a label is declared but not used. |
7565 | This warning is enabled by @option{-Wall}. | |
7566 | ||
7567 | To suppress this warning use the @code{unused} attribute | |
7568 | (@pxref{Variable Attributes}). | |
7569 | ||
d77de738 ML |
7570 | @opindex Wunused-local-typedefs |
7571 | @opindex Wno-unused-local-typedefs | |
ddf6fe37 | 7572 | @item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)} |
d77de738 ML |
7573 | Warn when a typedef locally defined in a function is not used. |
7574 | This warning is enabled by @option{-Wall}. | |
7575 | ||
d77de738 ML |
7576 | @opindex Wunused-parameter |
7577 | @opindex Wno-unused-parameter | |
ddf6fe37 | 7578 | @item -Wunused-parameter |
d77de738 ML |
7579 | Warn whenever a function parameter is unused aside from its declaration. |
7580 | ||
7581 | To suppress this warning use the @code{unused} attribute | |
7582 | (@pxref{Variable Attributes}). | |
7583 | ||
d77de738 ML |
7584 | @opindex Wunused-result |
7585 | @opindex Wno-unused-result | |
ddf6fe37 | 7586 | @item -Wno-unused-result |
d77de738 ML |
7587 | Do not warn if a caller of a function marked with attribute |
7588 | @code{warn_unused_result} (@pxref{Function Attributes}) does not use | |
7589 | its return value. The default is @option{-Wunused-result}. | |
7590 | ||
d77de738 ML |
7591 | @opindex Wunused-variable |
7592 | @opindex Wno-unused-variable | |
ddf6fe37 | 7593 | @item -Wunused-variable |
d77de738 ML |
7594 | Warn whenever a local or static variable is unused aside from its |
7595 | declaration. This option implies @option{-Wunused-const-variable=1} for C, | |
7596 | but not for C++. This warning is enabled by @option{-Wall}. | |
7597 | ||
7598 | To suppress this warning use the @code{unused} attribute | |
7599 | (@pxref{Variable Attributes}). | |
7600 | ||
d77de738 ML |
7601 | @opindex Wunused-const-variable |
7602 | @opindex Wno-unused-const-variable | |
ddf6fe37 AA |
7603 | @item -Wunused-const-variable |
7604 | @itemx -Wunused-const-variable=@var{n} | |
d77de738 ML |
7605 | Warn whenever a constant static variable is unused aside from its declaration. |
7606 | @option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable} | |
7607 | for C, but not for C++. In C this declares variable storage, but in C++ this | |
7608 | is not an error since const variables take the place of @code{#define}s. | |
7609 | ||
7610 | To suppress this warning use the @code{unused} attribute | |
7611 | (@pxref{Variable Attributes}). | |
7612 | ||
7613 | @table @gcctabopt | |
7614 | @item -Wunused-const-variable=1 | |
7615 | This is the warning level that is enabled by @option{-Wunused-variable} for | |
7616 | C. It warns only about unused static const variables defined in the main | |
7617 | compilation unit, but not about static const variables declared in any | |
7618 | header included. | |
7619 | ||
7620 | @item -Wunused-const-variable=2 | |
7621 | This warning level also warns for unused constant static variables in | |
7622 | headers (excluding system headers). This is the warning level of | |
7623 | @option{-Wunused-const-variable} and must be explicitly requested since | |
7624 | in C++ this isn't an error and in C it might be harder to clean up all | |
7625 | headers included. | |
7626 | @end table | |
7627 | ||
d77de738 ML |
7628 | @opindex Wunused-value |
7629 | @opindex Wno-unused-value | |
ddf6fe37 | 7630 | @item -Wunused-value |
d77de738 ML |
7631 | Warn whenever a statement computes a result that is explicitly not |
7632 | used. To suppress this warning cast the unused expression to | |
7633 | @code{void}. This includes an expression-statement or the left-hand | |
7634 | side of a comma expression that contains no side effects. For example, | |
7635 | an expression such as @code{x[i,j]} causes a warning, while | |
7636 | @code{x[(void)i,j]} does not. | |
7637 | ||
7638 | This warning is enabled by @option{-Wall}. | |
7639 | ||
d77de738 ML |
7640 | @opindex Wunused |
7641 | @opindex Wno-unused | |
ddf6fe37 | 7642 | @item -Wunused |
d77de738 ML |
7643 | All the above @option{-Wunused} options combined. |
7644 | ||
7645 | In order to get a warning about an unused function parameter, you must | |
7646 | either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies | |
7647 | @option{-Wunused}), or separately specify @option{-Wunused-parameter}. | |
7648 | ||
d77de738 ML |
7649 | @opindex Wuninitialized |
7650 | @opindex Wno-uninitialized | |
ddf6fe37 | 7651 | @item -Wuninitialized |
d77de738 ML |
7652 | Warn if an object with automatic or allocated storage duration is used |
7653 | without having been initialized. In C++, also warn if a non-static | |
7654 | reference or non-static @code{const} member appears in a class without | |
7655 | constructors. | |
7656 | ||
7657 | In addition, passing a pointer (or in C++, a reference) to an uninitialized | |
7658 | object to a @code{const}-qualified argument of a built-in function known to | |
7659 | read the object is also diagnosed by this warning. | |
7660 | (@option{-Wmaybe-uninitialized} is issued for ordinary functions.) | |
7661 | ||
7662 | If you want to warn about code that uses the uninitialized value of the | |
7663 | variable in its own initializer, use the @option{-Winit-self} option. | |
7664 | ||
7665 | These warnings occur for individual uninitialized elements of | |
7666 | structure, union or array variables as well as for variables that are | |
7667 | uninitialized as a whole. They do not occur for variables or elements | |
7668 | declared @code{volatile}. Because these warnings depend on | |
7669 | optimization, the exact variables or elements for which there are | |
7670 | warnings depend on the precise optimization options and version of GCC | |
7671 | used. | |
7672 | ||
7673 | Note that there may be no warning about a variable that is used only | |
7674 | to compute a value that itself is never used, because such | |
7675 | computations may be deleted by data flow analysis before the warnings | |
7676 | are printed. | |
7677 | ||
7678 | In C++, this warning also warns about using uninitialized objects in | |
7679 | member-initializer-lists. For example, GCC warns about @code{b} being | |
7680 | uninitialized in the following snippet: | |
7681 | ||
7682 | @smallexample | |
7683 | struct A @{ | |
7684 | int a; | |
7685 | int b; | |
7686 | A() : a(b) @{ @} | |
7687 | @}; | |
7688 | @end smallexample | |
7689 | ||
d77de738 ML |
7690 | @opindex Winvalid-memory-model |
7691 | @opindex Wno-invalid-memory-model | |
ddf6fe37 | 7692 | @item -Wno-invalid-memory-model |
d77de738 ML |
7693 | This option controls warnings |
7694 | for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins}, | |
7695 | and the C11 atomic generic functions with a memory consistency argument | |
7696 | that is either invalid for the operation or outside the range of values | |
7697 | of the @code{memory_order} enumeration. For example, since the | |
7698 | @code{__atomic_store} and @code{__atomic_store_n} built-ins are only | |
7699 | defined for the relaxed, release, and sequentially consistent memory | |
7700 | orders the following code is diagnosed: | |
7701 | ||
7702 | @smallexample | |
7703 | void store (int *i) | |
7704 | @{ | |
7705 | __atomic_store_n (i, 0, memory_order_consume); | |
7706 | @} | |
7707 | @end smallexample | |
7708 | ||
7709 | @option{-Winvalid-memory-model} is enabled by default. | |
7710 | ||
d77de738 ML |
7711 | @opindex Wmaybe-uninitialized |
7712 | @opindex Wno-maybe-uninitialized | |
ddf6fe37 | 7713 | @item -Wmaybe-uninitialized |
d77de738 ML |
7714 | For an object with automatic or allocated storage duration, if there exists |
7715 | a path from the function entry to a use of the object that is initialized, | |
7716 | but there exist some other paths for which the object is not initialized, | |
7717 | the compiler emits a warning if it cannot prove the uninitialized paths | |
7718 | are not executed at run time. | |
7719 | ||
7720 | In addition, passing a pointer (or in C++, a reference) to an uninitialized | |
7721 | object to a @code{const}-qualified function argument is also diagnosed by | |
7722 | this warning. (@option{-Wuninitialized} is issued for built-in functions | |
7723 | known to read the object.) Annotating the function with attribute | |
7724 | @code{access (none)} indicates that the argument isn't used to access | |
7725 | the object and avoids the warning (@pxref{Common Function Attributes}). | |
7726 | ||
7727 | These warnings are only possible in optimizing compilation, because otherwise | |
7728 | GCC does not keep track of the state of variables. | |
7729 | ||
7730 | These warnings are made optional because GCC may not be able to determine when | |
7731 | the code is correct in spite of appearing to have an error. Here is one | |
7732 | example of how this can happen: | |
7733 | ||
7734 | @smallexample | |
7735 | @group | |
7736 | @{ | |
7737 | int x; | |
7738 | switch (y) | |
7739 | @{ | |
7740 | case 1: x = 1; | |
7741 | break; | |
7742 | case 2: x = 4; | |
7743 | break; | |
7744 | case 3: x = 5; | |
7745 | @} | |
7746 | foo (x); | |
7747 | @} | |
7748 | @end group | |
7749 | @end smallexample | |
7750 | ||
7751 | @noindent | |
7752 | If the value of @code{y} is always 1, 2 or 3, then @code{x} is | |
7753 | always initialized, but GCC doesn't know this. To suppress the | |
7754 | warning, you need to provide a default case with assert(0) or | |
7755 | similar code. | |
7756 | ||
7757 | @cindex @code{longjmp} warnings | |
7758 | This option also warns when a non-volatile automatic variable might be | |
7759 | changed by a call to @code{longjmp}. | |
7760 | The compiler sees only the calls to @code{setjmp}. It cannot know | |
7761 | where @code{longjmp} will be called; in fact, a signal handler could | |
7762 | call it at any point in the code. As a result, you may get a warning | |
7763 | even when there is in fact no problem because @code{longjmp} cannot | |
7764 | in fact be called at the place that would cause a problem. | |
7765 | ||
7766 | Some spurious warnings can be avoided if you declare all the functions | |
7767 | you use that never return as @code{noreturn}. @xref{Function | |
7768 | Attributes}. | |
7769 | ||
7770 | This warning is enabled by @option{-Wall} or @option{-Wextra}. | |
7771 | ||
d77de738 ML |
7772 | @opindex Wunknown-pragmas |
7773 | @opindex Wno-unknown-pragmas | |
7774 | @cindex warning for unknown pragmas | |
7775 | @cindex unknown pragmas, warning | |
7776 | @cindex pragmas, warning of unknown | |
f33d7a88 | 7777 | @item -Wunknown-pragmas |
d77de738 ML |
7778 | Warn when a @code{#pragma} directive is encountered that is not understood by |
7779 | GCC@. If this command-line option is used, warnings are even issued | |
7780 | for unknown pragmas in system header files. This is not the case if | |
7781 | the warnings are only enabled by the @option{-Wall} command-line option. | |
7782 | ||
d77de738 ML |
7783 | @opindex Wno-pragmas |
7784 | @opindex Wpragmas | |
ddf6fe37 | 7785 | @item -Wno-pragmas |
d77de738 ML |
7786 | Do not warn about misuses of pragmas, such as incorrect parameters, |
7787 | invalid syntax, or conflicts between pragmas. See also | |
7788 | @option{-Wunknown-pragmas}. | |
7789 | ||
d77de738 ML |
7790 | @opindex Wno-prio-ctor-dtor |
7791 | @opindex Wprio-ctor-dtor | |
ddf6fe37 | 7792 | @item -Wno-prio-ctor-dtor |
d77de738 ML |
7793 | Do not warn if a priority from 0 to 100 is used for constructor or destructor. |
7794 | The use of constructor and destructor attributes allow you to assign a | |
7795 | priority to the constructor/destructor to control its order of execution | |
7796 | before @code{main} is called or after it returns. The priority values must be | |
7797 | greater than 100 as the compiler reserves priority values between 0--100 for | |
7798 | the implementation. | |
7799 | ||
d77de738 ML |
7800 | @opindex Wstrict-aliasing |
7801 | @opindex Wno-strict-aliasing | |
ddf6fe37 | 7802 | @item -Wstrict-aliasing |
d77de738 ML |
7803 | This option is only active when @option{-fstrict-aliasing} is active. |
7804 | It warns about code that might break the strict aliasing rules that the | |
7805 | compiler is using for optimization. The warning does not catch all | |
7806 | cases, but does attempt to catch the more common pitfalls. It is | |
7807 | included in @option{-Wall}. | |
7808 | It is equivalent to @option{-Wstrict-aliasing=3} | |
7809 | ||
d77de738 | 7810 | @opindex Wstrict-aliasing=n |
ddf6fe37 | 7811 | @item -Wstrict-aliasing=n |
d77de738 ML |
7812 | This option is only active when @option{-fstrict-aliasing} is active. |
7813 | It warns about code that might break the strict aliasing rules that the | |
7814 | compiler is using for optimization. | |
7815 | Higher levels correspond to higher accuracy (fewer false positives). | |
7816 | Higher levels also correspond to more effort, similar to the way @option{-O} | |
7817 | works. | |
7818 | @option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}. | |
7819 | ||
7820 | Level 1: Most aggressive, quick, least accurate. | |
7821 | Possibly useful when higher levels | |
7822 | do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few | |
7823 | false negatives. However, it has many false positives. | |
7824 | Warns for all pointer conversions between possibly incompatible types, | |
7825 | even if never dereferenced. Runs in the front end only. | |
7826 | ||
7827 | Level 2: Aggressive, quick, not too precise. | |
7828 | May still have many false positives (not as many as level 1 though), | |
7829 | and few false negatives (but possibly more than level 1). | |
7830 | Unlike level 1, it only warns when an address is taken. Warns about | |
7831 | incomplete types. Runs in the front end only. | |
7832 | ||
7833 | Level 3 (default for @option{-Wstrict-aliasing}): | |
7834 | Should have very few false positives and few false | |
7835 | negatives. Slightly slower than levels 1 or 2 when optimization is enabled. | |
7836 | Takes care of the common pun+dereference pattern in the front end: | |
7837 | @code{*(int*)&some_float}. | |
7838 | If optimization is enabled, it also runs in the back end, where it deals | |
7839 | with multiple statement cases using flow-sensitive points-to information. | |
7840 | Only warns when the converted pointer is dereferenced. | |
7841 | Does not warn about incomplete types. | |
7842 | ||
d77de738 ML |
7843 | @opindex Wstrict-overflow |
7844 | @opindex Wno-strict-overflow | |
ddf6fe37 AA |
7845 | @item -Wstrict-overflow |
7846 | @itemx -Wstrict-overflow=@var{n} | |
d77de738 ML |
7847 | This option is only active when signed overflow is undefined. |
7848 | It warns about cases where the compiler optimizes based on the | |
7849 | assumption that signed overflow does not occur. Note that it does not | |
7850 | warn about all cases where the code might overflow: it only warns | |
7851 | about cases where the compiler implements some optimization. Thus | |
7852 | this warning depends on the optimization level. | |
7853 | ||
7854 | An optimization that assumes that signed overflow does not occur is | |
7855 | perfectly safe if the values of the variables involved are such that | |
7856 | overflow never does, in fact, occur. Therefore this warning can | |
7857 | easily give a false positive: a warning about code that is not | |
7858 | actually a problem. To help focus on important issues, several | |
7859 | warning levels are defined. No warnings are issued for the use of | |
7860 | undefined signed overflow when estimating how many iterations a loop | |
7861 | requires, in particular when determining whether a loop will be | |
7862 | executed at all. | |
7863 | ||
7864 | @table @gcctabopt | |
7865 | @item -Wstrict-overflow=1 | |
7866 | Warn about cases that are both questionable and easy to avoid. For | |
7867 | example the compiler simplifies | |
7868 | @code{x + 1 > x} to @code{1}. This level of | |
7869 | @option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels | |
7870 | are not, and must be explicitly requested. | |
7871 | ||
7872 | @item -Wstrict-overflow=2 | |
7873 | Also warn about other cases where a comparison is simplified to a | |
7874 | constant. For example: @code{abs (x) >= 0}. This can only be | |
7875 | simplified when signed integer overflow is undefined, because | |
7876 | @code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than | |
7877 | zero. @option{-Wstrict-overflow} (with no level) is the same as | |
7878 | @option{-Wstrict-overflow=2}. | |
7879 | ||
7880 | @item -Wstrict-overflow=3 | |
7881 | Also warn about other cases where a comparison is simplified. For | |
7882 | example: @code{x + 1 > 1} is simplified to @code{x > 0}. | |
7883 | ||
7884 | @item -Wstrict-overflow=4 | |
7885 | Also warn about other simplifications not covered by the above cases. | |
7886 | For example: @code{(x * 10) / 5} is simplified to @code{x * 2}. | |
7887 | ||
7888 | @item -Wstrict-overflow=5 | |
7889 | Also warn about cases where the compiler reduces the magnitude of a | |
7890 | constant involved in a comparison. For example: @code{x + 2 > y} is | |
7891 | simplified to @code{x + 1 >= y}. This is reported only at the | |
7892 | highest warning level because this simplification applies to many | |
7893 | comparisons, so this warning level gives a very large number of | |
7894 | false positives. | |
7895 | @end table | |
7896 | ||
d77de738 ML |
7897 | @opindex Wstring-compare |
7898 | @opindex Wno-string-compare | |
ddf6fe37 | 7899 | @item -Wstring-compare |
d77de738 ML |
7900 | Warn for calls to @code{strcmp} and @code{strncmp} whose result is |
7901 | determined to be either zero or non-zero in tests for such equality | |
7902 | owing to the length of one argument being greater than the size of | |
7903 | the array the other argument is stored in (or the bound in the case | |
7904 | of @code{strncmp}). Such calls could be mistakes. For example, | |
7905 | the call to @code{strcmp} below is diagnosed because its result is | |
7906 | necessarily non-zero irrespective of the contents of the array @code{a}. | |
7907 | ||
7908 | @smallexample | |
7909 | extern char a[4]; | |
7910 | void f (char *d) | |
7911 | @{ | |
7912 | strcpy (d, "string"); | |
7913 | @dots{} | |
7914 | if (0 == strcmp (a, d)) // cannot be true | |
7915 | puts ("a and d are the same"); | |
7916 | @} | |
7917 | @end smallexample | |
7918 | ||
7919 | @option{-Wstring-compare} is enabled by @option{-Wextra}. | |
7920 | ||
ddf6fe37 AA |
7921 | @opindex Wstringop-overflow |
7922 | @opindex Wno-stringop-overflow | |
d77de738 ML |
7923 | @item -Wno-stringop-overflow |
7924 | @item -Wstringop-overflow | |
7925 | @itemx -Wstringop-overflow=@var{type} | |
d77de738 ML |
7926 | Warn for calls to string manipulation functions such as @code{memcpy} and |
7927 | @code{strcpy} that are determined to overflow the destination buffer. The | |
7928 | optional argument is one greater than the type of Object Size Checking to | |
7929 | perform to determine the size of the destination. @xref{Object Size Checking}. | |
7930 | The argument is meaningful only for functions that operate on character arrays | |
7931 | but not for raw memory functions like @code{memcpy} which always make use | |
7932 | of Object Size type-0. The option also warns for calls that specify a size | |
7933 | in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes. | |
7934 | The option produces the best results with optimization enabled but can detect | |
7935 | a small subset of simple buffer overflows even without optimization in | |
7936 | calls to the GCC built-in functions like @code{__builtin_memcpy} that | |
7937 | correspond to the standard functions. In any case, the option warns about | |
7938 | just a subset of buffer overflows detected by the corresponding overflow | |
7939 | checking built-ins. For example, the option issues a warning for | |
7940 | the @code{strcpy} call below because it copies at least 5 characters | |
7941 | (the string @code{"blue"} including the terminating NUL) into the buffer | |
7942 | of size 4. | |
7943 | ||
7944 | @smallexample | |
7945 | enum Color @{ blue, purple, yellow @}; | |
7946 | const char* f (enum Color clr) | |
7947 | @{ | |
7948 | static char buf [4]; | |
7949 | const char *str; | |
7950 | switch (clr) | |
7951 | @{ | |
7952 | case blue: str = "blue"; break; | |
7953 | case purple: str = "purple"; break; | |
7954 | case yellow: str = "yellow"; break; | |
7955 | @} | |
7956 | ||
7957 | return strcpy (buf, str); // warning here | |
7958 | @} | |
7959 | @end smallexample | |
7960 | ||
7961 | Option @option{-Wstringop-overflow=2} is enabled by default. | |
7962 | ||
7963 | @table @gcctabopt | |
d77de738 ML |
7964 | @opindex Wstringop-overflow |
7965 | @opindex Wno-stringop-overflow | |
ddf6fe37 AA |
7966 | @item -Wstringop-overflow |
7967 | @itemx -Wstringop-overflow=1 | |
d77de738 ML |
7968 | The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking |
7969 | to determine the sizes of destination objects. At this setting the option | |
7970 | does not warn for writes past the end of subobjects of larger objects accessed | |
7971 | by pointers unless the size of the largest surrounding object is known. When | |
7972 | the destination may be one of several objects it is assumed to be the largest | |
7973 | one of them. On Linux systems, when optimization is enabled at this setting | |
7974 | the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro | |
7975 | is defined to a non-zero value. | |
7976 | ||
7977 | @item -Wstringop-overflow=2 | |
7978 | The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking | |
7979 | to determine the sizes of destination objects. At this setting the option | |
7980 | warns about overflows when writing to members of the largest complete | |
7981 | objects whose exact size is known. However, it does not warn for excessive | |
7982 | writes to the same members of unknown objects referenced by pointers since | |
7983 | they may point to arrays containing unknown numbers of elements. This is | |
7984 | the default setting of the option. | |
7985 | ||
7986 | @item -Wstringop-overflow=3 | |
7987 | The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking | |
7988 | to determine the sizes of destination objects. At this setting the option | |
7989 | warns about overflowing the smallest object or data member. This is the | |
7990 | most restrictive setting of the option that may result in warnings for safe | |
7991 | code. | |
7992 | ||
7993 | @item -Wstringop-overflow=4 | |
7994 | The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking | |
7995 | to determine the sizes of destination objects. At this setting the option | |
7996 | warns about overflowing any data members, and when the destination is | |
7997 | one of several objects it uses the size of the largest of them to decide | |
7998 | whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this | |
7999 | setting of the option may result in warnings for benign code. | |
8000 | @end table | |
8001 | ||
d77de738 ML |
8002 | @opindex Wstringop-overread |
8003 | @opindex Wno-stringop-overread | |
ddf6fe37 | 8004 | @item -Wno-stringop-overread |
d77de738 ML |
8005 | Warn for calls to string manipulation functions such as @code{memchr}, or |
8006 | @code{strcpy} that are determined to read past the end of the source | |
8007 | sequence. | |
8008 | ||
8009 | Option @option{-Wstringop-overread} is enabled by default. | |
8010 | ||
d77de738 ML |
8011 | @opindex Wstringop-truncation |
8012 | @opindex Wno-stringop-truncation | |
ddf6fe37 | 8013 | @item -Wno-stringop-truncation |
d77de738 ML |
8014 | Do not warn for calls to bounded string manipulation functions |
8015 | such as @code{strncat}, | |
8016 | @code{strncpy}, and @code{stpncpy} that may either truncate the copied string | |
8017 | or leave the destination unchanged. | |
8018 | ||
8019 | In the following example, the call to @code{strncat} specifies a bound that | |
8020 | is less than the length of the source string. As a result, the copy of | |
8021 | the source will be truncated and so the call is diagnosed. To avoid the | |
8022 | warning use @code{bufsize - strlen (buf) - 1)} as the bound. | |
8023 | ||
8024 | @smallexample | |
8025 | void append (char *buf, size_t bufsize) | |
8026 | @{ | |
8027 | strncat (buf, ".txt", 3); | |
8028 | @} | |
8029 | @end smallexample | |
8030 | ||
8031 | As another example, the following call to @code{strncpy} results in copying | |
8032 | to @code{d} just the characters preceding the terminating NUL, without | |
8033 | appending the NUL to the end. Assuming the result of @code{strncpy} is | |
8034 | necessarily a NUL-terminated string is a common mistake, and so the call | |
8035 | is diagnosed. To avoid the warning when the result is not expected to be | |
8036 | NUL-terminated, call @code{memcpy} instead. | |
8037 | ||
8038 | @smallexample | |
8039 | void copy (char *d, const char *s) | |
8040 | @{ | |
8041 | strncpy (d, s, strlen (s)); | |
8042 | @} | |
8043 | @end smallexample | |
8044 | ||
8045 | In the following example, the call to @code{strncpy} specifies the size | |
8046 | of the destination buffer as the bound. If the length of the source | |
8047 | string is equal to or greater than this size the result of the copy will | |
8048 | not be NUL-terminated. Therefore, the call is also diagnosed. To avoid | |
8049 | the warning, specify @code{sizeof buf - 1} as the bound and set the last | |
8050 | element of the buffer to @code{NUL}. | |
8051 | ||
8052 | @smallexample | |
8053 | void copy (const char *s) | |
8054 | @{ | |
8055 | char buf[80]; | |
8056 | strncpy (buf, s, sizeof buf); | |
8057 | @dots{} | |
8058 | @} | |
8059 | @end smallexample | |
8060 | ||
8061 | In situations where a character array is intended to store a sequence | |
8062 | of bytes with no terminating @code{NUL} such an array may be annotated | |
8063 | with attribute @code{nonstring} to avoid this warning. Such arrays, | |
8064 | however, are not suitable arguments to functions that expect | |
8065 | @code{NUL}-terminated strings. To help detect accidental misuses of | |
8066 | such arrays GCC issues warnings unless it can prove that the use is | |
8067 | safe. @xref{Common Variable Attributes}. | |
8068 | ||
2a27ae32 QZ |
8069 | @opindex Wstrict-flex-arrays |
8070 | @opindex Wno-strict-flex-arrays | |
ddf6fe37 | 8071 | @item -Wstrict-flex-arrays |
2a27ae32 QZ |
8072 | Warn about inproper usages of flexible array members |
8073 | according to the @var{level} of the @code{strict_flex_array (@var{level})} | |
8074 | attribute attached to the trailing array field of a structure if it's | |
8075 | available, otherwise according to the @var{level} of the option | |
8076 | @option{-fstrict-flex-arrays=@var{level}}. | |
8077 | ||
8078 | This option is effective only when @var{level} is bigger than 0. Otherwise, | |
8079 | it will be ignored with a warning. | |
8080 | ||
8081 | when @var{level}=1, warnings will be issued for a trailing array reference | |
8082 | of a structure that have 2 or more elements if the trailing array is referenced | |
8083 | as a flexible array member. | |
8084 | ||
8085 | when @var{level}=2, in addition to @var{level}=1, additional warnings will be | |
8086 | issued for a trailing one-element array reference of a structure | |
8087 | if the array is referenced as a flexible array member. | |
8088 | ||
8089 | when @var{level}=3, in addition to @var{level}=2, additional warnings will be | |
8090 | issued for a trailing zero-length array reference of a structure | |
8091 | if the array is referenced as a flexible array member. | |
8092 | ||
8093 | ||
d77de738 ML |
8094 | @opindex Wsuggest-attribute= |
8095 | @opindex Wno-suggest-attribute= | |
53ba8d66 | 8096 | @item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}returns_nonnull@r{|} |
d77de738 ML |
8097 | Warn for cases where adding an attribute may be beneficial. The |
8098 | attributes currently supported are listed below. | |
8099 | ||
8100 | @table @gcctabopt | |
d77de738 ML |
8101 | @opindex Wsuggest-attribute=pure |
8102 | @opindex Wno-suggest-attribute=pure | |
8103 | @opindex Wsuggest-attribute=const | |
8104 | @opindex Wno-suggest-attribute=const | |
8105 | @opindex Wsuggest-attribute=noreturn | |
8106 | @opindex Wno-suggest-attribute=noreturn | |
8107 | @opindex Wmissing-noreturn | |
8108 | @opindex Wno-missing-noreturn | |
8109 | @opindex Wsuggest-attribute=malloc | |
8110 | @opindex Wno-suggest-attribute=malloc | |
ddf6fe37 AA |
8111 | @item -Wsuggest-attribute=pure |
8112 | @itemx -Wsuggest-attribute=const | |
8113 | @itemx -Wsuggest-attribute=noreturn | |
8114 | @itemx -Wmissing-noreturn | |
8115 | @itemx -Wsuggest-attribute=malloc | |
53ba8d66 JH |
8116 | @itemx -Wsuggest-attribute=returns_nonnull |
8117 | @itemx -Wno-suggest-attribute=returns_nonnull | |
d77de738 ML |
8118 | |
8119 | Warn about functions that might be candidates for attributes | |
53ba8d66 | 8120 | @code{pure}, @code{const}, @code{noreturn}, @code{malloc} or @code{returns_nonnull}. The compiler |
d77de738 ML |
8121 | only warns for functions visible in other compilation units or (in the case of |
8122 | @code{pure} and @code{const}) if it cannot prove that the function returns | |
8123 | normally. A function returns normally if it doesn't contain an infinite loop or | |
8124 | return abnormally by throwing, calling @code{abort} or trapping. This analysis | |
8125 | requires option @option{-fipa-pure-const}, which is enabled by default at | |
8126 | @option{-O} and higher. Higher optimization levels improve the accuracy | |
8127 | of the analysis. | |
8128 | ||
d77de738 ML |
8129 | @opindex Wsuggest-attribute=format |
8130 | @opindex Wmissing-format-attribute | |
8131 | @opindex Wno-suggest-attribute=format | |
8132 | @opindex Wno-missing-format-attribute | |
8133 | @opindex Wformat | |
8134 | @opindex Wno-format | |
ddf6fe37 AA |
8135 | @item -Wsuggest-attribute=format |
8136 | @itemx -Wmissing-format-attribute | |
d77de738 ML |
8137 | |
8138 | Warn about function pointers that might be candidates for @code{format} | |
8139 | attributes. Note these are only possible candidates, not absolute ones. | |
8140 | GCC guesses that function pointers with @code{format} attributes that | |
8141 | are used in assignment, initialization, parameter passing or return | |
8142 | statements should have a corresponding @code{format} attribute in the | |
8143 | resulting type. I.e.@: the left-hand side of the assignment or | |
8144 | initialization, the type of the parameter variable, or the return type | |
8145 | of the containing function respectively should also have a @code{format} | |
8146 | attribute to avoid the warning. | |
8147 | ||
8148 | GCC also warns about function definitions that might be | |
8149 | candidates for @code{format} attributes. Again, these are only | |
8150 | possible candidates. GCC guesses that @code{format} attributes | |
8151 | might be appropriate for any function that calls a function like | |
8152 | @code{vprintf} or @code{vscanf}, but this might not always be the | |
8153 | case, and some functions for which @code{format} attributes are | |
8154 | appropriate may not be detected. | |
8155 | ||
d77de738 ML |
8156 | @opindex Wsuggest-attribute=cold |
8157 | @opindex Wno-suggest-attribute=cold | |
ddf6fe37 | 8158 | @item -Wsuggest-attribute=cold |
d77de738 ML |
8159 | |
8160 | Warn about functions that might be candidates for @code{cold} attribute. This | |
8161 | is based on static detection and generally only warns about functions which | |
8162 | always leads to a call to another @code{cold} function such as wrappers of | |
8163 | C++ @code{throw} or fatal error reporting functions leading to @code{abort}. | |
8164 | @end table | |
8165 | ||
d880e093 MU |
8166 | @opindex Wno-alloc-size |
8167 | @opindex Walloc-size | |
8168 | @item -Walloc-size | |
8169 | Warn about calls to allocation functions decorated with attribute | |
8170 | @code{alloc_size} that specify insufficient size for the target type of | |
8171 | the pointer the result is assigned to, including those to the built-in | |
8172 | forms of the functions @code{aligned_alloc}, @code{alloca}, | |
8173 | @code{calloc}, | |
8174 | @code{malloc}, and @code{realloc}. | |
8175 | ||
d77de738 ML |
8176 | @opindex Wno-alloc-zero |
8177 | @opindex Walloc-zero | |
ddf6fe37 | 8178 | @item -Walloc-zero |
d77de738 ML |
8179 | Warn about calls to allocation functions decorated with attribute |
8180 | @code{alloc_size} that specify zero bytes, including those to the built-in | |
8181 | forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc}, | |
8182 | @code{malloc}, and @code{realloc}. Because the behavior of these functions | |
8183 | when called with a zero size differs among implementations (and in the case | |
8184 | of @code{realloc} has been deprecated) relying on it may result in subtle | |
8185 | portability bugs and should be avoided. | |
8186 | ||
d77de738 ML |
8187 | @opindex Walloc-size-larger-than= |
8188 | @opindex Wno-alloc-size-larger-than | |
ddf6fe37 | 8189 | @item -Walloc-size-larger-than=@var{byte-size} |
d77de738 ML |
8190 | Warn about calls to functions decorated with attribute @code{alloc_size} |
8191 | that attempt to allocate objects larger than the specified number of bytes, | |
8192 | or where the result of the size computation in an integer type with infinite | |
8193 | precision would exceed the value of @samp{PTRDIFF_MAX} on the target. | |
8194 | @option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8195 | Warnings controlled by the option can be disabled either by specifying | |
8196 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8197 | @option{-Wno-alloc-size-larger-than}. | |
8198 | @xref{Function Attributes}. | |
8199 | ||
d77de738 | 8200 | @opindex Wno-alloc-size-larger-than |
ddf6fe37 | 8201 | @item -Wno-alloc-size-larger-than |
d77de738 ML |
8202 | Disable @option{-Walloc-size-larger-than=} warnings. The option is |
8203 | equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or | |
8204 | larger. | |
8205 | ||
d77de738 ML |
8206 | @opindex Wno-alloca |
8207 | @opindex Walloca | |
ddf6fe37 | 8208 | @item -Walloca |
d77de738 ML |
8209 | This option warns on all uses of @code{alloca} in the source. |
8210 | ||
d77de738 ML |
8211 | @opindex Walloca-larger-than= |
8212 | @opindex Wno-alloca-larger-than | |
ddf6fe37 | 8213 | @item -Walloca-larger-than=@var{byte-size} |
d77de738 ML |
8214 | This option warns on calls to @code{alloca} with an integer argument whose |
8215 | value is either zero, or that is not bounded by a controlling predicate | |
8216 | that limits its value to at most @var{byte-size}. It also warns for calls | |
8217 | to @code{alloca} where the bound value is unknown. Arguments of non-integer | |
8218 | types are considered unbounded even if they appear to be constrained to | |
8219 | the expected range. | |
8220 | ||
8221 | For example, a bounded case of @code{alloca} could be: | |
8222 | ||
8223 | @smallexample | |
8224 | void func (size_t n) | |
8225 | @{ | |
8226 | void *p; | |
8227 | if (n <= 1000) | |
8228 | p = alloca (n); | |
8229 | else | |
8230 | p = malloc (n); | |
8231 | f (p); | |
8232 | @} | |
8233 | @end smallexample | |
8234 | ||
8235 | In the above example, passing @code{-Walloca-larger-than=1000} would not | |
8236 | issue a warning because the call to @code{alloca} is known to be at most | |
8237 | 1000 bytes. However, if @code{-Walloca-larger-than=500} were passed, | |
8238 | the compiler would emit a warning. | |
8239 | ||
8240 | Unbounded uses, on the other hand, are uses of @code{alloca} with no | |
8241 | controlling predicate constraining its integer argument. For example: | |
8242 | ||
8243 | @smallexample | |
8244 | void func () | |
8245 | @{ | |
8246 | void *p = alloca (n); | |
8247 | f (p); | |
8248 | @} | |
8249 | @end smallexample | |
8250 | ||
8251 | If @code{-Walloca-larger-than=500} were passed, the above would trigger | |
8252 | a warning, but this time because of the lack of bounds checking. | |
8253 | ||
8254 | Note, that even seemingly correct code involving signed integers could | |
8255 | cause a warning: | |
8256 | ||
8257 | @smallexample | |
8258 | void func (signed int n) | |
8259 | @{ | |
8260 | if (n < 500) | |
8261 | @{ | |
8262 | p = alloca (n); | |
8263 | f (p); | |
8264 | @} | |
8265 | @} | |
8266 | @end smallexample | |
8267 | ||
8268 | In the above example, @var{n} could be negative, causing a larger than | |
8269 | expected argument to be implicitly cast into the @code{alloca} call. | |
8270 | ||
8271 | This option also warns when @code{alloca} is used in a loop. | |
8272 | ||
8273 | @option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default | |
8274 | but is usually only effective when @option{-ftree-vrp} is active (default | |
8275 | for @option{-O2} and above). | |
8276 | ||
8277 | See also @option{-Wvla-larger-than=}@samp{byte-size}. | |
8278 | ||
d77de738 | 8279 | @opindex Wno-alloca-larger-than |
ddf6fe37 | 8280 | @item -Wno-alloca-larger-than |
d77de738 ML |
8281 | Disable @option{-Walloca-larger-than=} warnings. The option is |
8282 | equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger. | |
8283 | ||
d77de738 ML |
8284 | @opindex Warith-conversion |
8285 | @opindex Wno-arith-conversion | |
ddf6fe37 | 8286 | @item -Warith-conversion |
d77de738 ML |
8287 | Do warn about implicit conversions from arithmetic operations even |
8288 | when conversion of the operands to the same type cannot change their | |
8289 | values. This affects warnings from @option{-Wconversion}, | |
8290 | @option{-Wfloat-conversion}, and @option{-Wsign-conversion}. | |
8291 | ||
8292 | @smallexample | |
8293 | @group | |
8294 | void f (char c, int i) | |
8295 | @{ | |
8296 | c = c + i; // warns with @option{-Wconversion} | |
8297 | c = c + 1; // only warns with @option{-Warith-conversion} | |
8298 | @} | |
8299 | @end group | |
8300 | @end smallexample | |
8301 | ||
d77de738 ML |
8302 | @opindex Wno-array-bounds |
8303 | @opindex Warray-bounds | |
ddf6fe37 AA |
8304 | @item -Warray-bounds |
8305 | @itemx -Warray-bounds=@var{n} | |
d77de738 ML |
8306 | Warn about out of bounds subscripts or offsets into arrays. This warning |
8307 | is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp} | |
8308 | is active (the default for @option{-O2} and above) but a subset of instances | |
8309 | are issued even without optimization. | |
8310 | ||
710c9676 QZ |
8311 | By default, the trailing array of a structure will be treated as a flexible |
8312 | array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}} | |
8313 | if it is declared as either a flexible array member per C99 standard onwards | |
8314 | (@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element | |
8315 | array (@samp{[1]}). As a result, out of bounds subscripts or offsets into | |
8316 | zero-length arrays or one-element arrays are not warned by default. | |
8317 | ||
8318 | You can add the option @option{-fstrict-flex-arrays} or | |
8319 | @option{-fstrict-flex-arrays=@var{level}} to control how this | |
8320 | option treat trailing array of a structure as a flexible array member: | |
8321 | ||
8322 | when @var{level}<=1, no change to the default behavior. | |
8323 | ||
8324 | when @var{level}=2, additional warnings will be issued for out of bounds | |
8325 | subscripts or offsets into one-element arrays; | |
8326 | ||
8327 | when @var{level}=3, in addition to @var{level}=2, additional warnings will be | |
8328 | issued for out of bounds subscripts or offsets into zero-length arrays. | |
8329 | ||
d77de738 ML |
8330 | @table @gcctabopt |
8331 | @item -Warray-bounds=1 | |
8332 | This is the default warning level of @option{-Warray-bounds} and is enabled | |
8333 | by @option{-Wall}; higher levels are not, and must be explicitly requested. | |
8334 | ||
8335 | @item -Warray-bounds=2 | |
710c9676 QZ |
8336 | This warning level also warns about the intermediate results of pointer |
8337 | arithmetic that may yield out of bounds values. This warning level may | |
8338 | give a larger number of false positives and is deactivated by default. | |
d77de738 ML |
8339 | @end table |
8340 | ||
d77de738 ML |
8341 | @opindex Warray-compare |
8342 | @opindex Wno-array-compare | |
ddf6fe37 | 8343 | @item -Warray-compare |
d77de738 ML |
8344 | Warn about equality and relational comparisons between two operands of array |
8345 | type. This comparison was deprecated in C++20. For example: | |
8346 | ||
8347 | @smallexample | |
8348 | int arr1[5]; | |
8349 | int arr2[5]; | |
8350 | bool same = arr1 == arr2; | |
8351 | @end smallexample | |
8352 | ||
8353 | @option{-Warray-compare} is enabled by @option{-Wall}. | |
8354 | ||
ddf6fe37 | 8355 | @opindex Wno-array-parameter |
d77de738 ML |
8356 | @item -Warray-parameter |
8357 | @itemx -Warray-parameter=@var{n} | |
d77de738 ML |
8358 | Warn about redeclarations of functions involving arguments of array or |
8359 | pointer types of inconsistent kinds or forms, and enable the detection | |
8360 | of out-of-bounds accesses to such parameters by warnings such as | |
8361 | @option{-Warray-bounds}. | |
8362 | ||
8363 | If the first function declaration uses the array form the bound specified | |
8364 | in the array is assumed to be the minimum number of elements expected to | |
8365 | be provided in calls to the function and the maximum number of elements | |
8366 | accessed by it. Failing to provide arguments of sufficient size or accessing | |
8367 | more than the maximum number of elements may be diagnosed by warnings such | |
8368 | as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies | |
8369 | involving array parameters declared using the @code{T[static N]} form. | |
8370 | ||
8371 | For example, the warning triggers for the following redeclarations because | |
8372 | the first one allows an array of any size to be passed to @code{f} while | |
8373 | the second one with the keyword @code{static} specifies that the array | |
8374 | argument must have at least four elements. | |
8375 | ||
8376 | @smallexample | |
8377 | void f (int[static 4]); | |
8378 | void f (int[]); // warning (inconsistent array form) | |
8379 | ||
8380 | void g (void) | |
8381 | @{ | |
8382 | int *p = (int *)malloc (4); | |
8383 | f (p); // warning (array too small) | |
8384 | @dots{} | |
8385 | @} | |
8386 | @end smallexample | |
8387 | ||
8388 | At level 2 the warning also triggers for redeclarations involving any other | |
8389 | inconsistency in array or pointer argument forms denoting array sizes. | |
8390 | Pointers and arrays of unspecified bound are considered equivalent and do | |
8391 | not trigger a warning. | |
8392 | ||
8393 | @smallexample | |
8394 | void g (int*); | |
8395 | void g (int[]); // no warning | |
8396 | void g (int[8]); // warning (inconsistent array bound) | |
8397 | @end smallexample | |
8398 | ||
8399 | @option{-Warray-parameter=2} is included in @option{-Wall}. The | |
8400 | @option{-Wvla-parameter} option triggers warnings for similar inconsistencies | |
8401 | involving Variable Length Array arguments. | |
8402 | ||
d77de738 ML |
8403 | @opindex Wattribute-alias |
8404 | @opindex Wno-attribute-alias | |
ddf6fe37 AA |
8405 | @item -Wattribute-alias=@var{n} |
8406 | @itemx -Wno-attribute-alias | |
d77de738 ML |
8407 | Warn about declarations using the @code{alias} and similar attributes whose |
8408 | target is incompatible with the type of the alias. | |
8409 | @xref{Function Attributes,,Declaring Attributes of Functions}. | |
8410 | ||
8411 | @table @gcctabopt | |
8412 | @item -Wattribute-alias=1 | |
8413 | The default warning level of the @option{-Wattribute-alias} option diagnoses | |
8414 | incompatibilities between the type of the alias declaration and that of its | |
8415 | target. Such incompatibilities are typically indicative of bugs. | |
8416 | ||
8417 | @item -Wattribute-alias=2 | |
8418 | ||
8419 | At this level @option{-Wattribute-alias} also diagnoses cases where | |
8420 | the attributes of the alias declaration are more restrictive than the | |
8421 | attributes applied to its target. These mismatches can potentially | |
8422 | result in incorrect code generation. In other cases they may be | |
8423 | benign and could be resolved simply by adding the missing attribute to | |
8424 | the target. For comparison, see the @option{-Wmissing-attributes} | |
8425 | option, which controls diagnostics when the alias declaration is less | |
8426 | restrictive than the target, rather than more restrictive. | |
8427 | ||
8428 | Attributes considered include @code{alloc_align}, @code{alloc_size}, | |
8429 | @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc}, | |
8430 | @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure}, | |
8431 | @code{returns_nonnull}, and @code{returns_twice}. | |
8432 | @end table | |
8433 | ||
8434 | @option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}. | |
8435 | This is the default. You can disable these warnings with either | |
8436 | @option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}. | |
8437 | ||
d77de738 ML |
8438 | @opindex Wbidi-chars= |
8439 | @opindex Wbidi-chars | |
8440 | @opindex Wno-bidi-chars | |
ddf6fe37 | 8441 | @item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]} |
d77de738 ML |
8442 | Warn about possibly misleading UTF-8 bidirectional control characters in |
8443 | comments, string literals, character constants, and identifiers. Such | |
8444 | characters can change left-to-right writing direction into right-to-left | |
8445 | (and vice versa), which can cause confusion between the logical order and | |
8446 | visual order. This may be dangerous; for instance, it may seem that a piece | |
8447 | of code is not commented out, whereas it in fact is. | |
8448 | ||
8449 | There are three levels of warning supported by GCC@. The default is | |
8450 | @option{-Wbidi-chars=unpaired}, which warns about improperly terminated | |
8451 | bidi contexts. @option{-Wbidi-chars=none} turns the warning off. | |
8452 | @option{-Wbidi-chars=any} warns about any use of bidirectional control | |
8453 | characters. | |
8454 | ||
8455 | By default, this warning does not warn about UCNs. It is, however, possible | |
8456 | to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or | |
8457 | @option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid, | |
8458 | and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous | |
8459 | @option{-Wbidi-chars=any} was specified. | |
8460 | ||
d77de738 ML |
8461 | @opindex Wno-bool-compare |
8462 | @opindex Wbool-compare | |
ddf6fe37 | 8463 | @item -Wbool-compare |
d77de738 ML |
8464 | Warn about boolean expression compared with an integer value different from |
8465 | @code{true}/@code{false}. For instance, the following comparison is | |
8466 | always false: | |
8467 | @smallexample | |
8468 | int n = 5; | |
8469 | @dots{} | |
8470 | if ((n > 1) == 2) @{ @dots{} @} | |
8471 | @end smallexample | |
8472 | This warning is enabled by @option{-Wall}. | |
8473 | ||
d77de738 ML |
8474 | @opindex Wno-bool-operation |
8475 | @opindex Wbool-operation | |
ddf6fe37 | 8476 | @item -Wbool-operation |
d77de738 ML |
8477 | Warn about suspicious operations on expressions of a boolean type. For |
8478 | instance, bitwise negation of a boolean is very likely a bug in the program. | |
8479 | For C, this warning also warns about incrementing or decrementing a boolean, | |
8480 | which rarely makes sense. (In C++, decrementing a boolean is always invalid. | |
8481 | Incrementing a boolean is invalid in C++17, and deprecated otherwise.) | |
8482 | ||
8483 | This warning is enabled by @option{-Wall}. | |
8484 | ||
d77de738 ML |
8485 | @opindex Wno-duplicated-branches |
8486 | @opindex Wduplicated-branches | |
ddf6fe37 | 8487 | @item -Wduplicated-branches |
d77de738 ML |
8488 | Warn when an if-else has identical branches. This warning detects cases like |
8489 | @smallexample | |
8490 | if (p != NULL) | |
8491 | return 0; | |
8492 | else | |
8493 | return 0; | |
8494 | @end smallexample | |
8495 | It doesn't warn when both branches contain just a null statement. This warning | |
8496 | also warn for conditional operators: | |
8497 | @smallexample | |
8498 | int i = x ? *p : *p; | |
8499 | @end smallexample | |
8500 | ||
d77de738 ML |
8501 | @opindex Wno-duplicated-cond |
8502 | @opindex Wduplicated-cond | |
ddf6fe37 | 8503 | @item -Wduplicated-cond |
d77de738 ML |
8504 | Warn about duplicated conditions in an if-else-if chain. For instance, |
8505 | warn for the following code: | |
8506 | @smallexample | |
8507 | if (p->q != NULL) @{ @dots{} @} | |
8508 | else if (p->q != NULL) @{ @dots{} @} | |
8509 | @end smallexample | |
8510 | ||
d77de738 ML |
8511 | @opindex Wno-frame-address |
8512 | @opindex Wframe-address | |
ddf6fe37 | 8513 | @item -Wframe-address |
d77de738 ML |
8514 | Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address} |
8515 | is called with an argument greater than 0. Such calls may return indeterminate | |
8516 | values or crash the program. The warning is included in @option{-Wall}. | |
8517 | ||
d77de738 ML |
8518 | @opindex Wno-discarded-qualifiers |
8519 | @opindex Wdiscarded-qualifiers | |
ddf6fe37 | 8520 | @item -Wno-discarded-qualifiers @r{(C and Objective-C only)} |
d77de738 ML |
8521 | Do not warn if type qualifiers on pointers are being discarded. |
8522 | Typically, the compiler warns if a @code{const char *} variable is | |
8523 | passed to a function that takes a @code{char *} parameter. This option | |
8524 | can be used to suppress such a warning. | |
8525 | ||
d77de738 ML |
8526 | @opindex Wno-discarded-array-qualifiers |
8527 | @opindex Wdiscarded-array-qualifiers | |
ddf6fe37 | 8528 | @item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)} |
d77de738 ML |
8529 | Do not warn if type qualifiers on arrays which are pointer targets |
8530 | are being discarded. Typically, the compiler warns if a | |
8531 | @code{const int (*)[]} variable is passed to a function that | |
8532 | takes a @code{int (*)[]} parameter. This option can be used to | |
8533 | suppress such a warning. | |
8534 | ||
d77de738 ML |
8535 | @opindex Wno-incompatible-pointer-types |
8536 | @opindex Wincompatible-pointer-types | |
ddf6fe37 | 8537 | @item -Wno-incompatible-pointer-types @r{(C and Objective-C only)} |
d77de738 ML |
8538 | Do not warn when there is a conversion between pointers that have incompatible |
8539 | types. This warning is for cases not covered by @option{-Wno-pointer-sign}, | |
8540 | which warns for pointer argument passing or assignment with different | |
8541 | signedness. | |
8542 | ||
5fccebdb JM |
8543 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8544 | ||
d77de738 ML |
8545 | @opindex Wno-int-conversion |
8546 | @opindex Wint-conversion | |
ddf6fe37 | 8547 | @item -Wno-int-conversion @r{(C and Objective-C only)} |
d77de738 ML |
8548 | Do not warn about incompatible integer to pointer and pointer to integer |
8549 | conversions. This warning is about implicit conversions; for explicit | |
8550 | conversions the warnings @option{-Wno-int-to-pointer-cast} and | |
8551 | @option{-Wno-pointer-to-int-cast} may be used. | |
8552 | ||
5fccebdb JM |
8553 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8554 | ||
d77de738 ML |
8555 | @opindex Wzero-length-bounds |
8556 | @opindex Wzero-length-bounds | |
ddf6fe37 | 8557 | @item -Wzero-length-bounds |
d77de738 ML |
8558 | Warn about accesses to elements of zero-length array members that might |
8559 | overlap other members of the same object. Declaring interior zero-length | |
8e9c65d3 | 8560 | arrays is discouraged because accesses to them are undefined. |
d77de738 ML |
8561 | @xref{Zero Length}. |
8562 | ||
8563 | For example, the first two stores in function @code{bad} are diagnosed | |
8564 | because the array elements overlap the subsequent members @code{b} and | |
8565 | @code{c}. The third store is diagnosed by @option{-Warray-bounds} | |
8566 | because it is beyond the bounds of the enclosing object. | |
8567 | ||
8568 | @smallexample | |
8569 | struct X @{ int a[0]; int b, c; @}; | |
8570 | struct X x; | |
8571 | ||
8572 | void bad (void) | |
8573 | @{ | |
8574 | x.a[0] = 0; // -Wzero-length-bounds | |
8575 | x.a[1] = 1; // -Wzero-length-bounds | |
8576 | x.a[2] = 2; // -Warray-bounds | |
8577 | @} | |
8578 | @end smallexample | |
8579 | ||
8580 | Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}. | |
8581 | ||
d77de738 ML |
8582 | @opindex Wno-div-by-zero |
8583 | @opindex Wdiv-by-zero | |
ddf6fe37 | 8584 | @item -Wno-div-by-zero |
d77de738 ML |
8585 | Do not warn about compile-time integer division by zero. Floating-point |
8586 | division by zero is not warned about, as it can be a legitimate way of | |
8587 | obtaining infinities and NaNs. | |
8588 | ||
d77de738 ML |
8589 | @opindex Wsystem-headers |
8590 | @opindex Wno-system-headers | |
8591 | @cindex warnings from system headers | |
8592 | @cindex system headers, warnings from | |
f33d7a88 | 8593 | @item -Wsystem-headers |
d77de738 ML |
8594 | Print warning messages for constructs found in system header files. |
8595 | Warnings from system headers are normally suppressed, on the assumption | |
8596 | that they usually do not indicate real problems and would only make the | |
8597 | compiler output harder to read. Using this command-line option tells | |
8598 | GCC to emit warnings from system headers as if they occurred in user | |
8599 | code. However, note that using @option{-Wall} in conjunction with this | |
8600 | option does @emph{not} warn about unknown pragmas in system | |
8601 | headers---for that, @option{-Wunknown-pragmas} must also be used. | |
8602 | ||
d77de738 ML |
8603 | @opindex Wtautological-compare |
8604 | @opindex Wno-tautological-compare | |
ddf6fe37 | 8605 | @item -Wtautological-compare |
d77de738 ML |
8606 | Warn if a self-comparison always evaluates to true or false. This |
8607 | warning detects various mistakes such as: | |
8608 | @smallexample | |
8609 | int i = 1; | |
8610 | @dots{} | |
8611 | if (i > i) @{ @dots{} @} | |
8612 | @end smallexample | |
8613 | ||
8614 | This warning also warns about bitwise comparisons that always evaluate | |
8615 | to true or false, for instance: | |
8616 | @smallexample | |
8617 | if ((a & 16) == 10) @{ @dots{} @} | |
8618 | @end smallexample | |
8619 | will always be false. | |
8620 | ||
8621 | This warning is enabled by @option{-Wall}. | |
8622 | ||
d77de738 ML |
8623 | @opindex Wtrampolines |
8624 | @opindex Wno-trampolines | |
ddf6fe37 | 8625 | @item -Wtrampolines |
d77de738 ML |
8626 | Warn about trampolines generated for pointers to nested functions. |
8627 | A trampoline is a small piece of data or code that is created at run | |
8628 | time on the stack when the address of a nested function is taken, and is | |
8629 | used to call the nested function indirectly. For some targets, it is | |
8630 | made up of data only and thus requires no special treatment. But, for | |
8631 | most targets, it is made up of code and thus requires the stack to be | |
8632 | made executable in order for the program to work properly. | |
8633 | ||
d77de738 ML |
8634 | @opindex Wfloat-equal |
8635 | @opindex Wno-float-equal | |
ddf6fe37 | 8636 | @item -Wfloat-equal |
d77de738 ML |
8637 | Warn if floating-point values are used in equality comparisons. |
8638 | ||
8639 | The idea behind this is that sometimes it is convenient (for the | |
8640 | programmer) to consider floating-point values as approximations to | |
8641 | infinitely precise real numbers. If you are doing this, then you need | |
8642 | to compute (by analyzing the code, or in some other way) the maximum or | |
8643 | likely maximum error that the computation introduces, and allow for it | |
8644 | when performing comparisons (and when producing output, but that's a | |
8645 | different problem). In particular, instead of testing for equality, you | |
8646 | should check to see whether the two values have ranges that overlap; and | |
8647 | this is done with the relational operators, so equality comparisons are | |
8648 | probably mistaken. | |
8649 | ||
d77de738 ML |
8650 | @opindex Wtraditional |
8651 | @opindex Wno-traditional | |
ddf6fe37 | 8652 | @item -Wtraditional @r{(C and Objective-C only)} |
d77de738 ML |
8653 | Warn about certain constructs that behave differently in traditional and |
8654 | ISO C@. Also warn about ISO C constructs that have no traditional C | |
8655 | equivalent, and/or problematic constructs that should be avoided. | |
8656 | ||
8657 | @itemize @bullet | |
8658 | @item | |
8659 | Macro parameters that appear within string literals in the macro body. | |
8660 | In traditional C macro replacement takes place within string literals, | |
8661 | but in ISO C it does not. | |
8662 | ||
8663 | @item | |
8664 | In traditional C, some preprocessor directives did not exist. | |
8665 | Traditional preprocessors only considered a line to be a directive | |
8666 | if the @samp{#} appeared in column 1 on the line. Therefore | |
8667 | @option{-Wtraditional} warns about directives that traditional C | |
8668 | understands but ignores because the @samp{#} does not appear as the | |
8669 | first character on the line. It also suggests you hide directives like | |
8670 | @code{#pragma} not understood by traditional C by indenting them. Some | |
8671 | traditional implementations do not recognize @code{#elif}, so this option | |
8672 | suggests avoiding it altogether. | |
8673 | ||
8674 | @item | |
8675 | A function-like macro that appears without arguments. | |
8676 | ||
8677 | @item | |
8678 | The unary plus operator. | |
8679 | ||
8680 | @item | |
8681 | The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point | |
8682 | constant suffixes. (Traditional C does support the @samp{L} suffix on integer | |
8683 | constants.) Note, these suffixes appear in macros defined in the system | |
8684 | headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}. | |
8685 | Use of these macros in user code might normally lead to spurious | |
8686 | warnings, however GCC's integrated preprocessor has enough context to | |
8687 | avoid warning in these cases. | |
8688 | ||
8689 | @item | |
8690 | A function declared external in one block and then used after the end of | |
8691 | the block. | |
8692 | ||
8693 | @item | |
8694 | A @code{switch} statement has an operand of type @code{long}. | |
8695 | ||
8696 | @item | |
8697 | A non-@code{static} function declaration follows a @code{static} one. | |
8698 | This construct is not accepted by some traditional C compilers. | |
8699 | ||
8700 | @item | |
8701 | The ISO type of an integer constant has a different width or | |
8702 | signedness from its traditional type. This warning is only issued if | |
8703 | the base of the constant is ten. I.e.@: hexadecimal or octal values, which | |
8704 | typically represent bit patterns, are not warned about. | |
8705 | ||
8706 | @item | |
8707 | Usage of ISO string concatenation is detected. | |
8708 | ||
8709 | @item | |
8710 | Initialization of automatic aggregates. | |
8711 | ||
8712 | @item | |
8713 | Identifier conflicts with labels. Traditional C lacks a separate | |
8714 | namespace for labels. | |
8715 | ||
8716 | @item | |
8717 | Initialization of unions. If the initializer is zero, the warning is | |
8718 | omitted. This is done under the assumption that the zero initializer in | |
8719 | user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing | |
8720 | initializer warnings and relies on default initialization to zero in the | |
8721 | traditional C case. | |
8722 | ||
8723 | @item | |
8724 | Conversions by prototypes between fixed/floating-point values and vice | |
8725 | versa. The absence of these prototypes when compiling with traditional | |
8726 | C causes serious problems. This is a subset of the possible | |
8727 | conversion warnings; for the full set use @option{-Wtraditional-conversion}. | |
8728 | ||
8729 | @item | |
8730 | Use of ISO C style function definitions. This warning intentionally is | |
8731 | @emph{not} issued for prototype declarations or variadic functions | |
8732 | because these ISO C features appear in your code when using | |
8733 | libiberty's traditional C compatibility macros, @code{PARAMS} and | |
8734 | @code{VPARAMS}. This warning is also bypassed for nested functions | |
8735 | because that feature is already a GCC extension and thus not relevant to | |
8736 | traditional C compatibility. | |
8737 | @end itemize | |
8738 | ||
d77de738 ML |
8739 | @opindex Wtraditional-conversion |
8740 | @opindex Wno-traditional-conversion | |
ddf6fe37 | 8741 | @item -Wtraditional-conversion @r{(C and Objective-C only)} |
d77de738 ML |
8742 | Warn if a prototype causes a type conversion that is different from what |
8743 | would happen to the same argument in the absence of a prototype. This | |
8744 | includes conversions of fixed point to floating and vice versa, and | |
8745 | conversions changing the width or signedness of a fixed-point argument | |
8746 | except when the same as the default promotion. | |
8747 | ||
d77de738 ML |
8748 | @opindex Wdeclaration-after-statement |
8749 | @opindex Wno-declaration-after-statement | |
ddf6fe37 | 8750 | @item -Wdeclaration-after-statement @r{(C and Objective-C only)} |
d77de738 ML |
8751 | Warn when a declaration is found after a statement in a block. This |
8752 | construct, known from C++, was introduced with ISO C99 and is by default | |
8753 | allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}. | |
8754 | ||
5fccebdb JM |
8755 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8756 | ||
d77de738 ML |
8757 | @opindex Wshadow |
8758 | @opindex Wno-shadow | |
ddf6fe37 | 8759 | @item -Wshadow |
d77de738 ML |
8760 | Warn whenever a local variable or type declaration shadows another |
8761 | variable, parameter, type, class member (in C++), or instance variable | |
8762 | (in Objective-C) or whenever a built-in function is shadowed. Note | |
8763 | that in C++, the compiler warns if a local variable shadows an | |
8764 | explicit typedef, but not if it shadows a struct/class/enum. | |
8765 | If this warning is enabled, it includes also all instances of | |
8766 | local shadowing. This means that @option{-Wno-shadow=local} | |
8767 | and @option{-Wno-shadow=compatible-local} are ignored when | |
8768 | @option{-Wshadow} is used. | |
8769 | Same as @option{-Wshadow=global}. | |
8770 | ||
d77de738 ML |
8771 | @opindex Wno-shadow-ivar |
8772 | @opindex Wshadow-ivar | |
ddf6fe37 | 8773 | @item -Wno-shadow-ivar @r{(Objective-C only)} |
d77de738 ML |
8774 | Do not warn whenever a local variable shadows an instance variable in an |
8775 | Objective-C method. | |
8776 | ||
d77de738 | 8777 | @opindex Wshadow=global |
ddf6fe37 | 8778 | @item -Wshadow=global |
d77de738 ML |
8779 | Warn for any shadowing. |
8780 | Same as @option{-Wshadow}. | |
8781 | ||
d77de738 | 8782 | @opindex Wshadow=local |
ddf6fe37 | 8783 | @item -Wshadow=local |
d77de738 ML |
8784 | Warn when a local variable shadows another local variable or parameter. |
8785 | ||
d77de738 | 8786 | @opindex Wshadow=compatible-local |
ddf6fe37 | 8787 | @item -Wshadow=compatible-local |
d77de738 ML |
8788 | Warn when a local variable shadows another local variable or parameter |
8789 | whose type is compatible with that of the shadowing variable. In C++, | |
8790 | type compatibility here means the type of the shadowing variable can be | |
8791 | converted to that of the shadowed variable. The creation of this flag | |
8792 | (in addition to @option{-Wshadow=local}) is based on the idea that when | |
8793 | a local variable shadows another one of incompatible type, it is most | |
8794 | likely intentional, not a bug or typo, as shown in the following example: | |
8795 | ||
8796 | @smallexample | |
8797 | @group | |
8798 | for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i) | |
8799 | @{ | |
8800 | for (int i = 0; i < N; ++i) | |
8801 | @{ | |
8802 | ... | |
8803 | @} | |
8804 | ... | |
8805 | @} | |
8806 | @end group | |
8807 | @end smallexample | |
8808 | ||
8809 | Since the two variable @code{i} in the example above have incompatible types, | |
8810 | enabling only @option{-Wshadow=compatible-local} does not emit a warning. | |
8811 | Because their types are incompatible, if a programmer accidentally uses one | |
8812 | in place of the other, type checking is expected to catch that and emit an | |
8813 | error or warning. Use of this flag instead of @option{-Wshadow=local} can | |
8814 | possibly reduce the number of warnings triggered by intentional shadowing. | |
8815 | Note that this also means that shadowing @code{const char *i} by | |
8816 | @code{char *i} does not emit a warning. | |
8817 | ||
8818 | This warning is also enabled by @option{-Wshadow=local}. | |
8819 | ||
d77de738 ML |
8820 | @opindex Wlarger-than= |
8821 | @opindex Wlarger-than-@var{byte-size} | |
ddf6fe37 | 8822 | @item -Wlarger-than=@var{byte-size} |
d77de738 ML |
8823 | Warn whenever an object is defined whose size exceeds @var{byte-size}. |
8824 | @option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8825 | Warnings controlled by the option can be disabled either by specifying | |
8826 | @var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}. | |
8827 | ||
8828 | Also warn for calls to bounded functions such as @code{memchr} or | |
8829 | @code{strnlen} that specify a bound greater than the largest possible | |
8830 | object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings | |
8831 | can only be disabled by @option{-Wno-larger-than}. | |
8832 | ||
d77de738 | 8833 | @opindex Wno-larger-than |
ddf6fe37 | 8834 | @item -Wno-larger-than |
d77de738 ML |
8835 | Disable @option{-Wlarger-than=} warnings. The option is equivalent |
8836 | to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger. | |
8837 | ||
d77de738 ML |
8838 | @opindex Wframe-larger-than= |
8839 | @opindex Wno-frame-larger-than | |
ddf6fe37 | 8840 | @item -Wframe-larger-than=@var{byte-size} |
d77de738 ML |
8841 | Warn if the size of a function frame exceeds @var{byte-size}. |
8842 | The computation done to determine the stack frame size is approximate | |
8843 | and not conservative. | |
8844 | The actual requirements may be somewhat greater than @var{byte-size} | |
8845 | even if you do not get a warning. In addition, any space allocated | |
8846 | via @code{alloca}, variable-length arrays, or related constructs | |
8847 | is not included by the compiler when determining | |
8848 | whether or not to issue a warning. | |
8849 | @option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8850 | Warnings controlled by the option can be disabled either by specifying | |
8851 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8852 | @option{-Wno-frame-larger-than}. | |
8853 | ||
d77de738 | 8854 | @opindex Wno-frame-larger-than |
ddf6fe37 | 8855 | @item -Wno-frame-larger-than |
d77de738 ML |
8856 | Disable @option{-Wframe-larger-than=} warnings. The option is equivalent |
8857 | to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger. | |
8858 | ||
d77de738 ML |
8859 | @opindex Wfree-nonheap-object |
8860 | @opindex Wno-free-nonheap-object | |
ddf6fe37 | 8861 | @item -Wfree-nonheap-object |
d77de738 ML |
8862 | Warn when attempting to deallocate an object that was either not allocated |
8863 | on the heap, or by using a pointer that was not returned from a prior call | |
8864 | to the corresponding allocation function. For example, because the call | |
8865 | to @code{stpcpy} returns a pointer to the terminating nul character and | |
8866 | not to the beginning of the object, the call to @code{free} below is | |
8867 | diagnosed. | |
8868 | ||
8869 | @smallexample | |
8870 | void f (char *p) | |
8871 | @{ | |
8872 | p = stpcpy (p, "abc"); | |
8873 | // ... | |
8874 | free (p); // warning | |
8875 | @} | |
8876 | @end smallexample | |
8877 | ||
8878 | @option{-Wfree-nonheap-object} is included in @option{-Wall}. | |
8879 | ||
d77de738 ML |
8880 | @opindex Wstack-usage |
8881 | @opindex Wno-stack-usage | |
ddf6fe37 | 8882 | @item -Wstack-usage=@var{byte-size} |
d77de738 ML |
8883 | Warn if the stack usage of a function might exceed @var{byte-size}. |
8884 | The computation done to determine the stack usage is conservative. | |
8885 | Any space allocated via @code{alloca}, variable-length arrays, or related | |
8886 | constructs is included by the compiler when determining whether or not to | |
8887 | issue a warning. | |
8888 | ||
8889 | The message is in keeping with the output of @option{-fstack-usage}. | |
8890 | ||
8891 | @itemize | |
8892 | @item | |
8893 | If the stack usage is fully static but exceeds the specified amount, it's: | |
8894 | ||
8895 | @smallexample | |
8896 | warning: stack usage is 1120 bytes | |
8897 | @end smallexample | |
8898 | @item | |
8899 | If the stack usage is (partly) dynamic but bounded, it's: | |
8900 | ||
8901 | @smallexample | |
8902 | warning: stack usage might be 1648 bytes | |
8903 | @end smallexample | |
8904 | @item | |
8905 | If the stack usage is (partly) dynamic and not bounded, it's: | |
8906 | ||
8907 | @smallexample | |
8908 | warning: stack usage might be unbounded | |
8909 | @end smallexample | |
8910 | @end itemize | |
8911 | ||
8912 | @option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default. | |
8913 | Warnings controlled by the option can be disabled either by specifying | |
8914 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8915 | @option{-Wno-stack-usage}. | |
8916 | ||
d77de738 | 8917 | @opindex Wno-stack-usage |
ddf6fe37 | 8918 | @item -Wno-stack-usage |
d77de738 ML |
8919 | Disable @option{-Wstack-usage=} warnings. The option is equivalent |
8920 | to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger. | |
8921 | ||
d77de738 ML |
8922 | @opindex Wunsafe-loop-optimizations |
8923 | @opindex Wno-unsafe-loop-optimizations | |
ddf6fe37 | 8924 | @item -Wunsafe-loop-optimizations |
d77de738 ML |
8925 | Warn if the loop cannot be optimized because the compiler cannot |
8926 | assume anything on the bounds of the loop indices. With | |
8927 | @option{-funsafe-loop-optimizations} warn if the compiler makes | |
8928 | such assumptions. | |
8929 | ||
d77de738 ML |
8930 | @opindex Wno-pedantic-ms-format |
8931 | @opindex Wpedantic-ms-format | |
ddf6fe37 | 8932 | @item -Wno-pedantic-ms-format @r{(MinGW targets only)} |
d77de738 ML |
8933 | When used in combination with @option{-Wformat} |
8934 | and @option{-pedantic} without GNU extensions, this option | |
8935 | disables the warnings about non-ISO @code{printf} / @code{scanf} format | |
8936 | width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets, | |
8937 | which depend on the MS runtime. | |
8938 | ||
d77de738 ML |
8939 | @opindex Wpointer-arith |
8940 | @opindex Wno-pointer-arith | |
ddf6fe37 | 8941 | @item -Wpointer-arith |
d77de738 ML |
8942 | Warn about anything that depends on the ``size of'' a function type or |
8943 | of @code{void}. GNU C assigns these types a size of 1, for | |
8944 | convenience in calculations with @code{void *} pointers and pointers | |
8945 | to functions. In C++, warn also when an arithmetic operation involves | |
8946 | @code{NULL}. This warning is also enabled by @option{-Wpedantic}. | |
8947 | ||
5fccebdb JM |
8948 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8949 | ||
d77de738 ML |
8950 | @opindex Wpointer-compare |
8951 | @opindex Wno-pointer-compare | |
ddf6fe37 | 8952 | @item -Wno-pointer-compare |
d77de738 ML |
8953 | Do not warn if a pointer is compared with a zero character constant. |
8954 | This usually | |
8955 | means that the pointer was meant to be dereferenced. For example: | |
8956 | ||
8957 | @smallexample | |
8958 | const char *p = foo (); | |
8959 | if (p == '\0') | |
8960 | return 42; | |
8961 | @end smallexample | |
8962 | ||
8963 | Note that the code above is invalid in C++11. | |
8964 | ||
8965 | This warning is enabled by default. | |
8966 | ||
d77de738 ML |
8967 | @opindex Wtsan |
8968 | @opindex Wno-tsan | |
ddf6fe37 | 8969 | @item -Wtsan |
d77de738 ML |
8970 | Warn about unsupported features in ThreadSanitizer. |
8971 | ||
8972 | ThreadSanitizer does not support @code{std::atomic_thread_fence} and | |
8973 | can report false positives. | |
8974 | ||
8975 | This warning is enabled by default. | |
8976 | ||
d77de738 ML |
8977 | @opindex Wtype-limits |
8978 | @opindex Wno-type-limits | |
ddf6fe37 | 8979 | @item -Wtype-limits |
d77de738 ML |
8980 | Warn if a comparison is always true or always false due to the limited |
8981 | range of the data type, but do not warn for constant expressions. For | |
8982 | example, warn if an unsigned variable is compared against zero with | |
8983 | @code{<} or @code{>=}. This warning is also enabled by | |
8984 | @option{-Wextra}. | |
8985 | ||
d77de738 ML |
8986 | @opindex Wabsolute-value |
8987 | @opindex Wno-absolute-value | |
ddf6fe37 | 8988 | @item -Wabsolute-value @r{(C and Objective-C only)} |
d77de738 ML |
8989 | Warn for calls to standard functions that compute the absolute value |
8990 | of an argument when a more appropriate standard function is available. | |
8991 | For example, calling @code{abs(3.14)} triggers the warning because the | |
8992 | appropriate function to call to compute the absolute value of a double | |
8993 | argument is @code{fabs}. The option also triggers warnings when the | |
8994 | argument in a call to such a function has an unsigned type. This | |
8995 | warning can be suppressed with an explicit type cast and it is also | |
8996 | enabled by @option{-Wextra}. | |
8997 | ||
8998 | @include cppwarnopts.texi | |
8999 | ||
d77de738 ML |
9000 | @opindex Wbad-function-cast |
9001 | @opindex Wno-bad-function-cast | |
ddf6fe37 | 9002 | @item -Wbad-function-cast @r{(C and Objective-C only)} |
d77de738 ML |
9003 | Warn when a function call is cast to a non-matching type. |
9004 | For example, warn if a call to a function returning an integer type | |
9005 | is cast to a pointer type. | |
9006 | ||
d77de738 ML |
9007 | @opindex Wc90-c99-compat |
9008 | @opindex Wno-c90-c99-compat | |
ddf6fe37 | 9009 | @item -Wc90-c99-compat @r{(C and Objective-C only)} |
d77de738 ML |
9010 | Warn about features not present in ISO C90, but present in ISO C99. |
9011 | For instance, warn about use of variable length arrays, @code{long long} | |
9012 | type, @code{bool} type, compound literals, designated initializers, and so | |
9013 | on. This option is independent of the standards mode. Warnings are disabled | |
9014 | in the expression that follows @code{__extension__}. | |
9015 | ||
d77de738 ML |
9016 | @opindex Wc99-c11-compat |
9017 | @opindex Wno-c99-c11-compat | |
ddf6fe37 | 9018 | @item -Wc99-c11-compat @r{(C and Objective-C only)} |
d77de738 ML |
9019 | Warn about features not present in ISO C99, but present in ISO C11. |
9020 | For instance, warn about use of anonymous structures and unions, | |
9021 | @code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier, | |
9022 | @code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword, | |
9023 | and so on. This option is independent of the standards mode. Warnings are | |
9024 | disabled in the expression that follows @code{__extension__}. | |
9025 | ||
fad61bf7 JM |
9026 | @opindex Wc11-c23-compat |
9027 | @opindex Wno-c11-c23-compat | |
9028 | @item -Wc11-c23-compat @r{(C and Objective-C only)} | |
9029 | @itemx -Wc11-c2x-compat @r{(C and Objective-C only)} | |
9030 | Warn about features not present in ISO C11, but present in ISO C23. | |
d77de738 ML |
9031 | For instance, warn about omitting the string in @code{_Static_assert}, |
9032 | use of @samp{[[]]} syntax for attributes, use of decimal | |
9033 | floating-point types, and so on. This option is independent of the | |
9034 | standards mode. Warnings are disabled in the expression that follows | |
fad61bf7 JM |
9035 | @code{__extension__}. The name @option{-Wc11-c2x-compat} is |
9036 | deprecated. | |
d77de738 | 9037 | |
fad61bf7 | 9038 | When not compiling in C23 mode, these warnings are upgraded to errors |
5fccebdb JM |
9039 | by @option{-pedantic-errors}. |
9040 | ||
d77de738 ML |
9041 | @opindex Wc++-compat |
9042 | @opindex Wno-c++-compat | |
ddf6fe37 | 9043 | @item -Wc++-compat @r{(C and Objective-C only)} |
d77de738 ML |
9044 | Warn about ISO C constructs that are outside of the common subset of |
9045 | ISO C and ISO C++, e.g.@: request for implicit conversion from | |
9046 | @code{void *} to a pointer to non-@code{void} type. | |
9047 | ||
d77de738 ML |
9048 | @opindex Wc++11-compat |
9049 | @opindex Wno-c++11-compat | |
ddf6fe37 | 9050 | @item -Wc++11-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9051 | Warn about C++ constructs whose meaning differs between ISO C++ 1998 |
9052 | and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords | |
9053 | in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is | |
9054 | enabled by @option{-Wall}. | |
9055 | ||
d77de738 ML |
9056 | @opindex Wc++14-compat |
9057 | @opindex Wno-c++14-compat | |
ddf6fe37 | 9058 | @item -Wc++14-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9059 | Warn about C++ constructs whose meaning differs between ISO C++ 2011 |
9060 | and ISO C++ 2014. This warning is enabled by @option{-Wall}. | |
9061 | ||
d77de738 ML |
9062 | @opindex Wc++17-compat |
9063 | @opindex Wno-c++17-compat | |
ddf6fe37 | 9064 | @item -Wc++17-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9065 | Warn about C++ constructs whose meaning differs between ISO C++ 2014 |
9066 | and ISO C++ 2017. This warning is enabled by @option{-Wall}. | |
9067 | ||
d77de738 ML |
9068 | @opindex Wc++20-compat |
9069 | @opindex Wno-c++20-compat | |
ddf6fe37 | 9070 | @item -Wc++20-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9071 | Warn about C++ constructs whose meaning differs between ISO C++ 2017 |
9072 | and ISO C++ 2020. This warning is enabled by @option{-Wall}. | |
9073 | ||
d77de738 ML |
9074 | @opindex Wc++11-extensions |
9075 | @opindex Wno-c++11-extensions | |
ddf6fe37 | 9076 | @item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9077 | Do not warn about C++11 constructs in code being compiled using |
9078 | an older C++ standard. Even without this option, some C++11 constructs | |
9079 | will only be diagnosed if @option{-Wpedantic} is used. | |
9080 | ||
d77de738 ML |
9081 | @opindex Wc++14-extensions |
9082 | @opindex Wno-c++14-extensions | |
ddf6fe37 | 9083 | @item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9084 | Do not warn about C++14 constructs in code being compiled using |
9085 | an older C++ standard. Even without this option, some C++14 constructs | |
9086 | will only be diagnosed if @option{-Wpedantic} is used. | |
9087 | ||
d77de738 ML |
9088 | @opindex Wc++17-extensions |
9089 | @opindex Wno-c++17-extensions | |
ddf6fe37 | 9090 | @item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9091 | Do not warn about C++17 constructs in code being compiled using |
9092 | an older C++ standard. Even without this option, some C++17 constructs | |
9093 | will only be diagnosed if @option{-Wpedantic} is used. | |
9094 | ||
d77de738 ML |
9095 | @opindex Wc++20-extensions |
9096 | @opindex Wno-c++20-extensions | |
ddf6fe37 | 9097 | @item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9098 | Do not warn about C++20 constructs in code being compiled using |
9099 | an older C++ standard. Even without this option, some C++20 constructs | |
9100 | will only be diagnosed if @option{-Wpedantic} is used. | |
9101 | ||
d77de738 ML |
9102 | @opindex Wc++23-extensions |
9103 | @opindex Wno-c++23-extensions | |
ddf6fe37 | 9104 | @item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9105 | Do not warn about C++23 constructs in code being compiled using |
9106 | an older C++ standard. Even without this option, some C++23 constructs | |
9107 | will only be diagnosed if @option{-Wpedantic} is used. | |
9108 | ||
d77de738 ML |
9109 | @opindex Wcast-qual |
9110 | @opindex Wno-cast-qual | |
ddf6fe37 | 9111 | @item -Wcast-qual |
d77de738 ML |
9112 | Warn whenever a pointer is cast so as to remove a type qualifier from |
9113 | the target type. For example, warn if a @code{const char *} is cast | |
9114 | to an ordinary @code{char *}. | |
9115 | ||
9116 | Also warn when making a cast that introduces a type qualifier in an | |
9117 | unsafe way. For example, casting @code{char **} to @code{const char **} | |
9118 | is unsafe, as in this example: | |
9119 | ||
9120 | @smallexample | |
9121 | /* p is char ** value. */ | |
9122 | const char **q = (const char **) p; | |
9123 | /* Assignment of readonly string to const char * is OK. */ | |
9124 | *q = "string"; | |
9125 | /* Now char** pointer points to read-only memory. */ | |
9126 | **p = 'b'; | |
9127 | @end smallexample | |
9128 | ||
d77de738 ML |
9129 | @opindex Wcast-align |
9130 | @opindex Wno-cast-align | |
ddf6fe37 | 9131 | @item -Wcast-align |
d77de738 ML |
9132 | Warn whenever a pointer is cast such that the required alignment of the |
9133 | target is increased. For example, warn if a @code{char *} is cast to | |
9134 | an @code{int *} on machines where integers can only be accessed at | |
9135 | two- or four-byte boundaries. | |
9136 | ||
d77de738 | 9137 | @opindex Wcast-align=strict |
ddf6fe37 | 9138 | @item -Wcast-align=strict |
d77de738 ML |
9139 | Warn whenever a pointer is cast such that the required alignment of the |
9140 | target is increased. For example, warn if a @code{char *} is cast to | |
9141 | an @code{int *} regardless of the target machine. | |
9142 | ||
d77de738 ML |
9143 | @opindex Wcast-function-type |
9144 | @opindex Wno-cast-function-type | |
ddf6fe37 | 9145 | @item -Wcast-function-type |
d77de738 ML |
9146 | Warn when a function pointer is cast to an incompatible function pointer. |
9147 | In a cast involving function types with a variable argument list only | |
9148 | the types of initial arguments that are provided are considered. | |
9149 | Any parameter of pointer-type matches any other pointer-type. Any benign | |
9150 | differences in integral types are ignored, like @code{int} vs.@: @code{long} | |
9151 | on ILP32 targets. Likewise type qualifiers are ignored. The function | |
9152 | type @code{void (*) (void)} is special and matches everything, which can | |
9153 | be used to suppress this warning. | |
9154 | In a cast involving pointer to member types this warning warns whenever | |
9155 | the type cast is changing the pointer to member type. | |
9156 | This warning is enabled by @option{-Wextra}. | |
9157 | ||
d77de738 ML |
9158 | @opindex Wwrite-strings |
9159 | @opindex Wno-write-strings | |
ddf6fe37 | 9160 | @item -Wwrite-strings |
d77de738 ML |
9161 | When compiling C, give string constants the type @code{const |
9162 | char[@var{length}]} so that copying the address of one into a | |
9163 | non-@code{const} @code{char *} pointer produces a warning. These | |
9164 | warnings help you find at compile time code that can try to write | |
9165 | into a string constant, but only if you have been very careful about | |
9166 | using @code{const} in declarations and prototypes. Otherwise, it is | |
9167 | just a nuisance. This is why we did not make @option{-Wall} request | |
9168 | these warnings. | |
9169 | ||
9170 | When compiling C++, warn about the deprecated conversion from string | |
9171 | literals to @code{char *}. This warning is enabled by default for C++ | |
9172 | programs. | |
9173 | ||
5fccebdb JM |
9174 | This warning is upgraded to an error by @option{-pedantic-errors} in |
9175 | C++11 mode or later. | |
9176 | ||
d77de738 ML |
9177 | @opindex Wclobbered |
9178 | @opindex Wno-clobbered | |
f33d7a88 | 9179 | @item -Wclobbered |
d77de738 ML |
9180 | Warn for variables that might be changed by @code{longjmp} or |
9181 | @code{vfork}. This warning is also enabled by @option{-Wextra}. | |
9182 | ||
320dc51c TS |
9183 | @opindex Wcomplain-wrong-lang |
9184 | @opindex Wno-complain-wrong-lang | |
f33d7a88 | 9185 | @item -Wno-complain-wrong-lang |
320dc51c TS |
9186 | By default, language front ends complain when a command-line option is |
9187 | valid, but not applicable to that front end. | |
9188 | This may be disabled with @option{-Wno-complain-wrong-lang}, | |
9189 | which is mostly useful when invoking a single compiler driver for | |
9190 | multiple source files written in different languages, for example: | |
9191 | ||
9192 | @smallexample | |
9193 | $ g++ -fno-rtti a.cc b.f90 | |
9194 | @end smallexample | |
9195 | ||
9196 | The driver @file{g++} invokes the C++ front end to compile @file{a.cc} | |
9197 | and the Fortran front end to compile @file{b.f90}. | |
9198 | The latter front end diagnoses | |
9199 | @samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran}, | |
9200 | which may be disabled with @option{-Wno-complain-wrong-lang}. | |
9201 | ||
e1f45bea JM |
9202 | @opindex Wcompare-distinct-pointer-types |
9203 | @item -Wcompare-distinct-pointer-types @r{(C and Objective-C only)} | |
9204 | Warn if pointers of distinct types are compared without a cast. This | |
9205 | warning is enabled by default. | |
9206 | ||
d77de738 ML |
9207 | @opindex Wconversion |
9208 | @opindex Wno-conversion | |
f33d7a88 | 9209 | @item -Wconversion |
d77de738 ML |
9210 | Warn for implicit conversions that may alter a value. This includes |
9211 | conversions between real and integer, like @code{abs (x)} when | |
9212 | @code{x} is @code{double}; conversions between signed and unsigned, | |
9213 | like @code{unsigned ui = -1}; and conversions to smaller types, like | |
9214 | @code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs | |
9215 | ((int) x)} and @code{ui = (unsigned) -1}, or if the value is not | |
9216 | changed by the conversion like in @code{abs (2.0)}. Warnings about | |
9217 | conversions between signed and unsigned integers can be disabled by | |
9218 | using @option{-Wno-sign-conversion}. | |
9219 | ||
9220 | For C++, also warn for confusing overload resolution for user-defined | |
9221 | conversions; and conversions that never use a type conversion | |
9222 | operator: conversions to @code{void}, the same type, a base class or a | |
9223 | reference to them. Warnings about conversions between signed and | |
9224 | unsigned integers are disabled by default in C++ unless | |
9225 | @option{-Wsign-conversion} is explicitly enabled. | |
9226 | ||
9227 | Warnings about conversion from arithmetic on a small type back to that | |
9228 | type are only given with @option{-Warith-conversion}. | |
9229 | ||
d77de738 ML |
9230 | @opindex Wdangling-else |
9231 | @opindex Wno-dangling-else | |
ddf6fe37 | 9232 | @item -Wdangling-else |
d77de738 ML |
9233 | Warn about constructions where there may be confusion to which |
9234 | @code{if} statement an @code{else} branch belongs. Here is an example of | |
9235 | such a case: | |
9236 | ||
9237 | @smallexample | |
9238 | @group | |
9239 | @{ | |
9240 | if (a) | |
9241 | if (b) | |
9242 | foo (); | |
9243 | else | |
9244 | bar (); | |
9245 | @} | |
9246 | @end group | |
9247 | @end smallexample | |
9248 | ||
9249 | In C/C++, every @code{else} branch belongs to the innermost possible | |
9250 | @code{if} statement, which in this example is @code{if (b)}. This is | |
9251 | often not what the programmer expected, as illustrated in the above | |
9252 | example by indentation the programmer chose. When there is the | |
9253 | potential for this confusion, GCC issues a warning when this flag | |
9254 | is specified. To eliminate the warning, add explicit braces around | |
9255 | the innermost @code{if} statement so there is no way the @code{else} | |
9256 | can belong to the enclosing @code{if}. The resulting code | |
9257 | looks like this: | |
9258 | ||
9259 | @smallexample | |
9260 | @group | |
9261 | @{ | |
9262 | if (a) | |
9263 | @{ | |
9264 | if (b) | |
9265 | foo (); | |
9266 | else | |
9267 | bar (); | |
9268 | @} | |
9269 | @} | |
9270 | @end group | |
9271 | @end smallexample | |
9272 | ||
9273 | This warning is enabled by @option{-Wparentheses}. | |
9274 | ||
d77de738 ML |
9275 | @opindex Wdangling-pointer |
9276 | @opindex Wno-dangling-pointer | |
ddf6fe37 AA |
9277 | @item -Wdangling-pointer |
9278 | @itemx -Wdangling-pointer=@var{n} | |
d77de738 ML |
9279 | Warn about uses of pointers (or C++ references) to objects with automatic |
9280 | storage duration after their lifetime has ended. This includes local | |
9281 | variables declared in nested blocks, compound literals and other unnamed | |
9282 | temporary objects. In addition, warn about storing the address of such | |
9283 | objects in escaped pointers. The warning is enabled at all optimization | |
9284 | levels but may yield different results with optimization than without. | |
9285 | ||
9286 | @table @gcctabopt | |
9287 | @item -Wdangling-pointer=1 | |
9288 | At level 1 the warning diagnoses only unconditional uses of dangling pointers. | |
9289 | For example | |
9290 | @smallexample | |
9291 | int f (int c1, int c2, x) | |
9292 | @{ | |
9293 | char *p = strchr ((char[])@{ c1, c2 @}, c3); | |
4ace81b6 SL |
9294 | // warning: dangling pointer to a compound literal |
9295 | return p ? *p : 'x'; | |
d77de738 ML |
9296 | @} |
9297 | @end smallexample | |
9298 | In the following function the store of the address of the local variable | |
9299 | @code{x} in the escaped pointer @code{*p} also triggers the warning. | |
9300 | @smallexample | |
9301 | void g (int **p) | |
9302 | @{ | |
9303 | int x = 7; | |
4ace81b6 SL |
9304 | // warning: storing the address of a local variable in *p |
9305 | *p = &x; | |
d77de738 ML |
9306 | @} |
9307 | @end smallexample | |
9308 | ||
9309 | @item -Wdangling-pointer=2 | |
9310 | At level 2, in addition to unconditional uses the warning also diagnoses | |
9311 | conditional uses of dangling pointers. | |
9312 | ||
9313 | For example, because the array @var{a} in the following function is out of | |
9314 | scope when the pointer @var{s} that was set to point is used, the warning | |
9315 | triggers at this level. | |
9316 | ||
9317 | @smallexample | |
9318 | void f (char *s) | |
9319 | @{ | |
9320 | if (!s) | |
9321 | @{ | |
9322 | char a[12] = "tmpname"; | |
9323 | s = a; | |
9324 | @} | |
4ace81b6 SL |
9325 | // warning: dangling pointer to a may be used |
9326 | strcat (s, ".tmp"); | |
d77de738 ML |
9327 | ... |
9328 | @} | |
9329 | @end smallexample | |
9330 | @end table | |
9331 | ||
9332 | @option{-Wdangling-pointer=2} is included in @option{-Wall}. | |
9333 | ||
d77de738 ML |
9334 | @opindex Wdate-time |
9335 | @opindex Wno-date-time | |
ddf6fe37 | 9336 | @item -Wdate-time |
d77de738 ML |
9337 | Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__} |
9338 | are encountered as they might prevent bit-wise-identical reproducible | |
9339 | compilations. | |
9340 | ||
d77de738 ML |
9341 | @opindex Wempty-body |
9342 | @opindex Wno-empty-body | |
ddf6fe37 | 9343 | @item -Wempty-body |
d77de738 ML |
9344 | Warn if an empty body occurs in an @code{if}, @code{else} or @code{do |
9345 | while} statement. This warning is also enabled by @option{-Wextra}. | |
9346 | ||
d77de738 ML |
9347 | @opindex Wendif-labels |
9348 | @opindex Wno-endif-labels | |
ddf6fe37 | 9349 | @item -Wno-endif-labels |
d77de738 ML |
9350 | Do not warn about stray tokens after @code{#else} and @code{#endif}. |
9351 | ||
d77de738 ML |
9352 | @opindex Wenum-compare |
9353 | @opindex Wno-enum-compare | |
ddf6fe37 | 9354 | @item -Wenum-compare |
d77de738 ML |
9355 | Warn about a comparison between values of different enumerated types. |
9356 | In C++ enumerated type mismatches in conditional expressions are also | |
9357 | diagnosed and the warning is enabled by default. In C this warning is | |
9358 | enabled by @option{-Wall}. | |
9359 | ||
d77de738 ML |
9360 | @opindex Wenum-conversion |
9361 | @opindex Wno-enum-conversion | |
ddf6fe37 | 9362 | @item -Wenum-conversion |
d77de738 ML |
9363 | Warn when a value of enumerated type is implicitly converted to a |
9364 | different enumerated type. This warning is enabled by @option{-Wextra} | |
9365 | in C@. | |
9366 | ||
d77de738 ML |
9367 | @opindex Wenum-int-mismatch |
9368 | @opindex Wno-enum-int-mismatch | |
ddf6fe37 | 9369 | @item -Wenum-int-mismatch @r{(C and Objective-C only)} |
d77de738 ML |
9370 | Warn about mismatches between an enumerated type and an integer type in |
9371 | declarations. For example: | |
9372 | ||
9373 | @smallexample | |
9374 | enum E @{ l = -1, z = 0, g = 1 @}; | |
9375 | int foo(void); | |
9376 | enum E foo(void); | |
9377 | @end smallexample | |
9378 | ||
9379 | In C, an enumerated type is compatible with @code{char}, a signed | |
9380 | integer type, or an unsigned integer type. However, since the choice | |
9381 | of the underlying type of an enumerated type is implementation-defined, | |
9382 | such mismatches may cause portability issues. In C++, such mismatches | |
9383 | are an error. In C, this warning is enabled by @option{-Wall} and | |
9384 | @option{-Wc++-compat}. | |
9385 | ||
d77de738 ML |
9386 | @opindex Wjump-misses-init |
9387 | @opindex Wno-jump-misses-init | |
ddf6fe37 | 9388 | @item -Wjump-misses-init @r{(C, Objective-C only)} |
d77de738 ML |
9389 | Warn if a @code{goto} statement or a @code{switch} statement jumps |
9390 | forward across the initialization of a variable, or jumps backward to a | |
9391 | label after the variable has been initialized. This only warns about | |
9392 | variables that are initialized when they are declared. This warning is | |
9393 | only supported for C and Objective-C; in C++ this sort of branch is an | |
9394 | error in any case. | |
9395 | ||
9396 | @option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It | |
9397 | can be disabled with the @option{-Wno-jump-misses-init} option. | |
9398 | ||
d77de738 ML |
9399 | @opindex Wsign-compare |
9400 | @opindex Wno-sign-compare | |
9401 | @cindex warning for comparison of signed and unsigned values | |
9402 | @cindex comparison of signed and unsigned values, warning | |
9403 | @cindex signed and unsigned values, comparison warning | |
f33d7a88 | 9404 | @item -Wsign-compare |
d77de738 ML |
9405 | Warn when a comparison between signed and unsigned values could produce |
9406 | an incorrect result when the signed value is converted to unsigned. | |
9407 | In C++, this warning is also enabled by @option{-Wall}. In C, it is | |
9408 | also enabled by @option{-Wextra}. | |
9409 | ||
d77de738 ML |
9410 | @opindex Wsign-conversion |
9411 | @opindex Wno-sign-conversion | |
ddf6fe37 | 9412 | @item -Wsign-conversion |
d77de738 ML |
9413 | Warn for implicit conversions that may change the sign of an integer |
9414 | value, like assigning a signed integer expression to an unsigned | |
9415 | integer variable. An explicit cast silences the warning. In C, this | |
9416 | option is enabled also by @option{-Wconversion}. | |
9417 | ||
44e3f39a QZ |
9418 | @opindex Wflex-array-member-not-at-end |
9419 | @opindex Wno-flex-array-member-not-at-end | |
9420 | @item -Wflex-array-member-not-at-end @r{(C and C++ only)} | |
9421 | Warn when a structure containing a C99 flexible array member as the last | |
9422 | field is not at the end of another structure. | |
9423 | This warning warns e.g. about | |
9424 | ||
9425 | @smallexample | |
9426 | struct flex @{ int length; char data[]; @}; | |
9427 | struct mid_flex @{ int m; struct flex flex_data; int n; @}; | |
9428 | @end smallexample | |
9429 | ||
d77de738 ML |
9430 | @opindex Wfloat-conversion |
9431 | @opindex Wno-float-conversion | |
ddf6fe37 | 9432 | @item -Wfloat-conversion |
d77de738 ML |
9433 | Warn for implicit conversions that reduce the precision of a real value. |
9434 | This includes conversions from real to integer, and from higher precision | |
9435 | real to lower precision real values. This option is also enabled by | |
9436 | @option{-Wconversion}. | |
9437 | ||
d77de738 ML |
9438 | @opindex Wno-scalar-storage-order |
9439 | @opindex Wscalar-storage-order | |
ddf6fe37 | 9440 | @item -Wno-scalar-storage-order |
d77de738 ML |
9441 | Do not warn on suspicious constructs involving reverse scalar storage order. |
9442 | ||
d77de738 ML |
9443 | @opindex Wsizeof-array-div |
9444 | @opindex Wno-sizeof-array-div | |
ddf6fe37 | 9445 | @item -Wsizeof-array-div |
d77de738 ML |
9446 | Warn about divisions of two sizeof operators when the first one is applied |
9447 | to an array and the divisor does not equal the size of the array element. | |
9448 | In such a case, the computation will not yield the number of elements in the | |
9449 | array, which is likely what the user intended. This warning warns e.g. about | |
9450 | @smallexample | |
9451 | int fn () | |
9452 | @{ | |
9453 | int arr[10]; | |
9454 | return sizeof (arr) / sizeof (short); | |
9455 | @} | |
9456 | @end smallexample | |
9457 | ||
9458 | This warning is enabled by @option{-Wall}. | |
9459 | ||
d77de738 ML |
9460 | @opindex Wsizeof-pointer-div |
9461 | @opindex Wno-sizeof-pointer-div | |
ddf6fe37 | 9462 | @item -Wsizeof-pointer-div |
d77de738 ML |
9463 | Warn for suspicious divisions of two sizeof expressions that divide |
9464 | the pointer size by the element size, which is the usual way to compute | |
9465 | the array size but won't work out correctly with pointers. This warning | |
9466 | warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is | |
9467 | not an array, but a pointer. This warning is enabled by @option{-Wall}. | |
9468 | ||
d77de738 ML |
9469 | @opindex Wsizeof-pointer-memaccess |
9470 | @opindex Wno-sizeof-pointer-memaccess | |
ddf6fe37 | 9471 | @item -Wsizeof-pointer-memaccess |
d77de738 ML |
9472 | Warn for suspicious length parameters to certain string and memory built-in |
9473 | functions if the argument uses @code{sizeof}. This warning triggers for | |
9474 | example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not | |
9475 | an array, but a pointer, and suggests a possible fix, or about | |
9476 | @code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess} | |
9477 | also warns about calls to bounded string copy functions like @code{strncat} | |
9478 | or @code{strncpy} that specify as the bound a @code{sizeof} expression of | |
9479 | the source array. For example, in the following function the call to | |
9480 | @code{strncat} specifies the size of the source string as the bound. That | |
9481 | is almost certainly a mistake and so the call is diagnosed. | |
9482 | @smallexample | |
9483 | void make_file (const char *name) | |
9484 | @{ | |
9485 | char path[PATH_MAX]; | |
9486 | strncpy (path, name, sizeof path - 1); | |
9487 | strncat (path, ".text", sizeof ".text"); | |
9488 | @dots{} | |
9489 | @} | |
9490 | @end smallexample | |
9491 | ||
9492 | The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}. | |
9493 | ||
d77de738 ML |
9494 | @opindex Wsizeof-array-argument |
9495 | @opindex Wno-sizeof-array-argument | |
ddf6fe37 | 9496 | @item -Wno-sizeof-array-argument |
d77de738 ML |
9497 | Do not warn when the @code{sizeof} operator is applied to a parameter that is |
9498 | declared as an array in a function definition. This warning is enabled by | |
9499 | default for C and C++ programs. | |
9500 | ||
d77de738 ML |
9501 | @opindex Wmemset-elt-size |
9502 | @opindex Wno-memset-elt-size | |
ddf6fe37 | 9503 | @item -Wmemset-elt-size |
d77de738 ML |
9504 | Warn for suspicious calls to the @code{memset} built-in function, if the |
9505 | first argument references an array, and the third argument is a number | |
9506 | equal to the number of elements, but not equal to the size of the array | |
9507 | in memory. This indicates that the user has omitted a multiplication by | |
9508 | the element size. This warning is enabled by @option{-Wall}. | |
9509 | ||
d77de738 ML |
9510 | @opindex Wmemset-transposed-args |
9511 | @opindex Wno-memset-transposed-args | |
ddf6fe37 | 9512 | @item -Wmemset-transposed-args |
d77de738 ML |
9513 | Warn for suspicious calls to the @code{memset} built-in function where |
9514 | the second argument is not zero and the third argument is zero. For | |
9515 | example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because | |
9516 | @code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic | |
9517 | is only emitted if the third argument is a literal zero. Otherwise, if | |
9518 | it is an expression that is folded to zero, or a cast of zero to some | |
9519 | type, it is far less likely that the arguments have been mistakenly | |
9520 | transposed and no warning is emitted. This warning is enabled | |
9521 | by @option{-Wall}. | |
9522 | ||
d77de738 ML |
9523 | @opindex Waddress |
9524 | @opindex Wno-address | |
ddf6fe37 | 9525 | @item -Waddress |
d77de738 ML |
9526 | Warn about suspicious uses of address expressions. These include comparing |
9527 | the address of a function or a declared object to the null pointer constant | |
9528 | such as in | |
9529 | @smallexample | |
9530 | void f (void); | |
9531 | void g (void) | |
9532 | @{ | |
9533 | if (!f) // warning: expression evaluates to false | |
9534 | abort (); | |
9535 | @} | |
9536 | @end smallexample | |
9537 | comparisons of a pointer to a string literal, such as in | |
9538 | @smallexample | |
9539 | void f (const char *x) | |
9540 | @{ | |
9541 | if (x == "abc") // warning: expression evaluates to false | |
9542 | puts ("equal"); | |
9543 | @} | |
9544 | @end smallexample | |
9545 | and tests of the results of pointer addition or subtraction for equality | |
9546 | to null, such as in | |
9547 | @smallexample | |
9548 | void f (const int *p, int i) | |
9549 | @{ | |
9550 | return p + i == NULL; | |
9551 | @} | |
9552 | @end smallexample | |
9553 | Such uses typically indicate a programmer error: the address of most | |
9554 | functions and objects necessarily evaluates to true (the exception are | |
9555 | weak symbols), so their use in a conditional might indicate missing | |
9556 | parentheses in a function call or a missing dereference in an array | |
9557 | expression. The subset of the warning for object pointers can be | |
9558 | suppressed by casting the pointer operand to an integer type such | |
9559 | as @code{intptr_t} or @code{uintptr_t}. | |
9560 | Comparisons against string literals result in unspecified behavior | |
9561 | and are not portable, and suggest the intent was to call @code{strcmp}. | |
9562 | The warning is suppressed if the suspicious expression is the result | |
9563 | of macro expansion. | |
9564 | @option{-Waddress} warning is enabled by @option{-Wall}. | |
9565 | ||
d77de738 ML |
9566 | @opindex Waddress-of-packed-member |
9567 | @opindex Wno-address-of-packed-member | |
ddf6fe37 | 9568 | @item -Wno-address-of-packed-member |
d77de738 ML |
9569 | Do not warn when the address of packed member of struct or union is taken, |
9570 | which usually results in an unaligned pointer value. This is | |
9571 | enabled by default. | |
9572 | ||
d77de738 ML |
9573 | @opindex Wlogical-op |
9574 | @opindex Wno-logical-op | |
ddf6fe37 | 9575 | @item -Wlogical-op |
d77de738 ML |
9576 | Warn about suspicious uses of logical operators in expressions. |
9577 | This includes using logical operators in contexts where a | |
9578 | bit-wise operator is likely to be expected. Also warns when | |
9579 | the operands of a logical operator are the same: | |
9580 | @smallexample | |
9581 | extern int a; | |
9582 | if (a < 0 && a < 0) @{ @dots{} @} | |
9583 | @end smallexample | |
9584 | ||
d77de738 ML |
9585 | @opindex Wlogical-not-parentheses |
9586 | @opindex Wno-logical-not-parentheses | |
ddf6fe37 | 9587 | @item -Wlogical-not-parentheses |
d77de738 ML |
9588 | Warn about logical not used on the left hand side operand of a comparison. |
9589 | This option does not warn if the right operand is considered to be a boolean | |
9590 | expression. Its purpose is to detect suspicious code like the following: | |
9591 | @smallexample | |
9592 | int a; | |
9593 | @dots{} | |
9594 | if (!a > 1) @{ @dots{} @} | |
9595 | @end smallexample | |
9596 | ||
9597 | It is possible to suppress the warning by wrapping the LHS into | |
9598 | parentheses: | |
9599 | @smallexample | |
9600 | if ((!a) > 1) @{ @dots{} @} | |
9601 | @end smallexample | |
9602 | ||
9603 | This warning is enabled by @option{-Wall}. | |
9604 | ||
d77de738 ML |
9605 | @opindex Waggregate-return |
9606 | @opindex Wno-aggregate-return | |
ddf6fe37 | 9607 | @item -Waggregate-return |
d77de738 ML |
9608 | Warn if any functions that return structures or unions are defined or |
9609 | called. (In languages where you can return an array, this also elicits | |
9610 | a warning.) | |
9611 | ||
d77de738 ML |
9612 | @opindex Wno-aggressive-loop-optimizations |
9613 | @opindex Waggressive-loop-optimizations | |
ddf6fe37 | 9614 | @item -Wno-aggressive-loop-optimizations |
d77de738 ML |
9615 | Warn if in a loop with constant number of iterations the compiler detects |
9616 | undefined behavior in some statement during one or more of the iterations. | |
9617 | ||
d77de738 ML |
9618 | @opindex Wno-attributes |
9619 | @opindex Wattributes | |
ddf6fe37 | 9620 | @item -Wno-attributes |
d77de738 ML |
9621 | Do not warn if an unexpected @code{__attribute__} is used, such as |
9622 | unrecognized attributes, function attributes applied to variables, | |
9623 | etc. This does not stop errors for incorrect use of supported | |
9624 | attributes. | |
9625 | ||
5fccebdb JM |
9626 | Warnings about ill-formed uses of standard attributes are upgraded to |
9627 | errors by @option{-pedantic-errors}. | |
9628 | ||
d77de738 | 9629 | Additionally, using @option{-Wno-attributes=}, it is possible to suppress |
094a609c | 9630 | warnings about unknown scoped attributes (in C++11 and C23). For example, |
d77de738 ML |
9631 | @option{-Wno-attributes=vendor::attr} disables warning about the following |
9632 | declaration: | |
9633 | ||
9634 | @smallexample | |
9635 | [[vendor::attr]] void f(); | |
9636 | @end smallexample | |
9637 | ||
9638 | It is also possible to disable warning about all attributes in a namespace | |
9639 | using @option{-Wno-attributes=vendor::} which prevents warning about both | |
9640 | of these declarations: | |
9641 | ||
9642 | @smallexample | |
9643 | [[vendor::safe]] void f(); | |
9644 | [[vendor::unsafe]] void f2(); | |
9645 | @end smallexample | |
9646 | ||
9647 | Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}. | |
9648 | ||
d77de738 ML |
9649 | @opindex Wno-builtin-declaration-mismatch |
9650 | @opindex Wbuiltin-declaration-mismatch | |
ddf6fe37 | 9651 | @item -Wno-builtin-declaration-mismatch |
d77de738 ML |
9652 | Warn if a built-in function is declared with an incompatible signature |
9653 | or as a non-function, or when a built-in function declared with a type | |
9654 | that does not include a prototype is called with arguments whose promoted | |
9655 | types do not match those expected by the function. When @option{-Wextra} | |
9656 | is specified, also warn when a built-in function that takes arguments is | |
9657 | declared without a prototype. The @option{-Wbuiltin-declaration-mismatch} | |
9658 | warning is enabled by default. To avoid the warning include the appropriate | |
9659 | header to bring the prototypes of built-in functions into scope. | |
9660 | ||
9661 | For example, the call to @code{memset} below is diagnosed by the warning | |
9662 | because the function expects a value of type @code{size_t} as its argument | |
9663 | but the type of @code{32} is @code{int}. With @option{-Wextra}, | |
9664 | the declaration of the function is diagnosed as well. | |
9665 | @smallexample | |
9666 | extern void* memset (); | |
9667 | void f (void *d) | |
9668 | @{ | |
9669 | memset (d, '\0', 32); | |
9670 | @} | |
9671 | @end smallexample | |
9672 | ||
d77de738 ML |
9673 | @opindex Wno-builtin-macro-redefined |
9674 | @opindex Wbuiltin-macro-redefined | |
ddf6fe37 | 9675 | @item -Wno-builtin-macro-redefined |
d77de738 ML |
9676 | Do not warn if certain built-in macros are redefined. This suppresses |
9677 | warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__}, | |
9678 | @code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}. | |
9679 | ||
d77de738 ML |
9680 | @opindex Wstrict-prototypes |
9681 | @opindex Wno-strict-prototypes | |
ddf6fe37 | 9682 | @item -Wstrict-prototypes @r{(C and Objective-C only)} |
d77de738 ML |
9683 | Warn if a function is declared or defined without specifying the |
9684 | argument types. (An old-style function definition is permitted without | |
9685 | a warning if preceded by a declaration that specifies the argument | |
9686 | types.) | |
9687 | ||
d77de738 ML |
9688 | @opindex Wold-style-declaration |
9689 | @opindex Wno-old-style-declaration | |
ddf6fe37 | 9690 | @item -Wold-style-declaration @r{(C and Objective-C only)} |
d77de738 ML |
9691 | Warn for obsolescent usages, according to the C Standard, in a |
9692 | declaration. For example, warn if storage-class specifiers like | |
9693 | @code{static} are not the first things in a declaration. This warning | |
9694 | is also enabled by @option{-Wextra}. | |
9695 | ||
d77de738 ML |
9696 | @opindex Wold-style-definition |
9697 | @opindex Wno-old-style-definition | |
ddf6fe37 | 9698 | @item -Wold-style-definition @r{(C and Objective-C only)} |
d77de738 ML |
9699 | Warn if an old-style function definition is used. A warning is given |
9700 | even if there is a previous prototype. A definition using @samp{()} | |
094a609c | 9701 | is not considered an old-style definition in C23 mode, because it is |
d77de738 ML |
9702 | equivalent to @samp{(void)} in that case, but is considered an |
9703 | old-style definition for older standards. | |
9704 | ||
d77de738 ML |
9705 | @opindex Wmissing-parameter-type |
9706 | @opindex Wno-missing-parameter-type | |
ddf6fe37 | 9707 | @item -Wmissing-parameter-type @r{(C and Objective-C only)} |
d77de738 ML |
9708 | A function parameter is declared without a type specifier in K&R-style |
9709 | functions: | |
9710 | ||
9711 | @smallexample | |
9712 | void foo(bar) @{ @} | |
9713 | @end smallexample | |
9714 | ||
9715 | This warning is also enabled by @option{-Wextra}. | |
9716 | ||
d77de738 ML |
9717 | @opindex Wmissing-prototypes |
9718 | @opindex Wno-missing-prototypes | |
ddf6fe37 | 9719 | @item -Wmissing-prototypes @r{(C and Objective-C only)} |
d77de738 ML |
9720 | Warn if a global function is defined without a previous prototype |
9721 | declaration. This warning is issued even if the definition itself | |
9722 | provides a prototype. Use this option to detect global functions | |
9723 | that do not have a matching prototype declaration in a header file. | |
9724 | This option is not valid for C++ because all function declarations | |
9725 | provide prototypes and a non-matching declaration declares an | |
9726 | overload rather than conflict with an earlier declaration. | |
9727 | Use @option{-Wmissing-declarations} to detect missing declarations in C++. | |
9728 | ||
ffc74822 HM |
9729 | @opindex Wmissing-variable-declarations |
9730 | @opindex Wno-missing-variable-declarations | |
9731 | @item -Wmissing-variable-declarations @r{(C and Objective-C only)} | |
9732 | Warn if a global variable is defined without a previous declaration. | |
9733 | Use this option to detect global variables that do not have a matching | |
9734 | extern declaration in a header file. | |
9735 | ||
d77de738 ML |
9736 | @opindex Wmissing-declarations |
9737 | @opindex Wno-missing-declarations | |
ddf6fe37 | 9738 | @item -Wmissing-declarations |
d77de738 ML |
9739 | Warn if a global function is defined without a previous declaration. |
9740 | Do so even if the definition itself provides a prototype. | |
9741 | Use this option to detect global functions that are not declared in | |
9742 | header files. In C, no warnings are issued for functions with previous | |
9743 | non-prototype declarations; use @option{-Wmissing-prototypes} to detect | |
9744 | missing prototypes. In C++, no warnings are issued for function templates, | |
9745 | or for inline functions, or for functions in anonymous namespaces. | |
9746 | ||
d77de738 ML |
9747 | @opindex Wmissing-field-initializers |
9748 | @opindex Wno-missing-field-initializers | |
9749 | @opindex W | |
9750 | @opindex Wextra | |
9751 | @opindex Wno-extra | |
ddf6fe37 | 9752 | @item -Wmissing-field-initializers |
d77de738 ML |
9753 | Warn if a structure's initializer has some fields missing. For |
9754 | example, the following code causes such a warning, because | |
9755 | @code{x.h} is implicitly zero: | |
9756 | ||
9757 | @smallexample | |
9758 | struct s @{ int f, g, h; @}; | |
9759 | struct s x = @{ 3, 4 @}; | |
9760 | @end smallexample | |
9761 | ||
0f8f1dee MP |
9762 | @c It's unclear if this behavior is desirable. See PR39589 and PR96868. |
9763 | In C this option does not warn about designated initializers, so the | |
9764 | following modification does not trigger a warning: | |
d77de738 ML |
9765 | |
9766 | @smallexample | |
9767 | struct s @{ int f, g, h; @}; | |
9768 | struct s x = @{ .f = 3, .g = 4 @}; | |
9769 | @end smallexample | |
9770 | ||
9771 | In C this option does not warn about the universal zero initializer | |
9772 | @samp{@{ 0 @}}: | |
9773 | ||
9774 | @smallexample | |
9775 | struct s @{ int f, g, h; @}; | |
9776 | struct s x = @{ 0 @}; | |
9777 | @end smallexample | |
9778 | ||
9779 | Likewise, in C++ this option does not warn about the empty @{ @} | |
9780 | initializer, for example: | |
9781 | ||
9782 | @smallexample | |
9783 | struct s @{ int f, g, h; @}; | |
9784 | s x = @{ @}; | |
9785 | @end smallexample | |
9786 | ||
9787 | This warning is included in @option{-Wextra}. To get other @option{-Wextra} | |
9788 | warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}. | |
9789 | ||
d77de738 ML |
9790 | @opindex Wmissing-requires |
9791 | @opindex Wno-missing-requires | |
ddf6fe37 | 9792 | @item -Wno-missing-requires |
d77de738 ML |
9793 | |
9794 | By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement: | |
9795 | ||
9796 | @smallexample | |
9797 | bool satisfied = requires @{ C<T> @}; | |
9798 | @end smallexample | |
9799 | ||
9800 | Here @samp{satisfied} will be true if @samp{C<T>} is a valid | |
9801 | expression, which it is for all T. Presumably the user meant to write | |
9802 | ||
9803 | @smallexample | |
9804 | bool satisfied = requires @{ requires C<T> @}; | |
9805 | @end smallexample | |
9806 | ||
9807 | so @samp{satisfied} is only true if concept @samp{C} is satisfied for | |
9808 | type @samp{T}. | |
9809 | ||
9810 | This warning can be disabled with @option{-Wno-missing-requires}. | |
9811 | ||
d77de738 ML |
9812 | @opindex Wmissing-template-keyword |
9813 | @opindex Wno-missing-template-keyword | |
ddf6fe37 | 9814 | @item -Wno-missing-template-keyword |
d77de738 ML |
9815 | |
9816 | The member access tokens ., -> and :: must be followed by the @code{template} | |
9817 | keyword if the parent object is dependent and the member being named is a | |
9818 | template. | |
9819 | ||
9820 | @smallexample | |
9821 | template <class X> | |
9822 | void DoStuff (X x) | |
9823 | @{ | |
9824 | x.template DoSomeOtherStuff<X>(); // Good. | |
9825 | x.DoMoreStuff<X>(); // Warning, x is dependent. | |
9826 | @} | |
9827 | @end smallexample | |
9828 | ||
9829 | In rare cases it is possible to get false positives. To silence this, wrap | |
9830 | the expression in parentheses. For example, the following is treated as a | |
9831 | template, even where m and N are integers: | |
9832 | ||
9833 | @smallexample | |
9834 | void NotATemplate (my_class t) | |
9835 | @{ | |
9836 | int N = 5; | |
9837 | ||
9838 | bool test = t.m < N > (0); // Treated as a template. | |
9839 | test = (t.m < N) > (0); // Same meaning, but not treated as a template. | |
9840 | @} | |
9841 | @end smallexample | |
9842 | ||
9843 | This warning can be disabled with @option{-Wno-missing-template-keyword}. | |
9844 | ||
d77de738 ML |
9845 | @opindex Wno-multichar |
9846 | @opindex Wmultichar | |
ddf6fe37 | 9847 | @item -Wno-multichar |
d77de738 ML |
9848 | Do not warn if a multicharacter constant (@samp{'FOOF'}) is used. |
9849 | Usually they indicate a typo in the user's code, as they have | |
9850 | implementation-defined values, and should not be used in portable code. | |
9851 | ||
d77de738 ML |
9852 | @opindex Wnormalized= |
9853 | @opindex Wnormalized | |
9854 | @opindex Wno-normalized | |
9855 | @cindex NFC | |
9856 | @cindex NFKC | |
9857 | @cindex character set, input normalization | |
f33d7a88 | 9858 | @item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} |
d77de738 ML |
9859 | In ISO C and ISO C++, two identifiers are different if they are |
9860 | different sequences of characters. However, sometimes when characters | |
9861 | outside the basic ASCII character set are used, you can have two | |
9862 | different character sequences that look the same. To avoid confusion, | |
9863 | the ISO 10646 standard sets out some @dfn{normalization rules} which | |
9864 | when applied ensure that two sequences that look the same are turned into | |
9865 | the same sequence. GCC can warn you if you are using identifiers that | |
9866 | have not been normalized; this option controls that warning. | |
9867 | ||
9868 | There are four levels of warning supported by GCC@. The default is | |
9869 | @option{-Wnormalized=nfc}, which warns about any identifier that is | |
9870 | not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the | |
9871 | recommended form for most uses. It is equivalent to | |
9872 | @option{-Wnormalized}. | |
9873 | ||
9874 | Unfortunately, there are some characters allowed in identifiers by | |
9875 | ISO C and ISO C++ that, when turned into NFC, are not allowed in | |
9876 | identifiers. That is, there's no way to use these symbols in portable | |
9877 | ISO C or C++ and have all your identifiers in NFC@. | |
9878 | @option{-Wnormalized=id} suppresses the warning for these characters. | |
9879 | It is hoped that future versions of the standards involved will correct | |
9880 | this, which is why this option is not the default. | |
9881 | ||
9882 | You can switch the warning off for all characters by writing | |
9883 | @option{-Wnormalized=none} or @option{-Wno-normalized}. You should | |
9884 | only do this if you are using some other normalization scheme (like | |
9885 | ``D''), because otherwise you can easily create bugs that are | |
9886 | literally impossible to see. | |
9887 | ||
9888 | Some characters in ISO 10646 have distinct meanings but look identical | |
9889 | in some fonts or display methodologies, especially once formatting has | |
9890 | been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL | |
9891 | LETTER N'', displays just like a regular @code{n} that has been | |
9892 | placed in a superscript. ISO 10646 defines the @dfn{NFKC} | |
9893 | normalization scheme to convert all these into a standard form as | |
9894 | well, and GCC warns if your code is not in NFKC if you use | |
9895 | @option{-Wnormalized=nfkc}. This warning is comparable to warning | |
9896 | about every identifier that contains the letter O because it might be | |
9897 | confused with the digit 0, and so is not the default, but may be | |
9898 | useful as a local coding convention if the programming environment | |
9899 | cannot be fixed to display these characters distinctly. | |
9900 | ||
d77de738 ML |
9901 | @opindex Wno-attribute-warning |
9902 | @opindex Wattribute-warning | |
ddf6fe37 | 9903 | @item -Wno-attribute-warning |
d77de738 ML |
9904 | Do not warn about usage of functions (@pxref{Function Attributes}) |
9905 | declared with @code{warning} attribute. By default, this warning is | |
9906 | enabled. @option{-Wno-attribute-warning} can be used to disable the | |
9907 | warning or @option{-Wno-error=attribute-warning} can be used to | |
9908 | disable the error when compiled with @option{-Werror} flag. | |
9909 | ||
d77de738 ML |
9910 | @opindex Wno-deprecated |
9911 | @opindex Wdeprecated | |
ddf6fe37 | 9912 | @item -Wno-deprecated |
d77de738 ML |
9913 | Do not warn about usage of deprecated features. @xref{Deprecated Features}. |
9914 | ||
d77de738 ML |
9915 | @opindex Wno-deprecated-declarations |
9916 | @opindex Wdeprecated-declarations | |
ddf6fe37 | 9917 | @item -Wno-deprecated-declarations |
d77de738 ML |
9918 | Do not warn about uses of functions (@pxref{Function Attributes}), |
9919 | variables (@pxref{Variable Attributes}), and types (@pxref{Type | |
9920 | Attributes}) marked as deprecated by using the @code{deprecated} | |
9921 | attribute. | |
9922 | ||
d77de738 ML |
9923 | @opindex Wno-overflow |
9924 | @opindex Woverflow | |
ddf6fe37 | 9925 | @item -Wno-overflow |
d77de738 ML |
9926 | Do not warn about compile-time overflow in constant expressions. |
9927 | ||
d77de738 ML |
9928 | @opindex Wno-odr |
9929 | @opindex Wodr | |
ddf6fe37 | 9930 | @item -Wno-odr |
d77de738 ML |
9931 | Warn about One Definition Rule violations during link-time optimization. |
9932 | Enabled by default. | |
9933 | ||
d77de738 ML |
9934 | @opindex Wopenacc-parallelism |
9935 | @opindex Wno-openacc-parallelism | |
9936 | @cindex OpenACC accelerator programming | |
f33d7a88 | 9937 | @item -Wopenacc-parallelism |
d77de738 ML |
9938 | Warn about potentially suboptimal choices related to OpenACC parallelism. |
9939 | ||
d77de738 ML |
9940 | @opindex Wopenmp-simd |
9941 | @opindex Wno-openmp-simd | |
ddf6fe37 | 9942 | @item -Wopenmp-simd |
d77de738 ML |
9943 | Warn if the vectorizer cost model overrides the OpenMP |
9944 | simd directive set by user. The @option{-fsimd-cost-model=unlimited} | |
9945 | option can be used to relax the cost model. | |
9946 | ||
d77de738 ML |
9947 | @opindex Woverride-init |
9948 | @opindex Wno-override-init | |
9949 | @opindex W | |
9950 | @opindex Wextra | |
9951 | @opindex Wno-extra | |
ddf6fe37 | 9952 | @item -Woverride-init @r{(C and Objective-C only)} |
d77de738 ML |
9953 | Warn if an initialized field without side effects is overridden when |
9954 | using designated initializers (@pxref{Designated Inits, , Designated | |
9955 | Initializers}). | |
9956 | ||
9957 | This warning is included in @option{-Wextra}. To get other | |
9958 | @option{-Wextra} warnings without this one, use @option{-Wextra | |
9959 | -Wno-override-init}. | |
9960 | ||
d77de738 ML |
9961 | @opindex Woverride-init-side-effects |
9962 | @opindex Wno-override-init-side-effects | |
ddf6fe37 | 9963 | @item -Wno-override-init-side-effects @r{(C and Objective-C only)} |
d77de738 ML |
9964 | Do not warn if an initialized field with side effects is overridden when |
9965 | using designated initializers (@pxref{Designated Inits, , Designated | |
9966 | Initializers}). This warning is enabled by default. | |
9967 | ||
d77de738 ML |
9968 | @opindex Wpacked |
9969 | @opindex Wno-packed | |
ddf6fe37 | 9970 | @item -Wpacked |
d77de738 ML |
9971 | Warn if a structure is given the packed attribute, but the packed |
9972 | attribute has no effect on the layout or size of the structure. | |
9973 | Such structures may be mis-aligned for little benefit. For | |
9974 | instance, in this code, the variable @code{f.x} in @code{struct bar} | |
9975 | is misaligned even though @code{struct bar} does not itself | |
9976 | have the packed attribute: | |
9977 | ||
9978 | @smallexample | |
9979 | @group | |
9980 | struct foo @{ | |
9981 | int x; | |
9982 | char a, b, c, d; | |
9983 | @} __attribute__((packed)); | |
9984 | struct bar @{ | |
9985 | char z; | |
9986 | struct foo f; | |
9987 | @}; | |
9988 | @end group | |
9989 | @end smallexample | |
9990 | ||
d77de738 ML |
9991 | @opindex Wpacked-bitfield-compat |
9992 | @opindex Wno-packed-bitfield-compat | |
ddf6fe37 | 9993 | @item -Wnopacked-bitfield-compat |
d77de738 ML |
9994 | The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute |
9995 | on bit-fields of type @code{char}. This was fixed in GCC 4.4 but | |
9996 | the change can lead to differences in the structure layout. GCC | |
9997 | informs you when the offset of such a field has changed in GCC 4.4. | |
9998 | For example there is no longer a 4-bit padding between field @code{a} | |
9999 | and @code{b} in this structure: | |
10000 | ||
10001 | @smallexample | |
10002 | struct foo | |
10003 | @{ | |
10004 | char a:4; | |
10005 | char b:8; | |
10006 | @} __attribute__ ((packed)); | |
10007 | @end smallexample | |
10008 | ||
10009 | This warning is enabled by default. Use | |
10010 | @option{-Wno-packed-bitfield-compat} to disable this warning. | |
10011 | ||
d77de738 ML |
10012 | @opindex Wpacked-not-aligned |
10013 | @opindex Wno-packed-not-aligned | |
ddf6fe37 | 10014 | @item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
10015 | Warn if a structure field with explicitly specified alignment in a |
10016 | packed struct or union is misaligned. For example, a warning will | |
10017 | be issued on @code{struct S}, like, @code{warning: alignment 1 of | |
10018 | 'struct S' is less than 8}, in this code: | |
10019 | ||
10020 | @smallexample | |
10021 | @group | |
10022 | struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @}; | |
10023 | struct __attribute__ ((packed)) S @{ | |
10024 | struct S8 s8; | |
10025 | @}; | |
10026 | @end group | |
10027 | @end smallexample | |
10028 | ||
10029 | This warning is enabled by @option{-Wall}. | |
10030 | ||
d77de738 ML |
10031 | @opindex Wpadded |
10032 | @opindex Wno-padded | |
ddf6fe37 | 10033 | @item -Wpadded |
d77de738 ML |
10034 | Warn if padding is included in a structure, either to align an element |
10035 | of the structure or to align the whole structure. Sometimes when this | |
10036 | happens it is possible to rearrange the fields of the structure to | |
10037 | reduce the padding and so make the structure smaller. | |
10038 | ||
d77de738 ML |
10039 | @opindex Wredundant-decls |
10040 | @opindex Wno-redundant-decls | |
ddf6fe37 | 10041 | @item -Wredundant-decls |
d77de738 ML |
10042 | Warn if anything is declared more than once in the same scope, even in |
10043 | cases where multiple declaration is valid and changes nothing. | |
10044 | ||
d77de738 ML |
10045 | @opindex Wrestrict |
10046 | @opindex Wno-restrict | |
ddf6fe37 | 10047 | @item -Wrestrict |
d77de738 ML |
10048 | Warn when an object referenced by a @code{restrict}-qualified parameter |
10049 | (or, in C++, a @code{__restrict}-qualified parameter) is aliased by another | |
10050 | argument, or when copies between such objects overlap. For example, | |
10051 | the call to the @code{strcpy} function below attempts to truncate the string | |
10052 | by replacing its initial characters with the last four. However, because | |
10053 | the call writes the terminating NUL into @code{a[4]}, the copies overlap and | |
10054 | the call is diagnosed. | |
10055 | ||
10056 | @smallexample | |
10057 | void foo (void) | |
10058 | @{ | |
10059 | char a[] = "abcd1234"; | |
10060 | strcpy (a, a + 4); | |
10061 | @dots{} | |
10062 | @} | |
10063 | @end smallexample | |
10064 | The @option{-Wrestrict} option detects some instances of simple overlap | |
10065 | even without optimization but works best at @option{-O2} and above. It | |
10066 | is included in @option{-Wall}. | |
10067 | ||
d77de738 ML |
10068 | @opindex Wnested-externs |
10069 | @opindex Wno-nested-externs | |
ddf6fe37 | 10070 | @item -Wnested-externs @r{(C and Objective-C only)} |
d77de738 ML |
10071 | Warn if an @code{extern} declaration is encountered within a function. |
10072 | ||
d77de738 ML |
10073 | @opindex Winline |
10074 | @opindex Wno-inline | |
ddf6fe37 | 10075 | @item -Winline |
d77de738 ML |
10076 | Warn if a function that is declared as inline cannot be inlined. |
10077 | Even with this option, the compiler does not warn about failures to | |
10078 | inline functions declared in system headers. | |
10079 | ||
10080 | The compiler uses a variety of heuristics to determine whether or not | |
10081 | to inline a function. For example, the compiler takes into account | |
10082 | the size of the function being inlined and the amount of inlining | |
10083 | that has already been done in the current function. Therefore, | |
10084 | seemingly insignificant changes in the source program can cause the | |
10085 | warnings produced by @option{-Winline} to appear or disappear. | |
10086 | ||
d77de738 | 10087 | @opindex Winterference-size |
ddf6fe37 | 10088 | @item -Winterference-size |
d77de738 ML |
10089 | Warn about use of C++17 @code{std::hardware_destructive_interference_size} |
10090 | without specifying its value with @option{--param destructive-interference-size}. | |
10091 | Also warn about questionable values for that option. | |
10092 | ||
10093 | This variable is intended to be used for controlling class layout, to | |
10094 | avoid false sharing in concurrent code: | |
10095 | ||
10096 | @smallexample | |
10097 | struct independent_fields @{ | |
4ace81b6 SL |
10098 | alignas(std::hardware_destructive_interference_size) |
10099 | std::atomic<int> one; | |
10100 | alignas(std::hardware_destructive_interference_size) | |
10101 | std::atomic<int> two; | |
d77de738 ML |
10102 | @}; |
10103 | @end smallexample | |
10104 | ||
10105 | Here @samp{one} and @samp{two} are intended to be far enough apart | |
10106 | that stores to one won't require accesses to the other to reload the | |
10107 | cache line. | |
10108 | ||
10109 | By default, @option{--param destructive-interference-size} and | |
10110 | @option{--param constructive-interference-size} are set based on the | |
10111 | current @option{-mtune} option, typically to the L1 cache line size | |
10112 | for the particular target CPU, sometimes to a range if tuning for a | |
10113 | generic target. So all translation units that depend on ABI | |
10114 | compatibility for the use of these variables must be compiled with | |
10115 | the same @option{-mtune} (or @option{-mcpu}). | |
10116 | ||
10117 | If ABI stability is important, such as if the use is in a header for a | |
10118 | library, you should probably not use the hardware interference size | |
10119 | variables at all. Alternatively, you can force a particular value | |
10120 | with @option{--param}. | |
10121 | ||
10122 | If you are confident that your use of the variable does not affect ABI | |
10123 | outside a single build of your project, you can turn off the warning | |
10124 | with @option{-Wno-interference-size}. | |
10125 | ||
d77de738 ML |
10126 | @opindex Wint-in-bool-context |
10127 | @opindex Wno-int-in-bool-context | |
ddf6fe37 | 10128 | @item -Wint-in-bool-context |
d77de738 ML |
10129 | Warn for suspicious use of integer values where boolean values are expected, |
10130 | such as conditional expressions (?:) using non-boolean integer constants in | |
10131 | boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed | |
10132 | integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise | |
10133 | for all kinds of multiplications regardless of the data type. | |
10134 | This warning is enabled by @option{-Wall}. | |
10135 | ||
d77de738 ML |
10136 | @opindex Wno-int-to-pointer-cast |
10137 | @opindex Wint-to-pointer-cast | |
ddf6fe37 | 10138 | @item -Wno-int-to-pointer-cast |
d77de738 ML |
10139 | Suppress warnings from casts to pointer type of an integer of a |
10140 | different size. In C++, casting to a pointer type of smaller size is | |
10141 | an error. @option{Wint-to-pointer-cast} is enabled by default. | |
10142 | ||
10143 | ||
d77de738 ML |
10144 | @opindex Wno-pointer-to-int-cast |
10145 | @opindex Wpointer-to-int-cast | |
ddf6fe37 | 10146 | @item -Wno-pointer-to-int-cast @r{(C and Objective-C only)} |
d77de738 ML |
10147 | Suppress warnings from casts from a pointer to an integer type of a |
10148 | different size. | |
10149 | ||
d77de738 ML |
10150 | @opindex Winvalid-pch |
10151 | @opindex Wno-invalid-pch | |
ddf6fe37 | 10152 | @item -Winvalid-pch |
d77de738 ML |
10153 | Warn if a precompiled header (@pxref{Precompiled Headers}) is found in |
10154 | the search path but cannot be used. | |
10155 | ||
d77de738 ML |
10156 | @opindex Winvalid-utf8 |
10157 | @opindex Wno-invalid-utf8 | |
ddf6fe37 | 10158 | @item -Winvalid-utf8 |
d77de738 ML |
10159 | Warn if an invalid UTF-8 character is found. |
10160 | This warning is on by default for C++23 if @option{-finput-charset=UTF-8} | |
10161 | is used and turned into error with @option{-pedantic-errors}. | |
10162 | ||
d77de738 ML |
10163 | @opindex Wunicode |
10164 | @opindex Wno-unicode | |
ddf6fe37 | 10165 | @item -Wno-unicode |
d77de738 ML |
10166 | Don't diagnose invalid forms of delimited or named escape sequences which are |
10167 | treated as separate tokens. @option{Wunicode} is enabled by default. | |
10168 | ||
d77de738 ML |
10169 | @opindex Wlong-long |
10170 | @opindex Wno-long-long | |
ddf6fe37 | 10171 | @item -Wlong-long |
d77de738 ML |
10172 | Warn if @code{long long} type is used. This is enabled by either |
10173 | @option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98 | |
10174 | modes. To inhibit the warning messages, use @option{-Wno-long-long}. | |
10175 | ||
5fccebdb JM |
10176 | This warning is upgraded to an error by @option{-pedantic-errors}. |
10177 | ||
d77de738 ML |
10178 | @opindex Wvariadic-macros |
10179 | @opindex Wno-variadic-macros | |
ddf6fe37 | 10180 | @item -Wvariadic-macros |
d77de738 ML |
10181 | Warn if variadic macros are used in ISO C90 mode, or if the GNU |
10182 | alternate syntax is used in ISO C99 mode. This is enabled by either | |
10183 | @option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning | |
10184 | messages, use @option{-Wno-variadic-macros}. | |
10185 | ||
d77de738 ML |
10186 | @opindex Wvarargs |
10187 | @opindex Wno-varargs | |
ddf6fe37 | 10188 | @item -Wno-varargs |
d77de738 ML |
10189 | Do not warn upon questionable usage of the macros used to handle variable |
10190 | arguments like @code{va_start}. These warnings are enabled by default. | |
10191 | ||
d77de738 ML |
10192 | @opindex Wvector-operation-performance |
10193 | @opindex Wno-vector-operation-performance | |
ddf6fe37 | 10194 | @item -Wvector-operation-performance |
d77de738 ML |
10195 | Warn if vector operation is not implemented via SIMD capabilities of the |
10196 | architecture. Mainly useful for the performance tuning. | |
10197 | Vector operation can be implemented @code{piecewise}, which means that the | |
10198 | scalar operation is performed on every vector element; | |
10199 | @code{in parallel}, which means that the vector operation is implemented | |
10200 | using scalars of wider type, which normally is more performance efficient; | |
10201 | and @code{as a single scalar}, which means that vector fits into a | |
10202 | scalar type. | |
10203 | ||
d77de738 ML |
10204 | @opindex Wvla |
10205 | @opindex Wno-vla | |
ddf6fe37 | 10206 | @item -Wvla |
d77de738 ML |
10207 | Warn if a variable-length array is used in the code. |
10208 | @option{-Wno-vla} prevents the @option{-Wpedantic} warning of | |
10209 | the variable-length array. | |
10210 | ||
5fccebdb JM |
10211 | This warning is upgraded to an error by @option{-pedantic-errors}. |
10212 | ||
d77de738 ML |
10213 | @opindex Wvla-larger-than= |
10214 | @opindex Wno-vla-larger-than | |
ddf6fe37 | 10215 | @item -Wvla-larger-than=@var{byte-size} |
d77de738 ML |
10216 | If this option is used, the compiler warns for declarations of |
10217 | variable-length arrays whose size is either unbounded, or bounded | |
10218 | by an argument that allows the array size to exceed @var{byte-size} | |
10219 | bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size} | |
10220 | works, but with variable-length arrays. | |
10221 | ||
10222 | Note that GCC may optimize small variable-length arrays of a known | |
10223 | value into plain arrays, so this warning may not get triggered for | |
10224 | such arrays. | |
10225 | ||
10226 | @option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but | |
10227 | is typically only effective when @option{-ftree-vrp} is active (default | |
10228 | for @option{-O2} and above). | |
10229 | ||
10230 | See also @option{-Walloca-larger-than=@var{byte-size}}. | |
10231 | ||
d77de738 | 10232 | @opindex Wno-vla-larger-than |
ddf6fe37 | 10233 | @item -Wno-vla-larger-than |
d77de738 ML |
10234 | Disable @option{-Wvla-larger-than=} warnings. The option is equivalent |
10235 | to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger. | |
10236 | ||
d77de738 | 10237 | @opindex Wno-vla-parameter |
ddf6fe37 | 10238 | @item -Wvla-parameter |
d77de738 ML |
10239 | Warn about redeclarations of functions involving arguments of Variable |
10240 | Length Array types of inconsistent kinds or forms, and enable the detection | |
10241 | of out-of-bounds accesses to such parameters by warnings such as | |
10242 | @option{-Warray-bounds}. | |
10243 | ||
10244 | If the first function declaration uses the VLA form the bound specified | |
10245 | in the array is assumed to be the minimum number of elements expected to | |
10246 | be provided in calls to the function and the maximum number of elements | |
10247 | accessed by it. Failing to provide arguments of sufficient size or | |
10248 | accessing more than the maximum number of elements may be diagnosed. | |
10249 | ||
10250 | For example, the warning triggers for the following redeclarations because | |
10251 | the first one allows an array of any size to be passed to @code{f} while | |
10252 | the second one specifies that the array argument must have at least @code{n} | |
10253 | elements. In addition, calling @code{f} with the associated VLA bound | |
10254 | parameter in excess of the actual VLA bound triggers a warning as well. | |
10255 | ||
10256 | @smallexample | |
10257 | void f (int n, int[n]); | |
4ace81b6 SL |
10258 | // warning: argument 2 previously declared as a VLA |
10259 | void f (int, int[]); | |
d77de738 ML |
10260 | |
10261 | void g (int n) | |
10262 | @{ | |
10263 | if (n > 4) | |
10264 | return; | |
10265 | int a[n]; | |
4ace81b6 SL |
10266 | // warning: access to a by f may be out of bounds |
10267 | f (sizeof a, a); | |
d77de738 ML |
10268 | @dots{} |
10269 | @} | |
10270 | ||
10271 | @end smallexample | |
10272 | ||
10273 | @option{-Wvla-parameter} is included in @option{-Wall}. The | |
10274 | @option{-Warray-parameter} option triggers warnings for similar problems | |
10275 | involving ordinary array arguments. | |
10276 | ||
d77de738 ML |
10277 | @opindex Wvolatile-register-var |
10278 | @opindex Wno-volatile-register-var | |
ddf6fe37 | 10279 | @item -Wvolatile-register-var |
d77de738 ML |
10280 | Warn if a register variable is declared volatile. The volatile |
10281 | modifier does not inhibit all optimizations that may eliminate reads | |
10282 | and/or writes to register variables. This warning is enabled by | |
10283 | @option{-Wall}. | |
10284 | ||
d77de738 ML |
10285 | @opindex Wxor-used-as-pow |
10286 | @opindex Wno-xor-used-as-pow | |
ddf6fe37 | 10287 | @item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
10288 | Warn about uses of @code{^}, the exclusive or operator, where it appears |
10289 | the user meant exponentiation. Specifically, the warning occurs when the | |
10290 | left-hand side is the decimal constant 2 or 10 and the right-hand side | |
10291 | is also a decimal constant. | |
10292 | ||
10293 | In C and C++, @code{^} means exclusive or, whereas in some other languages | |
10294 | (e.g. TeX and some versions of BASIC) it means exponentiation. | |
10295 | ||
10296 | This warning is enabled by default. It can be silenced by converting one | |
10297 | of the operands to hexadecimal. | |
10298 | ||
d77de738 ML |
10299 | @opindex Wdisabled-optimization |
10300 | @opindex Wno-disabled-optimization | |
ddf6fe37 | 10301 | @item -Wdisabled-optimization |
d77de738 ML |
10302 | Warn if a requested optimization pass is disabled. This warning does |
10303 | not generally indicate that there is anything wrong with your code; it | |
10304 | merely indicates that GCC's optimizers are unable to handle the code | |
10305 | effectively. Often, the problem is that your code is too big or too | |
10306 | complex; GCC refuses to optimize programs when the optimization | |
10307 | itself is likely to take inordinate amounts of time. | |
10308 | ||
d77de738 ML |
10309 | @opindex Wpointer-sign |
10310 | @opindex Wno-pointer-sign | |
ddf6fe37 | 10311 | @item -Wpointer-sign @r{(C and Objective-C only)} |
d77de738 ML |
10312 | Warn for pointer argument passing or assignment with different signedness. |
10313 | This option is only supported for C and Objective-C@. It is implied by | |
10314 | @option{-Wall} and by @option{-Wpedantic}, which can be disabled with | |
10315 | @option{-Wno-pointer-sign}. | |
10316 | ||
5fccebdb JM |
10317 | This warning is upgraded to an error by @option{-pedantic-errors}. |
10318 | ||
d77de738 ML |
10319 | @opindex Wstack-protector |
10320 | @opindex Wno-stack-protector | |
ddf6fe37 | 10321 | @item -Wstack-protector |
d77de738 ML |
10322 | This option is only active when @option{-fstack-protector} is active. It |
10323 | warns about functions that are not protected against stack smashing. | |
10324 | ||
d77de738 ML |
10325 | @opindex Woverlength-strings |
10326 | @opindex Wno-overlength-strings | |
ddf6fe37 | 10327 | @item -Woverlength-strings |
d77de738 ML |
10328 | Warn about string constants that are longer than the ``minimum |
10329 | maximum'' length specified in the C standard. Modern compilers | |
10330 | generally allow string constants that are much longer than the | |
10331 | standard's minimum limit, but very portable programs should avoid | |
10332 | using longer strings. | |
10333 | ||
10334 | The limit applies @emph{after} string constant concatenation, and does | |
10335 | not count the trailing NUL@. In C90, the limit was 509 characters; in | |
10336 | C99, it was raised to 4095. C++98 does not specify a normative | |
10337 | minimum maximum, so we do not diagnose overlength strings in C++@. | |
10338 | ||
10339 | This option is implied by @option{-Wpedantic}, and can be disabled with | |
10340 | @option{-Wno-overlength-strings}. | |
10341 | ||
d77de738 ML |
10342 | @opindex Wunsuffixed-float-constants |
10343 | @opindex Wno-unsuffixed-float-constants | |
ddf6fe37 | 10344 | @item -Wunsuffixed-float-constants @r{(C and Objective-C only)} |
d77de738 ML |
10345 | |
10346 | Issue a warning for any floating constant that does not have | |
10347 | a suffix. When used together with @option{-Wsystem-headers} it | |
10348 | warns about such constants in system header files. This can be useful | |
10349 | when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma | |
10350 | from the decimal floating-point extension to C99. | |
10351 | ||
d77de738 ML |
10352 | @opindex Wlto-type-mismatch |
10353 | @opindex Wno-lto-type-mismatch | |
ddf6fe37 | 10354 | @item -Wno-lto-type-mismatch |
d77de738 ML |
10355 | |
10356 | During the link-time optimization, do not warn about type mismatches in | |
10357 | global declarations from different compilation units. | |
10358 | Requires @option{-flto} to be enabled. Enabled by default. | |
10359 | ||
d77de738 ML |
10360 | @opindex Wdesignated-init |
10361 | @opindex Wno-designated-init | |
ddf6fe37 | 10362 | @item -Wno-designated-init @r{(C and Objective-C only)} |
d77de738 ML |
10363 | Suppress warnings when a positional initializer is used to initialize |
10364 | a structure that has been marked with the @code{designated_init} | |
10365 | attribute. | |
10366 | ||
10367 | @end table | |
10368 | ||
10369 | @node Static Analyzer Options | |
10370 | @section Options That Control Static Analysis | |
10371 | ||
10372 | @table @gcctabopt | |
d77de738 ML |
10373 | @opindex analyzer |
10374 | @opindex fanalyzer | |
10375 | @opindex fno-analyzer | |
ddf6fe37 | 10376 | @item -fanalyzer |
d77de738 ML |
10377 | This option enables an static analysis of program flow which looks |
10378 | for ``interesting'' interprocedural paths through the | |
10379 | code, and issues warnings for problems found on them. | |
10380 | ||
10381 | This analysis is much more expensive than other GCC warnings. | |
10382 | ||
a90316c6 DM |
10383 | In technical terms, it performs coverage-guided symbolic execution of |
10384 | the code being compiled. It is neither sound nor complete: it can | |
10385 | have false positives and false negatives. It is a bug-finding tool, | |
10386 | rather than a tool for proving program correctness. | |
10387 | ||
10388 | The analyzer is only suitable for use on C code in this release. | |
10389 | ||
d77de738 ML |
10390 | Enabling this option effectively enables the following warnings: |
10391 | ||
43b72ede AA |
10392 | @gccoptlist{ |
10393 | -Wanalyzer-allocation-size | |
10394 | -Wanalyzer-deref-before-check | |
10395 | -Wanalyzer-double-fclose | |
10396 | -Wanalyzer-double-free | |
10397 | -Wanalyzer-exposure-through-output-file | |
10398 | -Wanalyzer-exposure-through-uninit-copy | |
10399 | -Wanalyzer-fd-access-mode-mismatch | |
10400 | -Wanalyzer-fd-double-close | |
10401 | -Wanalyzer-fd-leak | |
10402 | -Wanalyzer-fd-phase-mismatch | |
10403 | -Wanalyzer-fd-type-mismatch | |
10404 | -Wanalyzer-fd-use-after-close | |
10405 | -Wanalyzer-fd-use-without-check | |
10406 | -Wanalyzer-file-leak | |
10407 | -Wanalyzer-free-of-non-heap | |
10408 | -Wanalyzer-imprecise-fp-arithmetic | |
841008d3 | 10409 | -Wanalyzer-infinite-loop |
43b72ede AA |
10410 | -Wanalyzer-infinite-recursion |
10411 | -Wanalyzer-jump-through-null | |
10412 | -Wanalyzer-malloc-leak | |
10413 | -Wanalyzer-mismatching-deallocation | |
10414 | -Wanalyzer-null-argument | |
10415 | -Wanalyzer-null-dereference | |
10416 | -Wanalyzer-out-of-bounds | |
034d99e8 | 10417 | -Wanalyzer-overlapping-buffers |
43b72ede AA |
10418 | -Wanalyzer-possible-null-argument |
10419 | -Wanalyzer-possible-null-dereference | |
10420 | -Wanalyzer-putenv-of-auto-var | |
10421 | -Wanalyzer-shift-count-negative | |
10422 | -Wanalyzer-shift-count-overflow | |
10423 | -Wanalyzer-stale-setjmp-buffer | |
cfaaa8b1 DM |
10424 | -Wanalyzer-tainted-allocation-size |
10425 | -Wanalyzer-tainted-array-index | |
10426 | -Wanalyzer-tainted-assertion | |
10427 | -Wanalyzer-tainted-divisor | |
10428 | -Wanalyzer-tainted-offset | |
10429 | -Wanalyzer-tainted-size | |
f65f63c4 | 10430 | -Wanalyzer-undefined-behavior-strtok |
43b72ede AA |
10431 | -Wanalyzer-unsafe-call-within-signal-handler |
10432 | -Wanalyzer-use-after-free | |
10433 | -Wanalyzer-use-of-pointer-in-stale-stack-frame | |
10434 | -Wanalyzer-use-of-uninitialized-value | |
10435 | -Wanalyzer-va-arg-type-mismatch | |
10436 | -Wanalyzer-va-list-exhausted | |
10437 | -Wanalyzer-va-list-leak | |
10438 | -Wanalyzer-va-list-use-after-va-end | |
10439 | -Wanalyzer-write-to-const | |
10440 | -Wanalyzer-write-to-string-literal | |
d77de738 | 10441 | } |
d77de738 ML |
10442 | |
10443 | This option is only available if GCC was configured with analyzer | |
10444 | support enabled. | |
10445 | ||
d77de738 ML |
10446 | @opindex Wanalyzer-too-complex |
10447 | @opindex Wno-analyzer-too-complex | |
ddf6fe37 | 10448 | @item -Wanalyzer-too-complex |
d77de738 ML |
10449 | If @option{-fanalyzer} is enabled, the analyzer uses various heuristics |
10450 | to attempt to explore the control flow and data flow in the program, | |
10451 | but these can be defeated by sufficiently complicated code. | |
10452 | ||
10453 | By default, the analysis silently stops if the code is too | |
10454 | complicated for the analyzer to fully explore and it reaches an internal | |
10455 | limit. The @option{-Wanalyzer-too-complex} option warns if this occurs. | |
10456 | ||
d77de738 ML |
10457 | @opindex Wanalyzer-allocation-size |
10458 | @opindex Wno-analyzer-allocation-size | |
ddf6fe37 | 10459 | @item -Wno-analyzer-allocation-size |
4ace81b6 SL |
10460 | This warning requires @option{-fanalyzer}, which enables it; |
10461 | to disable it, use @option{-Wno-analyzer-allocation-size}. | |
d77de738 ML |
10462 | |
10463 | This diagnostic warns for paths through the code in which a pointer to | |
10464 | a buffer is assigned to point at a buffer with a size that is not a | |
10465 | multiple of @code{sizeof (*pointer)}. | |
10466 | ||
10467 | See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}. | |
10468 | ||
ce51e843 ML |
10469 | @opindex Wanalyzer-deref-before-check |
10470 | @opindex Wno-analyzer-deref-before-check | |
ddf6fe37 | 10471 | @item -Wno-analyzer-deref-before-check |
ce51e843 ML |
10472 | This warning requires @option{-fanalyzer}, which enables it; use |
10473 | @option{-Wno-analyzer-deref-before-check} | |
10474 | to disable it. | |
10475 | ||
10476 | This diagnostic warns for paths through the code in which a pointer | |
10477 | is checked for @code{NULL} *after* it has already been | |
10478 | dereferenced, suggesting that the pointer could have been NULL. | |
10479 | Such cases suggest that the check for NULL is either redundant, | |
10480 | or that it needs to be moved to before the pointer is dereferenced. | |
10481 | ||
10482 | This diagnostic also considers values passed to a function argument | |
10483 | marked with @code{__attribute__((nonnull))} as requiring a non-NULL | |
10484 | value, and thus will complain if such values are checked for @code{NULL} | |
10485 | after returning from such a function call. | |
10486 | ||
10487 | This diagnostic is unlikely to be reported when any level of optimization | |
10488 | is enabled, as GCC's optimization logic will typically consider such | |
10489 | checks for NULL as being redundant, and optimize them away before the | |
10490 | analyzer "sees" them. Hence optimization should be disabled when | |
10491 | attempting to trigger this diagnostic. | |
10492 | ||
d77de738 ML |
10493 | @opindex Wanalyzer-double-fclose |
10494 | @opindex Wno-analyzer-double-fclose | |
ddf6fe37 | 10495 | @item -Wno-analyzer-double-fclose |
d77de738 ML |
10496 | This warning requires @option{-fanalyzer}, which enables it; use |
10497 | @option{-Wno-analyzer-double-fclose} to disable it. | |
10498 | ||
10499 | This diagnostic warns for paths through the code in which a @code{FILE *} | |
10500 | can have @code{fclose} called on it more than once. | |
10501 | ||
10502 | See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}. | |
10503 | ||
d77de738 ML |
10504 | @opindex Wanalyzer-double-free |
10505 | @opindex Wno-analyzer-double-free | |
ddf6fe37 | 10506 | @item -Wno-analyzer-double-free |
d77de738 ML |
10507 | This warning requires @option{-fanalyzer}, which enables it; use |
10508 | @option{-Wno-analyzer-double-free} to disable it. | |
10509 | ||
10510 | This diagnostic warns for paths through the code in which a pointer | |
10511 | can have a deallocator called on it more than once, either @code{free}, | |
10512 | or a deallocator referenced by attribute @code{malloc}. | |
10513 | ||
10514 | See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}. | |
10515 | ||
d77de738 ML |
10516 | @opindex Wanalyzer-exposure-through-output-file |
10517 | @opindex Wno-analyzer-exposure-through-output-file | |
ddf6fe37 | 10518 | @item -Wno-analyzer-exposure-through-output-file |
d77de738 ML |
10519 | This warning requires @option{-fanalyzer}, which enables it; use |
10520 | @option{-Wno-analyzer-exposure-through-output-file} | |
10521 | to disable it. | |
10522 | ||
10523 | This diagnostic warns for paths through the code in which a | |
10524 | security-sensitive value is written to an output file | |
10525 | (such as writing a password to a log file). | |
10526 | ||
10527 | See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}. | |
10528 | ||
d77de738 ML |
10529 | @opindex Wanalyzer-exposure-through-uninit-copy |
10530 | @opindex Wno-analyzer-exposure-through-uninit-copy | |
ddf6fe37 | 10531 | @item -Wanalyzer-exposure-through-uninit-copy |
d77de738 ML |
10532 | This warning requires both @option{-fanalyzer} and the use of a plugin |
10533 | to specify a function that copies across a ``trust boundary''. Use | |
10534 | @option{-Wno-analyzer-exposure-through-uninit-copy} to disable it. | |
10535 | ||
10536 | This diagnostic warns for ``infoleaks'' - paths through the code in which | |
10537 | uninitialized values are copied across a security boundary | |
10538 | (such as code within an OS kernel that copies a partially-initialized | |
10539 | struct on the stack to user space). | |
10540 | ||
10541 | See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}. | |
10542 | ||
d77de738 ML |
10543 | @opindex Wanalyzer-fd-access-mode-mismatch |
10544 | @opindex Wno-analyzer-fd-access-mode-mismatch | |
ddf6fe37 | 10545 | @item -Wno-analyzer-fd-access-mode-mismatch |
d77de738 ML |
10546 | This warning requires @option{-fanalyzer}, which enables it; use |
10547 | @option{-Wno-analyzer-fd-access-mode-mismatch} | |
10548 | to disable it. | |
10549 | ||
10550 | This diagnostic warns for paths through code in which a | |
10551 | @code{read} on a write-only file descriptor is attempted, or vice versa. | |
10552 | ||
10553 | This diagnostic also warns for code paths in a which a function with attribute | |
10554 | @code{fd_arg_read (N)} is called with a file descriptor opened with | |
10555 | @code{O_WRONLY} at referenced argument @code{N} or a function with attribute | |
10556 | @code{fd_arg_write (N)} is called with a file descriptor opened with | |
10557 | @code{O_RDONLY} at referenced argument @var{N}. | |
10558 | ||
d77de738 ML |
10559 | @opindex Wanalyzer-fd-double-close |
10560 | @opindex Wno-analyzer-fd-double-close | |
ddf6fe37 | 10561 | @item -Wno-analyzer-fd-double-close |
d77de738 ML |
10562 | This warning requires @option{-fanalyzer}, which enables it; use |
10563 | @option{-Wno-analyzer-fd-double-close} | |
10564 | to disable it. | |
10565 | ||
10566 | This diagnostic warns for paths through code in which a | |
10567 | file descriptor can be closed more than once. | |
10568 | ||
10569 | See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}. | |
10570 | ||
d77de738 ML |
10571 | @opindex Wanalyzer-fd-leak |
10572 | @opindex Wno-analyzer-fd-leak | |
ddf6fe37 | 10573 | @item -Wno-analyzer-fd-leak |
d77de738 ML |
10574 | This warning requires @option{-fanalyzer}, which enables it; use |
10575 | @option{-Wno-analyzer-fd-leak} | |
10576 | to disable it. | |
10577 | ||
10578 | This diagnostic warns for paths through code in which an | |
10579 | open file descriptor is leaked. | |
10580 | ||
10581 | See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}. | |
10582 | ||
86a90006 DM |
10583 | @opindex Wanalyzer-fd-phase-mismatch |
10584 | @opindex Wno-analyzer-fd-phase-mismatch | |
ddf6fe37 | 10585 | @item -Wno-analyzer-fd-phase-mismatch |
86a90006 DM |
10586 | This warning requires @option{-fanalyzer}, which enables it; use |
10587 | @option{-Wno-analyzer-fd-phase-mismatch} | |
10588 | to disable it. | |
10589 | ||
10590 | This diagnostic warns for paths through code in which an operation is | |
10591 | attempted in the wrong phase of a file descriptor's lifetime. | |
10592 | For example, it will warn on attempts to call @code{accept} on a stream | |
10593 | socket that has not yet had @code{listen} successfully called on it. | |
10594 | ||
10595 | See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}. | |
10596 | ||
86a90006 DM |
10597 | @opindex Wanalyzer-fd-type-mismatch |
10598 | @opindex Wno-analyzer-fd-type-mismatch | |
ddf6fe37 | 10599 | @item -Wno-analyzer-fd-type-mismatch |
86a90006 DM |
10600 | This warning requires @option{-fanalyzer}, which enables it; use |
10601 | @option{-Wno-analyzer-fd-type-mismatch} | |
10602 | to disable it. | |
10603 | ||
10604 | This diagnostic warns for paths through code in which an | |
10605 | operation is attempted on the wrong type of file descriptor. | |
10606 | For example, it will warn on attempts to use socket operations | |
10607 | on a file descriptor obtained via @code{open}, or when attempting | |
10608 | to use a stream socket operation on a datagram socket. | |
10609 | ||
d77de738 ML |
10610 | @opindex Wanalyzer-fd-use-after-close |
10611 | @opindex Wno-analyzer-fd-use-after-close | |
ddf6fe37 | 10612 | @item -Wno-analyzer-fd-use-after-close |
d77de738 ML |
10613 | This warning requires @option{-fanalyzer}, which enables it; use |
10614 | @option{-Wno-analyzer-fd-use-after-close} | |
10615 | to disable it. | |
10616 | ||
10617 | This diagnostic warns for paths through code in which a | |
10618 | read or write is called on a closed file descriptor. | |
10619 | ||
10620 | This diagnostic also warns for paths through code in which | |
10621 | a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)} | |
10622 | or @code{fd_arg_write (N)} is called with a closed file descriptor at | |
10623 | referenced argument @code{N}. | |
10624 | ||
d77de738 ML |
10625 | @opindex Wanalyzer-fd-use-without-check |
10626 | @opindex Wno-analyzer-fd-use-without-check | |
ddf6fe37 | 10627 | @item -Wno-analyzer-fd-use-without-check |
d77de738 ML |
10628 | This warning requires @option{-fanalyzer}, which enables it; use |
10629 | @option{-Wno-analyzer-fd-use-without-check} | |
10630 | to disable it. | |
10631 | ||
10632 | This diagnostic warns for paths through code in which a | |
10633 | file descriptor is used without being checked for validity. | |
10634 | ||
10635 | This diagnostic also warns for paths through code in which | |
10636 | a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)} | |
10637 | or @code{fd_arg_write (N)} is called with a file descriptor, at referenced | |
10638 | argument @code{N}, without being checked for validity. | |
10639 | ||
d77de738 ML |
10640 | @opindex Wanalyzer-file-leak |
10641 | @opindex Wno-analyzer-file-leak | |
ddf6fe37 | 10642 | @item -Wno-analyzer-file-leak |
d77de738 ML |
10643 | This warning requires @option{-fanalyzer}, which enables it; use |
10644 | @option{-Wno-analyzer-file-leak} | |
10645 | to disable it. | |
10646 | ||
10647 | This diagnostic warns for paths through the code in which a | |
10648 | @code{<stdio.h>} @code{FILE *} stream object is leaked. | |
10649 | ||
10650 | See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}. | |
10651 | ||
d77de738 ML |
10652 | @opindex Wanalyzer-free-of-non-heap |
10653 | @opindex Wno-analyzer-free-of-non-heap | |
ddf6fe37 | 10654 | @item -Wno-analyzer-free-of-non-heap |
d77de738 ML |
10655 | This warning requires @option{-fanalyzer}, which enables it; use |
10656 | @option{-Wno-analyzer-free-of-non-heap} | |
10657 | to disable it. | |
10658 | ||
10659 | This diagnostic warns for paths through the code in which @code{free} | |
10660 | is called on a non-heap pointer (e.g. an on-stack buffer, or a global). | |
10661 | ||
10662 | See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}. | |
10663 | ||
d77de738 ML |
10664 | @opindex Wanalyzer-imprecise-fp-arithmetic |
10665 | @opindex Wno-analyzer-imprecise-fp-arithmetic | |
ddf6fe37 | 10666 | @item -Wno-analyzer-imprecise-fp-arithmetic |
d77de738 ML |
10667 | This warning requires @option{-fanalyzer}, which enables it; use |
10668 | @option{-Wno-analyzer-imprecise-fp-arithmetic} | |
10669 | to disable it. | |
10670 | ||
10671 | This diagnostic warns for paths through the code in which floating-point | |
10672 | arithmetic is used in locations where precise computation is needed. This | |
10673 | diagnostic only warns on use of floating-point operands inside the | |
10674 | calculation of an allocation size at the moment. | |
10675 | ||
841008d3 DM |
10676 | @opindex Wanalyzer-infinite-loop |
10677 | @opindex Wno-analyzer-infinite-loop | |
10678 | @item -Wno-analyzer-infinite-loop | |
10679 | This warning requires @option{-fanalyzer}, which enables it; use | |
10680 | @option{-Wno-analyzer-infinite-loop} to disable it. | |
10681 | ||
10682 | This diagnostics warns for paths through the code which appear to | |
10683 | lead to an infinite loop. | |
10684 | ||
10685 | Specifically, the analyzer will issue this warning when it "sees" a loop | |
10686 | in which: | |
10687 | @itemize @bullet | |
10688 | @item | |
10689 | no externally-visible work could be being done within the loop | |
10690 | @item | |
10691 | there is no way to escape from the loop | |
10692 | @item | |
10693 | the analyzer is sufficiently confident about the program state | |
10694 | throughout the loop to know that the above are true | |
10695 | @end itemize | |
10696 | ||
10697 | One way for this warning to be emitted is when there is an execution | |
10698 | path through a loop for which taking the path on one iteration implies | |
10699 | that the same path will be taken on all subsequent iterations. | |
10700 | ||
10701 | For example, consider: | |
10702 | ||
10703 | @smallexample | |
10704 | while (1) | |
10705 | @{ | |
10706 | char opcode = *cpu_state.pc; | |
10707 | switch (opcode) | |
10708 | @{ | |
10709 | case OPCODE_FOO: | |
10710 | handle_opcode_foo (&cpu_state); | |
10711 | break; | |
10712 | case OPCODE_BAR: | |
10713 | handle_opcode_bar (&cpu_state); | |
10714 | break; | |
10715 | @} | |
10716 | @} | |
10717 | @end smallexample | |
10718 | ||
10719 | The analyzer will complain for the above case because if @code{opcode} | |
10720 | ever matches none of the cases, the @code{switch} will follow the | |
10721 | implicit @code{default} case, making the body of the loop be a ``no-op'' | |
10722 | with @code{cpu_state.pc} unchanged, and thus using the same value of | |
10723 | @code{opcode} on all subseqent iterations, leading to an infinite loop. | |
10724 | ||
10725 | See @uref{https://cwe.mitre.org/data/definitions/835.html, CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')}. | |
10726 | ||
ce51e843 ML |
10727 | @opindex Wanalyzer-infinite-recursion |
10728 | @opindex Wno-analyzer-infinite-recursion | |
ddf6fe37 | 10729 | @item -Wno-analyzer-infinite-recursion |
ce51e843 ML |
10730 | This warning requires @option{-fanalyzer}, which enables it; use |
10731 | @option{-Wno-analyzer-infinite-recursion} to disable it. | |
10732 | ||
10733 | This diagnostics warns for paths through the code which appear to | |
10734 | lead to infinite recursion. | |
10735 | ||
10736 | Specifically, when the analyzer "sees" a recursive call, it will compare | |
10737 | the state of memory at the entry to the new frame with that at the entry | |
10738 | to the previous frame of that function on the stack. The warning is | |
10739 | issued if nothing in memory appears to be changing; any changes observed | |
10740 | to parameters or globals are assumed to lead to termination of the | |
10741 | recursion and thus suppress the warning. | |
10742 | ||
10743 | This diagnostic is likely to miss cases of infinite recursion that | |
10744 | are convered to iteration by the optimizer before the analyzer "sees" | |
10745 | them. Hence optimization should be disabled when attempting to trigger | |
10746 | this diagnostic. | |
10747 | ||
10748 | Compare with @option{-Winfinite-recursion}, which provides a similar | |
10749 | diagnostic, but is implemented in a different way. | |
10750 | ||
841008d3 DM |
10751 | See @uref{https://cwe.mitre.org/data/definitions/674.html, CWE-674: Uncontrolled Recursion}. |
10752 | ||
d77de738 ML |
10753 | @opindex Wanalyzer-jump-through-null |
10754 | @opindex Wno-analyzer-jump-through-null | |
ddf6fe37 | 10755 | @item -Wno-analyzer-jump-through-null |
d77de738 ML |
10756 | This warning requires @option{-fanalyzer}, which enables it; use |
10757 | @option{-Wno-analyzer-jump-through-null} | |
10758 | to disable it. | |
10759 | ||
10760 | This diagnostic warns for paths through the code in which a @code{NULL} | |
10761 | function pointer is called. | |
10762 | ||
d77de738 ML |
10763 | @opindex Wanalyzer-malloc-leak |
10764 | @opindex Wno-analyzer-malloc-leak | |
ddf6fe37 | 10765 | @item -Wno-analyzer-malloc-leak |
d77de738 ML |
10766 | This warning requires @option{-fanalyzer}, which enables it; use |
10767 | @option{-Wno-analyzer-malloc-leak} | |
10768 | to disable it. | |
10769 | ||
10770 | This diagnostic warns for paths through the code in which a | |
10771 | pointer allocated via an allocator is leaked: either @code{malloc}, | |
10772 | or a function marked with attribute @code{malloc}. | |
10773 | ||
10774 | See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}. | |
10775 | ||
d77de738 ML |
10776 | @opindex Wanalyzer-mismatching-deallocation |
10777 | @opindex Wno-analyzer-mismatching-deallocation | |
ddf6fe37 | 10778 | @item -Wno-analyzer-mismatching-deallocation |
d77de738 ML |
10779 | This warning requires @option{-fanalyzer}, which enables it; use |
10780 | @option{-Wno-analyzer-mismatching-deallocation} | |
10781 | to disable it. | |
10782 | ||
10783 | This diagnostic warns for paths through the code in which the | |
10784 | wrong deallocation function is called on a pointer value, based on | |
10785 | which function was used to allocate the pointer value. The diagnostic | |
10786 | will warn about mismatches between @code{free}, scalar @code{delete} | |
10787 | and vector @code{delete[]}, and those marked as allocator/deallocator | |
10788 | pairs using attribute @code{malloc}. | |
10789 | ||
10790 | See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}. | |
10791 | ||
d77de738 ML |
10792 | @opindex Wanalyzer-out-of-bounds |
10793 | @opindex Wno-analyzer-out-of-bounds | |
ddf6fe37 | 10794 | @item -Wno-analyzer-out-of-bounds |
4ace81b6 | 10795 | This warning requires @option{-fanalyzer}, which enables it; use |
d77de738 ML |
10796 | @option{-Wno-analyzer-out-of-bounds} to disable it. |
10797 | ||
4ace81b6 | 10798 | This diagnostic warns for paths through the code in which a buffer is |
d77de738 ML |
10799 | definitely read or written out-of-bounds. The diagnostic applies for |
10800 | cases where the analyzer is able to determine a constant offset and for | |
10801 | accesses past the end of a buffer, also a constant capacity. Further, | |
10802 | the diagnostic does limited checking for accesses past the end when the | |
10803 | offset as well as the capacity is symbolic. | |
10804 | ||
10805 | See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}. | |
10806 | ||
0e466e97 DM |
10807 | For cases where the analyzer is able, it will emit a text art diagram |
10808 | visualizing the spatial relationship between the memory region that the | |
10809 | analyzer predicts would be accessed, versus the range of memory that is | |
10810 | valid to access: whether they overlap, are touching, are close or far | |
10811 | apart; which one is before or after in memory, the relative sizes | |
10812 | involved, the direction of the access (read vs write), and, in some | |
10813 | cases, the values of data involved. This diagram can be suppressed | |
10814 | using @option{-fdiagnostics-text-art-charset=none}. | |
10815 | ||
034d99e8 DM |
10816 | @opindex Wanalyzer-overlapping-buffers |
10817 | @opindex Wno-analyzer-overlapping-buffers | |
10818 | @item -Wno-analyzer-overlapping-buffers | |
10819 | This warning requires @option{-fanalyzer}, which enables it; use | |
10820 | @option{-Wno-analyzer-overlapping-buffers} to disable it. | |
10821 | ||
10822 | This diagnostic warns for paths through the code in which overlapping | |
10823 | buffers are passed to an API for which the behavior on such buffers | |
10824 | is undefined. | |
10825 | ||
10826 | Specifically, the diagnostic occurs on calls to the following functions | |
10827 | @itemize @bullet | |
10828 | @item @code{memcpy} | |
10829 | @item @code{strcat} | |
10830 | @item @code{strcpy} | |
10831 | @end itemize | |
10832 | for cases where the buffers are known to overlap. | |
10833 | ||
d77de738 ML |
10834 | @opindex Wanalyzer-possible-null-argument |
10835 | @opindex Wno-analyzer-possible-null-argument | |
ddf6fe37 | 10836 | @item -Wno-analyzer-possible-null-argument |
d77de738 ML |
10837 | This warning requires @option{-fanalyzer}, which enables it; use |
10838 | @option{-Wno-analyzer-possible-null-argument} to disable it. | |
10839 | ||
10840 | This diagnostic warns for paths through the code in which a | |
10841 | possibly-NULL value is passed to a function argument marked | |
10842 | with @code{__attribute__((nonnull))} as requiring a non-NULL | |
10843 | value. | |
10844 | ||
10845 | See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}. | |
10846 | ||
d77de738 ML |
10847 | @opindex Wanalyzer-possible-null-dereference |
10848 | @opindex Wno-analyzer-possible-null-dereference | |
ddf6fe37 | 10849 | @item -Wno-analyzer-possible-null-dereference |
d77de738 ML |
10850 | This warning requires @option{-fanalyzer}, which enables it; use |
10851 | @option{-Wno-analyzer-possible-null-dereference} to disable it. | |
10852 | ||
10853 | This diagnostic warns for paths through the code in which a | |
10854 | possibly-NULL value is dereferenced. | |
10855 | ||
10856 | See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}. | |
10857 | ||
d77de738 ML |
10858 | @opindex Wanalyzer-null-argument |
10859 | @opindex Wno-analyzer-null-argument | |
ddf6fe37 | 10860 | @item -Wno-analyzer-null-argument |
d77de738 ML |
10861 | This warning requires @option{-fanalyzer}, which enables it; use |
10862 | @option{-Wno-analyzer-null-argument} to disable it. | |
10863 | ||
10864 | This diagnostic warns for paths through the code in which a | |
10865 | value known to be NULL is passed to a function argument marked | |
10866 | with @code{__attribute__((nonnull))} as requiring a non-NULL | |
10867 | value. | |
10868 | ||
10869 | See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}. | |
10870 | ||
d77de738 ML |
10871 | @opindex Wanalyzer-null-dereference |
10872 | @opindex Wno-analyzer-null-dereference | |
ddf6fe37 | 10873 | @item -Wno-analyzer-null-dereference |
d77de738 ML |
10874 | This warning requires @option{-fanalyzer}, which enables it; use |
10875 | @option{-Wno-analyzer-null-dereference} to disable it. | |
10876 | ||
10877 | This diagnostic warns for paths through the code in which a | |
10878 | value known to be NULL is dereferenced. | |
10879 | ||
10880 | See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}. | |
10881 | ||
d77de738 ML |
10882 | @opindex Wanalyzer-putenv-of-auto-var |
10883 | @opindex Wno-analyzer-putenv-of-auto-var | |
ddf6fe37 | 10884 | @item -Wno-analyzer-putenv-of-auto-var |
d77de738 ML |
10885 | This warning requires @option{-fanalyzer}, which enables it; use |
10886 | @option{-Wno-analyzer-putenv-of-auto-var} to disable it. | |
10887 | ||
10888 | This diagnostic warns for paths through the code in which a | |
10889 | call to @code{putenv} is passed a pointer to an automatic variable | |
10890 | or an on-stack buffer. | |
10891 | ||
10892 | 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}. | |
10893 | ||
d77de738 ML |
10894 | @opindex Wanalyzer-shift-count-negative |
10895 | @opindex Wno-analyzer-shift-count-negative | |
ddf6fe37 | 10896 | @item -Wno-analyzer-shift-count-negative |
d77de738 ML |
10897 | This warning requires @option{-fanalyzer}, which enables it; use |
10898 | @option{-Wno-analyzer-shift-count-negative} to disable it. | |
10899 | ||
10900 | This diagnostic warns for paths through the code in which a | |
10901 | shift is attempted with a negative count. It is analogous to | |
10902 | the @option{-Wshift-count-negative} diagnostic implemented in | |
10903 | the C/C++ front ends, but is implemented based on analyzing | |
10904 | interprocedural paths, rather than merely parsing the syntax tree. | |
10905 | However, the analyzer does not prioritize detection of such paths, so | |
10906 | false negatives are more likely relative to other warnings. | |
10907 | ||
d77de738 ML |
10908 | @opindex Wanalyzer-shift-count-overflow |
10909 | @opindex Wno-analyzer-shift-count-overflow | |
ddf6fe37 | 10910 | @item -Wno-analyzer-shift-count-overflow |
d77de738 ML |
10911 | This warning requires @option{-fanalyzer}, which enables it; use |
10912 | @option{-Wno-analyzer-shift-count-overflow} to disable it. | |
10913 | ||
10914 | This diagnostic warns for paths through the code in which a | |
10915 | shift is attempted with a count greater than or equal to the | |
10916 | precision of the operand's type. It is analogous to | |
10917 | the @option{-Wshift-count-overflow} diagnostic implemented in | |
10918 | the C/C++ front ends, but is implemented based on analyzing | |
10919 | interprocedural paths, rather than merely parsing the syntax tree. | |
10920 | However, the analyzer does not prioritize detection of such paths, so | |
10921 | false negatives are more likely relative to other warnings. | |
10922 | ||
d77de738 ML |
10923 | @opindex Wanalyzer-stale-setjmp-buffer |
10924 | @opindex Wno-analyzer-stale-setjmp-buffer | |
ddf6fe37 | 10925 | @item -Wno-analyzer-stale-setjmp-buffer |
d77de738 ML |
10926 | This warning requires @option{-fanalyzer}, which enables it; use |
10927 | @option{-Wno-analyzer-stale-setjmp-buffer} to disable it. | |
10928 | ||
10929 | This diagnostic warns for paths through the code in which | |
10930 | @code{longjmp} is called to rewind to a @code{jmp_buf} relating | |
10931 | to a @code{setjmp} call in a function that has returned. | |
10932 | ||
10933 | When @code{setjmp} is called on a @code{jmp_buf} to record a rewind | |
10934 | location, it records the stack frame. The stack frame becomes invalid | |
10935 | when the function containing the @code{setjmp} call returns. Attempting | |
10936 | to rewind to it via @code{longjmp} would reference a stack frame that | |
10937 | no longer exists, and likely lead to a crash (or worse). | |
10938 | ||
d77de738 ML |
10939 | @opindex Wanalyzer-tainted-allocation-size |
10940 | @opindex Wno-analyzer-tainted-allocation-size | |
ddf6fe37 | 10941 | @item -Wno-analyzer-tainted-allocation-size |
cfaaa8b1 | 10942 | This warning requires @option{-fanalyzer} which enables it; |
d77de738 ML |
10943 | use @option{-Wno-analyzer-tainted-allocation-size} to disable it. |
10944 | ||
10945 | This diagnostic warns for paths through the code in which a value | |
10946 | that could be under an attacker's control is used as the size | |
10947 | of an allocation without being sanitized, so that an attacker could | |
10948 | inject an excessively large allocation and potentially cause a denial | |
10949 | of service attack. | |
10950 | ||
10951 | See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}. | |
10952 | ||
ce51e843 ML |
10953 | @opindex Wanalyzer-tainted-assertion |
10954 | @opindex Wno-analyzer-tainted-assertion | |
ddf6fe37 | 10955 | @item -Wno-analyzer-tainted-assertion |
ce51e843 | 10956 | |
cfaaa8b1 | 10957 | This warning requires @option{-fanalyzer} which enables it; |
ce51e843 ML |
10958 | use @option{-Wno-analyzer-tainted-assertion} to disable it. |
10959 | ||
10960 | This diagnostic warns for paths through the code in which a value | |
10961 | that could be under an attacker's control is used as part of a | |
10962 | condition without being first sanitized, and that condition guards a | |
10963 | call to a function marked with attribute @code{noreturn} | |
10964 | (such as the function @code{__builtin_unreachable}). Such functions | |
10965 | typically indicate abnormal termination of the program, such as for | |
10966 | assertion failure handlers. For example: | |
10967 | ||
10968 | @smallexample | |
10969 | assert (some_tainted_value < SOME_LIMIT); | |
10970 | @end smallexample | |
10971 | ||
10972 | In such cases: | |
10973 | ||
10974 | @itemize | |
10975 | @item | |
10976 | when assertion-checking is enabled: an attacker could trigger | |
10977 | a denial of service by injecting an assertion failure | |
10978 | ||
10979 | @item | |
10980 | when assertion-checking is disabled, such as by defining @code{NDEBUG}, | |
10981 | an attacker could inject data that subverts the process, since it | |
10982 | presumably violates a precondition that is being assumed by the code. | |
10983 | ||
10984 | @end itemize | |
10985 | ||
10986 | Note that when assertion-checking is disabled, the assertions are | |
10987 | typically removed by the preprocessor before the analyzer has a chance | |
10988 | to "see" them, so this diagnostic can only generate warnings on builds | |
10989 | in which assertion-checking is enabled. | |
10990 | ||
10991 | For the purpose of this warning, any function marked with attribute | |
10992 | @code{noreturn} is considered as a possible assertion failure | |
10993 | handler, including @code{__builtin_unreachable}. Note that these functions | |
10994 | are sometimes removed by the optimizer before the analyzer "sees" them. | |
10995 | Hence optimization should be disabled when attempting to trigger this | |
10996 | diagnostic. | |
10997 | ||
10998 | See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}. | |
10999 | ||
11000 | The warning can also report problematic constructions such as | |
11001 | ||
11002 | @smallexample | |
11003 | switch (some_tainted_value) @{ | |
11004 | case 0: | |
11005 | /* [...etc; various valid cases omitted...] */ | |
11006 | break; | |
11007 | ||
11008 | default: | |
11009 | __builtin_unreachable (); /* BUG: attacker can trigger this */ | |
11010 | @} | |
11011 | @end smallexample | |
11012 | ||
11013 | despite the above not being an assertion failure, strictly speaking. | |
11014 | ||
d77de738 ML |
11015 | @opindex Wanalyzer-tainted-array-index |
11016 | @opindex Wno-analyzer-tainted-array-index | |
ddf6fe37 | 11017 | @item -Wno-analyzer-tainted-array-index |
cfaaa8b1 | 11018 | This warning requires @option{-fanalyzer} which enables it; |
d77de738 ML |
11019 | use @option{-Wno-analyzer-tainted-array-index} to disable it. |
11020 | ||
11021 | This diagnostic warns for paths through the code in which a value | |
11022 | that could be under an attacker's control is used as the index | |
11023 | of an array access without being sanitized, so that an attacker | |
11024 | could inject an out-of-bounds access. | |
11025 | ||
11026 | See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. | |
11027 | ||
d77de738 ML |
11028 | @opindex Wanalyzer-tainted-divisor |
11029 | @opindex Wno-analyzer-tainted-divisor | |
ddf6fe37 | 11030 | @item -Wno-analyzer-tainted-divisor |
cfaaa8b1 | 11031 | This warning requires @option{-fanalyzer} which enables it; |
d77de738 ML |
11032 | use @option{-Wno-analyzer-tainted-divisor} to disable it. |
11033 | ||
11034 | This diagnostic warns for paths through the code in which a value | |
11035 | that could be under an attacker's control is used as the divisor | |
11036 | in a division or modulus operation without being sanitized, so that | |
11037 | an attacker could inject a division-by-zero. | |
11038 | ||
11039 | See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}. | |
11040 | ||
d77de738 ML |
11041 | @opindex Wanalyzer-tainted-offset |
11042 | @opindex Wno-analyzer-tainted-offset | |
ddf6fe37 | 11043 | @item -Wno-analyzer-tainted-offset |
cfaaa8b1 | 11044 | This warning requires @option{-fanalyzer} which enables it; |
d77de738 ML |
11045 | use @option{-Wno-analyzer-tainted-offset} to disable it. |
11046 | ||
11047 | This diagnostic warns for paths through the code in which a value | |
11048 | that could be under an attacker's control is used as a pointer offset | |
11049 | without being sanitized, so that an attacker could inject an out-of-bounds | |
11050 | access. | |
11051 | ||
11052 | See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}. | |
11053 | ||
d77de738 ML |
11054 | @opindex Wanalyzer-tainted-size |
11055 | @opindex Wno-analyzer-tainted-size | |
ddf6fe37 | 11056 | @item -Wno-analyzer-tainted-size |
cfaaa8b1 | 11057 | This warning requires @option{-fanalyzer} which enables it; |
d77de738 ML |
11058 | use @option{-Wno-analyzer-tainted-size} to disable it. |
11059 | ||
11060 | This diagnostic warns for paths through the code in which a value | |
11061 | that could be under an attacker's control is used as the size of | |
11062 | an operation such as @code{memset} without being sanitized, so that an | |
11063 | attacker could inject an out-of-bounds access. | |
11064 | ||
11065 | See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. | |
11066 | ||
f65f63c4 DM |
11067 | @opindex Wanalyzer-undefined-behavior-strtok |
11068 | @opindex Wno-analyzer-undefined-behavior-strtok | |
11069 | @item -Wno-analyzer-undefined-behavior-strtok | |
11070 | This warning requires @option{-fanalyzer}, which enables it; use | |
11071 | @option{-Wno-analyzer-undefined-behavior-strtok} to disable it. | |
11072 | ||
11073 | This diagnostic warns for paths through the code in which a | |
11074 | call is made to @code{strtok} with undefined behavior. | |
11075 | ||
11076 | Specifically, passing NULL as the first parameter for the initial | |
11077 | call to @code{strtok} within a process has undefined behavior. | |
11078 | ||
d77de738 ML |
11079 | @opindex Wanalyzer-unsafe-call-within-signal-handler |
11080 | @opindex Wno-analyzer-unsafe-call-within-signal-handler | |
ddf6fe37 | 11081 | @item -Wno-analyzer-unsafe-call-within-signal-handler |
d77de738 ML |
11082 | This warning requires @option{-fanalyzer}, which enables it; use |
11083 | @option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it. | |
11084 | ||
11085 | This diagnostic warns for paths through the code in which a | |
11086 | function known to be async-signal-unsafe (such as @code{fprintf}) is | |
11087 | called from a signal handler. | |
11088 | ||
11089 | See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}. | |
11090 | ||
d77de738 ML |
11091 | @opindex Wanalyzer-use-after-free |
11092 | @opindex Wno-analyzer-use-after-free | |
ddf6fe37 | 11093 | @item -Wno-analyzer-use-after-free |
d77de738 ML |
11094 | This warning requires @option{-fanalyzer}, which enables it; use |
11095 | @option{-Wno-analyzer-use-after-free} to disable it. | |
11096 | ||
11097 | This diagnostic warns for paths through the code in which a | |
11098 | pointer is used after a deallocator is called on it: either @code{free}, | |
11099 | or a deallocator referenced by attribute @code{malloc}. | |
11100 | ||
11101 | See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}. | |
11102 | ||
d77de738 ML |
11103 | @opindex Wanalyzer-use-of-pointer-in-stale-stack-frame |
11104 | @opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame | |
ddf6fe37 | 11105 | @item -Wno-analyzer-use-of-pointer-in-stale-stack-frame |
d77de738 ML |
11106 | This warning requires @option{-fanalyzer}, which enables it; use |
11107 | @option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame} | |
11108 | to disable it. | |
11109 | ||
11110 | This diagnostic warns for paths through the code in which a pointer | |
11111 | is dereferenced that points to a variable in a stale stack frame. | |
11112 | ||
d77de738 ML |
11113 | @opindex Wanalyzer-va-arg-type-mismatch |
11114 | @opindex Wno-analyzer-va-arg-type-mismatch | |
ddf6fe37 | 11115 | @item -Wno-analyzer-va-arg-type-mismatch |
d77de738 ML |
11116 | This warning requires @option{-fanalyzer}, which enables it; use |
11117 | @option{-Wno-analyzer-va-arg-type-mismatch} | |
11118 | to disable it. | |
11119 | ||
11120 | This diagnostic warns for interprocedural paths through the code for which | |
11121 | the analyzer detects an attempt to use @code{va_arg} to extract a value | |
11122 | passed to a variadic call, but uses a type that does not match that of | |
11123 | the expression passed to the call. | |
11124 | ||
11125 | See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}. | |
11126 | ||
d77de738 ML |
11127 | @opindex Wanalyzer-va-list-exhausted |
11128 | @opindex Wno-analyzer-va-list-exhausted | |
ddf6fe37 | 11129 | @item -Wno-analyzer-va-list-exhausted |
d77de738 ML |
11130 | This warning requires @option{-fanalyzer}, which enables it; use |
11131 | @option{-Wno-analyzer-va-list-exhausted} | |
11132 | to disable it. | |
11133 | ||
11134 | This diagnostic warns for interprocedural paths through the code for which | |
11135 | the analyzer detects an attempt to use @code{va_arg} to access the next | |
11136 | value passed to a variadic call, but all of the values in the | |
11137 | @code{va_list} have already been consumed. | |
11138 | ||
11139 | See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}. | |
11140 | ||
d77de738 ML |
11141 | @opindex Wanalyzer-va-list-leak |
11142 | @opindex Wno-analyzer-va-list-leak | |
ddf6fe37 | 11143 | @item -Wno-analyzer-va-list-leak |
d77de738 ML |
11144 | This warning requires @option{-fanalyzer}, which enables it; use |
11145 | @option{-Wno-analyzer-va-list-leak} | |
11146 | to disable it. | |
11147 | ||
11148 | This diagnostic warns for interprocedural paths through the code for which | |
11149 | the analyzer detects that @code{va_start} or @code{va_copy} has been called | |
11150 | on a @code{va_list} without a corresponding call to @code{va_end}. | |
11151 | ||
d77de738 ML |
11152 | @opindex Wanalyzer-va-list-use-after-va-end |
11153 | @opindex Wno-analyzer-va-list-use-after-va-end | |
ddf6fe37 | 11154 | @item -Wno-analyzer-va-list-use-after-va-end |
d77de738 ML |
11155 | This warning requires @option{-fanalyzer}, which enables it; use |
11156 | @option{-Wno-analyzer-va-list-use-after-va-end} | |
11157 | to disable it. | |
11158 | ||
11159 | This diagnostic warns for interprocedural paths through the code for which | |
11160 | the analyzer detects an attempt to use a @code{va_list} after | |
11161 | @code{va_end} has been called on it. | |
11162 | @code{va_list}. | |
11163 | ||
d77de738 ML |
11164 | @opindex Wanalyzer-write-to-const |
11165 | @opindex Wno-analyzer-write-to-const | |
ddf6fe37 | 11166 | @item -Wno-analyzer-write-to-const |
d77de738 ML |
11167 | This warning requires @option{-fanalyzer}, which enables it; use |
11168 | @option{-Wno-analyzer-write-to-const} | |
11169 | to disable it. | |
11170 | ||
11171 | This diagnostic warns for paths through the code in which the analyzer | |
11172 | detects an attempt to write through a pointer to a @code{const} object. | |
11173 | However, the analyzer does not prioritize detection of such paths, so | |
11174 | false negatives are more likely relative to other warnings. | |
11175 | ||
d77de738 ML |
11176 | @opindex Wanalyzer-write-to-string-literal |
11177 | @opindex Wno-analyzer-write-to-string-literal | |
ddf6fe37 | 11178 | @item -Wno-analyzer-write-to-string-literal |
d77de738 ML |
11179 | This warning requires @option{-fanalyzer}, which enables it; use |
11180 | @option{-Wno-analyzer-write-to-string-literal} | |
11181 | to disable it. | |
11182 | ||
11183 | This diagnostic warns for paths through the code in which the analyzer | |
11184 | detects an attempt to write through a pointer to a string literal. | |
11185 | However, the analyzer does not prioritize detection of such paths, so | |
11186 | false negatives are more likely relative to other warnings. | |
11187 | ||
d77de738 ML |
11188 | @opindex Wanalyzer-use-of-uninitialized-value |
11189 | @opindex Wno-analyzer-use-of-uninitialized-value | |
ddf6fe37 | 11190 | @item -Wno-analyzer-use-of-uninitialized-value |
d77de738 ML |
11191 | This warning requires @option{-fanalyzer}, which enables it; use |
11192 | @option{-Wno-analyzer-use-of-uninitialized-value} to disable it. | |
11193 | ||
11194 | This diagnostic warns for paths through the code in which an uninitialized | |
11195 | value is used. | |
11196 | ||
11197 | See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}. | |
11198 | ||
11199 | @end table | |
11200 | ||
11201 | The analyzer has hardcoded knowledge about the behavior of the following | |
11202 | memory-management functions: | |
11203 | ||
11204 | @itemize @bullet | |
11205 | @item @code{alloca} | |
11206 | @item The built-in functions @code{__builtin_alloc}, | |
11207 | @code{__builtin_alloc_with_align}, @item @code{__builtin_calloc}, | |
11208 | @code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy}, | |
11209 | @code{__builtin_memcpy_chk}, @code{__builtin_memset}, | |
11210 | @code{__builtin_memset_chk}, @code{__builtin_realloc}, | |
11211 | @code{__builtin_stack_restore}, and @code{__builtin_stack_save} | |
11212 | @item @code{calloc} | |
11213 | @item @code{free} | |
11214 | @item @code{malloc} | |
11215 | @item @code{memset} | |
11216 | @item @code{operator delete} | |
11217 | @item @code{operator delete []} | |
11218 | @item @code{operator new} | |
11219 | @item @code{operator new []} | |
11220 | @item @code{realloc} | |
11221 | @item @code{strdup} | |
11222 | @item @code{strndup} | |
11223 | @end itemize | |
11224 | ||
4ace81b6 | 11225 | @noindent |
d77de738 ML |
11226 | of the following functions for working with file descriptors: |
11227 | ||
11228 | @itemize @bullet | |
11229 | @item @code{open} | |
11230 | @item @code{close} | |
11231 | @item @code{creat} | |
11232 | @item @code{dup}, @code{dup2} and @code{dup3} | |
78a17f44 | 11233 | @item @code{isatty} |
d77de738 ML |
11234 | @item @code{pipe}, and @code{pipe2} |
11235 | @item @code{read} | |
11236 | @item @code{write} | |
86a90006 | 11237 | @item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect} |
d77de738 ML |
11238 | @end itemize |
11239 | ||
4ace81b6 | 11240 | @noindent |
d77de738 ML |
11241 | of the following functions for working with @code{<stdio.h>} streams: |
11242 | @itemize @bullet | |
11243 | @item The built-in functions @code{__builtin_fprintf}, | |
11244 | @code{__builtin_fprintf_unlocked}, @code{__builtin_fputc}, | |
11245 | @code{__builtin_fputc_unlocked}, @code{__builtin_fputs}, | |
11246 | @code{__builtin_fputs_unlocked}, @code{__builtin_fwrite}, | |
11247 | @code{__builtin_fwrite_unlocked}, @code{__builtin_printf}, | |
11248 | @code{__builtin_printf_unlocked}, @code{__builtin_putc}, | |
11249 | @code{__builtin_putchar}, @code{__builtin_putchar_unlocked}, | |
11250 | @code{__builtin_putc_unlocked}, @code{__builtin_puts}, | |
11251 | @code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and | |
11252 | @code{__builtin_vprintf} | |
11253 | @item @code{fopen} | |
11254 | @item @code{fclose} | |
78a17f44 | 11255 | @item @code{ferror} |
d77de738 ML |
11256 | @item @code{fgets} |
11257 | @item @code{fgets_unlocked} | |
78a17f44 | 11258 | @item @code{fileno} |
d77de738 | 11259 | @item @code{fread} |
78a17f44 | 11260 | @item @code{getc} |
d77de738 ML |
11261 | @item @code{getchar} |
11262 | @item @code{fprintf} | |
11263 | @item @code{printf} | |
11264 | @item @code{fwrite} | |
11265 | @end itemize | |
11266 | ||
4ace81b6 | 11267 | @noindent |
d77de738 ML |
11268 | and of the following functions: |
11269 | ||
11270 | @itemize @bullet | |
11271 | @item The built-in functions @code{__builtin_expect}, | |
11272 | @code{__builtin_expect_with_probability}, @code{__builtin_strchr}, | |
11273 | @code{__builtin_strcpy}, @code{__builtin_strcpy_chk}, | |
11274 | @code{__builtin_strlen}, @code{__builtin_va_copy}, and | |
11275 | @code{__builtin_va_start} | |
11276 | @item The GNU extensions @code{error} and @code{error_at_line} | |
11277 | @item @code{getpass} | |
11278 | @item @code{longjmp} | |
11279 | @item @code{putenv} | |
11280 | @item @code{setjmp} | |
11281 | @item @code{siglongjmp} | |
11282 | @item @code{signal} | |
11283 | @item @code{sigsetjmp} | |
bbdc0e0d | 11284 | @item @code{strcat} |
d77de738 ML |
11285 | @item @code{strchr} |
11286 | @item @code{strlen} | |
11287 | @end itemize | |
11288 | ||
11289 | In addition, various functions with an @code{__analyzer_} prefix have | |
11290 | special meaning to the analyzer, described in the GCC Internals manual. | |
11291 | ||
11292 | Pertinent parameters for controlling the exploration are: | |
4ace81b6 SL |
11293 | @itemize @bullet |
11294 | @item @option{--param analyzer-bb-explosion-factor=@var{value}} | |
11295 | @item @option{--param analyzer-max-enodes-per-program-point=@var{value}} | |
11296 | @item @option{--param analyzer-max-recursion-depth=@var{value}} | |
11297 | @item @option{--param analyzer-min-snodes-for-call-summary=@var{value}} | |
11298 | @end itemize | |
d77de738 ML |
11299 | |
11300 | The following options control the analyzer. | |
11301 | ||
11302 | @table @gcctabopt | |
11303 | ||
d77de738 ML |
11304 | @opindex fanalyzer-call-summaries |
11305 | @opindex fno-analyzer-call-summaries | |
ddf6fe37 | 11306 | @item -fanalyzer-call-summaries |
d77de738 ML |
11307 | Simplify interprocedural analysis by computing the effect of certain calls, |
11308 | rather than exploring all paths through the function from callsite to each | |
11309 | possible return. | |
11310 | ||
11311 | If enabled, call summaries are only used for functions with more than one | |
11312 | call site, and that are sufficiently complicated (as per | |
11313 | @option{--param analyzer-min-snodes-for-call-summary=@var{value}}). | |
11314 | ||
d77de738 | 11315 | @opindex fanalyzer-checker |
ddf6fe37 | 11316 | @item -fanalyzer-checker=@var{name} |
d77de738 ML |
11317 | Restrict the analyzer to run just the named checker, and enable it. |
11318 | ||
0e466e97 DM |
11319 | @opindex fanalyzer-debug-text-art |
11320 | @opindex fno-analyzer-debug-text-art | |
11321 | @item -fanalyzer-debug-text-art-headings | |
11322 | This option is intended for analyzer developers. If enabled, | |
11323 | the analyzer will add extra annotations to any diagrams it generates. | |
11324 | ||
d77de738 ML |
11325 | @opindex fanalyzer-feasibility |
11326 | @opindex fno-analyzer-feasibility | |
ddf6fe37 | 11327 | @item -fno-analyzer-feasibility |
d77de738 ML |
11328 | This option is intended for analyzer developers. |
11329 | ||
11330 | By default the analyzer verifies that there is a feasible control flow path | |
11331 | for each diagnostic it emits: that the conditions that hold are not mutually | |
11332 | exclusive. Diagnostics for which no feasible path can be found are rejected. | |
11333 | This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for | |
11334 | debugging issues in this code. | |
11335 | ||
d77de738 ML |
11336 | @opindex fanalyzer-fine-grained |
11337 | @opindex fno-analyzer-fine-grained | |
ddf6fe37 | 11338 | @item -fanalyzer-fine-grained |
d77de738 ML |
11339 | This option is intended for analyzer developers. |
11340 | ||
11341 | Internally the analyzer builds an ``exploded graph'' that combines | |
11342 | control flow graphs with data flow information. | |
11343 | ||
11344 | By default, an edge in this graph can contain the effects of a run | |
11345 | of multiple statements within a basic block. With | |
11346 | @option{-fanalyzer-fine-grained}, each statement gets its own edge. | |
11347 | ||
d77de738 ML |
11348 | @opindex fanalyzer-show-duplicate-count |
11349 | @opindex fno-analyzer-show-duplicate-count | |
ddf6fe37 | 11350 | @item -fanalyzer-show-duplicate-count |
d77de738 ML |
11351 | This option is intended for analyzer developers: if multiple diagnostics |
11352 | have been detected as being duplicates of each other, it emits a note when | |
11353 | reporting the best diagnostic, giving the number of additional diagnostics | |
11354 | that were suppressed by the deduplication logic. | |
11355 | ||
ce8cdf5b | 11356 | @opindex fanalyzer-show-events-in-system-headers |
11357 | @opindex fno-analyzer-show-events-in-system-headers | |
11358 | @item -fanalyzer-show-events-in-system-headers | |
11359 | By default the analyzer emits simplified diagnostics paths by hiding | |
11360 | events fully located within a system header. | |
11361 | With @option{-fanalyzer-show-events-in-system-headers} such | |
11362 | events are no longer suppressed. | |
11363 | ||
d77de738 ML |
11364 | @opindex fanalyzer-state-merge |
11365 | @opindex fno-analyzer-state-merge | |
ddf6fe37 | 11366 | @item -fno-analyzer-state-merge |
d77de738 ML |
11367 | This option is intended for analyzer developers. |
11368 | ||
11369 | By default the analyzer attempts to simplify analysis by merging | |
11370 | sufficiently similar states at each program point as it builds its | |
11371 | ``exploded graph''. With @option{-fno-analyzer-state-merge} this | |
11372 | merging can be suppressed, for debugging state-handling issues. | |
11373 | ||
d77de738 ML |
11374 | @opindex fanalyzer-state-purge |
11375 | @opindex fno-analyzer-state-purge | |
ddf6fe37 | 11376 | @item -fno-analyzer-state-purge |
d77de738 ML |
11377 | This option is intended for analyzer developers. |
11378 | ||
11379 | By default the analyzer attempts to simplify analysis by purging | |
11380 | aspects of state at a program point that appear to no longer be relevant | |
11381 | e.g. the values of locals that aren't accessed later in the function | |
11382 | and which aren't relevant to leak analysis. | |
11383 | ||
11384 | With @option{-fno-analyzer-state-purge} this purging of state can | |
11385 | be suppressed, for debugging state-handling issues. | |
11386 | ||
8f636915 DM |
11387 | @opindex fanalyzer-suppress-followups |
11388 | @opindex fno-analyzer-suppress-followups | |
f33d7a88 | 11389 | @item -fno-analyzer-suppress-followups |
8f636915 DM |
11390 | This option is intended for analyzer developers. |
11391 | ||
11392 | By default the analyzer will stop exploring an execution path after | |
11393 | encountering certain diagnostics, in order to avoid potentially issuing a | |
11394 | cascade of follow-up diagnostics. | |
11395 | ||
11396 | The diagnostics that terminate analysis along a path are: | |
11397 | ||
11398 | @itemize | |
11399 | @item @option{-Wanalyzer-null-argument} | |
11400 | @item @option{-Wanalyzer-null-dereference} | |
11401 | @item @option{-Wanalyzer-use-after-free} | |
11402 | @item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame} | |
11403 | @item @option{-Wanalyzer-use-of-uninitialized-value} | |
11404 | @end itemize | |
11405 | ||
11406 | With @option{-fno-analyzer-suppress-followups} the analyzer will | |
11407 | continue to explore such paths even after such diagnostics, which may | |
11408 | be helpful for debugging issues in the analyzer, or for microbenchmarks | |
11409 | for detecting undefined behavior. | |
11410 | ||
d77de738 ML |
11411 | @opindex fanalyzer-transitivity |
11412 | @opindex fno-analyzer-transitivity | |
ddf6fe37 | 11413 | @item -fanalyzer-transitivity |
d77de738 ML |
11414 | This option enables transitivity of constraints within the analyzer. |
11415 | ||
d77de738 ML |
11416 | @opindex fanalyzer-undo-inlining |
11417 | @opindex fno-analyzer-undo-inlining | |
ddf6fe37 | 11418 | @item -fno-analyzer-undo-inlining |
d77de738 ML |
11419 | This option is intended for analyzer developers. |
11420 | ||
11421 | @option{-fanalyzer} runs relatively late compared to other code analysis | |
11422 | tools, and some optimizations have already been applied to the code. In | |
11423 | particular function inlining may have occurred, leading to the | |
11424 | interprocedural execution paths emitted by the analyzer containing | |
11425 | function frames that don't correspond to those in the original source | |
11426 | code. | |
11427 | ||
11428 | By default the analyzer attempts to reconstruct the original function | |
11429 | frames, and to emit events showing the inlined calls. | |
11430 | ||
11431 | With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct | |
11432 | the original frame information can be be disabled, which may be of help | |
11433 | when debugging issues in the analyzer. | |
11434 | ||
11435 | @item -fanalyzer-verbose-edges | |
11436 | This option is intended for analyzer developers. It enables more | |
11437 | verbose, lower-level detail in the descriptions of control flow | |
11438 | within diagnostic paths. | |
11439 | ||
11440 | @item -fanalyzer-verbose-state-changes | |
11441 | This option is intended for analyzer developers. It enables more | |
11442 | verbose, lower-level detail in the descriptions of events relating | |
11443 | to state machines within diagnostic paths. | |
11444 | ||
11445 | @item -fanalyzer-verbosity=@var{level} | |
11446 | This option controls the complexity of the control flow paths that are | |
11447 | emitted for analyzer diagnostics. | |
11448 | ||
11449 | The @var{level} can be one of: | |
11450 | ||
11451 | @table @samp | |
11452 | @item 0 | |
11453 | At this level, interprocedural call and return events are displayed, | |
11454 | along with the most pertinent state-change events relating to | |
11455 | a diagnostic. For example, for a double-@code{free} diagnostic, | |
11456 | both calls to @code{free} will be shown. | |
11457 | ||
11458 | @item 1 | |
11459 | As per the previous level, but also show events for the entry | |
11460 | to each function. | |
11461 | ||
11462 | @item 2 | |
11463 | As per the previous level, but also show events relating to | |
11464 | control flow that are significant to triggering the issue | |
11465 | (e.g. ``true path taken'' at a conditional). | |
11466 | ||
11467 | This level is the default. | |
11468 | ||
11469 | @item 3 | |
11470 | As per the previous level, but show all control flow events, not | |
11471 | just significant ones. | |
11472 | ||
11473 | @item 4 | |
11474 | This level is intended for analyzer developers; it adds various | |
11475 | other events intended for debugging the analyzer. | |
11476 | ||
11477 | @end table | |
11478 | ||
d77de738 | 11479 | @opindex fdump-analyzer |
ddf6fe37 | 11480 | @item -fdump-analyzer |
d77de738 ML |
11481 | Dump internal details about what the analyzer is doing to |
11482 | @file{@var{file}.analyzer.txt}. | |
4ace81b6 | 11483 | @option{-fdump-analyzer-stderr} overrides this option. |
d77de738 | 11484 | |
d77de738 | 11485 | @opindex fdump-analyzer-stderr |
ddf6fe37 | 11486 | @item -fdump-analyzer-stderr |
d77de738 ML |
11487 | Dump internal details about what the analyzer is doing to stderr. |
11488 | This option overrides @option{-fdump-analyzer}. | |
11489 | ||
d77de738 | 11490 | @opindex fdump-analyzer-callgraph |
ddf6fe37 | 11491 | @item -fdump-analyzer-callgraph |
d77de738 ML |
11492 | Dump a representation of the call graph suitable for viewing with |
11493 | GraphViz to @file{@var{file}.callgraph.dot}. | |
11494 | ||
d77de738 | 11495 | @opindex fdump-analyzer-exploded-graph |
ddf6fe37 | 11496 | @item -fdump-analyzer-exploded-graph |
d77de738 ML |
11497 | Dump a representation of the ``exploded graph'' suitable for viewing with |
11498 | GraphViz to @file{@var{file}.eg.dot}. | |
11499 | Nodes are color-coded based on state-machine states to emphasize | |
11500 | state changes. | |
11501 | ||
d77de738 | 11502 | @opindex dump-analyzer-exploded-nodes |
ddf6fe37 | 11503 | @item -fdump-analyzer-exploded-nodes |
d77de738 ML |
11504 | Emit diagnostics showing where nodes in the ``exploded graph'' are |
11505 | in relation to the program source. | |
11506 | ||
d77de738 | 11507 | @opindex dump-analyzer-exploded-nodes-2 |
ddf6fe37 | 11508 | @item -fdump-analyzer-exploded-nodes-2 |
d77de738 ML |
11509 | Dump a textual representation of the ``exploded graph'' to |
11510 | @file{@var{file}.eg.txt}. | |
11511 | ||
d77de738 | 11512 | @opindex dump-analyzer-exploded-nodes-3 |
ddf6fe37 | 11513 | @item -fdump-analyzer-exploded-nodes-3 |
d77de738 ML |
11514 | Dump a textual representation of the ``exploded graph'' to |
11515 | one dump file per node, to @file{@var{file}.eg-@var{id}.txt}. | |
11516 | This is typically a large number of dump files. | |
11517 | ||
d77de738 | 11518 | @opindex fdump-analyzer-exploded-paths |
ddf6fe37 | 11519 | @item -fdump-analyzer-exploded-paths |
d77de738 ML |
11520 | Dump a textual representation of the ``exploded path'' for each |
11521 | diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}. | |
11522 | ||
d77de738 | 11523 | @opindex dump-analyzer-feasibility |
ddf6fe37 | 11524 | @item -fdump-analyzer-feasibility |
d77de738 ML |
11525 | Dump internal details about the analyzer's search for feasible paths. |
11526 | The details are written in a form suitable for viewing with GraphViz | |
11527 | to filenames of the form @file{@var{file}.*.fg.dot}, | |
11528 | @file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}. | |
11529 | ||
841008d3 DM |
11530 | @opindex dump-analyzer-infinite-loop |
11531 | @item -fdump-analyzer-infinite-loop | |
11532 | Dump internal details about the analyzer's search for infinite loops. | |
11533 | The details are written in a form suitable for viewing with GraphViz | |
11534 | to filenames of the form @file{@var{file}.*.infinite-loop.dot}. | |
11535 | ||
d77de738 | 11536 | @opindex fdump-analyzer-json |
ddf6fe37 | 11537 | @item -fdump-analyzer-json |
d77de738 ML |
11538 | Dump a compressed JSON representation of analyzer internals to |
11539 | @file{@var{file}.analyzer.json.gz}. The precise format is subject | |
11540 | to change. | |
11541 | ||
d77de738 | 11542 | @opindex fdump-analyzer-state-purge |
ddf6fe37 | 11543 | @item -fdump-analyzer-state-purge |
d77de738 ML |
11544 | As per @option{-fdump-analyzer-supergraph}, dump a representation of the |
11545 | ``supergraph'' suitable for viewing with GraphViz, but annotate the | |
11546 | graph with information on what state will be purged at each node. | |
11547 | The graph is written to @file{@var{file}.state-purge.dot}. | |
11548 | ||
d77de738 | 11549 | @opindex fdump-analyzer-supergraph |
ddf6fe37 | 11550 | @item -fdump-analyzer-supergraph |
d77de738 ML |
11551 | Dump representations of the ``supergraph'' suitable for viewing with |
11552 | GraphViz to @file{@var{file}.supergraph.dot} and to | |
11553 | @file{@var{file}.supergraph-eg.dot}. These show all of the | |
11554 | control flow graphs in the program, with interprocedural edges for | |
11555 | calls and returns. The second dump contains annotations showing nodes | |
11556 | in the ``exploded graph'' and diagnostics associated with them. | |
11557 | ||
d77de738 | 11558 | @opindex fdump-analyzer-untracked |
ddf6fe37 | 11559 | @item -fdump-analyzer-untracked |
d77de738 ML |
11560 | Emit custom warnings with internal details intended for analyzer developers. |
11561 | ||
11562 | @end table | |
11563 | ||
11564 | @node Debugging Options | |
11565 | @section Options for Debugging Your Program | |
11566 | @cindex options, debugging | |
11567 | @cindex debugging information options | |
11568 | ||
11569 | To tell GCC to emit extra information for use by a debugger, in almost | |
11570 | all cases you need only to add @option{-g} to your other options. Some debug | |
11571 | formats can co-exist (like DWARF with CTF) when each of them is enabled | |
11572 | explicitly by adding the respective command line option to your other options. | |
11573 | ||
11574 | GCC allows you to use @option{-g} with | |
11575 | @option{-O}. The shortcuts taken by optimized code may occasionally | |
11576 | be surprising: some variables you declared may not exist | |
11577 | at all; flow of control may briefly move where you did not expect it; | |
11578 | some statements may not be executed because they compute constant | |
11579 | results or their values are already at hand; some statements may | |
11580 | execute in different places because they have been moved out of loops. | |
11581 | Nevertheless it is possible to debug optimized output. This makes | |
11582 | it reasonable to use the optimizer for programs that might have bugs. | |
11583 | ||
11584 | If you are not using some other optimization option, consider | |
11585 | using @option{-Og} (@pxref{Optimize Options}) with @option{-g}. | |
11586 | With no @option{-O} option at all, some compiler passes that collect | |
11587 | information useful for debugging do not run at all, so that | |
11588 | @option{-Og} may result in a better debugging experience. | |
11589 | ||
11590 | @table @gcctabopt | |
d77de738 | 11591 | @opindex g |
ddf6fe37 | 11592 | @item -g |
d77de738 ML |
11593 | Produce debugging information in the operating system's native format |
11594 | (stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging | |
11595 | information. | |
11596 | ||
11597 | On most systems that use stabs format, @option{-g} enables use of extra | |
11598 | debugging information that only GDB can use; this extra information | |
11599 | makes debugging work better in GDB but probably makes other debuggers | |
11600 | crash or refuse to read the program. If you want to control for certain whether | |
11601 | to generate the extra information, use @option{-gvms} (see below). | |
11602 | ||
d77de738 | 11603 | @opindex ggdb |
ddf6fe37 | 11604 | @item -ggdb |
d77de738 ML |
11605 | Produce debugging information for use by GDB@. This means to use the |
11606 | most expressive format available (DWARF, stabs, or the native format | |
11607 | if neither of those are supported), including GDB extensions if at all | |
11608 | possible. | |
11609 | ||
ddf6fe37 | 11610 | @opindex gdwarf |
d77de738 ML |
11611 | @item -gdwarf |
11612 | @itemx -gdwarf-@var{version} | |
d77de738 ML |
11613 | Produce debugging information in DWARF format (if that is supported). |
11614 | The value of @var{version} may be either 2, 3, 4 or 5; the default | |
11615 | version for most targets is 5 (with the exception of VxWorks, TPF and | |
a335cf24 | 11616 | Darwin / macOS, which default to version 2, and AIX, which defaults |
d77de738 ML |
11617 | to version 4). |
11618 | ||
11619 | Note that with DWARF Version 2, some ports require and always | |
11620 | use some non-conflicting DWARF 3 extensions in the unwind tables. | |
11621 | ||
11622 | Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments} | |
11623 | for maximum benefit. Version 5 requires GDB 8.0 or higher. | |
11624 | ||
11625 | GCC no longer supports DWARF Version 1, which is substantially | |
11626 | different than Version 2 and later. For historical reasons, some | |
11627 | other DWARF-related options such as | |
11628 | @option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2 | |
11629 | in their names, but apply to all currently-supported versions of DWARF. | |
11630 | ||
d77de738 | 11631 | @opindex gbtf |
ddf6fe37 | 11632 | @item -gbtf |
d77de738 ML |
11633 | Request BTF debug information. BTF is the default debugging format for the |
11634 | eBPF target. On other targets, like x86, BTF debug information can be | |
11635 | generated along with DWARF debug information when both of the debug formats are | |
11636 | enabled explicitly via their respective command line options. | |
11637 | ||
ddf6fe37 | 11638 | @opindex gctf |
d77de738 ML |
11639 | @item -gctf |
11640 | @itemx -gctf@var{level} | |
d77de738 ML |
11641 | Request CTF debug information and use level to specify how much CTF debug |
11642 | information should be produced. If @option{-gctf} is specified | |
11643 | without a value for level, the default level of CTF debug information is 2. | |
11644 | ||
11645 | CTF debug information can be generated along with DWARF debug information when | |
11646 | both of the debug formats are enabled explicitly via their respective command | |
11647 | line options. | |
11648 | ||
11649 | Level 0 produces no CTF debug information at all. Thus, @option{-gctf0} | |
11650 | negates @option{-gctf}. | |
11651 | ||
11652 | Level 1 produces CTF information for tracebacks only. This includes callsite | |
11653 | information, but does not include type information. | |
11654 | ||
11655 | Level 2 produces type information for entities (functions, data objects etc.) | |
11656 | at file-scope or global-scope only. | |
11657 | ||
d77de738 | 11658 | @opindex gvms |
ddf6fe37 | 11659 | @item -gvms |
d77de738 ML |
11660 | Produce debugging information in Alpha/VMS debug format (if that is |
11661 | supported). This is the format used by DEBUG on Alpha/VMS systems. | |
11662 | ||
2f7e7bfa MH |
11663 | @item -gcodeview |
11664 | @opindex gcodeview | |
11665 | Produce debugging information in CodeView debug format (if that is | |
11666 | supported). This is the format used by Microsoft Visual C++ on | |
11667 | Windows. | |
11668 | ||
d77de738 ML |
11669 | @item -g@var{level} |
11670 | @itemx -ggdb@var{level} | |
11671 | @itemx -gvms@var{level} | |
11672 | Request debugging information and also use @var{level} to specify how | |
11673 | much information. The default level is 2. | |
11674 | ||
11675 | Level 0 produces no debug information at all. Thus, @option{-g0} negates | |
11676 | @option{-g}. | |
11677 | ||
11678 | Level 1 produces minimal information, enough for making backtraces in | |
11679 | parts of the program that you don't plan to debug. This includes | |
11680 | descriptions of functions and external variables, and line number | |
11681 | tables, but no information about local variables. | |
11682 | ||
11683 | Level 3 includes extra information, such as all the macro definitions | |
11684 | present in the program. Some debuggers support macro expansion when | |
11685 | you use @option{-g3}. | |
11686 | ||
11687 | If you use multiple @option{-g} options, with or without level numbers, | |
11688 | the last such option is the one that is effective. | |
11689 | ||
11690 | @option{-gdwarf} does not accept a concatenated debug level, to avoid | |
11691 | confusion with @option{-gdwarf-@var{level}}. | |
11692 | Instead use an additional @option{-g@var{level}} option to change the | |
11693 | debug level for DWARF. | |
11694 | ||
d77de738 ML |
11695 | @opindex feliminate-unused-debug-symbols |
11696 | @opindex fno-eliminate-unused-debug-symbols | |
ddf6fe37 | 11697 | @item -fno-eliminate-unused-debug-symbols |
d77de738 ML |
11698 | By default, no debug information is produced for symbols that are not actually |
11699 | used. Use this option if you want debug information for all symbols. | |
11700 | ||
d77de738 | 11701 | @opindex femit-class-debug-always |
ddf6fe37 | 11702 | @item -femit-class-debug-always |
d77de738 ML |
11703 | Instead of emitting debugging information for a C++ class in only one |
11704 | object file, emit it in all object files using the class. This option | |
11705 | should be used only with debuggers that are unable to handle the way GCC | |
11706 | normally emits debugging information for classes because using this | |
11707 | option increases the size of debugging information by as much as a | |
11708 | factor of two. | |
11709 | ||
d77de738 ML |
11710 | @opindex fmerge-debug-strings |
11711 | @opindex fno-merge-debug-strings | |
ddf6fe37 | 11712 | @item -fno-merge-debug-strings |
d77de738 ML |
11713 | Direct the linker to not merge together strings in the debugging |
11714 | information that are identical in different object files. Merging is | |
11715 | not supported by all assemblers or linkers. Merging decreases the size | |
11716 | of the debug information in the output file at the cost of increasing | |
11717 | link processing time. Merging is enabled by default. | |
11718 | ||
d77de738 | 11719 | @opindex fdebug-prefix-map |
ddf6fe37 | 11720 | @item -fdebug-prefix-map=@var{old}=@var{new} |
d77de738 ML |
11721 | When compiling files residing in directory @file{@var{old}}, record |
11722 | debugging information describing them as if the files resided in | |
11723 | directory @file{@var{new}} instead. This can be used to replace a | |
11724 | build-time path with an install-time path in the debug info. It can | |
11725 | also be used to change an absolute path to a relative path by using | |
11726 | @file{.} for @var{new}. This can give more reproducible builds, which | |
11727 | are location independent, but may require an extra command to tell GDB | |
2eb0191a JJ |
11728 | where to find the source files. See also @option{-ffile-prefix-map} |
11729 | and @option{-fcanon-prefix-map}. | |
d77de738 | 11730 | |
d77de738 | 11731 | @opindex fvar-tracking |
ddf6fe37 | 11732 | @item -fvar-tracking |
d77de738 ML |
11733 | Run variable tracking pass. It computes where variables are stored at each |
11734 | position in code. Better debugging information is then generated | |
11735 | (if the debugging information format supports this information). | |
11736 | ||
11737 | It is enabled by default when compiling with optimization (@option{-Os}, | |
11738 | @option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and | |
11739 | the debug info format supports it. | |
11740 | ||
d77de738 ML |
11741 | @opindex fvar-tracking-assignments |
11742 | @opindex fno-var-tracking-assignments | |
ddf6fe37 | 11743 | @item -fvar-tracking-assignments |
d77de738 ML |
11744 | Annotate assignments to user variables early in the compilation and |
11745 | attempt to carry the annotations over throughout the compilation all the | |
11746 | way to the end, in an attempt to improve debug information while | |
11747 | optimizing. Use of @option{-gdwarf-4} is recommended along with it. | |
11748 | ||
11749 | It can be enabled even if var-tracking is disabled, in which case | |
11750 | annotations are created and maintained, but discarded at the end. | |
11751 | By default, this flag is enabled together with @option{-fvar-tracking}, | |
11752 | except when selective scheduling is enabled. | |
11753 | ||
d77de738 | 11754 | @opindex gsplit-dwarf |
ddf6fe37 | 11755 | @item -gsplit-dwarf |
d77de738 ML |
11756 | If DWARF debugging information is enabled, separate as much debugging |
11757 | information as possible into a separate output file with the extension | |
11758 | @file{.dwo}. This option allows the build system to avoid linking files with | |
11759 | debug information. To be useful, this option requires a debugger capable of | |
11760 | reading @file{.dwo} files. | |
11761 | ||
d77de738 ML |
11762 | @opindex gdwarf32 |
11763 | @opindex gdwarf64 | |
ddf6fe37 AA |
11764 | @item -gdwarf32 |
11765 | @itemx -gdwarf64 | |
d77de738 ML |
11766 | If DWARF debugging information is enabled, the @option{-gdwarf32} selects |
11767 | the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit | |
11768 | DWARF format. The default is target specific, on most targets it is | |
11769 | @option{-gdwarf32} though. The 32-bit DWARF format is smaller, but | |
11770 | can't support more than 2GiB of debug information in any of the DWARF | |
11771 | debug information sections. The 64-bit DWARF format allows larger debug | |
11772 | information and might not be well supported by all consumers yet. | |
11773 | ||
d77de738 | 11774 | @opindex gdescribe-dies |
ddf6fe37 | 11775 | @item -gdescribe-dies |
d77de738 ML |
11776 | Add description attributes to some DWARF DIEs that have no name attribute, |
11777 | such as artificial variables, external references and call site | |
11778 | parameter DIEs. | |
11779 | ||
d77de738 | 11780 | @opindex gpubnames |
ddf6fe37 | 11781 | @item -gpubnames |
d77de738 ML |
11782 | Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections. |
11783 | ||
d77de738 | 11784 | @opindex ggnu-pubnames |
ddf6fe37 | 11785 | @item -ggnu-pubnames |
d77de738 ML |
11786 | Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format |
11787 | suitable for conversion into a GDB@ index. This option is only useful | |
11788 | with a linker that can produce GDB@ index version 7. | |
11789 | ||
d77de738 ML |
11790 | @opindex fdebug-types-section |
11791 | @opindex fno-debug-types-section | |
ddf6fe37 | 11792 | @item -fdebug-types-section |
d77de738 ML |
11793 | When using DWARF Version 4 or higher, type DIEs can be put into |
11794 | their own @code{.debug_types} section instead of making them part of the | |
11795 | @code{.debug_info} section. It is more efficient to put them in a separate | |
11796 | comdat section since the linker can then remove duplicates. | |
11797 | But not all DWARF consumers support @code{.debug_types} sections yet | |
11798 | and on some objects @code{.debug_types} produces larger instead of smaller | |
11799 | debugging information. | |
11800 | ||
d77de738 ML |
11801 | @opindex grecord-gcc-switches |
11802 | @opindex gno-record-gcc-switches | |
ddf6fe37 AA |
11803 | @item -grecord-gcc-switches |
11804 | @itemx -gno-record-gcc-switches | |
d77de738 ML |
11805 | This switch causes the command-line options used to invoke the |
11806 | compiler that may affect code generation to be appended to the | |
11807 | DW_AT_producer attribute in DWARF debugging information. The options | |
11808 | are concatenated with spaces separating them from each other and from | |
11809 | the compiler version. | |
11810 | It is enabled by default. | |
11811 | See also @option{-frecord-gcc-switches} for another | |
11812 | way of storing compiler options into the object file. | |
11813 | ||
d77de738 | 11814 | @opindex gstrict-dwarf |
ddf6fe37 | 11815 | @item -gstrict-dwarf |
d77de738 ML |
11816 | Disallow using extensions of later DWARF standard version than selected |
11817 | with @option{-gdwarf-@var{version}}. On most targets using non-conflicting | |
11818 | DWARF extensions from later standard versions is allowed. | |
11819 | ||
d77de738 | 11820 | @opindex gno-strict-dwarf |
ddf6fe37 | 11821 | @item -gno-strict-dwarf |
d77de738 ML |
11822 | Allow using extensions of later DWARF standard version than selected with |
11823 | @option{-gdwarf-@var{version}}. | |
11824 | ||
d77de738 | 11825 | @opindex gas-loc-support |
ddf6fe37 | 11826 | @item -gas-loc-support |
d77de738 ML |
11827 | Inform the compiler that the assembler supports @code{.loc} directives. |
11828 | It may then use them for the assembler to generate DWARF2+ line number | |
11829 | tables. | |
11830 | ||
11831 | This is generally desirable, because assembler-generated line-number | |
11832 | tables are a lot more compact than those the compiler can generate | |
11833 | itself. | |
11834 | ||
11835 | This option will be enabled by default if, at GCC configure time, the | |
11836 | assembler was found to support such directives. | |
11837 | ||
d77de738 | 11838 | @opindex gno-as-loc-support |
ddf6fe37 | 11839 | @item -gno-as-loc-support |
d77de738 ML |
11840 | Force GCC to generate DWARF2+ line number tables internally, if DWARF2+ |
11841 | line number tables are to be generated. | |
11842 | ||
d77de738 | 11843 | @opindex gas-locview-support |
ddf6fe37 | 11844 | @item -gas-locview-support |
d77de738 ML |
11845 | Inform the compiler that the assembler supports @code{view} assignment |
11846 | and reset assertion checking in @code{.loc} directives. | |
11847 | ||
11848 | This option will be enabled by default if, at GCC configure time, the | |
11849 | assembler was found to support them. | |
11850 | ||
11851 | @item -gno-as-locview-support | |
11852 | Force GCC to assign view numbers internally, if | |
11853 | @option{-gvariable-location-views} are explicitly requested. | |
11854 | ||
d77de738 ML |
11855 | @opindex gcolumn-info |
11856 | @opindex gno-column-info | |
ddf6fe37 AA |
11857 | @item -gcolumn-info |
11858 | @itemx -gno-column-info | |
d77de738 ML |
11859 | Emit location column information into DWARF debugging information, rather |
11860 | than just file and line. | |
11861 | This option is enabled by default. | |
11862 | ||
d77de738 ML |
11863 | @opindex gstatement-frontiers |
11864 | @opindex gno-statement-frontiers | |
ddf6fe37 AA |
11865 | @item -gstatement-frontiers |
11866 | @itemx -gno-statement-frontiers | |
d77de738 ML |
11867 | This option causes GCC to create markers in the internal representation |
11868 | at the beginning of statements, and to keep them roughly in place | |
11869 | throughout compilation, using them to guide the output of @code{is_stmt} | |
11870 | markers in the line number table. This is enabled by default when | |
11871 | compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2}, | |
11872 | @dots{}), and outputting DWARF 2 debug information at the normal level. | |
11873 | ||
d77de738 ML |
11874 | @opindex gvariable-location-views |
11875 | @opindex gvariable-location-views=incompat5 | |
11876 | @opindex gno-variable-location-views | |
ddf6fe37 AA |
11877 | @item -gvariable-location-views |
11878 | @itemx -gvariable-location-views=incompat5 | |
11879 | @itemx -gno-variable-location-views | |
d77de738 ML |
11880 | Augment variable location lists with progressive view numbers implied |
11881 | from the line number table. This enables debug information consumers to | |
11882 | inspect state at certain points of the program, even if no instructions | |
11883 | associated with the corresponding source locations are present at that | |
11884 | point. If the assembler lacks support for view numbers in line number | |
11885 | tables, this will cause the compiler to emit the line number table, | |
11886 | which generally makes them somewhat less compact. The augmented line | |
11887 | number tables and location lists are fully backward-compatible, so they | |
11888 | can be consumed by debug information consumers that are not aware of | |
11889 | these augmentations, but they won't derive any benefit from them either. | |
11890 | ||
11891 | This is enabled by default when outputting DWARF 2 debug information at | |
11892 | the normal level, as long as there is assembler support, | |
11893 | @option{-fvar-tracking-assignments} is enabled and | |
11894 | @option{-gstrict-dwarf} is not. When assembler support is not | |
11895 | available, this may still be enabled, but it will force GCC to output | |
11896 | internal line number tables, and if | |
11897 | @option{-ginternal-reset-location-views} is not enabled, that will most | |
11898 | certainly lead to silently mismatching location views. | |
11899 | ||
11900 | There is a proposed representation for view numbers that is not backward | |
11901 | compatible with the location list format introduced in DWARF 5, that can | |
11902 | be enabled with @option{-gvariable-location-views=incompat5}. This | |
11903 | option may be removed in the future, is only provided as a reference | |
11904 | implementation of the proposed representation. Debug information | |
11905 | consumers are not expected to support this extended format, and they | |
11906 | would be rendered unable to decode location lists using it. | |
11907 | ||
d77de738 ML |
11908 | @opindex ginternal-reset-location-views |
11909 | @opindex gno-internal-reset-location-views | |
ddf6fe37 AA |
11910 | @item -ginternal-reset-location-views |
11911 | @itemx -gno-internal-reset-location-views | |
d77de738 ML |
11912 | Attempt to determine location views that can be omitted from location |
11913 | view lists. This requires the compiler to have very accurate insn | |
11914 | length estimates, which isn't always the case, and it may cause | |
11915 | incorrect view lists to be generated silently when using an assembler | |
11916 | that does not support location view lists. The GNU assembler will flag | |
11917 | any such error as a @code{view number mismatch}. This is only enabled | |
11918 | on ports that define a reliable estimation function. | |
11919 | ||
d77de738 ML |
11920 | @opindex ginline-points |
11921 | @opindex gno-inline-points | |
ddf6fe37 AA |
11922 | @item -ginline-points |
11923 | @itemx -gno-inline-points | |
d77de738 ML |
11924 | Generate extended debug information for inlined functions. Location |
11925 | view tracking markers are inserted at inlined entry points, so that | |
11926 | address and view numbers can be computed and output in debug | |
11927 | information. This can be enabled independently of location views, in | |
11928 | which case the view numbers won't be output, but it can only be enabled | |
11929 | along with statement frontiers, and it is only enabled by default if | |
11930 | location views are enabled. | |
11931 | ||
d77de738 | 11932 | @opindex gz |
ddf6fe37 | 11933 | @item -gz@r{[}=@var{type}@r{]} |
d77de738 ML |
11934 | Produce compressed debug sections in DWARF format, if that is supported. |
11935 | If @var{type} is not given, the default type depends on the capabilities | |
11936 | of the assembler and linker used. @var{type} may be one of | |
11937 | @samp{none} (don't compress debug sections), or @samp{zlib} (use zlib | |
11938 | compression in ELF gABI format). If the linker doesn't support writing | |
11939 | compressed debug sections, the option is rejected. Otherwise, if the | |
11940 | assembler does not support them, @option{-gz} is silently ignored when | |
11941 | producing object files. | |
11942 | ||
d77de738 | 11943 | @opindex femit-struct-debug-baseonly |
ddf6fe37 | 11944 | @item -femit-struct-debug-baseonly |
d77de738 ML |
11945 | Emit debug information for struct-like types |
11946 | only when the base name of the compilation source file | |
11947 | matches the base name of file in which the struct is defined. | |
11948 | ||
11949 | This option substantially reduces the size of debugging information, | |
11950 | but at significant potential loss in type information to the debugger. | |
11951 | See @option{-femit-struct-debug-reduced} for a less aggressive option. | |
11952 | See @option{-femit-struct-debug-detailed} for more detailed control. | |
11953 | ||
11954 | This option works only with DWARF debug output. | |
11955 | ||
d77de738 | 11956 | @opindex femit-struct-debug-reduced |
ddf6fe37 | 11957 | @item -femit-struct-debug-reduced |
d77de738 ML |
11958 | Emit debug information for struct-like types |
11959 | only when the base name of the compilation source file | |
11960 | matches the base name of file in which the type is defined, | |
11961 | unless the struct is a template or defined in a system header. | |
11962 | ||
11963 | This option significantly reduces the size of debugging information, | |
11964 | with some potential loss in type information to the debugger. | |
11965 | See @option{-femit-struct-debug-baseonly} for a more aggressive option. | |
11966 | See @option{-femit-struct-debug-detailed} for more detailed control. | |
11967 | ||
11968 | This option works only with DWARF debug output. | |
11969 | ||
d77de738 | 11970 | @opindex femit-struct-debug-detailed |
ddf6fe37 | 11971 | @item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} |
d77de738 ML |
11972 | Specify the struct-like types |
11973 | for which the compiler generates debug information. | |
11974 | The intent is to reduce duplicate struct debug information | |
11975 | between different object files within the same program. | |
11976 | ||
11977 | This option is a detailed version of | |
11978 | @option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly}, | |
11979 | which serves for most needs. | |
11980 | ||
11981 | A specification has the syntax@* | |
11982 | [@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none}) | |
11983 | ||
11984 | The optional first word limits the specification to | |
11985 | structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}). | |
11986 | A struct type is used directly when it is the type of a variable, member. | |
11987 | Indirect uses arise through pointers to structs. | |
11988 | That is, when use of an incomplete struct is valid, the use is indirect. | |
11989 | An example is | |
11990 | @samp{struct one direct; struct two * indirect;}. | |
11991 | ||
11992 | The optional second word limits the specification to | |
11993 | ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}). | |
11994 | Generic structs are a bit complicated to explain. | |
11995 | For C++, these are non-explicit specializations of template classes, | |
11996 | or non-template classes within the above. | |
11997 | Other programming languages have generics, | |
11998 | but @option{-femit-struct-debug-detailed} does not yet implement them. | |
11999 | ||
12000 | The third word specifies the source files for those | |
12001 | structs for which the compiler should emit debug information. | |
12002 | The values @samp{none} and @samp{any} have the normal meaning. | |
12003 | The value @samp{base} means that | |
12004 | the base of name of the file in which the type declaration appears | |
12005 | must match the base of the name of the main compilation file. | |
12006 | In practice, this means that when compiling @file{foo.c}, debug information | |
12007 | is generated for types declared in that file and @file{foo.h}, | |
12008 | but not other header files. | |
12009 | The value @samp{sys} means those types satisfying @samp{base} | |
12010 | or declared in system or compiler headers. | |
12011 | ||
12012 | You may need to experiment to determine the best settings for your application. | |
12013 | ||
12014 | The default is @option{-femit-struct-debug-detailed=all}. | |
12015 | ||
12016 | This option works only with DWARF debug output. | |
12017 | ||
d77de738 ML |
12018 | @opindex fdwarf2-cfi-asm |
12019 | @opindex fno-dwarf2-cfi-asm | |
ddf6fe37 | 12020 | @item -fno-dwarf2-cfi-asm |
d77de738 ML |
12021 | Emit DWARF unwind info as compiler generated @code{.eh_frame} section |
12022 | instead of using GAS @code{.cfi_*} directives. | |
12023 | ||
d77de738 ML |
12024 | @opindex feliminate-unused-debug-types |
12025 | @opindex fno-eliminate-unused-debug-types | |
ddf6fe37 | 12026 | @item -fno-eliminate-unused-debug-types |
d77de738 ML |
12027 | Normally, when producing DWARF output, GCC avoids producing debug symbol |
12028 | output for types that are nowhere used in the source file being compiled. | |
12029 | Sometimes it is useful to have GCC emit debugging | |
12030 | information for all types declared in a compilation | |
12031 | unit, regardless of whether or not they are actually used | |
12032 | in that compilation unit, for example | |
12033 | if, in the debugger, you want to cast a value to a type that is | |
12034 | not actually used in your program (but is declared). More often, | |
12035 | however, this results in a significant amount of wasted space. | |
12036 | @end table | |
12037 | ||
12038 | @node Optimize Options | |
12039 | @section Options That Control Optimization | |
12040 | @cindex optimize options | |
12041 | @cindex options, optimization | |
12042 | ||
12043 | These options control various sorts of optimizations. | |
12044 | ||
12045 | Without any optimization option, the compiler's goal is to reduce the | |
12046 | cost of compilation and to make debugging produce the expected | |
12047 | results. Statements are independent: if you stop the program with a | |
12048 | breakpoint between statements, you can then assign a new value to any | |
12049 | variable or change the program counter to any other statement in the | |
12050 | function and get exactly the results you expect from the source | |
12051 | code. | |
12052 | ||
12053 | Turning on optimization flags makes the compiler attempt to improve | |
12054 | the performance and/or code size at the expense of compilation time | |
12055 | and possibly the ability to debug the program. | |
12056 | ||
12057 | The compiler performs optimization based on the knowledge it has of the | |
12058 | program. Compiling multiple files at once to a single output file mode allows | |
12059 | the compiler to use information gained from all of the files when compiling | |
12060 | each of them. | |
12061 | ||
12062 | Not all optimizations are controlled directly by a flag. Only | |
12063 | optimizations that have a flag are listed in this section. | |
12064 | ||
12065 | Most optimizations are completely disabled at @option{-O0} or if an | |
12066 | @option{-O} level is not set on the command line, even if individual | |
12067 | optimization flags are specified. Similarly, @option{-Og} suppresses | |
12068 | many optimization passes. | |
12069 | ||
12070 | Depending on the target and how GCC was configured, a slightly different | |
12071 | set of optimizations may be enabled at each @option{-O} level than | |
12072 | those listed here. You can invoke GCC with @option{-Q --help=optimizers} | |
12073 | to find out the exact set of optimizations that are enabled at each level. | |
12074 | @xref{Overall Options}, for examples. | |
12075 | ||
12076 | @table @gcctabopt | |
d77de738 ML |
12077 | @opindex O |
12078 | @opindex O1 | |
ddf6fe37 AA |
12079 | @item -O |
12080 | @itemx -O1 | |
d77de738 ML |
12081 | Optimize. Optimizing compilation takes somewhat more time, and a lot |
12082 | more memory for a large function. | |
12083 | ||
12084 | With @option{-O}, the compiler tries to reduce code size and execution | |
12085 | time, without performing any optimizations that take a great deal of | |
12086 | compilation time. | |
12087 | ||
12088 | @c Note that in addition to the default_options_table list in opts.cc, | |
12089 | @c several optimization flags default to true but control optimization | |
12090 | @c passes that are explicitly disabled at -O0. | |
12091 | ||
12092 | @option{-O} turns on the following optimization flags: | |
12093 | ||
12094 | @c Please keep the following list alphabetized. | |
43b72ede AA |
12095 | @gccoptlist{-fauto-inc-dec |
12096 | -fbranch-count-reg | |
12097 | -fcombine-stack-adjustments | |
12098 | -fcompare-elim | |
12099 | -fcprop-registers | |
12100 | -fdce | |
12101 | -fdefer-pop | |
12102 | -fdelayed-branch | |
12103 | -fdse | |
12104 | -fforward-propagate | |
12105 | -fguess-branch-probability | |
12106 | -fif-conversion | |
12107 | -fif-conversion2 | |
12108 | -finline-functions-called-once | |
12109 | -fipa-modref | |
12110 | -fipa-profile | |
12111 | -fipa-pure-const | |
12112 | -fipa-reference | |
12113 | -fipa-reference-addressable | |
12114 | -fmerge-constants | |
12115 | -fmove-loop-invariants | |
12116 | -fmove-loop-stores | |
12117 | -fomit-frame-pointer | |
12118 | -freorder-blocks | |
12119 | -fshrink-wrap | |
12120 | -fshrink-wrap-separate | |
12121 | -fsplit-wide-types | |
12122 | -fssa-backprop | |
12123 | -fssa-phiopt | |
12124 | -ftree-bit-ccp | |
12125 | -ftree-ccp | |
12126 | -ftree-ch | |
12127 | -ftree-coalesce-vars | |
12128 | -ftree-copy-prop | |
12129 | -ftree-dce | |
12130 | -ftree-dominator-opts | |
12131 | -ftree-dse | |
12132 | -ftree-forwprop | |
12133 | -ftree-fre | |
12134 | -ftree-phiprop | |
12135 | -ftree-pta | |
12136 | -ftree-scev-cprop | |
12137 | -ftree-sink | |
12138 | -ftree-slsr | |
12139 | -ftree-sra | |
12140 | -ftree-ter | |
d77de738 ML |
12141 | -funit-at-a-time} |
12142 | ||
d77de738 | 12143 | @opindex O2 |
ddf6fe37 | 12144 | @item -O2 |
d77de738 ML |
12145 | Optimize even more. GCC performs nearly all supported optimizations |
12146 | that do not involve a space-speed tradeoff. | |
12147 | As compared to @option{-O}, this option increases both compilation time | |
12148 | and the performance of the generated code. | |
12149 | ||
12150 | @option{-O2} turns on all optimization flags specified by @option{-O1}. It | |
12151 | also turns on the following optimization flags: | |
12152 | ||
12153 | @c Please keep the following list alphabetized! | |
43b72ede AA |
12154 | @gccoptlist{-falign-functions -falign-jumps |
12155 | -falign-labels -falign-loops | |
12156 | -fcaller-saves | |
12157 | -fcode-hoisting | |
12158 | -fcrossjumping | |
12159 | -fcse-follow-jumps -fcse-skip-blocks | |
12160 | -fdelete-null-pointer-checks | |
12161 | -fdevirtualize -fdevirtualize-speculatively | |
12162 | -fexpensive-optimizations | |
12163 | -ffinite-loops | |
12164 | -fgcse -fgcse-lm | |
12165 | -fhoist-adjacent-loads | |
12166 | -finline-functions | |
12167 | -finline-small-functions | |
12168 | -findirect-inlining | |
12169 | -fipa-bit-cp -fipa-cp -fipa-icf | |
12170 | -fipa-ra -fipa-sra -fipa-vrp | |
12171 | -fisolate-erroneous-paths-dereference | |
12172 | -flra-remat | |
12173 | -foptimize-sibling-calls | |
12174 | -foptimize-strlen | |
12175 | -fpartial-inlining | |
12176 | -fpeephole2 | |
12177 | -freorder-blocks-algorithm=stc | |
12178 | -freorder-blocks-and-partition -freorder-functions | |
12179 | -frerun-cse-after-loop | |
12180 | -fschedule-insns -fschedule-insns2 | |
12181 | -fsched-interblock -fsched-spec | |
12182 | -fstore-merging | |
12183 | -fstrict-aliasing | |
12184 | -fthread-jumps | |
12185 | -ftree-builtin-call-dce | |
12186 | -ftree-loop-vectorize | |
12187 | -ftree-pre | |
12188 | -ftree-slp-vectorize | |
12189 | -ftree-switch-conversion -ftree-tail-merge | |
12190 | -ftree-vrp | |
d77de738 ML |
12191 | -fvect-cost-model=very-cheap} |
12192 | ||
12193 | Please note the warning under @option{-fgcse} about | |
12194 | invoking @option{-O2} on programs that use computed gotos. | |
12195 | ||
d77de738 | 12196 | @opindex O3 |
ddf6fe37 | 12197 | @item -O3 |
d77de738 ML |
12198 | Optimize yet more. @option{-O3} turns on all optimizations specified |
12199 | by @option{-O2} and also turns on the following optimization flags: | |
12200 | ||
12201 | @c Please keep the following list alphabetized! | |
43b72ede | 12202 | @gccoptlist{-fgcse-after-reload |
d77de738 | 12203 | -fipa-cp-clone |
43b72ede AA |
12204 | -floop-interchange |
12205 | -floop-unroll-and-jam | |
12206 | -fpeel-loops | |
12207 | -fpredictive-commoning | |
12208 | -fsplit-loops | |
12209 | -fsplit-paths | |
12210 | -ftree-loop-distribution | |
12211 | -ftree-partial-pre | |
12212 | -funswitch-loops | |
12213 | -fvect-cost-model=dynamic | |
d77de738 ML |
12214 | -fversion-loops-for-strides} |
12215 | ||
d77de738 | 12216 | @opindex O0 |
ddf6fe37 | 12217 | @item -O0 |
d77de738 ML |
12218 | Reduce compilation time and make debugging produce the expected |
12219 | results. This is the default. | |
12220 | ||
d77de738 | 12221 | @opindex Os |
ddf6fe37 | 12222 | @item -Os |
d77de738 ML |
12223 | Optimize for size. @option{-Os} enables all @option{-O2} optimizations |
12224 | except those that often increase code size: | |
12225 | ||
43b72ede AA |
12226 | @gccoptlist{-falign-functions -falign-jumps |
12227 | -falign-labels -falign-loops | |
d77de738 ML |
12228 | -fprefetch-loop-arrays -freorder-blocks-algorithm=stc} |
12229 | ||
12230 | It also enables @option{-finline-functions}, causes the compiler to tune for | |
12231 | code size rather than execution speed, and performs further optimizations | |
12232 | designed to reduce code size. | |
12233 | ||
d77de738 | 12234 | @opindex Ofast |
ddf6fe37 | 12235 | @item -Ofast |
d77de738 ML |
12236 | Disregard strict standards compliance. @option{-Ofast} enables all |
12237 | @option{-O3} optimizations. It also enables optimizations that are not | |
12238 | valid for all standard-compliant programs. | |
12239 | It turns on @option{-ffast-math}, @option{-fallow-store-data-races} | |
12240 | and the Fortran-specific @option{-fstack-arrays}, unless | |
12241 | @option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}. | |
12242 | It turns off @option{-fsemantic-interposition}. | |
12243 | ||
d77de738 | 12244 | @opindex Og |
ddf6fe37 | 12245 | @item -Og |
d77de738 ML |
12246 | Optimize debugging experience. @option{-Og} should be the optimization |
12247 | level of choice for the standard edit-compile-debug cycle, offering | |
12248 | a reasonable level of optimization while maintaining fast compilation | |
12249 | and a good debugging experience. It is a better choice than @option{-O0} | |
12250 | for producing debuggable code because some compiler passes | |
12251 | that collect debug information are disabled at @option{-O0}. | |
12252 | ||
12253 | Like @option{-O0}, @option{-Og} completely disables a number of | |
12254 | optimization passes so that individual options controlling them have | |
12255 | no effect. Otherwise @option{-Og} enables all @option{-O1} | |
12256 | optimization flags except for those that may interfere with debugging: | |
12257 | ||
43b72ede AA |
12258 | @gccoptlist{-fbranch-count-reg -fdelayed-branch |
12259 | -fdse -fif-conversion -fif-conversion2 | |
12260 | -finline-functions-called-once | |
12261 | -fmove-loop-invariants -fmove-loop-stores -fssa-phiopt | |
d77de738 ML |
12262 | -ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra} |
12263 | ||
d77de738 | 12264 | @opindex Oz |
ddf6fe37 | 12265 | @item -Oz |
d77de738 ML |
12266 | Optimize aggressively for size rather than speed. This may increase |
12267 | the number of instructions executed if those instructions require | |
12268 | fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os} | |
12269 | including enabling most @option{-O2} optimizations. | |
12270 | ||
12271 | @end table | |
12272 | ||
12273 | If you use multiple @option{-O} options, with or without level numbers, | |
12274 | the last such option is the one that is effective. | |
12275 | ||
12276 | Options of the form @option{-f@var{flag}} specify machine-independent | |
12277 | flags. Most flags have both positive and negative forms; the negative | |
12278 | form of @option{-ffoo} is @option{-fno-foo}. In the table | |
12279 | below, only one of the forms is listed---the one you typically | |
12280 | use. You can figure out the other form by either removing @samp{no-} | |
12281 | or adding it. | |
12282 | ||
12283 | The following options control specific optimizations. They are either | |
12284 | activated by @option{-O} options or are related to ones that are. You | |
12285 | can use the following flags in the rare cases when ``fine-tuning'' of | |
12286 | optimizations to be performed is desired. | |
12287 | ||
12288 | @table @gcctabopt | |
d77de738 ML |
12289 | @opindex fno-defer-pop |
12290 | @opindex fdefer-pop | |
ddf6fe37 | 12291 | @item -fno-defer-pop |
d77de738 ML |
12292 | For machines that must pop arguments after a function call, always pop |
12293 | the arguments as soon as each function returns. | |
12294 | At levels @option{-O1} and higher, @option{-fdefer-pop} is the default; | |
12295 | this allows the compiler to let arguments accumulate on the stack for several | |
12296 | function calls and pop them all at once. | |
12297 | ||
d77de738 | 12298 | @opindex fforward-propagate |
ddf6fe37 | 12299 | @item -fforward-propagate |
d77de738 ML |
12300 | Perform a forward propagation pass on RTL@. The pass tries to combine two |
12301 | instructions and checks if the result can be simplified. If loop unrolling | |
12302 | is active, two passes are performed and the second is scheduled after | |
12303 | loop unrolling. | |
12304 | ||
12305 | This option is enabled by default at optimization levels @option{-O1}, | |
12306 | @option{-O2}, @option{-O3}, @option{-Os}. | |
12307 | ||
d77de738 | 12308 | @opindex ffp-contract |
ddf6fe37 | 12309 | @item -ffp-contract=@var{style} |
d77de738 ML |
12310 | @option{-ffp-contract=off} disables floating-point expression contraction. |
12311 | @option{-ffp-contract=fast} enables floating-point expression contraction | |
12312 | such as forming of fused multiply-add operations if the target has | |
12313 | native support for them. | |
12314 | @option{-ffp-contract=on} enables floating-point expression contraction | |
1c1dd396 AM |
12315 | if allowed by the language standard. This is implemented for C and C++, |
12316 | where it enables contraction within one expression, but not across | |
12317 | different statements. | |
d77de738 | 12318 | |
1c1dd396 AM |
12319 | The default is @option{-ffp-contract=off} for C in a standards compliant mode |
12320 | (@option{-std=c11} or similar), @option{-ffp-contract=fast} otherwise. | |
d77de738 | 12321 | |
d77de738 | 12322 | @opindex fomit-frame-pointer |
ddf6fe37 | 12323 | @item -fomit-frame-pointer |
d77de738 ML |
12324 | Omit the frame pointer in functions that don't need one. This avoids the |
12325 | instructions to save, set up and restore the frame pointer; on many targets | |
12326 | it also makes an extra register available. | |
12327 | ||
12328 | On some targets this flag has no effect because the standard calling sequence | |
12329 | always uses a frame pointer, so it cannot be omitted. | |
12330 | ||
12331 | Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer | |
12332 | is used in all functions. Several targets always omit the frame pointer in | |
12333 | leaf functions. | |
12334 | ||
12335 | Enabled by default at @option{-O1} and higher. | |
12336 | ||
d77de738 | 12337 | @opindex foptimize-sibling-calls |
ddf6fe37 | 12338 | @item -foptimize-sibling-calls |
d77de738 ML |
12339 | Optimize sibling and tail recursive calls. |
12340 | ||
12341 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12342 | ||
d77de738 | 12343 | @opindex foptimize-strlen |
ddf6fe37 | 12344 | @item -foptimize-strlen |
d77de738 ML |
12345 | Optimize various standard C string functions (e.g.@: @code{strlen}, |
12346 | @code{strchr} or @code{strcpy}) and | |
12347 | their @code{_FORTIFY_SOURCE} counterparts into faster alternatives. | |
12348 | ||
12349 | Enabled at levels @option{-O2}, @option{-O3}. | |
12350 | ||
d77de738 ML |
12351 | @opindex fno-inline |
12352 | @opindex finline | |
ddf6fe37 | 12353 | @item -fno-inline |
d77de738 ML |
12354 | Do not expand any functions inline apart from those marked with |
12355 | the @code{always_inline} attribute. This is the default when not | |
12356 | optimizing. | |
12357 | ||
12358 | Single functions can be exempted from inlining by marking them | |
12359 | with the @code{noinline} attribute. | |
12360 | ||
d77de738 | 12361 | @opindex finline-small-functions |
ddf6fe37 | 12362 | @item -finline-small-functions |
d77de738 ML |
12363 | Integrate functions into their callers when their body is smaller than expected |
12364 | function call code (so overall size of program gets smaller). The compiler | |
12365 | heuristically decides which functions are simple enough to be worth integrating | |
12366 | in this way. This inlining applies to all functions, even those not declared | |
12367 | inline. | |
12368 | ||
12369 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12370 | ||
d77de738 | 12371 | @opindex findirect-inlining |
ddf6fe37 | 12372 | @item -findirect-inlining |
d77de738 ML |
12373 | Inline also indirect calls that are discovered to be known at compile |
12374 | time thanks to previous inlining. This option has any effect only | |
12375 | when inlining itself is turned on by the @option{-finline-functions} | |
12376 | or @option{-finline-small-functions} options. | |
12377 | ||
12378 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12379 | ||
d77de738 | 12380 | @opindex finline-functions |
ddf6fe37 | 12381 | @item -finline-functions |
d77de738 ML |
12382 | Consider all functions for inlining, even if they are not declared inline. |
12383 | The compiler heuristically decides which functions are worth integrating | |
12384 | in this way. | |
12385 | ||
12386 | If all calls to a given function are integrated, and the function is | |
12387 | declared @code{static}, then the function is normally not output as | |
12388 | assembler code in its own right. | |
12389 | ||
12390 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled | |
12391 | by @option{-fprofile-use} and @option{-fauto-profile}. | |
12392 | ||
d77de738 | 12393 | @opindex finline-functions-called-once |
ddf6fe37 | 12394 | @item -finline-functions-called-once |
d77de738 ML |
12395 | Consider all @code{static} functions called once for inlining into their |
12396 | caller even if they are not marked @code{inline}. If a call to a given | |
12397 | function is integrated, then the function is not output as assembler code | |
12398 | in its own right. | |
12399 | ||
12400 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os}, | |
12401 | but not @option{-Og}. | |
12402 | ||
d77de738 | 12403 | @opindex fearly-inlining |
ddf6fe37 | 12404 | @item -fearly-inlining |
d77de738 ML |
12405 | Inline functions marked by @code{always_inline} and functions whose body seems |
12406 | smaller than the function call overhead early before doing | |
12407 | @option{-fprofile-generate} instrumentation and real inlining pass. Doing so | |
12408 | makes profiling significantly cheaper and usually inlining faster on programs | |
12409 | having large chains of nested wrapper functions. | |
12410 | ||
12411 | Enabled by default. | |
12412 | ||
d77de738 | 12413 | @opindex fipa-sra |
ddf6fe37 | 12414 | @item -fipa-sra |
d77de738 ML |
12415 | Perform interprocedural scalar replacement of aggregates, removal of |
12416 | unused parameters and replacement of parameters passed by reference | |
12417 | by parameters passed by value. | |
12418 | ||
12419 | Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}. | |
12420 | ||
d77de738 | 12421 | @opindex finline-limit |
ddf6fe37 | 12422 | @item -finline-limit=@var{n} |
d77de738 ML |
12423 | By default, GCC limits the size of functions that can be inlined. This flag |
12424 | allows coarse control of this limit. @var{n} is the size of functions that | |
12425 | can be inlined in number of pseudo instructions. | |
12426 | ||
12427 | Inlining is actually controlled by a number of parameters, which may be | |
12428 | specified individually by using @option{--param @var{name}=@var{value}}. | |
12429 | The @option{-finline-limit=@var{n}} option sets some of these parameters | |
12430 | as follows: | |
12431 | ||
12432 | @table @gcctabopt | |
12433 | @item max-inline-insns-single | |
12434 | is set to @var{n}/2. | |
12435 | @item max-inline-insns-auto | |
12436 | is set to @var{n}/2. | |
12437 | @end table | |
12438 | ||
12439 | See below for a documentation of the individual | |
12440 | parameters controlling inlining and for the defaults of these parameters. | |
12441 | ||
12442 | @emph{Note:} there may be no value to @option{-finline-limit} that results | |
12443 | in default behavior. | |
12444 | ||
12445 | @emph{Note:} pseudo instruction represents, in this particular context, an | |
12446 | abstract measurement of function's size. In no way does it represent a count | |
12447 | of assembly instructions and as such its exact meaning might change from one | |
12448 | release to an another. | |
12449 | ||
d77de738 ML |
12450 | @opindex fno-keep-inline-dllexport |
12451 | @opindex fkeep-inline-dllexport | |
ddf6fe37 | 12452 | @item -fno-keep-inline-dllexport |
d77de738 ML |
12453 | This is a more fine-grained version of @option{-fkeep-inline-functions}, |
12454 | which applies only to functions that are declared using the @code{dllexport} | |
12455 | attribute or declspec. @xref{Function Attributes,,Declaring Attributes of | |
12456 | Functions}. | |
12457 | ||
d77de738 | 12458 | @opindex fkeep-inline-functions |
ddf6fe37 | 12459 | @item -fkeep-inline-functions |
d77de738 ML |
12460 | In C, emit @code{static} functions that are declared @code{inline} |
12461 | into the object file, even if the function has been inlined into all | |
12462 | of its callers. This switch does not affect functions using the | |
12463 | @code{extern inline} extension in GNU C90@. In C++, emit any and all | |
12464 | inline functions into the object file. | |
12465 | ||
d77de738 | 12466 | @opindex fkeep-static-functions |
ddf6fe37 | 12467 | @item -fkeep-static-functions |
d77de738 ML |
12468 | Emit @code{static} functions into the object file, even if the function |
12469 | is never used. | |
12470 | ||
d77de738 | 12471 | @opindex fkeep-static-consts |
ddf6fe37 | 12472 | @item -fkeep-static-consts |
d77de738 ML |
12473 | Emit variables declared @code{static const} when optimization isn't turned |
12474 | on, even if the variables aren't referenced. | |
12475 | ||
12476 | GCC enables this option by default. If you want to force the compiler to | |
12477 | check if a variable is referenced, regardless of whether or not | |
12478 | optimization is turned on, use the @option{-fno-keep-static-consts} option. | |
12479 | ||
d77de738 | 12480 | @opindex fmerge-constants |
ddf6fe37 | 12481 | @item -fmerge-constants |
d77de738 ML |
12482 | Attempt to merge identical constants (string constants and floating-point |
12483 | constants) across compilation units. | |
12484 | ||
12485 | This option is the default for optimized compilation if the assembler and | |
12486 | linker support it. Use @option{-fno-merge-constants} to inhibit this | |
12487 | behavior. | |
12488 | ||
12489 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
12490 | ||
d77de738 | 12491 | @opindex fmerge-all-constants |
ddf6fe37 | 12492 | @item -fmerge-all-constants |
d77de738 ML |
12493 | Attempt to merge identical constants and identical variables. |
12494 | ||
12495 | This option implies @option{-fmerge-constants}. In addition to | |
12496 | @option{-fmerge-constants} this considers e.g.@: even constant initialized | |
12497 | arrays or initialized constant variables with integral or floating-point | |
12498 | types. Languages like C or C++ require each variable, including multiple | |
12499 | instances of the same variable in recursive calls, to have distinct locations, | |
12500 | so using this option results in non-conforming | |
12501 | behavior. | |
12502 | ||
d77de738 | 12503 | @opindex fmodulo-sched |
ddf6fe37 | 12504 | @item -fmodulo-sched |
d77de738 ML |
12505 | Perform swing modulo scheduling immediately before the first scheduling |
12506 | pass. This pass looks at innermost loops and reorders their | |
12507 | instructions by overlapping different iterations. | |
12508 | ||
d77de738 | 12509 | @opindex fmodulo-sched-allow-regmoves |
ddf6fe37 | 12510 | @item -fmodulo-sched-allow-regmoves |
d77de738 ML |
12511 | Perform more aggressive SMS-based modulo scheduling with register moves |
12512 | allowed. By setting this flag certain anti-dependences edges are | |
12513 | deleted, which triggers the generation of reg-moves based on the | |
12514 | life-range analysis. This option is effective only with | |
12515 | @option{-fmodulo-sched} enabled. | |
12516 | ||
d77de738 ML |
12517 | @opindex fno-branch-count-reg |
12518 | @opindex fbranch-count-reg | |
ddf6fe37 | 12519 | @item -fno-branch-count-reg |
d77de738 ML |
12520 | Disable the optimization pass that scans for opportunities to use |
12521 | ``decrement and branch'' instructions on a count register instead of | |
12522 | instruction sequences that decrement a register, compare it against zero, and | |
12523 | then branch based upon the result. This option is only meaningful on | |
12524 | architectures that support such instructions, which include x86, PowerPC, | |
12525 | IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option | |
12526 | doesn't remove the decrement and branch instructions from the generated | |
12527 | instruction stream introduced by other optimization passes. | |
12528 | ||
12529 | The default is @option{-fbranch-count-reg} at @option{-O1} and higher, | |
12530 | except for @option{-Og}. | |
12531 | ||
d77de738 ML |
12532 | @opindex fno-function-cse |
12533 | @opindex ffunction-cse | |
ddf6fe37 | 12534 | @item -fno-function-cse |
d77de738 ML |
12535 | Do not put function addresses in registers; make each instruction that |
12536 | calls a constant function contain the function's address explicitly. | |
12537 | ||
12538 | This option results in less efficient code, but some strange hacks | |
12539 | that alter the assembler output may be confused by the optimizations | |
12540 | performed when this option is not used. | |
12541 | ||
12542 | The default is @option{-ffunction-cse} | |
12543 | ||
d77de738 ML |
12544 | @opindex fno-zero-initialized-in-bss |
12545 | @opindex fzero-initialized-in-bss | |
ddf6fe37 | 12546 | @item -fno-zero-initialized-in-bss |
d77de738 ML |
12547 | If the target supports a BSS section, GCC by default puts variables that |
12548 | are initialized to zero into BSS@. This can save space in the resulting | |
12549 | code. | |
12550 | ||
12551 | This option turns off this behavior because some programs explicitly | |
12552 | rely on variables going to the data section---e.g., so that the | |
12553 | resulting executable can find the beginning of that section and/or make | |
12554 | assumptions based on that. | |
12555 | ||
12556 | The default is @option{-fzero-initialized-in-bss}. | |
12557 | ||
d77de738 | 12558 | @opindex fthread-jumps |
ddf6fe37 | 12559 | @item -fthread-jumps |
d77de738 ML |
12560 | Perform optimizations that check to see if a jump branches to a |
12561 | location where another comparison subsumed by the first is found. If | |
12562 | so, the first branch is redirected to either the destination of the | |
12563 | second branch or a point immediately following it, depending on whether | |
12564 | the condition is known to be true or false. | |
12565 | ||
12566 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
12567 | ||
d77de738 | 12568 | @opindex fsplit-wide-types |
ddf6fe37 | 12569 | @item -fsplit-wide-types |
d77de738 ML |
12570 | When using a type that occupies multiple registers, such as @code{long |
12571 | long} on a 32-bit system, split the registers apart and allocate them | |
12572 | independently. This normally generates better code for those types, | |
12573 | but may make debugging more difficult. | |
12574 | ||
12575 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, | |
12576 | @option{-Os}. | |
12577 | ||
d77de738 | 12578 | @opindex fsplit-wide-types-early |
ddf6fe37 | 12579 | @item -fsplit-wide-types-early |
d77de738 ML |
12580 | Fully split wide types early, instead of very late. |
12581 | This option has no effect unless @option{-fsplit-wide-types} is turned on. | |
12582 | ||
12583 | This is the default on some targets. | |
12584 | ||
d77de738 | 12585 | @opindex fcse-follow-jumps |
ddf6fe37 | 12586 | @item -fcse-follow-jumps |
d77de738 ML |
12587 | In common subexpression elimination (CSE), scan through jump instructions |
12588 | when the target of the jump is not reached by any other path. For | |
12589 | example, when CSE encounters an @code{if} statement with an | |
12590 | @code{else} clause, CSE follows the jump when the condition | |
12591 | tested is false. | |
12592 | ||
12593 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12594 | ||
d77de738 | 12595 | @opindex fcse-skip-blocks |
ddf6fe37 | 12596 | @item -fcse-skip-blocks |
d77de738 ML |
12597 | This is similar to @option{-fcse-follow-jumps}, but causes CSE to |
12598 | follow jumps that conditionally skip over blocks. When CSE | |
12599 | encounters a simple @code{if} statement with no else clause, | |
12600 | @option{-fcse-skip-blocks} causes CSE to follow the jump around the | |
12601 | body of the @code{if}. | |
12602 | ||
12603 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12604 | ||
d77de738 | 12605 | @opindex frerun-cse-after-loop |
ddf6fe37 | 12606 | @item -frerun-cse-after-loop |
d77de738 ML |
12607 | Re-run common subexpression elimination after loop optimizations are |
12608 | performed. | |
12609 | ||
12610 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12611 | ||
d77de738 | 12612 | @opindex fgcse |
ddf6fe37 | 12613 | @item -fgcse |
d77de738 ML |
12614 | Perform a global common subexpression elimination pass. |
12615 | This pass also performs global constant and copy propagation. | |
12616 | ||
12617 | @emph{Note:} When compiling a program using computed gotos, a GCC | |
12618 | extension, you may get better run-time performance if you disable | |
12619 | the global common subexpression elimination pass by adding | |
12620 | @option{-fno-gcse} to the command line. | |
12621 | ||
12622 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12623 | ||
d77de738 | 12624 | @opindex fgcse-lm |
ddf6fe37 | 12625 | @item -fgcse-lm |
d77de738 ML |
12626 | When @option{-fgcse-lm} is enabled, global common subexpression elimination |
12627 | attempts to move loads that are only killed by stores into themselves. This | |
12628 | allows a loop containing a load/store sequence to be changed to a load outside | |
12629 | the loop, and a copy/store within the loop. | |
12630 | ||
12631 | Enabled by default when @option{-fgcse} is enabled. | |
12632 | ||
d77de738 | 12633 | @opindex fgcse-sm |
ddf6fe37 | 12634 | @item -fgcse-sm |
d77de738 ML |
12635 | When @option{-fgcse-sm} is enabled, a store motion pass is run after |
12636 | global common subexpression elimination. This pass attempts to move | |
12637 | stores out of loops. When used in conjunction with @option{-fgcse-lm}, | |
12638 | loops containing a load/store sequence can be changed to a load before | |
12639 | the loop and a store after the loop. | |
12640 | ||
12641 | Not enabled at any optimization level. | |
12642 | ||
d77de738 | 12643 | @opindex fgcse-las |
ddf6fe37 | 12644 | @item -fgcse-las |
d77de738 ML |
12645 | When @option{-fgcse-las} is enabled, the global common subexpression |
12646 | elimination pass eliminates redundant loads that come after stores to the | |
12647 | same memory location (both partial and full redundancies). | |
12648 | ||
12649 | Not enabled at any optimization level. | |
12650 | ||
d77de738 | 12651 | @opindex fgcse-after-reload |
ddf6fe37 | 12652 | @item -fgcse-after-reload |
d77de738 ML |
12653 | When @option{-fgcse-after-reload} is enabled, a redundant load elimination |
12654 | pass is performed after reload. The purpose of this pass is to clean up | |
12655 | redundant spilling. | |
12656 | ||
12657 | Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}. | |
12658 | ||
d77de738 | 12659 | @opindex faggressive-loop-optimizations |
ddf6fe37 | 12660 | @item -faggressive-loop-optimizations |
d77de738 ML |
12661 | This option tells the loop optimizer to use language constraints to |
12662 | derive bounds for the number of iterations of a loop. This assumes that | |
12663 | loop code does not invoke undefined behavior by for example causing signed | |
12664 | integer overflows or out-of-bound array accesses. The bounds for the | |
12665 | number of iterations of a loop are used to guide loop unrolling and peeling | |
12666 | and loop exit test optimizations. | |
12667 | This option is enabled by default. | |
12668 | ||
d77de738 | 12669 | @opindex funconstrained-commons |
ddf6fe37 | 12670 | @item -funconstrained-commons |
d77de738 ML |
12671 | This option tells the compiler that variables declared in common blocks |
12672 | (e.g.@: Fortran) may later be overridden with longer trailing arrays. This | |
12673 | prevents certain optimizations that depend on knowing the array bounds. | |
12674 | ||
d77de738 | 12675 | @opindex fcrossjumping |
ddf6fe37 | 12676 | @item -fcrossjumping |
d77de738 ML |
12677 | Perform cross-jumping transformation. |
12678 | This transformation unifies equivalent code and saves code size. The | |
12679 | resulting code may or may not perform better than without cross-jumping. | |
12680 | ||
12681 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12682 | ||
d77de738 | 12683 | @opindex fauto-inc-dec |
ddf6fe37 | 12684 | @item -fauto-inc-dec |
d77de738 ML |
12685 | Combine increments or decrements of addresses with memory accesses. |
12686 | This pass is always skipped on architectures that do not have | |
12687 | instructions to support this. Enabled by default at @option{-O1} and | |
12688 | higher on architectures that support this. | |
12689 | ||
d77de738 | 12690 | @opindex fdce |
ddf6fe37 | 12691 | @item -fdce |
d77de738 ML |
12692 | Perform dead code elimination (DCE) on RTL@. |
12693 | Enabled by default at @option{-O1} and higher. | |
12694 | ||
d77de738 | 12695 | @opindex fdse |
ddf6fe37 | 12696 | @item -fdse |
d77de738 ML |
12697 | Perform dead store elimination (DSE) on RTL@. |
12698 | Enabled by default at @option{-O1} and higher. | |
12699 | ||
d77de738 | 12700 | @opindex fif-conversion |
ddf6fe37 | 12701 | @item -fif-conversion |
d77de738 ML |
12702 | Attempt to transform conditional jumps into branch-less equivalents. This |
12703 | includes use of conditional moves, min, max, set flags and abs instructions, and | |
12704 | some tricks doable by standard arithmetics. The use of conditional execution | |
12705 | on chips where it is available is controlled by @option{-fif-conversion2}. | |
12706 | ||
12707 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but | |
12708 | not with @option{-Og}. | |
12709 | ||
d77de738 | 12710 | @opindex fif-conversion2 |
ddf6fe37 | 12711 | @item -fif-conversion2 |
d77de738 ML |
12712 | Use conditional execution (where available) to transform conditional jumps into |
12713 | branch-less equivalents. | |
12714 | ||
12715 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but | |
12716 | not with @option{-Og}. | |
12717 | ||
d77de738 | 12718 | @opindex fdeclone-ctor-dtor |
ddf6fe37 | 12719 | @item -fdeclone-ctor-dtor |
d77de738 ML |
12720 | The C++ ABI requires multiple entry points for constructors and |
12721 | destructors: one for a base subobject, one for a complete object, and | |
12722 | one for a virtual destructor that calls operator delete afterwards. | |
12723 | For a hierarchy with virtual bases, the base and complete variants are | |
12724 | clones, which means two copies of the function. With this option, the | |
12725 | base and complete variants are changed to be thunks that call a common | |
12726 | implementation. | |
12727 | ||
12728 | Enabled by @option{-Os}. | |
12729 | ||
d77de738 | 12730 | @opindex fdelete-null-pointer-checks |
ddf6fe37 | 12731 | @item -fdelete-null-pointer-checks |
d77de738 ML |
12732 | Assume that programs cannot safely dereference null pointers, and that |
12733 | no code or data element resides at address zero. | |
12734 | This option enables simple constant | |
12735 | folding optimizations at all optimization levels. In addition, other | |
12736 | optimization passes in GCC use this flag to control global dataflow | |
12737 | analyses that eliminate useless checks for null pointers; these assume | |
12738 | that a memory access to address zero always results in a trap, so | |
12739 | that if a pointer is checked after it has already been dereferenced, | |
12740 | it cannot be null. | |
12741 | ||
12742 | Note however that in some environments this assumption is not true. | |
12743 | Use @option{-fno-delete-null-pointer-checks} to disable this optimization | |
12744 | for programs that depend on that behavior. | |
12745 | ||
12746 | This option is enabled by default on most targets. On Nios II ELF, it | |
12747 | defaults to off. On AVR and MSP430, this option is completely disabled. | |
12748 | ||
12749 | Passes that use the dataflow information | |
12750 | are enabled independently at different optimization levels. | |
12751 | ||
d77de738 | 12752 | @opindex fdevirtualize |
ddf6fe37 | 12753 | @item -fdevirtualize |
d77de738 ML |
12754 | Attempt to convert calls to virtual functions to direct calls. This |
12755 | is done both within a procedure and interprocedurally as part of | |
12756 | indirect inlining (@option{-findirect-inlining}) and interprocedural constant | |
12757 | propagation (@option{-fipa-cp}). | |
12758 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12759 | ||
d77de738 | 12760 | @opindex fdevirtualize-speculatively |
ddf6fe37 | 12761 | @item -fdevirtualize-speculatively |
d77de738 ML |
12762 | Attempt to convert calls to virtual functions to speculative direct calls. |
12763 | Based on the analysis of the type inheritance graph, determine for a given call | |
12764 | the set of likely targets. If the set is small, preferably of size 1, change | |
12765 | the call into a conditional deciding between direct and indirect calls. The | |
12766 | speculative calls enable more optimizations, such as inlining. When they seem | |
12767 | useless after further optimization, they are converted back into original form. | |
12768 | ||
d77de738 | 12769 | @opindex fdevirtualize-at-ltrans |
ddf6fe37 | 12770 | @item -fdevirtualize-at-ltrans |
d77de738 ML |
12771 | Stream extra information needed for aggressive devirtualization when running |
12772 | the link-time optimizer in local transformation mode. | |
12773 | This option enables more devirtualization but | |
12774 | significantly increases the size of streamed data. For this reason it is | |
12775 | disabled by default. | |
12776 | ||
d77de738 | 12777 | @opindex fexpensive-optimizations |
ddf6fe37 | 12778 | @item -fexpensive-optimizations |
d77de738 ML |
12779 | Perform a number of minor optimizations that are relatively expensive. |
12780 | ||
12781 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12782 | ||
d77de738 | 12783 | @opindex free |
ddf6fe37 | 12784 | @item -free |
d77de738 ML |
12785 | Attempt to remove redundant extension instructions. This is especially |
12786 | helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit | |
12787 | registers after writing to their lower 32-bit half. | |
12788 | ||
88ae53a3 LC |
12789 | Enabled for Alpha, AArch64, LoongArch, PowerPC, RISC-V, SPARC, h83000 and x86 at |
12790 | levels @option{-O2}, @option{-O3}, @option{-Os}. | |
d77de738 | 12791 | |
d77de738 ML |
12792 | @opindex fno-lifetime-dse |
12793 | @opindex flifetime-dse | |
ddf6fe37 | 12794 | @item -fno-lifetime-dse |
d77de738 ML |
12795 | In C++ the value of an object is only affected by changes within its |
12796 | lifetime: when the constructor begins, the object has an indeterminate | |
12797 | value, and any changes during the lifetime of the object are dead when | |
12798 | the object is destroyed. Normally dead store elimination will take | |
12799 | advantage of this; if your code relies on the value of the object | |
12800 | storage persisting beyond the lifetime of the object, you can use this | |
12801 | flag to disable this optimization. To preserve stores before the | |
12802 | constructor starts (e.g.@: because your operator new clears the object | |
12803 | storage) but still treat the object as dead after the destructor, you | |
12804 | can use @option{-flifetime-dse=1}. The default behavior can be | |
12805 | explicitly selected with @option{-flifetime-dse=2}. | |
12806 | @option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}. | |
12807 | ||
d77de738 | 12808 | @opindex flive-range-shrinkage |
ddf6fe37 | 12809 | @item -flive-range-shrinkage |
d77de738 ML |
12810 | Attempt to decrease register pressure through register live range |
12811 | shrinkage. This is helpful for fast processors with small or moderate | |
12812 | size register sets. | |
12813 | ||
d77de738 | 12814 | @opindex fira-algorithm |
ddf6fe37 | 12815 | @item -fira-algorithm=@var{algorithm} |
d77de738 ML |
12816 | Use the specified coloring algorithm for the integrated register |
12817 | allocator. The @var{algorithm} argument can be @samp{priority}, which | |
12818 | specifies Chow's priority coloring, or @samp{CB}, which specifies | |
12819 | Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented | |
12820 | for all architectures, but for those targets that do support it, it is | |
12821 | the default because it generates better code. | |
12822 | ||
d77de738 | 12823 | @opindex fira-region |
ddf6fe37 | 12824 | @item -fira-region=@var{region} |
d77de738 ML |
12825 | Use specified regions for the integrated register allocator. The |
12826 | @var{region} argument should be one of the following: | |
12827 | ||
12828 | @table @samp | |
12829 | ||
12830 | @item all | |
12831 | Use all loops as register allocation regions. | |
12832 | This can give the best results for machines with a small and/or | |
12833 | irregular register set. | |
12834 | ||
12835 | @item mixed | |
12836 | Use all loops except for loops with small register pressure | |
12837 | as the regions. This value usually gives | |
12838 | the best results in most cases and for most architectures, | |
12839 | and is enabled by default when compiling with optimization for speed | |
12840 | (@option{-O}, @option{-O2}, @dots{}). | |
12841 | ||
12842 | @item one | |
12843 | Use all functions as a single region. | |
12844 | This typically results in the smallest code size, and is enabled by default for | |
12845 | @option{-Os} or @option{-O0}. | |
12846 | ||
12847 | @end table | |
12848 | ||
d77de738 | 12849 | @opindex fira-hoist-pressure |
ddf6fe37 | 12850 | @item -fira-hoist-pressure |
d77de738 ML |
12851 | Use IRA to evaluate register pressure in the code hoisting pass for |
12852 | decisions to hoist expressions. This option usually results in smaller | |
12853 | code, but it can slow the compiler down. | |
12854 | ||
12855 | This option is enabled at level @option{-Os} for all targets. | |
12856 | ||
d77de738 | 12857 | @opindex fira-loop-pressure |
ddf6fe37 | 12858 | @item -fira-loop-pressure |
d77de738 ML |
12859 | Use IRA to evaluate register pressure in loops for decisions to move |
12860 | loop invariants. This option usually results in generation | |
12861 | of faster and smaller code on machines with large register files (>= 32 | |
12862 | registers), but it can slow the compiler down. | |
12863 | ||
12864 | This option is enabled at level @option{-O3} for some targets. | |
12865 | ||
d77de738 ML |
12866 | @opindex fno-ira-share-save-slots |
12867 | @opindex fira-share-save-slots | |
ddf6fe37 | 12868 | @item -fno-ira-share-save-slots |
d77de738 ML |
12869 | Disable sharing of stack slots used for saving call-used hard |
12870 | registers living through a call. Each hard register gets a | |
12871 | separate stack slot, and as a result function stack frames are | |
12872 | larger. | |
12873 | ||
d77de738 ML |
12874 | @opindex fno-ira-share-spill-slots |
12875 | @opindex fira-share-spill-slots | |
ddf6fe37 | 12876 | @item -fno-ira-share-spill-slots |
d77de738 ML |
12877 | Disable sharing of stack slots allocated for pseudo-registers. Each |
12878 | pseudo-register that does not get a hard register gets a separate | |
12879 | stack slot, and as a result function stack frames are larger. | |
12880 | ||
d77de738 | 12881 | @opindex flra-remat |
ddf6fe37 | 12882 | @item -flra-remat |
d77de738 ML |
12883 | Enable CFG-sensitive rematerialization in LRA. Instead of loading |
12884 | values of spilled pseudos, LRA tries to rematerialize (recalculate) | |
12885 | values if it is profitable. | |
12886 | ||
12887 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12888 | ||
d77de738 | 12889 | @opindex fdelayed-branch |
ddf6fe37 | 12890 | @item -fdelayed-branch |
d77de738 ML |
12891 | If supported for the target machine, attempt to reorder instructions |
12892 | to exploit instruction slots available after delayed branch | |
12893 | instructions. | |
12894 | ||
12895 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, | |
12896 | but not at @option{-Og}. | |
12897 | ||
d77de738 | 12898 | @opindex fschedule-insns |
ddf6fe37 | 12899 | @item -fschedule-insns |
d77de738 ML |
12900 | If supported for the target machine, attempt to reorder instructions to |
12901 | eliminate execution stalls due to required data being unavailable. This | |
12902 | helps machines that have slow floating point or memory load instructions | |
12903 | by allowing other instructions to be issued until the result of the load | |
12904 | or floating-point instruction is required. | |
12905 | ||
12906 | Enabled at levels @option{-O2}, @option{-O3}. | |
12907 | ||
d77de738 | 12908 | @opindex fschedule-insns2 |
ddf6fe37 | 12909 | @item -fschedule-insns2 |
d77de738 ML |
12910 | Similar to @option{-fschedule-insns}, but requests an additional pass of |
12911 | instruction scheduling after register allocation has been done. This is | |
12912 | especially useful on machines with a relatively small number of | |
12913 | registers and where memory load instructions take more than one cycle. | |
12914 | ||
12915 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12916 | ||
d77de738 ML |
12917 | @opindex fno-sched-interblock |
12918 | @opindex fsched-interblock | |
ddf6fe37 | 12919 | @item -fno-sched-interblock |
d77de738 ML |
12920 | Disable instruction scheduling across basic blocks, which |
12921 | is normally enabled when scheduling before register allocation, i.e.@: | |
12922 | with @option{-fschedule-insns} or at @option{-O2} or higher. | |
12923 | ||
d77de738 ML |
12924 | @opindex fno-sched-spec |
12925 | @opindex fsched-spec | |
ddf6fe37 | 12926 | @item -fno-sched-spec |
d77de738 ML |
12927 | Disable speculative motion of non-load instructions, which |
12928 | is normally enabled when scheduling before register allocation, i.e.@: | |
12929 | with @option{-fschedule-insns} or at @option{-O2} or higher. | |
12930 | ||
d77de738 | 12931 | @opindex fsched-pressure |
ddf6fe37 | 12932 | @item -fsched-pressure |
d77de738 ML |
12933 | Enable register pressure sensitive insn scheduling before register |
12934 | allocation. This only makes sense when scheduling before register | |
12935 | allocation is enabled, i.e.@: with @option{-fschedule-insns} or at | |
12936 | @option{-O2} or higher. Usage of this option can improve the | |
12937 | generated code and decrease its size by preventing register pressure | |
12938 | increase above the number of available hard registers and subsequent | |
12939 | spills in register allocation. | |
12940 | ||
d77de738 | 12941 | @opindex fsched-spec-load |
ddf6fe37 | 12942 | @item -fsched-spec-load |
d77de738 ML |
12943 | Allow speculative motion of some load instructions. This only makes |
12944 | sense when scheduling before register allocation, i.e.@: with | |
12945 | @option{-fschedule-insns} or at @option{-O2} or higher. | |
12946 | ||
d77de738 | 12947 | @opindex fsched-spec-load-dangerous |
ddf6fe37 | 12948 | @item -fsched-spec-load-dangerous |
d77de738 ML |
12949 | Allow speculative motion of more load instructions. This only makes |
12950 | sense when scheduling before register allocation, i.e.@: with | |
12951 | @option{-fschedule-insns} or at @option{-O2} or higher. | |
12952 | ||
ddf6fe37 | 12953 | @opindex fsched-stalled-insns |
d77de738 ML |
12954 | @item -fsched-stalled-insns |
12955 | @itemx -fsched-stalled-insns=@var{n} | |
d77de738 ML |
12956 | Define how many insns (if any) can be moved prematurely from the queue |
12957 | of stalled insns into the ready list during the second scheduling pass. | |
12958 | @option{-fno-sched-stalled-insns} means that no insns are moved | |
12959 | prematurely, @option{-fsched-stalled-insns=0} means there is no limit | |
12960 | on how many queued insns can be moved prematurely. | |
12961 | @option{-fsched-stalled-insns} without a value is equivalent to | |
12962 | @option{-fsched-stalled-insns=1}. | |
12963 | ||
ddf6fe37 | 12964 | @opindex fsched-stalled-insns-dep |
d77de738 ML |
12965 | @item -fsched-stalled-insns-dep |
12966 | @itemx -fsched-stalled-insns-dep=@var{n} | |
d77de738 ML |
12967 | Define how many insn groups (cycles) are examined for a dependency |
12968 | on a stalled insn that is a candidate for premature removal from the queue | |
12969 | of stalled insns. This has an effect only during the second scheduling pass, | |
12970 | and only if @option{-fsched-stalled-insns} is used. | |
12971 | @option{-fno-sched-stalled-insns-dep} is equivalent to | |
12972 | @option{-fsched-stalled-insns-dep=0}. | |
12973 | @option{-fsched-stalled-insns-dep} without a value is equivalent to | |
12974 | @option{-fsched-stalled-insns-dep=1}. | |
12975 | ||
d77de738 | 12976 | @opindex fsched2-use-superblocks |
ddf6fe37 | 12977 | @item -fsched2-use-superblocks |
d77de738 ML |
12978 | When scheduling after register allocation, use superblock scheduling. |
12979 | This allows motion across basic block boundaries, | |
12980 | resulting in faster schedules. This option is experimental, as not all machine | |
12981 | descriptions used by GCC model the CPU closely enough to avoid unreliable | |
12982 | results from the algorithm. | |
12983 | ||
12984 | This only makes sense when scheduling after register allocation, i.e.@: with | |
12985 | @option{-fschedule-insns2} or at @option{-O2} or higher. | |
12986 | ||
d77de738 | 12987 | @opindex fsched-group-heuristic |
ddf6fe37 | 12988 | @item -fsched-group-heuristic |
d77de738 ML |
12989 | Enable the group heuristic in the scheduler. This heuristic favors |
12990 | the instruction that belongs to a schedule group. This is enabled | |
12991 | by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns} | |
12992 | or @option{-fschedule-insns2} or at @option{-O2} or higher. | |
12993 | ||
d77de738 | 12994 | @opindex fsched-critical-path-heuristic |
ddf6fe37 | 12995 | @item -fsched-critical-path-heuristic |
d77de738 ML |
12996 | Enable the critical-path heuristic in the scheduler. This heuristic favors |
12997 | instructions on the critical path. This is enabled by default when | |
12998 | scheduling is enabled, i.e.@: with @option{-fschedule-insns} | |
12999 | or @option{-fschedule-insns2} or at @option{-O2} or higher. | |
13000 | ||
d77de738 | 13001 | @opindex fsched-spec-insn-heuristic |
ddf6fe37 | 13002 | @item -fsched-spec-insn-heuristic |
d77de738 ML |
13003 | Enable the speculative instruction heuristic in the scheduler. This |
13004 | heuristic favors speculative instructions with greater dependency weakness. | |
13005 | This is enabled by default when scheduling is enabled, i.e.@: | |
13006 | with @option{-fschedule-insns} or @option{-fschedule-insns2} | |
13007 | or at @option{-O2} or higher. | |
13008 | ||
d77de738 | 13009 | @opindex fsched-rank-heuristic |
ddf6fe37 | 13010 | @item -fsched-rank-heuristic |
d77de738 ML |
13011 | Enable the rank heuristic in the scheduler. This heuristic favors |
13012 | the instruction belonging to a basic block with greater size or frequency. | |
13013 | This is enabled by default when scheduling is enabled, i.e.@: | |
13014 | with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
13015 | at @option{-O2} or higher. | |
13016 | ||
d77de738 | 13017 | @opindex fsched-last-insn-heuristic |
ddf6fe37 | 13018 | @item -fsched-last-insn-heuristic |
d77de738 ML |
13019 | Enable the last-instruction heuristic in the scheduler. This heuristic |
13020 | favors the instruction that is less dependent on the last instruction | |
13021 | scheduled. This is enabled by default when scheduling is enabled, | |
13022 | i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
13023 | at @option{-O2} or higher. | |
13024 | ||
d77de738 | 13025 | @opindex fsched-dep-count-heuristic |
ddf6fe37 | 13026 | @item -fsched-dep-count-heuristic |
d77de738 ML |
13027 | Enable the dependent-count heuristic in the scheduler. This heuristic |
13028 | favors the instruction that has more instructions depending on it. | |
13029 | This is enabled by default when scheduling is enabled, i.e.@: | |
13030 | with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
13031 | at @option{-O2} or higher. | |
13032 | ||
d77de738 | 13033 | @opindex freschedule-modulo-scheduled-loops |
ddf6fe37 | 13034 | @item -freschedule-modulo-scheduled-loops |
d77de738 ML |
13035 | Modulo scheduling is performed before traditional scheduling. If a loop |
13036 | is modulo scheduled, later scheduling passes may change its schedule. | |
13037 | Use this option to control that behavior. | |
13038 | ||
d77de738 | 13039 | @opindex fselective-scheduling |
ddf6fe37 | 13040 | @item -fselective-scheduling |
d77de738 ML |
13041 | Schedule instructions using selective scheduling algorithm. Selective |
13042 | scheduling runs instead of the first scheduler pass. | |
13043 | ||
d77de738 | 13044 | @opindex fselective-scheduling2 |
ddf6fe37 | 13045 | @item -fselective-scheduling2 |
d77de738 ML |
13046 | Schedule instructions using selective scheduling algorithm. Selective |
13047 | scheduling runs instead of the second scheduler pass. | |
13048 | ||
d77de738 | 13049 | @opindex fsel-sched-pipelining |
ddf6fe37 | 13050 | @item -fsel-sched-pipelining |
d77de738 ML |
13051 | Enable software pipelining of innermost loops during selective scheduling. |
13052 | This option has no effect unless one of @option{-fselective-scheduling} or | |
13053 | @option{-fselective-scheduling2} is turned on. | |
13054 | ||
d77de738 | 13055 | @opindex fsel-sched-pipelining-outer-loops |
ddf6fe37 | 13056 | @item -fsel-sched-pipelining-outer-loops |
d77de738 ML |
13057 | When pipelining loops during selective scheduling, also pipeline outer loops. |
13058 | This option has no effect unless @option{-fsel-sched-pipelining} is turned on. | |
13059 | ||
d77de738 | 13060 | @opindex fsemantic-interposition |
ddf6fe37 | 13061 | @item -fsemantic-interposition |
d77de738 ML |
13062 | Some object formats, like ELF, allow interposing of symbols by the |
13063 | dynamic linker. | |
13064 | This means that for symbols exported from the DSO, the compiler cannot perform | |
13065 | interprocedural propagation, inlining and other optimizations in anticipation | |
13066 | that the function or variable in question may change. While this feature is | |
13067 | useful, for example, to rewrite memory allocation functions by a debugging | |
13068 | implementation, it is expensive in the terms of code quality. | |
13069 | With @option{-fno-semantic-interposition} the compiler assumes that | |
13070 | if interposition happens for functions the overwriting function will have | |
13071 | precisely the same semantics (and side effects). | |
13072 | Similarly if interposition happens | |
13073 | for variables, the constructor of the variable will be the same. The flag | |
13074 | has no effect for functions explicitly declared inline | |
13075 | (where it is never allowed for interposition to change semantics) | |
13076 | and for symbols explicitly declared weak. | |
13077 | ||
d77de738 | 13078 | @opindex fshrink-wrap |
ddf6fe37 | 13079 | @item -fshrink-wrap |
d77de738 ML |
13080 | Emit function prologues only before parts of the function that need it, |
13081 | rather than at the top of the function. This flag is enabled by default at | |
13082 | @option{-O} and higher. | |
13083 | ||
d77de738 | 13084 | @opindex fshrink-wrap-separate |
ddf6fe37 | 13085 | @item -fshrink-wrap-separate |
d77de738 ML |
13086 | Shrink-wrap separate parts of the prologue and epilogue separately, so that |
13087 | those parts are only executed when needed. | |
13088 | This option is on by default, but has no effect unless @option{-fshrink-wrap} | |
13089 | is also turned on and the target supports this. | |
13090 | ||
d77de738 | 13091 | @opindex fcaller-saves |
ddf6fe37 | 13092 | @item -fcaller-saves |
d77de738 ML |
13093 | Enable allocation of values to registers that are clobbered by |
13094 | function calls, by emitting extra instructions to save and restore the | |
13095 | registers around such calls. Such allocation is done only when it | |
13096 | seems to result in better code. | |
13097 | ||
13098 | This option is always enabled by default on certain machines, usually | |
13099 | those which have no call-preserved registers to use instead. | |
13100 | ||
13101 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13102 | ||
d77de738 | 13103 | @opindex fcombine-stack-adjustments |
ddf6fe37 | 13104 | @item -fcombine-stack-adjustments |
d77de738 ML |
13105 | Tracks stack adjustments (pushes and pops) and stack memory references |
13106 | and then tries to find ways to combine them. | |
13107 | ||
13108 | Enabled by default at @option{-O1} and higher. | |
13109 | ||
d77de738 | 13110 | @opindex fipa-ra |
ddf6fe37 | 13111 | @item -fipa-ra |
d77de738 ML |
13112 | Use caller save registers for allocation if those registers are not used by |
13113 | any called function. In that case it is not necessary to save and restore | |
13114 | them around calls. This is only possible if called functions are part of | |
13115 | same compilation unit as current function and they are compiled before it. | |
13116 | ||
13117 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option | |
13118 | is disabled if generated code will be instrumented for profiling | |
13119 | (@option{-p}, or @option{-pg}) or if callee's register usage cannot be known | |
13120 | exactly (this happens on targets that do not expose prologues | |
13121 | and epilogues in RTL). | |
13122 | ||
d77de738 | 13123 | @opindex fconserve-stack |
ddf6fe37 | 13124 | @item -fconserve-stack |
d77de738 ML |
13125 | Attempt to minimize stack usage. The compiler attempts to use less |
13126 | stack space, even if that makes the program slower. This option | |
13127 | implies setting the @option{large-stack-frame} parameter to 100 | |
13128 | and the @option{large-stack-frame-growth} parameter to 400. | |
13129 | ||
d77de738 | 13130 | @opindex ftree-reassoc |
ddf6fe37 | 13131 | @item -ftree-reassoc |
d77de738 ML |
13132 | Perform reassociation on trees. This flag is enabled by default |
13133 | at @option{-O1} and higher. | |
13134 | ||
d77de738 | 13135 | @opindex fcode-hoisting |
ddf6fe37 | 13136 | @item -fcode-hoisting |
d77de738 ML |
13137 | Perform code hoisting. Code hoisting tries to move the |
13138 | evaluation of expressions executed on all paths to the function exit | |
13139 | as early as possible. This is especially useful as a code size | |
13140 | optimization, but it often helps for code speed as well. | |
13141 | This flag is enabled by default at @option{-O2} and higher. | |
13142 | ||
d77de738 | 13143 | @opindex ftree-pre |
ddf6fe37 | 13144 | @item -ftree-pre |
d77de738 ML |
13145 | Perform partial redundancy elimination (PRE) on trees. This flag is |
13146 | enabled by default at @option{-O2} and @option{-O3}. | |
13147 | ||
d77de738 | 13148 | @opindex ftree-partial-pre |
ddf6fe37 | 13149 | @item -ftree-partial-pre |
d77de738 ML |
13150 | Make partial redundancy elimination (PRE) more aggressive. This flag is |
13151 | enabled by default at @option{-O3}. | |
13152 | ||
d77de738 | 13153 | @opindex ftree-forwprop |
ddf6fe37 | 13154 | @item -ftree-forwprop |
d77de738 ML |
13155 | Perform forward propagation on trees. This flag is enabled by default |
13156 | at @option{-O1} and higher. | |
13157 | ||
d77de738 | 13158 | @opindex ftree-fre |
ddf6fe37 | 13159 | @item -ftree-fre |
d77de738 ML |
13160 | Perform full redundancy elimination (FRE) on trees. The difference |
13161 | between FRE and PRE is that FRE only considers expressions | |
13162 | that are computed on all paths leading to the redundant computation. | |
13163 | This analysis is faster than PRE, though it exposes fewer redundancies. | |
13164 | This flag is enabled by default at @option{-O1} and higher. | |
13165 | ||
d77de738 | 13166 | @opindex ftree-phiprop |
ddf6fe37 | 13167 | @item -ftree-phiprop |
d77de738 ML |
13168 | Perform hoisting of loads from conditional pointers on trees. This |
13169 | pass is enabled by default at @option{-O1} and higher. | |
13170 | ||
d77de738 | 13171 | @opindex fhoist-adjacent-loads |
ddf6fe37 | 13172 | @item -fhoist-adjacent-loads |
d77de738 ML |
13173 | Speculatively hoist loads from both branches of an if-then-else if the |
13174 | loads are from adjacent locations in the same structure and the target | |
13175 | architecture has a conditional move instruction. This flag is enabled | |
13176 | by default at @option{-O2} and higher. | |
13177 | ||
d77de738 | 13178 | @opindex ftree-copy-prop |
ddf6fe37 | 13179 | @item -ftree-copy-prop |
d77de738 ML |
13180 | Perform copy propagation on trees. This pass eliminates unnecessary |
13181 | copy operations. This flag is enabled by default at @option{-O1} and | |
13182 | higher. | |
13183 | ||
d77de738 | 13184 | @opindex fipa-pure-const |
ddf6fe37 | 13185 | @item -fipa-pure-const |
d77de738 ML |
13186 | Discover which functions are pure or constant. |
13187 | Enabled by default at @option{-O1} and higher. | |
13188 | ||
d77de738 | 13189 | @opindex fipa-reference |
ddf6fe37 | 13190 | @item -fipa-reference |
d77de738 ML |
13191 | Discover which static variables do not escape the |
13192 | compilation unit. | |
13193 | Enabled by default at @option{-O1} and higher. | |
13194 | ||
d77de738 | 13195 | @opindex fipa-reference-addressable |
ddf6fe37 | 13196 | @item -fipa-reference-addressable |
d77de738 ML |
13197 | Discover read-only, write-only and non-addressable static variables. |
13198 | Enabled by default at @option{-O1} and higher. | |
13199 | ||
d77de738 | 13200 | @opindex fipa-stack-alignment |
ddf6fe37 | 13201 | @item -fipa-stack-alignment |
d77de738 ML |
13202 | Reduce stack alignment on call sites if possible. |
13203 | Enabled by default. | |
13204 | ||
d77de738 | 13205 | @opindex fipa-pta |
ddf6fe37 | 13206 | @item -fipa-pta |
d77de738 ML |
13207 | Perform interprocedural pointer analysis and interprocedural modification |
13208 | and reference analysis. This option can cause excessive memory and | |
13209 | compile-time usage on large compilation units. It is not enabled by | |
13210 | default at any optimization level. | |
13211 | ||
d77de738 | 13212 | @opindex fipa-profile |
ddf6fe37 | 13213 | @item -fipa-profile |
d77de738 ML |
13214 | Perform interprocedural profile propagation. The functions called only from |
13215 | cold functions are marked as cold. Also functions executed once (such as | |
13216 | @code{cold}, @code{noreturn}, static constructors or destructors) are | |
13217 | identified. Cold functions and loop less parts of functions executed once are | |
13218 | then optimized for size. | |
13219 | Enabled by default at @option{-O1} and higher. | |
13220 | ||
d77de738 | 13221 | @opindex fipa-modref |
ddf6fe37 | 13222 | @item -fipa-modref |
d77de738 ML |
13223 | Perform interprocedural mod/ref analysis. This optimization analyzes the side |
13224 | effects of functions (memory locations that are modified or referenced) and | |
13225 | enables better optimization across the function call boundary. This flag is | |
13226 | enabled by default at @option{-O1} and higher. | |
13227 | ||
d77de738 | 13228 | @opindex fipa-cp |
ddf6fe37 | 13229 | @item -fipa-cp |
d77de738 ML |
13230 | Perform interprocedural constant propagation. |
13231 | This optimization analyzes the program to determine when values passed | |
13232 | to functions are constants and then optimizes accordingly. | |
13233 | This optimization can substantially increase performance | |
13234 | if the application has constants passed to functions. | |
13235 | This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}. | |
13236 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13237 | ||
d77de738 | 13238 | @opindex fipa-cp-clone |
ddf6fe37 | 13239 | @item -fipa-cp-clone |
d77de738 ML |
13240 | Perform function cloning to make interprocedural constant propagation stronger. |
13241 | When enabled, interprocedural constant propagation performs function cloning | |
13242 | when externally visible function can be called with constant arguments. | |
13243 | Because this optimization can create multiple copies of functions, | |
13244 | it may significantly increase code size | |
13245 | (see @option{--param ipa-cp-unit-growth=@var{value}}). | |
13246 | This flag is enabled by default at @option{-O3}. | |
13247 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13248 | ||
d77de738 | 13249 | @opindex fipa-bit-cp |
ddf6fe37 | 13250 | @item -fipa-bit-cp |
d77de738 ML |
13251 | When enabled, perform interprocedural bitwise constant |
13252 | propagation. This flag is enabled by default at @option{-O2} and | |
13253 | by @option{-fprofile-use} and @option{-fauto-profile}. | |
13254 | It requires that @option{-fipa-cp} is enabled. | |
13255 | ||
d77de738 | 13256 | @opindex fipa-vrp |
ddf6fe37 | 13257 | @item -fipa-vrp |
d77de738 ML |
13258 | When enabled, perform interprocedural propagation of value |
13259 | ranges. This flag is enabled by default at @option{-O2}. It requires | |
13260 | that @option{-fipa-cp} is enabled. | |
13261 | ||
d77de738 | 13262 | @opindex fipa-icf |
ddf6fe37 | 13263 | @item -fipa-icf |
d77de738 ML |
13264 | Perform Identical Code Folding for functions and read-only variables. |
13265 | The optimization reduces code size and may disturb unwind stacks by replacing | |
13266 | a function by equivalent one with a different name. The optimization works | |
13267 | more effectively with link-time optimization enabled. | |
13268 | ||
13269 | Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF | |
13270 | works on different levels and thus the optimizations are not same - there are | |
13271 | equivalences that are found only by GCC and equivalences found only by Gold. | |
13272 | ||
13273 | This flag is enabled by default at @option{-O2} and @option{-Os}. | |
13274 | ||
d77de738 | 13275 | @opindex flive-patching |
ddf6fe37 | 13276 | @item -flive-patching=@var{level} |
d77de738 ML |
13277 | Control GCC's optimizations to produce output suitable for live-patching. |
13278 | ||
13279 | If the compiler's optimization uses a function's body or information extracted | |
13280 | from its body to optimize/change another function, the latter is called an | |
13281 | impacted function of the former. If a function is patched, its impacted | |
13282 | functions should be patched too. | |
13283 | ||
13284 | The impacted functions are determined by the compiler's interprocedural | |
13285 | optimizations. For example, a caller is impacted when inlining a function | |
13286 | into its caller, | |
13287 | cloning a function and changing its caller to call this new clone, | |
13288 | or extracting a function's pureness/constness information to optimize | |
13289 | its direct or indirect callers, etc. | |
13290 | ||
13291 | Usually, the more IPA optimizations enabled, the larger the number of | |
13292 | impacted functions for each function. In order to control the number of | |
13293 | impacted functions and more easily compute the list of impacted function, | |
13294 | IPA optimizations can be partially enabled at two different levels. | |
13295 | ||
13296 | The @var{level} argument should be one of the following: | |
13297 | ||
13298 | @table @samp | |
13299 | ||
13300 | @item inline-clone | |
13301 | ||
13302 | Only enable inlining and cloning optimizations, which includes inlining, | |
13303 | cloning, interprocedural scalar replacement of aggregates and partial inlining. | |
13304 | As a result, when patching a function, all its callers and its clones' | |
13305 | callers are impacted, therefore need to be patched as well. | |
13306 | ||
13307 | @option{-flive-patching=inline-clone} disables the following optimization flags: | |
43b72ede AA |
13308 | @gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra |
13309 | -fipa-icf -fipa-icf-functions -fipa-icf-variables | |
13310 | -fipa-bit-cp -fipa-vrp -fipa-pure-const | |
13311 | -fipa-reference-addressable | |
d77de738 ML |
13312 | -fipa-stack-alignment -fipa-modref} |
13313 | ||
13314 | @item inline-only-static | |
13315 | ||
13316 | Only enable inlining of static functions. | |
13317 | As a result, when patching a static function, all its callers are impacted | |
13318 | and so need to be patched as well. | |
13319 | ||
13320 | In addition to all the flags that @option{-flive-patching=inline-clone} | |
13321 | disables, | |
13322 | @option{-flive-patching=inline-only-static} disables the following additional | |
13323 | optimization flags: | |
13324 | @gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp} | |
13325 | ||
13326 | @end table | |
13327 | ||
13328 | When @option{-flive-patching} is specified without any value, the default value | |
13329 | is @var{inline-clone}. | |
13330 | ||
13331 | This flag is disabled by default. | |
13332 | ||
13333 | Note that @option{-flive-patching} is not supported with link-time optimization | |
13334 | (@option{-flto}). | |
13335 | ||
d77de738 | 13336 | @opindex fisolate-erroneous-paths-dereference |
ddf6fe37 | 13337 | @item -fisolate-erroneous-paths-dereference |
d77de738 ML |
13338 | Detect paths that trigger erroneous or undefined behavior due to |
13339 | dereferencing a null pointer. Isolate those paths from the main control | |
13340 | flow and turn the statement with erroneous or undefined behavior into a trap. | |
13341 | This flag is enabled by default at @option{-O2} and higher and depends on | |
13342 | @option{-fdelete-null-pointer-checks} also being enabled. | |
13343 | ||
d77de738 | 13344 | @opindex fisolate-erroneous-paths-attribute |
ddf6fe37 | 13345 | @item -fisolate-erroneous-paths-attribute |
d77de738 ML |
13346 | Detect paths that trigger erroneous or undefined behavior due to a null value |
13347 | being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull} | |
13348 | attribute. Isolate those paths from the main control flow and turn the | |
13349 | statement with erroneous or undefined behavior into a trap. This is not | |
13350 | currently enabled, but may be enabled by @option{-O2} in the future. | |
13351 | ||
d77de738 | 13352 | @opindex ftree-sink |
ddf6fe37 | 13353 | @item -ftree-sink |
d77de738 ML |
13354 | Perform forward store motion on trees. This flag is |
13355 | enabled by default at @option{-O1} and higher. | |
13356 | ||
d77de738 | 13357 | @opindex ftree-bit-ccp |
ddf6fe37 | 13358 | @item -ftree-bit-ccp |
d77de738 ML |
13359 | Perform sparse conditional bit constant propagation on trees and propagate |
13360 | pointer alignment information. | |
13361 | This pass only operates on local scalar variables and is enabled by default | |
13362 | at @option{-O1} and higher, except for @option{-Og}. | |
13363 | It requires that @option{-ftree-ccp} is enabled. | |
13364 | ||
d77de738 | 13365 | @opindex ftree-ccp |
ddf6fe37 | 13366 | @item -ftree-ccp |
d77de738 ML |
13367 | Perform sparse conditional constant propagation (CCP) on trees. This |
13368 | pass only operates on local scalar variables and is enabled by default | |
13369 | at @option{-O1} and higher. | |
13370 | ||
d77de738 | 13371 | @opindex fssa-backprop |
ddf6fe37 | 13372 | @item -fssa-backprop |
d77de738 ML |
13373 | Propagate information about uses of a value up the definition chain |
13374 | in order to simplify the definitions. For example, this pass strips | |
13375 | sign operations if the sign of a value never matters. The flag is | |
13376 | enabled by default at @option{-O1} and higher. | |
13377 | ||
d77de738 | 13378 | @opindex fssa-phiopt |
ddf6fe37 | 13379 | @item -fssa-phiopt |
d77de738 ML |
13380 | Perform pattern matching on SSA PHI nodes to optimize conditional |
13381 | code. This pass is enabled by default at @option{-O1} and higher, | |
13382 | except for @option{-Og}. | |
13383 | ||
d77de738 | 13384 | @opindex ftree-switch-conversion |
ddf6fe37 | 13385 | @item -ftree-switch-conversion |
d77de738 ML |
13386 | Perform conversion of simple initializations in a switch to |
13387 | initializations from a scalar array. This flag is enabled by default | |
13388 | at @option{-O2} and higher. | |
13389 | ||
d77de738 | 13390 | @opindex ftree-tail-merge |
ddf6fe37 | 13391 | @item -ftree-tail-merge |
d77de738 ML |
13392 | Look for identical code sequences. When found, replace one with a jump to the |
13393 | other. This optimization is known as tail merging or cross jumping. This flag | |
13394 | is enabled by default at @option{-O2} and higher. The compilation time | |
13395 | in this pass can | |
13396 | be limited using @option{max-tail-merge-comparisons} parameter and | |
13397 | @option{max-tail-merge-iterations} parameter. | |
13398 | ||
d77de738 | 13399 | @opindex ftree-dce |
ddf6fe37 | 13400 | @item -ftree-dce |
d77de738 ML |
13401 | Perform dead code elimination (DCE) on trees. This flag is enabled by |
13402 | default at @option{-O1} and higher. | |
13403 | ||
d77de738 | 13404 | @opindex ftree-builtin-call-dce |
ddf6fe37 | 13405 | @item -ftree-builtin-call-dce |
d77de738 ML |
13406 | Perform conditional dead code elimination (DCE) for calls to built-in functions |
13407 | that may set @code{errno} but are otherwise free of side effects. This flag is | |
13408 | enabled by default at @option{-O2} and higher if @option{-Os} is not also | |
13409 | specified. | |
13410 | ||
d77de738 ML |
13411 | @opindex ffinite-loops |
13412 | @opindex fno-finite-loops | |
ddf6fe37 | 13413 | @item -ffinite-loops |
d77de738 ML |
13414 | Assume that a loop with an exit will eventually take the exit and not loop |
13415 | indefinitely. This allows the compiler to remove loops that otherwise have | |
13416 | no side-effects, not considering eventual endless looping as such. | |
13417 | ||
13418 | This option is enabled by default at @option{-O2} for C++ with -std=c++11 | |
13419 | or higher. | |
13420 | ||
d77de738 | 13421 | @opindex ftree-dominator-opts |
ddf6fe37 | 13422 | @item -ftree-dominator-opts |
d77de738 ML |
13423 | Perform a variety of simple scalar cleanups (constant/copy |
13424 | propagation, redundancy elimination, range propagation and expression | |
13425 | simplification) based on a dominator tree traversal. This also | |
13426 | performs jump threading (to reduce jumps to jumps). This flag is | |
13427 | enabled by default at @option{-O1} and higher. | |
13428 | ||
d77de738 | 13429 | @opindex ftree-dse |
ddf6fe37 | 13430 | @item -ftree-dse |
d77de738 ML |
13431 | Perform dead store elimination (DSE) on trees. A dead store is a store into |
13432 | a memory location that is later overwritten by another store without | |
13433 | any intervening loads. In this case the earlier store can be deleted. This | |
13434 | flag is enabled by default at @option{-O1} and higher. | |
13435 | ||
d77de738 | 13436 | @opindex ftree-ch |
ddf6fe37 | 13437 | @item -ftree-ch |
d77de738 ML |
13438 | Perform loop header copying on trees. This is beneficial since it increases |
13439 | effectiveness of code motion optimizations. It also saves one jump. This flag | |
13440 | is enabled by default at @option{-O1} and higher. It is not enabled | |
13441 | for @option{-Os}, since it usually increases code size. | |
13442 | ||
d77de738 | 13443 | @opindex ftree-loop-optimize |
ddf6fe37 | 13444 | @item -ftree-loop-optimize |
d77de738 ML |
13445 | Perform loop optimizations on trees. This flag is enabled by default |
13446 | at @option{-O1} and higher. | |
13447 | ||
d77de738 ML |
13448 | @opindex ftree-loop-linear |
13449 | @opindex floop-strip-mine | |
13450 | @opindex floop-block | |
ddf6fe37 AA |
13451 | @item -ftree-loop-linear |
13452 | @itemx -floop-strip-mine | |
13453 | @itemx -floop-block | |
d77de738 ML |
13454 | Perform loop nest optimizations. Same as |
13455 | @option{-floop-nest-optimize}. To use this code transformation, GCC has | |
13456 | to be configured with @option{--with-isl} to enable the Graphite loop | |
13457 | transformation infrastructure. | |
13458 | ||
d77de738 | 13459 | @opindex fgraphite-identity |
ddf6fe37 | 13460 | @item -fgraphite-identity |
d77de738 ML |
13461 | Enable the identity transformation for graphite. For every SCoP we generate |
13462 | the polyhedral representation and transform it back to gimple. Using | |
13463 | @option{-fgraphite-identity} we can check the costs or benefits of the | |
13464 | GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations | |
13465 | are also performed by the code generator isl, like index splitting and | |
13466 | dead code elimination in loops. | |
13467 | ||
d77de738 | 13468 | @opindex floop-nest-optimize |
ddf6fe37 | 13469 | @item -floop-nest-optimize |
d77de738 ML |
13470 | Enable the isl based loop nest optimizer. This is a generic loop nest |
13471 | optimizer based on the Pluto optimization algorithms. It calculates a loop | |
13472 | structure optimized for data-locality and parallelism. This option | |
13473 | is experimental. | |
13474 | ||
d77de738 | 13475 | @opindex floop-parallelize-all |
ddf6fe37 | 13476 | @item -floop-parallelize-all |
d77de738 ML |
13477 | Use the Graphite data dependence analysis to identify loops that can |
13478 | be parallelized. Parallelize all the loops that can be analyzed to | |
13479 | not contain loop carried dependences without checking that it is | |
13480 | profitable to parallelize the loops. | |
13481 | ||
d77de738 | 13482 | @opindex ftree-coalesce-vars |
ddf6fe37 | 13483 | @item -ftree-coalesce-vars |
d77de738 ML |
13484 | While transforming the program out of the SSA representation, attempt to |
13485 | reduce copying by coalescing versions of different user-defined | |
13486 | variables, instead of just compiler temporaries. This may severely | |
13487 | limit the ability to debug an optimized program compiled with | |
13488 | @option{-fno-var-tracking-assignments}. In the negated form, this flag | |
13489 | prevents SSA coalescing of user variables. This option is enabled by | |
13490 | default if optimization is enabled, and it does very little otherwise. | |
13491 | ||
d77de738 | 13492 | @opindex ftree-loop-if-convert |
ddf6fe37 | 13493 | @item -ftree-loop-if-convert |
d77de738 ML |
13494 | Attempt to transform conditional jumps in the innermost loops to |
13495 | branch-less equivalents. The intent is to remove control-flow from | |
13496 | the innermost loops in order to improve the ability of the | |
13497 | vectorization pass to handle these loops. This is enabled by default | |
13498 | if vectorization is enabled. | |
13499 | ||
d77de738 | 13500 | @opindex ftree-loop-distribution |
ddf6fe37 | 13501 | @item -ftree-loop-distribution |
d77de738 ML |
13502 | Perform loop distribution. This flag can improve cache performance on |
13503 | big loop bodies and allow further loop optimizations, like | |
13504 | parallelization or vectorization, to take place. For example, the loop | |
13505 | @smallexample | |
13506 | DO I = 1, N | |
13507 | A(I) = B(I) + C | |
13508 | D(I) = E(I) * F | |
13509 | ENDDO | |
13510 | @end smallexample | |
13511 | is transformed to | |
13512 | @smallexample | |
13513 | DO I = 1, N | |
13514 | A(I) = B(I) + C | |
13515 | ENDDO | |
13516 | DO I = 1, N | |
13517 | D(I) = E(I) * F | |
13518 | ENDDO | |
13519 | @end smallexample | |
13520 | This flag is enabled by default at @option{-O3}. | |
13521 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13522 | ||
d77de738 | 13523 | @opindex ftree-loop-distribute-patterns |
ddf6fe37 | 13524 | @item -ftree-loop-distribute-patterns |
d77de738 ML |
13525 | Perform loop distribution of patterns that can be code generated with |
13526 | calls to a library. This flag is enabled by default at @option{-O2} and | |
13527 | higher, and by @option{-fprofile-use} and @option{-fauto-profile}. | |
13528 | ||
13529 | This pass distributes the initialization loops and generates a call to | |
13530 | memset zero. For example, the loop | |
13531 | @smallexample | |
13532 | DO I = 1, N | |
13533 | A(I) = 0 | |
13534 | B(I) = A(I) + I | |
13535 | ENDDO | |
13536 | @end smallexample | |
13537 | is transformed to | |
13538 | @smallexample | |
13539 | DO I = 1, N | |
13540 | A(I) = 0 | |
13541 | ENDDO | |
13542 | DO I = 1, N | |
13543 | B(I) = A(I) + I | |
13544 | ENDDO | |
13545 | @end smallexample | |
13546 | and the initialization loop is transformed into a call to memset zero. | |
13547 | This flag is enabled by default at @option{-O3}. | |
13548 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13549 | ||
d77de738 | 13550 | @opindex floop-interchange |
ddf6fe37 | 13551 | @item -floop-interchange |
d77de738 ML |
13552 | Perform loop interchange outside of graphite. This flag can improve cache |
13553 | performance on loop nest and allow further loop optimizations, like | |
13554 | vectorization, to take place. For example, the loop | |
13555 | @smallexample | |
13556 | for (int i = 0; i < N; i++) | |
13557 | for (int j = 0; j < N; j++) | |
13558 | for (int k = 0; k < N; k++) | |
13559 | c[i][j] = c[i][j] + a[i][k]*b[k][j]; | |
13560 | @end smallexample | |
13561 | is transformed to | |
13562 | @smallexample | |
13563 | for (int i = 0; i < N; i++) | |
13564 | for (int k = 0; k < N; k++) | |
13565 | for (int j = 0; j < N; j++) | |
13566 | c[i][j] = c[i][j] + a[i][k]*b[k][j]; | |
13567 | @end smallexample | |
13568 | This flag is enabled by default at @option{-O3}. | |
13569 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13570 | ||
d77de738 | 13571 | @opindex floop-unroll-and-jam |
ddf6fe37 | 13572 | @item -floop-unroll-and-jam |
d77de738 ML |
13573 | Apply unroll and jam transformations on feasible loops. In a loop |
13574 | nest this unrolls the outer loop by some factor and fuses the resulting | |
13575 | multiple inner loops. This flag is enabled by default at @option{-O3}. | |
13576 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13577 | ||
d77de738 | 13578 | @opindex ftree-loop-im |
ddf6fe37 | 13579 | @item -ftree-loop-im |
d77de738 ML |
13580 | Perform loop invariant motion on trees. This pass moves only invariants that |
13581 | are hard to handle at RTL level (function calls, operations that expand to | |
13582 | nontrivial sequences of insns). With @option{-funswitch-loops} it also moves | |
13583 | operands of conditions that are invariant out of the loop, so that we can use | |
13584 | just trivial invariantness analysis in loop unswitching. The pass also includes | |
13585 | store motion. | |
13586 | ||
d77de738 | 13587 | @opindex ftree-loop-ivcanon |
ddf6fe37 | 13588 | @item -ftree-loop-ivcanon |
d77de738 ML |
13589 | Create a canonical counter for number of iterations in loops for which |
13590 | determining number of iterations requires complicated analysis. Later | |
13591 | optimizations then may determine the number easily. Useful especially | |
13592 | in connection with unrolling. | |
13593 | ||
d77de738 | 13594 | @opindex ftree-scev-cprop |
ddf6fe37 | 13595 | @item -ftree-scev-cprop |
d77de738 ML |
13596 | Perform final value replacement. If a variable is modified in a loop |
13597 | in such a way that its value when exiting the loop can be determined using | |
13598 | only its initial value and the number of loop iterations, replace uses of | |
13599 | the final value by such a computation, provided it is sufficiently cheap. | |
13600 | This reduces data dependencies and may allow further simplifications. | |
13601 | Enabled by default at @option{-O1} and higher. | |
13602 | ||
d77de738 | 13603 | @opindex fivopts |
ddf6fe37 | 13604 | @item -fivopts |
d77de738 ML |
13605 | Perform induction variable optimizations (strength reduction, induction |
13606 | variable merging and induction variable elimination) on trees. | |
13607 | ||
d77de738 | 13608 | @opindex ftree-parallelize-loops |
ddf6fe37 | 13609 | @item -ftree-parallelize-loops=n |
d77de738 ML |
13610 | Parallelize loops, i.e., split their iteration space to run in n threads. |
13611 | This is only possible for loops whose iterations are independent | |
13612 | and can be arbitrarily reordered. The optimization is only | |
13613 | profitable on multiprocessor machines, for loops that are CPU-intensive, | |
13614 | rather than constrained e.g.@: by memory bandwidth. This option | |
13615 | implies @option{-pthread}, and thus is only supported on targets | |
13616 | that have support for @option{-pthread}. | |
13617 | ||
d77de738 | 13618 | @opindex ftree-pta |
ddf6fe37 | 13619 | @item -ftree-pta |
d77de738 ML |
13620 | Perform function-local points-to analysis on trees. This flag is |
13621 | enabled by default at @option{-O1} and higher, except for @option{-Og}. | |
13622 | ||
d77de738 | 13623 | @opindex ftree-sra |
ddf6fe37 | 13624 | @item -ftree-sra |
d77de738 ML |
13625 | Perform scalar replacement of aggregates. This pass replaces structure |
13626 | references with scalars to prevent committing structures to memory too | |
13627 | early. This flag is enabled by default at @option{-O1} and higher, | |
13628 | except for @option{-Og}. | |
13629 | ||
d77de738 | 13630 | @opindex fstore-merging |
ddf6fe37 | 13631 | @item -fstore-merging |
d77de738 ML |
13632 | Perform merging of narrow stores to consecutive memory addresses. This pass |
13633 | merges contiguous stores of immediate values narrower than a word into fewer | |
13634 | wider stores to reduce the number of instructions. This is enabled by default | |
13635 | at @option{-O2} and higher as well as @option{-Os}. | |
13636 | ||
d77de738 | 13637 | @opindex ftree-ter |
ddf6fe37 | 13638 | @item -ftree-ter |
d77de738 ML |
13639 | Perform temporary expression replacement during the SSA->normal phase. Single |
13640 | use/single def temporaries are replaced at their use location with their | |
13641 | defining expression. This results in non-GIMPLE code, but gives the expanders | |
13642 | much more complex trees to work on resulting in better RTL generation. This is | |
13643 | enabled by default at @option{-O1} and higher. | |
13644 | ||
d77de738 | 13645 | @opindex ftree-slsr |
ddf6fe37 | 13646 | @item -ftree-slsr |
d77de738 ML |
13647 | Perform straight-line strength reduction on trees. This recognizes related |
13648 | expressions involving multiplications and replaces them by less expensive | |
13649 | calculations when possible. This is enabled by default at @option{-O1} and | |
13650 | higher. | |
13651 | ||
d77de738 | 13652 | @opindex ftree-vectorize |
ddf6fe37 | 13653 | @item -ftree-vectorize |
d77de738 ML |
13654 | Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize} |
13655 | and @option{-ftree-slp-vectorize} if not explicitly specified. | |
13656 | ||
d77de738 | 13657 | @opindex ftree-loop-vectorize |
ddf6fe37 | 13658 | @item -ftree-loop-vectorize |
d77de738 ML |
13659 | Perform loop vectorization on trees. This flag is enabled by default at |
13660 | @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use}, | |
13661 | and @option{-fauto-profile}. | |
13662 | ||
d77de738 | 13663 | @opindex ftree-slp-vectorize |
ddf6fe37 | 13664 | @item -ftree-slp-vectorize |
d77de738 ML |
13665 | Perform basic block vectorization on trees. This flag is enabled by default at |
13666 | @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use}, | |
13667 | and @option{-fauto-profile}. | |
13668 | ||
d77de738 | 13669 | @opindex ftrivial-auto-var-init |
ddf6fe37 | 13670 | @item -ftrivial-auto-var-init=@var{choice} |
d77de738 ML |
13671 | Initialize automatic variables with either a pattern or with zeroes to increase |
13672 | the security and predictability of a program by preventing uninitialized memory | |
13673 | disclosure and use. | |
13674 | GCC still considers an automatic variable that doesn't have an explicit | |
13675 | initializer as uninitialized, @option{-Wuninitialized} and | |
13676 | @option{-Wanalyzer-use-of-uninitialized-value} will still report | |
8f4634fb RB |
13677 | warning messages on such automatic variables and the compiler will |
13678 | perform optimization as if the variable were uninitialized. | |
d77de738 ML |
13679 | With this option, GCC will also initialize any padding of automatic variables |
13680 | that have structure or union types to zeroes. | |
13681 | However, the current implementation cannot initialize automatic variables that | |
13682 | are declared between the controlling expression and the first case of a | |
13683 | @code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all | |
13684 | such cases. | |
13685 | ||
13686 | The three values of @var{choice} are: | |
13687 | ||
13688 | @itemize @bullet | |
13689 | @item | |
13690 | @samp{uninitialized} doesn't initialize any automatic variables. | |
13691 | This is C and C++'s default. | |
13692 | ||
13693 | @item | |
13694 | @samp{pattern} Initialize automatic variables with values which will likely | |
13695 | transform logic bugs into crashes down the line, are easily recognized in a | |
13696 | crash dump and without being values that programmers can rely on for useful | |
13697 | program semantics. | |
13698 | The current value is byte-repeatable pattern with byte "0xFE". | |
13699 | The values used for pattern initialization might be changed in the future. | |
13700 | ||
13701 | @item | |
13702 | @samp{zero} Initialize automatic variables with zeroes. | |
13703 | @end itemize | |
13704 | ||
13705 | The default is @samp{uninitialized}. | |
13706 | ||
13707 | You can control this behavior for a specific variable by using the variable | |
13708 | attribute @code{uninitialized} (@pxref{Variable Attributes}). | |
13709 | ||
d77de738 | 13710 | @opindex fvect-cost-model |
ddf6fe37 | 13711 | @item -fvect-cost-model=@var{model} |
d77de738 ML |
13712 | Alter the cost model used for vectorization. The @var{model} argument |
13713 | should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or | |
13714 | @samp{very-cheap}. | |
13715 | With the @samp{unlimited} model the vectorized code-path is assumed | |
13716 | to be profitable while with the @samp{dynamic} model a runtime check | |
13717 | guards the vectorized code-path to enable it only for iteration | |
13718 | counts that will likely execute faster than when executing the original | |
13719 | scalar loop. The @samp{cheap} model disables vectorization of | |
13720 | loops where doing so would be cost prohibitive for example due to | |
13721 | required runtime checks for data dependence or alignment but otherwise | |
13722 | is equal to the @samp{dynamic} model. The @samp{very-cheap} model only | |
13723 | allows vectorization if the vector code would entirely replace the | |
13724 | scalar code that is being vectorized. For example, if each iteration | |
13725 | of a vectorized loop would only be able to handle exactly four iterations | |
13726 | of the scalar loop, the @samp{very-cheap} model would only allow | |
13727 | vectorization if the scalar iteration count is known to be a multiple | |
13728 | of four. | |
13729 | ||
13730 | The default cost model depends on other optimization flags and is | |
13731 | either @samp{dynamic} or @samp{cheap}. | |
13732 | ||
d77de738 | 13733 | @opindex fsimd-cost-model |
ddf6fe37 | 13734 | @item -fsimd-cost-model=@var{model} |
d77de738 ML |
13735 | Alter the cost model used for vectorization of loops marked with the OpenMP |
13736 | simd directive. The @var{model} argument should be one of | |
13737 | @samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model} | |
13738 | have the same meaning as described in @option{-fvect-cost-model} and by | |
13739 | default a cost model defined with @option{-fvect-cost-model} is used. | |
13740 | ||
d77de738 | 13741 | @opindex ftree-vrp |
ddf6fe37 | 13742 | @item -ftree-vrp |
d77de738 ML |
13743 | Perform Value Range Propagation on trees. This is similar to the |
13744 | constant propagation pass, but instead of values, ranges of values are | |
13745 | propagated. This allows the optimizers to remove unnecessary range | |
13746 | checks like array bound checks and null pointer checks. This is | |
13747 | enabled by default at @option{-O2} and higher. Null pointer check | |
13748 | elimination is only done if @option{-fdelete-null-pointer-checks} is | |
13749 | enabled. | |
13750 | ||
d77de738 | 13751 | @opindex fsplit-paths |
ddf6fe37 | 13752 | @item -fsplit-paths |
d77de738 ML |
13753 | Split paths leading to loop backedges. This can improve dead code |
13754 | elimination and common subexpression elimination. This is enabled by | |
13755 | default at @option{-O3} and above. | |
13756 | ||
d77de738 | 13757 | @opindex fsplit-ivs-in-unroller |
ddf6fe37 | 13758 | @item -fsplit-ivs-in-unroller |
d77de738 ML |
13759 | Enables expression of values of induction variables in later iterations |
13760 | of the unrolled loop using the value in the first iteration. This breaks | |
13761 | long dependency chains, thus improving efficiency of the scheduling passes. | |
13762 | ||
13763 | A combination of @option{-fweb} and CSE is often sufficient to obtain the | |
13764 | same effect. However, that is not reliable in cases where the loop body | |
13765 | is more complicated than a single basic block. It also does not work at all | |
13766 | on some architectures due to restrictions in the CSE pass. | |
13767 | ||
13768 | This optimization is enabled by default. | |
13769 | ||
d77de738 | 13770 | @opindex fvariable-expansion-in-unroller |
ddf6fe37 | 13771 | @item -fvariable-expansion-in-unroller |
d77de738 ML |
13772 | With this option, the compiler creates multiple copies of some |
13773 | local variables when unrolling a loop, which can result in superior code. | |
13774 | ||
13775 | This optimization is enabled by default for PowerPC targets, but disabled | |
13776 | by default otherwise. | |
13777 | ||
d77de738 | 13778 | @opindex fpartial-inlining |
ddf6fe37 | 13779 | @item -fpartial-inlining |
d77de738 ML |
13780 | Inline parts of functions. This option has any effect only |
13781 | when inlining itself is turned on by the @option{-finline-functions} | |
13782 | or @option{-finline-small-functions} options. | |
13783 | ||
13784 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13785 | ||
d77de738 | 13786 | @opindex fpredictive-commoning |
ddf6fe37 | 13787 | @item -fpredictive-commoning |
d77de738 ML |
13788 | Perform predictive commoning optimization, i.e., reusing computations |
13789 | (especially memory loads and stores) performed in previous | |
13790 | iterations of loops. | |
13791 | ||
13792 | This option is enabled at level @option{-O3}. | |
13793 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13794 | ||
d77de738 | 13795 | @opindex fprefetch-loop-arrays |
ddf6fe37 | 13796 | @item -fprefetch-loop-arrays |
d77de738 ML |
13797 | If supported by the target machine, generate instructions to prefetch |
13798 | memory to improve the performance of loops that access large arrays. | |
13799 | ||
13800 | This option may generate better or worse code; results are highly | |
13801 | dependent on the structure of loops within the source code. | |
13802 | ||
13803 | Disabled at level @option{-Os}. | |
13804 | ||
d77de738 ML |
13805 | @opindex fno-printf-return-value |
13806 | @opindex fprintf-return-value | |
ddf6fe37 | 13807 | @item -fno-printf-return-value |
d77de738 ML |
13808 | Do not substitute constants for known return value of formatted output |
13809 | functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and | |
13810 | @code{vsnprintf} (but not @code{printf} of @code{fprintf}). This | |
13811 | transformation allows GCC to optimize or even eliminate branches based | |
13812 | on the known return value of these functions called with arguments that | |
13813 | are either constant, or whose values are known to be in a range that | |
13814 | makes determining the exact return value possible. For example, when | |
13815 | @option{-fprintf-return-value} is in effect, both the branch and the | |
13816 | body of the @code{if} statement (but not the call to @code{snprint}) | |
13817 | can be optimized away when @code{i} is a 32-bit or smaller integer | |
13818 | because the return value is guaranteed to be at most 8. | |
13819 | ||
13820 | @smallexample | |
13821 | char buf[9]; | |
13822 | if (snprintf (buf, "%08x", i) >= sizeof buf) | |
13823 | @dots{} | |
13824 | @end smallexample | |
13825 | ||
13826 | The @option{-fprintf-return-value} option relies on other optimizations | |
13827 | and yields best results with @option{-O2} and above. It works in tandem | |
13828 | with the @option{-Wformat-overflow} and @option{-Wformat-truncation} | |
13829 | options. The @option{-fprintf-return-value} option is enabled by default. | |
13830 | ||
d77de738 ML |
13831 | @opindex fno-peephole |
13832 | @opindex fpeephole | |
13833 | @opindex fno-peephole2 | |
13834 | @opindex fpeephole2 | |
ddf6fe37 AA |
13835 | @item -fno-peephole |
13836 | @itemx -fno-peephole2 | |
d77de738 ML |
13837 | Disable any machine-specific peephole optimizations. The difference |
13838 | between @option{-fno-peephole} and @option{-fno-peephole2} is in how they | |
13839 | are implemented in the compiler; some targets use one, some use the | |
13840 | other, a few use both. | |
13841 | ||
13842 | @option{-fpeephole} is enabled by default. | |
13843 | @option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13844 | ||
d77de738 ML |
13845 | @opindex fno-guess-branch-probability |
13846 | @opindex fguess-branch-probability | |
ddf6fe37 | 13847 | @item -fno-guess-branch-probability |
d77de738 ML |
13848 | Do not guess branch probabilities using heuristics. |
13849 | ||
13850 | GCC uses heuristics to guess branch probabilities if they are | |
13851 | not provided by profiling feedback (@option{-fprofile-arcs}). These | |
13852 | heuristics are based on the control flow graph. If some branch probabilities | |
13853 | are specified by @code{__builtin_expect}, then the heuristics are | |
13854 | used to guess branch probabilities for the rest of the control flow graph, | |
13855 | taking the @code{__builtin_expect} info into account. The interactions | |
13856 | between the heuristics and @code{__builtin_expect} can be complex, and in | |
13857 | some cases, it may be useful to disable the heuristics so that the effects | |
13858 | of @code{__builtin_expect} are easier to understand. | |
13859 | ||
13860 | It is also possible to specify expected probability of the expression | |
13861 | with @code{__builtin_expect_with_probability} built-in function. | |
13862 | ||
13863 | The default is @option{-fguess-branch-probability} at levels | |
13864 | @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. | |
13865 | ||
d77de738 | 13866 | @opindex freorder-blocks |
ddf6fe37 | 13867 | @item -freorder-blocks |
d77de738 ML |
13868 | Reorder basic blocks in the compiled function in order to reduce number of |
13869 | taken branches and improve code locality. | |
13870 | ||
13871 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
13872 | ||
d77de738 | 13873 | @opindex freorder-blocks-algorithm |
ddf6fe37 | 13874 | @item -freorder-blocks-algorithm=@var{algorithm} |
d77de738 ML |
13875 | Use the specified algorithm for basic block reordering. The |
13876 | @var{algorithm} argument can be @samp{simple}, which does not increase | |
13877 | code size (except sometimes due to secondary effects like alignment), | |
13878 | or @samp{stc}, the ``software trace cache'' algorithm, which tries to | |
13879 | put all often executed code together, minimizing the number of branches | |
13880 | executed by making extra copies of code. | |
13881 | ||
13882 | The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and | |
13883 | @samp{stc} at levels @option{-O2}, @option{-O3}. | |
13884 | ||
d77de738 | 13885 | @opindex freorder-blocks-and-partition |
ddf6fe37 | 13886 | @item -freorder-blocks-and-partition |
d77de738 ML |
13887 | In addition to reordering basic blocks in the compiled function, in order |
13888 | to reduce number of taken branches, partitions hot and cold basic blocks | |
13889 | into separate sections of the assembly and @file{.o} files, to improve | |
13890 | paging and cache locality performance. | |
13891 | ||
13892 | This optimization is automatically turned off in the presence of | |
13893 | exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined | |
13894 | section attribute and on any architecture that does not support named | |
13895 | sections. When @option{-fsplit-stack} is used this option is not | |
13896 | enabled by default (to avoid linker errors), but may be enabled | |
13897 | explicitly (if using a working linker). | |
13898 | ||
13899 | Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13900 | ||
d77de738 | 13901 | @opindex freorder-functions |
ddf6fe37 | 13902 | @item -freorder-functions |
d77de738 ML |
13903 | Reorder functions in the object file in order to |
13904 | improve code locality. This is implemented by using special | |
13905 | subsections @code{.text.hot} for most frequently executed functions and | |
13906 | @code{.text.unlikely} for unlikely executed functions. Reordering is done by | |
13907 | the linker so object file format must support named sections and linker must | |
13908 | place them in a reasonable way. | |
13909 | ||
13910 | This option isn't effective unless you either provide profile feedback | |
13911 | (see @option{-fprofile-arcs} for details) or manually annotate functions with | |
13912 | @code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}). | |
13913 | ||
13914 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13915 | ||
d77de738 | 13916 | @opindex fstrict-aliasing |
ddf6fe37 | 13917 | @item -fstrict-aliasing |
d77de738 ML |
13918 | Allow the compiler to assume the strictest aliasing rules applicable to |
13919 | the language being compiled. For C (and C++), this activates | |
13920 | optimizations based on the type of expressions. In particular, an | |
13921 | object of one type is assumed never to reside at the same address as an | |
13922 | object of a different type, unless the types are almost the same. For | |
13923 | example, an @code{unsigned int} can alias an @code{int}, but not a | |
13924 | @code{void*} or a @code{double}. A character type may alias any other | |
13925 | type. | |
13926 | ||
13927 | @anchor{Type-punning}Pay special attention to code like this: | |
13928 | @smallexample | |
13929 | union a_union @{ | |
13930 | int i; | |
13931 | double d; | |
13932 | @}; | |
13933 | ||
13934 | int f() @{ | |
13935 | union a_union t; | |
13936 | t.d = 3.0; | |
13937 | return t.i; | |
13938 | @} | |
13939 | @end smallexample | |
13940 | The practice of reading from a different union member than the one most | |
13941 | recently written to (called ``type-punning'') is common. Even with | |
13942 | @option{-fstrict-aliasing}, type-punning is allowed, provided the memory | |
13943 | is accessed through the union type. So, the code above works as | |
13944 | expected. @xref{Structures unions enumerations and bit-fields | |
13945 | implementation}. However, this code might not: | |
13946 | @smallexample | |
13947 | int f() @{ | |
13948 | union a_union t; | |
13949 | int* ip; | |
13950 | t.d = 3.0; | |
13951 | ip = &t.i; | |
13952 | return *ip; | |
13953 | @} | |
13954 | @end smallexample | |
13955 | ||
13956 | Similarly, access by taking the address, casting the resulting pointer | |
13957 | and dereferencing the result has undefined behavior, even if the cast | |
13958 | uses a union type, e.g.: | |
13959 | @smallexample | |
13960 | int f() @{ | |
13961 | double d = 3.0; | |
13962 | return ((union a_union *) &d)->i; | |
13963 | @} | |
13964 | @end smallexample | |
13965 | ||
13966 | The @option{-fstrict-aliasing} option is enabled at levels | |
13967 | @option{-O2}, @option{-O3}, @option{-Os}. | |
13968 | ||
d77de738 | 13969 | @opindex fipa-strict-aliasing |
ddf6fe37 | 13970 | @item -fipa-strict-aliasing |
d77de738 ML |
13971 | Controls whether rules of @option{-fstrict-aliasing} are applied across |
13972 | function boundaries. Note that if multiple functions gets inlined into a | |
13973 | single function the memory accesses are no longer considered to be crossing a | |
13974 | function boundary. | |
13975 | ||
13976 | The @option{-fipa-strict-aliasing} option is enabled by default and is | |
13977 | effective only in combination with @option{-fstrict-aliasing}. | |
13978 | ||
ddf6fe37 | 13979 | @opindex falign-functions |
d77de738 ML |
13980 | @item -falign-functions |
13981 | @itemx -falign-functions=@var{n} | |
13982 | @itemx -falign-functions=@var{n}:@var{m} | |
13983 | @itemx -falign-functions=@var{n}:@var{m}:@var{n2} | |
13984 | @itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13985 | Align the start of functions to the next power-of-two greater than or |
13986 | equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at | |
13987 | least the first @var{m} bytes of the function can be fetched by the CPU | |
13988 | without crossing an @var{n}-byte alignment boundary. | |
13989 | ||
13990 | If @var{m} is not specified, it defaults to @var{n}. | |
13991 | ||
13992 | Examples: @option{-falign-functions=32} aligns functions to the next | |
13993 | 32-byte boundary, @option{-falign-functions=24} aligns to the next | |
13994 | 32-byte boundary only if this can be done by skipping 23 bytes or less, | |
13995 | @option{-falign-functions=32:7} aligns to the next | |
13996 | 32-byte boundary only if this can be done by skipping 6 bytes or less. | |
13997 | ||
13998 | The second pair of @var{n2}:@var{m2} values allows you to specify | |
13999 | a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to | |
14000 | the next 64-byte boundary if this can be done by skipping 6 bytes or less, | |
14001 | otherwise aligns to the next 32-byte boundary if this can be done | |
14002 | by skipping 2 bytes or less. | |
14003 | If @var{m2} is not specified, it defaults to @var{n2}. | |
14004 | ||
14005 | Some assemblers only support this flag when @var{n} is a power of two; | |
14006 | in that case, it is rounded up. | |
14007 | ||
14008 | @option{-fno-align-functions} and @option{-falign-functions=1} are | |
14009 | equivalent and mean that functions are not aligned. | |
14010 | ||
14011 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
14012 | The maximum allowed @var{n} option value is 65536. | |
14013 | ||
14014 | Enabled at levels @option{-O2}, @option{-O3}. | |
14015 | ||
14016 | @item -flimit-function-alignment | |
14017 | If this option is enabled, the compiler tries to avoid unnecessarily | |
14018 | overaligning functions. It attempts to instruct the assembler to align | |
14019 | by the amount specified by @option{-falign-functions}, but not to | |
14020 | skip more bytes than the size of the function. | |
14021 | ||
ddf6fe37 | 14022 | @opindex falign-labels |
d77de738 ML |
14023 | @item -falign-labels |
14024 | @itemx -falign-labels=@var{n} | |
14025 | @itemx -falign-labels=@var{n}:@var{m} | |
14026 | @itemx -falign-labels=@var{n}:@var{m}:@var{n2} | |
14027 | @itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
14028 | Align all branch targets to a power-of-two boundary. |
14029 | ||
14030 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
14031 | @option{-fno-align-labels} and @option{-falign-labels=1} are | |
14032 | equivalent and mean that labels are not aligned. | |
14033 | ||
14034 | If @option{-falign-loops} or @option{-falign-jumps} are applicable and | |
14035 | are greater than this value, then their values are used instead. | |
14036 | ||
14037 | If @var{n} is not specified or is zero, use a machine-dependent default | |
14038 | which is very likely to be @samp{1}, meaning no alignment. | |
14039 | The maximum allowed @var{n} option value is 65536. | |
14040 | ||
14041 | Enabled at levels @option{-O2}, @option{-O3}. | |
14042 | ||
ddf6fe37 | 14043 | @opindex falign-loops |
d77de738 ML |
14044 | @item -falign-loops |
14045 | @itemx -falign-loops=@var{n} | |
14046 | @itemx -falign-loops=@var{n}:@var{m} | |
14047 | @itemx -falign-loops=@var{n}:@var{m}:@var{n2} | |
14048 | @itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
14049 | Align loops to a power-of-two boundary. If the loops are executed |
14050 | many times, this makes up for any execution of the dummy padding | |
14051 | instructions. | |
14052 | ||
14053 | If @option{-falign-labels} is greater than this value, then its value | |
14054 | is used instead. | |
14055 | ||
14056 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
14057 | @option{-fno-align-loops} and @option{-falign-loops=1} are | |
14058 | equivalent and mean that loops are not aligned. | |
14059 | The maximum allowed @var{n} option value is 65536. | |
14060 | ||
14061 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
14062 | ||
14063 | Enabled at levels @option{-O2}, @option{-O3}. | |
14064 | ||
ddf6fe37 | 14065 | @opindex falign-jumps |
d77de738 ML |
14066 | @item -falign-jumps |
14067 | @itemx -falign-jumps=@var{n} | |
14068 | @itemx -falign-jumps=@var{n}:@var{m} | |
14069 | @itemx -falign-jumps=@var{n}:@var{m}:@var{n2} | |
14070 | @itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
14071 | Align branch targets to a power-of-two boundary, for branch targets |
14072 | where the targets can only be reached by jumping. In this case, | |
14073 | no dummy operations need be executed. | |
14074 | ||
14075 | If @option{-falign-labels} is greater than this value, then its value | |
14076 | is used instead. | |
14077 | ||
14078 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
14079 | @option{-fno-align-jumps} and @option{-falign-jumps=1} are | |
14080 | equivalent and mean that loops are not aligned. | |
14081 | ||
14082 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
14083 | The maximum allowed @var{n} option value is 65536. | |
14084 | ||
14085 | Enabled at levels @option{-O2}, @option{-O3}. | |
14086 | ||
d77de738 | 14087 | @opindex fno-allocation-dce |
ddf6fe37 | 14088 | @item -fno-allocation-dce |
d77de738 ML |
14089 | Do not remove unused C++ allocations in dead code elimination. |
14090 | ||
d77de738 | 14091 | @opindex fallow-store-data-races |
ddf6fe37 | 14092 | @item -fallow-store-data-races |
d77de738 ML |
14093 | Allow the compiler to perform optimizations that may introduce new data races |
14094 | on stores, without proving that the variable cannot be concurrently accessed | |
14095 | by other threads. Does not affect optimization of local data. It is safe to | |
14096 | use this option if it is known that global data will not be accessed by | |
14097 | multiple threads. | |
14098 | ||
14099 | Examples of optimizations enabled by @option{-fallow-store-data-races} include | |
14100 | hoisting or if-conversions that may cause a value that was already in memory | |
14101 | to be re-written with that same value. Such re-writing is safe in a single | |
14102 | threaded context but may be unsafe in a multi-threaded context. Note that on | |
14103 | some processors, if-conversions may be required in order to enable | |
14104 | vectorization. | |
14105 | ||
14106 | Enabled at level @option{-Ofast}. | |
14107 | ||
d77de738 | 14108 | @opindex funit-at-a-time |
ddf6fe37 | 14109 | @item -funit-at-a-time |
d77de738 ML |
14110 | This option is left for compatibility reasons. @option{-funit-at-a-time} |
14111 | has no effect, while @option{-fno-unit-at-a-time} implies | |
14112 | @option{-fno-toplevel-reorder} and @option{-fno-section-anchors}. | |
14113 | ||
14114 | Enabled by default. | |
14115 | ||
d77de738 ML |
14116 | @opindex fno-toplevel-reorder |
14117 | @opindex ftoplevel-reorder | |
ddf6fe37 | 14118 | @item -fno-toplevel-reorder |
d77de738 ML |
14119 | Do not reorder top-level functions, variables, and @code{asm} |
14120 | statements. Output them in the same order that they appear in the | |
14121 | input file. When this option is used, unreferenced static variables | |
14122 | are not removed. This option is intended to support existing code | |
14123 | that relies on a particular ordering. For new code, it is better to | |
14124 | use attributes when possible. | |
14125 | ||
14126 | @option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and | |
14127 | also at @option{-O0} if @option{-fsection-anchors} is explicitly requested. | |
14128 | Additionally @option{-fno-toplevel-reorder} implies | |
14129 | @option{-fno-section-anchors}. | |
14130 | ||
d77de738 | 14131 | @opindex funreachable-traps |
ddf6fe37 | 14132 | @item -funreachable-traps |
d77de738 ML |
14133 | With this option, the compiler turns calls to |
14134 | @code{__builtin_unreachable} into traps, instead of using them for | |
14135 | optimization. This also affects any such calls implicitly generated | |
14136 | by the compiler. | |
14137 | ||
14138 | This option has the same effect as @option{-fsanitize=unreachable | |
14139 | -fsanitize-trap=unreachable}, but does not affect the values of those | |
14140 | options. If @option{-fsanitize=unreachable} is enabled, that option | |
14141 | takes priority over this one. | |
14142 | ||
14143 | This option is enabled by default at @option{-O0} and @option{-Og}. | |
14144 | ||
d77de738 | 14145 | @opindex fweb |
ddf6fe37 | 14146 | @item -fweb |
d77de738 ML |
14147 | Constructs webs as commonly used for register allocation purposes and assign |
14148 | each web individual pseudo register. This allows the register allocation pass | |
14149 | to operate on pseudos directly, but also strengthens several other optimization | |
14150 | passes, such as CSE, loop optimizer and trivial dead code remover. It can, | |
14151 | however, make debugging impossible, since variables no longer stay in a | |
14152 | ``home register''. | |
14153 | ||
14154 | Enabled by default with @option{-funroll-loops}. | |
14155 | ||
d77de738 | 14156 | @opindex fwhole-program |
ddf6fe37 | 14157 | @item -fwhole-program |
d77de738 ML |
14158 | Assume that the current compilation unit represents the whole program being |
14159 | compiled. All public functions and variables with the exception of @code{main} | |
14160 | and those merged by attribute @code{externally_visible} become static functions | |
14161 | and in effect are optimized more aggressively by interprocedural optimizers. | |
14162 | ||
39ebd3a9 JH |
14163 | With @option{-flto} this option has a limited use. In most cases the |
14164 | precise list of symbols used or exported from the binary is known the | |
14165 | resolution info passed to the link-time optimizer by the linker plugin. It is | |
14166 | still useful if no linker plugin is used or during incremental link step when | |
14167 | final code is produced (with @option{-flto} | |
14168 | @option{-flinker-output=nolto-rel}). | |
d77de738 | 14169 | |
d77de738 | 14170 | @opindex flto |
ddf6fe37 | 14171 | @item -flto[=@var{n}] |
d77de738 ML |
14172 | This option runs the standard link-time optimizer. When invoked |
14173 | with source code, it generates GIMPLE (one of GCC's internal | |
14174 | representations) and writes it to special ELF sections in the object | |
14175 | file. When the object files are linked together, all the function | |
14176 | bodies are read from these ELF sections and instantiated as if they | |
14177 | had been part of the same translation unit. | |
14178 | ||
14179 | To use the link-time optimizer, @option{-flto} and optimization | |
14180 | options should be specified at compile time and during the final link. | |
14181 | It is recommended that you compile all the files participating in the | |
14182 | same link with the same options and also specify those options at | |
14183 | link time. | |
14184 | For example: | |
14185 | ||
14186 | @smallexample | |
14187 | gcc -c -O2 -flto foo.c | |
14188 | gcc -c -O2 -flto bar.c | |
14189 | gcc -o myprog -flto -O2 foo.o bar.o | |
14190 | @end smallexample | |
14191 | ||
14192 | The first two invocations to GCC save a bytecode representation | |
14193 | of GIMPLE into special ELF sections inside @file{foo.o} and | |
14194 | @file{bar.o}. The final invocation reads the GIMPLE bytecode from | |
14195 | @file{foo.o} and @file{bar.o}, merges the two files into a single | |
14196 | internal image, and compiles the result as usual. Since both | |
14197 | @file{foo.o} and @file{bar.o} are merged into a single image, this | |
14198 | causes all the interprocedural analyses and optimizations in GCC to | |
14199 | work across the two files as if they were a single one. This means, | |
14200 | for example, that the inliner is able to inline functions in | |
14201 | @file{bar.o} into functions in @file{foo.o} and vice-versa. | |
14202 | ||
14203 | Another (simpler) way to enable link-time optimization is: | |
14204 | ||
14205 | @smallexample | |
14206 | gcc -o myprog -flto -O2 foo.c bar.c | |
14207 | @end smallexample | |
14208 | ||
14209 | The above generates bytecode for @file{foo.c} and @file{bar.c}, | |
14210 | merges them together into a single GIMPLE representation and optimizes | |
14211 | them as usual to produce @file{myprog}. | |
14212 | ||
14213 | The important thing to keep in mind is that to enable link-time | |
14214 | optimizations you need to use the GCC driver to perform the link step. | |
14215 | GCC automatically performs link-time optimization if any of the | |
14216 | objects involved were compiled with the @option{-flto} command-line option. | |
14217 | You can always override | |
14218 | the automatic decision to do link-time optimization | |
14219 | by passing @option{-fno-lto} to the link command. | |
14220 | ||
14221 | To make whole program optimization effective, it is necessary to make | |
14222 | certain whole program assumptions. The compiler needs to know | |
14223 | what functions and variables can be accessed by libraries and runtime | |
14224 | outside of the link-time optimized unit. When supported by the linker, | |
14225 | the linker plugin (see @option{-fuse-linker-plugin}) passes information | |
14226 | to the compiler about used and externally visible symbols. When | |
14227 | the linker plugin is not available, @option{-fwhole-program} should be | |
14228 | used to allow the compiler to make these assumptions, which leads | |
14229 | to more aggressive optimization decisions. | |
14230 | ||
14231 | When a file is compiled with @option{-flto} without | |
14232 | @option{-fuse-linker-plugin}, the generated object file is larger than | |
14233 | a regular object file because it contains GIMPLE bytecodes and the usual | |
14234 | final code (see @option{-ffat-lto-objects}). This means that | |
14235 | object files with LTO information can be linked as normal object | |
14236 | files; if @option{-fno-lto} is passed to the linker, no | |
14237 | interprocedural optimizations are applied. Note that when | |
14238 | @option{-fno-fat-lto-objects} is enabled the compile stage is faster | |
14239 | but you cannot perform a regular, non-LTO link on them. | |
14240 | ||
14241 | When producing the final binary, GCC only | |
14242 | applies link-time optimizations to those files that contain bytecode. | |
14243 | Therefore, you can mix and match object files and libraries with | |
14244 | GIMPLE bytecodes and final object code. GCC automatically selects | |
14245 | which files to optimize in LTO mode and which files to link without | |
14246 | further processing. | |
14247 | ||
14248 | Generally, options specified at link time override those | |
14249 | specified at compile time, although in some cases GCC attempts to infer | |
14250 | link-time options from the settings used to compile the input files. | |
14251 | ||
14252 | If you do not specify an optimization level option @option{-O} at | |
14253 | link time, then GCC uses the highest optimization level | |
14254 | used when compiling the object files. Note that it is generally | |
14255 | ineffective to specify an optimization level option only at link time and | |
14256 | not at compile time, for two reasons. First, compiling without | |
14257 | optimization suppresses compiler passes that gather information | |
14258 | needed for effective optimization at link time. Second, some early | |
14259 | optimization passes can be performed only at compile time and | |
14260 | not at link time. | |
14261 | ||
14262 | There are some code generation flags preserved by GCC when | |
14263 | generating bytecodes, as they need to be used during the final link. | |
14264 | Currently, the following options and their settings are taken from | |
14265 | the first object file that explicitly specifies them: | |
14266 | @option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions}, | |
14267 | @option{-fgnu-tm} and all the @option{-m} target flags. | |
14268 | ||
14269 | The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and | |
14270 | @option{-fPIE} are combined based on the following scheme: | |
14271 | ||
14272 | @smallexample | |
14273 | @option{-fPIC} + @option{-fpic} = @option{-fpic} | |
14274 | @option{-fPIC} + @option{-fno-pic} = @option{-fno-pic} | |
14275 | @option{-fpic/-fPIC} + (no option) = (no option) | |
14276 | @option{-fPIC} + @option{-fPIE} = @option{-fPIE} | |
14277 | @option{-fpic} + @option{-fPIE} = @option{-fpie} | |
14278 | @option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie} | |
14279 | @end smallexample | |
14280 | ||
14281 | Certain ABI-changing flags are required to match in all compilation units, | |
14282 | and trying to override this at link time with a conflicting value | |
14283 | is ignored. This includes options such as @option{-freg-struct-return} | |
14284 | and @option{-fpcc-struct-return}. | |
14285 | ||
14286 | Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow}, | |
14287 | @option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing} | |
14288 | are passed through to the link stage and merged conservatively for | |
14289 | conflicting translation units. Specifically | |
14290 | @option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take | |
14291 | precedence; and for example @option{-ffp-contract=off} takes precedence | |
14292 | over @option{-ffp-contract=fast}. You can override them at link time. | |
14293 | ||
14294 | Diagnostic options such as @option{-Wstringop-overflow} are passed | |
14295 | through to the link stage and their setting matches that of the | |
14296 | compile-step at function granularity. Note that this matters only | |
14297 | for diagnostics emitted during optimization. Note that code | |
14298 | transforms such as inlining can lead to warnings being enabled | |
14299 | or disabled for regions if code not consistent with the setting | |
14300 | at compile time. | |
14301 | ||
14302 | When you need to pass options to the assembler via @option{-Wa} or | |
14303 | @option{-Xassembler} make sure to either compile such translation | |
14304 | units with @option{-fno-lto} or consistently use the same assembler | |
14305 | options on all translation units. You can alternatively also | |
14306 | specify assembler options at LTO link time. | |
14307 | ||
14308 | To enable debug info generation you need to supply @option{-g} at | |
14309 | compile time. If any of the input files at link time were built | |
14310 | with debug info generation enabled the link will enable debug info | |
14311 | generation as well. Any elaborate debug info settings | |
14312 | like the dwarf level @option{-gdwarf-5} need to be explicitly repeated | |
14313 | at the linker command line and mixing different settings in different | |
14314 | translation units is discouraged. | |
14315 | ||
14316 | If LTO encounters objects with C linkage declared with incompatible | |
14317 | types in separate translation units to be linked together (undefined | |
14318 | behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be | |
14319 | issued. The behavior is still undefined at run time. Similar | |
14320 | diagnostics may be raised for other languages. | |
14321 | ||
14322 | Another feature of LTO is that it is possible to apply interprocedural | |
14323 | optimizations on files written in different languages: | |
14324 | ||
14325 | @smallexample | |
14326 | gcc -c -flto foo.c | |
14327 | g++ -c -flto bar.cc | |
14328 | gfortran -c -flto baz.f90 | |
14329 | g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran | |
14330 | @end smallexample | |
14331 | ||
14332 | Notice that the final link is done with @command{g++} to get the C++ | |
14333 | runtime libraries and @option{-lgfortran} is added to get the Fortran | |
14334 | runtime libraries. In general, when mixing languages in LTO mode, you | |
14335 | should use the same link command options as when mixing languages in a | |
14336 | regular (non-LTO) compilation. | |
14337 | ||
14338 | If object files containing GIMPLE bytecode are stored in a library archive, say | |
14339 | @file{libfoo.a}, it is possible to extract and use them in an LTO link if you | |
14340 | are using a linker with plugin support. To create static libraries suitable | |
14341 | for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar} | |
14342 | and @command{ranlib}; | |
14343 | to show the symbols of object files with GIMPLE bytecode, use | |
14344 | @command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib} | |
14345 | and @command{nm} have been compiled with plugin support. At link time, use the | |
14346 | flag @option{-fuse-linker-plugin} to ensure that the library participates in | |
14347 | the LTO optimization process: | |
14348 | ||
14349 | @smallexample | |
14350 | gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo | |
14351 | @end smallexample | |
14352 | ||
14353 | With the linker plugin enabled, the linker extracts the needed | |
14354 | GIMPLE files from @file{libfoo.a} and passes them on to the running GCC | |
14355 | to make them part of the aggregated GIMPLE image to be optimized. | |
14356 | ||
14357 | If you are not using a linker with plugin support and/or do not | |
14358 | enable the linker plugin, then the objects inside @file{libfoo.a} | |
14359 | are extracted and linked as usual, but they do not participate | |
14360 | in the LTO optimization process. In order to make a static library suitable | |
14361 | for both LTO optimization and usual linkage, compile its object files with | |
14362 | @option{-flto} @option{-ffat-lto-objects}. | |
14363 | ||
14364 | Link-time optimizations do not require the presence of the whole program to | |
14365 | operate. If the program does not require any symbols to be exported, it is | |
14366 | possible to combine @option{-flto} and @option{-fwhole-program} to allow | |
14367 | the interprocedural optimizers to use more aggressive assumptions which may | |
14368 | lead to improved optimization opportunities. | |
14369 | Use of @option{-fwhole-program} is not needed when linker plugin is | |
14370 | active (see @option{-fuse-linker-plugin}). | |
14371 | ||
14372 | The current implementation of LTO makes no | |
14373 | attempt to generate bytecode that is portable between different | |
14374 | types of hosts. The bytecode files are versioned and there is a | |
14375 | strict version check, so bytecode files generated in one version of | |
14376 | GCC do not work with an older or newer version of GCC. | |
14377 | ||
14378 | Link-time optimization does not work well with generation of debugging | |
14379 | information on systems other than those using a combination of ELF and | |
14380 | DWARF. | |
14381 | ||
14382 | If you specify the optional @var{n}, the optimization and code | |
14383 | generation done at link time is executed in parallel using @var{n} | |
14384 | parallel jobs by utilizing an installed @command{make} program. The | |
14385 | environment variable @env{MAKE} may be used to override the program | |
14386 | used. | |
14387 | ||
14388 | You can also specify @option{-flto=jobserver} to use GNU make's | |
14389 | job server mode to determine the number of parallel jobs. This | |
14390 | is useful when the Makefile calling GCC is already executing in parallel. | |
14391 | You must prepend a @samp{+} to the command recipe in the parent Makefile | |
14392 | for this to work. This option likely only works if @env{MAKE} is | |
14393 | GNU make. Even without the option value, GCC tries to automatically | |
14394 | detect a running GNU make's job server. | |
14395 | ||
14396 | Use @option{-flto=auto} to use GNU make's job server, if available, | |
14397 | or otherwise fall back to autodetection of the number of CPU threads | |
14398 | present in your system. | |
14399 | ||
d77de738 | 14400 | @opindex flto-partition |
ddf6fe37 | 14401 | @item -flto-partition=@var{alg} |
d77de738 ML |
14402 | Specify the partitioning algorithm used by the link-time optimizer. |
14403 | The value is either @samp{1to1} to specify a partitioning mirroring | |
14404 | the original source files or @samp{balanced} to specify partitioning | |
14405 | into equally sized chunks (whenever possible) or @samp{max} to create | |
14406 | new partition for every symbol where possible. Specifying @samp{none} | |
14407 | as an algorithm disables partitioning and streaming completely. | |
14408 | The default value is @samp{balanced}. While @samp{1to1} can be used | |
14409 | as an workaround for various code ordering issues, the @samp{max} | |
14410 | partitioning is intended for internal testing only. | |
14411 | The value @samp{one} specifies that exactly one partition should be | |
14412 | used while the value @samp{none} bypasses partitioning and executes | |
14413 | the link-time optimization step directly from the WPA phase. | |
14414 | ||
d77de738 | 14415 | @opindex flto-compression-level |
ddf6fe37 | 14416 | @item -flto-compression-level=@var{n} |
d77de738 ML |
14417 | This option specifies the level of compression used for intermediate |
14418 | language written to LTO object files, and is only meaningful in | |
14419 | conjunction with LTO mode (@option{-flto}). GCC currently supports two | |
14420 | LTO compression algorithms. For zstd, valid values are 0 (no compression) | |
14421 | to 19 (maximum compression), while zlib supports values from 0 to 9. | |
14422 | Values outside this range are clamped to either minimum or maximum | |
14423 | of the supported values. If the option is not given, | |
14424 | a default balanced compression setting is used. | |
14425 | ||
d77de738 | 14426 | @opindex fuse-linker-plugin |
ddf6fe37 | 14427 | @item -fuse-linker-plugin |
d77de738 ML |
14428 | Enables the use of a linker plugin during link-time optimization. This |
14429 | option relies on plugin support in the linker, which is available in gold | |
14430 | or in GNU ld 2.21 or newer. | |
14431 | ||
14432 | This option enables the extraction of object files with GIMPLE bytecode out | |
14433 | of library archives. This improves the quality of optimization by exposing | |
14434 | more code to the link-time optimizer. This information specifies what | |
14435 | symbols can be accessed externally (by non-LTO object or during dynamic | |
14436 | linking). Resulting code quality improvements on binaries (and shared | |
14437 | libraries that use hidden visibility) are similar to @option{-fwhole-program}. | |
14438 | See @option{-flto} for a description of the effect of this flag and how to | |
14439 | use it. | |
14440 | ||
14441 | This option is enabled by default when LTO support in GCC is enabled | |
14442 | and GCC was configured for use with | |
14443 | a linker supporting plugins (GNU ld 2.21 or newer or gold). | |
14444 | ||
d77de738 | 14445 | @opindex ffat-lto-objects |
ddf6fe37 | 14446 | @item -ffat-lto-objects |
d77de738 ML |
14447 | Fat LTO objects are object files that contain both the intermediate language |
14448 | and the object code. This makes them usable for both LTO linking and normal | |
14449 | linking. This option is effective only when compiling with @option{-flto} | |
14450 | and is ignored at link time. | |
14451 | ||
14452 | @option{-fno-fat-lto-objects} improves compilation time over plain LTO, but | |
14453 | requires the complete toolchain to be aware of LTO. It requires a linker with | |
14454 | linker plugin support for basic functionality. Additionally, | |
14455 | @command{nm}, @command{ar} and @command{ranlib} | |
14456 | need to support linker plugins to allow a full-featured build environment | |
14457 | (capable of building static libraries etc). GCC provides the @command{gcc-ar}, | |
14458 | @command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options | |
14459 | to these tools. With non fat LTO makefiles need to be modified to use them. | |
14460 | ||
14461 | Note that modern binutils provide plugin auto-load mechanism. | |
14462 | Installing the linker plugin into @file{$libdir/bfd-plugins} has the same | |
14463 | effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and | |
14464 | @command{gcc-ranlib}). | |
14465 | ||
14466 | The default is @option{-fno-fat-lto-objects} on targets with linker plugin | |
14467 | support. | |
14468 | ||
d77de738 | 14469 | @opindex fcompare-elim |
ddf6fe37 | 14470 | @item -fcompare-elim |
d77de738 ML |
14471 | After register allocation and post-register allocation instruction splitting, |
14472 | identify arithmetic instructions that compute processor flags similar to a | |
14473 | comparison operation based on that arithmetic. If possible, eliminate the | |
14474 | explicit comparison operation. | |
14475 | ||
14476 | This pass only applies to certain targets that cannot explicitly represent | |
14477 | the comparison operation before register allocation is complete. | |
14478 | ||
14479 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
14480 | ||
04c9cf5c MT |
14481 | @opindex ffold-mem-offsets |
14482 | @item -ffold-mem-offsets | |
14483 | @itemx -fno-fold-mem-offsets | |
14484 | Try to eliminate add instructions by folding them in memory loads/stores. | |
14485 | ||
14486 | Enabled at levels @option{-O2}, @option{-O3}. | |
14487 | ||
d77de738 | 14488 | @opindex fcprop-registers |
ddf6fe37 | 14489 | @item -fcprop-registers |
d77de738 ML |
14490 | After register allocation and post-register allocation instruction splitting, |
14491 | perform a copy-propagation pass to try to reduce scheduling dependencies | |
14492 | and occasionally eliminate the copy. | |
14493 | ||
14494 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
14495 | ||
d77de738 | 14496 | @opindex fprofile-correction |
ddf6fe37 | 14497 | @item -fprofile-correction |
d77de738 ML |
14498 | Profiles collected using an instrumented binary for multi-threaded programs may |
14499 | be inconsistent due to missed counter updates. When this option is specified, | |
14500 | GCC uses heuristics to correct or smooth out such inconsistencies. By | |
14501 | default, GCC emits an error message when an inconsistent profile is detected. | |
14502 | ||
14503 | This option is enabled by @option{-fauto-profile}. | |
14504 | ||
d77de738 | 14505 | @opindex fprofile-partial-training |
ddf6fe37 | 14506 | @item -fprofile-partial-training |
d77de738 ML |
14507 | With @code{-fprofile-use} all portions of programs not executed during train |
14508 | run are optimized agressively for size rather than speed. In some cases it is | |
14509 | not practical to train all possible hot paths in the program. (For | |
14510 | example, program may contain functions specific for a given hardware and | |
14511 | trianing may not cover all hardware configurations program is run on.) With | |
14512 | @code{-fprofile-partial-training} profile feedback will be ignored for all | |
14513 | functions not executed during the train run leading them to be optimized as if | |
14514 | they were compiled without profile feedback. This leads to better performance | |
14515 | when train run is not representative but also leads to significantly bigger | |
14516 | code. | |
14517 | ||
ddf6fe37 | 14518 | @opindex fprofile-use |
d77de738 ML |
14519 | @item -fprofile-use |
14520 | @itemx -fprofile-use=@var{path} | |
d77de738 ML |
14521 | Enable profile feedback-directed optimizations, |
14522 | and the following optimizations, many of which | |
14523 | are generally profitable only with profile feedback available: | |
14524 | ||
43b72ede AA |
14525 | @gccoptlist{-fbranch-probabilities -fprofile-values |
14526 | -funroll-loops -fpeel-loops -ftracer -fvpt | |
14527 | -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp | |
14528 | -fpredictive-commoning -fsplit-loops -funswitch-loops | |
14529 | -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize | |
14530 | -fvect-cost-model=dynamic -ftree-loop-distribute-patterns | |
d77de738 ML |
14531 | -fprofile-reorder-functions} |
14532 | ||
14533 | Before you can use this option, you must first generate profiling information. | |
14534 | @xref{Instrumentation Options}, for information about the | |
14535 | @option{-fprofile-generate} option. | |
14536 | ||
14537 | By default, GCC emits an error message if the feedback profiles do not | |
14538 | match the source code. This error can be turned into a warning by using | |
14539 | @option{-Wno-error=coverage-mismatch}. Note this may result in poorly | |
14540 | optimized code. Additionally, by default, GCC also emits a warning message if | |
14541 | the feedback profiles do not exist (see @option{-Wmissing-profile}). | |
14542 | ||
14543 | If @var{path} is specified, GCC looks at the @var{path} to find | |
14544 | the profile feedback data files. See @option{-fprofile-dir}. | |
14545 | ||
ddf6fe37 | 14546 | @opindex fauto-profile |
d77de738 ML |
14547 | @item -fauto-profile |
14548 | @itemx -fauto-profile=@var{path} | |
d77de738 ML |
14549 | Enable sampling-based feedback-directed optimizations, |
14550 | and the following optimizations, | |
14551 | many of which are generally profitable only with profile feedback available: | |
14552 | ||
43b72ede AA |
14553 | @gccoptlist{-fbranch-probabilities -fprofile-values |
14554 | -funroll-loops -fpeel-loops -ftracer -fvpt | |
14555 | -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp | |
14556 | -fpredictive-commoning -fsplit-loops -funswitch-loops | |
14557 | -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize | |
14558 | -fvect-cost-model=dynamic -ftree-loop-distribute-patterns | |
d77de738 ML |
14559 | -fprofile-correction} |
14560 | ||
14561 | @var{path} is the name of a file containing AutoFDO profile information. | |
14562 | If omitted, it defaults to @file{fbdata.afdo} in the current directory. | |
14563 | ||
14564 | Producing an AutoFDO profile data file requires running your program | |
14565 | with the @command{perf} utility on a supported GNU/Linux target system. | |
14566 | For more information, see @uref{https://perf.wiki.kernel.org/}. | |
14567 | ||
14568 | E.g. | |
14569 | @smallexample | |
14570 | perf record -e br_inst_retired:near_taken -b -o perf.data \ | |
14571 | -- your_program | |
14572 | @end smallexample | |
14573 | ||
14574 | Then use the @command{create_gcov} tool to convert the raw profile data | |
14575 | to a format that can be used by GCC.@ You must also supply the | |
14576 | unstripped binary for your program to this tool. | |
14577 | See @uref{https://github.com/google/autofdo}. | |
14578 | ||
14579 | E.g. | |
14580 | @smallexample | |
14581 | create_gcov --binary=your_program.unstripped --profile=perf.data \ | |
14582 | --gcov=profile.afdo | |
14583 | @end smallexample | |
14584 | @end table | |
14585 | ||
14586 | The following options control compiler behavior regarding floating-point | |
14587 | arithmetic. These options trade off between speed and | |
14588 | correctness. All must be specifically enabled. | |
14589 | ||
14590 | @table @gcctabopt | |
d77de738 | 14591 | @opindex ffloat-store |
ddf6fe37 | 14592 | @item -ffloat-store |
d77de738 ML |
14593 | Do not store floating-point variables in registers, and inhibit other |
14594 | options that might change whether a floating-point value is taken from a | |
14595 | register or memory. | |
14596 | ||
14597 | @cindex floating-point precision | |
14598 | This option prevents undesirable excess precision on machines such as | |
14599 | the 68000 where the floating registers (of the 68881) keep more | |
14600 | precision than a @code{double} is supposed to have. Similarly for the | |
14601 | x86 architecture. For most programs, the excess precision does only | |
14602 | good, but a few programs rely on the precise definition of IEEE floating | |
14603 | point. Use @option{-ffloat-store} for such programs, after modifying | |
14604 | them to store all pertinent intermediate computations into variables. | |
14605 | ||
d77de738 | 14606 | @opindex fexcess-precision |
ddf6fe37 | 14607 | @item -fexcess-precision=@var{style} |
d77de738 ML |
14608 | This option allows further control over excess precision on machines |
14609 | where floating-point operations occur in a format with more precision or | |
14610 | range than the IEEE standard and interchange floating-point types. By | |
14611 | default, @option{-fexcess-precision=fast} is in effect; this means that | |
14612 | operations may be carried out in a wider precision than the types specified | |
14613 | in the source if that would result in faster code, and it is unpredictable | |
14614 | when rounding to the types specified in the source code takes place. | |
14615 | When compiling C or C++, if @option{-fexcess-precision=standard} is specified | |
14616 | then excess precision follows the rules specified in ISO C99 or C++; in particular, | |
14617 | both casts and assignments cause values to be rounded to their | |
14618 | semantic types (whereas @option{-ffloat-store} only affects | |
14619 | assignments). This option is enabled by default for C or C++ if a strict | |
14620 | conformance option such as @option{-std=c99} or @option{-std=c++17} is used. | |
14621 | @option{-ffast-math} enables @option{-fexcess-precision=fast} by default | |
14622 | regardless of whether a strict conformance option is used. | |
14623 | ||
14624 | @opindex mfpmath | |
14625 | @option{-fexcess-precision=standard} is not implemented for languages | |
14626 | other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse} | |
14627 | or @option{-mfpmath=sse+387} is specified; in the former case, IEEE | |
14628 | semantics apply without excess precision, and in the latter, rounding | |
14629 | is unpredictable. | |
14630 | ||
d77de738 | 14631 | @opindex ffast-math |
ddf6fe37 | 14632 | @item -ffast-math |
d77de738 ML |
14633 | Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, |
14634 | @option{-ffinite-math-only}, @option{-fno-rounding-math}, | |
14635 | @option{-fno-signaling-nans}, @option{-fcx-limited-range} and | |
14636 | @option{-fexcess-precision=fast}. | |
14637 | ||
14638 | This option causes the preprocessor macro @code{__FAST_MATH__} to be defined. | |
14639 | ||
14640 | This option is not turned on by any @option{-O} option besides | |
14641 | @option{-Ofast} since it can result in incorrect output for programs | |
14642 | that depend on an exact implementation of IEEE or ISO rules/specifications | |
14643 | for math functions. It may, however, yield faster code for programs | |
14644 | that do not require the guarantees of these specifications. | |
14645 | ||
d77de738 ML |
14646 | @opindex fno-math-errno |
14647 | @opindex fmath-errno | |
ddf6fe37 | 14648 | @item -fno-math-errno |
d77de738 ML |
14649 | Do not set @code{errno} after calling math functions that are executed |
14650 | with a single instruction, e.g., @code{sqrt}. A program that relies on | |
14651 | IEEE exceptions for math error handling may want to use this flag | |
14652 | for speed while maintaining IEEE arithmetic compatibility. | |
14653 | ||
14654 | This option is not turned on by any @option{-O} option since | |
14655 | it can result in incorrect output for programs that depend on | |
14656 | an exact implementation of IEEE or ISO rules/specifications for | |
14657 | math functions. It may, however, yield faster code for programs | |
14658 | that do not require the guarantees of these specifications. | |
14659 | ||
14660 | The default is @option{-fmath-errno}. | |
14661 | ||
14662 | On Darwin systems, the math library never sets @code{errno}. There is | |
14663 | therefore no reason for the compiler to consider the possibility that | |
14664 | it might, and @option{-fno-math-errno} is the default. | |
14665 | ||
d77de738 | 14666 | @opindex funsafe-math-optimizations |
ddf6fe37 | 14667 | @item -funsafe-math-optimizations |
d77de738 ML |
14668 | |
14669 | Allow optimizations for floating-point arithmetic that (a) assume | |
14670 | that arguments and results are valid and (b) may violate IEEE or | |
14671 | ANSI standards. When used at link time, it may include libraries | |
14672 | or startup files that change the default FPU control word or other | |
14673 | similar optimizations. | |
14674 | ||
14675 | This option is not turned on by any @option{-O} option since | |
14676 | it can result in incorrect output for programs that depend on | |
14677 | an exact implementation of IEEE or ISO rules/specifications for | |
14678 | math functions. It may, however, yield faster code for programs | |
14679 | that do not require the guarantees of these specifications. | |
14680 | Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math}, | |
14681 | @option{-fassociative-math} and @option{-freciprocal-math}. | |
14682 | ||
14683 | The default is @option{-fno-unsafe-math-optimizations}. | |
14684 | ||
d77de738 | 14685 | @opindex fassociative-math |
ddf6fe37 | 14686 | @item -fassociative-math |
d77de738 ML |
14687 | |
14688 | Allow re-association of operands in series of floating-point operations. | |
14689 | This violates the ISO C and C++ language standard by possibly changing | |
14690 | computation result. NOTE: re-ordering may change the sign of zero as | |
14691 | well as ignore NaNs and inhibit or create underflow or overflow (and | |
14692 | thus cannot be used on code that relies on rounding behavior like | |
14693 | @code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons | |
14694 | and thus may not be used when ordered comparisons are required. | |
14695 | This option requires that both @option{-fno-signed-zeros} and | |
14696 | @option{-fno-trapping-math} be in effect. Moreover, it doesn't make | |
14697 | much sense with @option{-frounding-math}. For Fortran the option | |
14698 | is automatically enabled when both @option{-fno-signed-zeros} and | |
14699 | @option{-fno-trapping-math} are in effect. | |
14700 | ||
14701 | The default is @option{-fno-associative-math}. | |
14702 | ||
d77de738 | 14703 | @opindex freciprocal-math |
ddf6fe37 | 14704 | @item -freciprocal-math |
d77de738 ML |
14705 | |
14706 | Allow the reciprocal of a value to be used instead of dividing by | |
14707 | the value if this enables optimizations. For example @code{x / y} | |
14708 | can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)} | |
14709 | is subject to common subexpression elimination. Note that this loses | |
14710 | precision and increases the number of flops operating on the value. | |
14711 | ||
14712 | The default is @option{-fno-reciprocal-math}. | |
14713 | ||
d77de738 | 14714 | @opindex ffinite-math-only |
ddf6fe37 | 14715 | @item -ffinite-math-only |
d77de738 ML |
14716 | Allow optimizations for floating-point arithmetic that assume |
14717 | that arguments and results are not NaNs or +-Infs. | |
14718 | ||
14719 | This option is not turned on by any @option{-O} option since | |
14720 | it can result in incorrect output for programs that depend on | |
14721 | an exact implementation of IEEE or ISO rules/specifications for | |
14722 | math functions. It may, however, yield faster code for programs | |
14723 | that do not require the guarantees of these specifications. | |
14724 | ||
14725 | The default is @option{-fno-finite-math-only}. | |
14726 | ||
d77de738 ML |
14727 | @opindex fno-signed-zeros |
14728 | @opindex fsigned-zeros | |
ddf6fe37 | 14729 | @item -fno-signed-zeros |
d77de738 ML |
14730 | Allow optimizations for floating-point arithmetic that ignore the |
14731 | signedness of zero. IEEE arithmetic specifies the behavior of | |
14732 | distinct +0.0 and @minus{}0.0 values, which then prohibits simplification | |
14733 | of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}). | |
14734 | This option implies that the sign of a zero result isn't significant. | |
14735 | ||
14736 | The default is @option{-fsigned-zeros}. | |
14737 | ||
d77de738 ML |
14738 | @opindex fno-trapping-math |
14739 | @opindex ftrapping-math | |
ddf6fe37 | 14740 | @item -fno-trapping-math |
d77de738 ML |
14741 | Compile code assuming that floating-point operations cannot generate |
14742 | user-visible traps. These traps include division by zero, overflow, | |
14743 | underflow, inexact result and invalid operation. This option requires | |
14744 | that @option{-fno-signaling-nans} be in effect. Setting this option may | |
14745 | allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example. | |
14746 | ||
14747 | This option should never be turned on by any @option{-O} option since | |
14748 | it can result in incorrect output for programs that depend on | |
14749 | an exact implementation of IEEE or ISO rules/specifications for | |
14750 | math functions. | |
14751 | ||
14752 | The default is @option{-ftrapping-math}. | |
14753 | ||
14754 | Future versions of GCC may provide finer control of this setting | |
14755 | using C99's @code{FENV_ACCESS} pragma. This command-line option | |
14756 | will be used along with @option{-frounding-math} to specify the | |
14757 | default state for @code{FENV_ACCESS}. | |
14758 | ||
d77de738 | 14759 | @opindex frounding-math |
ddf6fe37 | 14760 | @item -frounding-math |
d77de738 ML |
14761 | Disable transformations and optimizations that assume default floating-point |
14762 | rounding behavior. This is round-to-zero for all floating point | |
14763 | to integer conversions, and round-to-nearest for all other arithmetic | |
14764 | truncations. This option should be specified for programs that change | |
14765 | the FP rounding mode dynamically, or that may be executed with a | |
14766 | non-default rounding mode. This option disables constant folding of | |
14767 | floating-point expressions at compile time (which may be affected by | |
14768 | rounding mode) and arithmetic transformations that are unsafe in the | |
14769 | presence of sign-dependent rounding modes. | |
14770 | ||
14771 | The default is @option{-fno-rounding-math}. | |
14772 | ||
14773 | This option is experimental and does not currently guarantee to | |
14774 | disable all GCC optimizations that are affected by rounding mode. | |
14775 | Future versions of GCC may provide finer control of this setting | |
14776 | using C99's @code{FENV_ACCESS} pragma. This command-line option | |
14777 | will be used along with @option{-ftrapping-math} to specify the | |
14778 | default state for @code{FENV_ACCESS}. | |
14779 | ||
d77de738 | 14780 | @opindex fsignaling-nans |
ddf6fe37 | 14781 | @item -fsignaling-nans |
d77de738 ML |
14782 | Compile code assuming that IEEE signaling NaNs may generate user-visible |
14783 | traps during floating-point operations. Setting this option disables | |
14784 | optimizations that may change the number of exceptions visible with | |
14785 | signaling NaNs. This option implies @option{-ftrapping-math}. | |
14786 | ||
14787 | This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to | |
14788 | be defined. | |
14789 | ||
14790 | The default is @option{-fno-signaling-nans}. | |
14791 | ||
14792 | This option is experimental and does not currently guarantee to | |
14793 | disable all GCC optimizations that affect signaling NaN behavior. | |
14794 | ||
d77de738 ML |
14795 | @opindex fno-fp-int-builtin-inexact |
14796 | @opindex ffp-int-builtin-inexact | |
ddf6fe37 | 14797 | @item -fno-fp-int-builtin-inexact |
d77de738 ML |
14798 | Do not allow the built-in functions @code{ceil}, @code{floor}, |
14799 | @code{round} and @code{trunc}, and their @code{float} and @code{long | |
14800 | double} variants, to generate code that raises the ``inexact'' | |
14801 | floating-point exception for noninteger arguments. ISO C99 and C11 | |
14802 | allow these functions to raise the ``inexact'' exception, but ISO/IEC | |
14803 | TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into | |
094a609c | 14804 | ISO C23, does not allow these functions to do so. |
d77de738 ML |
14805 | |
14806 | The default is @option{-ffp-int-builtin-inexact}, allowing the | |
094a609c | 14807 | exception to be raised, unless C23 or a later C standard is selected. |
d77de738 ML |
14808 | This option does nothing unless @option{-ftrapping-math} is in effect. |
14809 | ||
14810 | Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions | |
14811 | generate a call to a library function then the ``inexact'' exception | |
14812 | may be raised if the library implementation does not follow TS 18661. | |
14813 | ||
d77de738 | 14814 | @opindex fsingle-precision-constant |
ddf6fe37 | 14815 | @item -fsingle-precision-constant |
d77de738 ML |
14816 | Treat floating-point constants as single precision instead of |
14817 | implicitly converting them to double-precision constants. | |
14818 | ||
d77de738 | 14819 | @opindex fcx-limited-range |
ddf6fe37 | 14820 | @item -fcx-limited-range |
d77de738 ML |
14821 | When enabled, this option states that a range reduction step is not |
14822 | needed when performing complex division. Also, there is no checking | |
14823 | whether the result of a complex multiplication or division is @code{NaN | |
14824 | + I*NaN}, with an attempt to rescue the situation in that case. The | |
14825 | default is @option{-fno-cx-limited-range}, but is enabled by | |
14826 | @option{-ffast-math}. | |
14827 | ||
14828 | This option controls the default setting of the ISO C99 | |
14829 | @code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to | |
14830 | all languages. | |
14831 | ||
d77de738 | 14832 | @opindex fcx-fortran-rules |
ddf6fe37 | 14833 | @item -fcx-fortran-rules |
d77de738 ML |
14834 | Complex multiplication and division follow Fortran rules. Range |
14835 | reduction is done as part of complex division, but there is no checking | |
14836 | whether the result of a complex multiplication or division is @code{NaN | |
14837 | + I*NaN}, with an attempt to rescue the situation in that case. | |
14838 | ||
14839 | The default is @option{-fno-cx-fortran-rules}. | |
14840 | ||
14841 | @end table | |
14842 | ||
14843 | The following options control optimizations that may improve | |
14844 | performance, but are not enabled by any @option{-O} options. This | |
14845 | section includes experimental options that may produce broken code. | |
14846 | ||
14847 | @table @gcctabopt | |
d77de738 | 14848 | @opindex fbranch-probabilities |
ddf6fe37 | 14849 | @item -fbranch-probabilities |
d77de738 ML |
14850 | After running a program compiled with @option{-fprofile-arcs} |
14851 | (@pxref{Instrumentation Options}), | |
14852 | you can compile it a second time using | |
14853 | @option{-fbranch-probabilities}, to improve optimizations based on | |
14854 | the number of times each branch was taken. When a program | |
14855 | compiled with @option{-fprofile-arcs} exits, it saves arc execution | |
14856 | counts to a file called @file{@var{sourcename}.gcda} for each source | |
14857 | file. The information in this data file is very dependent on the | |
14858 | structure of the generated code, so you must use the same source code | |
14859 | and the same optimization options for both compilations. | |
14860 | See details about the file naming in @option{-fprofile-arcs}. | |
14861 | ||
14862 | With @option{-fbranch-probabilities}, GCC puts a | |
14863 | @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}. | |
14864 | These can be used to improve optimization. Currently, they are only | |
14865 | used in one place: in @file{reorg.cc}, instead of guessing which path a | |
14866 | branch is most likely to take, the @samp{REG_BR_PROB} values are used to | |
14867 | exactly determine which path is taken more often. | |
14868 | ||
14869 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14870 | ||
d77de738 | 14871 | @opindex fprofile-values |
ddf6fe37 | 14872 | @item -fprofile-values |
d77de738 ML |
14873 | If combined with @option{-fprofile-arcs}, it adds code so that some |
14874 | data about values of expressions in the program is gathered. | |
14875 | ||
14876 | With @option{-fbranch-probabilities}, it reads back the data gathered | |
14877 | from profiling values of expressions for usage in optimizations. | |
14878 | ||
14879 | Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and | |
14880 | @option{-fauto-profile}. | |
14881 | ||
d77de738 | 14882 | @opindex fprofile-reorder-functions |
ddf6fe37 | 14883 | @item -fprofile-reorder-functions |
d77de738 ML |
14884 | Function reordering based on profile instrumentation collects |
14885 | first time of execution of a function and orders these functions | |
14886 | in ascending order. | |
14887 | ||
14888 | Enabled with @option{-fprofile-use}. | |
14889 | ||
d77de738 | 14890 | @opindex fvpt |
ddf6fe37 | 14891 | @item -fvpt |
d77de738 ML |
14892 | If combined with @option{-fprofile-arcs}, this option instructs the compiler |
14893 | to add code to gather information about values of expressions. | |
14894 | ||
14895 | With @option{-fbranch-probabilities}, it reads back the data gathered | |
14896 | and actually performs the optimizations based on them. | |
14897 | Currently the optimizations include specialization of division operations | |
14898 | using the knowledge about the value of the denominator. | |
14899 | ||
14900 | Enabled with @option{-fprofile-use} and @option{-fauto-profile}. | |
14901 | ||
d77de738 | 14902 | @opindex frename-registers |
ddf6fe37 | 14903 | @item -frename-registers |
d77de738 ML |
14904 | Attempt to avoid false dependencies in scheduled code by making use |
14905 | of registers left over after register allocation. This optimization | |
14906 | most benefits processors with lots of registers. Depending on the | |
14907 | debug information format adopted by the target, however, it can | |
14908 | make debugging impossible, since variables no longer stay in | |
14909 | a ``home register''. | |
14910 | ||
14911 | Enabled by default with @option{-funroll-loops}. | |
14912 | ||
d77de738 | 14913 | @opindex fschedule-fusion |
ddf6fe37 | 14914 | @item -fschedule-fusion |
d77de738 ML |
14915 | Performs a target dependent pass over the instruction stream to schedule |
14916 | instructions of same type together because target machine can execute them | |
14917 | more efficiently if they are adjacent to each other in the instruction flow. | |
14918 | ||
14919 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
14920 | ||
d77de738 | 14921 | @opindex ftracer |
ddf6fe37 | 14922 | @item -ftracer |
d77de738 ML |
14923 | Perform tail duplication to enlarge superblock size. This transformation |
14924 | simplifies the control flow of the function allowing other optimizations to do | |
14925 | a better job. | |
14926 | ||
14927 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14928 | ||
d77de738 | 14929 | @opindex funroll-loops |
ddf6fe37 | 14930 | @item -funroll-loops |
d77de738 ML |
14931 | Unroll loops whose number of iterations can be determined at compile time or |
14932 | upon entry to the loop. @option{-funroll-loops} implies | |
14933 | @option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}. | |
14934 | It also turns on complete loop peeling (i.e.@: complete removal of loops with | |
14935 | a small constant number of iterations). This option makes code larger, and may | |
14936 | or may not make it run faster. | |
14937 | ||
14938 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14939 | ||
d77de738 | 14940 | @opindex funroll-all-loops |
ddf6fe37 | 14941 | @item -funroll-all-loops |
d77de738 ML |
14942 | Unroll all loops, even if their number of iterations is uncertain when |
14943 | the loop is entered. This usually makes programs run more slowly. | |
14944 | @option{-funroll-all-loops} implies the same options as | |
14945 | @option{-funroll-loops}. | |
14946 | ||
d77de738 | 14947 | @opindex fpeel-loops |
ddf6fe37 | 14948 | @item -fpeel-loops |
d77de738 ML |
14949 | Peels loops for which there is enough information that they do not |
14950 | roll much (from profile feedback or static analysis). It also turns on | |
14951 | complete loop peeling (i.e.@: complete removal of loops with small constant | |
14952 | number of iterations). | |
14953 | ||
14954 | Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}. | |
14955 | ||
d77de738 | 14956 | @opindex fmove-loop-invariants |
ddf6fe37 | 14957 | @item -fmove-loop-invariants |
d77de738 ML |
14958 | Enables the loop invariant motion pass in the RTL loop optimizer. Enabled |
14959 | at level @option{-O1} and higher, except for @option{-Og}. | |
14960 | ||
d77de738 | 14961 | @opindex fmove-loop-stores |
ddf6fe37 | 14962 | @item -fmove-loop-stores |
d77de738 ML |
14963 | Enables the loop store motion pass in the GIMPLE loop optimizer. This |
14964 | moves invariant stores to after the end of the loop in exchange for | |
14965 | carrying the stored value in a register across the iteration. | |
14966 | Note for this option to have an effect @option{-ftree-loop-im} has to | |
14967 | be enabled as well. Enabled at level @option{-O1} and higher, except | |
14968 | for @option{-Og}. | |
14969 | ||
d77de738 | 14970 | @opindex fsplit-loops |
ddf6fe37 | 14971 | @item -fsplit-loops |
d77de738 ML |
14972 | Split a loop into two if it contains a condition that's always true |
14973 | for one side of the iteration space and false for the other. | |
14974 | ||
14975 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14976 | ||
d77de738 | 14977 | @opindex funswitch-loops |
ddf6fe37 | 14978 | @item -funswitch-loops |
d77de738 ML |
14979 | Move branches with loop invariant conditions out of the loop, with duplicates |
14980 | of the loop on both branches (modified according to result of the condition). | |
14981 | ||
14982 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14983 | ||
d77de738 | 14984 | @opindex fversion-loops-for-strides |
ddf6fe37 | 14985 | @item -fversion-loops-for-strides |
d77de738 ML |
14986 | If a loop iterates over an array with a variable stride, create another |
14987 | version of the loop that assumes the stride is always one. For example: | |
14988 | ||
14989 | @smallexample | |
14990 | for (int i = 0; i < n; ++i) | |
14991 | x[i * stride] = @dots{}; | |
14992 | @end smallexample | |
14993 | ||
14994 | becomes: | |
14995 | ||
14996 | @smallexample | |
14997 | if (stride == 1) | |
14998 | for (int i = 0; i < n; ++i) | |
14999 | x[i] = @dots{}; | |
15000 | else | |
15001 | for (int i = 0; i < n; ++i) | |
15002 | x[i * stride] = @dots{}; | |
15003 | @end smallexample | |
15004 | ||
15005 | This is particularly useful for assumed-shape arrays in Fortran where | |
15006 | (for example) it allows better vectorization assuming contiguous accesses. | |
15007 | This flag is enabled by default at @option{-O3}. | |
15008 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
15009 | ||
d77de738 ML |
15010 | @opindex ffunction-sections |
15011 | @opindex fdata-sections | |
ddf6fe37 AA |
15012 | @item -ffunction-sections |
15013 | @itemx -fdata-sections | |
d77de738 ML |
15014 | Place each function or data item into its own section in the output |
15015 | file if the target supports arbitrary sections. The name of the | |
15016 | function or the name of the data item determines the section's name | |
15017 | in the output file. | |
15018 | ||
15019 | Use these options on systems where the linker can perform optimizations to | |
15020 | improve locality of reference in the instruction space. Most systems using the | |
15021 | ELF object format have linkers with such optimizations. On AIX, the linker | |
15022 | rearranges sections (CSECTs) based on the call graph. The performance impact | |
15023 | varies. | |
15024 | ||
15025 | Together with a linker garbage collection (linker @option{--gc-sections} | |
15026 | option) these options may lead to smaller statically-linked executables (after | |
15027 | stripping). | |
15028 | ||
15029 | On ELF/DWARF systems these options do not degenerate the quality of the debug | |
15030 | information. There could be issues with other object files/debug info formats. | |
15031 | ||
15032 | Only use these options when there are significant benefits from doing so. When | |
15033 | you specify these options, the assembler and linker create larger object and | |
15034 | executable files and are also slower. These options affect code generation. | |
15035 | They prevent optimizations by the compiler and assembler using relative | |
15036 | locations inside a translation unit since the locations are unknown until | |
15037 | link time. An example of such an optimization is relaxing calls to short call | |
15038 | instructions. | |
15039 | ||
d77de738 | 15040 | @opindex fstdarg-opt |
ddf6fe37 | 15041 | @item -fstdarg-opt |
d77de738 ML |
15042 | Optimize the prologue of variadic argument functions with respect to usage of |
15043 | those arguments. | |
15044 | ||
d77de738 | 15045 | @opindex fsection-anchors |
ddf6fe37 | 15046 | @item -fsection-anchors |
d77de738 ML |
15047 | Try to reduce the number of symbolic address calculations by using |
15048 | shared ``anchor'' symbols to address nearby objects. This transformation | |
15049 | can help to reduce the number of GOT entries and GOT accesses on some | |
15050 | targets. | |
15051 | ||
15052 | For example, the implementation of the following function @code{foo}: | |
15053 | ||
15054 | @smallexample | |
15055 | static int a, b, c; | |
15056 | int foo (void) @{ return a + b + c; @} | |
15057 | @end smallexample | |
15058 | ||
15059 | @noindent | |
15060 | usually calculates the addresses of all three variables, but if you | |
15061 | compile it with @option{-fsection-anchors}, it accesses the variables | |
15062 | from a common anchor point instead. The effect is similar to the | |
15063 | following pseudocode (which isn't valid C): | |
15064 | ||
15065 | @smallexample | |
15066 | int foo (void) | |
15067 | @{ | |
15068 | register int *xr = &x; | |
15069 | return xr[&a - &x] + xr[&b - &x] + xr[&c - &x]; | |
15070 | @} | |
15071 | @end smallexample | |
15072 | ||
15073 | Not all targets support this option. | |
15074 | ||
d77de738 | 15075 | @opindex fzero-call-used-regs |
ddf6fe37 | 15076 | @item -fzero-call-used-regs=@var{choice} |
d77de738 ML |
15077 | Zero call-used registers at function return to increase program |
15078 | security by either mitigating Return-Oriented Programming (ROP) | |
15079 | attacks or preventing information leakage through registers. | |
15080 | ||
15081 | The possible values of @var{choice} are the same as for the | |
15082 | @code{zero_call_used_regs} attribute (@pxref{Function Attributes}). | |
15083 | The default is @samp{skip}. | |
15084 | ||
15085 | You can control this behavior for a specific function by using the function | |
15086 | attribute @code{zero_call_used_regs} (@pxref{Function Attributes}). | |
15087 | ||
d77de738 | 15088 | @opindex param |
ddf6fe37 | 15089 | @item --param @var{name}=@var{value} |
d77de738 ML |
15090 | In some places, GCC uses various constants to control the amount of |
15091 | optimization that is done. For example, GCC does not inline functions | |
15092 | that contain more than a certain number of instructions. You can | |
15093 | control some of these constants on the command line using the | |
15094 | @option{--param} option. | |
15095 | ||
15096 | The names of specific parameters, and the meaning of the values, are | |
15097 | tied to the internals of the compiler, and are subject to change | |
15098 | without notice in future releases. | |
15099 | ||
c381327d GP |
15100 | In order to get the minimal, maximal and default values of a parameter, |
15101 | use the @option{--help=param -Q} options. | |
d77de738 ML |
15102 | |
15103 | In each case, the @var{value} is an integer. The following choices | |
15104 | of @var{name} are recognized for all targets: | |
15105 | ||
15106 | @table @gcctabopt | |
15107 | @item predictable-branch-outcome | |
15108 | When branch is predicted to be taken with probability lower than this threshold | |
15109 | (in percent), then it is considered well predictable. | |
15110 | ||
15111 | @item max-rtl-if-conversion-insns | |
15112 | RTL if-conversion tries to remove conditional branches around a block and | |
15113 | replace them with conditionally executed instructions. This parameter | |
15114 | gives the maximum number of instructions in a block which should be | |
15115 | considered for if-conversion. The compiler will | |
15116 | also use other heuristics to decide whether if-conversion is likely to be | |
15117 | profitable. | |
15118 | ||
15119 | @item max-rtl-if-conversion-predictable-cost | |
15120 | RTL if-conversion will try to remove conditional branches around a block | |
15121 | and replace them with conditionally executed instructions. These parameters | |
15122 | give the maximum permissible cost for the sequence that would be generated | |
15123 | by if-conversion depending on whether the branch is statically determined | |
15124 | to be predictable or not. The units for this parameter are the same as | |
15125 | those for the GCC internal seq_cost metric. The compiler will try to | |
15126 | provide a reasonable default for this parameter using the BRANCH_COST | |
15127 | target macro. | |
15128 | ||
15129 | @item max-crossjump-edges | |
15130 | The maximum number of incoming edges to consider for cross-jumping. | |
15131 | The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in | |
15132 | the number of edges incoming to each block. Increasing values mean | |
15133 | more aggressive optimization, making the compilation time increase with | |
15134 | probably small improvement in executable size. | |
15135 | ||
15136 | @item min-crossjump-insns | |
15137 | The minimum number of instructions that must be matched at the end | |
15138 | of two blocks before cross-jumping is performed on them. This | |
15139 | value is ignored in the case where all instructions in the block being | |
15140 | cross-jumped from are matched. | |
15141 | ||
15142 | @item max-grow-copy-bb-insns | |
15143 | The maximum code size expansion factor when copying basic blocks | |
15144 | instead of jumping. The expansion is relative to a jump instruction. | |
15145 | ||
15146 | @item max-goto-duplication-insns | |
15147 | The maximum number of instructions to duplicate to a block that jumps | |
15148 | to a computed goto. To avoid @math{O(N^2)} behavior in a number of | |
15149 | passes, GCC factors computed gotos early in the compilation process, | |
15150 | and unfactors them as late as possible. Only computed jumps at the | |
15151 | end of a basic blocks with no more than max-goto-duplication-insns are | |
15152 | unfactored. | |
15153 | ||
15154 | @item max-delay-slot-insn-search | |
15155 | The maximum number of instructions to consider when looking for an | |
15156 | instruction to fill a delay slot. If more than this arbitrary number of | |
15157 | instructions are searched, the time savings from filling the delay slot | |
15158 | are minimal, so stop searching. Increasing values mean more | |
15159 | aggressive optimization, making the compilation time increase with probably | |
15160 | small improvement in execution time. | |
15161 | ||
15162 | @item max-delay-slot-live-search | |
15163 | When trying to fill delay slots, the maximum number of instructions to | |
15164 | consider when searching for a block with valid live register | |
15165 | information. Increasing this arbitrarily chosen value means more | |
15166 | aggressive optimization, increasing the compilation time. This parameter | |
15167 | should be removed when the delay slot code is rewritten to maintain the | |
15168 | control-flow graph. | |
15169 | ||
15170 | @item max-gcse-memory | |
15171 | The approximate maximum amount of memory in @code{kB} that can be allocated in | |
15172 | order to perform the global common subexpression elimination | |
15173 | optimization. If more memory than specified is required, the | |
15174 | optimization is not done. | |
15175 | ||
15176 | @item max-gcse-insertion-ratio | |
15177 | If the ratio of expression insertions to deletions is larger than this value | |
15178 | for any expression, then RTL PRE inserts or removes the expression and thus | |
15179 | leaves partially redundant computations in the instruction stream. | |
15180 | ||
15181 | @item max-pending-list-length | |
15182 | The maximum number of pending dependencies scheduling allows | |
15183 | before flushing the current state and starting over. Large functions | |
15184 | with few branches or calls can create excessively large lists which | |
15185 | needlessly consume memory and resources. | |
15186 | ||
15187 | @item max-modulo-backtrack-attempts | |
15188 | The maximum number of backtrack attempts the scheduler should make | |
15189 | when modulo scheduling a loop. Larger values can exponentially increase | |
15190 | compilation time. | |
15191 | ||
15192 | @item max-inline-functions-called-once-loop-depth | |
15193 | Maximal loop depth of a call considered by inline heuristics that tries to | |
15194 | inline all functions called once. | |
15195 | ||
15196 | @item max-inline-functions-called-once-insns | |
15197 | Maximal estimated size of functions produced while inlining functions called | |
15198 | once. | |
15199 | ||
15200 | @item max-inline-insns-single | |
15201 | Several parameters control the tree inliner used in GCC@. This number sets the | |
15202 | maximum number of instructions (counted in GCC's internal representation) in a | |
15203 | single function that the tree inliner considers for inlining. This only | |
15204 | affects functions declared inline and methods implemented in a class | |
15205 | declaration (C++). | |
15206 | ||
15207 | ||
15208 | @item max-inline-insns-auto | |
15209 | When you use @option{-finline-functions} (included in @option{-O3}), | |
15210 | a lot of functions that would otherwise not be considered for inlining | |
15211 | by the compiler are investigated. To those functions, a different | |
15212 | (more restrictive) limit compared to functions declared inline can | |
15213 | be applied (@option{--param max-inline-insns-auto}). | |
15214 | ||
15215 | @item max-inline-insns-small | |
15216 | This is bound applied to calls which are considered relevant with | |
15217 | @option{-finline-small-functions}. | |
15218 | ||
15219 | @item max-inline-insns-size | |
15220 | This is bound applied to calls which are optimized for size. Small growth | |
15221 | may be desirable to anticipate optimization oppurtunities exposed by inlining. | |
15222 | ||
15223 | @item uninlined-function-insns | |
15224 | Number of instructions accounted by inliner for function overhead such as | |
15225 | function prologue and epilogue. | |
15226 | ||
15227 | @item uninlined-function-time | |
15228 | Extra time accounted by inliner for function overhead such as time needed to | |
15229 | execute function prologue and epilogue. | |
15230 | ||
15231 | @item inline-heuristics-hint-percent | |
15232 | The scale (in percents) applied to @option{inline-insns-single}, | |
15233 | @option{inline-insns-single-O2}, @option{inline-insns-auto} | |
15234 | when inline heuristics hints that inlining is | |
15235 | very profitable (will enable later optimizations). | |
15236 | ||
15237 | @item uninlined-thunk-insns | |
15238 | @item uninlined-thunk-time | |
15239 | Same as @option{--param uninlined-function-insns} and | |
15240 | @option{--param uninlined-function-time} but applied to function thunks. | |
15241 | ||
15242 | @item inline-min-speedup | |
15243 | When estimated performance improvement of caller + callee runtime exceeds this | |
15244 | threshold (in percent), the function can be inlined regardless of the limit on | |
15245 | @option{--param max-inline-insns-single} and @option{--param | |
15246 | max-inline-insns-auto}. | |
15247 | ||
15248 | @item large-function-insns | |
15249 | The limit specifying really large functions. For functions larger than this | |
15250 | limit after inlining, inlining is constrained by | |
15251 | @option{--param large-function-growth}. This parameter is useful primarily | |
15252 | to avoid extreme compilation time caused by non-linear algorithms used by the | |
15253 | back end. | |
15254 | ||
15255 | @item large-function-growth | |
15256 | Specifies maximal growth of large function caused by inlining in percents. | |
15257 | For example, parameter value 100 limits large function growth to 2.0 times | |
15258 | the original size. | |
15259 | ||
15260 | @item large-unit-insns | |
15261 | The limit specifying large translation unit. Growth caused by inlining of | |
15262 | units larger than this limit is limited by @option{--param inline-unit-growth}. | |
15263 | For small units this might be too tight. | |
15264 | For example, consider a unit consisting of function A | |
15265 | that is inline and B that just calls A three times. If B is small relative to | |
15266 | A, the growth of unit is 300\% and yet such inlining is very sane. For very | |
15267 | large units consisting of small inlineable functions, however, the overall unit | |
15268 | growth limit is needed to avoid exponential explosion of code size. Thus for | |
15269 | smaller units, the size is increased to @option{--param large-unit-insns} | |
15270 | before applying @option{--param inline-unit-growth}. | |
15271 | ||
15272 | @item lazy-modules | |
15273 | Maximum number of concurrently open C++ module files when lazy loading. | |
15274 | ||
15275 | @item inline-unit-growth | |
15276 | Specifies maximal overall growth of the compilation unit caused by inlining. | |
15277 | For example, parameter value 20 limits unit growth to 1.2 times the original | |
15278 | size. Cold functions (either marked cold via an attribute or by profile | |
15279 | feedback) are not accounted into the unit size. | |
15280 | ||
15281 | @item ipa-cp-unit-growth | |
15282 | Specifies maximal overall growth of the compilation unit caused by | |
15283 | interprocedural constant propagation. For example, parameter value 10 limits | |
15284 | unit growth to 1.1 times the original size. | |
15285 | ||
15286 | @item ipa-cp-large-unit-insns | |
15287 | The size of translation unit that IPA-CP pass considers large. | |
15288 | ||
15289 | @item large-stack-frame | |
15290 | The limit specifying large stack frames. While inlining the algorithm is trying | |
15291 | to not grow past this limit too much. | |
15292 | ||
15293 | @item large-stack-frame-growth | |
15294 | Specifies maximal growth of large stack frames caused by inlining in percents. | |
15295 | For example, parameter value 1000 limits large stack frame growth to 11 times | |
15296 | the original size. | |
15297 | ||
15298 | @item max-inline-insns-recursive | |
15299 | @itemx max-inline-insns-recursive-auto | |
15300 | Specifies the maximum number of instructions an out-of-line copy of a | |
15301 | self-recursive inline | |
15302 | function can grow into by performing recursive inlining. | |
15303 | ||
15304 | @option{--param max-inline-insns-recursive} applies to functions | |
15305 | declared inline. | |
15306 | For functions not declared inline, recursive inlining | |
15307 | happens only when @option{-finline-functions} (included in @option{-O3}) is | |
15308 | enabled; @option{--param max-inline-insns-recursive-auto} applies instead. | |
15309 | ||
15310 | @item max-inline-recursive-depth | |
15311 | @itemx max-inline-recursive-depth-auto | |
15312 | Specifies the maximum recursion depth used for recursive inlining. | |
15313 | ||
15314 | @option{--param max-inline-recursive-depth} applies to functions | |
15315 | declared inline. For functions not declared inline, recursive inlining | |
15316 | happens only when @option{-finline-functions} (included in @option{-O3}) is | |
15317 | enabled; @option{--param max-inline-recursive-depth-auto} applies instead. | |
15318 | ||
15319 | @item min-inline-recursive-probability | |
15320 | Recursive inlining is profitable only for function having deep recursion | |
15321 | in average and can hurt for function having little recursion depth by | |
15322 | increasing the prologue size or complexity of function body to other | |
15323 | optimizers. | |
15324 | ||
15325 | When profile feedback is available (see @option{-fprofile-generate}) the actual | |
15326 | recursion depth can be guessed from the probability that function recurses | |
15327 | via a given call expression. This parameter limits inlining only to call | |
15328 | expressions whose probability exceeds the given threshold (in percents). | |
15329 | ||
15330 | @item early-inlining-insns | |
15331 | Specify growth that the early inliner can make. In effect it increases | |
15332 | the amount of inlining for code having a large abstraction penalty. | |
15333 | ||
15334 | @item max-early-inliner-iterations | |
15335 | Limit of iterations of the early inliner. This basically bounds | |
15336 | the number of nested indirect calls the early inliner can resolve. | |
15337 | Deeper chains are still handled by late inlining. | |
15338 | ||
15339 | @item comdat-sharing-probability | |
15340 | Probability (in percent) that C++ inline function with comdat visibility | |
15341 | are shared across multiple compilation units. | |
15342 | ||
15343 | @item modref-max-bases | |
15344 | @item modref-max-refs | |
15345 | @item modref-max-accesses | |
15346 | Specifies the maximal number of base pointers, references and accesses stored | |
15347 | for a single function by mod/ref analysis. | |
15348 | ||
15349 | @item modref-max-tests | |
15350 | Specifies the maxmal number of tests alias oracle can perform to disambiguate | |
15351 | memory locations using the mod/ref information. This parameter ought to be | |
15352 | bigger than @option{--param modref-max-bases} and @option{--param | |
15353 | modref-max-refs}. | |
15354 | ||
15355 | @item modref-max-depth | |
15356 | Specifies the maximum depth of DFS walk used by modref escape analysis. | |
15357 | Setting to 0 disables the analysis completely. | |
15358 | ||
15359 | @item modref-max-escape-points | |
15360 | Specifies the maximum number of escape points tracked by modref per SSA-name. | |
15361 | ||
15362 | @item modref-max-adjustments | |
15363 | Specifies the maximum number the access range is enlarged during modref dataflow | |
15364 | analysis. | |
15365 | ||
15366 | @item profile-func-internal-id | |
15367 | A parameter to control whether to use function internal id in profile | |
15368 | database lookup. If the value is 0, the compiler uses an id that | |
15369 | is based on function assembler name and filename, which makes old profile | |
15370 | data more tolerant to source changes such as function reordering etc. | |
15371 | ||
15372 | @item min-vect-loop-bound | |
15373 | The minimum number of iterations under which loops are not vectorized | |
15374 | when @option{-ftree-vectorize} is used. The number of iterations after | |
15375 | vectorization needs to be greater than the value specified by this option | |
15376 | to allow vectorization. | |
15377 | ||
15378 | @item gcse-cost-distance-ratio | |
15379 | Scaling factor in calculation of maximum distance an expression | |
15380 | can be moved by GCSE optimizations. This is currently supported only in the | |
15381 | code hoisting pass. The bigger the ratio, the more aggressive code hoisting | |
15382 | is with simple expressions, i.e., the expressions that have cost | |
15383 | less than @option{gcse-unrestricted-cost}. Specifying 0 disables | |
15384 | hoisting of simple expressions. | |
15385 | ||
15386 | @item gcse-unrestricted-cost | |
15387 | Cost, roughly measured as the cost of a single typical machine | |
15388 | instruction, at which GCSE optimizations do not constrain | |
15389 | the distance an expression can travel. This is currently | |
15390 | supported only in the code hoisting pass. The lesser the cost, | |
15391 | the more aggressive code hoisting is. Specifying 0 | |
15392 | allows all expressions to travel unrestricted distances. | |
15393 | ||
15394 | @item max-hoist-depth | |
15395 | The depth of search in the dominator tree for expressions to hoist. | |
15396 | This is used to avoid quadratic behavior in hoisting algorithm. | |
15397 | The value of 0 does not limit on the search, but may slow down compilation | |
15398 | of huge functions. | |
15399 | ||
15400 | @item max-tail-merge-comparisons | |
15401 | The maximum amount of similar bbs to compare a bb with. This is used to | |
15402 | avoid quadratic behavior in tree tail merging. | |
15403 | ||
15404 | @item max-tail-merge-iterations | |
15405 | The maximum amount of iterations of the pass over the function. This is used to | |
15406 | limit compilation time in tree tail merging. | |
15407 | ||
15408 | @item store-merging-allow-unaligned | |
15409 | Allow the store merging pass to introduce unaligned stores if it is legal to | |
15410 | do so. | |
15411 | ||
15412 | @item max-stores-to-merge | |
15413 | The maximum number of stores to attempt to merge into wider stores in the store | |
15414 | merging pass. | |
15415 | ||
15416 | @item max-store-chains-to-track | |
15417 | The maximum number of store chains to track at the same time in the attempt | |
15418 | to merge them into wider stores in the store merging pass. | |
15419 | ||
15420 | @item max-stores-to-track | |
15421 | The maximum number of stores to track at the same time in the attemt to | |
15422 | to merge them into wider stores in the store merging pass. | |
15423 | ||
15424 | @item max-unrolled-insns | |
15425 | The maximum number of instructions that a loop may have to be unrolled. | |
15426 | If a loop is unrolled, this parameter also determines how many times | |
15427 | the loop code is unrolled. | |
15428 | ||
15429 | @item max-average-unrolled-insns | |
15430 | The maximum number of instructions biased by probabilities of their execution | |
15431 | that a loop may have to be unrolled. If a loop is unrolled, | |
15432 | this parameter also determines how many times the loop code is unrolled. | |
15433 | ||
15434 | @item max-unroll-times | |
15435 | The maximum number of unrollings of a single loop. | |
15436 | ||
15437 | @item max-peeled-insns | |
15438 | The maximum number of instructions that a loop may have to be peeled. | |
15439 | If a loop is peeled, this parameter also determines how many times | |
15440 | the loop code is peeled. | |
15441 | ||
15442 | @item max-peel-times | |
15443 | The maximum number of peelings of a single loop. | |
15444 | ||
15445 | @item max-peel-branches | |
15446 | The maximum number of branches on the hot path through the peeled sequence. | |
15447 | ||
15448 | @item max-completely-peeled-insns | |
15449 | The maximum number of insns of a completely peeled loop. | |
15450 | ||
15451 | @item max-completely-peel-times | |
15452 | The maximum number of iterations of a loop to be suitable for complete peeling. | |
15453 | ||
15454 | @item max-completely-peel-loop-nest-depth | |
15455 | The maximum depth of a loop nest suitable for complete peeling. | |
15456 | ||
15457 | @item max-unswitch-insns | |
15458 | The maximum number of insns of an unswitched loop. | |
15459 | ||
5b50850c RB |
15460 | @item max-unswitch-depth |
15461 | The maximum depth of a loop nest to be unswitched. | |
15462 | ||
d77de738 ML |
15463 | @item lim-expensive |
15464 | The minimum cost of an expensive expression in the loop invariant motion. | |
15465 | ||
15466 | @item min-loop-cond-split-prob | |
15467 | When FDO profile information is available, @option{min-loop-cond-split-prob} | |
15468 | specifies minimum threshold for probability of semi-invariant condition | |
15469 | statement to trigger loop split. | |
15470 | ||
15471 | @item iv-consider-all-candidates-bound | |
15472 | Bound on number of candidates for induction variables, below which | |
15473 | all candidates are considered for each use in induction variable | |
15474 | optimizations. If there are more candidates than this, | |
15475 | only the most relevant ones are considered to avoid quadratic time complexity. | |
15476 | ||
15477 | @item iv-max-considered-uses | |
15478 | The induction variable optimizations give up on loops that contain more | |
15479 | induction variable uses. | |
15480 | ||
15481 | @item iv-always-prune-cand-set-bound | |
15482 | If the number of candidates in the set is smaller than this value, | |
15483 | always try to remove unnecessary ivs from the set | |
15484 | when adding a new one. | |
15485 | ||
15486 | @item avg-loop-niter | |
15487 | Average number of iterations of a loop. | |
15488 | ||
15489 | @item dse-max-object-size | |
15490 | Maximum size (in bytes) of objects tracked bytewise by dead store elimination. | |
15491 | Larger values may result in larger compilation times. | |
15492 | ||
15493 | @item dse-max-alias-queries-per-store | |
15494 | Maximum number of queries into the alias oracle per store. | |
15495 | Larger values result in larger compilation times and may result in more | |
15496 | removed dead stores. | |
15497 | ||
15498 | @item scev-max-expr-size | |
15499 | Bound on size of expressions used in the scalar evolutions analyzer. | |
15500 | Large expressions slow the analyzer. | |
15501 | ||
15502 | @item scev-max-expr-complexity | |
15503 | Bound on the complexity of the expressions in the scalar evolutions analyzer. | |
15504 | Complex expressions slow the analyzer. | |
15505 | ||
15506 | @item max-tree-if-conversion-phi-args | |
15507 | Maximum number of arguments in a PHI supported by TREE if conversion | |
15508 | unless the loop is marked with simd pragma. | |
15509 | ||
15510 | @item vect-max-layout-candidates | |
15511 | The maximum number of possible vector layouts (such as permutations) | |
15512 | to consider when optimizing to-be-vectorized code. | |
15513 | ||
15514 | @item vect-max-version-for-alignment-checks | |
15515 | The maximum number of run-time checks that can be performed when | |
15516 | doing loop versioning for alignment in the vectorizer. | |
15517 | ||
15518 | @item vect-max-version-for-alias-checks | |
15519 | The maximum number of run-time checks that can be performed when | |
15520 | doing loop versioning for alias in the vectorizer. | |
15521 | ||
15522 | @item vect-max-peeling-for-alignment | |
15523 | The maximum number of loop peels to enhance access alignment | |
15524 | for vectorizer. Value -1 means no limit. | |
15525 | ||
15526 | @item max-iterations-to-track | |
15527 | The maximum number of iterations of a loop the brute-force algorithm | |
15528 | for analysis of the number of iterations of the loop tries to evaluate. | |
15529 | ||
15530 | @item hot-bb-count-fraction | |
15531 | The denominator n of fraction 1/n of the maximal execution count of a | |
15532 | basic block in the entire program that a basic block needs to at least | |
15533 | have in order to be considered hot. The default is 10000, which means | |
15534 | that a basic block is considered hot if its execution count is greater | |
15535 | than 1/10000 of the maximal execution count. 0 means that it is never | |
15536 | considered hot. Used in non-LTO mode. | |
15537 | ||
15538 | @item hot-bb-count-ws-permille | |
15539 | The number of most executed permilles, ranging from 0 to 1000, of the | |
15540 | profiled execution of the entire program to which the execution count | |
15541 | of a basic block must be part of in order to be considered hot. The | |
15542 | default is 990, which means that a basic block is considered hot if | |
15543 | its execution count contributes to the upper 990 permilles, or 99.0%, | |
15544 | of the profiled execution of the entire program. 0 means that it is | |
15545 | never considered hot. Used in LTO mode. | |
15546 | ||
15547 | @item hot-bb-frequency-fraction | |
15548 | The denominator n of fraction 1/n of the execution frequency of the | |
15549 | entry block of a function that a basic block of this function needs | |
15550 | to at least have in order to be considered hot. The default is 1000, | |
15551 | which means that a basic block is considered hot in a function if it | |
15552 | is executed more frequently than 1/1000 of the frequency of the entry | |
15553 | block of the function. 0 means that it is never considered hot. | |
15554 | ||
15555 | @item unlikely-bb-count-fraction | |
15556 | The denominator n of fraction 1/n of the number of profiled runs of | |
15557 | the entire program below which the execution count of a basic block | |
15558 | must be in order for the basic block to be considered unlikely executed. | |
15559 | The default is 20, which means that a basic block is considered unlikely | |
15560 | executed if it is executed in fewer than 1/20, or 5%, of the runs of | |
15561 | the program. 0 means that it is always considered unlikely executed. | |
15562 | ||
15563 | @item max-predicted-iterations | |
15564 | The maximum number of loop iterations we predict statically. This is useful | |
15565 | in cases where a function contains a single loop with known bound and | |
15566 | another loop with unknown bound. | |
15567 | The known number of iterations is predicted correctly, while | |
15568 | the unknown number of iterations average to roughly 10. This means that the | |
15569 | loop without bounds appears artificially cold relative to the other one. | |
15570 | ||
15571 | @item builtin-expect-probability | |
15572 | Control the probability of the expression having the specified value. This | |
15573 | parameter takes a percentage (i.e.@: 0 ... 100) as input. | |
15574 | ||
15575 | @item builtin-string-cmp-inline-length | |
15576 | The maximum length of a constant string for a builtin string cmp call | |
15577 | eligible for inlining. | |
15578 | ||
15579 | @item align-threshold | |
15580 | ||
15581 | Select fraction of the maximal frequency of executions of a basic block in | |
15582 | a function to align the basic block. | |
15583 | ||
15584 | @item align-loop-iterations | |
15585 | ||
15586 | A loop expected to iterate at least the selected number of iterations is | |
15587 | aligned. | |
15588 | ||
15589 | @item tracer-dynamic-coverage | |
15590 | @itemx tracer-dynamic-coverage-feedback | |
15591 | ||
15592 | This value is used to limit superblock formation once the given percentage of | |
15593 | executed instructions is covered. This limits unnecessary code size | |
15594 | expansion. | |
15595 | ||
15596 | The @option{tracer-dynamic-coverage-feedback} parameter | |
15597 | is used only when profile | |
15598 | feedback is available. The real profiles (as opposed to statically estimated | |
15599 | ones) are much less balanced allowing the threshold to be larger value. | |
15600 | ||
15601 | @item tracer-max-code-growth | |
15602 | Stop tail duplication once code growth has reached given percentage. This is | |
15603 | a rather artificial limit, as most of the duplicates are eliminated later in | |
15604 | cross jumping, so it may be set to much higher values than is the desired code | |
15605 | growth. | |
15606 | ||
15607 | @item tracer-min-branch-ratio | |
15608 | ||
15609 | Stop reverse growth when the reverse probability of best edge is less than this | |
15610 | threshold (in percent). | |
15611 | ||
15612 | @item tracer-min-branch-probability | |
15613 | @itemx tracer-min-branch-probability-feedback | |
15614 | ||
15615 | Stop forward growth if the best edge has probability lower than this | |
15616 | threshold. | |
15617 | ||
15618 | Similarly to @option{tracer-dynamic-coverage} two parameters are | |
15619 | provided. @option{tracer-min-branch-probability-feedback} is used for | |
15620 | compilation with profile feedback and @option{tracer-min-branch-probability} | |
15621 | compilation without. The value for compilation with profile feedback | |
15622 | needs to be more conservative (higher) in order to make tracer | |
15623 | effective. | |
15624 | ||
15625 | @item stack-clash-protection-guard-size | |
15626 | Specify the size of the operating system provided stack guard as | |
15627 | 2 raised to @var{num} bytes. Higher values may reduce the | |
15628 | number of explicit probes, but a value larger than the operating system | |
15629 | provided guard will leave code vulnerable to stack clash style attacks. | |
15630 | ||
15631 | @item stack-clash-protection-probe-interval | |
15632 | Stack clash protection involves probing stack space as it is allocated. This | |
15633 | param controls the maximum distance between probes into the stack as 2 raised | |
15634 | to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value | |
15635 | larger than the operating system provided guard will leave code vulnerable to | |
15636 | stack clash style attacks. | |
15637 | ||
15638 | @item max-cse-path-length | |
15639 | ||
15640 | The maximum number of basic blocks on path that CSE considers. | |
15641 | ||
15642 | @item max-cse-insns | |
15643 | The maximum number of instructions CSE processes before flushing. | |
15644 | ||
15645 | @item ggc-min-expand | |
15646 | ||
15647 | GCC uses a garbage collector to manage its own memory allocation. This | |
15648 | parameter specifies the minimum percentage by which the garbage | |
15649 | collector's heap should be allowed to expand between collections. | |
15650 | Tuning this may improve compilation speed; it has no effect on code | |
15651 | generation. | |
15652 | ||
15653 | The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when | |
15654 | RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is | |
15655 | the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If | |
15656 | GCC is not able to calculate RAM on a particular platform, the lower | |
15657 | bound of 30% is used. Setting this parameter and | |
15658 | @option{ggc-min-heapsize} to zero causes a full collection to occur at | |
15659 | every opportunity. This is extremely slow, but can be useful for | |
15660 | debugging. | |
15661 | ||
15662 | @item ggc-min-heapsize | |
15663 | ||
15664 | Minimum size of the garbage collector's heap before it begins bothering | |
15665 | to collect garbage. The first collection occurs after the heap expands | |
15666 | by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again, | |
15667 | tuning this may improve compilation speed, and has no effect on code | |
15668 | generation. | |
15669 | ||
15670 | The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that | |
15671 | tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but | |
15672 | with a lower bound of 4096 (four megabytes) and an upper bound of | |
15673 | 131072 (128 megabytes). If GCC is not able to calculate RAM on a | |
15674 | particular platform, the lower bound is used. Setting this parameter | |
15675 | very large effectively disables garbage collection. Setting this | |
15676 | parameter and @option{ggc-min-expand} to zero causes a full collection | |
15677 | to occur at every opportunity. | |
15678 | ||
15679 | @item max-reload-search-insns | |
15680 | The maximum number of instruction reload should look backward for equivalent | |
15681 | register. Increasing values mean more aggressive optimization, making the | |
15682 | compilation time increase with probably slightly better performance. | |
15683 | ||
15684 | @item max-cselib-memory-locations | |
15685 | The maximum number of memory locations cselib should take into account. | |
15686 | Increasing values mean more aggressive optimization, making the compilation time | |
15687 | increase with probably slightly better performance. | |
15688 | ||
15689 | @item max-sched-ready-insns | |
15690 | The maximum number of instructions ready to be issued the scheduler should | |
15691 | consider at any given time during the first scheduling pass. Increasing | |
15692 | values mean more thorough searches, making the compilation time increase | |
15693 | with probably little benefit. | |
15694 | ||
15695 | @item max-sched-region-blocks | |
15696 | The maximum number of blocks in a region to be considered for | |
15697 | interblock scheduling. | |
15698 | ||
15699 | @item max-pipeline-region-blocks | |
15700 | The maximum number of blocks in a region to be considered for | |
15701 | pipelining in the selective scheduler. | |
15702 | ||
15703 | @item max-sched-region-insns | |
15704 | The maximum number of insns in a region to be considered for | |
15705 | interblock scheduling. | |
15706 | ||
15707 | @item max-pipeline-region-insns | |
15708 | The maximum number of insns in a region to be considered for | |
15709 | pipelining in the selective scheduler. | |
15710 | ||
15711 | @item min-spec-prob | |
15712 | The minimum probability (in percents) of reaching a source block | |
15713 | for interblock speculative scheduling. | |
15714 | ||
15715 | @item max-sched-extend-regions-iters | |
15716 | The maximum number of iterations through CFG to extend regions. | |
15717 | A value of 0 disables region extensions. | |
15718 | ||
15719 | @item max-sched-insn-conflict-delay | |
15720 | The maximum conflict delay for an insn to be considered for speculative motion. | |
15721 | ||
15722 | @item sched-spec-prob-cutoff | |
15723 | The minimal probability of speculation success (in percents), so that | |
15724 | speculative insns are scheduled. | |
15725 | ||
15726 | @item sched-state-edge-prob-cutoff | |
15727 | The minimum probability an edge must have for the scheduler to save its | |
15728 | state across it. | |
15729 | ||
15730 | @item sched-mem-true-dep-cost | |
15731 | Minimal distance (in CPU cycles) between store and load targeting same | |
15732 | memory locations. | |
15733 | ||
15734 | @item selsched-max-lookahead | |
15735 | The maximum size of the lookahead window of selective scheduling. It is a | |
15736 | depth of search for available instructions. | |
15737 | ||
15738 | @item selsched-max-sched-times | |
15739 | The maximum number of times that an instruction is scheduled during | |
15740 | selective scheduling. This is the limit on the number of iterations | |
15741 | through which the instruction may be pipelined. | |
15742 | ||
15743 | @item selsched-insns-to-rename | |
15744 | The maximum number of best instructions in the ready list that are considered | |
15745 | for renaming in the selective scheduler. | |
15746 | ||
15747 | @item sms-min-sc | |
15748 | The minimum value of stage count that swing modulo scheduler | |
15749 | generates. | |
15750 | ||
15751 | @item max-last-value-rtl | |
15752 | The maximum size measured as number of RTLs that can be recorded in an expression | |
15753 | in combiner for a pseudo register as last known value of that register. | |
15754 | ||
15755 | @item max-combine-insns | |
15756 | The maximum number of instructions the RTL combiner tries to combine. | |
15757 | ||
15758 | @item integer-share-limit | |
15759 | Small integer constants can use a shared data structure, reducing the | |
15760 | compiler's memory usage and increasing its speed. This sets the maximum | |
15761 | value of a shared integer constant. | |
15762 | ||
15763 | @item ssp-buffer-size | |
15764 | The minimum size of buffers (i.e.@: arrays) that receive stack smashing | |
15765 | protection when @option{-fstack-protector} is used. | |
15766 | ||
15767 | @item min-size-for-stack-sharing | |
15768 | The minimum size of variables taking part in stack slot sharing when not | |
15769 | optimizing. | |
15770 | ||
15771 | @item max-jump-thread-duplication-stmts | |
15772 | Maximum number of statements allowed in a block that needs to be | |
15773 | duplicated when threading jumps. | |
15774 | ||
15775 | @item max-jump-thread-paths | |
15776 | The maximum number of paths to consider when searching for jump threading | |
15777 | opportunities. When arriving at a block, incoming edges are only considered | |
15778 | if the number of paths to be searched so far multiplied by the number of | |
15779 | incoming edges does not exhaust the specified maximum number of paths to | |
15780 | consider. | |
15781 | ||
15782 | @item max-fields-for-field-sensitive | |
15783 | Maximum number of fields in a structure treated in | |
15784 | a field sensitive manner during pointer analysis. | |
15785 | ||
15786 | @item prefetch-latency | |
15787 | Estimate on average number of instructions that are executed before | |
15788 | prefetch finishes. The distance prefetched ahead is proportional | |
15789 | to this constant. Increasing this number may also lead to less | |
15790 | streams being prefetched (see @option{simultaneous-prefetches}). | |
15791 | ||
15792 | @item simultaneous-prefetches | |
15793 | Maximum number of prefetches that can run at the same time. | |
15794 | ||
15795 | @item l1-cache-line-size | |
15796 | The size of cache line in L1 data cache, in bytes. | |
15797 | ||
15798 | @item l1-cache-size | |
15799 | The size of L1 data cache, in kilobytes. | |
15800 | ||
15801 | @item l2-cache-size | |
15802 | The size of L2 data cache, in kilobytes. | |
15803 | ||
15804 | @item prefetch-dynamic-strides | |
15805 | Whether the loop array prefetch pass should issue software prefetch hints | |
15806 | for strides that are non-constant. In some cases this may be | |
15807 | beneficial, though the fact the stride is non-constant may make it | |
15808 | hard to predict when there is clear benefit to issuing these hints. | |
15809 | ||
15810 | Set to 1 if the prefetch hints should be issued for non-constant | |
15811 | strides. Set to 0 if prefetch hints should be issued only for strides that | |
15812 | are known to be constant and below @option{prefetch-minimum-stride}. | |
15813 | ||
15814 | @item prefetch-minimum-stride | |
15815 | Minimum constant stride, in bytes, to start using prefetch hints for. If | |
15816 | the stride is less than this threshold, prefetch hints will not be issued. | |
15817 | ||
15818 | This setting is useful for processors that have hardware prefetchers, in | |
15819 | which case there may be conflicts between the hardware prefetchers and | |
15820 | the software prefetchers. If the hardware prefetchers have a maximum | |
15821 | stride they can handle, it should be used here to improve the use of | |
15822 | software prefetchers. | |
15823 | ||
15824 | A value of -1 means we don't have a threshold and therefore | |
15825 | prefetch hints can be issued for any constant stride. | |
15826 | ||
15827 | This setting is only useful for strides that are known and constant. | |
15828 | ||
15829 | @item destructive-interference-size | |
15830 | @item constructive-interference-size | |
15831 | The values for the C++17 variables | |
15832 | @code{std::hardware_destructive_interference_size} and | |
15833 | @code{std::hardware_constructive_interference_size}. The destructive | |
15834 | interference size is the minimum recommended offset between two | |
15835 | independent concurrently-accessed objects; the constructive | |
15836 | interference size is the maximum recommended size of contiguous memory | |
15837 | accessed together. Typically both will be the size of an L1 cache | |
15838 | line for the target, in bytes. For a generic target covering a range of L1 | |
15839 | cache line sizes, typically the constructive interference size will be | |
15840 | the small end of the range and the destructive size will be the large | |
15841 | end. | |
15842 | ||
15843 | The destructive interference size is intended to be used for layout, | |
15844 | and thus has ABI impact. The default value is not expected to be | |
15845 | stable, and on some targets varies with @option{-mtune}, so use of | |
15846 | this variable in a context where ABI stability is important, such as | |
15847 | the public interface of a library, is strongly discouraged; if it is | |
15848 | used in that context, users can stabilize the value using this | |
15849 | option. | |
15850 | ||
15851 | The constructive interference size is less sensitive, as it is | |
15852 | typically only used in a @samp{static_assert} to make sure that a type | |
15853 | fits within a cache line. | |
15854 | ||
15855 | See also @option{-Winterference-size}. | |
15856 | ||
15857 | @item loop-interchange-max-num-stmts | |
15858 | The maximum number of stmts in a loop to be interchanged. | |
15859 | ||
15860 | @item loop-interchange-stride-ratio | |
15861 | The minimum ratio between stride of two loops for interchange to be profitable. | |
15862 | ||
15863 | @item min-insn-to-prefetch-ratio | |
15864 | The minimum ratio between the number of instructions and the | |
15865 | number of prefetches to enable prefetching in a loop. | |
15866 | ||
15867 | @item prefetch-min-insn-to-mem-ratio | |
15868 | The minimum ratio between the number of instructions and the | |
15869 | number of memory references to enable prefetching in a loop. | |
15870 | ||
15871 | @item use-canonical-types | |
15872 | Whether the compiler should use the ``canonical'' type system. | |
15873 | Should always be 1, which uses a more efficient internal | |
15874 | mechanism for comparing types in C++ and Objective-C++. However, if | |
15875 | bugs in the canonical type system are causing compilation failures, | |
15876 | set this value to 0 to disable canonical types. | |
15877 | ||
15878 | @item switch-conversion-max-branch-ratio | |
15879 | Switch initialization conversion refuses to create arrays that are | |
15880 | bigger than @option{switch-conversion-max-branch-ratio} times the number of | |
15881 | branches in the switch. | |
15882 | ||
15883 | @item max-partial-antic-length | |
15884 | Maximum length of the partial antic set computed during the tree | |
15885 | partial redundancy elimination optimization (@option{-ftree-pre}) when | |
15886 | optimizing at @option{-O3} and above. For some sorts of source code | |
15887 | the enhanced partial redundancy elimination optimization can run away, | |
15888 | consuming all of the memory available on the host machine. This | |
15889 | parameter sets a limit on the length of the sets that are computed, | |
15890 | which prevents the runaway behavior. Setting a value of 0 for | |
15891 | this parameter allows an unlimited set length. | |
15892 | ||
15893 | @item rpo-vn-max-loop-depth | |
15894 | Maximum loop depth that is value-numbered optimistically. | |
15895 | When the limit hits the innermost | |
15896 | @var{rpo-vn-max-loop-depth} loops and the outermost loop in the | |
15897 | loop nest are value-numbered optimistically and the remaining ones not. | |
15898 | ||
15899 | @item sccvn-max-alias-queries-per-access | |
15900 | Maximum number of alias-oracle queries we perform when looking for | |
15901 | redundancies for loads and stores. If this limit is hit the search | |
15902 | is aborted and the load or store is not considered redundant. The | |
15903 | number of queries is algorithmically limited to the number of | |
15904 | stores on all paths from the load to the function entry. | |
15905 | ||
15906 | @item ira-max-loops-num | |
15907 | IRA uses regional register allocation by default. If a function | |
15908 | contains more loops than the number given by this parameter, only at most | |
15909 | the given number of the most frequently-executed loops form regions | |
15910 | for regional register allocation. | |
15911 | ||
15912 | @item ira-max-conflict-table-size | |
15913 | Although IRA uses a sophisticated algorithm to compress the conflict | |
15914 | table, the table can still require excessive amounts of memory for | |
15915 | huge functions. If the conflict table for a function could be more | |
15916 | than the size in MB given by this parameter, the register allocator | |
15917 | instead uses a faster, simpler, and lower-quality | |
15918 | algorithm that does not require building a pseudo-register conflict table. | |
15919 | ||
15920 | @item ira-loop-reserved-regs | |
15921 | IRA can be used to evaluate more accurate register pressure in loops | |
15922 | for decisions to move loop invariants (see @option{-O3}). The number | |
15923 | of available registers reserved for some other purposes is given | |
15924 | by this parameter. Default of the parameter | |
15925 | is the best found from numerous experiments. | |
15926 | ||
15927 | @item ira-consider-dup-in-all-alts | |
15928 | Make IRA to consider matching constraint (duplicated operand number) | |
15929 | heavily in all available alternatives for preferred register class. | |
15930 | If it is set as zero, it means IRA only respects the matching | |
15931 | constraint when it's in the only available alternative with an | |
15932 | appropriate register class. Otherwise, it means IRA will check all | |
15933 | available alternatives for preferred register class even if it has | |
15934 | found some choice with an appropriate register class and respect the | |
15935 | found qualified matching constraint. | |
15936 | ||
9847c753 ML |
15937 | @item ira-simple-lra-insn-threshold |
15938 | Approximate function insn number in 1K units triggering simple local RA. | |
15939 | ||
d77de738 ML |
15940 | @item lra-inheritance-ebb-probability-cutoff |
15941 | LRA tries to reuse values reloaded in registers in subsequent insns. | |
15942 | This optimization is called inheritance. EBB is used as a region to | |
15943 | do this optimization. The parameter defines a minimal fall-through | |
15944 | edge probability in percentage used to add BB to inheritance EBB in | |
15945 | LRA. The default value was chosen | |
15946 | from numerous runs of SPEC2000 on x86-64. | |
15947 | ||
15948 | @item loop-invariant-max-bbs-in-loop | |
15949 | Loop invariant motion can be very expensive, both in compilation time and | |
15950 | in amount of needed compile-time memory, with very large loops. Loops | |
15951 | with more basic blocks than this parameter won't have loop invariant | |
15952 | motion optimization performed on them. | |
15953 | ||
15954 | @item loop-max-datarefs-for-datadeps | |
15955 | Building data dependencies is expensive for very large loops. This | |
15956 | parameter limits the number of data references in loops that are | |
15957 | considered for data dependence analysis. These large loops are no | |
15958 | handled by the optimizations using loop data dependencies. | |
15959 | ||
15960 | @item max-vartrack-size | |
15961 | Sets a maximum number of hash table slots to use during variable | |
15962 | tracking dataflow analysis of any function. If this limit is exceeded | |
15963 | with variable tracking at assignments enabled, analysis for that | |
15964 | function is retried without it, after removing all debug insns from | |
15965 | the function. If the limit is exceeded even without debug insns, var | |
15966 | tracking analysis is completely disabled for the function. Setting | |
15967 | the parameter to zero makes it unlimited. | |
15968 | ||
15969 | @item max-vartrack-expr-depth | |
15970 | Sets a maximum number of recursion levels when attempting to map | |
15971 | variable names or debug temporaries to value expressions. This trades | |
15972 | compilation time for more complete debug information. If this is set too | |
15973 | low, value expressions that are available and could be represented in | |
15974 | debug information may end up not being used; setting this higher may | |
15975 | enable the compiler to find more complex debug expressions, but compile | |
15976 | time and memory use may grow. | |
15977 | ||
15978 | @item max-debug-marker-count | |
15979 | Sets a threshold on the number of debug markers (e.g.@: begin stmt | |
15980 | markers) to avoid complexity explosion at inlining or expanding to RTL. | |
15981 | If a function has more such gimple stmts than the set limit, such stmts | |
15982 | will be dropped from the inlined copy of a function, and from its RTL | |
15983 | expansion. | |
15984 | ||
15985 | @item min-nondebug-insn-uid | |
15986 | Use uids starting at this parameter for nondebug insns. The range below | |
15987 | the parameter is reserved exclusively for debug insns created by | |
15988 | @option{-fvar-tracking-assignments}, but debug insns may get | |
15989 | (non-overlapping) uids above it if the reserved range is exhausted. | |
15990 | ||
10478270 MJ |
15991 | @item ipa-sra-deref-prob-threshold |
15992 | IPA-SRA replaces a pointer which is known not be NULL with one or more | |
15993 | new parameters only when the probability (in percent, relative to | |
15994 | function entry) of it being dereferenced is higher than this parameter. | |
15995 | ||
d77de738 ML |
15996 | @item ipa-sra-ptr-growth-factor |
15997 | IPA-SRA replaces a pointer to an aggregate with one or more new | |
15998 | parameters only when their cumulative size is less or equal to | |
15999 | @option{ipa-sra-ptr-growth-factor} times the size of the original | |
16000 | pointer parameter. | |
16001 | ||
69363825 ML |
16002 | @item ipa-sra-ptrwrap-growth-factor |
16003 | Additional maximum allowed growth of total size of new parameters | |
16004 | that ipa-sra replaces a pointer to an aggregate with, | |
049dccd0 MJ |
16005 | if it points to a local variable that the caller only writes to and |
16006 | passes it as an argument to other functions. | |
69363825 | 16007 | |
d77de738 ML |
16008 | @item ipa-sra-max-replacements |
16009 | Maximum pieces of an aggregate that IPA-SRA tracks. As a | |
16010 | consequence, it is also the maximum number of replacements of a formal | |
16011 | parameter. | |
16012 | ||
16013 | @item sra-max-scalarization-size-Ospeed | |
16014 | @itemx sra-max-scalarization-size-Osize | |
16015 | The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to | |
16016 | replace scalar parts of aggregates with uses of independent scalar | |
16017 | variables. These parameters control the maximum size, in storage units, | |
16018 | of aggregate which is considered for replacement when compiling for | |
16019 | speed | |
16020 | (@option{sra-max-scalarization-size-Ospeed}) or size | |
16021 | (@option{sra-max-scalarization-size-Osize}) respectively. | |
16022 | ||
16023 | @item sra-max-propagations | |
16024 | The maximum number of artificial accesses that Scalar Replacement of | |
16025 | Aggregates (SRA) will track, per one local variable, in order to | |
16026 | facilitate copy propagation. | |
16027 | ||
16028 | @item tm-max-aggregate-size | |
16029 | When making copies of thread-local variables in a transaction, this | |
16030 | parameter specifies the size in bytes after which variables are | |
16031 | saved with the logging functions as opposed to save/restore code | |
16032 | sequence pairs. This option only applies when using | |
16033 | @option{-fgnu-tm}. | |
16034 | ||
16035 | @item graphite-max-nb-scop-params | |
16036 | To avoid exponential effects in the Graphite loop transforms, the | |
16037 | number of parameters in a Static Control Part (SCoP) is bounded. | |
16038 | A value of zero can be used to lift | |
16039 | the bound. A variable whose value is unknown at compilation time and | |
16040 | defined outside a SCoP is a parameter of the SCoP. | |
16041 | ||
551935d1 AO |
16042 | @item hardcfr-max-blocks |
16043 | Disable @option{-fharden-control-flow-redundancy} for functions with a | |
16044 | larger number of blocks than the specified value. Zero removes any | |
16045 | limit. | |
16046 | ||
16047 | @item hardcfr-max-inline-blocks | |
16048 | Force @option{-fharden-control-flow-redundancy} to use out-of-line | |
16049 | checking for functions with a larger number of basic blocks than the | |
16050 | specified value. | |
16051 | ||
d77de738 ML |
16052 | @item loop-block-tile-size |
16053 | Loop blocking or strip mining transforms, enabled with | |
16054 | @option{-floop-block} or @option{-floop-strip-mine}, strip mine each | |
16055 | loop in the loop nest by a given number of iterations. The strip | |
16056 | length can be changed using the @option{loop-block-tile-size} | |
16057 | parameter. | |
16058 | ||
16059 | @item ipa-jump-function-lookups | |
16060 | Specifies number of statements visited during jump function offset discovery. | |
16061 | ||
16062 | @item ipa-cp-value-list-size | |
16063 | IPA-CP attempts to track all possible values and types passed to a function's | |
16064 | parameter in order to propagate them and perform devirtualization. | |
16065 | @option{ipa-cp-value-list-size} is the maximum number of values and types it | |
16066 | stores per one formal parameter of a function. | |
16067 | ||
16068 | @item ipa-cp-eval-threshold | |
16069 | IPA-CP calculates its own score of cloning profitability heuristics | |
16070 | and performs those cloning opportunities with scores that exceed | |
16071 | @option{ipa-cp-eval-threshold}. | |
16072 | ||
16073 | @item ipa-cp-max-recursive-depth | |
16074 | Maximum depth of recursive cloning for self-recursive function. | |
16075 | ||
16076 | @item ipa-cp-min-recursive-probability | |
16077 | Recursive cloning only when the probability of call being executed exceeds | |
16078 | the parameter. | |
16079 | ||
16080 | @item ipa-cp-profile-count-base | |
16081 | When using @option{-fprofile-use} option, IPA-CP will consider the measured | |
16082 | execution count of a call graph edge at this percentage position in their | |
16083 | histogram as the basis for its heuristics calculation. | |
16084 | ||
16085 | @item ipa-cp-recursive-freq-factor | |
16086 | The number of times interprocedural copy propagation expects recursive | |
16087 | functions to call themselves. | |
16088 | ||
16089 | @item ipa-cp-recursion-penalty | |
16090 | Percentage penalty the recursive functions will receive when they | |
16091 | are evaluated for cloning. | |
16092 | ||
16093 | @item ipa-cp-single-call-penalty | |
16094 | Percentage penalty functions containing a single call to another | |
16095 | function will receive when they are evaluated for cloning. | |
16096 | ||
16097 | @item ipa-max-agg-items | |
16098 | IPA-CP is also capable to propagate a number of scalar values passed | |
16099 | in an aggregate. @option{ipa-max-agg-items} controls the maximum | |
16100 | number of such values per one parameter. | |
16101 | ||
16102 | @item ipa-cp-loop-hint-bonus | |
16103 | When IPA-CP determines that a cloning candidate would make the number | |
16104 | of iterations of a loop known, it adds a bonus of | |
16105 | @option{ipa-cp-loop-hint-bonus} to the profitability score of | |
16106 | the candidate. | |
16107 | ||
16108 | @item ipa-max-loop-predicates | |
16109 | The maximum number of different predicates IPA will use to describe when | |
16110 | loops in a function have known properties. | |
16111 | ||
16112 | @item ipa-max-aa-steps | |
16113 | During its analysis of function bodies, IPA-CP employs alias analysis | |
16114 | in order to track values pointed to by function parameters. In order | |
16115 | not spend too much time analyzing huge functions, it gives up and | |
16116 | consider all memory clobbered after examining | |
16117 | @option{ipa-max-aa-steps} statements modifying memory. | |
16118 | ||
16119 | @item ipa-max-switch-predicate-bounds | |
16120 | Maximal number of boundary endpoints of case ranges of switch statement. | |
16121 | For switch exceeding this limit, IPA-CP will not construct cloning cost | |
16122 | predicate, which is used to estimate cloning benefit, for default case | |
16123 | of the switch statement. | |
16124 | ||
16125 | @item ipa-max-param-expr-ops | |
16126 | IPA-CP will analyze conditional statement that references some function | |
16127 | parameter to estimate benefit for cloning upon certain constant value. | |
16128 | But if number of operations in a parameter expression exceeds | |
16129 | @option{ipa-max-param-expr-ops}, the expression is treated as complicated | |
16130 | one, and is not handled by IPA analysis. | |
16131 | ||
16132 | @item lto-partitions | |
16133 | Specify desired number of partitions produced during WHOPR compilation. | |
16134 | The number of partitions should exceed the number of CPUs used for compilation. | |
16135 | ||
16136 | @item lto-min-partition | |
16137 | Size of minimal partition for WHOPR (in estimated instructions). | |
16138 | This prevents expenses of splitting very small programs into too many | |
16139 | partitions. | |
16140 | ||
16141 | @item lto-max-partition | |
16142 | Size of max partition for WHOPR (in estimated instructions). | |
16143 | to provide an upper bound for individual size of partition. | |
16144 | Meant to be used only with balanced partitioning. | |
16145 | ||
16146 | @item lto-max-streaming-parallelism | |
16147 | Maximal number of parallel processes used for LTO streaming. | |
16148 | ||
16149 | @item cxx-max-namespaces-for-diagnostic-help | |
16150 | The maximum number of namespaces to consult for suggestions when C++ | |
16151 | name lookup fails for an identifier. | |
16152 | ||
16153 | @item sink-frequency-threshold | |
16154 | The maximum relative execution frequency (in percents) of the target block | |
16155 | relative to a statement's original block to allow statement sinking of a | |
16156 | statement. Larger numbers result in more aggressive statement sinking. | |
16157 | A small positive adjustment is applied for | |
16158 | statements with memory operands as those are even more profitable so sink. | |
16159 | ||
16160 | @item max-stores-to-sink | |
16161 | The maximum number of conditional store pairs that can be sunk. Set to 0 | |
16162 | if either vectorization (@option{-ftree-vectorize}) or if-conversion | |
16163 | (@option{-ftree-loop-if-convert}) is disabled. | |
16164 | ||
16165 | @item case-values-threshold | |
16166 | The smallest number of different values for which it is best to use a | |
16167 | jump-table instead of a tree of conditional branches. If the value is | |
16168 | 0, use the default for the machine. | |
16169 | ||
16170 | @item jump-table-max-growth-ratio-for-size | |
16171 | The maximum code size growth ratio when expanding | |
16172 | into a jump table (in percent). The parameter is used when | |
16173 | optimizing for size. | |
16174 | ||
16175 | @item jump-table-max-growth-ratio-for-speed | |
16176 | The maximum code size growth ratio when expanding | |
16177 | into a jump table (in percent). The parameter is used when | |
16178 | optimizing for speed. | |
16179 | ||
16180 | @item tree-reassoc-width | |
16181 | Set the maximum number of instructions executed in parallel in | |
16182 | reassociated tree. This parameter overrides target dependent | |
16183 | heuristics used by default if has non zero value. | |
16184 | ||
16185 | @item sched-pressure-algorithm | |
16186 | Choose between the two available implementations of | |
16187 | @option{-fsched-pressure}. Algorithm 1 is the original implementation | |
16188 | and is the more likely to prevent instructions from being reordered. | |
16189 | Algorithm 2 was designed to be a compromise between the relatively | |
16190 | conservative approach taken by algorithm 1 and the rather aggressive | |
16191 | approach taken by the default scheduler. It relies more heavily on | |
16192 | having a regular register file and accurate register pressure classes. | |
16193 | See @file{haifa-sched.cc} in the GCC sources for more details. | |
16194 | ||
16195 | The default choice depends on the target. | |
16196 | ||
16197 | @item max-slsr-cand-scan | |
16198 | Set the maximum number of existing candidates that are considered when | |
16199 | seeking a basis for a new straight-line strength reduction candidate. | |
16200 | ||
16201 | @item asan-globals | |
16202 | Enable buffer overflow detection for global objects. This kind | |
16203 | of protection is enabled by default if you are using | |
16204 | @option{-fsanitize=address} option. | |
16205 | To disable global objects protection use @option{--param asan-globals=0}. | |
16206 | ||
16207 | @item asan-stack | |
16208 | Enable buffer overflow detection for stack objects. This kind of | |
16209 | protection is enabled by default when using @option{-fsanitize=address}. | |
16210 | To disable stack protection use @option{--param asan-stack=0} option. | |
16211 | ||
16212 | @item asan-instrument-reads | |
16213 | Enable buffer overflow detection for memory reads. This kind of | |
16214 | protection is enabled by default when using @option{-fsanitize=address}. | |
16215 | To disable memory reads protection use | |
16216 | @option{--param asan-instrument-reads=0}. | |
16217 | ||
16218 | @item asan-instrument-writes | |
16219 | Enable buffer overflow detection for memory writes. This kind of | |
16220 | protection is enabled by default when using @option{-fsanitize=address}. | |
16221 | To disable memory writes protection use | |
16222 | @option{--param asan-instrument-writes=0} option. | |
16223 | ||
16224 | @item asan-memintrin | |
16225 | Enable detection for built-in functions. This kind of protection | |
16226 | is enabled by default when using @option{-fsanitize=address}. | |
16227 | To disable built-in functions protection use | |
16228 | @option{--param asan-memintrin=0}. | |
16229 | ||
16230 | @item asan-use-after-return | |
16231 | Enable detection of use-after-return. This kind of protection | |
16232 | is enabled by default when using the @option{-fsanitize=address} option. | |
16233 | To disable it use @option{--param asan-use-after-return=0}. | |
16234 | ||
16235 | Note: By default the check is disabled at run time. To enable it, | |
16236 | add @code{detect_stack_use_after_return=1} to the environment variable | |
16237 | @env{ASAN_OPTIONS}. | |
16238 | ||
16239 | @item asan-instrumentation-with-call-threshold | |
16240 | If number of memory accesses in function being instrumented | |
16241 | is greater or equal to this number, use callbacks instead of inline checks. | |
16242 | E.g. to disable inline code use | |
16243 | @option{--param asan-instrumentation-with-call-threshold=0}. | |
16244 | ||
545c9f8b | 16245 | @item asan-kernel-mem-intrinsic-prefix |
f56ed5b3 SL |
16246 | If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove} |
16247 | with @samp{__asan_} or @samp{__hwasan_} | |
16248 | for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress}, | |
16249 | respectively. | |
545c9f8b | 16250 | |
d77de738 ML |
16251 | @item hwasan-instrument-stack |
16252 | Enable hwasan instrumentation of statically sized stack-allocated variables. | |
16253 | This kind of instrumentation is enabled by default when using | |
16254 | @option{-fsanitize=hwaddress} and disabled by default when using | |
16255 | @option{-fsanitize=kernel-hwaddress}. | |
16256 | To disable stack instrumentation use | |
16257 | @option{--param hwasan-instrument-stack=0}, and to enable it use | |
16258 | @option{--param hwasan-instrument-stack=1}. | |
16259 | ||
16260 | @item hwasan-random-frame-tag | |
16261 | When using stack instrumentation, decide tags for stack variables using a | |
16262 | deterministic sequence beginning at a random tag for each frame. With this | |
16263 | parameter unset tags are chosen using the same sequence but beginning from 1. | |
16264 | This is enabled by default for @option{-fsanitize=hwaddress} and unavailable | |
16265 | for @option{-fsanitize=kernel-hwaddress}. | |
16266 | To disable it use @option{--param hwasan-random-frame-tag=0}. | |
16267 | ||
16268 | @item hwasan-instrument-allocas | |
16269 | Enable hwasan instrumentation of dynamically sized stack-allocated variables. | |
16270 | This kind of instrumentation is enabled by default when using | |
16271 | @option{-fsanitize=hwaddress} and disabled by default when using | |
16272 | @option{-fsanitize=kernel-hwaddress}. | |
16273 | To disable instrumentation of such variables use | |
16274 | @option{--param hwasan-instrument-allocas=0}, and to enable it use | |
16275 | @option{--param hwasan-instrument-allocas=1}. | |
16276 | ||
16277 | @item hwasan-instrument-reads | |
16278 | Enable hwasan checks on memory reads. Instrumentation of reads is enabled by | |
16279 | default for both @option{-fsanitize=hwaddress} and | |
16280 | @option{-fsanitize=kernel-hwaddress}. | |
16281 | To disable checking memory reads use | |
16282 | @option{--param hwasan-instrument-reads=0}. | |
16283 | ||
16284 | @item hwasan-instrument-writes | |
16285 | Enable hwasan checks on memory writes. Instrumentation of writes is enabled by | |
16286 | default for both @option{-fsanitize=hwaddress} and | |
16287 | @option{-fsanitize=kernel-hwaddress}. | |
16288 | To disable checking memory writes use | |
16289 | @option{--param hwasan-instrument-writes=0}. | |
16290 | ||
16291 | @item hwasan-instrument-mem-intrinsics | |
16292 | Enable hwasan instrumentation of builtin functions. Instrumentation of these | |
16293 | builtin functions is enabled by default for both @option{-fsanitize=hwaddress} | |
16294 | and @option{-fsanitize=kernel-hwaddress}. | |
16295 | To disable instrumentation of builtin functions use | |
16296 | @option{--param hwasan-instrument-mem-intrinsics=0}. | |
16297 | ||
16298 | @item use-after-scope-direct-emission-threshold | |
16299 | If the size of a local variable in bytes is smaller or equal to this | |
16300 | number, directly poison (or unpoison) shadow memory instead of using | |
16301 | run-time callbacks. | |
16302 | ||
16303 | @item tsan-distinguish-volatile | |
16304 | Emit special instrumentation for accesses to volatiles. | |
16305 | ||
16306 | @item tsan-instrument-func-entry-exit | |
16307 | Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit(). | |
16308 | ||
16309 | @item max-fsm-thread-path-insns | |
16310 | Maximum number of instructions to copy when duplicating blocks on a | |
16311 | finite state automaton jump thread path. | |
16312 | ||
16313 | @item threader-debug | |
16314 | threader-debug=[none|all] Enables verbose dumping of the threader solver. | |
16315 | ||
16316 | @item parloops-chunk-size | |
16317 | Chunk size of omp schedule for loops parallelized by parloops. | |
16318 | ||
16319 | @item parloops-schedule | |
16320 | Schedule type of omp schedule for loops parallelized by parloops (static, | |
16321 | dynamic, guided, auto, runtime). | |
16322 | ||
16323 | @item parloops-min-per-thread | |
16324 | The minimum number of iterations per thread of an innermost parallelized | |
16325 | loop for which the parallelized variant is preferred over the single threaded | |
16326 | one. Note that for a parallelized loop nest the | |
16327 | minimum number of iterations of the outermost loop per thread is two. | |
16328 | ||
16329 | @item max-ssa-name-query-depth | |
16330 | Maximum depth of recursion when querying properties of SSA names in things | |
16331 | like fold routines. One level of recursion corresponds to following a | |
16332 | use-def chain. | |
16333 | ||
16334 | @item max-speculative-devirt-maydefs | |
16335 | The maximum number of may-defs we analyze when looking for a must-def | |
16336 | specifying the dynamic type of an object that invokes a virtual call | |
16337 | we may be able to devirtualize speculatively. | |
16338 | ||
d77de738 ML |
16339 | @item ranger-debug |
16340 | Specifies the type of debug output to be issued for ranges. | |
16341 | ||
d77de738 ML |
16342 | @item unroll-jam-min-percent |
16343 | The minimum percentage of memory references that must be optimized | |
16344 | away for the unroll-and-jam transformation to be considered profitable. | |
16345 | ||
16346 | @item unroll-jam-max-unroll | |
16347 | The maximum number of times the outer loop should be unrolled by | |
16348 | the unroll-and-jam transformation. | |
16349 | ||
16350 | @item max-rtl-if-conversion-unpredictable-cost | |
16351 | Maximum permissible cost for the sequence that would be generated | |
16352 | by the RTL if-conversion pass for a branch that is considered unpredictable. | |
16353 | ||
16354 | @item max-variable-expansions-in-unroller | |
16355 | If @option{-fvariable-expansion-in-unroller} is used, the maximum number | |
16356 | of times that an individual variable will be expanded during loop unrolling. | |
16357 | ||
16358 | @item partial-inlining-entry-probability | |
16359 | Maximum probability of the entry BB of split region | |
16360 | (in percent relative to entry BB of the function) | |
16361 | to make partial inlining happen. | |
16362 | ||
16363 | @item max-tracked-strlens | |
16364 | Maximum number of strings for which strlen optimization pass will | |
16365 | track string lengths. | |
16366 | ||
16367 | @item gcse-after-reload-partial-fraction | |
16368 | The threshold ratio for performing partial redundancy | |
16369 | elimination after reload. | |
16370 | ||
16371 | @item gcse-after-reload-critical-fraction | |
16372 | The threshold ratio of critical edges execution count that | |
16373 | permit performing redundancy elimination after reload. | |
16374 | ||
16375 | @item max-loop-header-insns | |
16376 | The maximum number of insns in loop header duplicated | |
16377 | by the copy loop headers pass. | |
16378 | ||
16379 | @item vect-epilogues-nomask | |
16380 | Enable loop epilogue vectorization using smaller vector size. | |
16381 | ||
16382 | @item vect-partial-vector-usage | |
16383 | Controls when the loop vectorizer considers using partial vector loads | |
16384 | and stores as an alternative to falling back to scalar code. 0 stops | |
16385 | the vectorizer from ever using partial vector loads and stores. 1 allows | |
16386 | partial vector loads and stores if vectorization removes the need for the | |
16387 | code to iterate. 2 allows partial vector loads and stores in all loops. | |
16388 | The parameter only has an effect on targets that support partial | |
16389 | vector loads and stores. | |
16390 | ||
16391 | @item vect-inner-loop-cost-factor | |
16392 | The maximum factor which the loop vectorizer applies to the cost of statements | |
16393 | in an inner loop relative to the loop being vectorized. The factor applied | |
16394 | is the maximum of the estimated number of iterations of the inner loop and | |
16395 | this parameter. The default value of this parameter is 50. | |
16396 | ||
16397 | @item vect-induction-float | |
16398 | Enable loop vectorization of floating point inductions. | |
16399 | ||
cbe32d38 ML |
16400 | @item vrp-sparse-threshold |
16401 | Maximum number of basic blocks before VRP uses a sparse bitmap cache. | |
16402 | ||
16403 | @item vrp-switch-limit | |
16404 | Maximum number of outgoing edges in a switch before VRP will not process it. | |
16405 | ||
16406 | @item vrp-vector-threshold | |
16407 | Maximum number of basic blocks for VRP to use a basic cache vector. | |
16408 | ||
d77de738 ML |
16409 | @item avoid-fma-max-bits |
16410 | Maximum number of bits for which we avoid creating FMAs. | |
16411 | ||
16412 | @item sms-loop-average-count-threshold | |
16413 | A threshold on the average loop count considered by the swing modulo scheduler. | |
16414 | ||
16415 | @item sms-dfa-history | |
16416 | The number of cycles the swing modulo scheduler considers when checking | |
16417 | conflicts using DFA. | |
16418 | ||
16419 | @item graphite-allow-codegen-errors | |
16420 | Whether codegen errors should be ICEs when @option{-fchecking}. | |
16421 | ||
16422 | @item sms-max-ii-factor | |
16423 | A factor for tuning the upper bound that swing modulo scheduler | |
16424 | uses for scheduling a loop. | |
16425 | ||
16426 | @item lra-max-considered-reload-pseudos | |
16427 | The max number of reload pseudos which are considered during | |
16428 | spilling a non-reload pseudo. | |
16429 | ||
16430 | @item max-pow-sqrt-depth | |
16431 | Maximum depth of sqrt chains to use when synthesizing exponentiation | |
16432 | by a real constant. | |
16433 | ||
16434 | @item max-dse-active-local-stores | |
16435 | Maximum number of active local stores in RTL dead store elimination. | |
16436 | ||
16437 | @item asan-instrument-allocas | |
16438 | Enable asan allocas/VLAs protection. | |
16439 | ||
16440 | @item max-iterations-computation-cost | |
16441 | Bound on the cost of an expression to compute the number of iterations. | |
16442 | ||
16443 | @item max-isl-operations | |
16444 | Maximum number of isl operations, 0 means unlimited. | |
16445 | ||
16446 | @item graphite-max-arrays-per-scop | |
16447 | Maximum number of arrays per scop. | |
16448 | ||
16449 | @item max-vartrack-reverse-op-size | |
16450 | Max. size of loc list for which reverse ops should be added. | |
16451 | ||
16452 | @item fsm-scale-path-stmts | |
16453 | Scale factor to apply to the number of statements in a threading path | |
7c9f20fc RB |
16454 | crossing a loop backedge when comparing to |
16455 | @option{--param=max-jump-thread-duplication-stmts}. | |
d77de738 ML |
16456 | |
16457 | @item uninit-control-dep-attempts | |
16458 | Maximum number of nested calls to search for control dependencies | |
16459 | during uninitialized variable analysis. | |
16460 | ||
b8a2a124 RB |
16461 | @item uninit-max-chain-len |
16462 | Maximum number of predicates anded for each predicate ored in the normalized | |
16463 | predicate chain. | |
16464 | ||
16465 | @item uninit-max-num-chains | |
16466 | Maximum number of predicates ored in the normalized predicate chain. | |
16467 | ||
d77de738 ML |
16468 | @item sched-autopref-queue-depth |
16469 | Hardware autoprefetcher scheduler model control flag. | |
16470 | Number of lookahead cycles the model looks into; at ' | |
16471 | ' only enable instruction sorting heuristic. | |
16472 | ||
16473 | @item loop-versioning-max-inner-insns | |
16474 | The maximum number of instructions that an inner loop can have | |
16475 | before the loop versioning pass considers it too big to copy. | |
16476 | ||
16477 | @item loop-versioning-max-outer-insns | |
16478 | The maximum number of instructions that an outer loop can have | |
16479 | before the loop versioning pass considers it too big to copy, | |
16480 | discounting any instructions in inner loops that directly benefit | |
16481 | from versioning. | |
16482 | ||
16483 | @item ssa-name-def-chain-limit | |
16484 | The maximum number of SSA_NAME assignments to follow in determining | |
16485 | a property of a variable such as its value. This limits the number | |
16486 | of iterations or recursive calls GCC performs when optimizing certain | |
16487 | statements or when determining their validity prior to issuing | |
16488 | diagnostics. | |
16489 | ||
16490 | @item store-merging-max-size | |
16491 | Maximum size of a single store merging region in bytes. | |
16492 | ||
16493 | @item hash-table-verification-limit | |
16494 | The number of elements for which hash table verification is done | |
16495 | for each searched element. | |
16496 | ||
16497 | @item max-find-base-term-values | |
16498 | Maximum number of VALUEs handled during a single find_base_term call. | |
16499 | ||
16500 | @item analyzer-max-enodes-per-program-point | |
16501 | The maximum number of exploded nodes per program point within | |
16502 | the analyzer, before terminating analysis of that point. | |
16503 | ||
16504 | @item analyzer-max-constraints | |
16505 | The maximum number of constraints per state. | |
16506 | ||
16507 | @item analyzer-min-snodes-for-call-summary | |
16508 | The minimum number of supernodes within a function for the | |
16509 | analyzer to consider summarizing its effects at call sites. | |
16510 | ||
16511 | @item analyzer-max-enodes-for-full-dump | |
16512 | The maximum depth of exploded nodes that should appear in a dot dump | |
16513 | before switching to a less verbose format. | |
16514 | ||
16515 | @item analyzer-max-recursion-depth | |
16516 | The maximum number of times a callsite can appear in a call stack | |
16517 | within the analyzer, before terminating analysis of a call that would | |
16518 | recurse deeper. | |
16519 | ||
16520 | @item analyzer-max-svalue-depth | |
16521 | The maximum depth of a symbolic value, before approximating | |
16522 | the value as unknown. | |
16523 | ||
16524 | @item analyzer-max-infeasible-edges | |
16525 | The maximum number of infeasible edges to reject before declaring | |
16526 | a diagnostic as infeasible. | |
16527 | ||
16528 | @item gimple-fe-computed-hot-bb-threshold | |
16529 | The number of executions of a basic block which is considered hot. | |
16530 | The parameter is used only in GIMPLE FE. | |
16531 | ||
16532 | @item analyzer-bb-explosion-factor | |
16533 | The maximum number of 'after supernode' exploded nodes within the analyzer | |
16534 | per supernode, before terminating analysis. | |
16535 | ||
c0c5a57b MJ |
16536 | @item analyzer-text-art-string-ellipsis-threshold |
16537 | The number of bytes at which to ellipsize string literals in analyzer text art diagrams. | |
16538 | ||
16539 | @item analyzer-text-art-ideal-canvas-width | |
16540 | The ideal width in characters of text art diagrams generated by the analyzer. | |
16541 | ||
16542 | @item analyzer-text-art-string-ellipsis-head-len | |
16543 | The number of literal bytes to show at the head of a string literal in text art when ellipsizing it. | |
16544 | ||
16545 | @item analyzer-text-art-string-ellipsis-tail-len | |
16546 | The number of literal bytes to show at the tail of a string literal in text art when ellipsizing it. | |
16547 | ||
d77de738 ML |
16548 | @item ranger-logical-depth |
16549 | Maximum depth of logical expression evaluation ranger will look through | |
16550 | when evaluating outgoing edge ranges. | |
16551 | ||
9fd6d83a ML |
16552 | @item ranger-recompute-depth |
16553 | Maximum depth of instruction chains to consider for recomputation | |
16554 | in the outgoing range calculator. | |
16555 | ||
d77de738 ML |
16556 | @item relation-block-limit |
16557 | Maximum number of relations the oracle will register in a basic block. | |
16558 | ||
16559 | @item min-pagesize | |
16560 | Minimum page size for warning purposes. | |
16561 | ||
16562 | @item openacc-kernels | |
16563 | Specify mode of OpenACC `kernels' constructs handling. | |
16564 | With @option{--param=openacc-kernels=decompose}, OpenACC `kernels' | |
16565 | constructs are decomposed into parts, a sequence of compute | |
16566 | constructs, each then handled individually. | |
16567 | This is work in progress. | |
16568 | With @option{--param=openacc-kernels=parloops}, OpenACC `kernels' | |
16569 | constructs are handled by the @samp{parloops} pass, en bloc. | |
16570 | This is the current default. | |
16571 | ||
16572 | @item openacc-privatization | |
4ace81b6 SL |
16573 | Control whether the @option{-fopt-info-omp-note} and applicable |
16574 | @option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics. | |
d77de738 ML |
16575 | With @option{--param=openacc-privatization=quiet}, don't diagnose. |
16576 | This is the current default. | |
16577 | With @option{--param=openacc-privatization=noisy}, do diagnose. | |
16578 | ||
16579 | @end table | |
16580 | ||
16581 | The following choices of @var{name} are available on AArch64 targets: | |
16582 | ||
16583 | @table @gcctabopt | |
16584 | @item aarch64-sve-compare-costs | |
16585 | When vectorizing for SVE, consider using ``unpacked'' vectors for | |
16586 | smaller elements and use the cost model to pick the cheapest approach. | |
16587 | Also use the cost model to choose between SVE and Advanced SIMD vectorization. | |
16588 | ||
16589 | Using unpacked vectors includes storing smaller elements in larger | |
16590 | containers and accessing elements with extending loads and truncating | |
16591 | stores. | |
16592 | ||
16593 | @item aarch64-float-recp-precision | |
16594 | The number of Newton iterations for calculating the reciprocal for float type. | |
16595 | The precision of division is proportional to this param when division | |
16596 | approximation is enabled. The default value is 1. | |
16597 | ||
16598 | @item aarch64-double-recp-precision | |
16599 | The number of Newton iterations for calculating the reciprocal for double type. | |
16600 | The precision of division is propotional to this param when division | |
16601 | approximation is enabled. The default value is 2. | |
16602 | ||
16603 | @item aarch64-autovec-preference | |
16604 | Force an ISA selection strategy for auto-vectorization. Accepts values from | |
16605 | 0 to 4, inclusive. | |
16606 | @table @samp | |
16607 | @item 0 | |
16608 | Use the default heuristics. | |
16609 | @item 1 | |
16610 | Use only Advanced SIMD for auto-vectorization. | |
16611 | @item 2 | |
16612 | Use only SVE for auto-vectorization. | |
16613 | @item 3 | |
16614 | Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are | |
16615 | deemed equal. | |
16616 | @item 4 | |
16617 | Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal. | |
16618 | @end table | |
16619 | The default value is 0. | |
16620 | ||
834fc2bf MA |
16621 | @item aarch64-ldp-policy |
16622 | Fine-grained policy for load pairs. | |
16623 | With @option{--param=aarch64-ldp-policy=default}, use the policy of the | |
16624 | tuning structure. This is the current default. | |
16625 | With @option{--param=aarch64-ldp-policy=always}, emit ldp regardless | |
16626 | of alignment. | |
16627 | With @option{--param=aarch64-ldp-policy=never}, do not emit ldp. | |
16628 | With @option{--param=aarch64-ldp-policy=aligned}, emit ldp only if the | |
16629 | source pointer is aligned to at least double the alignment of the type. | |
16630 | ||
16631 | @item aarch64-stp-policy | |
16632 | Fine-grained policy for store pairs. | |
16633 | With @option{--param=aarch64-stp-policy=default}, use the policy of the | |
16634 | tuning structure. This is the current default. | |
16635 | With @option{--param=aarch64-stp-policy=always}, emit stp regardless | |
16636 | of alignment. | |
16637 | With @option{--param=aarch64-stp-policy=never}, do not emit stp. | |
16638 | With @option{--param=aarch64-stp-policy=aligned}, emit stp only if the | |
16639 | source pointer is aligned to at least double the alignment of the type. | |
16640 | ||
d77de738 ML |
16641 | @item aarch64-loop-vect-issue-rate-niters |
16642 | The tuning for some AArch64 CPUs tries to take both latencies and issue | |
16643 | rates into account when deciding whether a loop should be vectorized | |
16644 | using SVE, vectorized using Advanced SIMD, or not vectorized at all. | |
16645 | If this parameter is set to @var{n}, GCC will not use this heuristic | |
16646 | for loops that are known to execute in fewer than @var{n} Advanced | |
16647 | SIMD iterations. | |
16648 | ||
16649 | @item aarch64-vect-unroll-limit | |
16650 | The vectorizer will use available tuning information to determine whether it | |
16651 | would be beneficial to unroll the main vectorized loop and by how much. This | |
16652 | parameter set's the upper bound of how much the vectorizer will unroll the main | |
16653 | loop. The default value is four. | |
16654 | ||
16655 | @end table | |
16656 | ||
16657 | The following choices of @var{name} are available on i386 and x86_64 targets: | |
16658 | ||
16659 | @table @gcctabopt | |
16660 | @item x86-stlf-window-ninsns | |
16661 | Instructions number above which STFL stall penalty can be compensated. | |
16662 | ||
60101899 RB |
16663 | @item x86-stv-max-visits |
16664 | The maximum number of use and def visits when discovering a STV chain before | |
16665 | the discovery is aborted. | |
16666 | ||
d77de738 ML |
16667 | @end table |
16668 | ||
16669 | @end table | |
16670 | ||
16671 | @node Instrumentation Options | |
16672 | @section Program Instrumentation Options | |
16673 | @cindex instrumentation options | |
16674 | @cindex program instrumentation options | |
16675 | @cindex run-time error checking options | |
16676 | @cindex profiling options | |
16677 | @cindex options, program instrumentation | |
16678 | @cindex options, run-time error checking | |
16679 | @cindex options, profiling | |
16680 | ||
16681 | GCC supports a number of command-line options that control adding | |
16682 | run-time instrumentation to the code it normally generates. | |
16683 | For example, one purpose of instrumentation is collect profiling | |
16684 | statistics for use in finding program hot spots, code coverage | |
16685 | analysis, or profile-guided optimizations. | |
16686 | Another class of program instrumentation is adding run-time checking | |
16687 | to detect programming errors like invalid pointer | |
16688 | dereferences or out-of-bounds array accesses, as well as deliberately | |
16689 | hostile attacks such as stack smashing or C++ vtable hijacking. | |
16690 | There is also a general hook which can be used to implement other | |
16691 | forms of tracing or function-level instrumentation for debug or | |
16692 | program analysis purposes. | |
16693 | ||
16694 | @table @gcctabopt | |
16695 | @cindex @command{prof} | |
16696 | @cindex @command{gprof} | |
d77de738 ML |
16697 | @opindex p |
16698 | @opindex pg | |
ddf6fe37 AA |
16699 | @item -p |
16700 | @itemx -pg | |
d77de738 ML |
16701 | Generate extra code to write profile information suitable for the |
16702 | analysis program @command{prof} (for @option{-p}) or @command{gprof} | |
16703 | (for @option{-pg}). You must use this option when compiling | |
16704 | the source files you want data about, and you must also use it when | |
16705 | linking. | |
16706 | ||
16707 | You can use the function attribute @code{no_instrument_function} to | |
16708 | suppress profiling of individual functions when compiling with these options. | |
16709 | @xref{Common Function Attributes}. | |
16710 | ||
d77de738 | 16711 | @opindex fprofile-arcs |
ddf6fe37 | 16712 | @item -fprofile-arcs |
d77de738 ML |
16713 | Add code so that program flow @dfn{arcs} are instrumented. During |
16714 | execution the program records how many times each branch and call is | |
16715 | executed and how many times it is taken or returns. On targets that support | |
16716 | constructors with priority support, profiling properly handles constructors, | |
16717 | destructors and C++ constructors (and destructors) of classes which are used | |
16718 | as a type of a global variable. | |
16719 | ||
16720 | When the compiled | |
16721 | program exits it saves this data to a file called | |
16722 | @file{@var{auxname}.gcda} for each source file. The data may be used for | |
16723 | profile-directed optimizations (@option{-fbranch-probabilities}), or for | |
16724 | test coverage analysis (@option{-ftest-coverage}). Each object file's | |
16725 | @var{auxname} is generated from the name of the output file, if | |
16726 | explicitly specified and it is not the final executable, otherwise it is | |
16727 | the basename of the source file. In both cases any suffix is removed | |
16728 | (e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or | |
16729 | @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}). | |
16730 | ||
16731 | Note that if a command line directly links source files, the corresponding | |
16732 | @var{.gcda} files will be prefixed with the unsuffixed name of the output file. | |
16733 | E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and | |
16734 | @file{binary-b.gcda} files. | |
16735 | ||
16736 | @xref{Cross-profiling}. | |
16737 | ||
16738 | @cindex @command{gcov} | |
d77de738 | 16739 | @opindex coverage |
ddf6fe37 | 16740 | @item --coverage |
d77de738 ML |
16741 | |
16742 | This option is used to compile and link code instrumented for coverage | |
16743 | analysis. The option is a synonym for @option{-fprofile-arcs} | |
16744 | @option{-ftest-coverage} (when compiling) and @option{-lgcov} (when | |
16745 | linking). See the documentation for those options for more details. | |
16746 | ||
16747 | @itemize | |
16748 | ||
16749 | @item | |
16750 | Compile the source files with @option{-fprofile-arcs} plus optimization | |
16751 | and code generation options. For test coverage analysis, use the | |
16752 | additional @option{-ftest-coverage} option. You do not need to profile | |
16753 | every source file in a program. | |
16754 | ||
16755 | @item | |
16756 | Compile the source files additionally with @option{-fprofile-abs-path} | |
16757 | to create absolute path names in the @file{.gcno} files. This allows | |
16758 | @command{gcov} to find the correct sources in projects where compilations | |
16759 | occur with different working directories. | |
16760 | ||
16761 | @item | |
16762 | Link your object files with @option{-lgcov} or @option{-fprofile-arcs} | |
16763 | (the latter implies the former). | |
16764 | ||
16765 | @item | |
16766 | Run the program on a representative workload to generate the arc profile | |
16767 | information. This may be repeated any number of times. You can run | |
16768 | concurrent instances of your program, and provided that the file system | |
16769 | supports locking, the data files will be correctly updated. Unless | |
16770 | a strict ISO C dialect option is in effect, @code{fork} calls are | |
16771 | detected and correctly handled without double counting. | |
16772 | ||
16773 | Moreover, an object file can be recompiled multiple times | |
16774 | and the corresponding @file{.gcda} file merges as long as | |
16775 | the source file and the compiler options are unchanged. | |
16776 | ||
16777 | @item | |
16778 | For profile-directed optimizations, compile the source files again with | |
16779 | the same optimization and code generation options plus | |
16780 | @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that | |
16781 | Control Optimization}). | |
16782 | ||
16783 | @item | |
16784 | For test coverage analysis, use @command{gcov} to produce human readable | |
16785 | information from the @file{.gcno} and @file{.gcda} files. Refer to the | |
16786 | @command{gcov} documentation for further information. | |
16787 | ||
16788 | @end itemize | |
16789 | ||
16790 | With @option{-fprofile-arcs}, for each function of your program GCC | |
16791 | creates a program flow graph, then finds a spanning tree for the graph. | |
16792 | Only arcs that are not on the spanning tree have to be instrumented: the | |
16793 | compiler adds code to count the number of times that these arcs are | |
16794 | executed. When an arc is the only exit or only entrance to a block, the | |
16795 | instrumentation code can be added to the block; otherwise, a new basic | |
16796 | block must be created to hold the instrumentation code. | |
16797 | ||
16798 | @need 2000 | |
d77de738 | 16799 | @opindex ftest-coverage |
ddf6fe37 | 16800 | @item -ftest-coverage |
d77de738 ML |
16801 | Produce a notes file that the @command{gcov} code-coverage utility |
16802 | (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to | |
16803 | show program coverage. Each source file's note file is called | |
16804 | @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option | |
16805 | above for a description of @var{auxname} and instructions on how to | |
16806 | generate test coverage data. Coverage data matches the source files | |
16807 | more closely if you do not optimize. | |
16808 | ||
d77de738 | 16809 | @opindex fprofile-abs-path |
ddf6fe37 | 16810 | @item -fprofile-abs-path |
d77de738 ML |
16811 | Automatically convert relative source file names to absolute path names |
16812 | in the @file{.gcno} files. This allows @command{gcov} to find the correct | |
16813 | sources in projects where compilations occur with different working | |
16814 | directories. | |
16815 | ||
d77de738 | 16816 | @opindex fprofile-dir |
ddf6fe37 | 16817 | @item -fprofile-dir=@var{path} |
d77de738 ML |
16818 | |
16819 | Set the directory to search for the profile data files in to @var{path}. | |
16820 | This option affects only the profile data generated by | |
16821 | @option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs} | |
16822 | and used by @option{-fprofile-use} and @option{-fbranch-probabilities} | |
16823 | and its related options. Both absolute and relative paths can be used. | |
16824 | By default, GCC uses the current directory as @var{path}, thus the | |
16825 | profile data file appears in the same directory as the object file. | |
16826 | In order to prevent the file name clashing, if the object file name is | |
16827 | not an absolute path, we mangle the absolute path of the | |
16828 | @file{@var{sourcename}.gcda} file and use it as the file name of a | |
16829 | @file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}. | |
16830 | See similar option @option{-fprofile-note}. | |
16831 | ||
16832 | When an executable is run in a massive parallel environment, it is recommended | |
16833 | to save profile to different folders. That can be done with variables | |
16834 | in @var{path} that are exported during run-time: | |
16835 | ||
16836 | @table @gcctabopt | |
16837 | ||
16838 | @item %p | |
16839 | process ID. | |
16840 | ||
16841 | @item %q@{VAR@} | |
16842 | value of environment variable @var{VAR} | |
16843 | ||
16844 | @end table | |
16845 | ||
ddf6fe37 | 16846 | @opindex fprofile-generate |
d77de738 ML |
16847 | @item -fprofile-generate |
16848 | @itemx -fprofile-generate=@var{path} | |
d77de738 ML |
16849 | |
16850 | Enable options usually used for instrumenting application to produce | |
16851 | profile useful for later recompilation with profile feedback based | |
16852 | optimization. You must use @option{-fprofile-generate} both when | |
16853 | compiling and when linking your program. | |
16854 | ||
16855 | The following options are enabled: | |
16856 | @option{-fprofile-arcs}, @option{-fprofile-values}, | |
16857 | @option{-finline-functions}, and @option{-fipa-bit-cp}. | |
16858 | ||
16859 | If @var{path} is specified, GCC looks at the @var{path} to find | |
16860 | the profile feedback data files. See @option{-fprofile-dir}. | |
16861 | ||
16862 | To optimize the program based on the collected profile information, use | |
16863 | @option{-fprofile-use}. @xref{Optimize Options}, for more information. | |
16864 | ||
ddf6fe37 | 16865 | @opindex fprofile-info-section |
d77de738 ML |
16866 | @item -fprofile-info-section |
16867 | @itemx -fprofile-info-section=@var{name} | |
d77de738 ML |
16868 | |
16869 | Register the profile information in the specified section instead of using a | |
16870 | constructor/destructor. The section name is @var{name} if it is specified, | |
16871 | otherwise the section name defaults to @code{.gcov_info}. A pointer to the | |
16872 | profile information generated by @option{-fprofile-arcs} is placed in the | |
16873 | specified section for each translation unit. This option disables the profile | |
16874 | information registration through a constructor and it disables the profile | |
16875 | information processing through a destructor. This option is not intended to be | |
16876 | used in hosted environments such as GNU/Linux. It targets freestanding | |
16877 | environments (for example embedded systems) with limited resources which do not | |
16878 | support constructors/destructors or the C library file I/O. | |
16879 | ||
16880 | The linker could collect the input sections in a continuous memory block and | |
16881 | define start and end symbols. A GNU linker script example which defines a | |
16882 | linker output section follows: | |
16883 | ||
16884 | @smallexample | |
16885 | .gcov_info : | |
16886 | @{ | |
16887 | PROVIDE (__gcov_info_start = .); | |
16888 | KEEP (*(.gcov_info)) | |
16889 | PROVIDE (__gcov_info_end = .); | |
16890 | @} | |
16891 | @end smallexample | |
16892 | ||
16893 | The program could dump the profiling information registered in this linker set | |
16894 | for example like this: | |
16895 | ||
16896 | @smallexample | |
16897 | #include <gcov.h> | |
16898 | #include <stdio.h> | |
16899 | #include <stdlib.h> | |
16900 | ||
16901 | extern const struct gcov_info *const __gcov_info_start[]; | |
16902 | extern const struct gcov_info *const __gcov_info_end[]; | |
16903 | ||
16904 | static void | |
16905 | dump (const void *d, unsigned n, void *arg) | |
16906 | @{ | |
16907 | const unsigned char *c = d; | |
16908 | ||
16909 | for (unsigned i = 0; i < n; ++i) | |
16910 | printf ("%02x", c[i]); | |
16911 | @} | |
16912 | ||
16913 | static void | |
16914 | filename (const char *f, void *arg) | |
16915 | @{ | |
16916 | __gcov_filename_to_gcfn (f, dump, arg ); | |
16917 | @} | |
16918 | ||
16919 | static void * | |
16920 | allocate (unsigned length, void *arg) | |
16921 | @{ | |
16922 | return malloc (length); | |
16923 | @} | |
16924 | ||
16925 | static void | |
16926 | dump_gcov_info (void) | |
16927 | @{ | |
16928 | const struct gcov_info *const *info = __gcov_info_start; | |
16929 | const struct gcov_info *const *end = __gcov_info_end; | |
16930 | ||
16931 | /* Obfuscate variable to prevent compiler optimizations. */ | |
16932 | __asm__ ("" : "+r" (info)); | |
16933 | ||
16934 | while (info != end) | |
16935 | @{ | |
16936 | void *arg = NULL; | |
16937 | __gcov_info_to_gcda (*info, filename, dump, allocate, arg); | |
16938 | putchar ('\n'); | |
16939 | ++info; | |
16940 | @} | |
16941 | @} | |
16942 | ||
16943 | int | |
16944 | main (void) | |
16945 | @{ | |
16946 | dump_gcov_info (); | |
16947 | return 0; | |
16948 | @} | |
16949 | @end smallexample | |
16950 | ||
16951 | The @command{merge-stream} subcommand of @command{gcov-tool} may be used to | |
16952 | deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and | |
16953 | @code{__gcov_info_to_gcda} functions and merge the profile information into | |
16954 | @file{.gcda} files on the host filesystem. | |
16955 | ||
d77de738 | 16956 | @opindex fprofile-note |
ddf6fe37 | 16957 | @item -fprofile-note=@var{path} |
d77de738 ML |
16958 | |
16959 | If @var{path} is specified, GCC saves @file{.gcno} file into @var{path} | |
16960 | location. If you combine the option with multiple source files, | |
16961 | the @file{.gcno} file will be overwritten. | |
16962 | ||
d77de738 | 16963 | @opindex fprofile-prefix-path |
ddf6fe37 | 16964 | @item -fprofile-prefix-path=@var{path} |
d77de738 ML |
16965 | |
16966 | This option can be used in combination with | |
16967 | @option{profile-generate=}@var{profile_dir} and | |
16968 | @option{profile-use=}@var{profile_dir} to inform GCC where is the base | |
16969 | directory of built source tree. By default @var{profile_dir} will contain | |
16970 | files with mangled absolute paths of all object files in the built project. | |
16971 | This is not desirable when directory used to build the instrumented binary | |
16972 | differs from the directory used to build the binary optimized with profile | |
16973 | feedback because the profile data will not be found during the optimized build. | |
16974 | In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path} | |
16975 | pointing to the base directory of the build can be used to strip the irrelevant | |
16976 | part of the path and keep all file names relative to the main build directory. | |
16977 | ||
d77de738 | 16978 | @opindex fprofile-prefix-map |
ddf6fe37 | 16979 | @item -fprofile-prefix-map=@var{old}=@var{new} |
d77de738 ML |
16980 | When compiling files residing in directory @file{@var{old}}, record |
16981 | profiling information (with @option{--coverage}) | |
16982 | describing them as if the files resided in | |
16983 | directory @file{@var{new}} instead. | |
2eb0191a | 16984 | See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}. |
d77de738 | 16985 | |
d77de738 | 16986 | @opindex fprofile-update |
ddf6fe37 | 16987 | @item -fprofile-update=@var{method} |
d77de738 ML |
16988 | |
16989 | Alter the update method for an application instrumented for profile | |
16990 | feedback based optimization. The @var{method} argument should be one of | |
16991 | @samp{single}, @samp{atomic} or @samp{prefer-atomic}. | |
16992 | The first one is useful for single-threaded applications, | |
16993 | while the second one prevents profile corruption by emitting thread-safe code. | |
16994 | ||
16995 | @strong{Warning:} When an application does not properly join all threads | |
16996 | (or creates an detached thread), a profile file can be still corrupted. | |
16997 | ||
16998 | Using @samp{prefer-atomic} would be transformed either to @samp{atomic}, | |
16999 | when supported by a target, or to @samp{single} otherwise. The GCC driver | |
17000 | automatically selects @samp{prefer-atomic} when @option{-pthread} | |
20a3c74c SH |
17001 | is present in the command line, otherwise the default method is @samp{single}. |
17002 | ||
17003 | If @samp{atomic} is selected, then the profile information is updated using | |
17004 | atomic operations on a best-effort basis. Ideally, the profile information is | |
17005 | updated through atomic operations in hardware. If the target platform does not | |
17006 | support the required atomic operations in hardware, however, @file{libatomic} | |
17007 | is available, then the profile information is updated through calls to | |
17008 | @file{libatomic}. If the target platform neither supports the required atomic | |
17009 | operations in hardware nor @file{libatomic}, then the profile information is | |
17010 | not atomically updated and a warning is issued. In this case, the obtained | |
17011 | profiling information may be corrupt for multi-threaded applications. | |
17012 | ||
17013 | For performance reasons, if 64-bit counters are used for the profiling | |
17014 | information and the target platform only supports 32-bit atomic operations in | |
17015 | hardware, then the performance critical profiling updates are done using two | |
17016 | 32-bit atomic operations for each counter update. If a signal interrupts these | |
17017 | two operations updating a counter, then the profiling information may be in an | |
17018 | inconsistent state. | |
d77de738 | 17019 | |
d77de738 | 17020 | @opindex fprofile-filter-files |
ddf6fe37 | 17021 | @item -fprofile-filter-files=@var{regex} |
d77de738 ML |
17022 | |
17023 | Instrument only functions from files whose name matches | |
17024 | any of the regular expressions (separated by semi-colons). | |
17025 | ||
17026 | For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument | |
17027 | only @file{main.c} and all C files starting with 'module'. | |
17028 | ||
d77de738 | 17029 | @opindex fprofile-exclude-files |
ddf6fe37 | 17030 | @item -fprofile-exclude-files=@var{regex} |
d77de738 ML |
17031 | |
17032 | Instrument only functions from files whose name does not match | |
17033 | any of the regular expressions (separated by semi-colons). | |
17034 | ||
17035 | For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation | |
17036 | of all files that are located in the @file{/usr/} folder. | |
17037 | ||
d77de738 | 17038 | @opindex fprofile-reproducible |
ddf6fe37 | 17039 | @item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} |
d77de738 ML |
17040 | Control level of reproducibility of profile gathered by |
17041 | @code{-fprofile-generate}. This makes it possible to rebuild program | |
17042 | with same outcome which is useful, for example, for distribution | |
17043 | packages. | |
17044 | ||
17045 | With @option{-fprofile-reproducible=serial} the profile gathered by | |
17046 | @option{-fprofile-generate} is reproducible provided the trained program | |
17047 | behaves the same at each invocation of the train run, it is not | |
17048 | multi-threaded and profile data streaming is always done in the same | |
17049 | order. Note that profile streaming happens at the end of program run but | |
17050 | also before @code{fork} function is invoked. | |
17051 | ||
17052 | Note that it is quite common that execution counts of some part of | |
17053 | programs depends, for example, on length of temporary file names or | |
17054 | memory space randomization (that may affect hash-table collision rate). | |
17055 | Such non-reproducible part of programs may be annotated by | |
17056 | @code{no_instrument_function} function attribute. @command{gcov-dump} with | |
17057 | @option{-l} can be used to dump gathered data and verify that they are | |
17058 | indeed reproducible. | |
17059 | ||
17060 | With @option{-fprofile-reproducible=parallel-runs} collected profile | |
17061 | stays reproducible regardless the order of streaming of the data into | |
17062 | gcda files. This setting makes it possible to run multiple instances of | |
17063 | instrumented program in parallel (such as with @code{make -j}). This | |
17064 | reduces quality of gathered data, in particular of indirect call | |
17065 | profiling. | |
17066 | ||
d77de738 | 17067 | @opindex fsanitize=address |
ddf6fe37 | 17068 | @item -fsanitize=address |
d77de738 ML |
17069 | Enable AddressSanitizer, a fast memory error detector. |
17070 | Memory access instructions are instrumented to detect | |
17071 | out-of-bounds and use-after-free bugs. | |
17072 | The option enables @option{-fsanitize-address-use-after-scope}. | |
17073 | See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for | |
17074 | more details. The run-time behavior can be influenced using the | |
17075 | @env{ASAN_OPTIONS} environment variable. When set to @code{help=1}, | |
17076 | the available options are shown at startup of the instrumented program. See | |
17077 | @url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags} | |
17078 | for a list of supported options. | |
17079 | The option cannot be combined with @option{-fsanitize=thread} or | |
17080 | @option{-fsanitize=hwaddress}. Note that the only target | |
17081 | @option{-fsanitize=hwaddress} is currently supported on is AArch64. | |
17082 | ||
6a07798c MP |
17083 | To get more accurate stack traces, it is possible to use options such as |
17084 | @option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent | |
17085 | most function inlining), @option{-fno-optimize-sibling-calls} (which prevents | |
17086 | optimizing sibling and tail recursive calls; this option is implicit for | |
17087 | @option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which | |
17088 | disables Identical Code Folding for functions). Since multiple runs of the | |
17089 | program may yield backtraces with different addresses due to ASLR (Address | |
17090 | Space Layout Randomization), it may be desirable to turn ASLR off. On Linux, | |
17091 | this can be achieved with @samp{setarch `uname -m` -R ./prog}. | |
17092 | ||
d77de738 | 17093 | @opindex fsanitize=kernel-address |
f33d7a88 | 17094 | @item -fsanitize=kernel-address |
d77de738 | 17095 | Enable AddressSanitizer for Linux kernel. |
a0bf71be | 17096 | See @uref{https://github.com/google/kernel-sanitizers} for more details. |
d77de738 | 17097 | |
d77de738 | 17098 | @opindex fsanitize=hwaddress |
f33d7a88 | 17099 | @item -fsanitize=hwaddress |
d77de738 ML |
17100 | Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to |
17101 | ignore the top byte of a pointer to allow the detection of memory errors with | |
17102 | a low memory overhead. | |
17103 | Memory access instructions are instrumented to detect out-of-bounds and | |
17104 | use-after-free bugs. | |
17105 | The option enables @option{-fsanitize-address-use-after-scope}. | |
17106 | See | |
17107 | @uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html} | |
17108 | for more details. The run-time behavior can be influenced using the | |
17109 | @env{HWASAN_OPTIONS} environment variable. When set to @code{help=1}, | |
17110 | the available options are shown at startup of the instrumented program. | |
17111 | The option cannot be combined with @option{-fsanitize=thread} or | |
17112 | @option{-fsanitize=address}, and is currently only available on AArch64. | |
17113 | ||
d77de738 | 17114 | @opindex fsanitize=kernel-hwaddress |
ddf6fe37 | 17115 | @item -fsanitize=kernel-hwaddress |
d77de738 ML |
17116 | Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel. |
17117 | Similar to @option{-fsanitize=kernel-address} but using an alternate | |
17118 | instrumentation method, and similar to @option{-fsanitize=hwaddress} but with | |
17119 | instrumentation differences necessary for compiling the Linux kernel. | |
17120 | These differences are to avoid hwasan library initialization calls and to | |
17121 | account for the stack pointer having a different value in its top byte. | |
17122 | ||
17123 | @emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}. | |
17124 | Instrumenting the stack and alloca calls are not on by default but are still | |
17125 | possible by specifying the command-line options | |
17126 | @option{--param hwasan-instrument-stack=1} and | |
17127 | @option{--param hwasan-instrument-allocas=1} respectively. Using a random frame | |
17128 | tag is not implemented for kernel instrumentation. | |
17129 | ||
d77de738 | 17130 | @opindex fsanitize=pointer-compare |
ddf6fe37 | 17131 | @item -fsanitize=pointer-compare |
d77de738 ML |
17132 | Instrument comparison operation (<, <=, >, >=) with pointer operands. |
17133 | The option must be combined with either @option{-fsanitize=kernel-address} or | |
17134 | @option{-fsanitize=address} | |
17135 | The option cannot be combined with @option{-fsanitize=thread}. | |
17136 | Note: By default the check is disabled at run time. To enable it, | |
17137 | add @code{detect_invalid_pointer_pairs=2} to the environment variable | |
17138 | @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects | |
17139 | invalid operation only when both pointers are non-null. | |
17140 | ||
d77de738 | 17141 | @opindex fsanitize=pointer-subtract |
ddf6fe37 | 17142 | @item -fsanitize=pointer-subtract |
d77de738 ML |
17143 | Instrument subtraction with pointer operands. |
17144 | The option must be combined with either @option{-fsanitize=kernel-address} or | |
17145 | @option{-fsanitize=address} | |
17146 | The option cannot be combined with @option{-fsanitize=thread}. | |
17147 | Note: By default the check is disabled at run time. To enable it, | |
17148 | add @code{detect_invalid_pointer_pairs=2} to the environment variable | |
17149 | @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects | |
17150 | invalid operation only when both pointers are non-null. | |
17151 | ||
d77de738 | 17152 | @opindex fsanitize=shadow-call-stack |
ddf6fe37 | 17153 | @item -fsanitize=shadow-call-stack |
d77de738 ML |
17154 | Enable ShadowCallStack, a security enhancement mechanism used to protect |
17155 | programs against return address overwrites (e.g. stack buffer overflows.) | |
17156 | It works by saving a function's return address to a separately allocated | |
17157 | shadow call stack in the function prologue and restoring the return address | |
17158 | from the shadow call stack in the function epilogue. Instrumentation only | |
17159 | occurs in functions that need to save the return address to the stack. | |
17160 | ||
17161 | Currently it only supports the aarch64 platform. It is specifically | |
17162 | designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option. | |
17163 | For the user space programs, runtime support is not currently provided | |
17164 | in libc and libgcc. Users who want to use this feature in user space need | |
17165 | to provide their own support for the runtime. It should be noted that | |
17166 | this may cause the ABI rules to be broken. | |
17167 | ||
17168 | On aarch64, the instrumentation makes use of the platform register @code{x18}. | |
17169 | This generally means that any code that may run on the same thread as code | |
17170 | compiled with ShadowCallStack must be compiled with the flag | |
17171 | @option{-ffixed-x18}, otherwise functions compiled without | |
17172 | @option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow | |
17173 | stack pointer. | |
17174 | ||
17175 | Also, because there is no userspace runtime support, code compiled with | |
17176 | ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions} | |
17177 | to turn off exceptions. | |
17178 | ||
17179 | See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more | |
17180 | details. | |
17181 | ||
d77de738 | 17182 | @opindex fsanitize=thread |
ddf6fe37 | 17183 | @item -fsanitize=thread |
d77de738 ML |
17184 | Enable ThreadSanitizer, a fast data race detector. |
17185 | Memory access instructions are instrumented to detect | |
17186 | data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more | |
17187 | details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS} | |
17188 | environment variable; see | |
17189 | @url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of | |
17190 | supported options. | |
17191 | The option cannot be combined with @option{-fsanitize=address}, | |
17192 | @option{-fsanitize=leak}. | |
17193 | ||
17194 | Note that sanitized atomic builtins cannot throw exceptions when | |
17195 | operating on invalid memory addresses with non-call exceptions | |
17196 | (@option{-fnon-call-exceptions}). | |
17197 | ||
d77de738 | 17198 | @opindex fsanitize=leak |
ddf6fe37 | 17199 | @item -fsanitize=leak |
d77de738 | 17200 | Enable LeakSanitizer, a memory leak detector. |
c5c4fdac JG |
17201 | This option only matters for linking of executables. |
17202 | The executable is linked against a library that overrides @code{malloc} | |
d77de738 ML |
17203 | and other allocator functions. See |
17204 | @uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more | |
17205 | details. The run-time behavior can be influenced using the | |
17206 | @env{LSAN_OPTIONS} environment variable. | |
17207 | The option cannot be combined with @option{-fsanitize=thread}. | |
17208 | ||
d77de738 | 17209 | @opindex fsanitize=undefined |
ddf6fe37 | 17210 | @item -fsanitize=undefined |
d77de738 ML |
17211 | Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector. |
17212 | Various computations are instrumented to detect undefined behavior | |
17213 | at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the | |
17214 | @env{UBSAN_OPTIONS} environment variable. Current suboptions are: | |
17215 | ||
17216 | @table @gcctabopt | |
17217 | ||
d77de738 | 17218 | @opindex fsanitize=shift |
ddf6fe37 | 17219 | @item -fsanitize=shift |
d77de738 ML |
17220 | This option enables checking that the result of a shift operation is |
17221 | not undefined. Note that what exactly is considered undefined differs | |
17222 | slightly between C and C++, as well as between ISO C90 and C99, etc. | |
17223 | This option has two suboptions, @option{-fsanitize=shift-base} and | |
17224 | @option{-fsanitize=shift-exponent}. | |
17225 | ||
d77de738 | 17226 | @opindex fsanitize=shift-exponent |
ddf6fe37 | 17227 | @item -fsanitize=shift-exponent |
d77de738 ML |
17228 | This option enables checking that the second argument of a shift operation |
17229 | is not negative and is smaller than the precision of the promoted first | |
17230 | argument. | |
17231 | ||
d77de738 | 17232 | @opindex fsanitize=shift-base |
ddf6fe37 | 17233 | @item -fsanitize=shift-base |
d77de738 ML |
17234 | If the second argument of a shift operation is within range, check that the |
17235 | result of a shift operation is not undefined. Note that what exactly is | |
17236 | considered undefined differs slightly between C and C++, as well as between | |
17237 | ISO C90 and C99, etc. | |
17238 | ||
d77de738 | 17239 | @opindex fsanitize=integer-divide-by-zero |
ddf6fe37 | 17240 | @item -fsanitize=integer-divide-by-zero |
d77de738 ML |
17241 | Detect integer division by zero. |
17242 | ||
d77de738 | 17243 | @opindex fsanitize=unreachable |
ddf6fe37 | 17244 | @item -fsanitize=unreachable |
d77de738 ML |
17245 | With this option, the compiler turns the @code{__builtin_unreachable} |
17246 | call into a diagnostics message call instead. When reaching the | |
17247 | @code{__builtin_unreachable} call, the behavior is undefined. | |
17248 | ||
d77de738 | 17249 | @opindex fsanitize=vla-bound |
ddf6fe37 | 17250 | @item -fsanitize=vla-bound |
d77de738 ML |
17251 | This option instructs the compiler to check that the size of a variable |
17252 | length array is positive. | |
17253 | ||
d77de738 | 17254 | @opindex fsanitize=null |
ddf6fe37 | 17255 | @item -fsanitize=null |
d77de738 ML |
17256 | This option enables pointer checking. Particularly, the application |
17257 | built with this option turned on will issue an error message when it | |
17258 | tries to dereference a NULL pointer, or if a reference (possibly an | |
17259 | rvalue reference) is bound to a NULL pointer, or if a method is invoked | |
17260 | on an object pointed by a NULL pointer. | |
17261 | ||
d77de738 | 17262 | @opindex fsanitize=return |
ddf6fe37 | 17263 | @item -fsanitize=return |
d77de738 ML |
17264 | This option enables return statement checking. Programs |
17265 | built with this option turned on will issue an error message | |
17266 | when the end of a non-void function is reached without actually | |
17267 | returning a value. This option works in C++ only. | |
17268 | ||
d77de738 | 17269 | @opindex fsanitize=signed-integer-overflow |
ddf6fe37 | 17270 | @item -fsanitize=signed-integer-overflow |
d77de738 ML |
17271 | This option enables signed integer overflow checking. We check that |
17272 | the result of @code{+}, @code{*}, and both unary and binary @code{-} | |
17273 | does not overflow in the signed arithmetics. This also detects | |
17274 | @code{INT_MIN / -1} signed division. Note, integer promotion | |
17275 | rules must be taken into account. That is, the following is not an | |
17276 | overflow: | |
17277 | @smallexample | |
17278 | signed char a = SCHAR_MAX; | |
17279 | a++; | |
17280 | @end smallexample | |
17281 | ||
d77de738 | 17282 | @opindex fsanitize=bounds |
ddf6fe37 | 17283 | @item -fsanitize=bounds |
d77de738 ML |
17284 | This option enables instrumentation of array bounds. Various out of bounds |
17285 | accesses are detected. Flexible array members, flexible array member-like | |
c7728805 JJ |
17286 | arrays, and initializers of variables with static storage are not |
17287 | instrumented, with the exception of flexible array member-like arrays | |
17288 | for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=} | |
17289 | options or @code{strict_flex_array} attributes say they shouldn't be treated | |
17290 | like flexible array member-like arrays. | |
d77de738 | 17291 | |
d77de738 | 17292 | @opindex fsanitize=bounds-strict |
ddf6fe37 | 17293 | @item -fsanitize=bounds-strict |
d77de738 | 17294 | This option enables strict instrumentation of array bounds. Most out of bounds |
c7728805 JJ |
17295 | accesses are detected, including flexible array member-like arrays. |
17296 | Initializers of variables with static storage are not instrumented. | |
d77de738 | 17297 | |
d77de738 | 17298 | @opindex fsanitize=alignment |
ddf6fe37 | 17299 | @item -fsanitize=alignment |
d77de738 ML |
17300 | |
17301 | This option enables checking of alignment of pointers when they are | |
17302 | dereferenced, or when a reference is bound to insufficiently aligned target, | |
17303 | or when a method or constructor is invoked on insufficiently aligned object. | |
17304 | ||
d77de738 | 17305 | @opindex fsanitize=object-size |
ddf6fe37 | 17306 | @item -fsanitize=object-size |
d77de738 | 17307 | This option enables instrumentation of memory references using the |
7283380a SP |
17308 | @code{__builtin_dynamic_object_size} function. Various out of bounds |
17309 | pointer accesses are detected. | |
d77de738 | 17310 | |
d77de738 | 17311 | @opindex fsanitize=float-divide-by-zero |
ddf6fe37 | 17312 | @item -fsanitize=float-divide-by-zero |
d77de738 ML |
17313 | Detect floating-point division by zero. Unlike other similar options, |
17314 | @option{-fsanitize=float-divide-by-zero} is not enabled by | |
17315 | @option{-fsanitize=undefined}, since floating-point division by zero can | |
17316 | be a legitimate way of obtaining infinities and NaNs. | |
17317 | ||
d77de738 | 17318 | @opindex fsanitize=float-cast-overflow |
ddf6fe37 | 17319 | @item -fsanitize=float-cast-overflow |
d77de738 ML |
17320 | This option enables floating-point type to integer conversion checking. |
17321 | We check that the result of the conversion does not overflow. | |
17322 | Unlike other similar options, @option{-fsanitize=float-cast-overflow} is | |
17323 | not enabled by @option{-fsanitize=undefined}. | |
17324 | This option does not work well with @code{FE_INVALID} exceptions enabled. | |
17325 | ||
d77de738 | 17326 | @opindex fsanitize=nonnull-attribute |
ddf6fe37 | 17327 | @item -fsanitize=nonnull-attribute |
d77de738 ML |
17328 | |
17329 | This option enables instrumentation of calls, checking whether null values | |
17330 | are not passed to arguments marked as requiring a non-null value by the | |
17331 | @code{nonnull} function attribute. | |
17332 | ||
d77de738 | 17333 | @opindex fsanitize=returns-nonnull-attribute |
ddf6fe37 | 17334 | @item -fsanitize=returns-nonnull-attribute |
d77de738 ML |
17335 | |
17336 | This option enables instrumentation of return statements in functions | |
17337 | marked with @code{returns_nonnull} function attribute, to detect returning | |
17338 | of null values from such functions. | |
17339 | ||
d77de738 | 17340 | @opindex fsanitize=bool |
ddf6fe37 | 17341 | @item -fsanitize=bool |
d77de738 ML |
17342 | |
17343 | This option enables instrumentation of loads from bool. If a value other | |
17344 | than 0/1 is loaded, a run-time error is issued. | |
17345 | ||
d77de738 | 17346 | @opindex fsanitize=enum |
ddf6fe37 | 17347 | @item -fsanitize=enum |
d77de738 ML |
17348 | |
17349 | This option enables instrumentation of loads from an enum type. If | |
17350 | a value outside the range of values for the enum type is loaded, | |
17351 | a run-time error is issued. | |
17352 | ||
d77de738 | 17353 | @opindex fsanitize=vptr |
ddf6fe37 | 17354 | @item -fsanitize=vptr |
d77de738 ML |
17355 | |
17356 | This option enables instrumentation of C++ member function calls, member | |
17357 | accesses and some conversions between pointers to base and derived classes, | |
17358 | to verify the referenced object has the correct dynamic type. | |
17359 | ||
d77de738 | 17360 | @opindex fsanitize=pointer-overflow |
ddf6fe37 | 17361 | @item -fsanitize=pointer-overflow |
d77de738 ML |
17362 | |
17363 | This option enables instrumentation of pointer arithmetics. If the pointer | |
17364 | arithmetics overflows, a run-time error is issued. | |
17365 | ||
d77de738 | 17366 | @opindex fsanitize=builtin |
ddf6fe37 | 17367 | @item -fsanitize=builtin |
d77de738 ML |
17368 | |
17369 | This option enables instrumentation of arguments to selected builtin | |
17370 | functions. If an invalid value is passed to such arguments, a run-time | |
17371 | error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz} | |
17372 | or @code{__builtin_clz} invokes undefined behavior and is diagnosed | |
17373 | by this option. | |
17374 | ||
17375 | @end table | |
17376 | ||
17377 | Note that sanitizers tend to increase the rate of false positive | |
17378 | warnings, most notably those around @option{-Wmaybe-uninitialized}. | |
17379 | We recommend against combining @option{-Werror} and [the use of] | |
17380 | sanitizers. | |
17381 | ||
17382 | While @option{-ftrapv} causes traps for signed overflows to be emitted, | |
17383 | @option{-fsanitize=undefined} gives a diagnostic message. | |
17384 | This currently works only for the C family of languages. | |
17385 | ||
d77de738 | 17386 | @opindex fno-sanitize=all |
ddf6fe37 | 17387 | @item -fno-sanitize=all |
d77de738 ML |
17388 | |
17389 | This option disables all previously enabled sanitizers. | |
17390 | @option{-fsanitize=all} is not allowed, as some sanitizers cannot be used | |
17391 | together. | |
17392 | ||
d77de738 | 17393 | @opindex fasan-shadow-offset |
ddf6fe37 | 17394 | @item -fasan-shadow-offset=@var{number} |
d77de738 ML |
17395 | This option forces GCC to use custom shadow offset in AddressSanitizer checks. |
17396 | It is useful for experimenting with different shadow memory layouts in | |
17397 | Kernel AddressSanitizer. | |
17398 | ||
d77de738 | 17399 | @opindex fsanitize-sections |
ddf6fe37 | 17400 | @item -fsanitize-sections=@var{s1},@var{s2},... |
d77de738 ML |
17401 | Sanitize global variables in selected user-defined sections. @var{si} may |
17402 | contain wildcards. | |
17403 | ||
d77de738 ML |
17404 | @opindex fsanitize-recover |
17405 | @opindex fno-sanitize-recover | |
ddf6fe37 | 17406 | @item -fsanitize-recover@r{[}=@var{opts}@r{]} |
d77de738 ML |
17407 | @option{-fsanitize-recover=} controls error recovery mode for sanitizers |
17408 | mentioned in comma-separated list of @var{opts}. Enabling this option | |
17409 | for a sanitizer component causes it to attempt to continue | |
17410 | running the program as if no error happened. This means multiple | |
17411 | runtime errors can be reported in a single program run, and the exit | |
17412 | code of the program may indicate success even when errors | |
17413 | have been reported. The @option{-fno-sanitize-recover=} option | |
17414 | can be used to alter | |
17415 | this behavior: only the first detected error is reported | |
17416 | and program then exits with a non-zero exit code. | |
17417 | ||
17418 | Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions | |
17419 | except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}), | |
17420 | @option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero}, | |
17421 | @option{-fsanitize=bounds-strict}, | |
17422 | @option{-fsanitize=kernel-address} and @option{-fsanitize=address}. | |
17423 | For these sanitizers error recovery is turned on by default, | |
17424 | except @option{-fsanitize=address}, for which this feature is experimental. | |
17425 | @option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also | |
17426 | accepted, the former enables recovery for all sanitizers that support it, | |
17427 | the latter disables recovery for all sanitizers that support it. | |
17428 | ||
17429 | Even if a recovery mode is turned on the compiler side, it needs to be also | |
17430 | enabled on the runtime library side, otherwise the failures are still fatal. | |
17431 | The runtime library defaults to @code{halt_on_error=0} for | |
17432 | ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for | |
17433 | AddressSanitizer is @code{halt_on_error=1}. This can be overridden through | |
17434 | setting the @code{halt_on_error} flag in the corresponding environment variable. | |
17435 | ||
17436 | Syntax without an explicit @var{opts} parameter is deprecated. It is | |
17437 | equivalent to specifying an @var{opts} list of: | |
17438 | ||
17439 | @smallexample | |
17440 | undefined,float-cast-overflow,float-divide-by-zero,bounds-strict | |
17441 | @end smallexample | |
17442 | ||
d77de738 | 17443 | @opindex fsanitize-address-use-after-scope |
ddf6fe37 | 17444 | @item -fsanitize-address-use-after-scope |
d77de738 ML |
17445 | Enable sanitization of local variables to detect use-after-scope bugs. |
17446 | The option sets @option{-fstack-reuse} to @samp{none}. | |
17447 | ||
d77de738 ML |
17448 | @opindex fsanitize-trap |
17449 | @opindex fno-sanitize-trap | |
ddf6fe37 | 17450 | @item -fsanitize-trap@r{[}=@var{opts}@r{]} |
d77de738 ML |
17451 | The @option{-fsanitize-trap=} option instructs the compiler to |
17452 | report for sanitizers mentioned in comma-separated list of @var{opts} | |
17453 | undefined behavior using @code{__builtin_trap} rather than a @code{libubsan} | |
17454 | library routine. If this option is enabled for certain sanitizer, | |
17455 | it takes precedence over the @option{-fsanitizer-recover=} for that | |
17456 | sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless | |
17457 | of whether recovery is enabled or disabled using @option{-fsanitize-recover=}. | |
17458 | ||
17459 | The advantage of this is that the @code{libubsan} library is not needed | |
17460 | and is not linked in, so this is usable even in freestanding environments. | |
17461 | ||
17462 | Currently this feature works with @option{-fsanitize=undefined} (and its suboptions | |
17463 | except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow}, | |
17464 | @option{-fsanitize=float-divide-by-zero} and | |
17465 | @option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also | |
17466 | specified, which enables it for @code{undefined} suboptions, | |
17467 | @option{-fsanitize=float-cast-overflow}, | |
17468 | @option{-fsanitize=float-divide-by-zero} and | |
17469 | @option{-fsanitize=bounds-strict}. | |
17470 | If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used | |
17471 | and @code{-fsanitize=vptr} is enabled on the command line, the | |
17472 | instrumentation is silently ignored as the instrumentation always needs | |
17473 | @code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed. | |
17474 | ||
d77de738 | 17475 | @opindex fsanitize-undefined-trap-on-error |
ddf6fe37 | 17476 | @item -fsanitize-undefined-trap-on-error |
d77de738 ML |
17477 | The @option{-fsanitize-undefined-trap-on-error} option is deprecated |
17478 | equivalent of @option{-fsanitize-trap=all}. | |
17479 | ||
d77de738 | 17480 | @opindex fsanitize-coverage=trace-pc |
ddf6fe37 | 17481 | @item -fsanitize-coverage=trace-pc |
d77de738 ML |
17482 | Enable coverage-guided fuzzing code instrumentation. |
17483 | Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block. | |
17484 | ||
d77de738 | 17485 | @opindex fsanitize-coverage=trace-cmp |
ddf6fe37 | 17486 | @item -fsanitize-coverage=trace-cmp |
d77de738 ML |
17487 | Enable dataflow guided fuzzing code instrumentation. |
17488 | Inserts a call to @code{__sanitizer_cov_trace_cmp1}, | |
17489 | @code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or | |
17490 | @code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands | |
17491 | variable or @code{__sanitizer_cov_trace_const_cmp1}, | |
17492 | @code{__sanitizer_cov_trace_const_cmp2}, | |
17493 | @code{__sanitizer_cov_trace_const_cmp4} or | |
17494 | @code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one | |
17495 | operand constant, @code{__sanitizer_cov_trace_cmpf} or | |
17496 | @code{__sanitizer_cov_trace_cmpd} for float or double comparisons and | |
17497 | @code{__sanitizer_cov_trace_switch} for switch statements. | |
17498 | ||
d77de738 | 17499 | @opindex fcf-protection |
ddf6fe37 | 17500 | @item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} |
d77de738 ML |
17501 | Enable code instrumentation of control-flow transfers to increase |
17502 | program security by checking that target addresses of control-flow | |
17503 | transfer instructions (such as indirect function call, function return, | |
17504 | indirect jump) are valid. This prevents diverting the flow of control | |
17505 | to an unexpected target. This is intended to protect against such | |
17506 | threats as Return-oriented Programming (ROP), and similarly | |
17507 | call/jmp-oriented programming (COP/JOP). | |
17508 | ||
17509 | The value @code{branch} tells the compiler to implement checking of | |
17510 | validity of control-flow transfer at the point of indirect branch | |
17511 | instructions, i.e.@: call/jmp instructions. The value @code{return} | |
17512 | implements checking of validity at the point of returning from a | |
17513 | function. The value @code{full} is an alias for specifying both | |
17514 | @code{branch} and @code{return}. The value @code{none} turns off | |
17515 | instrumentation. | |
17516 | ||
17517 | The value @code{check} is used for the final link with link-time | |
17518 | optimization (LTO). An error is issued if LTO object files are | |
17519 | compiled with different @option{-fcf-protection} values. The | |
17520 | value @code{check} is ignored at the compile time. | |
17521 | ||
17522 | The macro @code{__CET__} is defined when @option{-fcf-protection} is | |
17523 | used. The first bit of @code{__CET__} is set to 1 for the value | |
17524 | @code{branch} and the second bit of @code{__CET__} is set to 1 for | |
17525 | the @code{return}. | |
17526 | ||
17527 | You can also use the @code{nocf_check} attribute to identify | |
17528 | which functions and calls should be skipped from instrumentation | |
17529 | (@pxref{Function Attributes}). | |
17530 | ||
17531 | Currently the x86 GNU/Linux target provides an implementation based | |
17532 | on Intel Control-flow Enforcement Technology (CET) which works for | |
17533 | i686 processor or newer. | |
17534 | ||
d77de738 | 17535 | @opindex fharden-compares |
ddf6fe37 | 17536 | @item -fharden-compares |
d77de738 ML |
17537 | For every logical test that survives gimple optimizations and is |
17538 | @emph{not} the condition in a conditional branch (for example, | |
17539 | conditions tested for conditional moves, or to store in boolean | |
17540 | variables), emit extra code to compute and verify the reversed | |
17541 | condition, and to call @code{__builtin_trap} if the results do not | |
17542 | match. Use with @samp{-fharden-conditional-branches} to cover all | |
17543 | conditionals. | |
17544 | ||
d77de738 | 17545 | @opindex fharden-conditional-branches |
ddf6fe37 | 17546 | @item -fharden-conditional-branches |
d77de738 ML |
17547 | For every non-vectorized conditional branch that survives gimple |
17548 | optimizations, emit extra code to compute and verify the reversed | |
17549 | condition, and to call @code{__builtin_trap} if the result is | |
17550 | unexpected. Use with @samp{-fharden-compares} to cover all | |
17551 | conditionals. | |
17552 | ||
551935d1 AO |
17553 | @opindex fharden-control-flow-redundancy |
17554 | @item -fharden-control-flow-redundancy | |
17555 | Emit extra code to set booleans when entering basic blocks, and to | |
17556 | verify and trap, at function exits, when the booleans do not form an | |
17557 | execution path that is compatible with the control flow graph. | |
17558 | ||
17559 | Verification takes place before returns, before mandatory tail calls | |
17560 | (see below) and, optionally, before escaping exceptions with | |
17561 | @option{-fhardcfr-check-exceptions}, before returning calls with | |
17562 | @option{-fhardcfr-check-returning-calls}, and before noreturn calls with | |
17563 | @option{-fhardcfr-check-noreturn-calls}). Tuning options | |
17564 | @option{--param hardcfr-max-blocks} and @option{--param | |
17565 | hardcfr-max-inline-blocks} are available. | |
17566 | ||
17567 | Tail call optimization takes place too late to affect control flow | |
17568 | redundancy, but calls annotated as mandatory tail calls by language | |
17569 | front-ends, and any calls marked early enough as potential tail calls | |
17570 | would also have verification issued before the call, but these | |
17571 | possibilities are merely theoretical, as these conditions can only be | |
17572 | met when using custom compiler plugins. | |
17573 | ||
17574 | @opindex fhardcfr-skip-leaf | |
17575 | @item -fhardcfr-skip-leaf | |
17576 | Disable @option{-fharden-control-flow-redundancy} in leaf functions. | |
17577 | ||
17578 | @opindex fhardcfr-check-exceptions | |
17579 | @opindex fno-hardcfr-check-exceptions | |
17580 | @item -fhardcfr-check-exceptions | |
17581 | When @option{-fharden-control-flow-redundancy} is active, check the | |
17582 | recorded execution path against the control flow graph at exception | |
17583 | escape points, as if the function body was wrapped with a cleanup | |
17584 | handler that performed the check and reraised. This option is enabled | |
17585 | by default; use @option{-fno-hardcfr-check-exceptions} to disable it. | |
17586 | ||
17587 | @opindex fhardcfr-check-returning-calls | |
17588 | @opindex fno-hardcfr-check-returning-calls | |
17589 | @item -fhardcfr-check-returning-calls | |
17590 | When @option{-fharden-control-flow-redundancy} is active, check the | |
17591 | recorded execution path against the control flow graph before any | |
17592 | function call immediately followed by a return of its result, if any, so | |
17593 | as to not prevent tail-call optimization, whether or not it is | |
17594 | ultimately optimized to a tail call. | |
17595 | ||
17596 | This option is enabled by default whenever sibling call optimizations | |
17597 | are enabled (see @option{-foptimize-sibling-calls}), but it can be | |
17598 | enabled (or disabled, using its negated form) explicitly, regardless of | |
17599 | the optimizations. | |
17600 | ||
17601 | @opindex fhardcfr-check-noreturn-calls | |
17602 | @item -fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]} | |
17603 | When @option{-fharden-control-flow-redundancy} is active, check the | |
17604 | recorded execution path against the control flow graph before | |
17605 | @code{noreturn} calls, either all of them (@option{always}), those that | |
17606 | aren't expected to return control to the caller through an exception | |
17607 | (@option{no-xthrow}, the default), those that may not return control to | |
17608 | the caller through an exception either (@option{nothrow}), or none of | |
17609 | them (@option{never}). | |
17610 | ||
17611 | Checking before a @code{noreturn} function that may return control to | |
17612 | the caller through an exception may cause checking to be performed more | |
17613 | than once, if the exception is caught in the caller, whether by a | |
17614 | handler or a cleanup. When @option{-fhardcfr-check-exceptions} is also | |
17615 | enabled, the compiler will avoid associating a @code{noreturn} call with | |
17616 | the implicitly-added cleanup handler, since it would be redundant with | |
17617 | the check performed before the call, but other handlers or cleanups in | |
17618 | the function, if activated, will modify the recorded execution path and | |
17619 | check it again when another checkpoint is hit. The checkpoint may even | |
17620 | be another @code{noreturn} call, so checking may end up performed | |
17621 | multiple times. | |
17622 | ||
17623 | Various optimizers may cause calls to be marked as @code{noreturn} | |
17624 | and/or @code{nothrow}, even in the absence of the corresponding | |
17625 | attributes, which may affect the placement of checks before calls, as | |
17626 | well as the addition of implicit cleanup handlers for them. This | |
17627 | unpredictability, and the fact that raising and reraising exceptions | |
17628 | frequently amounts to implicitly calling @code{noreturn} functions, have | |
17629 | made @option{no-xthrow} the default setting for this option: it excludes | |
17630 | from the @code{noreturn} treatment only internal functions used to | |
17631 | (re)raise exceptions, that are not affected by these optimizations. | |
17632 | ||
d77de738 | 17633 | @opindex fstack-protector |
ddf6fe37 | 17634 | @item -fstack-protector |
d77de738 ML |
17635 | Emit extra code to check for buffer overflows, such as stack smashing |
17636 | attacks. This is done by adding a guard variable to functions with | |
17637 | vulnerable objects. This includes functions that call @code{alloca}, and | |
17638 | functions with buffers larger than or equal to 8 bytes. The guards are | |
17639 | initialized when a function is entered and then checked when the function | |
17640 | exits. If a guard check fails, an error message is printed and the program | |
17641 | exits. Only variables that are actually allocated on the stack are | |
17642 | considered, optimized away variables or variables allocated in registers | |
17643 | don't count. | |
17644 | ||
d77de738 | 17645 | @opindex fstack-protector-all |
ddf6fe37 | 17646 | @item -fstack-protector-all |
d77de738 ML |
17647 | Like @option{-fstack-protector} except that all functions are protected. |
17648 | ||
d77de738 | 17649 | @opindex fstack-protector-strong |
ddf6fe37 | 17650 | @item -fstack-protector-strong |
d77de738 ML |
17651 | Like @option{-fstack-protector} but includes additional functions to |
17652 | be protected --- those that have local array definitions, or have | |
17653 | references to local frame addresses. Only variables that are actually | |
17654 | allocated on the stack are considered, optimized away variables or variables | |
17655 | allocated in registers don't count. | |
17656 | ||
d77de738 | 17657 | @opindex fstack-protector-explicit |
ddf6fe37 | 17658 | @item -fstack-protector-explicit |
d77de738 ML |
17659 | Like @option{-fstack-protector} but only protects those functions which |
17660 | have the @code{stack_protect} attribute. | |
17661 | ||
d77de738 | 17662 | @opindex fstack-check |
ddf6fe37 | 17663 | @item -fstack-check |
d77de738 ML |
17664 | Generate code to verify that you do not go beyond the boundary of the |
17665 | stack. You should specify this flag if you are running in an | |
17666 | environment with multiple threads, but you only rarely need to specify it in | |
17667 | a single-threaded environment since stack overflow is automatically | |
17668 | detected on nearly all systems if there is only one stack. | |
17669 | ||
17670 | Note that this switch does not actually cause checking to be done; the | |
17671 | operating system or the language runtime must do that. The switch causes | |
17672 | generation of code to ensure that they see the stack being extended. | |
17673 | ||
17674 | You can additionally specify a string parameter: @samp{no} means no | |
17675 | checking, @samp{generic} means force the use of old-style checking, | |
17676 | @samp{specific} means use the best checking method and is equivalent | |
17677 | to bare @option{-fstack-check}. | |
17678 | ||
17679 | Old-style checking is a generic mechanism that requires no specific | |
17680 | target support in the compiler but comes with the following drawbacks: | |
17681 | ||
17682 | @enumerate | |
17683 | @item | |
17684 | Modified allocation strategy for large objects: they are always | |
17685 | allocated dynamically if their size exceeds a fixed threshold. Note this | |
17686 | may change the semantics of some code. | |
17687 | ||
17688 | @item | |
17689 | Fixed limit on the size of the static frame of functions: when it is | |
17690 | topped by a particular function, stack checking is not reliable and | |
17691 | a warning is issued by the compiler. | |
17692 | ||
17693 | @item | |
17694 | Inefficiency: because of both the modified allocation strategy and the | |
17695 | generic implementation, code performance is hampered. | |
17696 | @end enumerate | |
17697 | ||
17698 | Note that old-style stack checking is also the fallback method for | |
17699 | @samp{specific} if no target support has been added in the compiler. | |
17700 | ||
17701 | @samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion | |
17702 | and stack overflows. @samp{specific} is an excellent choice when compiling | |
17703 | Ada code. It is not generally sufficient to protect against stack-clash | |
17704 | attacks. To protect against those you want @samp{-fstack-clash-protection}. | |
17705 | ||
d77de738 | 17706 | @opindex fstack-clash-protection |
ddf6fe37 | 17707 | @item -fstack-clash-protection |
d77de738 ML |
17708 | Generate code to prevent stack clash style attacks. When this option is |
17709 | enabled, the compiler will only allocate one page of stack space at a time | |
17710 | and each page is accessed immediately after allocation. Thus, it prevents | |
17711 | allocations from jumping over any stack guard page provided by the | |
17712 | operating system. | |
17713 | ||
17714 | Most targets do not fully support stack clash protection. However, on | |
17715 | those targets @option{-fstack-clash-protection} will protect dynamic stack | |
17716 | allocations. @option{-fstack-clash-protection} may also provide limited | |
17717 | protection for static stack allocations if the target supports | |
17718 | @option{-fstack-check=specific}. | |
17719 | ||
d77de738 ML |
17720 | @opindex fstack-limit-register |
17721 | @opindex fstack-limit-symbol | |
17722 | @opindex fno-stack-limit | |
ddf6fe37 AA |
17723 | @item -fstack-limit-register=@var{reg} |
17724 | @itemx -fstack-limit-symbol=@var{sym} | |
17725 | @itemx -fno-stack-limit | |
d77de738 ML |
17726 | Generate code to ensure that the stack does not grow beyond a certain value, |
17727 | either the value of a register or the address of a symbol. If a larger | |
17728 | stack is required, a signal is raised at run time. For most targets, | |
17729 | the signal is raised before the stack overruns the boundary, so | |
17730 | it is possible to catch the signal without taking special precautions. | |
17731 | ||
17732 | For instance, if the stack starts at absolute address @samp{0x80000000} | |
17733 | and grows downwards, you can use the flags | |
17734 | @option{-fstack-limit-symbol=__stack_limit} and | |
17735 | @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit | |
17736 | of 128KB@. Note that this may only work with the GNU linker. | |
17737 | ||
17738 | You can locally override stack limit checking by using the | |
17739 | @code{no_stack_limit} function attribute (@pxref{Function Attributes}). | |
17740 | ||
d77de738 | 17741 | @opindex fsplit-stack |
ddf6fe37 | 17742 | @item -fsplit-stack |
d77de738 ML |
17743 | Generate code to automatically split the stack before it overflows. |
17744 | The resulting program has a discontiguous stack which can only | |
17745 | overflow if the program is unable to allocate any more memory. This | |
17746 | is most useful when running threaded programs, as it is no longer | |
17747 | necessary to calculate a good stack size to use for each thread. This | |
17748 | is currently only implemented for the x86 targets running | |
17749 | GNU/Linux. | |
17750 | ||
17751 | When code compiled with @option{-fsplit-stack} calls code compiled | |
17752 | without @option{-fsplit-stack}, there may not be much stack space | |
17753 | available for the latter code to run. If compiling all code, | |
17754 | including library code, with @option{-fsplit-stack} is not an option, | |
17755 | then the linker can fix up these calls so that the code compiled | |
17756 | without @option{-fsplit-stack} always has a large stack. Support for | |
17757 | this is implemented in the gold linker in GNU binutils release 2.21 | |
17758 | and later. | |
17759 | ||
d77de738 | 17760 | @opindex fvtable-verify |
ddf6fe37 | 17761 | @item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} |
d77de738 ML |
17762 | This option is only available when compiling C++ code. |
17763 | It turns on (or off, if using @option{-fvtable-verify=none}) the security | |
17764 | feature that verifies at run time, for every virtual call, that | |
17765 | the vtable pointer through which the call is made is valid for the type of | |
17766 | the object, and has not been corrupted or overwritten. If an invalid vtable | |
17767 | pointer is detected at run time, an error is reported and execution of the | |
17768 | program is immediately halted. | |
17769 | ||
17770 | This option causes run-time data structures to be built at program startup, | |
17771 | which are used for verifying the vtable pointers. | |
17772 | The options @samp{std} and @samp{preinit} | |
17773 | control the timing of when these data structures are built. In both cases the | |
17774 | data structures are built before execution reaches @code{main}. Using | |
17775 | @option{-fvtable-verify=std} causes the data structures to be built after | |
17776 | shared libraries have been loaded and initialized. | |
17777 | @option{-fvtable-verify=preinit} causes them to be built before shared | |
17778 | libraries have been loaded and initialized. | |
17779 | ||
17780 | If this option appears multiple times in the command line with different | |
17781 | values specified, @samp{none} takes highest priority over both @samp{std} and | |
17782 | @samp{preinit}; @samp{preinit} takes priority over @samp{std}. | |
17783 | ||
d77de738 | 17784 | @opindex fvtv-debug |
ddf6fe37 | 17785 | @item -fvtv-debug |
d77de738 ML |
17786 | When used in conjunction with @option{-fvtable-verify=std} or |
17787 | @option{-fvtable-verify=preinit}, causes debug versions of the | |
17788 | runtime functions for the vtable verification feature to be called. | |
17789 | This flag also causes the compiler to log information about which | |
17790 | vtable pointers it finds for each class. | |
17791 | This information is written to a file named @file{vtv_set_ptr_data.log} | |
17792 | in the directory named by the environment variable @env{VTV_LOGS_DIR} | |
17793 | if that is defined or the current working directory otherwise. | |
17794 | ||
17795 | Note: This feature @emph{appends} data to the log file. If you want a fresh log | |
17796 | file, be sure to delete any existing one. | |
17797 | ||
d77de738 | 17798 | @opindex fvtv-counts |
ddf6fe37 | 17799 | @item -fvtv-counts |
d77de738 ML |
17800 | This is a debugging flag. When used in conjunction with |
17801 | @option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this | |
17802 | causes the compiler to keep track of the total number of virtual calls | |
17803 | it encounters and the number of verifications it inserts. It also | |
17804 | counts the number of calls to certain run-time library functions | |
17805 | that it inserts and logs this information for each compilation unit. | |
17806 | The compiler writes this information to a file named | |
17807 | @file{vtv_count_data.log} in the directory named by the environment | |
17808 | variable @env{VTV_LOGS_DIR} if that is defined or the current working | |
17809 | directory otherwise. It also counts the size of the vtable pointer sets | |
17810 | for each class, and writes this information to @file{vtv_class_set_sizes.log} | |
17811 | in the same directory. | |
17812 | ||
17813 | Note: This feature @emph{appends} data to the log files. To get fresh log | |
17814 | files, be sure to delete any existing ones. | |
17815 | ||
d77de738 | 17816 | @opindex finstrument-functions |
ddf6fe37 | 17817 | @item -finstrument-functions |
d77de738 ML |
17818 | Generate instrumentation calls for entry and exit to functions. Just |
17819 | after function entry and just before function exit, the following | |
17820 | profiling functions are called with the address of the current | |
17821 | function and its call site. (On some platforms, | |
17822 | @code{__builtin_return_address} does not work beyond the current | |
17823 | function, so the call site information may not be available to the | |
17824 | profiling functions otherwise.) | |
17825 | ||
17826 | @smallexample | |
17827 | void __cyg_profile_func_enter (void *this_fn, | |
17828 | void *call_site); | |
17829 | void __cyg_profile_func_exit (void *this_fn, | |
17830 | void *call_site); | |
17831 | @end smallexample | |
17832 | ||
17833 | The first argument is the address of the start of the current function, | |
17834 | which may be looked up exactly in the symbol table. | |
17835 | ||
17836 | This instrumentation is also done for functions expanded inline in other | |
17837 | functions. The profiling calls indicate where, conceptually, the | |
17838 | inline function is entered and exited. This means that addressable | |
17839 | versions of such functions must be available. If all your uses of a | |
17840 | function are expanded inline, this may mean an additional expansion of | |
17841 | code size. If you use @code{extern inline} in your C code, an | |
17842 | addressable version of such functions must be provided. (This is | |
17843 | normally the case anyway, but if you get lucky and the optimizer always | |
17844 | expands the functions inline, you might have gotten away without | |
17845 | providing static copies.) | |
17846 | ||
17847 | A function may be given the attribute @code{no_instrument_function}, in | |
17848 | which case this instrumentation is not done. This can be used, for | |
17849 | example, for the profiling functions listed above, high-priority | |
17850 | interrupt routines, and any functions from which the profiling functions | |
17851 | cannot safely be called (perhaps signal handlers, if the profiling | |
17852 | routines generate output or allocate memory). | |
17853 | @xref{Common Function Attributes}. | |
17854 | ||
9c19597c | 17855 | @opindex finstrument-functions-once |
ddf6fe37 | 17856 | @item -finstrument-functions-once |
d77de738 ML |
17857 | This is similar to @option{-finstrument-functions}, but the profiling |
17858 | functions are called only once per instrumented function, i.e. the first | |
17859 | profiling function is called after the first entry into the instrumented | |
17860 | function and the second profiling function is called before the exit | |
17861 | corresponding to this first entry. | |
17862 | ||
17863 | The definition of @code{once} for the purpose of this option is a little | |
17864 | vague because the implementation is not protected against data races. | |
17865 | As a result, the implementation only guarantees that the profiling | |
17866 | functions are called at @emph{least} once per process and at @emph{most} | |
17867 | once per thread, but the calls are always paired, that is to say, if a | |
17868 | thread calls the first function, then it will call the second function, | |
17869 | unless it never reaches the exit of the instrumented function. | |
17870 | ||
d77de738 | 17871 | @opindex finstrument-functions-exclude-file-list |
ddf6fe37 | 17872 | @item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{} |
d77de738 ML |
17873 | |
17874 | Set the list of functions that are excluded from instrumentation (see | |
17875 | the description of @option{-finstrument-functions}). If the file that | |
17876 | contains a function definition matches with one of @var{file}, then | |
17877 | that function is not instrumented. The match is done on substrings: | |
17878 | if the @var{file} parameter is a substring of the file name, it is | |
17879 | considered to be a match. | |
17880 | ||
17881 | For example: | |
17882 | ||
17883 | @smallexample | |
17884 | -finstrument-functions-exclude-file-list=/bits/stl,include/sys | |
17885 | @end smallexample | |
17886 | ||
17887 | @noindent | |
17888 | excludes any inline function defined in files whose pathnames | |
17889 | contain @file{/bits/stl} or @file{include/sys}. | |
17890 | ||
17891 | If, for some reason, you want to include letter @samp{,} in one of | |
17892 | @var{sym}, write @samp{\,}. For example, | |
17893 | @option{-finstrument-functions-exclude-file-list='\,\,tmp'} | |
17894 | (note the single quote surrounding the option). | |
17895 | ||
d77de738 | 17896 | @opindex finstrument-functions-exclude-function-list |
ddf6fe37 | 17897 | @item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} |
d77de738 ML |
17898 | |
17899 | This is similar to @option{-finstrument-functions-exclude-file-list}, | |
17900 | but this option sets the list of function names to be excluded from | |
17901 | instrumentation. The function name to be matched is its user-visible | |
17902 | name, such as @code{vector<int> blah(const vector<int> &)}, not the | |
17903 | internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The | |
17904 | match is done on substrings: if the @var{sym} parameter is a substring | |
17905 | of the function name, it is considered to be a match. For C99 and C++ | |
17906 | extended identifiers, the function name must be given in UTF-8, not | |
17907 | using universal character names. | |
17908 | ||
d77de738 | 17909 | @opindex fpatchable-function-entry |
ddf6fe37 | 17910 | @item -fpatchable-function-entry=@var{N}[,@var{M}] |
d77de738 ML |
17911 | Generate @var{N} NOPs right at the beginning |
17912 | of each function, with the function entry point before the @var{M}th NOP. | |
17913 | If @var{M} is omitted, it defaults to @code{0} so the | |
17914 | function entry points to the address just at the first NOP. | |
17915 | The NOP instructions reserve extra space which can be used to patch in | |
17916 | any desired instrumentation at run time, provided that the code segment | |
17917 | is writable. The amount of space is controllable indirectly via | |
17918 | the number of NOPs; the NOP instruction used corresponds to the instruction | |
17919 | emitted by the internal GCC back-end interface @code{gen_nop}. This behavior | |
17920 | is target-specific and may also depend on the architecture variant and/or | |
17921 | other compilation options. | |
17922 | ||
17923 | For run-time identification, the starting addresses of these areas, | |
17924 | which correspond to their respective function entries minus @var{M}, | |
17925 | are additionally collected in the @code{__patchable_function_entries} | |
17926 | section of the resulting binary. | |
17927 | ||
17928 | Note that the value of @code{__attribute__ ((patchable_function_entry | |
17929 | (N,M)))} takes precedence over command-line option | |
17930 | @option{-fpatchable-function-entry=N,M}. This can be used to increase | |
17931 | the area size or to remove it completely on a single function. | |
17932 | If @code{N=0}, no pad location is recorded. | |
17933 | ||
17934 | The NOP instructions are inserted at---and maybe before, depending on | |
17935 | @var{M}---the function entry address, even before the prologue. On | |
17936 | PowerPC with the ELFv2 ABI, for a function with dual entry points, | |
17937 | the local entry point is this function entry address. | |
17938 | ||
17939 | The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the | |
17940 | ELFv2 ABI, for a function with dual entry points, the supported values | |
17941 | for @var{M} are 0, 2, 6 and 14. | |
17942 | @end table | |
17943 | ||
17944 | ||
17945 | @node Preprocessor Options | |
17946 | @section Options Controlling the Preprocessor | |
17947 | @cindex preprocessor options | |
17948 | @cindex options, preprocessor | |
17949 | ||
17950 | These options control the C preprocessor, which is run on each C source | |
17951 | file before actual compilation. | |
17952 | ||
17953 | If you use the @option{-E} option, nothing is done except preprocessing. | |
17954 | Some of these options make sense only together with @option{-E} because | |
17955 | they cause the preprocessor output to be unsuitable for actual | |
17956 | compilation. | |
17957 | ||
17958 | In addition to the options listed here, there are a number of options | |
17959 | to control search paths for include files documented in | |
17960 | @ref{Directory Options}. | |
17961 | Options to control preprocessor diagnostics are listed in | |
17962 | @ref{Warning Options}. | |
17963 | ||
17964 | @table @gcctabopt | |
17965 | @include cppopts.texi | |
17966 | ||
d77de738 | 17967 | @opindex Wp |
ddf6fe37 | 17968 | @item -Wp,@var{option} |
d77de738 ML |
17969 | You can use @option{-Wp,@var{option}} to bypass the compiler driver |
17970 | and pass @var{option} directly through to the preprocessor. If | |
17971 | @var{option} contains commas, it is split into multiple options at the | |
17972 | commas. However, many options are modified, translated or interpreted | |
17973 | by the compiler driver before being passed to the preprocessor, and | |
17974 | @option{-Wp} forcibly bypasses this phase. The preprocessor's direct | |
17975 | interface is undocumented and subject to change, so whenever possible | |
17976 | you should avoid using @option{-Wp} and let the driver handle the | |
17977 | options instead. | |
17978 | ||
d77de738 | 17979 | @opindex Xpreprocessor |
ddf6fe37 | 17980 | @item -Xpreprocessor @var{option} |
d77de738 ML |
17981 | Pass @var{option} as an option to the preprocessor. You can use this to |
17982 | supply system-specific preprocessor options that GCC does not | |
17983 | recognize. | |
17984 | ||
17985 | If you want to pass an option that takes an argument, you must use | |
17986 | @option{-Xpreprocessor} twice, once for the option and once for the argument. | |
17987 | ||
d77de738 | 17988 | @opindex no-integrated-cpp |
ddf6fe37 | 17989 | @item -no-integrated-cpp |
d77de738 ML |
17990 | Perform preprocessing as a separate pass before compilation. |
17991 | By default, GCC performs preprocessing as an integrated part of | |
17992 | input tokenization and parsing. | |
17993 | If this option is provided, the appropriate language front end | |
17994 | (@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++, | |
17995 | and Objective-C, respectively) is instead invoked twice, | |
17996 | once for preprocessing only and once for actual compilation | |
17997 | of the preprocessed input. | |
17998 | This option may be useful in conjunction with the @option{-B} or | |
17999 | @option{-wrapper} options to specify an alternate preprocessor or | |
18000 | perform additional processing of the program source between | |
18001 | normal preprocessing and compilation. | |
18002 | ||
d77de738 | 18003 | @opindex flarge-source-files |
ddf6fe37 | 18004 | @item -flarge-source-files |
d77de738 ML |
18005 | Adjust GCC to expect large source files, at the expense of slower |
18006 | compilation and higher memory usage. | |
18007 | ||
18008 | Specifically, GCC normally tracks both column numbers and line numbers | |
18009 | within source files and it normally prints both of these numbers in | |
18010 | diagnostics. However, once it has processed a certain number of source | |
18011 | lines, it stops tracking column numbers and only tracks line numbers. | |
18012 | This means that diagnostics for later lines do not include column numbers. | |
18013 | It also means that options like @option{-Wmisleading-indentation} cease to work | |
18014 | at that point, although the compiler prints a note if this happens. | |
18015 | Passing @option{-flarge-source-files} significantly increases the number | |
18016 | of source lines that GCC can process before it stops tracking columns. | |
18017 | ||
18018 | @end table | |
18019 | ||
18020 | @node Assembler Options | |
18021 | @section Passing Options to the Assembler | |
18022 | ||
18023 | @c prevent bad page break with this line | |
18024 | You can pass options to the assembler. | |
18025 | ||
18026 | @table @gcctabopt | |
d77de738 | 18027 | @opindex Wa |
ddf6fe37 | 18028 | @item -Wa,@var{option} |
d77de738 ML |
18029 | Pass @var{option} as an option to the assembler. If @var{option} |
18030 | contains commas, it is split into multiple options at the commas. | |
18031 | ||
d77de738 | 18032 | @opindex Xassembler |
ddf6fe37 | 18033 | @item -Xassembler @var{option} |
d77de738 ML |
18034 | Pass @var{option} as an option to the assembler. You can use this to |
18035 | supply system-specific assembler options that GCC does not | |
18036 | recognize. | |
18037 | ||
18038 | If you want to pass an option that takes an argument, you must use | |
18039 | @option{-Xassembler} twice, once for the option and once for the argument. | |
18040 | ||
18041 | @end table | |
18042 | ||
18043 | @node Link Options | |
18044 | @section Options for Linking | |
18045 | @cindex link options | |
18046 | @cindex options, linking | |
18047 | ||
18048 | These options come into play when the compiler links object files into | |
18049 | an executable output file. They are meaningless if the compiler is | |
18050 | not doing a link step. | |
18051 | ||
18052 | @table @gcctabopt | |
18053 | @cindex file names | |
18054 | @item @var{object-file-name} | |
18055 | A file name that does not end in a special recognized suffix is | |
18056 | considered to name an object file or library. (Object files are | |
18057 | distinguished from libraries by the linker according to the file | |
18058 | contents.) If linking is done, these object files are used as input | |
18059 | to the linker. | |
18060 | ||
d77de738 ML |
18061 | @opindex c |
18062 | @opindex S | |
18063 | @opindex E | |
ddf6fe37 AA |
18064 | @item -c |
18065 | @itemx -S | |
18066 | @itemx -E | |
d77de738 ML |
18067 | If any of these options is used, then the linker is not run, and |
18068 | object file names should not be used as arguments. @xref{Overall | |
18069 | Options}. | |
18070 | ||
d77de738 | 18071 | @opindex flinker-output |
ddf6fe37 | 18072 | @item -flinker-output=@var{type} |
d77de738 ML |
18073 | This option controls code generation of the link-time optimizer. By |
18074 | default the linker output is automatically determined by the linker | |
18075 | plugin. For debugging the compiler and if incremental linking with a | |
18076 | non-LTO object file is desired, it may be useful to control the type | |
18077 | manually. | |
18078 | ||
18079 | If @var{type} is @samp{exec}, code generation produces a static | |
18080 | binary. In this case @option{-fpic} and @option{-fpie} are both | |
18081 | disabled. | |
18082 | ||
18083 | If @var{type} is @samp{dyn}, code generation produces a shared | |
18084 | library. In this case @option{-fpic} or @option{-fPIC} is preserved, | |
18085 | but not enabled automatically. This allows to build shared libraries | |
18086 | without position-independent code on architectures where this is | |
18087 | possible, i.e.@: on x86. | |
18088 | ||
18089 | If @var{type} is @samp{pie}, code generation produces an @option{-fpie} | |
18090 | executable. This results in similar optimizations as @samp{exec} | |
18091 | except that @option{-fpie} is not disabled if specified at compilation | |
18092 | time. | |
18093 | ||
18094 | If @var{type} is @samp{rel}, the compiler assumes that incremental linking is | |
18095 | done. The sections containing intermediate code for link-time optimization are | |
18096 | merged, pre-optimized, and output to the resulting object file. In addition, if | |
18097 | @option{-ffat-lto-objects} is specified, binary code is produced for future | |
18098 | non-LTO linking. The object file produced by incremental linking is smaller | |
18099 | than a static library produced from the same object files. At link time the | |
18100 | result of incremental linking also loads faster than a static | |
18101 | library assuming that the majority of objects in the library are used. | |
18102 | ||
18103 | Finally @samp{nolto-rel} configures the compiler for incremental linking where | |
18104 | code generation is forced, a final binary is produced, and the intermediate | |
18105 | code for later link-time optimization is stripped. When multiple object files | |
18106 | are linked together the resulting code is better optimized than with | |
18107 | link-time optimizations disabled (for example, cross-module inlining | |
18108 | happens), but most of benefits of whole program optimizations are lost. | |
18109 | ||
18110 | During the incremental link (by @option{-r}) the linker plugin defaults to | |
18111 | @option{rel}. With current interfaces to GNU Binutils it is however not | |
18112 | possible to incrementally link LTO objects and non-LTO objects into a single | |
18113 | mixed object file. If any of object files in incremental link cannot | |
18114 | be used for link-time optimization, the linker plugin issues a warning and | |
18115 | uses @samp{nolto-rel}. To maintain whole program optimization, it is | |
18116 | recommended to link such objects into static library instead. Alternatively it | |
18117 | is possible to use H.J. Lu's binutils with support for mixed objects. | |
18118 | ||
d77de738 | 18119 | @opindex fuse-ld=bfd |
ddf6fe37 | 18120 | @item -fuse-ld=bfd |
d77de738 ML |
18121 | Use the @command{bfd} linker instead of the default linker. |
18122 | ||
d77de738 | 18123 | @opindex fuse-ld=gold |
ddf6fe37 | 18124 | @item -fuse-ld=gold |
d77de738 ML |
18125 | Use the @command{gold} linker instead of the default linker. |
18126 | ||
d77de738 | 18127 | @opindex fuse-ld=lld |
ddf6fe37 | 18128 | @item -fuse-ld=lld |
d77de738 ML |
18129 | Use the LLVM @command{lld} linker instead of the default linker. |
18130 | ||
d77de738 | 18131 | @opindex fuse-ld=mold |
ddf6fe37 | 18132 | @item -fuse-ld=mold |
d77de738 ML |
18133 | Use the Modern Linker (@command{mold}) instead of the default linker. |
18134 | ||
18135 | @cindex Libraries | |
ddf6fe37 | 18136 | @opindex l |
d77de738 ML |
18137 | @item -l@var{library} |
18138 | @itemx -l @var{library} | |
d77de738 ML |
18139 | Search the library named @var{library} when linking. (The second |
18140 | alternative with the library as a separate argument is only for | |
18141 | POSIX compliance and is not recommended.) | |
18142 | ||
18143 | The @option{-l} option is passed directly to the linker by GCC. Refer | |
18144 | to your linker documentation for exact details. The general | |
18145 | description below applies to the GNU linker. | |
18146 | ||
18147 | The linker searches a standard list of directories for the library. | |
18148 | The directories searched include several standard system directories | |
18149 | plus any that you specify with @option{-L}. | |
18150 | ||
18151 | Static libraries are archives of object files, and have file names | |
18152 | like @file{lib@var{library}.a}. Some targets also support shared | |
18153 | libraries, which typically have names like @file{lib@var{library}.so}. | |
18154 | If both static and shared libraries are found, the linker gives | |
18155 | preference to linking with the shared library unless the | |
18156 | @option{-static} option is used. | |
18157 | ||
18158 | It makes a difference where in the command you write this option; the | |
18159 | linker searches and processes libraries and object files in the order they | |
18160 | are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z} | |
18161 | after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers | |
18162 | to functions in @samp{z}, those functions may not be loaded. | |
18163 | ||
d77de738 | 18164 | @opindex lobjc |
ddf6fe37 | 18165 | @item -lobjc |
d77de738 ML |
18166 | You need this special case of the @option{-l} option in order to |
18167 | link an Objective-C or Objective-C++ program. | |
18168 | ||
d77de738 | 18169 | @opindex nostartfiles |
ddf6fe37 | 18170 | @item -nostartfiles |
d77de738 ML |
18171 | Do not use the standard system startup files when linking. |
18172 | The standard system libraries are used normally, unless @option{-nostdlib}, | |
18173 | @option{-nolibc}, or @option{-nodefaultlibs} is used. | |
18174 | ||
d77de738 | 18175 | @opindex nodefaultlibs |
ddf6fe37 | 18176 | @item -nodefaultlibs |
d77de738 ML |
18177 | Do not use the standard system libraries when linking. |
18178 | Only the libraries you specify are passed to the linker, and options | |
18179 | specifying linkage of the system libraries, such as @option{-static-libgcc} | |
18180 | or @option{-shared-libgcc}, are ignored. | |
18181 | The standard startup files are used normally, unless @option{-nostartfiles} | |
18182 | is used. | |
18183 | ||
18184 | The compiler may generate calls to @code{memcmp}, | |
18185 | @code{memset}, @code{memcpy} and @code{memmove}. | |
18186 | These entries are usually resolved by entries in | |
18187 | libc. These entry points should be supplied through some other | |
18188 | mechanism when this option is specified. | |
18189 | ||
d77de738 | 18190 | @opindex nolibc |
ddf6fe37 | 18191 | @item -nolibc |
d77de738 ML |
18192 | Do not use the C library or system libraries tightly coupled with it when |
18193 | linking. Still link with the startup files, @file{libgcc} or toolchain | |
18194 | provided language support libraries such as @file{libgnat}, @file{libgfortran} | |
18195 | or @file{libstdc++} unless options preventing their inclusion are used as | |
18196 | well. This typically removes @option{-lc} from the link command line, as well | |
18197 | as system libraries that normally go with it and become meaningless when | |
18198 | absence of a C library is assumed, for example @option{-lpthread} or | |
18199 | @option{-lm} in some configurations. This is intended for bare-board | |
18200 | targets when there is indeed no C library available. | |
18201 | ||
d77de738 | 18202 | @opindex nostdlib |
ddf6fe37 | 18203 | @item -nostdlib |
d77de738 ML |
18204 | Do not use the standard system startup files or libraries when linking. |
18205 | No startup files and only the libraries you specify are passed to | |
18206 | the linker, and options specifying linkage of the system libraries, such as | |
18207 | @option{-static-libgcc} or @option{-shared-libgcc}, are ignored. | |
18208 | ||
18209 | The compiler may generate calls to @code{memcmp}, @code{memset}, | |
18210 | @code{memcpy} and @code{memmove}. | |
18211 | These entries are usually resolved by entries in | |
18212 | libc. These entry points should be supplied through some other | |
18213 | mechanism when this option is specified. | |
18214 | ||
18215 | @cindex @option{-lgcc}, use with @option{-nostdlib} | |
18216 | @cindex @option{-nostdlib} and unresolved references | |
18217 | @cindex unresolved references and @option{-nostdlib} | |
18218 | @cindex @option{-lgcc}, use with @option{-nodefaultlibs} | |
18219 | @cindex @option{-nodefaultlibs} and unresolved references | |
18220 | @cindex unresolved references and @option{-nodefaultlibs} | |
18221 | One of the standard libraries bypassed by @option{-nostdlib} and | |
18222 | @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines | |
18223 | which GCC uses to overcome shortcomings of particular machines, or special | |
18224 | needs for some languages. | |
18225 | (@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler | |
18226 | Collection (GCC) Internals}, | |
18227 | for more discussion of @file{libgcc.a}.) | |
18228 | In most cases, you need @file{libgcc.a} even when you want to avoid | |
18229 | other standard libraries. In other words, when you specify @option{-nostdlib} | |
18230 | or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well. | |
18231 | This ensures that you have no unresolved references to internal GCC | |
18232 | library subroutines. | |
18233 | (An example of such an internal subroutine is @code{__main}, used to ensure C++ | |
18234 | constructors are called; @pxref{Collect2,,@code{collect2}, gccint, | |
18235 | GNU Compiler Collection (GCC) Internals}.) | |
18236 | ||
d77de738 | 18237 | @opindex nostdlib++ |
ddf6fe37 | 18238 | @item -nostdlib++ |
d77de738 ML |
18239 | Do not implicitly link with standard C++ libraries. |
18240 | ||
d77de738 ML |
18241 | @opindex e |
18242 | @opindex entry | |
ddf6fe37 AA |
18243 | @item -e @var{entry} |
18244 | @itemx --entry=@var{entry} | |
d77de738 ML |
18245 | |
18246 | Specify that the program entry point is @var{entry}. The argument is | |
18247 | interpreted by the linker; the GNU linker accepts either a symbol name | |
18248 | or an address. | |
18249 | ||
d77de738 | 18250 | @opindex pie |
ddf6fe37 | 18251 | @item -pie |
d77de738 ML |
18252 | Produce a dynamically linked position independent executable on targets |
18253 | that support it. For predictable results, you must also specify the same | |
18254 | set of options used for compilation (@option{-fpie}, @option{-fPIE}, | |
18255 | or model suboptions) when you specify this linker option. | |
18256 | ||
d77de738 | 18257 | @opindex no-pie |
ddf6fe37 | 18258 | @item -no-pie |
d77de738 ML |
18259 | Don't produce a dynamically linked position independent executable. |
18260 | ||
d77de738 | 18261 | @opindex static-pie |
ddf6fe37 | 18262 | @item -static-pie |
d77de738 ML |
18263 | Produce a static position independent executable on targets that support |
18264 | it. A static position independent executable is similar to a static | |
18265 | executable, but can be loaded at any address without a dynamic linker. | |
18266 | For predictable results, you must also specify the same set of options | |
18267 | used for compilation (@option{-fpie}, @option{-fPIE}, or model | |
18268 | suboptions) when you specify this linker option. | |
18269 | ||
d77de738 | 18270 | @opindex pthread |
ddf6fe37 | 18271 | @item -pthread |
d77de738 ML |
18272 | Link with the POSIX threads library. This option is supported on |
18273 | GNU/Linux targets, most other Unix derivatives, and also on | |
18274 | x86 Cygwin and MinGW targets. On some targets this option also sets | |
18275 | flags for the preprocessor, so it should be used consistently for both | |
18276 | compilation and linking. | |
18277 | ||
d77de738 | 18278 | @opindex r |
ddf6fe37 | 18279 | @item -r |
d77de738 ML |
18280 | Produce a relocatable object as output. This is also known as partial |
18281 | linking. | |
18282 | ||
d77de738 | 18283 | @opindex rdynamic |
ddf6fe37 | 18284 | @item -rdynamic |
d77de738 ML |
18285 | Pass the flag @option{-export-dynamic} to the ELF linker, on targets |
18286 | that support it. This instructs the linker to add all symbols, not | |
18287 | only used ones, to the dynamic symbol table. This option is needed | |
18288 | for some uses of @code{dlopen} or to allow obtaining backtraces | |
18289 | from within a program. | |
18290 | ||
d77de738 | 18291 | @opindex s |
ddf6fe37 | 18292 | @item -s |
d77de738 ML |
18293 | Remove all symbol table and relocation information from the executable. |
18294 | ||
d77de738 | 18295 | @opindex static |
ddf6fe37 | 18296 | @item -static |
d77de738 ML |
18297 | On systems that support dynamic linking, this overrides @option{-pie} |
18298 | and prevents linking with the shared libraries. On other systems, this | |
18299 | option has no effect. | |
18300 | ||
d77de738 | 18301 | @opindex shared |
ddf6fe37 | 18302 | @item -shared |
d77de738 ML |
18303 | Produce a shared object which can then be linked with other objects to |
18304 | form an executable. Not all systems support this option. For predictable | |
18305 | results, you must also specify the same set of options used for compilation | |
18306 | (@option{-fpic}, @option{-fPIC}, or model suboptions) when | |
18307 | you specify this linker option.@footnote{On some systems, @samp{gcc -shared} | |
18308 | needs to build supplementary stub code for constructors to work. On | |
18309 | multi-libbed systems, @samp{gcc -shared} must select the correct support | |
18310 | libraries to link against. Failing to supply the correct flags may lead | |
18311 | to subtle defects. Supplying them in cases where they are not necessary | |
b799acef RB |
18312 | is innocuous. @option{-shared} suppresses the addition of startup code |
18313 | to alter the floating-point environment as done with @option{-ffast-math}, | |
18314 | @option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.} | |
d77de738 | 18315 | |
d77de738 ML |
18316 | @opindex shared-libgcc |
18317 | @opindex static-libgcc | |
ddf6fe37 AA |
18318 | @item -shared-libgcc |
18319 | @itemx -static-libgcc | |
d77de738 ML |
18320 | On systems that provide @file{libgcc} as a shared library, these options |
18321 | force the use of either the shared or static version, respectively. | |
18322 | If no shared version of @file{libgcc} was built when the compiler was | |
18323 | configured, these options have no effect. | |
18324 | ||
18325 | There are several situations in which an application should use the | |
18326 | shared @file{libgcc} instead of the static version. The most common | |
18327 | of these is when the application wishes to throw and catch exceptions | |
18328 | across different shared libraries. In that case, each of the libraries | |
18329 | as well as the application itself should use the shared @file{libgcc}. | |
18330 | ||
18331 | Therefore, the G++ driver automatically adds @option{-shared-libgcc} | |
18332 | whenever you build a shared library or a main executable, because C++ | |
18333 | programs typically use exceptions, so this is the right thing to do. | |
18334 | ||
18335 | If, instead, you use the GCC driver to create shared libraries, you may | |
18336 | find that they are not always linked with the shared @file{libgcc}. | |
18337 | If GCC finds, at its configuration time, that you have a non-GNU linker | |
18338 | or a GNU linker that does not support option @option{--eh-frame-hdr}, | |
18339 | it links the shared version of @file{libgcc} into shared libraries | |
18340 | by default. Otherwise, it takes advantage of the linker and optimizes | |
18341 | away the linking with the shared version of @file{libgcc}, linking with | |
18342 | the static version of libgcc by default. This allows exceptions to | |
18343 | propagate through such shared libraries, without incurring relocation | |
18344 | costs at library load time. | |
18345 | ||
18346 | However, if a library or main executable is supposed to throw or catch | |
18347 | exceptions, you must link it using the G++ driver, or using the option | |
18348 | @option{-shared-libgcc}, such that it is linked with the shared | |
18349 | @file{libgcc}. | |
18350 | ||
d77de738 | 18351 | @opindex static-libasan |
ddf6fe37 | 18352 | @item -static-libasan |
d77de738 ML |
18353 | When the @option{-fsanitize=address} option is used to link a program, |
18354 | the GCC driver automatically links against @option{libasan}. If | |
18355 | @file{libasan} is available as a shared library, and the @option{-static} | |
18356 | option is not used, then this links against the shared version of | |
18357 | @file{libasan}. The @option{-static-libasan} option directs the GCC | |
18358 | driver to link @file{libasan} statically, without necessarily linking | |
18359 | other libraries statically. | |
18360 | ||
d77de738 | 18361 | @opindex static-libtsan |
ddf6fe37 | 18362 | @item -static-libtsan |
d77de738 ML |
18363 | When the @option{-fsanitize=thread} option is used to link a program, |
18364 | the GCC driver automatically links against @option{libtsan}. If | |
18365 | @file{libtsan} is available as a shared library, and the @option{-static} | |
18366 | option is not used, then this links against the shared version of | |
18367 | @file{libtsan}. The @option{-static-libtsan} option directs the GCC | |
18368 | driver to link @file{libtsan} statically, without necessarily linking | |
18369 | other libraries statically. | |
18370 | ||
d77de738 | 18371 | @opindex static-liblsan |
ddf6fe37 | 18372 | @item -static-liblsan |
d77de738 ML |
18373 | When the @option{-fsanitize=leak} option is used to link a program, |
18374 | the GCC driver automatically links against @option{liblsan}. If | |
18375 | @file{liblsan} is available as a shared library, and the @option{-static} | |
18376 | option is not used, then this links against the shared version of | |
18377 | @file{liblsan}. The @option{-static-liblsan} option directs the GCC | |
18378 | driver to link @file{liblsan} statically, without necessarily linking | |
18379 | other libraries statically. | |
18380 | ||
d77de738 | 18381 | @opindex static-libubsan |
ddf6fe37 | 18382 | @item -static-libubsan |
d77de738 ML |
18383 | When the @option{-fsanitize=undefined} option is used to link a program, |
18384 | the GCC driver automatically links against @option{libubsan}. If | |
18385 | @file{libubsan} is available as a shared library, and the @option{-static} | |
18386 | option is not used, then this links against the shared version of | |
18387 | @file{libubsan}. The @option{-static-libubsan} option directs the GCC | |
18388 | driver to link @file{libubsan} statically, without necessarily linking | |
18389 | other libraries statically. | |
18390 | ||
d77de738 | 18391 | @opindex static-libstdc++ |
ddf6fe37 | 18392 | @item -static-libstdc++ |
d77de738 ML |
18393 | When the @command{g++} program is used to link a C++ program, it |
18394 | normally automatically links against @option{libstdc++}. If | |
18395 | @file{libstdc++} is available as a shared library, and the | |
18396 | @option{-static} option is not used, then this links against the | |
18397 | shared version of @file{libstdc++}. That is normally fine. However, it | |
18398 | is sometimes useful to freeze the version of @file{libstdc++} used by | |
18399 | the program without going all the way to a fully static link. The | |
18400 | @option{-static-libstdc++} option directs the @command{g++} driver to | |
18401 | link @file{libstdc++} statically, without necessarily linking other | |
18402 | libraries statically. | |
18403 | ||
d77de738 | 18404 | @opindex symbolic |
ddf6fe37 | 18405 | @item -symbolic |
d77de738 ML |
18406 | Bind references to global symbols when building a shared object. Warn |
18407 | about any unresolved references (unless overridden by the link editor | |
18408 | option @option{-Xlinker -z -Xlinker defs}). Only a few systems support | |
18409 | this option. | |
18410 | ||
d77de738 ML |
18411 | @opindex T |
18412 | @cindex linker script | |
f33d7a88 | 18413 | @item -T @var{script} |
d77de738 ML |
18414 | Use @var{script} as the linker script. This option is supported by most |
18415 | systems using the GNU linker. On some targets, such as bare-board | |
18416 | targets without an operating system, the @option{-T} option may be required | |
18417 | when linking to avoid references to undefined symbols. | |
18418 | ||
d77de738 | 18419 | @opindex Xlinker |
ddf6fe37 | 18420 | @item -Xlinker @var{option} |
d77de738 ML |
18421 | Pass @var{option} as an option to the linker. You can use this to |
18422 | supply system-specific linker options that GCC does not recognize. | |
18423 | ||
18424 | If you want to pass an option that takes a separate argument, you must use | |
18425 | @option{-Xlinker} twice, once for the option and once for the argument. | |
18426 | For example, to pass @option{-assert definitions}, you must write | |
18427 | @option{-Xlinker -assert -Xlinker definitions}. It does not work to write | |
18428 | @option{-Xlinker "-assert definitions"}, because this passes the entire | |
18429 | string as a single argument, which is not what the linker expects. | |
18430 | ||
18431 | When using the GNU linker, it is usually more convenient to pass | |
18432 | arguments to linker options using the @option{@var{option}=@var{value}} | |
18433 | syntax than as separate arguments. For example, you can specify | |
18434 | @option{-Xlinker -Map=output.map} rather than | |
18435 | @option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support | |
18436 | this syntax for command-line options. | |
18437 | ||
d77de738 | 18438 | @opindex Wl |
ddf6fe37 | 18439 | @item -Wl,@var{option} |
d77de738 ML |
18440 | Pass @var{option} as an option to the linker. If @var{option} contains |
18441 | commas, it is split into multiple options at the commas. You can use this | |
18442 | syntax to pass an argument to the option. | |
18443 | For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the | |
18444 | linker. When using the GNU linker, you can also get the same effect with | |
18445 | @option{-Wl,-Map=output.map}. | |
18446 | ||
d77de738 | 18447 | @opindex u |
ddf6fe37 | 18448 | @item -u @var{symbol} |
d77de738 ML |
18449 | Pretend the symbol @var{symbol} is undefined, to force linking of |
18450 | library modules to define it. You can use @option{-u} multiple times with | |
18451 | different symbols to force loading of additional library modules. | |
18452 | ||
d77de738 | 18453 | @opindex z |
ddf6fe37 | 18454 | @item -z @var{keyword} |
d77de738 ML |
18455 | @option{-z} is passed directly on to the linker along with the keyword |
18456 | @var{keyword}. See the section in the documentation of your linker for | |
18457 | permitted values and their meanings. | |
18458 | @end table | |
18459 | ||
18460 | @node Directory Options | |
18461 | @section Options for Directory Search | |
18462 | @cindex directory options | |
18463 | @cindex options, directory search | |
18464 | @cindex search path | |
18465 | ||
18466 | These options specify directories to search for header files, for | |
18467 | libraries and for parts of the compiler: | |
18468 | ||
18469 | @table @gcctabopt | |
18470 | @include cppdiropts.texi | |
18471 | ||
d77de738 | 18472 | @opindex iplugindir= |
ddf6fe37 | 18473 | @item -iplugindir=@var{dir} |
d77de738 ML |
18474 | Set the directory to search for plugins that are passed |
18475 | by @option{-fplugin=@var{name}} instead of | |
18476 | @option{-fplugin=@var{path}/@var{name}.so}. This option is not meant | |
18477 | to be used by the user, but only passed by the driver. | |
18478 | ||
d77de738 | 18479 | @opindex L |
ddf6fe37 | 18480 | @item -L@var{dir} |
d77de738 ML |
18481 | Add directory @var{dir} to the list of directories to be searched |
18482 | for @option{-l}. | |
18483 | ||
d77de738 | 18484 | @opindex B |
ddf6fe37 | 18485 | @item -B@var{prefix} |
d77de738 ML |
18486 | This option specifies where to find the executables, libraries, |
18487 | include files, and data files of the compiler itself. | |
18488 | ||
18489 | The compiler driver program runs one or more of the subprograms | |
18490 | @command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries | |
18491 | @var{prefix} as a prefix for each program it tries to run, both with and | |
18492 | without @samp{@var{machine}/@var{version}/} for the corresponding target | |
18493 | machine and compiler version. | |
18494 | ||
18495 | For each subprogram to be run, the compiler driver first tries the | |
18496 | @option{-B} prefix, if any. If that name is not found, or if @option{-B} | |
18497 | is not specified, the driver tries two standard prefixes, | |
18498 | @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of | |
18499 | those results in a file name that is found, the unmodified program | |
18500 | name is searched for using the directories specified in your | |
18501 | @env{PATH} environment variable. | |
18502 | ||
18503 | The compiler checks to see if the path provided by @option{-B} | |
18504 | refers to a directory, and if necessary it adds a directory | |
18505 | separator character at the end of the path. | |
18506 | ||
18507 | @option{-B} prefixes that effectively specify directory names also apply | |
18508 | to libraries in the linker, because the compiler translates these | |
18509 | options into @option{-L} options for the linker. They also apply to | |
18510 | include files in the preprocessor, because the compiler translates these | |
18511 | options into @option{-isystem} options for the preprocessor. In this case, | |
18512 | the compiler appends @samp{include} to the prefix. | |
18513 | ||
18514 | The runtime support file @file{libgcc.a} can also be searched for using | |
18515 | the @option{-B} prefix, if needed. If it is not found there, the two | |
18516 | standard prefixes above are tried, and that is all. The file is left | |
18517 | out of the link if it is not found by those means. | |
18518 | ||
18519 | Another way to specify a prefix much like the @option{-B} prefix is to use | |
18520 | the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment | |
18521 | Variables}. | |
18522 | ||
18523 | As a special kludge, if the path provided by @option{-B} is | |
18524 | @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to | |
18525 | 9, then it is replaced by @file{[dir/]include}. This is to help | |
18526 | with boot-strapping the compiler. | |
18527 | ||
d77de738 | 18528 | @opindex no-canonical-prefixes |
ddf6fe37 | 18529 | @item -no-canonical-prefixes |
d77de738 ML |
18530 | Do not expand any symbolic links, resolve references to @samp{/../} |
18531 | or @samp{/./}, or make the path absolute when generating a relative | |
18532 | prefix. | |
18533 | ||
d77de738 | 18534 | @opindex sysroot |
ddf6fe37 | 18535 | @item --sysroot=@var{dir} |
d77de738 ML |
18536 | Use @var{dir} as the logical root directory for headers and libraries. |
18537 | For example, if the compiler normally searches for headers in | |
18538 | @file{/usr/include} and libraries in @file{/usr/lib}, it instead | |
18539 | searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}. | |
18540 | ||
18541 | If you use both this option and the @option{-isysroot} option, then | |
18542 | the @option{--sysroot} option applies to libraries, but the | |
18543 | @option{-isysroot} option applies to header files. | |
18544 | ||
18545 | The GNU linker (beginning with version 2.16) has the necessary support | |
18546 | for this option. If your linker does not support this option, the | |
18547 | header file aspect of @option{--sysroot} still works, but the | |
18548 | library aspect does not. | |
18549 | ||
d77de738 | 18550 | @opindex no-sysroot-suffix |
ddf6fe37 | 18551 | @item --no-sysroot-suffix |
d77de738 ML |
18552 | For some targets, a suffix is added to the root directory specified |
18553 | with @option{--sysroot}, depending on the other options used, so that | |
18554 | headers may for example be found in | |
18555 | @file{@var{dir}/@var{suffix}/usr/include} instead of | |
18556 | @file{@var{dir}/usr/include}. This option disables the addition of | |
18557 | such a suffix. | |
18558 | ||
18559 | @end table | |
18560 | ||
18561 | @node Code Gen Options | |
18562 | @section Options for Code Generation Conventions | |
18563 | @cindex code generation conventions | |
18564 | @cindex options, code generation | |
18565 | @cindex run-time options | |
18566 | ||
18567 | These machine-independent options control the interface conventions | |
18568 | used in code generation. | |
18569 | ||
18570 | Most of them have both positive and negative forms; the negative form | |
18571 | of @option{-ffoo} is @option{-fno-foo}. In the table below, only | |
18572 | one of the forms is listed---the one that is not the default. You | |
18573 | can figure out the other form by either removing @samp{no-} or adding | |
18574 | it. | |
18575 | ||
18576 | @table @gcctabopt | |
d77de738 | 18577 | @opindex fstack_reuse |
ddf6fe37 | 18578 | @item -fstack-reuse=@var{reuse-level} |
d77de738 ML |
18579 | This option controls stack space reuse for user declared local/auto variables |
18580 | and compiler generated temporaries. @var{reuse_level} can be @samp{all}, | |
18581 | @samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all | |
18582 | local variables and temporaries, @samp{named_vars} enables the reuse only for | |
18583 | user defined local variables with names, and @samp{none} disables stack reuse | |
18584 | completely. The default value is @samp{all}. The option is needed when the | |
18585 | program extends the lifetime of a scoped local variable or a compiler generated | |
18586 | temporary beyond the end point defined by the language. When a lifetime of | |
18587 | a variable ends, and if the variable lives in memory, the optimizing compiler | |
18588 | has the freedom to reuse its stack space with other temporaries or scoped | |
18589 | local variables whose live range does not overlap with it. Legacy code extending | |
18590 | local lifetime is likely to break with the stack reuse optimization. | |
18591 | ||
18592 | For example, | |
18593 | ||
18594 | @smallexample | |
18595 | int *p; | |
18596 | @{ | |
18597 | int local1; | |
18598 | ||
18599 | p = &local1; | |
18600 | local1 = 10; | |
18601 | .... | |
18602 | @} | |
18603 | @{ | |
18604 | int local2; | |
18605 | local2 = 20; | |
18606 | ... | |
18607 | @} | |
18608 | ||
18609 | if (*p == 10) // out of scope use of local1 | |
18610 | @{ | |
18611 | ||
18612 | @} | |
18613 | @end smallexample | |
18614 | ||
18615 | Another example: | |
18616 | @smallexample | |
18617 | ||
18618 | struct A | |
18619 | @{ | |
18620 | A(int k) : i(k), j(k) @{ @} | |
18621 | int i; | |
18622 | int j; | |
18623 | @}; | |
18624 | ||
18625 | A *ap; | |
18626 | ||
18627 | void foo(const A& ar) | |
18628 | @{ | |
18629 | ap = &ar; | |
18630 | @} | |
18631 | ||
18632 | void bar() | |
18633 | @{ | |
18634 | foo(A(10)); // temp object's lifetime ends when foo returns | |
18635 | ||
18636 | @{ | |
18637 | A a(20); | |
18638 | .... | |
18639 | @} | |
18640 | ap->i+= 10; // ap references out of scope temp whose space | |
18641 | // is reused with a. What is the value of ap->i? | |
18642 | @} | |
18643 | ||
18644 | @end smallexample | |
18645 | ||
18646 | The lifetime of a compiler generated temporary is well defined by the C++ | |
18647 | standard. When a lifetime of a temporary ends, and if the temporary lives | |
18648 | in memory, the optimizing compiler has the freedom to reuse its stack | |
18649 | space with other temporaries or scoped local variables whose live range | |
18650 | does not overlap with it. However some of the legacy code relies on | |
18651 | the behavior of older compilers in which temporaries' stack space is | |
18652 | not reused, the aggressive stack reuse can lead to runtime errors. This | |
18653 | option is used to control the temporary stack reuse optimization. | |
18654 | ||
d77de738 | 18655 | @opindex ftrapv |
ddf6fe37 | 18656 | @item -ftrapv |
d77de738 ML |
18657 | This option generates traps for signed overflow on addition, subtraction, |
18658 | multiplication operations. | |
18659 | The options @option{-ftrapv} and @option{-fwrapv} override each other, so using | |
18660 | @option{-ftrapv} @option{-fwrapv} on the command-line results in | |
18661 | @option{-fwrapv} being effective. Note that only active options override, so | |
18662 | using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line | |
18663 | results in @option{-ftrapv} being effective. | |
18664 | ||
d77de738 | 18665 | @opindex fwrapv |
ddf6fe37 | 18666 | @item -fwrapv |
d77de738 ML |
18667 | This option instructs the compiler to assume that signed arithmetic |
18668 | overflow of addition, subtraction and multiplication wraps around | |
18669 | using twos-complement representation. This flag enables some optimizations | |
18670 | and disables others. | |
18671 | The options @option{-ftrapv} and @option{-fwrapv} override each other, so using | |
18672 | @option{-ftrapv} @option{-fwrapv} on the command-line results in | |
18673 | @option{-fwrapv} being effective. Note that only active options override, so | |
18674 | using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line | |
18675 | results in @option{-ftrapv} being effective. | |
18676 | ||
d77de738 | 18677 | @opindex fwrapv-pointer |
ddf6fe37 | 18678 | @item -fwrapv-pointer |
d77de738 ML |
18679 | This option instructs the compiler to assume that pointer arithmetic |
18680 | overflow on addition and subtraction wraps around using twos-complement | |
18681 | representation. This flag disables some optimizations which assume | |
18682 | pointer overflow is invalid. | |
18683 | ||
d77de738 | 18684 | @opindex fstrict-overflow |
ddf6fe37 | 18685 | @item -fstrict-overflow |
d77de738 ML |
18686 | This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when |
18687 | negated implies @option{-fwrapv} @option{-fwrapv-pointer}. | |
18688 | ||
d77de738 | 18689 | @opindex fexceptions |
ddf6fe37 | 18690 | @item -fexceptions |
d77de738 ML |
18691 | Enable exception handling. Generates extra code needed to propagate |
18692 | exceptions. For some targets, this implies GCC generates frame | |
18693 | unwind information for all functions, which can produce significant data | |
18694 | size overhead, although it does not affect execution. If you do not | |
18695 | specify this option, GCC enables it by default for languages like | |
18696 | C++ that normally require exception handling, and disables it for | |
18697 | languages like C that do not normally require it. However, you may need | |
18698 | to enable this option when compiling C code that needs to interoperate | |
18699 | properly with exception handlers written in C++. You may also wish to | |
18700 | disable this option if you are compiling older C++ programs that don't | |
18701 | use exception handling. | |
18702 | ||
d77de738 | 18703 | @opindex fnon-call-exceptions |
ddf6fe37 | 18704 | @item -fnon-call-exceptions |
d77de738 ML |
18705 | Generate code that allows trapping instructions to throw exceptions. |
18706 | Note that this requires platform-specific runtime support that does | |
18707 | not exist everywhere. Moreover, it only allows @emph{trapping} | |
18708 | instructions to throw exceptions, i.e.@: memory references or floating-point | |
18709 | instructions. It does not allow exceptions to be thrown from | |
18710 | arbitrary signal handlers such as @code{SIGALRM}. This enables | |
18711 | @option{-fexceptions}. | |
18712 | ||
d77de738 | 18713 | @opindex fdelete-dead-exceptions |
ddf6fe37 | 18714 | @item -fdelete-dead-exceptions |
d77de738 ML |
18715 | Consider that instructions that may throw exceptions but don't otherwise |
18716 | contribute to the execution of the program can be optimized away. | |
18717 | This does not affect calls to functions except those with the | |
18718 | @code{pure} or @code{const} attributes. | |
18719 | This option is enabled by default for the Ada and C++ compilers, as permitted by | |
18720 | the language specifications. | |
18721 | Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels. | |
18722 | ||
d77de738 | 18723 | @opindex funwind-tables |
ddf6fe37 | 18724 | @item -funwind-tables |
d77de738 ML |
18725 | Similar to @option{-fexceptions}, except that it just generates any needed |
18726 | static data, but does not affect the generated code in any other way. | |
18727 | You normally do not need to enable this option; instead, a language processor | |
18728 | that needs this handling enables it on your behalf. | |
18729 | ||
d77de738 | 18730 | @opindex fasynchronous-unwind-tables |
ddf6fe37 | 18731 | @item -fasynchronous-unwind-tables |
d77de738 ML |
18732 | Generate unwind table in DWARF format, if supported by target machine. The |
18733 | table is exact at each instruction boundary, so it can be used for stack | |
18734 | unwinding from asynchronous events (such as debugger or garbage collector). | |
18735 | ||
d77de738 ML |
18736 | @opindex fno-gnu-unique |
18737 | @opindex fgnu-unique | |
ddf6fe37 | 18738 | @item -fno-gnu-unique |
d77de738 ML |
18739 | On systems with recent GNU assembler and C library, the C++ compiler |
18740 | uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions | |
18741 | of template static data members and static local variables in inline | |
18742 | functions are unique even in the presence of @code{RTLD_LOCAL}; this | |
18743 | is necessary to avoid problems with a library used by two different | |
18744 | @code{RTLD_LOCAL} plugins depending on a definition in one of them and | |
18745 | therefore disagreeing with the other one about the binding of the | |
18746 | symbol. But this causes @code{dlclose} to be ignored for affected | |
18747 | DSOs; if your program relies on reinitialization of a DSO via | |
18748 | @code{dlclose} and @code{dlopen}, you can use | |
18749 | @option{-fno-gnu-unique}. | |
18750 | ||
d77de738 | 18751 | @opindex fpcc-struct-return |
ddf6fe37 | 18752 | @item -fpcc-struct-return |
d77de738 ML |
18753 | Return ``short'' @code{struct} and @code{union} values in memory like |
18754 | longer ones, rather than in registers. This convention is less | |
18755 | efficient, but it has the advantage of allowing intercallability between | |
18756 | GCC-compiled files and files compiled with other compilers, particularly | |
18757 | the Portable C Compiler (pcc). | |
18758 | ||
18759 | The precise convention for returning structures in memory depends | |
18760 | on the target configuration macros. | |
18761 | ||
18762 | Short structures and unions are those whose size and alignment match | |
18763 | that of some integer type. | |
18764 | ||
18765 | @strong{Warning:} code compiled with the @option{-fpcc-struct-return} | |
18766 | switch is not binary compatible with code compiled with the | |
18767 | @option{-freg-struct-return} switch. | |
18768 | Use it to conform to a non-default application binary interface. | |
18769 | ||
d77de738 | 18770 | @opindex freg-struct-return |
ddf6fe37 | 18771 | @item -freg-struct-return |
d77de738 ML |
18772 | Return @code{struct} and @code{union} values in registers when possible. |
18773 | This is more efficient for small structures than | |
18774 | @option{-fpcc-struct-return}. | |
18775 | ||
18776 | If you specify neither @option{-fpcc-struct-return} nor | |
18777 | @option{-freg-struct-return}, GCC defaults to whichever convention is | |
18778 | standard for the target. If there is no standard convention, GCC | |
18779 | defaults to @option{-fpcc-struct-return}, except on targets where GCC is | |
18780 | the principal compiler. In those cases, we can choose the standard, and | |
18781 | we chose the more efficient register return alternative. | |
18782 | ||
18783 | @strong{Warning:} code compiled with the @option{-freg-struct-return} | |
18784 | switch is not binary compatible with code compiled with the | |
18785 | @option{-fpcc-struct-return} switch. | |
18786 | Use it to conform to a non-default application binary interface. | |
18787 | ||
d77de738 | 18788 | @opindex fshort-enums |
ddf6fe37 | 18789 | @item -fshort-enums |
d77de738 ML |
18790 | Allocate to an @code{enum} type only as many bytes as it needs for the |
18791 | declared range of possible values. Specifically, the @code{enum} type | |
18792 | is equivalent to the smallest integer type that has enough room. | |
d8a656d5 JW |
18793 | This option has no effect for an enumeration type with a fixed underlying |
18794 | type. | |
d77de738 ML |
18795 | |
18796 | @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate | |
18797 | code that is not binary compatible with code generated without that switch. | |
18798 | Use it to conform to a non-default application binary interface. | |
18799 | ||
d77de738 | 18800 | @opindex fshort-wchar |
ddf6fe37 | 18801 | @item -fshort-wchar |
d77de738 ML |
18802 | Override the underlying type for @code{wchar_t} to be @code{short |
18803 | unsigned int} instead of the default for the target. This option is | |
18804 | useful for building programs to run under WINE@. | |
18805 | ||
18806 | @strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate | |
18807 | code that is not binary compatible with code generated without that switch. | |
18808 | Use it to conform to a non-default application binary interface. | |
18809 | ||
d77de738 ML |
18810 | @opindex fcommon |
18811 | @opindex fno-common | |
18812 | @cindex tentative definitions | |
f33d7a88 | 18813 | @item -fcommon |
d77de738 ML |
18814 | In C code, this option controls the placement of global variables |
18815 | defined without an initializer, known as @dfn{tentative definitions} | |
18816 | in the C standard. Tentative definitions are distinct from declarations | |
18817 | of a variable with the @code{extern} keyword, which do not allocate storage. | |
18818 | ||
18819 | The default is @option{-fno-common}, which specifies that the compiler places | |
18820 | uninitialized global variables in the BSS section of the object file. | |
18821 | This inhibits the merging of tentative definitions by the linker so you get a | |
18822 | multiple-definition error if the same variable is accidentally defined in more | |
18823 | than one compilation unit. | |
18824 | ||
18825 | The @option{-fcommon} places uninitialized global variables in a common block. | |
18826 | This allows the linker to resolve all tentative definitions of the same variable | |
18827 | in different compilation units to the same object, or to a non-tentative | |
18828 | definition. This behavior is inconsistent with C++, and on many targets implies | |
18829 | a speed and code size penalty on global variable references. It is mainly | |
18830 | useful to enable legacy code to link without errors. | |
18831 | ||
d77de738 ML |
18832 | @opindex fno-ident |
18833 | @opindex fident | |
ddf6fe37 | 18834 | @item -fno-ident |
d77de738 ML |
18835 | Ignore the @code{#ident} directive. |
18836 | ||
d77de738 | 18837 | @opindex finhibit-size-directive |
ddf6fe37 | 18838 | @item -finhibit-size-directive |
d77de738 ML |
18839 | Don't output a @code{.size} assembler directive, or anything else that |
18840 | would cause trouble if the function is split in the middle, and the | |
18841 | two halves are placed at locations far apart in memory. This option is | |
18842 | used when compiling @file{crtstuff.c}; you should not need to use it | |
18843 | for anything else. | |
18844 | ||
d77de738 | 18845 | @opindex fverbose-asm |
ddf6fe37 | 18846 | @item -fverbose-asm |
d77de738 ML |
18847 | Put extra commentary information in the generated assembly code to |
18848 | make it more readable. This option is generally only of use to those | |
18849 | who actually need to read the generated assembly code (perhaps while | |
18850 | debugging the compiler itself). | |
18851 | ||
18852 | @option{-fno-verbose-asm}, the default, causes the | |
18853 | extra information to be omitted and is useful when comparing two assembler | |
18854 | files. | |
18855 | ||
18856 | The added comments include: | |
18857 | ||
18858 | @itemize @bullet | |
18859 | ||
18860 | @item | |
18861 | information on the compiler version and command-line options, | |
18862 | ||
18863 | @item | |
18864 | the source code lines associated with the assembly instructions, | |
18865 | in the form FILENAME:LINENUMBER:CONTENT OF LINE, | |
18866 | ||
18867 | @item | |
18868 | hints on which high-level expressions correspond to | |
18869 | the various assembly instruction operands. | |
18870 | ||
18871 | @end itemize | |
18872 | ||
18873 | For example, given this C source file: | |
18874 | ||
18875 | @smallexample | |
18876 | int test (int n) | |
18877 | @{ | |
18878 | int i; | |
18879 | int total = 0; | |
18880 | ||
18881 | for (i = 0; i < n; i++) | |
18882 | total += i * i; | |
18883 | ||
18884 | return total; | |
18885 | @} | |
18886 | @end smallexample | |
18887 | ||
18888 | compiling to (x86_64) assembly via @option{-S} and emitting the result | |
18889 | direct to stdout via @option{-o} @option{-} | |
18890 | ||
18891 | @smallexample | |
18892 | gcc -S test.c -fverbose-asm -Os -o - | |
18893 | @end smallexample | |
18894 | ||
18895 | gives output similar to this: | |
18896 | ||
18897 | @smallexample | |
18898 | .file "test.c" | |
18899 | # GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu) | |
18900 | [...snip...] | |
18901 | # options passed: | |
18902 | [...snip...] | |
18903 | ||
18904 | .text | |
18905 | .globl test | |
18906 | .type test, @@function | |
18907 | test: | |
18908 | .LFB0: | |
18909 | .cfi_startproc | |
18910 | # test.c:4: int total = 0; | |
18911 | xorl %eax, %eax # <retval> | |
18912 | # test.c:6: for (i = 0; i < n; i++) | |
18913 | xorl %edx, %edx # i | |
18914 | .L2: | |
18915 | # test.c:6: for (i = 0; i < n; i++) | |
18916 | cmpl %edi, %edx # n, i | |
18917 | jge .L5 #, | |
18918 | # test.c:7: total += i * i; | |
18919 | movl %edx, %ecx # i, tmp92 | |
18920 | imull %edx, %ecx # i, tmp92 | |
18921 | # test.c:6: for (i = 0; i < n; i++) | |
18922 | incl %edx # i | |
18923 | # test.c:7: total += i * i; | |
18924 | addl %ecx, %eax # tmp92, <retval> | |
18925 | jmp .L2 # | |
18926 | .L5: | |
18927 | # test.c:10: @} | |
18928 | ret | |
18929 | .cfi_endproc | |
18930 | .LFE0: | |
18931 | .size test, .-test | |
18932 | .ident "GCC: (GNU) 7.0.0 20160809 (experimental)" | |
18933 | .section .note.GNU-stack,"",@@progbits | |
18934 | @end smallexample | |
18935 | ||
18936 | The comments are intended for humans rather than machines and hence the | |
18937 | precise format of the comments is subject to change. | |
18938 | ||
d77de738 | 18939 | @opindex frecord-gcc-switches |
ddf6fe37 | 18940 | @item -frecord-gcc-switches |
d77de738 ML |
18941 | This switch causes the command line used to invoke the |
18942 | compiler to be recorded into the object file that is being created. | |
18943 | This switch is only implemented on some targets and the exact format | |
18944 | of the recording is target and binary file format dependent, but it | |
18945 | usually takes the form of a section containing ASCII text. This | |
18946 | switch is related to the @option{-fverbose-asm} switch, but that | |
18947 | switch only records information in the assembler output file as | |
18948 | comments, so it never reaches the object file. | |
18949 | See also @option{-grecord-gcc-switches} for another | |
18950 | way of storing compiler options into the object file. | |
18951 | ||
d77de738 ML |
18952 | @opindex fpic |
18953 | @cindex global offset table | |
18954 | @cindex PIC | |
f33d7a88 | 18955 | @item -fpic |
d77de738 ML |
18956 | Generate position-independent code (PIC) suitable for use in a shared |
18957 | library, if supported for the target machine. Such code accesses all | |
18958 | constant addresses through a global offset table (GOT)@. The dynamic | |
18959 | loader resolves the GOT entries when the program starts (the dynamic | |
18960 | loader is not part of GCC; it is part of the operating system). If | |
18961 | the GOT size for the linked executable exceeds a machine-specific | |
18962 | maximum size, you get an error message from the linker indicating that | |
18963 | @option{-fpic} does not work; in that case, recompile with @option{-fPIC} | |
18964 | instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k | |
18965 | on the m68k and RS/6000. The x86 has no such limit.) | |
18966 | ||
18967 | Position-independent code requires special support, and therefore works | |
18968 | only on certain machines. For the x86, GCC supports PIC for System V | |
18969 | but not for the Sun 386i. Code generated for the IBM RS/6000 is always | |
18970 | position-independent. | |
18971 | ||
18972 | When this flag is set, the macros @code{__pic__} and @code{__PIC__} | |
18973 | are defined to 1. | |
18974 | ||
d77de738 | 18975 | @opindex fPIC |
ddf6fe37 | 18976 | @item -fPIC |
d77de738 ML |
18977 | If supported for the target machine, emit position-independent code, |
18978 | suitable for dynamic linking and avoiding any limit on the size of the | |
18979 | global offset table. This option makes a difference on AArch64, m68k, | |
18980 | PowerPC and SPARC@. | |
18981 | ||
18982 | Position-independent code requires special support, and therefore works | |
18983 | only on certain machines. | |
18984 | ||
18985 | When this flag is set, the macros @code{__pic__} and @code{__PIC__} | |
18986 | are defined to 2. | |
18987 | ||
d77de738 ML |
18988 | @opindex fpie |
18989 | @opindex fPIE | |
ddf6fe37 AA |
18990 | @item -fpie |
18991 | @itemx -fPIE | |
d77de738 ML |
18992 | These options are similar to @option{-fpic} and @option{-fPIC}, but the |
18993 | generated position-independent code can be only linked into executables. | |
18994 | Usually these options are used to compile code that will be linked using | |
18995 | the @option{-pie} GCC option. | |
18996 | ||
18997 | @option{-fpie} and @option{-fPIE} both define the macros | |
18998 | @code{__pie__} and @code{__PIE__}. The macros have the value 1 | |
18999 | for @option{-fpie} and 2 for @option{-fPIE}. | |
19000 | ||
d77de738 ML |
19001 | @opindex fno-plt |
19002 | @opindex fplt | |
ddf6fe37 | 19003 | @item -fno-plt |
d77de738 ML |
19004 | Do not use the PLT for external function calls in position-independent code. |
19005 | Instead, load the callee address at call sites from the GOT and branch to it. | |
19006 | This leads to more efficient code by eliminating PLT stubs and exposing | |
19007 | GOT loads to optimizations. On architectures such as 32-bit x86 where | |
19008 | PLT stubs expect the GOT pointer in a specific register, this gives more | |
19009 | register allocation freedom to the compiler. | |
19010 | Lazy binding requires use of the PLT; | |
19011 | with @option{-fno-plt} all external symbols are resolved at load time. | |
19012 | ||
19013 | Alternatively, the function attribute @code{noplt} can be used to avoid calls | |
19014 | through the PLT for specific external functions. | |
19015 | ||
19016 | In position-dependent code, a few targets also convert calls to | |
19017 | functions that are marked to not use the PLT to use the GOT instead. | |
19018 | ||
d77de738 ML |
19019 | @opindex fno-jump-tables |
19020 | @opindex fjump-tables | |
ddf6fe37 | 19021 | @item -fno-jump-tables |
d77de738 ML |
19022 | Do not use jump tables for switch statements even where it would be |
19023 | more efficient than other code generation strategies. This option is | |
19024 | of use in conjunction with @option{-fpic} or @option{-fPIC} for | |
19025 | building code that forms part of a dynamic linker and cannot | |
19026 | reference the address of a jump table. On some targets, jump tables | |
19027 | do not require a GOT and this option is not needed. | |
19028 | ||
d77de738 ML |
19029 | @opindex fno-bit-tests |
19030 | @opindex fbit-tests | |
ddf6fe37 | 19031 | @item -fno-bit-tests |
d77de738 ML |
19032 | Do not use bit tests for switch statements even where it would be |
19033 | more efficient than other code generation strategies. | |
19034 | ||
d77de738 | 19035 | @opindex ffixed |
ddf6fe37 | 19036 | @item -ffixed-@var{reg} |
d77de738 ML |
19037 | Treat the register named @var{reg} as a fixed register; generated code |
19038 | should never refer to it (except perhaps as a stack pointer, frame | |
19039 | pointer or in some other fixed role). | |
19040 | ||
19041 | @var{reg} must be the name of a register. The register names accepted | |
19042 | are machine-specific and are defined in the @code{REGISTER_NAMES} | |
19043 | macro in the machine description macro file. | |
19044 | ||
19045 | This flag does not have a negative form, because it specifies a | |
19046 | three-way choice. | |
19047 | ||
d77de738 | 19048 | @opindex fcall-used |
ddf6fe37 | 19049 | @item -fcall-used-@var{reg} |
d77de738 ML |
19050 | Treat the register named @var{reg} as an allocable register that is |
19051 | clobbered by function calls. It may be allocated for temporaries or | |
19052 | variables that do not live across a call. Functions compiled this way | |
19053 | do not save and restore the register @var{reg}. | |
19054 | ||
19055 | It is an error to use this flag with the frame pointer or stack pointer. | |
19056 | Use of this flag for other registers that have fixed pervasive roles in | |
19057 | the machine's execution model produces disastrous results. | |
19058 | ||
19059 | This flag does not have a negative form, because it specifies a | |
19060 | three-way choice. | |
19061 | ||
d77de738 | 19062 | @opindex fcall-saved |
ddf6fe37 | 19063 | @item -fcall-saved-@var{reg} |
d77de738 ML |
19064 | Treat the register named @var{reg} as an allocable register saved by |
19065 | functions. It may be allocated even for temporaries or variables that | |
19066 | live across a call. Functions compiled this way save and restore | |
19067 | the register @var{reg} if they use it. | |
19068 | ||
19069 | It is an error to use this flag with the frame pointer or stack pointer. | |
19070 | Use of this flag for other registers that have fixed pervasive roles in | |
19071 | the machine's execution model produces disastrous results. | |
19072 | ||
19073 | A different sort of disaster results from the use of this flag for | |
19074 | a register in which function values may be returned. | |
19075 | ||
19076 | This flag does not have a negative form, because it specifies a | |
19077 | three-way choice. | |
19078 | ||
d77de738 | 19079 | @opindex fpack-struct |
ddf6fe37 | 19080 | @item -fpack-struct[=@var{n}] |
d77de738 ML |
19081 | Without a value specified, pack all structure members together without |
19082 | holes. When a value is specified (which must be a small power of two), pack | |
19083 | structure members according to this value, representing the maximum | |
19084 | alignment (that is, objects with default alignment requirements larger than | |
19085 | this are output potentially unaligned at the next fitting location. | |
19086 | ||
19087 | @strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate | |
19088 | code that is not binary compatible with code generated without that switch. | |
19089 | Additionally, it makes the code suboptimal. | |
19090 | Use it to conform to a non-default application binary interface. | |
19091 | ||
d77de738 | 19092 | @opindex fleading-underscore |
ddf6fe37 | 19093 | @item -fleading-underscore |
d77de738 ML |
19094 | This option and its counterpart, @option{-fno-leading-underscore}, forcibly |
19095 | change the way C symbols are represented in the object file. One use | |
19096 | is to help link with legacy assembly code. | |
19097 | ||
19098 | @strong{Warning:} the @option{-fleading-underscore} switch causes GCC to | |
19099 | generate code that is not binary compatible with code generated without that | |
19100 | switch. Use it to conform to a non-default application binary interface. | |
19101 | Not all targets provide complete support for this switch. | |
19102 | ||
d77de738 | 19103 | @opindex ftls-model |
ddf6fe37 | 19104 | @item -ftls-model=@var{model} |
d77de738 ML |
19105 | Alter the thread-local storage model to be used (@pxref{Thread-Local}). |
19106 | The @var{model} argument should be one of @samp{global-dynamic}, | |
19107 | @samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}. | |
19108 | Note that the choice is subject to optimization: the compiler may use | |
19109 | a more efficient model for symbols not visible outside of the translation | |
19110 | unit, or if @option{-fpic} is not given on the command line. | |
19111 | ||
19112 | The default without @option{-fpic} is @samp{initial-exec}; with | |
19113 | @option{-fpic} the default is @samp{global-dynamic}. | |
19114 | ||
d77de738 | 19115 | @opindex ftrampolines |
ddf6fe37 | 19116 | @item -ftrampolines |
d77de738 ML |
19117 | For targets that normally need trampolines for nested functions, always |
19118 | generate them instead of using descriptors. Otherwise, for targets that | |
19119 | do not need them, like for example HP-PA or IA-64, do nothing. | |
19120 | ||
19121 | A trampoline is a small piece of code that is created at run time on the | |
19122 | stack when the address of a nested function is taken, and is used to call | |
19123 | the nested function indirectly. Therefore, it requires the stack to be | |
19124 | made executable in order for the program to work properly. | |
19125 | ||
19126 | @option{-fno-trampolines} is enabled by default on a language by language | |
19127 | basis to let the compiler avoid generating them, if it computes that this | |
19128 | is safe, and replace them with descriptors. Descriptors are made up of data | |
19129 | only, but the generated code must be prepared to deal with them. As of this | |
19130 | writing, @option{-fno-trampolines} is enabled by default only for Ada. | |
19131 | ||
19132 | Moreover, code compiled with @option{-ftrampolines} and code compiled with | |
19133 | @option{-fno-trampolines} are not binary compatible if nested functions are | |
19134 | present. This option must therefore be used on a program-wide basis and be | |
19135 | manipulated with extreme care. | |
19136 | ||
19137 | For languages other than Ada, the @code{-ftrampolines} and | |
19138 | @code{-fno-trampolines} options currently have no effect, and | |
19139 | trampolines are always generated on platforms that need them | |
19140 | for nested functions. | |
19141 | ||
28d8c680 AB |
19142 | @opindex ftrampoline-impl |
19143 | @item -ftrampoline-impl=@r{[}stack@r{|}heap@r{]} | |
19144 | By default, trampolines are generated on stack. However, certain platforms | |
19145 | (such as the Apple M1) do not permit an executable stack. Compiling with | |
19146 | @option{-ftrampoline-impl=heap} generate calls to | |
19147 | @code{__builtin_nested_func_ptr_created} and | |
19148 | @code{__builtin_nested_func_ptr_deleted} in order to allocate and | |
19149 | deallocate trampoline space on the executable heap. These functions are | |
19150 | implemented in libgcc, and will only be provided on specific targets: | |
19151 | x86_64 Darwin, x86_64 and aarch64 Linux. @emph{PLEASE NOTE}: Heap | |
19152 | trampolines are @emph{not} guaranteed to be correctly deallocated if you | |
19153 | @code{setjmp}, instantiate nested functions, and then @code{longjmp} back | |
19154 | to a state prior to having allocated those nested functions. | |
19155 | ||
d77de738 | 19156 | @opindex fvisibility |
ddf6fe37 | 19157 | @item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} |
d77de738 ML |
19158 | Set the default ELF image symbol visibility to the specified option---all |
19159 | symbols are marked with this unless overridden within the code. | |
19160 | Using this feature can very substantially improve linking and | |
19161 | load times of shared object libraries, produce more optimized | |
19162 | code, provide near-perfect API export and prevent symbol clashes. | |
19163 | It is @strong{strongly} recommended that you use this in any shared objects | |
19164 | you distribute. | |
19165 | ||
19166 | Despite the nomenclature, @samp{default} always means public; i.e., | |
19167 | available to be linked against from outside the shared object. | |
19168 | @samp{protected} and @samp{internal} are pretty useless in real-world | |
19169 | usage so the only other commonly used option is @samp{hidden}. | |
19170 | The default if @option{-fvisibility} isn't specified is | |
19171 | @samp{default}, i.e., make every symbol public. | |
19172 | ||
19173 | A good explanation of the benefits offered by ensuring ELF | |
19174 | symbols have the correct visibility is given by ``How To Write | |
19175 | Shared Libraries'' by Ulrich Drepper (which can be found at | |
19176 | @w{@uref{https://www.akkadia.org/drepper/}})---however a superior | |
19177 | solution made possible by this option to marking things hidden when | |
19178 | the default is public is to make the default hidden and mark things | |
19179 | public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden} | |
19180 | and @code{__attribute__ ((visibility("default")))} instead of | |
19181 | @code{__declspec(dllexport)} you get almost identical semantics with | |
19182 | identical syntax. This is a great boon to those working with | |
19183 | cross-platform projects. | |
19184 | ||
19185 | For those adding visibility support to existing code, you may find | |
19186 | @code{#pragma GCC visibility} of use. This works by you enclosing | |
19187 | the declarations you wish to set visibility for with (for example) | |
19188 | @code{#pragma GCC visibility push(hidden)} and | |
19189 | @code{#pragma GCC visibility pop}. | |
19190 | Bear in mind that symbol visibility should be viewed @strong{as | |
19191 | part of the API interface contract} and thus all new code should | |
19192 | always specify visibility when it is not the default; i.e., declarations | |
19193 | only for use within the local DSO should @strong{always} be marked explicitly | |
19194 | as hidden as so to avoid PLT indirection overheads---making this | |
19195 | abundantly clear also aids readability and self-documentation of the code. | |
19196 | Note that due to ISO C++ specification requirements, @code{operator new} and | |
19197 | @code{operator delete} must always be of default visibility. | |
19198 | ||
19199 | Be aware that headers from outside your project, in particular system | |
19200 | headers and headers from any other library you use, may not be | |
19201 | expecting to be compiled with visibility other than the default. You | |
19202 | may need to explicitly say @code{#pragma GCC visibility push(default)} | |
19203 | before including any such headers. | |
19204 | ||
19205 | @code{extern} declarations are not affected by @option{-fvisibility}, so | |
19206 | a lot of code can be recompiled with @option{-fvisibility=hidden} with | |
19207 | no modifications. However, this means that calls to @code{extern} | |
19208 | functions with no explicit visibility use the PLT, so it is more | |
19209 | effective to use @code{__attribute ((visibility))} and/or | |
19210 | @code{#pragma GCC visibility} to tell the compiler which @code{extern} | |
19211 | declarations should be treated as hidden. | |
19212 | ||
19213 | Note that @option{-fvisibility} does affect C++ vague linkage | |
19214 | entities. This means that, for instance, an exception class that is | |
19215 | be thrown between DSOs must be explicitly marked with default | |
19216 | visibility so that the @samp{type_info} nodes are unified between | |
19217 | the DSOs. | |
19218 | ||
19219 | An overview of these techniques, their benefits and how to use them | |
19220 | is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}. | |
19221 | ||
d77de738 | 19222 | @opindex fstrict-volatile-bitfields |
ddf6fe37 | 19223 | @item -fstrict-volatile-bitfields |
d77de738 ML |
19224 | This option should be used if accesses to volatile bit-fields (or other |
19225 | structure fields, although the compiler usually honors those types | |
19226 | anyway) should use a single access of the width of the | |
19227 | field's type, aligned to a natural alignment if possible. For | |
19228 | example, targets with memory-mapped peripheral registers might require | |
19229 | all such accesses to be 16 bits wide; with this flag you can | |
19230 | declare all peripheral bit-fields as @code{unsigned short} (assuming short | |
19231 | is 16 bits on these targets) to force GCC to use 16-bit accesses | |
19232 | instead of, perhaps, a more efficient 32-bit access. | |
19233 | ||
19234 | If this option is disabled, the compiler uses the most efficient | |
19235 | instruction. In the previous example, that might be a 32-bit load | |
19236 | instruction, even though that accesses bytes that do not contain | |
19237 | any portion of the bit-field, or memory-mapped registers unrelated to | |
19238 | the one being updated. | |
19239 | ||
19240 | In some cases, such as when the @code{packed} attribute is applied to a | |
19241 | structure field, it may not be possible to access the field with a single | |
19242 | read or write that is correctly aligned for the target machine. In this | |
19243 | case GCC falls back to generating multiple accesses rather than code that | |
19244 | will fault or truncate the result at run time. | |
19245 | ||
19246 | Note: Due to restrictions of the C/C++11 memory model, write accesses are | |
19247 | not allowed to touch non bit-field members. It is therefore recommended | |
19248 | to define all bits of the field's type as bit-field members. | |
19249 | ||
19250 | The default value of this option is determined by the application binary | |
19251 | interface for the target processor. | |
19252 | ||
d77de738 | 19253 | @opindex fsync-libcalls |
ddf6fe37 | 19254 | @item -fsync-libcalls |
d77de738 ML |
19255 | This option controls whether any out-of-line instance of the @code{__sync} |
19256 | family of functions may be used to implement the C++11 @code{__atomic} | |
19257 | family of functions. | |
19258 | ||
19259 | The default value of this option is enabled, thus the only useful form | |
19260 | of the option is @option{-fno-sync-libcalls}. This option is used in | |
19261 | the implementation of the @file{libatomic} runtime library. | |
19262 | ||
19263 | @end table | |
19264 | ||
19265 | @node Developer Options | |
19266 | @section GCC Developer Options | |
19267 | @cindex developer options | |
19268 | @cindex debugging GCC | |
19269 | @cindex debug dump options | |
19270 | @cindex dump options | |
19271 | @cindex compilation statistics | |
19272 | ||
19273 | This section describes command-line options that are primarily of | |
19274 | interest to GCC developers, including options to support compiler | |
19275 | testing and investigation of compiler bugs and compile-time | |
19276 | performance problems. This includes options that produce debug dumps | |
19277 | at various points in the compilation; that print statistics such as | |
19278 | memory use and execution time; and that print information about GCC's | |
19279 | configuration, such as where it searches for libraries. You should | |
19280 | rarely need to use any of these options for ordinary compilation and | |
19281 | linking tasks. | |
19282 | ||
19283 | Many developer options that cause GCC to dump output to a file take an | |
19284 | optional @samp{=@var{filename}} suffix. You can specify @samp{stdout} | |
19285 | or @samp{-} to dump to standard output, and @samp{stderr} for standard | |
19286 | error. | |
19287 | ||
19288 | If @samp{=@var{filename}} is omitted, a default dump file name is | |
19289 | constructed by concatenating the base dump file name, a pass number, | |
19290 | phase letter, and pass name. The base dump file name is the name of | |
19291 | output file produced by the compiler if explicitly specified and not | |
19292 | an executable; otherwise it is the source file name. | |
19293 | The pass number is determined by the order passes are registered with | |
19294 | the compiler's pass manager. | |
19295 | This is generally the same as the order of execution, but passes | |
19296 | registered by plugins, target-specific passes, or passes that are | |
19297 | otherwise registered late are numbered higher than the pass named | |
19298 | @samp{final}, even if they are executed earlier. The phase letter is | |
19299 | one of @samp{i} (inter-procedural analysis), @samp{l} | |
19300 | (language-specific), @samp{r} (RTL), or @samp{t} (tree). | |
19301 | The files are created in the directory of the output file. | |
19302 | ||
19303 | @table @gcctabopt | |
19304 | ||
ddf6fe37 | 19305 | @opindex fcallgraph-info |
d77de738 ML |
19306 | @item -fcallgraph-info |
19307 | @itemx -fcallgraph-info=@var{MARKERS} | |
d77de738 ML |
19308 | Makes the compiler output callgraph information for the program, on a |
19309 | per-object-file basis. The information is generated in the common VCG | |
19310 | format. It can be decorated with additional, per-node and/or per-edge | |
19311 | information, if a list of comma-separated markers is additionally | |
19312 | specified. When the @code{su} marker is specified, the callgraph is | |
19313 | decorated with stack usage information; it is equivalent to | |
19314 | @option{-fstack-usage}. When the @code{da} marker is specified, the | |
19315 | callgraph is decorated with information about dynamically allocated | |
19316 | objects. | |
19317 | ||
19318 | When compiling with @option{-flto}, no callgraph information is output | |
19319 | along with the object file. At LTO link time, @option{-fcallgraph-info} | |
19320 | may generate multiple callgraph information files next to intermediate | |
19321 | LTO output files. | |
19322 | ||
ddf6fe37 AA |
19323 | @opindex d |
19324 | @opindex fdump-rtl-@var{pass} | |
d77de738 ML |
19325 | @item -d@var{letters} |
19326 | @itemx -fdump-rtl-@var{pass} | |
19327 | @itemx -fdump-rtl-@var{pass}=@var{filename} | |
d77de738 ML |
19328 | Says to make debugging dumps during compilation at times specified by |
19329 | @var{letters}. This is used for debugging the RTL-based passes of the | |
19330 | compiler. | |
19331 | ||
19332 | Some @option{-d@var{letters}} switches have different meaning when | |
19333 | @option{-E} is used for preprocessing. @xref{Preprocessor Options}, | |
19334 | for information about preprocessor-specific dump options. | |
19335 | ||
19336 | Debug dumps can be enabled with a @option{-fdump-rtl} switch or some | |
19337 | @option{-d} option @var{letters}. Here are the possible | |
19338 | letters for use in @var{pass} and @var{letters}, and their meanings: | |
19339 | ||
19340 | @table @gcctabopt | |
19341 | ||
d77de738 | 19342 | @opindex fdump-rtl-alignments |
ddf6fe37 | 19343 | @item -fdump-rtl-alignments |
d77de738 ML |
19344 | Dump after branch alignments have been computed. |
19345 | ||
d77de738 | 19346 | @opindex fdump-rtl-asmcons |
ddf6fe37 | 19347 | @item -fdump-rtl-asmcons |
d77de738 ML |
19348 | Dump after fixing rtl statements that have unsatisfied in/out constraints. |
19349 | ||
d77de738 | 19350 | @opindex fdump-rtl-auto_inc_dec |
ddf6fe37 | 19351 | @item -fdump-rtl-auto_inc_dec |
d77de738 ML |
19352 | Dump after auto-inc-dec discovery. This pass is only run on |
19353 | architectures that have auto inc or auto dec instructions. | |
19354 | ||
d77de738 | 19355 | @opindex fdump-rtl-barriers |
ddf6fe37 | 19356 | @item -fdump-rtl-barriers |
d77de738 ML |
19357 | Dump after cleaning up the barrier instructions. |
19358 | ||
d77de738 | 19359 | @opindex fdump-rtl-bbpart |
ddf6fe37 | 19360 | @item -fdump-rtl-bbpart |
d77de738 ML |
19361 | Dump after partitioning hot and cold basic blocks. |
19362 | ||
d77de738 | 19363 | @opindex fdump-rtl-bbro |
ddf6fe37 | 19364 | @item -fdump-rtl-bbro |
d77de738 ML |
19365 | Dump after block reordering. |
19366 | ||
d77de738 ML |
19367 | @opindex fdump-rtl-btl2 |
19368 | @opindex fdump-rtl-btl2 | |
ddf6fe37 AA |
19369 | @item -fdump-rtl-btl1 |
19370 | @itemx -fdump-rtl-btl2 | |
d77de738 ML |
19371 | @option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping |
19372 | after the two branch | |
19373 | target load optimization passes. | |
19374 | ||
d77de738 | 19375 | @opindex fdump-rtl-bypass |
ddf6fe37 | 19376 | @item -fdump-rtl-bypass |
d77de738 ML |
19377 | Dump after jump bypassing and control flow optimizations. |
19378 | ||
d77de738 | 19379 | @opindex fdump-rtl-combine |
ddf6fe37 | 19380 | @item -fdump-rtl-combine |
d77de738 ML |
19381 | Dump after the RTL instruction combination pass. |
19382 | ||
d77de738 | 19383 | @opindex fdump-rtl-compgotos |
ddf6fe37 | 19384 | @item -fdump-rtl-compgotos |
d77de738 ML |
19385 | Dump after duplicating the computed gotos. |
19386 | ||
d77de738 ML |
19387 | @opindex fdump-rtl-ce1 |
19388 | @opindex fdump-rtl-ce2 | |
19389 | @opindex fdump-rtl-ce3 | |
ddf6fe37 AA |
19390 | @item -fdump-rtl-ce1 |
19391 | @itemx -fdump-rtl-ce2 | |
19392 | @itemx -fdump-rtl-ce3 | |
d77de738 ML |
19393 | @option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and |
19394 | @option{-fdump-rtl-ce3} enable dumping after the three | |
19395 | if conversion passes. | |
19396 | ||
d77de738 | 19397 | @opindex fdump-rtl-cprop_hardreg |
ddf6fe37 | 19398 | @item -fdump-rtl-cprop_hardreg |
d77de738 ML |
19399 | Dump after hard register copy propagation. |
19400 | ||
d77de738 | 19401 | @opindex fdump-rtl-csa |
ddf6fe37 | 19402 | @item -fdump-rtl-csa |
d77de738 ML |
19403 | Dump after combining stack adjustments. |
19404 | ||
d77de738 ML |
19405 | @opindex fdump-rtl-cse1 |
19406 | @opindex fdump-rtl-cse2 | |
ddf6fe37 AA |
19407 | @item -fdump-rtl-cse1 |
19408 | @itemx -fdump-rtl-cse2 | |
d77de738 ML |
19409 | @option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after |
19410 | the two common subexpression elimination passes. | |
19411 | ||
d77de738 | 19412 | @opindex fdump-rtl-dce |
ddf6fe37 | 19413 | @item -fdump-rtl-dce |
d77de738 ML |
19414 | Dump after the standalone dead code elimination passes. |
19415 | ||
d77de738 | 19416 | @opindex fdump-rtl-dbr |
ddf6fe37 | 19417 | @item -fdump-rtl-dbr |
d77de738 ML |
19418 | Dump after delayed branch scheduling. |
19419 | ||
d77de738 ML |
19420 | @opindex fdump-rtl-dce1 |
19421 | @opindex fdump-rtl-dce2 | |
ddf6fe37 AA |
19422 | @item -fdump-rtl-dce1 |
19423 | @itemx -fdump-rtl-dce2 | |
d77de738 ML |
19424 | @option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after |
19425 | the two dead store elimination passes. | |
19426 | ||
d77de738 | 19427 | @opindex fdump-rtl-eh |
ddf6fe37 | 19428 | @item -fdump-rtl-eh |
d77de738 ML |
19429 | Dump after finalization of EH handling code. |
19430 | ||
d77de738 | 19431 | @opindex fdump-rtl-eh_ranges |
ddf6fe37 | 19432 | @item -fdump-rtl-eh_ranges |
d77de738 ML |
19433 | Dump after conversion of EH handling range regions. |
19434 | ||
d77de738 | 19435 | @opindex fdump-rtl-expand |
ddf6fe37 | 19436 | @item -fdump-rtl-expand |
d77de738 ML |
19437 | Dump after RTL generation. |
19438 | ||
d77de738 ML |
19439 | @opindex fdump-rtl-fwprop1 |
19440 | @opindex fdump-rtl-fwprop2 | |
ddf6fe37 AA |
19441 | @item -fdump-rtl-fwprop1 |
19442 | @itemx -fdump-rtl-fwprop2 | |
d77de738 ML |
19443 | @option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable |
19444 | dumping after the two forward propagation passes. | |
19445 | ||
d77de738 ML |
19446 | @opindex fdump-rtl-gcse1 |
19447 | @opindex fdump-rtl-gcse2 | |
ddf6fe37 AA |
19448 | @item -fdump-rtl-gcse1 |
19449 | @itemx -fdump-rtl-gcse2 | |
d77de738 ML |
19450 | @option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping |
19451 | after global common subexpression elimination. | |
19452 | ||
d77de738 | 19453 | @opindex fdump-rtl-init-regs |
ddf6fe37 | 19454 | @item -fdump-rtl-init-regs |
d77de738 ML |
19455 | Dump after the initialization of the registers. |
19456 | ||
d77de738 | 19457 | @opindex fdump-rtl-initvals |
ddf6fe37 | 19458 | @item -fdump-rtl-initvals |
d77de738 ML |
19459 | Dump after the computation of the initial value sets. |
19460 | ||
d77de738 | 19461 | @opindex fdump-rtl-into_cfglayout |
ddf6fe37 | 19462 | @item -fdump-rtl-into_cfglayout |
d77de738 ML |
19463 | Dump after converting to cfglayout mode. |
19464 | ||
d77de738 | 19465 | @opindex fdump-rtl-ira |
ddf6fe37 | 19466 | @item -fdump-rtl-ira |
d77de738 ML |
19467 | Dump after iterated register allocation. |
19468 | ||
d77de738 | 19469 | @opindex fdump-rtl-jump |
ddf6fe37 | 19470 | @item -fdump-rtl-jump |
d77de738 ML |
19471 | Dump after the second jump optimization. |
19472 | ||
d77de738 | 19473 | @opindex fdump-rtl-loop2 |
ddf6fe37 | 19474 | @item -fdump-rtl-loop2 |
d77de738 ML |
19475 | @option{-fdump-rtl-loop2} enables dumping after the rtl |
19476 | loop optimization passes. | |
19477 | ||
d77de738 | 19478 | @opindex fdump-rtl-mach |
ddf6fe37 | 19479 | @item -fdump-rtl-mach |
d77de738 ML |
19480 | Dump after performing the machine dependent reorganization pass, if that |
19481 | pass exists. | |
19482 | ||
d77de738 | 19483 | @opindex fdump-rtl-mode_sw |
ddf6fe37 | 19484 | @item -fdump-rtl-mode_sw |
d77de738 ML |
19485 | Dump after removing redundant mode switches. |
19486 | ||
d77de738 | 19487 | @opindex fdump-rtl-rnreg |
ddf6fe37 | 19488 | @item -fdump-rtl-rnreg |
d77de738 ML |
19489 | Dump after register renumbering. |
19490 | ||
d77de738 | 19491 | @opindex fdump-rtl-outof_cfglayout |
ddf6fe37 | 19492 | @item -fdump-rtl-outof_cfglayout |
d77de738 ML |
19493 | Dump after converting from cfglayout mode. |
19494 | ||
d77de738 | 19495 | @opindex fdump-rtl-peephole2 |
ddf6fe37 | 19496 | @item -fdump-rtl-peephole2 |
d77de738 ML |
19497 | Dump after the peephole pass. |
19498 | ||
d77de738 | 19499 | @opindex fdump-rtl-postreload |
ddf6fe37 | 19500 | @item -fdump-rtl-postreload |
d77de738 ML |
19501 | Dump after post-reload optimizations. |
19502 | ||
d77de738 | 19503 | @opindex fdump-rtl-pro_and_epilogue |
ddf6fe37 | 19504 | @item -fdump-rtl-pro_and_epilogue |
d77de738 ML |
19505 | Dump after generating the function prologues and epilogues. |
19506 | ||
d77de738 ML |
19507 | @opindex fdump-rtl-sched1 |
19508 | @opindex fdump-rtl-sched2 | |
ddf6fe37 AA |
19509 | @item -fdump-rtl-sched1 |
19510 | @itemx -fdump-rtl-sched2 | |
d77de738 ML |
19511 | @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping |
19512 | after the basic block scheduling passes. | |
19513 | ||
d77de738 | 19514 | @opindex fdump-rtl-ree |
ddf6fe37 | 19515 | @item -fdump-rtl-ree |
d77de738 ML |
19516 | Dump after sign/zero extension elimination. |
19517 | ||
d77de738 | 19518 | @opindex fdump-rtl-seqabstr |
ddf6fe37 | 19519 | @item -fdump-rtl-seqabstr |
d77de738 ML |
19520 | Dump after common sequence discovery. |
19521 | ||
d77de738 | 19522 | @opindex fdump-rtl-shorten |
ddf6fe37 | 19523 | @item -fdump-rtl-shorten |
d77de738 ML |
19524 | Dump after shortening branches. |
19525 | ||
d77de738 | 19526 | @opindex fdump-rtl-sibling |
ddf6fe37 | 19527 | @item -fdump-rtl-sibling |
d77de738 ML |
19528 | Dump after sibling call optimizations. |
19529 | ||
d77de738 ML |
19530 | @opindex fdump-rtl-split1 |
19531 | @opindex fdump-rtl-split2 | |
19532 | @opindex fdump-rtl-split3 | |
19533 | @opindex fdump-rtl-split4 | |
19534 | @opindex fdump-rtl-split5 | |
ddf6fe37 AA |
19535 | @item -fdump-rtl-split1 |
19536 | @itemx -fdump-rtl-split2 | |
19537 | @itemx -fdump-rtl-split3 | |
19538 | @itemx -fdump-rtl-split4 | |
19539 | @itemx -fdump-rtl-split5 | |
d77de738 ML |
19540 | These options enable dumping after five rounds of |
19541 | instruction splitting. | |
19542 | ||
d77de738 | 19543 | @opindex fdump-rtl-sms |
ddf6fe37 | 19544 | @item -fdump-rtl-sms |
d77de738 ML |
19545 | Dump after modulo scheduling. This pass is only run on some |
19546 | architectures. | |
19547 | ||
d77de738 | 19548 | @opindex fdump-rtl-stack |
ddf6fe37 | 19549 | @item -fdump-rtl-stack |
d77de738 ML |
19550 | Dump after conversion from GCC's ``flat register file'' registers to the |
19551 | x87's stack-like registers. This pass is only run on x86 variants. | |
19552 | ||
d77de738 ML |
19553 | @opindex fdump-rtl-subreg1 |
19554 | @opindex fdump-rtl-subreg2 | |
ddf6fe37 AA |
19555 | @item -fdump-rtl-subreg1 |
19556 | @itemx -fdump-rtl-subreg2 | |
d77de738 ML |
19557 | @option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after |
19558 | the two subreg expansion passes. | |
19559 | ||
d77de738 | 19560 | @opindex fdump-rtl-unshare |
ddf6fe37 | 19561 | @item -fdump-rtl-unshare |
d77de738 ML |
19562 | Dump after all rtl has been unshared. |
19563 | ||
d77de738 | 19564 | @opindex fdump-rtl-vartrack |
ddf6fe37 | 19565 | @item -fdump-rtl-vartrack |
d77de738 ML |
19566 | Dump after variable tracking. |
19567 | ||
d77de738 | 19568 | @opindex fdump-rtl-vregs |
ddf6fe37 | 19569 | @item -fdump-rtl-vregs |
d77de738 ML |
19570 | Dump after converting virtual registers to hard registers. |
19571 | ||
d77de738 | 19572 | @opindex fdump-rtl-web |
ddf6fe37 | 19573 | @item -fdump-rtl-web |
d77de738 ML |
19574 | Dump after live range splitting. |
19575 | ||
d77de738 ML |
19576 | @opindex fdump-rtl-regclass |
19577 | @opindex fdump-rtl-subregs_of_mode_init | |
19578 | @opindex fdump-rtl-subregs_of_mode_finish | |
19579 | @opindex fdump-rtl-dfinit | |
19580 | @opindex fdump-rtl-dfinish | |
ddf6fe37 AA |
19581 | @item -fdump-rtl-regclass |
19582 | @itemx -fdump-rtl-subregs_of_mode_init | |
19583 | @itemx -fdump-rtl-subregs_of_mode_finish | |
19584 | @itemx -fdump-rtl-dfinit | |
19585 | @itemx -fdump-rtl-dfinish | |
d77de738 ML |
19586 | These dumps are defined but always produce empty files. |
19587 | ||
d77de738 ML |
19588 | @opindex da |
19589 | @opindex fdump-rtl-all | |
ddf6fe37 AA |
19590 | @item -da |
19591 | @itemx -fdump-rtl-all | |
d77de738 ML |
19592 | Produce all the dumps listed above. |
19593 | ||
d77de738 | 19594 | @opindex dA |
ddf6fe37 | 19595 | @item -dA |
d77de738 ML |
19596 | Annotate the assembler output with miscellaneous debugging information. |
19597 | ||
d77de738 | 19598 | @opindex dD |
ddf6fe37 | 19599 | @item -dD |
d77de738 ML |
19600 | Dump all macro definitions, at the end of preprocessing, in addition to |
19601 | normal output. | |
19602 | ||
d77de738 | 19603 | @opindex dH |
ddf6fe37 | 19604 | @item -dH |
d77de738 ML |
19605 | Produce a core dump whenever an error occurs. |
19606 | ||
d77de738 | 19607 | @opindex dp |
ddf6fe37 | 19608 | @item -dp |
d77de738 ML |
19609 | Annotate the assembler output with a comment indicating which |
19610 | pattern and alternative is used. The length and cost of each instruction are | |
19611 | also printed. | |
19612 | ||
d77de738 | 19613 | @opindex dP |
ddf6fe37 | 19614 | @item -dP |
d77de738 ML |
19615 | Dump the RTL in the assembler output as a comment before each instruction. |
19616 | Also turns on @option{-dp} annotation. | |
19617 | ||
d77de738 | 19618 | @opindex dx |
ddf6fe37 | 19619 | @item -dx |
d77de738 ML |
19620 | Just generate RTL for a function instead of compiling it. Usually used |
19621 | with @option{-fdump-rtl-expand}. | |
19622 | @end table | |
19623 | ||
d77de738 | 19624 | @opindex fdump-debug |
ddf6fe37 | 19625 | @item -fdump-debug |
d77de738 ML |
19626 | Dump debugging information generated during the debug |
19627 | generation phase. | |
19628 | ||
d77de738 | 19629 | @opindex fdump-earlydebug |
ddf6fe37 | 19630 | @item -fdump-earlydebug |
d77de738 ML |
19631 | Dump debugging information generated during the early debug |
19632 | generation phase. | |
19633 | ||
d77de738 | 19634 | @opindex fdump-noaddr |
ddf6fe37 | 19635 | @item -fdump-noaddr |
d77de738 ML |
19636 | When doing debugging dumps, suppress address output. This makes it more |
19637 | feasible to use diff on debugging dumps for compiler invocations with | |
19638 | different compiler binaries and/or different | |
19639 | text / bss / data / heap / stack / dso start locations. | |
19640 | ||
d77de738 | 19641 | @opindex freport-bug |
ddf6fe37 | 19642 | @item -freport-bug |
d77de738 ML |
19643 | Collect and dump debug information into a temporary file if an |
19644 | internal compiler error (ICE) occurs. | |
19645 | ||
d77de738 | 19646 | @opindex fdump-unnumbered |
ddf6fe37 | 19647 | @item -fdump-unnumbered |
d77de738 ML |
19648 | When doing debugging dumps, suppress instruction numbers and address output. |
19649 | This makes it more feasible to use diff on debugging dumps for compiler | |
19650 | invocations with different options, in particular with and without | |
19651 | @option{-g}. | |
19652 | ||
d77de738 | 19653 | @opindex fdump-unnumbered-links |
ddf6fe37 | 19654 | @item -fdump-unnumbered-links |
d77de738 ML |
19655 | When doing debugging dumps (see @option{-d} option above), suppress |
19656 | instruction numbers for the links to the previous and next instructions | |
19657 | in a sequence. | |
19658 | ||
ddf6fe37 | 19659 | @opindex fdump-ipa |
d77de738 ML |
19660 | @item -fdump-ipa-@var{switch} |
19661 | @itemx -fdump-ipa-@var{switch}-@var{options} | |
d77de738 ML |
19662 | Control the dumping at various stages of inter-procedural analysis |
19663 | language tree to a file. The file name is generated by appending a | |
19664 | switch specific suffix to the source file name, and the file is created | |
19665 | in the same directory as the output file. The following dumps are | |
19666 | possible: | |
19667 | ||
19668 | @table @samp | |
19669 | @item all | |
19670 | Enables all inter-procedural analysis dumps. | |
19671 | ||
19672 | @item cgraph | |
19673 | Dumps information about call-graph optimization, unused function removal, | |
19674 | and inlining decisions. | |
19675 | ||
19676 | @item inline | |
19677 | Dump after function inlining. | |
19678 | ||
19679 | @end table | |
19680 | ||
19681 | Additionally, the options @option{-optimized}, @option{-missed}, | |
19682 | @option{-note}, and @option{-all} can be provided, with the same meaning | |
19683 | as for @option{-fopt-info}, defaulting to @option{-optimized}. | |
19684 | ||
19685 | For example, @option{-fdump-ipa-inline-optimized-missed} will emit | |
19686 | information on callsites that were inlined, along with callsites | |
19687 | that were not inlined. | |
19688 | ||
19689 | By default, the dump will contain messages about successful | |
19690 | optimizations (equivalent to @option{-optimized}) together with | |
19691 | low-level details about the analysis. | |
19692 | ||
d77de738 | 19693 | @opindex fdump-lang |
ddf6fe37 | 19694 | @item -fdump-lang |
d77de738 ML |
19695 | Dump language-specific information. The file name is made by appending |
19696 | @file{.lang} to the source file name. | |
19697 | ||
ddf6fe37 AA |
19698 | @opindex fdump-lang-all |
19699 | @opindex fdump-lang | |
d77de738 ML |
19700 | @item -fdump-lang-all |
19701 | @itemx -fdump-lang-@var{switch} | |
19702 | @itemx -fdump-lang-@var{switch}-@var{options} | |
19703 | @itemx -fdump-lang-@var{switch}-@var{options}=@var{filename} | |
d77de738 ML |
19704 | Control the dumping of language-specific information. The @var{options} |
19705 | and @var{filename} portions behave as described in the | |
19706 | @option{-fdump-tree} option. The following @var{switch} values are | |
19707 | accepted: | |
19708 | ||
19709 | @table @samp | |
19710 | @item all | |
19711 | ||
19712 | Enable all language-specific dumps. | |
19713 | ||
19714 | @item class | |
19715 | Dump class hierarchy information. Virtual table information is emitted | |
19716 | unless '@option{slim}' is specified. This option is applicable to C++ only. | |
19717 | ||
19718 | @item module | |
19719 | Dump module information. Options @option{lineno} (locations), | |
19720 | @option{graph} (reachability), @option{blocks} (clusters), | |
19721 | @option{uid} (serialization), @option{alias} (mergeable), | |
19722 | @option{asmname} (Elrond), @option{eh} (mapper) & @option{vops} | |
19723 | (macros) may provide additional information. This option is | |
19724 | applicable to C++ only. | |
19725 | ||
19726 | @item raw | |
19727 | Dump the raw internal tree data. This option is applicable to C++ only. | |
19728 | ||
19729 | @end table | |
19730 | ||
d77de738 | 19731 | @opindex fdump-passes |
ddf6fe37 | 19732 | @item -fdump-passes |
d77de738 ML |
19733 | Print on @file{stderr} the list of optimization passes that are turned |
19734 | on and off by the current command-line options. | |
19735 | ||
d77de738 | 19736 | @opindex fdump-statistics |
ddf6fe37 | 19737 | @item -fdump-statistics-@var{option} |
d77de738 ML |
19738 | Enable and control dumping of pass statistics in a separate file. The |
19739 | file name is generated by appending a suffix ending in | |
19740 | @samp{.statistics} to the source file name, and the file is created in | |
19741 | the same directory as the output file. If the @samp{-@var{option}} | |
19742 | form is used, @samp{-stats} causes counters to be summed over the | |
19743 | whole compilation unit while @samp{-details} dumps every event as | |
19744 | the passes generate them. The default with no option is to sum | |
19745 | counters for each function compiled. | |
19746 | ||
ddf6fe37 AA |
19747 | @opindex fdump-tree-all |
19748 | @opindex fdump-tree | |
d77de738 ML |
19749 | @item -fdump-tree-all |
19750 | @itemx -fdump-tree-@var{switch} | |
19751 | @itemx -fdump-tree-@var{switch}-@var{options} | |
19752 | @itemx -fdump-tree-@var{switch}-@var{options}=@var{filename} | |
d77de738 ML |
19753 | Control the dumping at various stages of processing the intermediate |
19754 | language tree to a file. If the @samp{-@var{options}} | |
19755 | form is used, @var{options} is a list of @samp{-} separated options | |
19756 | which control the details of the dump. Not all options are applicable | |
19757 | to all dumps; those that are not meaningful are ignored. The | |
19758 | following options are available | |
19759 | ||
19760 | @table @samp | |
19761 | @item address | |
19762 | Print the address of each node. Usually this is not meaningful as it | |
19763 | changes according to the environment and source file. Its primary use | |
19764 | is for tying up a dump file with a debug environment. | |
19765 | @item asmname | |
19766 | If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that | |
19767 | in the dump instead of @code{DECL_NAME}. Its primary use is ease of | |
19768 | use working backward from mangled names in the assembly file. | |
19769 | @item slim | |
19770 | When dumping front-end intermediate representations, inhibit dumping | |
19771 | of members of a scope or body of a function merely because that scope | |
19772 | has been reached. Only dump such items when they are directly reachable | |
19773 | by some other path. | |
19774 | ||
19775 | When dumping pretty-printed trees, this option inhibits dumping the | |
19776 | bodies of control structures. | |
19777 | ||
19778 | When dumping RTL, print the RTL in slim (condensed) form instead of | |
19779 | the default LISP-like representation. | |
19780 | @item raw | |
19781 | Print a raw representation of the tree. By default, trees are | |
19782 | pretty-printed into a C-like representation. | |
19783 | @item details | |
19784 | Enable more detailed dumps (not honored by every dump option). Also | |
19785 | include information from the optimization passes. | |
19786 | @item stats | |
19787 | Enable dumping various statistics about the pass (not honored by every dump | |
19788 | option). | |
19789 | @item blocks | |
19790 | Enable showing basic block boundaries (disabled in raw dumps). | |
19791 | @item graph | |
19792 | For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}), | |
19793 | dump a representation of the control flow graph suitable for viewing with | |
19794 | GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in | |
19795 | the file is pretty-printed as a subgraph, so that GraphViz can render them | |
19796 | all in a single plot. | |
19797 | ||
19798 | This option currently only works for RTL dumps, and the RTL is always | |
19799 | dumped in slim form. | |
19800 | @item vops | |
19801 | Enable showing virtual operands for every statement. | |
19802 | @item lineno | |
19803 | Enable showing line numbers for statements. | |
19804 | @item uid | |
19805 | Enable showing the unique ID (@code{DECL_UID}) for each variable. | |
19806 | @item verbose | |
19807 | Enable showing the tree dump for each statement. | |
19808 | @item eh | |
19809 | Enable showing the EH region number holding each statement. | |
19810 | @item scev | |
19811 | Enable showing scalar evolution analysis details. | |
19812 | @item optimized | |
19813 | Enable showing optimization information (only available in certain | |
19814 | passes). | |
19815 | @item missed | |
19816 | Enable showing missed optimization information (only available in certain | |
19817 | passes). | |
19818 | @item note | |
19819 | Enable other detailed optimization information (only available in | |
19820 | certain passes). | |
19821 | @item all | |
19822 | Turn on all options, except @option{raw}, @option{slim}, @option{verbose} | |
19823 | and @option{lineno}. | |
19824 | @item optall | |
19825 | Turn on all optimization options, i.e., @option{optimized}, | |
19826 | @option{missed}, and @option{note}. | |
19827 | @end table | |
19828 | ||
19829 | To determine what tree dumps are available or find the dump for a pass | |
19830 | of interest follow the steps below. | |
19831 | ||
19832 | @enumerate | |
19833 | @item | |
19834 | Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output | |
19835 | look for a code that corresponds to the pass you are interested in. | |
19836 | For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and | |
19837 | @code{tree-vrp2} correspond to the three Value Range Propagation passes. | |
19838 | The number at the end distinguishes distinct invocations of the same pass. | |
19839 | @item | |
19840 | To enable the creation of the dump file, append the pass code to | |
19841 | the @option{-fdump-} option prefix and invoke GCC with it. For example, | |
19842 | to enable the dump from the Early Value Range Propagation pass, invoke | |
19843 | GCC with the @option{-fdump-tree-evrp} option. Optionally, you may | |
19844 | specify the name of the dump file. If you don't specify one, GCC | |
19845 | creates as described below. | |
19846 | @item | |
19847 | Find the pass dump in a file whose name is composed of three components | |
19848 | separated by a period: the name of the source file GCC was invoked to | |
19849 | compile, a numeric suffix indicating the pass number followed by the | |
19850 | letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes), | |
19851 | and finally the pass code. For example, the Early VRP pass dump might | |
19852 | be in a file named @file{myfile.c.038t.evrp} in the current working | |
19853 | directory. Note that the numeric codes are not stable and may change | |
19854 | from one version of GCC to another. | |
19855 | @end enumerate | |
19856 | ||
ddf6fe37 | 19857 | @opindex fopt-info |
d77de738 ML |
19858 | @item -fopt-info |
19859 | @itemx -fopt-info-@var{options} | |
19860 | @itemx -fopt-info-@var{options}=@var{filename} | |
d77de738 ML |
19861 | Controls optimization dumps from various optimization passes. If the |
19862 | @samp{-@var{options}} form is used, @var{options} is a list of | |
19863 | @samp{-} separated option keywords to select the dump details and | |
19864 | optimizations. | |
19865 | ||
19866 | The @var{options} can be divided into three groups: | |
19867 | @enumerate | |
19868 | @item | |
19869 | options describing what kinds of messages should be emitted, | |
19870 | @item | |
19871 | options describing the verbosity of the dump, and | |
19872 | @item | |
19873 | options describing which optimizations should be included. | |
19874 | @end enumerate | |
19875 | The options from each group can be freely mixed as they are | |
19876 | non-overlapping. However, in case of any conflicts, | |
19877 | the later options override the earlier options on the command | |
19878 | line. | |
19879 | ||
19880 | The following options control which kinds of messages should be emitted: | |
19881 | ||
19882 | @table @samp | |
19883 | @item optimized | |
19884 | Print information when an optimization is successfully applied. It is | |
19885 | up to a pass to decide which information is relevant. For example, the | |
19886 | vectorizer passes print the source location of loops which are | |
19887 | successfully vectorized. | |
19888 | @item missed | |
19889 | Print information about missed optimizations. Individual passes | |
19890 | control which information to include in the output. | |
19891 | @item note | |
19892 | Print verbose information about optimizations, such as certain | |
19893 | transformations, more detailed messages about decisions etc. | |
19894 | @item all | |
19895 | Print detailed optimization information. This includes | |
19896 | @samp{optimized}, @samp{missed}, and @samp{note}. | |
19897 | @end table | |
19898 | ||
19899 | The following option controls the dump verbosity: | |
19900 | ||
19901 | @table @samp | |
19902 | @item internals | |
19903 | By default, only ``high-level'' messages are emitted. This option enables | |
19904 | additional, more detailed, messages, which are likely to only be of interest | |
19905 | to GCC developers. | |
19906 | @end table | |
19907 | ||
19908 | One or more of the following option keywords can be used to describe a | |
19909 | group of optimizations: | |
19910 | ||
19911 | @table @samp | |
19912 | @item ipa | |
19913 | Enable dumps from all interprocedural optimizations. | |
19914 | @item loop | |
19915 | Enable dumps from all loop optimizations. | |
19916 | @item inline | |
19917 | Enable dumps from all inlining optimizations. | |
19918 | @item omp | |
19919 | Enable dumps from all OMP (Offloading and Multi Processing) optimizations. | |
19920 | @item vec | |
19921 | Enable dumps from all vectorization optimizations. | |
19922 | @item optall | |
19923 | Enable dumps from all optimizations. This is a superset of | |
19924 | the optimization groups listed above. | |
19925 | @end table | |
19926 | ||
19927 | If @var{options} is | |
19928 | omitted, it defaults to @samp{optimized-optall}, which means to dump messages | |
19929 | about successful optimizations from all the passes, omitting messages | |
19930 | that are treated as ``internals''. | |
19931 | ||
19932 | If the @var{filename} is provided, then the dumps from all the | |
19933 | applicable optimizations are concatenated into the @var{filename}. | |
19934 | Otherwise the dump is output onto @file{stderr}. Though multiple | |
19935 | @option{-fopt-info} options are accepted, only one of them can include | |
19936 | a @var{filename}. If other filenames are provided then all but the | |
19937 | first such option are ignored. | |
19938 | ||
19939 | Note that the output @var{filename} is overwritten | |
19940 | in case of multiple translation units. If a combined output from | |
19941 | multiple translation units is desired, @file{stderr} should be used | |
19942 | instead. | |
19943 | ||
19944 | In the following example, the optimization info is output to | |
19945 | @file{stderr}: | |
19946 | ||
19947 | @smallexample | |
19948 | gcc -O3 -fopt-info | |
19949 | @end smallexample | |
19950 | ||
19951 | This example: | |
19952 | @smallexample | |
19953 | gcc -O3 -fopt-info-missed=missed.all | |
19954 | @end smallexample | |
19955 | ||
19956 | @noindent | |
19957 | outputs missed optimization report from all the passes into | |
19958 | @file{missed.all}, and this one: | |
19959 | ||
19960 | @smallexample | |
19961 | gcc -O2 -ftree-vectorize -fopt-info-vec-missed | |
19962 | @end smallexample | |
19963 | ||
19964 | @noindent | |
19965 | prints information about missed optimization opportunities from | |
19966 | vectorization passes on @file{stderr}. | |
19967 | Note that @option{-fopt-info-vec-missed} is equivalent to | |
19968 | @option{-fopt-info-missed-vec}. The order of the optimization group | |
19969 | names and message types listed after @option{-fopt-info} does not matter. | |
19970 | ||
19971 | As another example, | |
19972 | @smallexample | |
19973 | gcc -O3 -fopt-info-inline-optimized-missed=inline.txt | |
19974 | @end smallexample | |
19975 | ||
19976 | @noindent | |
19977 | outputs information about missed optimizations as well as | |
19978 | optimized locations from all the inlining passes into | |
19979 | @file{inline.txt}. | |
19980 | ||
19981 | Finally, consider: | |
19982 | ||
19983 | @smallexample | |
19984 | gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt | |
19985 | @end smallexample | |
19986 | ||
19987 | @noindent | |
19988 | Here the two output filenames @file{vec.miss} and @file{loop.opt} are | |
19989 | in conflict since only one output file is allowed. In this case, only | |
19990 | the first option takes effect and the subsequent options are | |
19991 | ignored. Thus only @file{vec.miss} is produced which contains | |
19992 | dumps from the vectorizer about missed opportunities. | |
19993 | ||
d77de738 | 19994 | @opindex fsave-optimization-record |
ddf6fe37 | 19995 | @item -fsave-optimization-record |
d77de738 ML |
19996 | Write a SRCFILE.opt-record.json.gz file detailing what optimizations |
19997 | were performed, for those optimizations that support @option{-fopt-info}. | |
19998 | ||
19999 | This option is experimental and the format of the data within the | |
20000 | compressed JSON file is subject to change. | |
20001 | ||
20002 | It is roughly equivalent to a machine-readable version of | |
20003 | @option{-fopt-info-all}, as a collection of messages with source file, | |
20004 | line number and column number, with the following additional data for | |
20005 | each message: | |
20006 | ||
20007 | @itemize @bullet | |
20008 | ||
20009 | @item | |
20010 | the execution count of the code being optimized, along with metadata about | |
20011 | whether this was from actual profile data, or just an estimate, allowing | |
20012 | consumers to prioritize messages by code hotness, | |
20013 | ||
20014 | @item | |
20015 | the function name of the code being optimized, where applicable, | |
20016 | ||
20017 | @item | |
20018 | the ``inlining chain'' for the code being optimized, so that when | |
20019 | a function is inlined into several different places (which might | |
20020 | themselves be inlined), the reader can distinguish between the copies, | |
20021 | ||
20022 | @item | |
20023 | objects identifying those parts of the message that refer to expressions, | |
20024 | statements or symbol-table nodes, which of these categories they are, and, | |
20025 | when available, their source code location, | |
20026 | ||
20027 | @item | |
20028 | the GCC pass that emitted the message, and | |
20029 | ||
20030 | @item | |
20031 | the location in GCC's own code from which the message was emitted | |
20032 | ||
20033 | @end itemize | |
20034 | ||
20035 | Additionally, some messages are logically nested within other | |
20036 | messages, reflecting implementation details of the optimization | |
20037 | passes. | |
20038 | ||
d77de738 | 20039 | @opindex fsched-verbose |
ddf6fe37 | 20040 | @item -fsched-verbose=@var{n} |
d77de738 ML |
20041 | On targets that use instruction scheduling, this option controls the |
20042 | amount of debugging output the scheduler prints to the dump files. | |
20043 | ||
20044 | For @var{n} greater than zero, @option{-fsched-verbose} outputs the | |
20045 | same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}. | |
20046 | For @var{n} greater than one, it also output basic block probabilities, | |
20047 | detailed ready list information and unit/insn info. For @var{n} greater | |
20048 | than two, it includes RTL at abort point, control-flow and regions info. | |
20049 | And for @var{n} over four, @option{-fsched-verbose} also includes | |
20050 | dependence info. | |
20051 | ||
20052 | ||
20053 | ||
d77de738 ML |
20054 | @opindex fdisable- |
20055 | @opindex fenable- | |
ddf6fe37 AA |
20056 | @item -fenable-@var{kind}-@var{pass} |
20057 | @itemx -fdisable-@var{kind}-@var{pass}=@var{range-list} | |
d77de738 ML |
20058 | |
20059 | This is a set of options that are used to explicitly disable/enable | |
20060 | optimization passes. These options are intended for use for debugging GCC. | |
20061 | Compiler users should use regular options for enabling/disabling | |
20062 | passes instead. | |
20063 | ||
20064 | @table @gcctabopt | |
20065 | ||
20066 | @item -fdisable-ipa-@var{pass} | |
20067 | Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
20068 | statically invoked in the compiler multiple times, the pass name should be | |
20069 | appended with a sequential number starting from 1. | |
20070 | ||
20071 | @item -fdisable-rtl-@var{pass} | |
20072 | @itemx -fdisable-rtl-@var{pass}=@var{range-list} | |
20073 | Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
20074 | statically invoked in the compiler multiple times, the pass name should be | |
20075 | appended with a sequential number starting from 1. @var{range-list} is a | |
20076 | comma-separated list of function ranges or assembler names. Each range is a number | |
20077 | pair separated by a colon. The range is inclusive in both ends. If the range | |
20078 | is trivial, the number pair can be simplified as a single number. If the | |
20079 | function's call graph node's @var{uid} falls within one of the specified ranges, | |
20080 | the @var{pass} is disabled for that function. The @var{uid} is shown in the | |
20081 | function header of a dump file, and the pass names can be dumped by using | |
20082 | option @option{-fdump-passes}. | |
20083 | ||
20084 | @item -fdisable-tree-@var{pass} | |
20085 | @itemx -fdisable-tree-@var{pass}=@var{range-list} | |
20086 | Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of | |
20087 | option arguments. | |
20088 | ||
20089 | @item -fenable-ipa-@var{pass} | |
20090 | Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
20091 | statically invoked in the compiler multiple times, the pass name should be | |
20092 | appended with a sequential number starting from 1. | |
20093 | ||
20094 | @item -fenable-rtl-@var{pass} | |
20095 | @itemx -fenable-rtl-@var{pass}=@var{range-list} | |
20096 | Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument | |
20097 | description and examples. | |
20098 | ||
20099 | @item -fenable-tree-@var{pass} | |
20100 | @itemx -fenable-tree-@var{pass}=@var{range-list} | |
20101 | Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description | |
20102 | of option arguments. | |
20103 | ||
20104 | @end table | |
20105 | ||
20106 | Here are some examples showing uses of these options. | |
20107 | ||
20108 | @smallexample | |
20109 | ||
20110 | # disable ccp1 for all functions | |
20111 | -fdisable-tree-ccp1 | |
20112 | # disable complete unroll for function whose cgraph node uid is 1 | |
20113 | -fenable-tree-cunroll=1 | |
20114 | # disable gcse2 for functions at the following ranges [1,1], | |
20115 | # [300,400], and [400,1000] | |
20116 | # disable gcse2 for functions foo and foo2 | |
20117 | -fdisable-rtl-gcse2=foo,foo2 | |
20118 | # disable early inlining | |
20119 | -fdisable-tree-einline | |
20120 | # disable ipa inlining | |
20121 | -fdisable-ipa-inline | |
20122 | # enable tree full unroll | |
20123 | -fenable-tree-unroll | |
20124 | ||
20125 | @end smallexample | |
20126 | ||
d77de738 ML |
20127 | @opindex fchecking |
20128 | @opindex fno-checking | |
ddf6fe37 AA |
20129 | @item -fchecking |
20130 | @itemx -fchecking=@var{n} | |
d77de738 ML |
20131 | Enable internal consistency checking. The default depends on |
20132 | the compiler configuration. @option{-fchecking=2} enables further | |
20133 | internal consistency checking that might affect code generation. | |
20134 | ||
d77de738 | 20135 | @opindex frandom-seed |
ddf6fe37 | 20136 | @item -frandom-seed=@var{string} |
d77de738 ML |
20137 | This option provides a seed that GCC uses in place of |
20138 | random numbers in generating certain symbol names | |
20139 | that have to be different in every compiled file. It is also used to | |
20140 | place unique stamps in coverage data files and the object files that | |
20141 | produce them. You can use the @option{-frandom-seed} option to produce | |
20142 | reproducibly identical object files. | |
20143 | ||
20144 | The @var{string} can either be a number (decimal, octal or hex) or an | |
20145 | arbitrary string (in which case it's converted to a number by | |
20146 | computing CRC32). | |
20147 | ||
20148 | The @var{string} should be different for every file you compile. | |
20149 | ||
d77de738 | 20150 | @opindex save-temps |
ddf6fe37 | 20151 | @item -save-temps |
d77de738 ML |
20152 | Store the usual ``temporary'' intermediate files permanently; name them |
20153 | as auxiliary output files, as specified described under | |
20154 | @option{-dumpbase} and @option{-dumpdir}. | |
20155 | ||
20156 | When used in combination with the @option{-x} command-line option, | |
20157 | @option{-save-temps} is sensible enough to avoid overwriting an | |
20158 | input source file with the same extension as an intermediate file. | |
20159 | The corresponding intermediate file may be obtained by renaming the | |
20160 | source file before using @option{-save-temps}. | |
20161 | ||
d77de738 | 20162 | @opindex save-temps=cwd |
ddf6fe37 | 20163 | @item -save-temps=cwd |
d77de738 ML |
20164 | Equivalent to @option{-save-temps -dumpdir ./}. |
20165 | ||
d77de738 | 20166 | @opindex save-temps=obj |
ddf6fe37 | 20167 | @item -save-temps=obj |
d77de738 ML |
20168 | Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where |
20169 | @file{outdir/} is the directory of the output file specified after the | |
20170 | @option{-o} option, including any directory separators. If the | |
20171 | @option{-o} option is not used, the @option{-save-temps=obj} switch | |
20172 | behaves like @option{-save-temps=cwd}. | |
20173 | ||
d77de738 | 20174 | @opindex time |
ddf6fe37 | 20175 | @item -time@r{[}=@var{file}@r{]} |
d77de738 ML |
20176 | Report the CPU time taken by each subprocess in the compilation |
20177 | sequence. For C source files, this is the compiler proper and assembler | |
20178 | (plus the linker if linking is done). | |
20179 | ||
20180 | Without the specification of an output file, the output looks like this: | |
20181 | ||
20182 | @smallexample | |
20183 | # cc1 0.12 0.01 | |
20184 | # as 0.00 0.01 | |
20185 | @end smallexample | |
20186 | ||
20187 | The first number on each line is the ``user time'', that is time spent | |
20188 | executing the program itself. The second number is ``system time'', | |
20189 | time spent executing operating system routines on behalf of the program. | |
20190 | Both numbers are in seconds. | |
20191 | ||
20192 | With the specification of an output file, the output is appended to the | |
20193 | named file, and it looks like this: | |
20194 | ||
20195 | @smallexample | |
20196 | 0.12 0.01 cc1 @var{options} | |
20197 | 0.00 0.01 as @var{options} | |
20198 | @end smallexample | |
20199 | ||
20200 | The ``user time'' and the ``system time'' are moved before the program | |
20201 | name, and the options passed to the program are displayed, so that one | |
20202 | can later tell what file was being compiled, and with which options. | |
20203 | ||
d77de738 | 20204 | @opindex fdump-final-insns |
ddf6fe37 | 20205 | @item -fdump-final-insns@r{[}=@var{file}@r{]} |
d77de738 ML |
20206 | Dump the final internal representation (RTL) to @var{file}. If the |
20207 | optional argument is omitted (or if @var{file} is @code{.}), the name | |
20208 | of the dump file is determined by appending @code{.gkd} to the | |
20209 | dump base name, see @option{-dumpbase}. | |
20210 | ||
d77de738 ML |
20211 | @opindex fcompare-debug |
20212 | @opindex fno-compare-debug | |
ddf6fe37 | 20213 | @item -fcompare-debug@r{[}=@var{opts}@r{]} |
d77de738 ML |
20214 | If no error occurs during compilation, run the compiler a second time, |
20215 | adding @var{opts} and @option{-fcompare-debug-second} to the arguments | |
20216 | passed to the second compilation. Dump the final internal | |
20217 | representation in both compilations, and print an error if they differ. | |
20218 | ||
20219 | If the equal sign is omitted, the default @option{-gtoggle} is used. | |
20220 | ||
20221 | The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty | |
20222 | and nonzero, implicitly enables @option{-fcompare-debug}. If | |
20223 | @env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash, | |
20224 | then it is used for @var{opts}, otherwise the default @option{-gtoggle} | |
20225 | is used. | |
20226 | ||
20227 | @option{-fcompare-debug=}, with the equal sign but without @var{opts}, | |
20228 | is equivalent to @option{-fno-compare-debug}, which disables the dumping | |
20229 | of the final representation and the second compilation, preventing even | |
20230 | @env{GCC_COMPARE_DEBUG} from taking effect. | |
20231 | ||
20232 | To verify full coverage during @option{-fcompare-debug} testing, set | |
20233 | @env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden}, | |
20234 | which GCC rejects as an invalid option in any actual compilation | |
20235 | (rather than preprocessing, assembly or linking). To get just a | |
20236 | warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug | |
20237 | not overridden} will do. | |
20238 | ||
d77de738 | 20239 | @opindex fcompare-debug-second |
ddf6fe37 | 20240 | @item -fcompare-debug-second |
d77de738 ML |
20241 | This option is implicitly passed to the compiler for the second |
20242 | compilation requested by @option{-fcompare-debug}, along with options to | |
20243 | silence warnings, and omitting other options that would cause the compiler | |
20244 | to produce output to files or to standard output as a side effect. Dump | |
20245 | files and preserved temporary files are renamed so as to contain the | |
20246 | @code{.gk} additional extension during the second compilation, to avoid | |
20247 | overwriting those generated by the first. | |
20248 | ||
20249 | When this option is passed to the compiler driver, it causes the | |
20250 | @emph{first} compilation to be skipped, which makes it useful for little | |
20251 | other than debugging the compiler proper. | |
20252 | ||
d77de738 | 20253 | @opindex gtoggle |
ddf6fe37 | 20254 | @item -gtoggle |
d77de738 ML |
20255 | Turn off generation of debug info, if leaving out this option |
20256 | generates it, or turn it on at level 2 otherwise. The position of this | |
20257 | argument in the command line does not matter; it takes effect after all | |
20258 | other options are processed, and it does so only once, no matter how | |
20259 | many times it is given. This is mainly intended to be used with | |
20260 | @option{-fcompare-debug}. | |
20261 | ||
d77de738 ML |
20262 | @opindex fvar-tracking-assignments-toggle |
20263 | @opindex fno-var-tracking-assignments-toggle | |
ddf6fe37 | 20264 | @item -fvar-tracking-assignments-toggle |
d77de738 ML |
20265 | Toggle @option{-fvar-tracking-assignments}, in the same way that |
20266 | @option{-gtoggle} toggles @option{-g}. | |
20267 | ||
d77de738 | 20268 | @opindex Q |
ddf6fe37 | 20269 | @item -Q |
d77de738 ML |
20270 | Makes the compiler print out each function name as it is compiled, and |
20271 | print some statistics about each pass when it finishes. | |
20272 | ||
d77de738 | 20273 | @opindex ftime-report |
ddf6fe37 | 20274 | @item -ftime-report |
75d62394 DM |
20275 | Makes the compiler print some statistics to stderr about the time consumed |
20276 | by each pass when it finishes. | |
20277 | ||
20278 | If SARIF output of diagnostics was requested via | |
20279 | @option{-fdiagnostics-format=sarif-file} or | |
20280 | @option{-fdiagnostics-format=sarif-stderr} then the @option{-ftime-report} | |
20281 | information is instead emitted in JSON form as part of SARIF output. The | |
20282 | precise format of this JSON data is subject to change, and the values may | |
20283 | not exactly match those emitted to stderr due to being written out at a | |
20284 | slightly different place within the compiler. | |
d77de738 | 20285 | |
d77de738 | 20286 | @opindex ftime-report-details |
ddf6fe37 | 20287 | @item -ftime-report-details |
d77de738 ML |
20288 | Record the time consumed by infrastructure parts separately for each pass. |
20289 | ||
d77de738 | 20290 | @opindex fira-verbose |
ddf6fe37 | 20291 | @item -fira-verbose=@var{n} |
d77de738 ML |
20292 | Control the verbosity of the dump file for the integrated register allocator. |
20293 | The default value is 5. If the value @var{n} is greater or equal to 10, | |
20294 | the dump output is sent to stderr using the same format as @var{n} minus 10. | |
20295 | ||
d77de738 | 20296 | @opindex flto-report |
ddf6fe37 | 20297 | @item -flto-report |
d77de738 ML |
20298 | Prints a report with internal details on the workings of the link-time |
20299 | optimizer. The contents of this report vary from version to version. | |
20300 | It is meant to be useful to GCC developers when processing object | |
20301 | files in LTO mode (via @option{-flto}). | |
20302 | ||
20303 | Disabled by default. | |
20304 | ||
d77de738 | 20305 | @opindex flto-report-wpa |
ddf6fe37 | 20306 | @item -flto-report-wpa |
d77de738 ML |
20307 | Like @option{-flto-report}, but only print for the WPA phase of link-time |
20308 | optimization. | |
20309 | ||
d77de738 | 20310 | @opindex fmem-report |
ddf6fe37 | 20311 | @item -fmem-report |
d77de738 ML |
20312 | Makes the compiler print some statistics about permanent memory |
20313 | allocation when it finishes. | |
20314 | ||
d77de738 | 20315 | @opindex fmem-report-wpa |
ddf6fe37 | 20316 | @item -fmem-report-wpa |
d77de738 ML |
20317 | Makes the compiler print some statistics about permanent memory |
20318 | allocation for the WPA phase only. | |
20319 | ||
d77de738 | 20320 | @opindex fpre-ipa-mem-report |
d77de738 | 20321 | @opindex fpost-ipa-mem-report |
ddf6fe37 AA |
20322 | @item -fpre-ipa-mem-report |
20323 | @item -fpost-ipa-mem-report | |
d77de738 ML |
20324 | Makes the compiler print some statistics about permanent memory |
20325 | allocation before or after interprocedural optimization. | |
20326 | ||
d77de738 | 20327 | @opindex fmultiflags |
ddf6fe37 | 20328 | @item -fmultiflags |
d77de738 ML |
20329 | This option enables multilib-aware @code{TFLAGS} to be used to build |
20330 | target libraries with options different from those the compiler is | |
20331 | configured to use by default, through the use of specs (@xref{Spec | |
20332 | Files}) set up by compiler internals, by the target, or by builders at | |
20333 | configure time. | |
20334 | ||
20335 | Like @code{TFLAGS}, this allows the target libraries to be built for | |
20336 | portable baseline environments, while the compiler defaults to more | |
20337 | demanding ones. That's useful because users can easily override the | |
20338 | defaults the compiler is configured to use to build their own programs, | |
20339 | if the defaults are not ideal for their target environment, whereas | |
20340 | rebuilding the runtime libraries is usually not as easy or desirable. | |
20341 | ||
20342 | Unlike @code{TFLAGS}, the use of specs enables different flags to be | |
20343 | selected for different multilibs. The way to accomplish that is to | |
20344 | build with @samp{make TFLAGS=-fmultiflags}, after configuring | |
20345 | @samp{--with-specs=%@{fmultiflags:...@}}. | |
20346 | ||
20347 | This option is discarded by the driver once it's done processing driver | |
20348 | self spec. | |
20349 | ||
20350 | It is also useful to check that @code{TFLAGS} are being used to build | |
20351 | all target libraries, by configuring a non-bootstrap compiler | |
20352 | @samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building | |
20353 | the compiler and target libraries. | |
20354 | ||
d77de738 | 20355 | @opindex fprofile-report |
ddf6fe37 | 20356 | @item -fprofile-report |
d77de738 ML |
20357 | Makes the compiler print some statistics about consistency of the |
20358 | (estimated) profile and effect of individual passes. | |
20359 | ||
d77de738 | 20360 | @opindex fstack-usage |
ddf6fe37 | 20361 | @item -fstack-usage |
d77de738 ML |
20362 | Makes the compiler output stack usage information for the program, on a |
20363 | per-function basis. The filename for the dump is made by appending | |
20364 | @file{.su} to the @var{auxname}. @var{auxname} is generated from the name of | |
20365 | the output file, if explicitly specified and it is not an executable, | |
20366 | otherwise it is the basename of the source file. An entry is made up | |
20367 | of three fields: | |
20368 | ||
20369 | @itemize | |
20370 | @item | |
20371 | The name of the function. | |
20372 | @item | |
20373 | A number of bytes. | |
20374 | @item | |
20375 | One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}. | |
20376 | @end itemize | |
20377 | ||
20378 | The qualifier @code{static} means that the function manipulates the stack | |
20379 | statically: a fixed number of bytes are allocated for the frame on function | |
20380 | entry and released on function exit; no stack adjustments are otherwise made | |
20381 | in the function. The second field is this fixed number of bytes. | |
20382 | ||
20383 | The qualifier @code{dynamic} means that the function manipulates the stack | |
20384 | dynamically: in addition to the static allocation described above, stack | |
20385 | adjustments are made in the body of the function, for example to push/pop | |
20386 | arguments around function calls. If the qualifier @code{bounded} is also | |
20387 | present, the amount of these adjustments is bounded at compile time and | |
20388 | the second field is an upper bound of the total amount of stack used by | |
20389 | the function. If it is not present, the amount of these adjustments is | |
20390 | not bounded at compile time and the second field only represents the | |
20391 | bounded part. | |
20392 | ||
d77de738 | 20393 | @opindex fstats |
ddf6fe37 | 20394 | @item -fstats |
d77de738 ML |
20395 | Emit statistics about front-end processing at the end of the compilation. |
20396 | This option is supported only by the C++ front end, and | |
20397 | the information is generally only useful to the G++ development team. | |
20398 | ||
d77de738 | 20399 | @opindex fdbg-cnt-list |
ddf6fe37 | 20400 | @item -fdbg-cnt-list |
d77de738 ML |
20401 | Print the name and the counter upper bound for all debug counters. |
20402 | ||
20403 | ||
d77de738 | 20404 | @opindex fdbg-cnt |
ddf6fe37 | 20405 | @item -fdbg-cnt=@var{counter-value-list} |
d77de738 ML |
20406 | Set the internal debug counter lower and upper bound. @var{counter-value-list} |
20407 | is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1} | |
20408 | [:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets | |
20409 | the name of the counter and list of closed intervals. | |
20410 | The @var{lower_bound} is optional and is zero | |
20411 | initialized if not set. | |
20412 | For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10}, | |
20413 | @code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and | |
20414 | eleventh invocation. | |
20415 | For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations. | |
20416 | ||
d77de738 | 20417 | @opindex print-file-name |
ddf6fe37 | 20418 | @item -print-file-name=@var{library} |
d77de738 ML |
20419 | Print the full absolute name of the library file @var{library} that |
20420 | would be used when linking---and don't do anything else. With this | |
20421 | option, GCC does not compile or link anything; it just prints the | |
20422 | file name. | |
20423 | ||
d77de738 | 20424 | @opindex print-multi-directory |
ddf6fe37 | 20425 | @item -print-multi-directory |
d77de738 ML |
20426 | Print the directory name corresponding to the multilib selected by any |
20427 | other switches present in the command line. This directory is supposed | |
20428 | to exist in @env{GCC_EXEC_PREFIX}. | |
20429 | ||
d77de738 | 20430 | @opindex print-multi-lib |
ddf6fe37 | 20431 | @item -print-multi-lib |
d77de738 ML |
20432 | Print the mapping from multilib directory names to compiler switches |
20433 | that enable them. The directory name is separated from the switches by | |
20434 | @samp{;}, and each switch starts with an @samp{@@} instead of the | |
20435 | @samp{-}, without spaces between multiple switches. This is supposed to | |
20436 | ease shell processing. | |
20437 | ||
d77de738 | 20438 | @opindex print-multi-os-directory |
ddf6fe37 | 20439 | @item -print-multi-os-directory |
d77de738 ML |
20440 | Print the path to OS libraries for the selected |
20441 | multilib, relative to some @file{lib} subdirectory. If OS libraries are | |
20442 | present in the @file{lib} subdirectory and no multilibs are used, this is | |
20443 | usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}} | |
20444 | sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or | |
20445 | @file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}} | |
20446 | subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}. | |
20447 | ||
d77de738 | 20448 | @opindex print-multiarch |
ddf6fe37 | 20449 | @item -print-multiarch |
d77de738 ML |
20450 | Print the path to OS libraries for the selected multiarch, |
20451 | relative to some @file{lib} subdirectory. | |
20452 | ||
d77de738 | 20453 | @opindex print-prog-name |
ddf6fe37 | 20454 | @item -print-prog-name=@var{program} |
d77de738 ML |
20455 | Like @option{-print-file-name}, but searches for a program such as @command{cpp}. |
20456 | ||
d77de738 | 20457 | @opindex print-libgcc-file-name |
ddf6fe37 | 20458 | @item -print-libgcc-file-name |
d77de738 ML |
20459 | Same as @option{-print-file-name=libgcc.a}. |
20460 | ||
20461 | This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs} | |
20462 | but you do want to link with @file{libgcc.a}. You can do: | |
20463 | ||
20464 | @smallexample | |
20465 | gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name` | |
20466 | @end smallexample | |
20467 | ||
d77de738 | 20468 | @opindex print-search-dirs |
ddf6fe37 | 20469 | @item -print-search-dirs |
d77de738 ML |
20470 | Print the name of the configured installation directory and a list of |
20471 | program and library directories @command{gcc} searches---and don't do anything else. | |
20472 | ||
20473 | This is useful when @command{gcc} prints the error message | |
20474 | @samp{installation problem, cannot exec cpp0: No such file or directory}. | |
20475 | To resolve this you either need to put @file{cpp0} and the other compiler | |
20476 | components where @command{gcc} expects to find them, or you can set the environment | |
20477 | variable @env{GCC_EXEC_PREFIX} to the directory where you installed them. | |
20478 | Don't forget the trailing @samp{/}. | |
20479 | @xref{Environment Variables}. | |
20480 | ||
d77de738 | 20481 | @opindex print-sysroot |
ddf6fe37 | 20482 | @item -print-sysroot |
d77de738 ML |
20483 | Print the target sysroot directory that is used during |
20484 | compilation. This is the target sysroot specified either at configure | |
20485 | time or using the @option{--sysroot} option, possibly with an extra | |
20486 | suffix that depends on compilation options. If no target sysroot is | |
20487 | specified, the option prints nothing. | |
20488 | ||
d77de738 | 20489 | @opindex print-sysroot-headers-suffix |
ddf6fe37 | 20490 | @item -print-sysroot-headers-suffix |
d77de738 ML |
20491 | Print the suffix added to the target sysroot when searching for |
20492 | headers, or give an error if the compiler is not configured with such | |
20493 | a suffix---and don't do anything else. | |
20494 | ||
d77de738 | 20495 | @opindex dumpmachine |
ddf6fe37 | 20496 | @item -dumpmachine |
d77de738 ML |
20497 | Print the compiler's target machine (for example, |
20498 | @samp{i686-pc-linux-gnu})---and don't do anything else. | |
20499 | ||
d77de738 | 20500 | @opindex dumpversion |
ddf6fe37 | 20501 | @item -dumpversion |
d77de738 ML |
20502 | Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do |
20503 | anything else. This is the compiler version used in filesystem paths and | |
20504 | specs. Depending on how the compiler has been configured it can be just | |
20505 | a single number (major version), two numbers separated by a dot (major and | |
20506 | minor version) or three numbers separated by dots (major, minor and patchlevel | |
20507 | version). | |
20508 | ||
d77de738 | 20509 | @opindex dumpfullversion |
ddf6fe37 | 20510 | @item -dumpfullversion |
d77de738 ML |
20511 | Print the full compiler version---and don't do anything else. The output is |
20512 | always three numbers separated by dots, major, minor and patchlevel version. | |
20513 | ||
d77de738 | 20514 | @opindex dumpspecs |
ddf6fe37 | 20515 | @item -dumpspecs |
d77de738 ML |
20516 | Print the compiler's built-in specs---and don't do anything else. (This |
20517 | is used when GCC itself is being built.) @xref{Spec Files}. | |
20518 | @end table | |
20519 | ||
20520 | @node Submodel Options | |
20521 | @section Machine-Dependent Options | |
20522 | @cindex submodel options | |
20523 | @cindex specifying hardware config | |
20524 | @cindex hardware models and configurations, specifying | |
20525 | @cindex target-dependent options | |
20526 | @cindex machine-dependent options | |
20527 | ||
20528 | Each target machine supported by GCC can have its own options---for | |
20529 | example, to allow you to compile for a particular processor variant or | |
20530 | ABI, or to control optimizations specific to that machine. By | |
20531 | convention, the names of machine-specific options start with | |
20532 | @samp{-m}. | |
20533 | ||
20534 | Some configurations of the compiler also support additional target-specific | |
20535 | options, usually for compatibility with other compilers on the same | |
20536 | platform. | |
20537 | ||
20538 | @c This list is ordered alphanumerically by subsection name. | |
20539 | @c It should be the same order and spelling as these options are listed | |
20540 | @c in Machine Dependent Options | |
20541 | ||
20542 | @menu | |
20543 | * AArch64 Options:: | |
20544 | * Adapteva Epiphany Options:: | |
20545 | * AMD GCN Options:: | |
20546 | * ARC Options:: | |
20547 | * ARM Options:: | |
20548 | * AVR Options:: | |
20549 | * Blackfin Options:: | |
20550 | * C6X Options:: | |
20551 | * CRIS Options:: | |
20552 | * C-SKY Options:: | |
20553 | * Darwin Options:: | |
20554 | * DEC Alpha Options:: | |
20555 | * eBPF Options:: | |
20556 | * FR30 Options:: | |
20557 | * FT32 Options:: | |
20558 | * FRV Options:: | |
20559 | * GNU/Linux Options:: | |
20560 | * H8/300 Options:: | |
20561 | * HPPA Options:: | |
20562 | * IA-64 Options:: | |
20563 | * LM32 Options:: | |
20564 | * LoongArch Options:: | |
20565 | * M32C Options:: | |
20566 | * M32R/D Options:: | |
20567 | * M680x0 Options:: | |
20568 | * MCore Options:: | |
d77de738 ML |
20569 | * MicroBlaze Options:: |
20570 | * MIPS Options:: | |
20571 | * MMIX Options:: | |
20572 | * MN10300 Options:: | |
20573 | * Moxie Options:: | |
20574 | * MSP430 Options:: | |
20575 | * NDS32 Options:: | |
20576 | * Nios II Options:: | |
20577 | * Nvidia PTX Options:: | |
20578 | * OpenRISC Options:: | |
20579 | * PDP-11 Options:: | |
d77de738 ML |
20580 | * PowerPC Options:: |
20581 | * PRU Options:: | |
20582 | * RISC-V Options:: | |
20583 | * RL78 Options:: | |
20584 | * RS/6000 and PowerPC Options:: | |
20585 | * RX Options:: | |
20586 | * S/390 and zSeries Options:: | |
d77de738 ML |
20587 | * SH Options:: |
20588 | * Solaris 2 Options:: | |
20589 | * SPARC Options:: | |
20590 | * System V Options:: | |
20591 | * V850 Options:: | |
20592 | * VAX Options:: | |
20593 | * Visium Options:: | |
20594 | * VMS Options:: | |
20595 | * VxWorks Options:: | |
20596 | * x86 Options:: | |
20597 | * x86 Windows Options:: | |
20598 | * Xstormy16 Options:: | |
20599 | * Xtensa Options:: | |
20600 | * zSeries Options:: | |
20601 | @end menu | |
20602 | ||
20603 | @node AArch64 Options | |
20604 | @subsection AArch64 Options | |
20605 | @cindex AArch64 Options | |
20606 | ||
20607 | These options are defined for AArch64 implementations: | |
20608 | ||
20609 | @table @gcctabopt | |
20610 | ||
d77de738 | 20611 | @opindex mabi |
ddf6fe37 | 20612 | @item -mabi=@var{name} |
d77de738 ML |
20613 | Generate code for the specified data model. Permissible values |
20614 | are @samp{ilp32} for SysV-like data model where int, long int and pointers | |
20615 | are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits, | |
20616 | but long int and pointers are 64 bits. | |
20617 | ||
20618 | The default depends on the specific target configuration. Note that | |
20619 | the LP64 and ILP32 ABIs are not link-compatible; you must compile your | |
20620 | entire program with the same ABI, and link with a compatible set of libraries. | |
20621 | ||
d77de738 | 20622 | @opindex mbig-endian |
ddf6fe37 | 20623 | @item -mbig-endian |
d77de738 ML |
20624 | Generate big-endian code. This is the default when GCC is configured for an |
20625 | @samp{aarch64_be-*-*} target. | |
20626 | ||
d77de738 | 20627 | @opindex mgeneral-regs-only |
ddf6fe37 | 20628 | @item -mgeneral-regs-only |
d77de738 ML |
20629 | Generate code which uses only the general-purpose registers. This will prevent |
20630 | the compiler from using floating-point and Advanced SIMD registers but will not | |
20631 | impose any restrictions on the assembler. | |
20632 | ||
d77de738 | 20633 | @opindex mlittle-endian |
ddf6fe37 | 20634 | @item -mlittle-endian |
d77de738 ML |
20635 | Generate little-endian code. This is the default when GCC is configured for an |
20636 | @samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target. | |
20637 | ||
d77de738 | 20638 | @opindex mcmodel=tiny |
ddf6fe37 | 20639 | @item -mcmodel=tiny |
d77de738 ML |
20640 | Generate code for the tiny code model. The program and its statically defined |
20641 | symbols must be within 1MB of each other. Programs can be statically or | |
20642 | dynamically linked. | |
20643 | ||
d77de738 | 20644 | @opindex mcmodel=small |
ddf6fe37 | 20645 | @item -mcmodel=small |
d77de738 ML |
20646 | Generate code for the small code model. The program and its statically defined |
20647 | symbols must be within 4GB of each other. Programs can be statically or | |
20648 | dynamically linked. This is the default code model. | |
20649 | ||
d77de738 | 20650 | @opindex mcmodel=large |
ddf6fe37 | 20651 | @item -mcmodel=large |
d77de738 ML |
20652 | Generate code for the large code model. This makes no assumptions about |
20653 | addresses and sizes of sections. Programs can be statically linked only. The | |
20654 | @option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32}, | |
20655 | @option{-fpic} and @option{-fPIC}. | |
20656 | ||
573624ec KT |
20657 | @item -mtp=@var{name} |
20658 | @opindex mtp | |
20659 | Specify the system register to use as a thread pointer. The valid values | |
4389a2d2 KT |
20660 | are @samp{tpidr_el0}, @samp{tpidrro_el0}, @samp{tpidr_el1}, @samp{tpidr_el2}, |
20661 | @samp{tpidr_el3}. For backwards compatibility the aliases @samp{el0}, | |
20662 | @samp{el1}, @samp{el2}, @samp{el3} are also accepted. | |
20663 | The default setting is @samp{tpidr_el0}. It is recommended to compile all | |
20664 | code intended to interoperate with the same value of this option to avoid | |
20665 | accessing a different thread pointer from the wrong exception level. | |
573624ec | 20666 | |
d77de738 ML |
20667 | @opindex mstrict-align |
20668 | @opindex mno-strict-align | |
ddf6fe37 AA |
20669 | @item -mstrict-align |
20670 | @itemx -mno-strict-align | |
d77de738 ML |
20671 | Avoid or allow generating memory accesses that may not be aligned on a natural |
20672 | object boundary as described in the architecture specification. | |
20673 | ||
d77de738 ML |
20674 | @opindex momit-leaf-frame-pointer |
20675 | @opindex mno-omit-leaf-frame-pointer | |
ddf6fe37 AA |
20676 | @item -momit-leaf-frame-pointer |
20677 | @itemx -mno-omit-leaf-frame-pointer | |
d77de738 ML |
20678 | Omit or keep the frame pointer in leaf functions. The former behavior is the |
20679 | default. | |
20680 | ||
d77de738 ML |
20681 | @opindex mstack-protector-guard |
20682 | @opindex mstack-protector-guard-reg | |
20683 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
20684 | @item -mstack-protector-guard=@var{guard} |
20685 | @itemx -mstack-protector-guard-reg=@var{reg} | |
20686 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
20687 | Generate stack protection code using canary at @var{guard}. Supported |
20688 | locations are @samp{global} for a global canary or @samp{sysreg} for a | |
20689 | canary in an appropriate system register. | |
20690 | ||
20691 | With the latter choice the options | |
20692 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
20693 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
20694 | which system register to use as base register for reading the canary, | |
20695 | and from what offset from that base register. There is no default | |
20696 | register or offset as this is entirely for use within the Linux | |
20697 | kernel. | |
20698 | ||
d77de738 | 20699 | @opindex mtls-dialect=desc |
ddf6fe37 | 20700 | @item -mtls-dialect=desc |
d77de738 ML |
20701 | Use TLS descriptors as the thread-local storage mechanism for dynamic accesses |
20702 | of TLS variables. This is the default. | |
20703 | ||
d77de738 | 20704 | @opindex mtls-dialect=traditional |
ddf6fe37 | 20705 | @item -mtls-dialect=traditional |
d77de738 ML |
20706 | Use traditional TLS as the thread-local storage mechanism for dynamic accesses |
20707 | of TLS variables. | |
20708 | ||
d77de738 | 20709 | @opindex mtls-size |
ddf6fe37 | 20710 | @item -mtls-size=@var{size} |
d77de738 ML |
20711 | Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48. |
20712 | This option requires binutils 2.26 or newer. | |
20713 | ||
d77de738 ML |
20714 | @opindex mfix-cortex-a53-835769 |
20715 | @opindex mno-fix-cortex-a53-835769 | |
ddf6fe37 AA |
20716 | @item -mfix-cortex-a53-835769 |
20717 | @itemx -mno-fix-cortex-a53-835769 | |
d77de738 ML |
20718 | Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769. |
20719 | This involves inserting a NOP instruction between memory instructions and | |
20720 | 64-bit integer multiply-accumulate instructions. | |
20721 | ||
d77de738 ML |
20722 | @opindex mfix-cortex-a53-843419 |
20723 | @opindex mno-fix-cortex-a53-843419 | |
ddf6fe37 AA |
20724 | @item -mfix-cortex-a53-843419 |
20725 | @itemx -mno-fix-cortex-a53-843419 | |
d77de738 ML |
20726 | Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419. |
20727 | This erratum workaround is made at link time and this will only pass the | |
20728 | corresponding flag to the linker. | |
20729 | ||
d77de738 ML |
20730 | @opindex mlow-precision-recip-sqrt |
20731 | @opindex mno-low-precision-recip-sqrt | |
ddf6fe37 AA |
20732 | @item -mlow-precision-recip-sqrt |
20733 | @itemx -mno-low-precision-recip-sqrt | |
d77de738 ML |
20734 | Enable or disable the reciprocal square root approximation. |
20735 | This option only has an effect if @option{-ffast-math} or | |
20736 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
20737 | precision of reciprocal square root results to about 16 bits for | |
20738 | single precision and to 32 bits for double precision. | |
20739 | ||
d77de738 ML |
20740 | @opindex mlow-precision-sqrt |
20741 | @opindex mno-low-precision-sqrt | |
ddf6fe37 AA |
20742 | @item -mlow-precision-sqrt |
20743 | @itemx -mno-low-precision-sqrt | |
d77de738 ML |
20744 | Enable or disable the square root approximation. |
20745 | This option only has an effect if @option{-ffast-math} or | |
20746 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
20747 | precision of square root results to about 16 bits for | |
20748 | single precision and to 32 bits for double precision. | |
20749 | If enabled, it implies @option{-mlow-precision-recip-sqrt}. | |
20750 | ||
d77de738 ML |
20751 | @opindex mlow-precision-div |
20752 | @opindex mno-low-precision-div | |
ddf6fe37 AA |
20753 | @item -mlow-precision-div |
20754 | @itemx -mno-low-precision-div | |
d77de738 ML |
20755 | Enable or disable the division approximation. |
20756 | This option only has an effect if @option{-ffast-math} or | |
20757 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
20758 | precision of division results to about 16 bits for | |
20759 | single precision and to 32 bits for double precision. | |
20760 | ||
20761 | @item -mtrack-speculation | |
20762 | @itemx -mno-track-speculation | |
20763 | Enable or disable generation of additional code to track speculative | |
20764 | execution through conditional branches. The tracking state can then | |
20765 | be used by the compiler when expanding calls to | |
20766 | @code{__builtin_speculation_safe_copy} to permit a more efficient code | |
20767 | sequence to be generated. | |
20768 | ||
20769 | @item -moutline-atomics | |
20770 | @itemx -mno-outline-atomics | |
20771 | Enable or disable calls to out-of-line helpers to implement atomic operations. | |
20772 | These helpers will, at runtime, determine if the LSE instructions from | |
20773 | ARMv8.1-A can be used; if not, they will use the load/store-exclusive | |
20774 | instructions that are present in the base ARMv8.0 ISA. | |
20775 | ||
20776 | This option is only applicable when compiling for the base ARMv8.0 | |
20777 | instruction set. If using a later revision, e.g. @option{-march=armv8.1-a} | |
20778 | or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be | |
20779 | used directly. The same applies when using @option{-mcpu=} when the | |
20780 | selected cpu supports the @samp{lse} feature. | |
20781 | This option is on by default. | |
20782 | ||
d77de738 | 20783 | @opindex march |
ddf6fe37 | 20784 | @item -march=@var{name} |
d77de738 ML |
20785 | Specify the name of the target architecture and, optionally, one or |
20786 | more feature modifiers. This option has the form | |
20787 | @option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}. | |
20788 | ||
20789 | The table below summarizes the permissible values for @var{arch} | |
20790 | and the features that they enable by default: | |
20791 | ||
20792 | @multitable @columnfractions 0.20 0.20 0.60 | |
20793 | @headitem @var{arch} value @tab Architecture @tab Includes by default | |
20794 | @item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd} | |
20795 | @item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma} | |
20796 | @item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a} | |
20797 | @item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth} | |
20798 | @item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod} | |
20799 | @item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres} | |
20800 | @item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm} | |
20801 | @item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64} | |
20802 | @item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops} | |
20803 | @item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2} | |
20804 | @item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm} | |
20805 | @item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64} | |
20806 | @item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops} | |
20807 | @item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r} | |
20808 | @end multitable | |
20809 | ||
20810 | The value @samp{native} is available on native AArch64 GNU/Linux and | |
20811 | causes the compiler to pick the architecture of the host system. This | |
20812 | option has no effect if the compiler is unable to recognize the | |
20813 | architecture of the host system, | |
20814 | ||
20815 | The permissible values for @var{feature} are listed in the sub-section | |
20816 | on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu} | |
20817 | Feature Modifiers}. Where conflicting feature modifiers are | |
20818 | specified, the right-most feature is used. | |
20819 | ||
20820 | GCC uses @var{name} to determine what kind of instructions it can emit | |
20821 | when generating assembly code. If @option{-march} is specified | |
20822 | without either of @option{-mtune} or @option{-mcpu} also being | |
20823 | specified, the code is tuned to perform well across a range of target | |
20824 | processors implementing the target architecture. | |
20825 | ||
d77de738 | 20826 | @opindex mtune |
ddf6fe37 | 20827 | @item -mtune=@var{name} |
d77de738 ML |
20828 | Specify the name of the target processor for which GCC should tune the |
20829 | performance of the code. Permissible values for this option are: | |
20830 | @samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, | |
20831 | @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, | |
20832 | @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77}, | |
20833 | @samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34}, | |
20834 | @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, | |
20835 | @samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor}, | |
20836 | @samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1}, | |
20837 | @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx}, | |
20838 | @samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan}, | |
20839 | @samp{octeontx}, @samp{octeontx81}, @samp{octeontx83}, | |
20840 | @samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96} | |
20841 | @samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n}, | |
20842 | @samp{octeontx2f95mm}, | |
20843 | @samp{a64fx}, | |
20844 | @samp{thunderx}, @samp{thunderxt88}, | |
20845 | @samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110}, | |
20846 | @samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus}, | |
20847 | @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
20848 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
20849 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}, | |
ce51e843 | 20850 | @samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2}, |
3bfde22c SJ |
20851 | @samp{cortex-x3}, @samp{cortex-x4}, @samp{cortex-a510}, @samp{cortex-a520}, |
20852 | @samp{cortex-a710}, @samp{cortex-a715}, @samp{cortex-a720}, @samp{ampere1}, | |
20853 | @samp{ampere1a}, and @samp{native}. | |
d77de738 ML |
20854 | |
20855 | The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
20856 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
20857 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC | |
20858 | should tune for a big.LITTLE system. | |
20859 | ||
20860 | The value @samp{neoverse-512tvb} specifies that GCC should tune | |
20861 | for Neoverse cores that (a) implement SVE and (b) have a total vector | |
20862 | bandwidth of 512 bits per cycle. In other words, the option tells GCC to | |
20863 | tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic | |
20864 | instructions a cycle and that can execute an equivalent number of SVE | |
20865 | arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE). | |
20866 | This is more general than tuning for a specific core like Neoverse V1 | |
20867 | but is more specific than the default tuning described below. | |
20868 | ||
20869 | Additionally on native AArch64 GNU/Linux systems the value | |
20870 | @samp{native} tunes performance to the host system. This option has no effect | |
20871 | if the compiler is unable to recognize the processor of the host system. | |
20872 | ||
20873 | Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=} | |
20874 | are specified, the code is tuned to perform well across a range | |
20875 | of target processors. | |
20876 | ||
20877 | This option cannot be suffixed by feature modifiers. | |
20878 | ||
d77de738 | 20879 | @opindex mcpu |
ddf6fe37 | 20880 | @item -mcpu=@var{name} |
d77de738 ML |
20881 | Specify the name of the target processor, optionally suffixed by one |
20882 | or more feature modifiers. This option has the form | |
20883 | @option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where | |
20884 | the permissible values for @var{cpu} are the same as those available | |
20885 | for @option{-mtune}. The permissible values for @var{feature} are | |
20886 | documented in the sub-section on | |
20887 | @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu} | |
20888 | Feature Modifiers}. Where conflicting feature modifiers are | |
20889 | specified, the right-most feature is used. | |
20890 | ||
20891 | GCC uses @var{name} to determine what kind of instructions it can emit when | |
20892 | generating assembly code (as if by @option{-march}) and to determine | |
20893 | the target processor for which to tune for performance (as if | |
20894 | by @option{-mtune}). Where this option is used in conjunction | |
20895 | with @option{-march} or @option{-mtune}, those options take precedence | |
20896 | over the appropriate part of this option. | |
20897 | ||
20898 | @option{-mcpu=neoverse-512tvb} is special in that it does not refer | |
20899 | to a specific core, but instead refers to all Neoverse cores that | |
20900 | (a) implement SVE and (b) have a total vector bandwidth of 512 bits | |
20901 | a cycle. Unless overridden by @option{-march}, | |
20902 | @option{-mcpu=neoverse-512tvb} generates code that can run on a | |
20903 | Neoverse V1 core, since Neoverse V1 is the first Neoverse core with | |
20904 | these properties. Unless overridden by @option{-mtune}, | |
20905 | @option{-mcpu=neoverse-512tvb} tunes code in the same way as for | |
20906 | @option{-mtune=neoverse-512tvb}. | |
20907 | ||
d77de738 | 20908 | @opindex moverride |
ddf6fe37 | 20909 | @item -moverride=@var{string} |
d77de738 ML |
20910 | Override tuning decisions made by the back-end in response to a |
20911 | @option{-mtune=} switch. The syntax, semantics, and accepted values | |
20912 | for @var{string} in this option are not guaranteed to be consistent | |
20913 | across releases. | |
20914 | ||
20915 | This option is only intended to be useful when developing GCC. | |
20916 | ||
d77de738 | 20917 | @opindex mverbose-cost-dump |
ddf6fe37 | 20918 | @item -mverbose-cost-dump |
d77de738 ML |
20919 | Enable verbose cost model dumping in the debug dump files. This option is |
20920 | provided for use in debugging the compiler. | |
20921 | ||
d77de738 ML |
20922 | @opindex mpc-relative-literal-loads |
20923 | @opindex mno-pc-relative-literal-loads | |
ddf6fe37 AA |
20924 | @item -mpc-relative-literal-loads |
20925 | @itemx -mno-pc-relative-literal-loads | |
d77de738 ML |
20926 | Enable or disable PC-relative literal loads. With this option literal pools are |
20927 | accessed using a single instruction and emitted after each function. This | |
20928 | limits the maximum size of functions to 1MB. This is enabled by default for | |
20929 | @option{-mcmodel=tiny}. | |
20930 | ||
d77de738 | 20931 | @opindex msign-return-address |
ddf6fe37 | 20932 | @item -msign-return-address=@var{scope} |
d77de738 ML |
20933 | Select the function scope on which return address signing will be applied. |
20934 | Permissible values are @samp{none}, which disables return address signing, | |
20935 | @samp{non-leaf}, which enables pointer signing for functions which are not leaf | |
20936 | functions, and @samp{all}, which enables pointer signing for all functions. The | |
20937 | default value is @samp{none}. This option has been deprecated by | |
20938 | -mbranch-protection. | |
20939 | ||
d77de738 | 20940 | @opindex mbranch-protection |
ddf6fe37 | 20941 | @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti} |
d77de738 ML |
20942 | Select the branch protection features to use. |
20943 | @samp{none} is the default and turns off all types of branch protection. | |
20944 | @samp{standard} turns on all types of branch protection features. If a feature | |
20945 | has additional tuning options, then @samp{standard} sets it to its standard | |
20946 | level. | |
20947 | @samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard | |
20948 | level: signing functions that save the return address to memory (non-leaf | |
20949 | functions will practically always do this) using the a-key. The optional | |
20950 | argument @samp{leaf} can be used to extend the signing to include leaf | |
20951 | functions. The optional argument @samp{b-key} can be used to sign the functions | |
20952 | with the B-key instead of the A-key. | |
20953 | @samp{bti} turns on branch target identification mechanism. | |
20954 | ||
d77de738 | 20955 | @opindex mharden-sls |
ddf6fe37 | 20956 | @item -mharden-sls=@var{opts} |
d77de738 ML |
20957 | Enable compiler hardening against straight line speculation (SLS). |
20958 | @var{opts} is a comma-separated list of the following options: | |
20959 | @table @samp | |
20960 | @item retbr | |
20961 | @item blr | |
20962 | @end table | |
20963 | In addition, @samp{-mharden-sls=all} enables all SLS hardening while | |
20964 | @samp{-mharden-sls=none} disables all SLS hardening. | |
20965 | ||
d77de738 | 20966 | @opindex msve-vector-bits |
ddf6fe37 | 20967 | @item -msve-vector-bits=@var{bits} |
d77de738 ML |
20968 | Specify the number of bits in an SVE vector register. This option only has |
20969 | an effect when SVE is enabled. | |
20970 | ||
20971 | GCC supports two forms of SVE code generation: ``vector-length | |
20972 | agnostic'' output that works with any size of vector register and | |
20973 | ``vector-length specific'' output that allows GCC to make assumptions | |
20974 | about the vector length when it is useful for optimization reasons. | |
20975 | The possible values of @samp{bits} are: @samp{scalable}, @samp{128}, | |
20976 | @samp{256}, @samp{512}, @samp{1024} and @samp{2048}. | |
20977 | Specifying @samp{scalable} selects vector-length agnostic | |
20978 | output. At present @samp{-msve-vector-bits=128} also generates vector-length | |
20979 | agnostic output for big-endian targets. All other values generate | |
20980 | vector-length specific code. The behavior of these values may change | |
20981 | in future releases and no value except @samp{scalable} should be | |
20982 | relied on for producing code that is portable across different | |
20983 | hardware SVE vector lengths. | |
20984 | ||
20985 | The default is @samp{-msve-vector-bits=scalable}, which produces | |
20986 | vector-length agnostic code. | |
20987 | @end table | |
20988 | ||
20989 | @subsubsection @option{-march} and @option{-mcpu} Feature Modifiers | |
20990 | @anchor{aarch64-feature-modifiers} | |
20991 | @cindex @option{-march} feature modifiers | |
20992 | @cindex @option{-mcpu} feature modifiers | |
20993 | Feature modifiers used with @option{-march} and @option{-mcpu} can be any of | |
20994 | the following and their inverses @option{no@var{feature}}: | |
20995 | ||
20996 | @table @samp | |
20997 | @item crc | |
20998 | Enable CRC extension. This is on by default for | |
20999 | @option{-march=armv8.1-a}. | |
21000 | @item crypto | |
21001 | Enable Crypto extension. This also enables Advanced SIMD and floating-point | |
21002 | instructions. | |
21003 | @item fp | |
21004 | Enable floating-point instructions. This is on by default for all possible | |
21005 | values for options @option{-march} and @option{-mcpu}. | |
21006 | @item simd | |
21007 | Enable Advanced SIMD instructions. This also enables floating-point | |
21008 | instructions. This is on by default for all possible values for options | |
21009 | @option{-march} and @option{-mcpu}. | |
21010 | @item sve | |
21011 | Enable Scalable Vector Extension instructions. This also enables Advanced | |
21012 | SIMD and floating-point instructions. | |
21013 | @item lse | |
21014 | Enable Large System Extension instructions. This is on by default for | |
21015 | @option{-march=armv8.1-a}. | |
21016 | @item rdma | |
21017 | Enable Round Double Multiply Accumulate instructions. This is on by default | |
21018 | for @option{-march=armv8.1-a}. | |
21019 | @item fp16 | |
21020 | Enable FP16 extension. This also enables floating-point instructions. | |
21021 | @item fp16fml | |
21022 | Enable FP16 fmla extension. This also enables FP16 extensions and | |
21023 | 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. | |
21024 | ||
21025 | @item rcpc | |
0431e8ae AV |
21026 | Enable the RCpc extension. This enables the use of the LDAPR instructions for |
21027 | load-acquire atomic semantics, and passes it on to the assembler, enabling | |
21028 | inline asm statements to use instructions from the RCpc extension. | |
d77de738 ML |
21029 | @item dotprod |
21030 | Enable the Dot Product extension. This also enables Advanced SIMD instructions. | |
21031 | @item aes | |
21032 | Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced | |
21033 | SIMD instructions. | |
21034 | @item sha2 | |
21035 | Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions. | |
21036 | @item sha3 | |
21037 | Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD | |
21038 | instructions. Use of this option with architectures prior to Armv8.2-A is not supported. | |
21039 | @item sm4 | |
21040 | Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions. | |
21041 | Use of this option with architectures prior to Armv8.2-A is not supported. | |
21042 | @item profile | |
21043 | Enable the Statistical Profiling extension. This option is only to enable the | |
21044 | extension at the assembler level and does not affect code generation. | |
21045 | @item rng | |
21046 | Enable the Armv8.5-a Random Number instructions. This option is only to | |
21047 | enable the extension at the assembler level and does not affect code | |
21048 | generation. | |
21049 | @item memtag | |
21050 | Enable the Armv8.5-a Memory Tagging Extensions. | |
21051 | Use of this option with architectures prior to Armv8.5-A is not supported. | |
21052 | @item sb | |
21053 | Enable the Armv8-a Speculation Barrier instruction. This option is only to | |
21054 | enable the extension at the assembler level and does not affect code | |
21055 | generation. This option is enabled by default for @option{-march=armv8.5-a}. | |
21056 | @item ssbs | |
21057 | Enable the Armv8-a Speculative Store Bypass Safe instruction. This option | |
21058 | is only to enable the extension at the assembler level and does not affect code | |
21059 | generation. This option is enabled by default for @option{-march=armv8.5-a}. | |
21060 | @item predres | |
21061 | Enable the Armv8-a Execution and Data Prediction Restriction instructions. | |
21062 | This option is only to enable the extension at the assembler level and does | |
21063 | not affect code generation. This option is enabled by default for | |
21064 | @option{-march=armv8.5-a}. | |
21065 | @item sve2 | |
21066 | Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE | |
21067 | instructions. | |
21068 | @item sve2-bitperm | |
21069 | Enable SVE2 bitperm instructions. This also enables SVE2 instructions. | |
21070 | @item sve2-sm4 | |
21071 | Enable SVE2 sm4 instructions. This also enables SVE2 instructions. | |
21072 | @item sve2-aes | |
21073 | Enable SVE2 aes instructions. This also enables SVE2 instructions. | |
21074 | @item sve2-sha3 | |
21075 | Enable SVE2 sha3 instructions. This also enables SVE2 instructions. | |
21076 | @item tme | |
21077 | Enable the Transactional Memory Extension. | |
21078 | @item i8mm | |
21079 | Enable 8-bit Integer Matrix Multiply instructions. This also enables | |
21080 | Advanced SIMD and floating-point instructions. This option is enabled by | |
21081 | default for @option{-march=armv8.6-a}. Use of this option with architectures | |
21082 | prior to Armv8.2-A is not supported. | |
21083 | @item f32mm | |
21084 | Enable 32-bit Floating point Matrix Multiply instructions. This also enables | |
21085 | SVE instructions. Use of this option with architectures prior to Armv8.2-A is | |
21086 | not supported. | |
21087 | @item f64mm | |
21088 | Enable 64-bit Floating point Matrix Multiply instructions. This also enables | |
21089 | SVE instructions. Use of this option with architectures prior to Armv8.2-A is | |
21090 | not supported. | |
21091 | @item bf16 | |
21092 | Enable brain half-precision floating-point instructions. This also enables | |
21093 | Advanced SIMD and floating-point instructions. This option is enabled by | |
21094 | default for @option{-march=armv8.6-a}. Use of this option with architectures | |
21095 | prior to Armv8.2-A is not supported. | |
21096 | @item ls64 | |
21097 | Enable the 64-byte atomic load and store instructions for accelerators. | |
21098 | This option is enabled by default for @option{-march=armv8.7-a}. | |
21099 | @item mops | |
21100 | Enable the instructions to accelerate memory operations like @code{memcpy}, | |
21101 | @code{memmove}, @code{memset}. This option is enabled by default for | |
21102 | @option{-march=armv8.8-a} | |
21103 | @item flagm | |
21104 | Enable the Flag Manipulation instructions Extension. | |
21105 | @item pauth | |
21106 | Enable the Pointer Authentication Extension. | |
d758d190 KT |
21107 | @item cssc |
21108 | Enable the Common Short Sequence Compression instructions. | |
d77de738 ML |
21109 | |
21110 | @end table | |
21111 | ||
21112 | Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd}, | |
21113 | which implies @option{fp}. | |
21114 | Conversely, @option{nofp} implies @option{nosimd}, which implies | |
21115 | @option{nocrypto}, @option{noaes} and @option{nosha2}. | |
21116 | ||
21117 | @node Adapteva Epiphany Options | |
21118 | @subsection Adapteva Epiphany Options | |
21119 | ||
21120 | These @samp{-m} options are defined for Adapteva Epiphany: | |
21121 | ||
21122 | @table @gcctabopt | |
d77de738 | 21123 | @opindex mhalf-reg-file |
ddf6fe37 | 21124 | @item -mhalf-reg-file |
d77de738 ML |
21125 | Don't allocate any register in the range @code{r32}@dots{}@code{r63}. |
21126 | That allows code to run on hardware variants that lack these registers. | |
21127 | ||
d77de738 | 21128 | @opindex mprefer-short-insn-regs |
ddf6fe37 | 21129 | @item -mprefer-short-insn-regs |
d77de738 ML |
21130 | Preferentially allocate registers that allow short instruction generation. |
21131 | This can result in increased instruction count, so this may either reduce or | |
21132 | increase overall code size. | |
21133 | ||
d77de738 | 21134 | @opindex mbranch-cost |
ddf6fe37 | 21135 | @item -mbranch-cost=@var{num} |
d77de738 ML |
21136 | Set the cost of branches to roughly @var{num} ``simple'' instructions. |
21137 | This cost is only a heuristic and is not guaranteed to produce | |
21138 | consistent results across releases. | |
21139 | ||
d77de738 | 21140 | @opindex mcmove |
ddf6fe37 | 21141 | @item -mcmove |
d77de738 ML |
21142 | Enable the generation of conditional moves. |
21143 | ||
d77de738 | 21144 | @opindex mnops |
ddf6fe37 | 21145 | @item -mnops=@var{num} |
d77de738 ML |
21146 | Emit @var{num} NOPs before every other generated instruction. |
21147 | ||
d77de738 ML |
21148 | @opindex mno-soft-cmpsf |
21149 | @opindex msoft-cmpsf | |
ddf6fe37 | 21150 | @item -mno-soft-cmpsf |
d77de738 ML |
21151 | For single-precision floating-point comparisons, emit an @code{fsub} instruction |
21152 | and test the flags. This is faster than a software comparison, but can | |
21153 | get incorrect results in the presence of NaNs, or when two different small | |
21154 | numbers are compared such that their difference is calculated as zero. | |
21155 | The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant, | |
21156 | software comparisons. | |
21157 | ||
d77de738 | 21158 | @opindex mstack-offset |
ddf6fe37 | 21159 | @item -mstack-offset=@var{num} |
d77de738 ML |
21160 | Set the offset between the top of the stack and the stack pointer. |
21161 | E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7} | |
21162 | can be used by leaf functions without stack allocation. | |
21163 | Values other than @samp{8} or @samp{16} are untested and unlikely to work. | |
21164 | Note also that this option changes the ABI; compiling a program with a | |
21165 | different stack offset than the libraries have been compiled with | |
21166 | generally does not work. | |
21167 | This option can be useful if you want to evaluate if a different stack | |
21168 | offset would give you better code, but to actually use a different stack | |
21169 | offset to build working programs, it is recommended to configure the | |
21170 | toolchain with the appropriate @option{--with-stack-offset=@var{num}} option. | |
21171 | ||
d77de738 ML |
21172 | @opindex mno-round-nearest |
21173 | @opindex mround-nearest | |
ddf6fe37 | 21174 | @item -mno-round-nearest |
d77de738 ML |
21175 | Make the scheduler assume that the rounding mode has been set to |
21176 | truncating. The default is @option{-mround-nearest}. | |
21177 | ||
d77de738 | 21178 | @opindex mlong-calls |
ddf6fe37 | 21179 | @item -mlong-calls |
d77de738 ML |
21180 | If not otherwise specified by an attribute, assume all calls might be beyond |
21181 | the offset range of the @code{b} / @code{bl} instructions, and therefore load the | |
21182 | function address into a register before performing a (otherwise direct) call. | |
21183 | This is the default. | |
21184 | ||
d77de738 | 21185 | @opindex short-calls |
ddf6fe37 | 21186 | @item -mshort-calls |
d77de738 ML |
21187 | If not otherwise specified by an attribute, assume all direct calls are |
21188 | in the range of the @code{b} / @code{bl} instructions, so use these instructions | |
21189 | for direct calls. The default is @option{-mlong-calls}. | |
21190 | ||
d77de738 | 21191 | @opindex msmall16 |
ddf6fe37 | 21192 | @item -msmall16 |
d77de738 ML |
21193 | Assume addresses can be loaded as 16-bit unsigned values. This does not |
21194 | apply to function addresses for which @option{-mlong-calls} semantics | |
21195 | are in effect. | |
21196 | ||
d77de738 | 21197 | @opindex mfp-mode |
ddf6fe37 | 21198 | @item -mfp-mode=@var{mode} |
d77de738 ML |
21199 | Set the prevailing mode of the floating-point unit. |
21200 | This determines the floating-point mode that is provided and expected | |
21201 | at function call and return time. Making this mode match the mode you | |
21202 | predominantly need at function start can make your programs smaller and | |
21203 | faster by avoiding unnecessary mode switches. | |
21204 | ||
21205 | @var{mode} can be set to one the following values: | |
21206 | ||
21207 | @table @samp | |
21208 | @item caller | |
21209 | Any mode at function entry is valid, and retained or restored when | |
21210 | the function returns, and when it calls other functions. | |
21211 | This mode is useful for compiling libraries or other compilation units | |
21212 | you might want to incorporate into different programs with different | |
21213 | prevailing FPU modes, and the convenience of being able to use a single | |
21214 | object file outweighs the size and speed overhead for any extra | |
21215 | mode switching that might be needed, compared with what would be needed | |
21216 | with a more specific choice of prevailing FPU mode. | |
21217 | ||
21218 | @item truncate | |
21219 | This is the mode used for floating-point calculations with | |
21220 | truncating (i.e.@: round towards zero) rounding mode. That includes | |
21221 | conversion from floating point to integer. | |
21222 | ||
21223 | @item round-nearest | |
21224 | This is the mode used for floating-point calculations with | |
21225 | round-to-nearest-or-even rounding mode. | |
21226 | ||
21227 | @item int | |
21228 | This is the mode used to perform integer calculations in the FPU, e.g.@: | |
21229 | integer multiply, or integer multiply-and-accumulate. | |
21230 | @end table | |
21231 | ||
21232 | The default is @option{-mfp-mode=caller} | |
21233 | ||
d77de738 ML |
21234 | @opindex mno-split-lohi |
21235 | @opindex msplit-lohi | |
21236 | @opindex mno-postinc | |
21237 | @opindex mpostinc | |
21238 | @opindex mno-postmodify | |
21239 | @opindex mpostmodify | |
ddf6fe37 AA |
21240 | @item -mno-split-lohi |
21241 | @itemx -mno-postinc | |
21242 | @itemx -mno-postmodify | |
d77de738 ML |
21243 | Code generation tweaks that disable, respectively, splitting of 32-bit |
21244 | loads, generation of post-increment addresses, and generation of | |
21245 | post-modify addresses. The defaults are @option{msplit-lohi}, | |
21246 | @option{-mpost-inc}, and @option{-mpost-modify}. | |
21247 | ||
d77de738 ML |
21248 | @opindex mno-vect-double |
21249 | @opindex mvect-double | |
ddf6fe37 | 21250 | @item -mnovect-double |
d77de738 ML |
21251 | Change the preferred SIMD mode to SImode. The default is |
21252 | @option{-mvect-double}, which uses DImode as preferred SIMD mode. | |
21253 | ||
d77de738 | 21254 | @opindex max-vect-align |
ddf6fe37 | 21255 | @item -max-vect-align=@var{num} |
d77de738 ML |
21256 | The maximum alignment for SIMD vector mode types. |
21257 | @var{num} may be 4 or 8. The default is 8. | |
21258 | Note that this is an ABI change, even though many library function | |
21259 | interfaces are unaffected if they don't use SIMD vector modes | |
21260 | in places that affect size and/or alignment of relevant types. | |
21261 | ||
d77de738 | 21262 | @opindex msplit-vecmove-early |
ddf6fe37 | 21263 | @item -msplit-vecmove-early |
d77de738 ML |
21264 | Split vector moves into single word moves before reload. In theory this |
21265 | can give better register allocation, but so far the reverse seems to be | |
21266 | generally the case. | |
21267 | ||
d77de738 | 21268 | @opindex m1reg- |
ddf6fe37 | 21269 | @item -m1reg-@var{reg} |
d77de738 ML |
21270 | Specify a register to hold the constant @minus{}1, which makes loading small negative |
21271 | constants and certain bitmasks faster. | |
21272 | Allowable values for @var{reg} are @samp{r43} and @samp{r63}, | |
21273 | which specify use of that register as a fixed register, | |
21274 | and @samp{none}, which means that no register is used for this | |
21275 | purpose. The default is @option{-m1reg-none}. | |
21276 | ||
21277 | @end table | |
21278 | ||
21279 | @node AMD GCN Options | |
21280 | @subsection AMD GCN Options | |
21281 | @cindex AMD GCN Options | |
21282 | ||
21283 | These options are defined specifically for the AMD GCN port. | |
21284 | ||
21285 | @table @gcctabopt | |
21286 | ||
d77de738 | 21287 | @opindex march |
d77de738 | 21288 | @opindex mtune |
ddf6fe37 AA |
21289 | @item -march=@var{gpu} |
21290 | @itemx -mtune=@var{gpu} | |
d77de738 ML |
21291 | Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu} |
21292 | are | |
21293 | ||
21294 | @table @samp | |
21295 | @item fiji | |
56ed1055 AS |
21296 | Compile for GCN3 Fiji devices (gfx803). Support deprecated; availablility |
21297 | depends on how GCC has been configured, see @option{--with-arch} and | |
21298 | @option{--with-multilib-list}. | |
d77de738 ML |
21299 | |
21300 | @item gfx900 | |
21301 | Compile for GCN5 Vega 10 devices (gfx900). | |
21302 | ||
21303 | @item gfx906 | |
21304 | Compile for GCN5 Vega 20 devices (gfx906). | |
21305 | ||
21306 | @item gfx908 | |
21307 | Compile for CDNA1 Instinct MI100 series devices (gfx908). | |
21308 | ||
21309 | @item gfx90a | |
21310 | Compile for CDNA2 Instinct MI200 series devices (gfx90a). | |
21311 | ||
21312 | @end table | |
21313 | ||
ddf6fe37 | 21314 | @opindex msram-ecc |
d77de738 ML |
21315 | @item -msram-ecc=on |
21316 | @itemx -msram-ecc=off | |
21317 | @itemx -msram-ecc=any | |
d77de738 ML |
21318 | Compile binaries suitable for devices with the SRAM-ECC feature enabled, |
21319 | disabled, or either mode. This feature can be enabled per-process on some | |
21320 | devices. The compiled code must match the device mode. The default is | |
21321 | @samp{any}, for devices that support it. | |
21322 | ||
d77de738 | 21323 | @opindex mstack-size |
ddf6fe37 | 21324 | @item -mstack-size=@var{bytes} |
d77de738 ML |
21325 | Specify how many @var{bytes} of stack space will be requested for each GPU |
21326 | thread (wave-front). Beware that there may be many threads and limited memory | |
21327 | available. The size of the stack allocation may also have an impact on | |
21328 | run-time performance. The default is 32KB when using OpenACC or OpenMP, and | |
21329 | 1MB otherwise. | |
21330 | ||
d77de738 | 21331 | @opindex mxnack |
366e3d30 TB |
21332 | @item -mxnack=on |
21333 | @itemx -mxnack=off | |
21334 | @itemx -mxnack=any | |
21335 | Compile binaries suitable for devices with the XNACK feature enabled, disabled, | |
21336 | or either mode. Some devices always require XNACK and some allow the user to | |
21337 | configure XNACK. The compiled code must match the device mode. | |
21338 | @c The default is @samp{-mxnack=any}. | |
21339 | At present this option is a placeholder for support that is not yet implemented. | |
d77de738 ML |
21340 | |
21341 | @end table | |
21342 | ||
21343 | @node ARC Options | |
21344 | @subsection ARC Options | |
21345 | @cindex ARC options | |
21346 | ||
21347 | The following options control the architecture variant for which code | |
21348 | is being compiled: | |
21349 | ||
21350 | @c architecture variants | |
21351 | @table @gcctabopt | |
21352 | ||
d77de738 | 21353 | @opindex mbarrel-shifter |
ddf6fe37 | 21354 | @item -mbarrel-shifter |
d77de738 ML |
21355 | Generate instructions supported by barrel shifter. This is the default |
21356 | unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect. | |
21357 | ||
d77de738 | 21358 | @opindex mjli-always |
ddf6fe37 | 21359 | @item -mjli-always |
d77de738 ML |
21360 | Force to call a function using jli_s instruction. This option is |
21361 | valid only for ARCv2 architecture. | |
21362 | ||
d77de738 | 21363 | @opindex mcpu |
ddf6fe37 | 21364 | @item -mcpu=@var{cpu} |
d77de738 ML |
21365 | Set architecture type, register usage, and instruction scheduling |
21366 | parameters for @var{cpu}. There are also shortcut alias options | |
21367 | available for backward compatibility and convenience. Supported | |
21368 | values for @var{cpu} are | |
21369 | ||
21370 | @table @samp | |
21371 | @opindex mA6 | |
21372 | @opindex mARC600 | |
21373 | @item arc600 | |
21374 | Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}. | |
21375 | ||
d77de738 | 21376 | @opindex mARC601 |
ddf6fe37 | 21377 | @item arc601 |
d77de738 ML |
21378 | Compile for ARC601. Alias: @option{-mARC601}. |
21379 | ||
d77de738 ML |
21380 | @opindex mA7 |
21381 | @opindex mARC700 | |
ddf6fe37 | 21382 | @item arc700 |
d77de738 ML |
21383 | Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}. |
21384 | This is the default when configured with @option{--with-cpu=arc700}@. | |
21385 | ||
21386 | @item arcem | |
21387 | Compile for ARC EM. | |
21388 | ||
21389 | @item archs | |
21390 | Compile for ARC HS. | |
21391 | ||
21392 | @item em | |
21393 | Compile for ARC EM CPU with no hardware extensions. | |
21394 | ||
21395 | @item em4 | |
21396 | Compile for ARC EM4 CPU. | |
21397 | ||
21398 | @item em4_dmips | |
21399 | Compile for ARC EM4 DMIPS CPU. | |
21400 | ||
21401 | @item em4_fpus | |
21402 | Compile for ARC EM4 DMIPS CPU with the single-precision floating-point | |
21403 | extension. | |
21404 | ||
21405 | @item em4_fpuda | |
21406 | Compile for ARC EM4 DMIPS CPU with single-precision floating-point and | |
21407 | double assist instructions. | |
21408 | ||
21409 | @item hs | |
21410 | Compile for ARC HS CPU with no hardware extensions except the atomic | |
21411 | instructions. | |
21412 | ||
21413 | @item hs34 | |
21414 | Compile for ARC HS34 CPU. | |
21415 | ||
21416 | @item hs38 | |
21417 | Compile for ARC HS38 CPU. | |
21418 | ||
21419 | @item hs38_linux | |
21420 | Compile for ARC HS38 CPU with all hardware extensions on. | |
21421 | ||
21422 | @item hs4x | |
21423 | Compile for ARC HS4x CPU. | |
21424 | ||
21425 | @item hs4xd | |
21426 | Compile for ARC HS4xD CPU. | |
21427 | ||
21428 | @item hs4x_rel31 | |
21429 | Compile for ARC HS4x CPU release 3.10a. | |
21430 | ||
21431 | @item arc600_norm | |
21432 | Compile for ARC 600 CPU with @code{norm} instructions enabled. | |
21433 | ||
21434 | @item arc600_mul32x16 | |
21435 | Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply | |
21436 | instructions enabled. | |
21437 | ||
21438 | @item arc600_mul64 | |
21439 | Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family | |
21440 | instructions enabled. | |
21441 | ||
21442 | @item arc601_norm | |
21443 | Compile for ARC 601 CPU with @code{norm} instructions enabled. | |
21444 | ||
21445 | @item arc601_mul32x16 | |
21446 | Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply | |
21447 | instructions enabled. | |
21448 | ||
21449 | @item arc601_mul64 | |
21450 | Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family | |
21451 | instructions enabled. | |
21452 | ||
21453 | @item nps400 | |
21454 | Compile for ARC 700 on NPS400 chip. | |
21455 | ||
21456 | @item em_mini | |
21457 | Compile for ARC EM minimalist configuration featuring reduced register | |
21458 | set. | |
21459 | ||
21460 | @end table | |
21461 | ||
d77de738 | 21462 | @opindex mdpfp |
d77de738 | 21463 | @opindex mdpfp-compact |
ddf6fe37 AA |
21464 | @item -mdpfp |
21465 | @itemx -mdpfp-compact | |
d77de738 ML |
21466 | Generate double-precision FPX instructions, tuned for the compact |
21467 | implementation. | |
21468 | ||
d77de738 | 21469 | @opindex mdpfp-fast |
ddf6fe37 | 21470 | @item -mdpfp-fast |
d77de738 ML |
21471 | Generate double-precision FPX instructions, tuned for the fast |
21472 | implementation. | |
21473 | ||
d77de738 | 21474 | @opindex mno-dpfp-lrsr |
ddf6fe37 | 21475 | @item -mno-dpfp-lrsr |
d77de738 ML |
21476 | Disable @code{lr} and @code{sr} instructions from using FPX extension |
21477 | aux registers. | |
21478 | ||
d77de738 | 21479 | @opindex mea |
ddf6fe37 | 21480 | @item -mea |
d77de738 ML |
21481 | Generate extended arithmetic instructions. Currently only |
21482 | @code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are | |
21483 | supported. Only valid for @option{-mcpu=ARC700}. | |
21484 | ||
d77de738 ML |
21485 | @opindex mno-mpy |
21486 | @opindex mmpy | |
ddf6fe37 | 21487 | @item -mno-mpy |
d77de738 ML |
21488 | Do not generate @code{mpy}-family instructions for ARC700. This option is |
21489 | deprecated. | |
21490 | ||
d77de738 | 21491 | @opindex mmul32x16 |
ddf6fe37 | 21492 | @item -mmul32x16 |
d77de738 ML |
21493 | Generate 32x16-bit multiply and multiply-accumulate instructions. |
21494 | ||
d77de738 | 21495 | @opindex mmul64 |
ddf6fe37 | 21496 | @item -mmul64 |
d77de738 ML |
21497 | Generate @code{mul64} and @code{mulu64} instructions. |
21498 | Only valid for @option{-mcpu=ARC600}. | |
21499 | ||
d77de738 | 21500 | @opindex mnorm |
ddf6fe37 | 21501 | @item -mnorm |
d77de738 ML |
21502 | Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700} |
21503 | is in effect. | |
21504 | ||
d77de738 | 21505 | @opindex mspfp |
d77de738 | 21506 | @opindex mspfp-compact |
ddf6fe37 AA |
21507 | @item -mspfp |
21508 | @itemx -mspfp-compact | |
d77de738 ML |
21509 | Generate single-precision FPX instructions, tuned for the compact |
21510 | implementation. | |
21511 | ||
d77de738 | 21512 | @opindex mspfp-fast |
ddf6fe37 | 21513 | @item -mspfp-fast |
d77de738 ML |
21514 | Generate single-precision FPX instructions, tuned for the fast |
21515 | implementation. | |
21516 | ||
d77de738 | 21517 | @opindex msimd |
ddf6fe37 | 21518 | @item -msimd |
d77de738 ML |
21519 | Enable generation of ARC SIMD instructions via target-specific |
21520 | builtins. Only valid for @option{-mcpu=ARC700}. | |
21521 | ||
d77de738 | 21522 | @opindex msoft-float |
ddf6fe37 | 21523 | @item -msoft-float |
d77de738 ML |
21524 | This option ignored; it is provided for compatibility purposes only. |
21525 | Software floating-point code is emitted by default, and this default | |
21526 | can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or | |
21527 | @option{-mspfp-fast} for single precision, and @option{-mdpfp}, | |
21528 | @option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision. | |
21529 | ||
d77de738 | 21530 | @opindex mswap |
ddf6fe37 | 21531 | @item -mswap |
d77de738 ML |
21532 | Generate @code{swap} instructions. |
21533 | ||
d77de738 | 21534 | @opindex matomic |
ddf6fe37 | 21535 | @item -matomic |
d77de738 ML |
21536 | This enables use of the locked load/store conditional extension to implement |
21537 | atomic memory built-in functions. Not available for ARC 6xx or ARC | |
21538 | EM cores. | |
21539 | ||
d77de738 | 21540 | @opindex mdiv-rem |
ddf6fe37 | 21541 | @item -mdiv-rem |
d77de738 ML |
21542 | Enable @code{div} and @code{rem} instructions for ARCv2 cores. |
21543 | ||
d77de738 | 21544 | @opindex mcode-density |
ddf6fe37 | 21545 | @item -mcode-density |
d77de738 ML |
21546 | Enable code density instructions for ARC EM. |
21547 | This option is on by default for ARC HS. | |
21548 | ||
d77de738 | 21549 | @opindex mll64 |
ddf6fe37 | 21550 | @item -mll64 |
d77de738 ML |
21551 | Enable double load/store operations for ARC HS cores. |
21552 | ||
d77de738 | 21553 | @opindex mtp-regno |
ddf6fe37 | 21554 | @item -mtp-regno=@var{regno} |
d77de738 ML |
21555 | Specify thread pointer register number. |
21556 | ||
d77de738 | 21557 | @opindex mmpy-option |
ddf6fe37 | 21558 | @item -mmpy-option=@var{multo} |
d77de738 ML |
21559 | Compile ARCv2 code with a multiplier design option. You can specify |
21560 | the option using either a string or numeric value for @var{multo}. | |
21561 | @samp{wlh1} is the default value. The recognized values are: | |
21562 | ||
21563 | @table @samp | |
21564 | @item 0 | |
21565 | @itemx none | |
21566 | No multiplier available. | |
21567 | ||
21568 | @item 1 | |
21569 | @itemx w | |
21570 | 16x16 multiplier, fully pipelined. | |
21571 | The following instructions are enabled: @code{mpyw} and @code{mpyuw}. | |
21572 | ||
21573 | @item 2 | |
21574 | @itemx wlh1 | |
21575 | 32x32 multiplier, fully | |
21576 | pipelined (1 stage). The following instructions are additionally | |
21577 | enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21578 | ||
21579 | @item 3 | |
21580 | @itemx wlh2 | |
21581 | 32x32 multiplier, fully pipelined | |
21582 | (2 stages). The following instructions are additionally enabled: @code{mpy}, | |
21583 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21584 | ||
21585 | @item 4 | |
21586 | @itemx wlh3 | |
21587 | Two 16x16 multipliers, blocking, | |
21588 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21589 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21590 | ||
21591 | @item 5 | |
21592 | @itemx wlh4 | |
21593 | One 16x16 multiplier, blocking, | |
21594 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21595 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21596 | ||
21597 | @item 6 | |
21598 | @itemx wlh5 | |
21599 | One 32x4 multiplier, blocking, | |
21600 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21601 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21602 | ||
21603 | @item 7 | |
21604 | @itemx plus_dmpy | |
21605 | ARC HS SIMD support. | |
21606 | ||
21607 | @item 8 | |
21608 | @itemx plus_macd | |
21609 | ARC HS SIMD support. | |
21610 | ||
21611 | @item 9 | |
21612 | @itemx plus_qmacw | |
21613 | ARC HS SIMD support. | |
21614 | ||
21615 | @end table | |
21616 | ||
21617 | This option is only available for ARCv2 cores@. | |
21618 | ||
d77de738 | 21619 | @opindex mfpu |
ddf6fe37 | 21620 | @item -mfpu=@var{fpu} |
d77de738 ML |
21621 | Enables support for specific floating-point hardware extensions for ARCv2 |
21622 | cores. Supported values for @var{fpu} are: | |
21623 | ||
21624 | @table @samp | |
21625 | ||
21626 | @item fpus | |
21627 | Enables support for single-precision floating-point hardware | |
21628 | extensions@. | |
21629 | ||
21630 | @item fpud | |
21631 | Enables support for double-precision floating-point hardware | |
21632 | extensions. The single-precision floating-point extension is also | |
21633 | enabled. Not available for ARC EM@. | |
21634 | ||
21635 | @item fpuda | |
21636 | Enables support for double-precision floating-point hardware | |
21637 | extensions using double-precision assist instructions. The single-precision | |
21638 | floating-point extension is also enabled. This option is | |
21639 | only available for ARC EM@. | |
21640 | ||
21641 | @item fpuda_div | |
21642 | Enables support for double-precision floating-point hardware | |
21643 | extensions using double-precision assist instructions. | |
21644 | The single-precision floating-point, square-root, and divide | |
21645 | extensions are also enabled. This option is | |
21646 | only available for ARC EM@. | |
21647 | ||
21648 | @item fpuda_fma | |
21649 | Enables support for double-precision floating-point hardware | |
21650 | extensions using double-precision assist instructions. | |
21651 | The single-precision floating-point and fused multiply and add | |
21652 | hardware extensions are also enabled. This option is | |
21653 | only available for ARC EM@. | |
21654 | ||
21655 | @item fpuda_all | |
21656 | Enables support for double-precision floating-point hardware | |
21657 | extensions using double-precision assist instructions. | |
21658 | All single-precision floating-point hardware extensions are also | |
21659 | enabled. This option is only available for ARC EM@. | |
21660 | ||
21661 | @item fpus_div | |
21662 | Enables support for single-precision floating-point, square-root and divide | |
21663 | hardware extensions@. | |
21664 | ||
21665 | @item fpud_div | |
21666 | Enables support for double-precision floating-point, square-root and divide | |
21667 | hardware extensions. This option | |
21668 | includes option @samp{fpus_div}. Not available for ARC EM@. | |
21669 | ||
21670 | @item fpus_fma | |
21671 | Enables support for single-precision floating-point and | |
21672 | fused multiply and add hardware extensions@. | |
21673 | ||
21674 | @item fpud_fma | |
21675 | Enables support for double-precision floating-point and | |
21676 | fused multiply and add hardware extensions. This option | |
21677 | includes option @samp{fpus_fma}. Not available for ARC EM@. | |
21678 | ||
21679 | @item fpus_all | |
21680 | Enables support for all single-precision floating-point hardware | |
21681 | extensions@. | |
21682 | ||
21683 | @item fpud_all | |
21684 | Enables support for all single- and double-precision floating-point | |
21685 | hardware extensions. Not available for ARC EM@. | |
21686 | ||
21687 | @end table | |
21688 | ||
d77de738 | 21689 | @opindex mirq-ctrl-saved |
ddf6fe37 | 21690 | @item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count} |
d77de738 ML |
21691 | Specifies general-purposes registers that the processor automatically |
21692 | saves/restores on interrupt entry and exit. @var{register-range} is | |
21693 | specified as two registers separated by a dash. The register range | |
21694 | always starts with @code{r0}, the upper limit is @code{fp} register. | |
21695 | @var{blink} and @var{lp_count} are optional. This option is only | |
21696 | valid for ARC EM and ARC HS cores. | |
21697 | ||
d77de738 | 21698 | @opindex mrgf-banked-regs |
ddf6fe37 | 21699 | @item -mrgf-banked-regs=@var{number} |
d77de738 ML |
21700 | Specifies the number of registers replicated in second register bank |
21701 | on entry to fast interrupt. Fast interrupts are interrupts with the | |
21702 | highest priority level P0. These interrupts save only PC and STATUS32 | |
21703 | registers to avoid memory transactions during interrupt entry and exit | |
21704 | sequences. Use this option when you are using fast interrupts in an | |
21705 | ARC V2 family processor. Permitted values are 4, 8, 16, and 32. | |
21706 | ||
d77de738 | 21707 | @opindex mlpc-width |
ddf6fe37 | 21708 | @item -mlpc-width=@var{width} |
d77de738 ML |
21709 | Specify the width of the @code{lp_count} register. Valid values for |
21710 | @var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is | |
21711 | fixed to 32 bits. If the width is less than 32, the compiler does not | |
21712 | attempt to transform loops in your program to use the zero-delay loop | |
21713 | mechanism unless it is known that the @code{lp_count} register can | |
21714 | hold the required loop-counter value. Depending on the width | |
21715 | specified, the compiler and run-time library might continue to use the | |
21716 | loop mechanism for various needs. This option defines macro | |
21717 | @code{__ARC_LPC_WIDTH__} with the value of @var{width}. | |
21718 | ||
d77de738 | 21719 | @opindex mrf16 |
ddf6fe37 | 21720 | @item -mrf16 |
d77de738 ML |
21721 | This option instructs the compiler to generate code for a 16-entry |
21722 | register file. This option defines the @code{__ARC_RF16__} | |
21723 | preprocessor macro. | |
21724 | ||
d77de738 | 21725 | @opindex mbranch-index |
ddf6fe37 | 21726 | @item -mbranch-index |
d77de738 ML |
21727 | Enable use of @code{bi} or @code{bih} instructions to implement jump |
21728 | tables. | |
21729 | ||
21730 | @end table | |
21731 | ||
21732 | The following options are passed through to the assembler, and also | |
21733 | define preprocessor macro symbols. | |
21734 | ||
21735 | @c Flags used by the assembler, but for which we define preprocessor | |
21736 | @c macro symbols as well. | |
21737 | @table @gcctabopt | |
d77de738 | 21738 | @opindex mdsp-packa |
ddf6fe37 | 21739 | @item -mdsp-packa |
d77de738 ML |
21740 | Passed down to the assembler to enable the DSP Pack A extensions. |
21741 | Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is | |
21742 | deprecated. | |
21743 | ||
d77de738 | 21744 | @opindex mdvbf |
ddf6fe37 | 21745 | @item -mdvbf |
d77de738 ML |
21746 | Passed down to the assembler to enable the dual Viterbi butterfly |
21747 | extension. Also sets the preprocessor symbol @code{__Xdvbf}. This | |
21748 | option is deprecated. | |
21749 | ||
21750 | @c ARC700 4.10 extension instruction | |
d77de738 | 21751 | @opindex mlock |
ddf6fe37 | 21752 | @item -mlock |
d77de738 ML |
21753 | Passed down to the assembler to enable the locked load/store |
21754 | conditional extension. Also sets the preprocessor symbol | |
21755 | @code{__Xlock}. | |
21756 | ||
d77de738 | 21757 | @opindex mmac-d16 |
ddf6fe37 | 21758 | @item -mmac-d16 |
d77de738 ML |
21759 | Passed down to the assembler. Also sets the preprocessor symbol |
21760 | @code{__Xxmac_d16}. This option is deprecated. | |
21761 | ||
d77de738 | 21762 | @opindex mmac-24 |
ddf6fe37 | 21763 | @item -mmac-24 |
d77de738 ML |
21764 | Passed down to the assembler. Also sets the preprocessor symbol |
21765 | @code{__Xxmac_24}. This option is deprecated. | |
21766 | ||
21767 | @c ARC700 4.10 extension instruction | |
d77de738 | 21768 | @opindex mrtsc |
ddf6fe37 | 21769 | @item -mrtsc |
d77de738 ML |
21770 | Passed down to the assembler to enable the 64-bit time-stamp counter |
21771 | extension instruction. Also sets the preprocessor symbol | |
21772 | @code{__Xrtsc}. This option is deprecated. | |
21773 | ||
21774 | @c ARC700 4.10 extension instruction | |
d77de738 | 21775 | @opindex mswape |
ddf6fe37 | 21776 | @item -mswape |
d77de738 ML |
21777 | Passed down to the assembler to enable the swap byte ordering |
21778 | extension instruction. Also sets the preprocessor symbol | |
21779 | @code{__Xswape}. | |
21780 | ||
d77de738 | 21781 | @opindex mtelephony |
ddf6fe37 | 21782 | @item -mtelephony |
d77de738 ML |
21783 | Passed down to the assembler to enable dual- and single-operand |
21784 | instructions for telephony. Also sets the preprocessor symbol | |
21785 | @code{__Xtelephony}. This option is deprecated. | |
21786 | ||
d77de738 | 21787 | @opindex mxy |
ddf6fe37 | 21788 | @item -mxy |
d77de738 ML |
21789 | Passed down to the assembler to enable the XY memory extension. Also |
21790 | sets the preprocessor symbol @code{__Xxy}. | |
21791 | ||
21792 | @end table | |
21793 | ||
21794 | The following options control how the assembly code is annotated: | |
21795 | ||
21796 | @c Assembly annotation options | |
21797 | @table @gcctabopt | |
d77de738 | 21798 | @opindex misize |
ddf6fe37 | 21799 | @item -misize |
d77de738 ML |
21800 | Annotate assembler instructions with estimated addresses. |
21801 | ||
d77de738 | 21802 | @opindex mannotate-align |
ddf6fe37 | 21803 | @item -mannotate-align |
e4b19406 | 21804 | Does nothing. Preserved for backward compatibility. |
d77de738 ML |
21805 | |
21806 | @end table | |
21807 | ||
21808 | The following options are passed through to the linker: | |
21809 | ||
21810 | @c options passed through to the linker | |
21811 | @table @gcctabopt | |
d77de738 | 21812 | @opindex marclinux |
ddf6fe37 | 21813 | @item -marclinux |
d77de738 ML |
21814 | Passed through to the linker, to specify use of the @code{arclinux} emulation. |
21815 | This option is enabled by default in tool chains built for | |
21816 | @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets | |
21817 | when profiling is not requested. | |
21818 | ||
d77de738 | 21819 | @opindex marclinux_prof |
ddf6fe37 | 21820 | @item -marclinux_prof |
d77de738 ML |
21821 | Passed through to the linker, to specify use of the |
21822 | @code{arclinux_prof} emulation. This option is enabled by default in | |
21823 | tool chains built for @w{@code{arc-linux-uclibc}} and | |
21824 | @w{@code{arceb-linux-uclibc}} targets when profiling is requested. | |
21825 | ||
21826 | @end table | |
21827 | ||
21828 | The following options control the semantics of generated code: | |
21829 | ||
21830 | @c semantically relevant code generation options | |
21831 | @table @gcctabopt | |
d77de738 | 21832 | @opindex mlong-calls |
ddf6fe37 | 21833 | @item -mlong-calls |
d77de738 ML |
21834 | Generate calls as register indirect calls, thus providing access |
21835 | to the full 32-bit address range. | |
21836 | ||
d77de738 | 21837 | @opindex mmedium-calls |
ddf6fe37 | 21838 | @item -mmedium-calls |
d77de738 ML |
21839 | Don't use less than 25-bit addressing range for calls, which is the |
21840 | offset available for an unconditional branch-and-link | |
21841 | instruction. Conditional execution of function calls is suppressed, to | |
21842 | allow use of the 25-bit range, rather than the 21-bit range with | |
21843 | conditional branch-and-link. This is the default for tool chains built | |
21844 | for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets. | |
21845 | ||
d77de738 | 21846 | @opindex G |
ddf6fe37 | 21847 | @item -G @var{num} |
d77de738 ML |
21848 | Put definitions of externally-visible data in a small data section if |
21849 | that data is no bigger than @var{num} bytes. The default value of | |
21850 | @var{num} is 4 for any ARC configuration, or 8 when we have double | |
21851 | load/store operations. | |
21852 | ||
d77de738 ML |
21853 | @opindex mno-sdata |
21854 | @opindex msdata | |
ddf6fe37 | 21855 | @item -mno-sdata |
d77de738 ML |
21856 | Do not generate sdata references. This is the default for tool chains |
21857 | built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} | |
21858 | targets. | |
21859 | ||
d77de738 | 21860 | @opindex mvolatile-cache |
ddf6fe37 | 21861 | @item -mvolatile-cache |
d77de738 ML |
21862 | Use ordinarily cached memory accesses for volatile references. This is the |
21863 | default. | |
21864 | ||
d77de738 ML |
21865 | @opindex mno-volatile-cache |
21866 | @opindex mvolatile-cache | |
ddf6fe37 | 21867 | @item -mno-volatile-cache |
d77de738 ML |
21868 | Enable cache bypass for volatile references. |
21869 | ||
21870 | @end table | |
21871 | ||
21872 | The following options fine tune code generation: | |
21873 | @c code generation tuning options | |
21874 | @table @gcctabopt | |
d77de738 | 21875 | @opindex malign-call |
ddf6fe37 | 21876 | @item -malign-call |
d77de738 ML |
21877 | Does nothing. Preserved for backward compatibility. |
21878 | ||
d77de738 | 21879 | @opindex mauto-modify-reg |
ddf6fe37 | 21880 | @item -mauto-modify-reg |
d77de738 ML |
21881 | Enable the use of pre/post modify with register displacement. |
21882 | ||
d77de738 | 21883 | @opindex mbbit-peephole |
ddf6fe37 | 21884 | @item -mbbit-peephole |
07f7615c | 21885 | Does nothing. Preserved for backward compatibility. |
d77de738 | 21886 | |
d77de738 | 21887 | @opindex mno-brcc |
ddf6fe37 | 21888 | @item -mno-brcc |
d77de738 ML |
21889 | This option disables a target-specific pass in @file{arc_reorg} to |
21890 | generate compare-and-branch (@code{br@var{cc}}) instructions. | |
21891 | It has no effect on | |
21892 | generation of these instructions driven by the combiner pass. | |
21893 | ||
d77de738 | 21894 | @opindex mcase-vector-pcrel |
ddf6fe37 | 21895 | @item -mcase-vector-pcrel |
d77de738 ML |
21896 | Use PC-relative switch case tables to enable case table shortening. |
21897 | This is the default for @option{-Os}. | |
21898 | ||
d77de738 | 21899 | @opindex mcompact-casesi |
ddf6fe37 | 21900 | @item -mcompact-casesi |
d77de738 ML |
21901 | Enable compact @code{casesi} pattern. This is the default for @option{-Os}, |
21902 | and only available for ARCv1 cores. This option is deprecated. | |
21903 | ||
d77de738 | 21904 | @opindex mno-cond-exec |
ddf6fe37 | 21905 | @item -mno-cond-exec |
d77de738 ML |
21906 | Disable the ARCompact-specific pass to generate conditional |
21907 | execution instructions. | |
21908 | ||
21909 | Due to delay slot scheduling and interactions between operand numbers, | |
21910 | literal sizes, instruction lengths, and the support for conditional execution, | |
21911 | the target-independent pass to generate conditional execution is often lacking, | |
21912 | so the ARC port has kept a special pass around that tries to find more | |
21913 | conditional execution generation opportunities after register allocation, | |
21914 | branch shortening, and delay slot scheduling have been done. This pass | |
21915 | generally, but not always, improves performance and code size, at the cost of | |
21916 | extra compilation time, which is why there is an option to switch it off. | |
21917 | If you have a problem with call instructions exceeding their allowable | |
21918 | offset range because they are conditionalized, you should consider using | |
21919 | @option{-mmedium-calls} instead. | |
21920 | ||
d77de738 | 21921 | @opindex mearly-cbranchsi |
ddf6fe37 | 21922 | @item -mearly-cbranchsi |
d77de738 ML |
21923 | Enable pre-reload use of the @code{cbranchsi} pattern. |
21924 | ||
d77de738 | 21925 | @opindex mexpand-adddi |
ddf6fe37 | 21926 | @item -mexpand-adddi |
d77de738 ML |
21927 | Expand @code{adddi3} and @code{subdi3} at RTL generation time into |
21928 | @code{add.f}, @code{adc} etc. This option is deprecated. | |
21929 | ||
d77de738 | 21930 | @opindex mindexed-loads |
ddf6fe37 | 21931 | @item -mindexed-loads |
d77de738 ML |
21932 | Enable the use of indexed loads. This can be problematic because some |
21933 | optimizers then assume that indexed stores exist, which is not | |
21934 | the case. | |
21935 | ||
d77de738 | 21936 | @opindex mlra |
ddf6fe37 | 21937 | @item -mlra |
d77de738 ML |
21938 | Enable Local Register Allocation. This is still experimental for ARC, |
21939 | so by default the compiler uses standard reload | |
21940 | (i.e.@: @option{-mno-lra}). | |
21941 | ||
d77de738 | 21942 | @opindex mlra-priority-none |
ddf6fe37 | 21943 | @item -mlra-priority-none |
d77de738 ML |
21944 | Don't indicate any priority for target registers. |
21945 | ||
d77de738 | 21946 | @opindex mlra-priority-compact |
ddf6fe37 | 21947 | @item -mlra-priority-compact |
d77de738 ML |
21948 | Indicate target register priority for r0..r3 / r12..r15. |
21949 | ||
d77de738 | 21950 | @opindex mlra-priority-noncompact |
ddf6fe37 | 21951 | @item -mlra-priority-noncompact |
d77de738 ML |
21952 | Reduce target register priority for r0..r3 / r12..r15. |
21953 | ||
d77de738 | 21954 | @opindex mmillicode |
ddf6fe37 | 21955 | @item -mmillicode |
d77de738 ML |
21956 | When optimizing for size (using @option{-Os}), prologues and epilogues |
21957 | that have to save or restore a large number of registers are often | |
21958 | shortened by using call to a special function in libgcc; this is | |
21959 | referred to as a @emph{millicode} call. As these calls can pose | |
21960 | performance issues, and/or cause linking issues when linking in a | |
21961 | nonstandard way, this option is provided to turn on or off millicode | |
21962 | call generation. | |
21963 | ||
d77de738 | 21964 | @opindex mcode-density-frame |
ddf6fe37 | 21965 | @item -mcode-density-frame |
d77de738 ML |
21966 | This option enable the compiler to emit @code{enter} and @code{leave} |
21967 | instructions. These instructions are only valid for CPUs with | |
21968 | code-density feature. | |
21969 | ||
d77de738 | 21970 | @opindex mmixed-code |
ddf6fe37 | 21971 | @item -mmixed-code |
d77de738 ML |
21972 | Does nothing. Preserved for backward compatibility. |
21973 | ||
d77de738 | 21974 | @opindex mq-class |
ddf6fe37 | 21975 | @item -mq-class |
d77de738 ML |
21976 | Ths option is deprecated. Enable @samp{q} instruction alternatives. |
21977 | This is the default for @option{-Os}. | |
21978 | ||
d77de738 | 21979 | @opindex mRcq |
ddf6fe37 | 21980 | @item -mRcq |
d77de738 ML |
21981 | Does nothing. Preserved for backward compatibility. |
21982 | ||
d77de738 | 21983 | @opindex mRcw |
ddf6fe37 | 21984 | @item -mRcw |
d77de738 ML |
21985 | Does nothing. Preserved for backward compatibility. |
21986 | ||
d77de738 | 21987 | @opindex msize-level |
ddf6fe37 | 21988 | @item -msize-level=@var{level} |
d77de738 ML |
21989 | Fine-tune size optimization with regards to instruction lengths and alignment. |
21990 | The recognized values for @var{level} are: | |
21991 | @table @samp | |
21992 | @item 0 | |
21993 | No size optimization. This level is deprecated and treated like @samp{1}. | |
21994 | ||
21995 | @item 1 | |
21996 | Short instructions are used opportunistically. | |
21997 | ||
21998 | @item 2 | |
21999 | In addition, alignment of loops and of code after barriers are dropped. | |
22000 | ||
22001 | @item 3 | |
22002 | In addition, optional data alignment is dropped, and the option @option{Os} is enabled. | |
22003 | ||
22004 | @end table | |
22005 | ||
22006 | This defaults to @samp{3} when @option{-Os} is in effect. Otherwise, | |
22007 | the behavior when this is not set is equivalent to level @samp{1}. | |
22008 | ||
d77de738 | 22009 | @opindex mtune |
ddf6fe37 | 22010 | @item -mtune=@var{cpu} |
d77de738 ML |
22011 | Set instruction scheduling parameters for @var{cpu}, overriding any implied |
22012 | by @option{-mcpu=}. | |
22013 | ||
22014 | Supported values for @var{cpu} are | |
22015 | ||
22016 | @table @samp | |
22017 | @item ARC600 | |
22018 | Tune for ARC600 CPU. | |
22019 | ||
22020 | @item ARC601 | |
22021 | Tune for ARC601 CPU. | |
22022 | ||
22023 | @item ARC700 | |
22024 | Tune for ARC700 CPU with standard multiplier block. | |
22025 | ||
22026 | @item ARC700-xmac | |
22027 | Tune for ARC700 CPU with XMAC block. | |
22028 | ||
22029 | @item ARC725D | |
22030 | Tune for ARC725D CPU. | |
22031 | ||
22032 | @item ARC750D | |
22033 | Tune for ARC750D CPU. | |
22034 | ||
22035 | @item core3 | |
22036 | Tune for ARCv2 core3 type CPU. This option enable usage of | |
22037 | @code{dbnz} instruction. | |
22038 | ||
22039 | @item release31a | |
22040 | Tune for ARC4x release 3.10a. | |
22041 | ||
22042 | @end table | |
22043 | ||
d77de738 | 22044 | @opindex mmultcost |
ddf6fe37 | 22045 | @item -mmultcost=@var{num} |
d77de738 ML |
22046 | Cost to assume for a multiply instruction, with @samp{4} being equal to a |
22047 | normal instruction. | |
22048 | ||
d77de738 | 22049 | @opindex munalign-prob-threshold |
ddf6fe37 | 22050 | @item -munalign-prob-threshold=@var{probability} |
d77de738 ML |
22051 | Does nothing. Preserved for backward compatibility. |
22052 | ||
22053 | @end table | |
22054 | ||
22055 | The following options are maintained for backward compatibility, but | |
22056 | are now deprecated and will be removed in a future release: | |
22057 | ||
22058 | @c Deprecated options | |
22059 | @table @gcctabopt | |
22060 | ||
d77de738 | 22061 | @opindex margonaut |
ddf6fe37 | 22062 | @item -margonaut |
d77de738 ML |
22063 | Obsolete FPX. |
22064 | ||
d77de738 | 22065 | @opindex mbig-endian |
d77de738 | 22066 | @opindex EB |
ddf6fe37 AA |
22067 | @item -mbig-endian |
22068 | @itemx -EB | |
d77de738 ML |
22069 | Compile code for big-endian targets. Use of these options is now |
22070 | deprecated. Big-endian code is supported by configuring GCC to build | |
22071 | @w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets, | |
22072 | for which big endian is the default. | |
22073 | ||
d77de738 | 22074 | @opindex mlittle-endian |
d77de738 | 22075 | @opindex EL |
ddf6fe37 AA |
22076 | @item -mlittle-endian |
22077 | @itemx -EL | |
d77de738 ML |
22078 | Compile code for little-endian targets. Use of these options is now |
22079 | deprecated. Little-endian code is supported by configuring GCC to build | |
22080 | @w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets, | |
22081 | for which little endian is the default. | |
22082 | ||
d77de738 | 22083 | @opindex mbarrel_shifter |
ddf6fe37 | 22084 | @item -mbarrel_shifter |
d77de738 ML |
22085 | Replaced by @option{-mbarrel-shifter}. |
22086 | ||
d77de738 | 22087 | @opindex mdpfp_compact |
ddf6fe37 | 22088 | @item -mdpfp_compact |
d77de738 ML |
22089 | Replaced by @option{-mdpfp-compact}. |
22090 | ||
d77de738 | 22091 | @opindex mdpfp_fast |
ddf6fe37 | 22092 | @item -mdpfp_fast |
d77de738 ML |
22093 | Replaced by @option{-mdpfp-fast}. |
22094 | ||
d77de738 | 22095 | @opindex mdsp_packa |
ddf6fe37 | 22096 | @item -mdsp_packa |
d77de738 ML |
22097 | Replaced by @option{-mdsp-packa}. |
22098 | ||
d77de738 | 22099 | @opindex mEA |
ddf6fe37 | 22100 | @item -mEA |
d77de738 ML |
22101 | Replaced by @option{-mea}. |
22102 | ||
d77de738 | 22103 | @opindex mmac_24 |
ddf6fe37 | 22104 | @item -mmac_24 |
d77de738 ML |
22105 | Replaced by @option{-mmac-24}. |
22106 | ||
d77de738 | 22107 | @opindex mmac_d16 |
ddf6fe37 | 22108 | @item -mmac_d16 |
d77de738 ML |
22109 | Replaced by @option{-mmac-d16}. |
22110 | ||
d77de738 | 22111 | @opindex mspfp_compact |
ddf6fe37 | 22112 | @item -mspfp_compact |
d77de738 ML |
22113 | Replaced by @option{-mspfp-compact}. |
22114 | ||
d77de738 | 22115 | @opindex mspfp_fast |
ddf6fe37 | 22116 | @item -mspfp_fast |
d77de738 ML |
22117 | Replaced by @option{-mspfp-fast}. |
22118 | ||
d77de738 | 22119 | @opindex mtune |
ddf6fe37 | 22120 | @item -mtune=@var{cpu} |
d77de738 ML |
22121 | Values @samp{arc600}, @samp{arc601}, @samp{arc700} and |
22122 | @samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600}, | |
22123 | @samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively. | |
22124 | ||
d77de738 | 22125 | @opindex multcost |
ddf6fe37 | 22126 | @item -multcost=@var{num} |
d77de738 ML |
22127 | Replaced by @option{-mmultcost}. |
22128 | ||
22129 | @end table | |
22130 | ||
22131 | @node ARM Options | |
22132 | @subsection ARM Options | |
22133 | @cindex ARM options | |
22134 | ||
22135 | These @samp{-m} options are defined for the ARM port: | |
22136 | ||
22137 | @table @gcctabopt | |
d77de738 | 22138 | @opindex mabi |
ddf6fe37 | 22139 | @item -mabi=@var{name} |
d77de738 ML |
22140 | Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu}, |
22141 | @samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}. | |
22142 | ||
d77de738 | 22143 | @opindex mapcs-frame |
ddf6fe37 | 22144 | @item -mapcs-frame |
d77de738 ML |
22145 | Generate a stack frame that is compliant with the ARM Procedure Call |
22146 | Standard for all functions, even if this is not strictly necessary for | |
22147 | correct execution of the code. Specifying @option{-fomit-frame-pointer} | |
22148 | with this option causes the stack frames not to be generated for | |
22149 | leaf functions. The default is @option{-mno-apcs-frame}. | |
22150 | This option is deprecated. | |
22151 | ||
d77de738 | 22152 | @opindex mapcs |
ddf6fe37 | 22153 | @item -mapcs |
d77de738 ML |
22154 | This is a synonym for @option{-mapcs-frame} and is deprecated. |
22155 | ||
22156 | @ignore | |
22157 | @c not currently implemented | |
d77de738 | 22158 | @opindex mapcs-stack-check |
ddf6fe37 | 22159 | @item -mapcs-stack-check |
d77de738 ML |
22160 | Generate code to check the amount of stack space available upon entry to |
22161 | every function (that actually uses some stack space). If there is | |
22162 | insufficient space available then either the function | |
22163 | @code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is | |
22164 | called, depending upon the amount of stack space required. The runtime | |
22165 | system is required to provide these functions. The default is | |
22166 | @option{-mno-apcs-stack-check}, since this produces smaller code. | |
22167 | ||
22168 | @c not currently implemented | |
d77de738 | 22169 | @opindex mapcs-reentrant |
ddf6fe37 | 22170 | @item -mapcs-reentrant |
d77de738 ML |
22171 | Generate reentrant, position-independent code. The default is |
22172 | @option{-mno-apcs-reentrant}. | |
22173 | @end ignore | |
22174 | ||
d77de738 | 22175 | @opindex mthumb-interwork |
ddf6fe37 | 22176 | @item -mthumb-interwork |
d77de738 ML |
22177 | Generate code that supports calling between the ARM and Thumb |
22178 | instruction sets. Without this option, on pre-v5 architectures, the | |
22179 | two instruction sets cannot be reliably used inside one program. The | |
22180 | default is @option{-mno-thumb-interwork}, since slightly larger code | |
22181 | is generated when @option{-mthumb-interwork} is specified. In AAPCS | |
22182 | configurations this option is meaningless. | |
22183 | ||
d77de738 ML |
22184 | @opindex mno-sched-prolog |
22185 | @opindex msched-prolog | |
ddf6fe37 | 22186 | @item -mno-sched-prolog |
d77de738 ML |
22187 | Prevent the reordering of instructions in the function prologue, or the |
22188 | merging of those instruction with the instructions in the function's | |
22189 | body. This means that all functions start with a recognizable set | |
22190 | of instructions (or in fact one of a choice from a small set of | |
22191 | different function prologues), and this information can be used to | |
22192 | locate the start of functions inside an executable piece of code. The | |
22193 | default is @option{-msched-prolog}. | |
22194 | ||
d77de738 | 22195 | @opindex mfloat-abi |
ddf6fe37 | 22196 | @item -mfloat-abi=@var{name} |
d77de738 ML |
22197 | Specifies which floating-point ABI to use. Permissible values |
22198 | are: @samp{soft}, @samp{softfp} and @samp{hard}. | |
22199 | ||
22200 | Specifying @samp{soft} causes GCC to generate output containing | |
22201 | library calls for floating-point operations. | |
22202 | @samp{softfp} allows the generation of code using hardware floating-point | |
22203 | instructions, but still uses the soft-float calling conventions. | |
22204 | @samp{hard} allows generation of floating-point instructions | |
22205 | and uses FPU-specific calling conventions. | |
22206 | ||
22207 | The default depends on the specific target configuration. Note that | |
22208 | the hard-float and soft-float ABIs are not link-compatible; you must | |
22209 | compile your entire program with the same ABI, and link with a | |
22210 | compatible set of libraries. | |
22211 | ||
d77de738 | 22212 | @opindex mgeneral-regs-only |
ddf6fe37 | 22213 | @item -mgeneral-regs-only |
d77de738 ML |
22214 | Generate code which uses only the general-purpose registers. This will prevent |
22215 | the compiler from using floating-point and Advanced SIMD registers but will not | |
22216 | impose any restrictions on the assembler. | |
22217 | ||
d77de738 | 22218 | @opindex mlittle-endian |
ddf6fe37 | 22219 | @item -mlittle-endian |
d77de738 ML |
22220 | Generate code for a processor running in little-endian mode. This is |
22221 | the default for all standard configurations. | |
22222 | ||
d77de738 | 22223 | @opindex mbig-endian |
ddf6fe37 | 22224 | @item -mbig-endian |
d77de738 ML |
22225 | Generate code for a processor running in big-endian mode; the default is |
22226 | to compile code for a little-endian processor. | |
22227 | ||
ddf6fe37 | 22228 | @opindex mbe8 |
d77de738 ML |
22229 | @item -mbe8 |
22230 | @itemx -mbe32 | |
d77de738 ML |
22231 | When linking a big-endian image select between BE8 and BE32 formats. |
22232 | The option has no effect for little-endian images and is ignored. The | |
22233 | default is dependent on the selected target architecture. For ARMv6 | |
22234 | and later architectures the default is BE8, for older architectures | |
22235 | the default is BE32. BE32 format has been deprecated by ARM. | |
22236 | ||
d77de738 | 22237 | @opindex march |
ddf6fe37 | 22238 | @item -march=@var{name}@r{[}+extension@dots{}@r{]} |
d77de738 ML |
22239 | This specifies the name of the target ARM architecture. GCC uses this |
22240 | name to determine what kind of instructions it can emit when generating | |
22241 | assembly code. This option can be used in conjunction with or instead | |
22242 | of the @option{-mcpu=} option. | |
22243 | ||
22244 | Permissible names are: | |
22245 | @samp{armv4t}, | |
22246 | @samp{armv5t}, @samp{armv5te}, | |
22247 | @samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2}, | |
22248 | @samp{armv6z}, @samp{armv6zk}, | |
22249 | @samp{armv7}, @samp{armv7-a}, @samp{armv7ve}, | |
22250 | @samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a}, | |
22251 | @samp{armv8.4-a}, | |
22252 | @samp{armv8.5-a}, | |
22253 | @samp{armv8.6-a}, | |
22254 | @samp{armv9-a}, | |
22255 | @samp{armv7-r}, | |
22256 | @samp{armv8-r}, | |
22257 | @samp{armv6-m}, @samp{armv6s-m}, | |
22258 | @samp{armv7-m}, @samp{armv7e-m}, | |
22259 | @samp{armv8-m.base}, @samp{armv8-m.main}, | |
22260 | @samp{armv8.1-m.main}, | |
22261 | @samp{armv9-a}, | |
22262 | @samp{iwmmxt} and @samp{iwmmxt2}. | |
22263 | ||
22264 | Additionally, the following architectures, which lack support for the | |
22265 | Thumb execution state, are recognized but support is deprecated: @samp{armv4}. | |
22266 | ||
22267 | Many of the architectures support extensions. These can be added by | |
22268 | appending @samp{+@var{extension}} to the architecture name. Extension | |
22269 | options are processed in order and capabilities accumulate. An extension | |
22270 | will also enable any necessary base extensions | |
22271 | upon which it depends. For example, the @samp{+crypto} extension | |
22272 | will always enable the @samp{+simd} extension. The exception to the | |
22273 | additive construction is for extensions that are prefixed with | |
22274 | @samp{+no@dots{}}: these extensions disable the specified option and | |
22275 | any other extensions that may depend on the presence of that | |
22276 | extension. | |
22277 | ||
22278 | For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to | |
22279 | writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is | |
22280 | entirely disabled by the @samp{+nofp} option that follows it. | |
22281 | ||
22282 | Most extension names are generically named, but have an effect that is | |
22283 | dependent upon the architecture to which it is applied. For example, | |
22284 | the @samp{+simd} option can be applied to both @samp{armv7-a} and | |
22285 | @samp{armv8-a} architectures, but will enable the original ARMv7-A | |
22286 | Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A | |
22287 | variant for @samp{armv8-a}. | |
22288 | ||
22289 | The table below lists the supported extensions for each architecture. | |
22290 | Architectures not mentioned do not support any extensions. | |
22291 | ||
22292 | @table @samp | |
22293 | @item armv5te | |
22294 | @itemx armv6 | |
22295 | @itemx armv6j | |
22296 | @itemx armv6k | |
22297 | @itemx armv6kz | |
22298 | @itemx armv6t2 | |
22299 | @itemx armv6z | |
22300 | @itemx armv6zk | |
22301 | @table @samp | |
22302 | @item +fp | |
22303 | The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be | |
22304 | used as an alias for this extension. | |
22305 | ||
22306 | @item +nofp | |
22307 | Disable the floating-point instructions. | |
22308 | @end table | |
22309 | ||
22310 | @item armv7 | |
22311 | The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures. | |
22312 | @table @samp | |
22313 | @item +fp | |
22314 | The VFPv3 floating-point instructions, with 16 double-precision | |
22315 | registers. The extension @samp{+vfpv3-d16} can be used as an alias | |
22316 | for this extension. Note that floating-point is not supported by the | |
22317 | base ARMv7-M architecture, but is compatible with both the ARMv7-A and | |
22318 | ARMv7-R architectures. | |
22319 | ||
22320 | @item +nofp | |
22321 | Disable the floating-point instructions. | |
22322 | @end table | |
22323 | ||
22324 | @item armv7-a | |
22325 | @table @samp | |
22326 | @item +mp | |
22327 | The multiprocessing extension. | |
22328 | ||
22329 | @item +sec | |
22330 | The security extension. | |
22331 | ||
22332 | @item +fp | |
22333 | The VFPv3 floating-point instructions, with 16 double-precision | |
22334 | registers. The extension @samp{+vfpv3-d16} can be used as an alias | |
22335 | for this extension. | |
22336 | ||
22337 | @item +simd | |
22338 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions. | |
22339 | The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases | |
22340 | for this extension. | |
22341 | ||
22342 | @item +vfpv3 | |
22343 | The VFPv3 floating-point instructions, with 32 double-precision | |
22344 | registers. | |
22345 | ||
22346 | @item +vfpv3-d16-fp16 | |
22347 | The VFPv3 floating-point instructions, with 16 double-precision | |
22348 | registers and the half-precision floating-point conversion operations. | |
22349 | ||
22350 | @item +vfpv3-fp16 | |
22351 | The VFPv3 floating-point instructions, with 32 double-precision | |
22352 | registers and the half-precision floating-point conversion operations. | |
22353 | ||
22354 | @item +vfpv4-d16 | |
22355 | The VFPv4 floating-point instructions, with 16 double-precision | |
22356 | registers. | |
22357 | ||
22358 | @item +vfpv4 | |
22359 | The VFPv4 floating-point instructions, with 32 double-precision | |
22360 | registers. | |
22361 | ||
22362 | @item +neon-fp16 | |
22363 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with | |
22364 | the half-precision floating-point conversion operations. | |
22365 | ||
22366 | @item +neon-vfpv4 | |
22367 | The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. | |
22368 | ||
22369 | @item +nosimd | |
22370 | Disable the Advanced SIMD instructions (does not disable floating point). | |
22371 | ||
22372 | @item +nofp | |
22373 | Disable the floating-point and Advanced SIMD instructions. | |
22374 | @end table | |
22375 | ||
22376 | @item armv7ve | |
22377 | The extended version of the ARMv7-A architecture with support for | |
22378 | virtualization. | |
22379 | @table @samp | |
22380 | @item +fp | |
22381 | The VFPv4 floating-point instructions, with 16 double-precision registers. | |
22382 | The extension @samp{+vfpv4-d16} can be used as an alias for this extension. | |
22383 | ||
22384 | @item +simd | |
22385 | The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The | |
22386 | extension @samp{+neon-vfpv4} can be used as an alias for this extension. | |
22387 | ||
22388 | @item +vfpv3-d16 | |
22389 | The VFPv3 floating-point instructions, with 16 double-precision | |
22390 | registers. | |
22391 | ||
22392 | @item +vfpv3 | |
22393 | The VFPv3 floating-point instructions, with 32 double-precision | |
22394 | registers. | |
22395 | ||
22396 | @item +vfpv3-d16-fp16 | |
22397 | The VFPv3 floating-point instructions, with 16 double-precision | |
22398 | registers and the half-precision floating-point conversion operations. | |
22399 | ||
22400 | @item +vfpv3-fp16 | |
22401 | The VFPv3 floating-point instructions, with 32 double-precision | |
22402 | registers and the half-precision floating-point conversion operations. | |
22403 | ||
22404 | @item +vfpv4-d16 | |
22405 | The VFPv4 floating-point instructions, with 16 double-precision | |
22406 | registers. | |
22407 | ||
22408 | @item +vfpv4 | |
22409 | The VFPv4 floating-point instructions, with 32 double-precision | |
22410 | registers. | |
22411 | ||
22412 | @item +neon | |
22413 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions. | |
22414 | The extension @samp{+neon-vfpv3} can be used as an alias for this extension. | |
22415 | ||
22416 | @item +neon-fp16 | |
22417 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with | |
22418 | the half-precision floating-point conversion operations. | |
22419 | ||
22420 | @item +nosimd | |
22421 | Disable the Advanced SIMD instructions (does not disable floating point). | |
22422 | ||
22423 | @item +nofp | |
22424 | Disable the floating-point and Advanced SIMD instructions. | |
22425 | @end table | |
22426 | ||
22427 | @item armv8-a | |
22428 | @table @samp | |
22429 | @item +crc | |
22430 | The Cyclic Redundancy Check (CRC) instructions. | |
22431 | @item +simd | |
22432 | The ARMv8-A Advanced SIMD and floating-point instructions. | |
22433 | @item +crypto | |
22434 | The cryptographic instructions. | |
22435 | @item +nocrypto | |
22436 | Disable the cryptographic instructions. | |
22437 | @item +nofp | |
22438 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22439 | @item +sb | |
22440 | Speculation Barrier Instruction. | |
22441 | @item +predres | |
22442 | Execution and Data Prediction Restriction Instructions. | |
22443 | @end table | |
22444 | ||
22445 | @item armv8.1-a | |
22446 | @table @samp | |
22447 | @item +simd | |
22448 | The ARMv8.1-A Advanced SIMD and floating-point instructions. | |
22449 | ||
22450 | @item +crypto | |
22451 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22452 | floating-point instructions. | |
22453 | ||
22454 | @item +nocrypto | |
22455 | Disable the cryptographic instructions. | |
22456 | ||
22457 | @item +nofp | |
22458 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22459 | ||
22460 | @item +sb | |
22461 | Speculation Barrier Instruction. | |
22462 | ||
22463 | @item +predres | |
22464 | Execution and Data Prediction Restriction Instructions. | |
22465 | @end table | |
22466 | ||
22467 | @item armv8.2-a | |
22468 | @itemx armv8.3-a | |
22469 | @table @samp | |
22470 | @item +fp16 | |
22471 | The half-precision floating-point data processing instructions. | |
22472 | This also enables the Advanced SIMD and floating-point instructions. | |
22473 | ||
22474 | @item +fp16fml | |
22475 | The half-precision floating-point fmla extension. This also enables | |
22476 | the half-precision floating-point extension and Advanced SIMD and | |
22477 | floating-point instructions. | |
22478 | ||
22479 | @item +simd | |
22480 | The ARMv8.1-A Advanced SIMD and floating-point instructions. | |
22481 | ||
22482 | @item +crypto | |
22483 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22484 | floating-point instructions. | |
22485 | ||
22486 | @item +dotprod | |
22487 | Enable the Dot Product extension. This also enables Advanced SIMD instructions. | |
22488 | ||
22489 | @item +nocrypto | |
22490 | Disable the cryptographic extension. | |
22491 | ||
22492 | @item +nofp | |
22493 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22494 | ||
22495 | @item +sb | |
22496 | Speculation Barrier Instruction. | |
22497 | ||
22498 | @item +predres | |
22499 | Execution and Data Prediction Restriction Instructions. | |
22500 | ||
22501 | @item +i8mm | |
22502 | 8-bit Integer Matrix Multiply instructions. | |
22503 | This also enables Advanced SIMD and floating-point instructions. | |
22504 | ||
22505 | @item +bf16 | |
22506 | Brain half-precision floating-point instructions. | |
22507 | This also enables Advanced SIMD and floating-point instructions. | |
22508 | @end table | |
22509 | ||
22510 | @item armv8.4-a | |
22511 | @table @samp | |
22512 | @item +fp16 | |
22513 | The half-precision floating-point data processing instructions. | |
22514 | This also enables the Advanced SIMD and floating-point instructions as well | |
22515 | as the Dot Product extension and the half-precision floating-point fmla | |
22516 | extension. | |
22517 | ||
22518 | @item +simd | |
22519 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22520 | Dot Product extension. | |
22521 | ||
22522 | @item +crypto | |
22523 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22524 | floating-point instructions as well as the Dot Product extension. | |
22525 | ||
22526 | @item +nocrypto | |
22527 | Disable the cryptographic extension. | |
22528 | ||
22529 | @item +nofp | |
22530 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22531 | ||
22532 | @item +sb | |
22533 | Speculation Barrier Instruction. | |
22534 | ||
22535 | @item +predres | |
22536 | Execution and Data Prediction Restriction Instructions. | |
22537 | ||
22538 | @item +i8mm | |
22539 | 8-bit Integer Matrix Multiply instructions. | |
22540 | This also enables Advanced SIMD and floating-point instructions. | |
22541 | ||
22542 | @item +bf16 | |
22543 | Brain half-precision floating-point instructions. | |
22544 | This also enables Advanced SIMD and floating-point instructions. | |
22545 | @end table | |
22546 | ||
22547 | @item armv8.5-a | |
22548 | @table @samp | |
22549 | @item +fp16 | |
22550 | The half-precision floating-point data processing instructions. | |
22551 | This also enables the Advanced SIMD and floating-point instructions as well | |
22552 | as the Dot Product extension and the half-precision floating-point fmla | |
22553 | extension. | |
22554 | ||
22555 | @item +simd | |
22556 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22557 | Dot Product extension. | |
22558 | ||
22559 | @item +crypto | |
22560 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22561 | floating-point instructions as well as the Dot Product extension. | |
22562 | ||
22563 | @item +nocrypto | |
22564 | Disable the cryptographic extension. | |
22565 | ||
22566 | @item +nofp | |
22567 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22568 | ||
22569 | @item +i8mm | |
22570 | 8-bit Integer Matrix Multiply instructions. | |
22571 | This also enables Advanced SIMD and floating-point instructions. | |
22572 | ||
22573 | @item +bf16 | |
22574 | Brain half-precision floating-point instructions. | |
22575 | This also enables Advanced SIMD and floating-point instructions. | |
22576 | @end table | |
22577 | ||
22578 | @item armv8.6-a | |
22579 | @table @samp | |
22580 | @item +fp16 | |
22581 | The half-precision floating-point data processing instructions. | |
22582 | This also enables the Advanced SIMD and floating-point instructions as well | |
22583 | as the Dot Product extension and the half-precision floating-point fmla | |
22584 | extension. | |
22585 | ||
22586 | @item +simd | |
22587 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22588 | Dot Product extension. | |
22589 | ||
22590 | @item +crypto | |
22591 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22592 | floating-point instructions as well as the Dot Product extension. | |
22593 | ||
22594 | @item +nocrypto | |
22595 | Disable the cryptographic extension. | |
22596 | ||
22597 | @item +nofp | |
22598 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22599 | ||
22600 | @item +i8mm | |
22601 | 8-bit Integer Matrix Multiply instructions. | |
22602 | This also enables Advanced SIMD and floating-point instructions. | |
22603 | ||
22604 | @item +bf16 | |
22605 | Brain half-precision floating-point instructions. | |
22606 | This also enables Advanced SIMD and floating-point instructions. | |
22607 | @end table | |
22608 | ||
22609 | @item armv7-r | |
22610 | @table @samp | |
22611 | @item +fp.sp | |
22612 | The single-precision VFPv3 floating-point instructions. The extension | |
22613 | @samp{+vfpv3xd} can be used as an alias for this extension. | |
22614 | ||
22615 | @item +fp | |
22616 | The VFPv3 floating-point instructions with 16 double-precision registers. | |
22617 | The extension +vfpv3-d16 can be used as an alias for this extension. | |
22618 | ||
22619 | @item +vfpv3xd-d16-fp16 | |
22620 | The single-precision VFPv3 floating-point instructions with 16 double-precision | |
22621 | registers and the half-precision floating-point conversion operations. | |
22622 | ||
22623 | @item +vfpv3-d16-fp16 | |
22624 | The VFPv3 floating-point instructions with 16 double-precision | |
22625 | registers and the half-precision floating-point conversion operations. | |
22626 | ||
22627 | @item +nofp | |
22628 | Disable the floating-point extension. | |
22629 | ||
22630 | @item +idiv | |
22631 | The ARM-state integer division instructions. | |
22632 | ||
22633 | @item +noidiv | |
22634 | Disable the ARM-state integer division extension. | |
22635 | @end table | |
22636 | ||
22637 | @item armv7e-m | |
22638 | @table @samp | |
22639 | @item +fp | |
22640 | The single-precision VFPv4 floating-point instructions. | |
22641 | ||
22642 | @item +fpv5 | |
22643 | The single-precision FPv5 floating-point instructions. | |
22644 | ||
22645 | @item +fp.dp | |
22646 | The single- and double-precision FPv5 floating-point instructions. | |
22647 | ||
22648 | @item +nofp | |
22649 | Disable the floating-point extensions. | |
22650 | @end table | |
22651 | ||
22652 | @item armv8.1-m.main | |
22653 | @table @samp | |
22654 | ||
22655 | @item +dsp | |
22656 | The DSP instructions. | |
22657 | ||
22658 | @item +mve | |
22659 | The M-Profile Vector Extension (MVE) integer instructions. | |
22660 | ||
22661 | @item +mve.fp | |
22662 | The M-Profile Vector Extension (MVE) integer and single precision | |
22663 | floating-point instructions. | |
22664 | ||
22665 | @item +fp | |
22666 | The single-precision floating-point instructions. | |
22667 | ||
22668 | @item +fp.dp | |
22669 | The single- and double-precision floating-point instructions. | |
22670 | ||
22671 | @item +nofp | |
22672 | Disable the floating-point extension. | |
22673 | ||
22674 | @item +cdecp0, +cdecp1, ... , +cdecp7 | |
22675 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
22676 | to the numbers given in the options in the range 0 to 7. | |
c91bb7b9 AC |
22677 | |
22678 | @item +pacbti | |
22679 | Enable the Pointer Authentication and Branch Target Identification Extension. | |
d77de738 ML |
22680 | @end table |
22681 | ||
22682 | @item armv8-m.main | |
22683 | @table @samp | |
22684 | @item +dsp | |
22685 | The DSP instructions. | |
22686 | ||
22687 | @item +nodsp | |
22688 | Disable the DSP extension. | |
22689 | ||
22690 | @item +fp | |
22691 | The single-precision floating-point instructions. | |
22692 | ||
22693 | @item +fp.dp | |
22694 | The single- and double-precision floating-point instructions. | |
22695 | ||
22696 | @item +nofp | |
22697 | Disable the floating-point extension. | |
22698 | ||
22699 | @item +cdecp0, +cdecp1, ... , +cdecp7 | |
22700 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
22701 | to the numbers given in the options in the range 0 to 7. | |
22702 | @end table | |
22703 | ||
22704 | @item armv8-r | |
22705 | @table @samp | |
22706 | @item +crc | |
22707 | The Cyclic Redundancy Check (CRC) instructions. | |
22708 | @item +fp.sp | |
22709 | The single-precision FPv5 floating-point instructions. | |
22710 | @item +simd | |
22711 | The ARMv8-A Advanced SIMD and floating-point instructions. | |
22712 | @item +crypto | |
22713 | The cryptographic instructions. | |
22714 | @item +nocrypto | |
22715 | Disable the cryptographic instructions. | |
22716 | @item +nofp | |
22717 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22718 | @end table | |
22719 | ||
22720 | @end table | |
22721 | ||
22722 | @option{-march=native} causes the compiler to auto-detect the architecture | |
22723 | of the build computer. At present, this feature is only supported on | |
22724 | GNU/Linux, and not all architectures are recognized. If the auto-detect | |
22725 | is unsuccessful the option has no effect. | |
22726 | ||
d77de738 | 22727 | @opindex mtune |
ddf6fe37 | 22728 | @item -mtune=@var{name} |
d77de738 ML |
22729 | This option specifies the name of the target ARM processor for |
22730 | which GCC should tune the performance of the code. | |
22731 | For some ARM implementations better performance can be obtained by using | |
22732 | this option. | |
22733 | Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t}, | |
22734 | @samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110}, | |
22735 | @samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810}, | |
22736 | @samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t}, | |
22737 | @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s}, | |
22738 | @samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t}, | |
22739 | @samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e}, | |
22740 | @samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp}, | |
22741 | @samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s}, | |
22742 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8}, | |
22743 | @samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17}, | |
22744 | @samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, | |
22745 | @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, | |
22746 | @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77}, | |
22747 | @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710}, | |
22748 | @samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5}, | |
22749 | @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus}, | |
22750 | @samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3}, | |
22751 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33}, | |
ccfd1e7f SP |
22752 | @samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1}, |
22753 | @samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply}, | |
d77de738 ML |
22754 | @samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4}, |
22755 | @samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale}, | |
22756 | @samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626}, | |
22757 | @samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1}, | |
22758 | @samp{xgene1}. | |
22759 | ||
22760 | Additionally, this option can specify that GCC should tune the performance | |
22761 | of the code for a big.LITTLE system. Permissible names are: | |
22762 | @samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7}, | |
22763 | @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
22764 | @samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
22765 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}. | |
22766 | ||
22767 | @option{-mtune=generic-@var{arch}} specifies that GCC should tune the | |
22768 | performance for a blend of processors within architecture @var{arch}. | |
22769 | The aim is to generate code that run well on the current most popular | |
22770 | processors, balancing between optimizations that benefit some CPUs in the | |
22771 | range, and avoiding performance pitfalls of other CPUs. The effects of | |
22772 | this option may change in future GCC versions as CPU models come and go. | |
22773 | ||
22774 | @option{-mtune} permits the same extension options as @option{-mcpu}, but | |
22775 | the extension options do not affect the tuning of the generated code. | |
22776 | ||
22777 | @option{-mtune=native} causes the compiler to auto-detect the CPU | |
22778 | of the build computer. At present, this feature is only supported on | |
22779 | GNU/Linux, and not all architectures are recognized. If the auto-detect is | |
22780 | unsuccessful the option has no effect. | |
22781 | ||
d77de738 | 22782 | @opindex mcpu |
ddf6fe37 | 22783 | @item -mcpu=@var{name}@r{[}+extension@dots{}@r{]} |
d77de738 ML |
22784 | This specifies the name of the target ARM processor. GCC uses this name |
22785 | to derive the name of the target ARM architecture (as if specified | |
22786 | by @option{-march}) and the ARM processor type for which to tune for | |
22787 | performance (as if specified by @option{-mtune}). Where this option | |
22788 | is used in conjunction with @option{-march} or @option{-mtune}, | |
22789 | those options take precedence over the appropriate part of this option. | |
22790 | ||
22791 | Many of the supported CPUs implement optional architectural | |
22792 | extensions. Where this is so the architectural extensions are | |
22793 | normally enabled by default. If implementations that lack the | |
22794 | extension exist, then the extension syntax can be used to disable | |
22795 | those extensions that have been omitted. For floating-point and | |
22796 | Advanced SIMD (Neon) instructions, the settings of the options | |
22797 | @option{-mfloat-abi} and @option{-mfpu} must also be considered: | |
22798 | floating-point and Advanced SIMD instructions will only be used if | |
22799 | @option{-mfloat-abi} is not set to @samp{soft}; and any setting of | |
22800 | @option{-mfpu} other than @samp{auto} will override the available | |
22801 | floating-point and SIMD extension instructions. | |
22802 | ||
22803 | For example, @samp{cortex-a9} can be found in three major | |
22804 | configurations: integer only, with just a floating-point unit or with | |
22805 | floating-point and Advanced SIMD. The default is to enable all the | |
22806 | instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can | |
22807 | be used to disable just the SIMD or both the SIMD and floating-point | |
22808 | instructions respectively. | |
22809 | ||
22810 | Permissible names for this option are the same as those for | |
22811 | @option{-mtune}. | |
22812 | ||
22813 | The following extension options are common to the listed CPUs: | |
22814 | ||
22815 | @table @samp | |
22816 | @item +nodsp | |
ccfd1e7f SP |
22817 | Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p}, |
22818 | @samp{cortex-m55} and @samp{cortex-m85}. Also disable the M-Profile Vector | |
22819 | Extension (MVE) integer and single precision floating-point instructions on | |
22820 | @samp{cortex-m55} and @samp{cortex-m85}. | |
22821 | ||
22822 | @item +nopacbti | |
22823 | Disable the Pointer Authentication and Branch Target Identification Extension | |
22824 | on @samp{cortex-m85}. | |
d77de738 ML |
22825 | |
22826 | @item +nomve | |
22827 | Disable the M-Profile Vector Extension (MVE) integer and single precision | |
ccfd1e7f | 22828 | floating-point instructions on @samp{cortex-m55} and @samp{cortex-m85}. |
d77de738 ML |
22829 | |
22830 | @item +nomve.fp | |
22831 | Disable the M-Profile Vector Extension (MVE) single precision floating-point | |
ccfd1e7f | 22832 | instructions on @samp{cortex-m55} and @samp{cortex-m85}. |
d77de738 | 22833 | |
798a0d05 SP |
22834 | @item +cdecp0, +cdecp1, ... , +cdecp7 |
22835 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
22836 | to the numbers given in the options in the range 0 to 7 on @samp{cortex-m55}. | |
22837 | ||
d77de738 ML |
22838 | @item +nofp |
22839 | Disables the floating-point instructions on @samp{arm9e}, | |
22840 | @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e}, | |
22841 | @samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s}, | |
22842 | @samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, | |
22843 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p} | |
ccfd1e7f SP |
22844 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}, |
22845 | @samp{cortex-m55} and @samp{cortex-m85}. | |
d77de738 ML |
22846 | Disables the floating-point and SIMD instructions on |
22847 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, | |
22848 | @samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12}, | |
22849 | @samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7}, | |
22850 | @samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35}, | |
22851 | @samp{cortex-a53} and @samp{cortex-a55}. | |
22852 | ||
22853 | @item +nofp.dp | |
22854 | Disables the double-precision component of the floating-point instructions | |
22855 | on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, | |
22856 | @samp{cortex-r52plus} and @samp{cortex-m7}. | |
22857 | ||
22858 | @item +nosimd | |
22859 | Disables the SIMD (but not floating-point) instructions on | |
22860 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7} | |
22861 | and @samp{cortex-a9}. | |
22862 | ||
22863 | @item +crypto | |
22864 | Enables the cryptographic instructions on @samp{cortex-a32}, | |
22865 | @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57}, | |
22866 | @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1}, | |
22867 | @samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
22868 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and | |
22869 | @samp{cortex-a75.cortex-a55}. | |
22870 | @end table | |
22871 | ||
22872 | Additionally the @samp{generic-armv7-a} pseudo target defaults to | |
22873 | VFPv3 with 16 double-precision registers. It supports the following | |
22874 | extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16}, | |
22875 | @samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16}, | |
22876 | @samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3}, | |
22877 | @samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for | |
22878 | the extensions to @option{-march=armv7-a}. | |
22879 | ||
22880 | @option{-mcpu=generic-@var{arch}} is also permissible, and is | |
22881 | equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}. | |
22882 | See @option{-mtune} for more information. | |
22883 | ||
22884 | @option{-mcpu=native} causes the compiler to auto-detect the CPU | |
22885 | of the build computer. At present, this feature is only supported on | |
22886 | GNU/Linux, and not all architectures are recognized. If the auto-detect | |
22887 | is unsuccessful the option has no effect. | |
22888 | ||
d77de738 | 22889 | @opindex mfpu |
ddf6fe37 | 22890 | @item -mfpu=@var{name} |
d77de738 ML |
22891 | This specifies what floating-point hardware (or hardware emulation) is |
22892 | available on the target. Permissible names are: @samp{auto}, @samp{vfpv2}, | |
22893 | @samp{vfpv3}, | |
22894 | @samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd}, | |
22895 | @samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4}, | |
22896 | @samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4}, | |
22897 | @samp{fpv5-d16}, @samp{fpv5-sp-d16}, | |
22898 | @samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}. | |
22899 | Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp} | |
22900 | is an alias for @samp{vfpv2}. | |
22901 | ||
22902 | The setting @samp{auto} is the default and is special. It causes the | |
22903 | compiler to select the floating-point and Advanced SIMD instructions | |
22904 | based on the settings of @option{-mcpu} and @option{-march}. | |
22905 | ||
22906 | If the selected floating-point hardware includes the NEON extension | |
22907 | (e.g.@: @option{-mfpu=neon}), note that floating-point | |
22908 | operations are not generated by GCC's auto-vectorization pass unless | |
22909 | @option{-funsafe-math-optimizations} is also specified. This is | |
22910 | because NEON hardware does not fully implement the IEEE 754 standard for | |
22911 | floating-point arithmetic (in particular denormal values are treated as | |
22912 | zero), so the use of NEON instructions may lead to a loss of precision. | |
22913 | ||
22914 | 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}). | |
22915 | ||
d77de738 | 22916 | @opindex mfp16-format |
ddf6fe37 | 22917 | @item -mfp16-format=@var{name} |
d77de738 ML |
22918 | Specify the format of the @code{__fp16} half-precision floating-point type. |
22919 | Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative}; | |
22920 | the default is @samp{none}, in which case the @code{__fp16} type is not | |
22921 | defined. @xref{Half-Precision}, for more information. | |
22922 | ||
d77de738 | 22923 | @opindex mstructure-size-boundary |
ddf6fe37 | 22924 | @item -mstructure-size-boundary=@var{n} |
d77de738 ML |
22925 | The sizes of all structures and unions are rounded up to a multiple |
22926 | of the number of bits set by this option. Permissible values are 8, 32 | |
22927 | and 64. The default value varies for different toolchains. For the COFF | |
22928 | targeted toolchain the default value is 8. A value of 64 is only allowed | |
22929 | if the underlying ABI supports it. | |
22930 | ||
22931 | Specifying a larger number can produce faster, more efficient code, but | |
22932 | can also increase the size of the program. Different values are potentially | |
22933 | incompatible. Code compiled with one value cannot necessarily expect to | |
22934 | work with code or libraries compiled with another value, if they exchange | |
22935 | information using structures or unions. | |
22936 | ||
22937 | This option is deprecated. | |
22938 | ||
d77de738 | 22939 | @opindex mabort-on-noreturn |
ddf6fe37 | 22940 | @item -mabort-on-noreturn |
d77de738 ML |
22941 | Generate a call to the function @code{abort} at the end of a |
22942 | @code{noreturn} function. It is executed if the function tries to | |
22943 | return. | |
22944 | ||
d77de738 ML |
22945 | @opindex mlong-calls |
22946 | @opindex mno-long-calls | |
ddf6fe37 AA |
22947 | @item -mlong-calls |
22948 | @itemx -mno-long-calls | |
d77de738 ML |
22949 | Tells the compiler to perform function calls by first loading the |
22950 | address of the function into a register and then performing a subroutine | |
22951 | call on this register. This switch is needed if the target function | |
22952 | lies outside of the 64-megabyte addressing range of the offset-based | |
22953 | version of subroutine call instruction. | |
22954 | ||
22955 | Even if this switch is enabled, not all function calls are turned | |
22956 | into long calls. The heuristic is that static functions, functions | |
22957 | that have the @code{short_call} attribute, functions that are inside | |
22958 | the scope of a @code{#pragma no_long_calls} directive, and functions whose | |
22959 | definitions have already been compiled within the current compilation | |
22960 | unit are not turned into long calls. The exceptions to this rule are | |
22961 | that weak function definitions, functions with the @code{long_call} | |
22962 | attribute or the @code{section} attribute, and functions that are within | |
22963 | the scope of a @code{#pragma long_calls} directive are always | |
22964 | turned into long calls. | |
22965 | ||
22966 | This feature is not enabled by default. Specifying | |
22967 | @option{-mno-long-calls} restores the default behavior, as does | |
22968 | placing the function calls within the scope of a @code{#pragma | |
22969 | long_calls_off} directive. Note these switches have no effect on how | |
22970 | the compiler generates code to handle function calls via function | |
22971 | pointers. | |
22972 | ||
d77de738 | 22973 | @opindex msingle-pic-base |
ddf6fe37 | 22974 | @item -msingle-pic-base |
d77de738 ML |
22975 | Treat the register used for PIC addressing as read-only, rather than |
22976 | loading it in the prologue for each function. The runtime system is | |
22977 | responsible for initializing this register with an appropriate value | |
22978 | before execution begins. | |
22979 | ||
d77de738 | 22980 | @opindex mpic-register |
ddf6fe37 | 22981 | @item -mpic-register=@var{reg} |
d77de738 ML |
22982 | Specify the register to be used for PIC addressing. |
22983 | For standard PIC base case, the default is any suitable register | |
22984 | determined by compiler. For single PIC base case, the default is | |
22985 | @samp{R9} if target is EABI based or stack-checking is enabled, | |
22986 | otherwise the default is @samp{R10}. | |
22987 | ||
d77de738 | 22988 | @opindex mpic-data-is-text-relative |
ddf6fe37 | 22989 | @item -mpic-data-is-text-relative |
d77de738 ML |
22990 | Assume that the displacement between the text and data segments is fixed |
22991 | at static link time. This permits using PC-relative addressing | |
22992 | operations to access data known to be in the data segment. For | |
22993 | non-VxWorks RTP targets, this option is enabled by default. When | |
22994 | disabled on such targets, it will enable @option{-msingle-pic-base} by | |
22995 | default. | |
22996 | ||
d77de738 | 22997 | @opindex mpoke-function-name |
ddf6fe37 | 22998 | @item -mpoke-function-name |
d77de738 ML |
22999 | Write the name of each function into the text section, directly |
23000 | preceding the function prologue. The generated code is similar to this: | |
23001 | ||
23002 | @smallexample | |
23003 | t0 | |
23004 | .ascii "arm_poke_function_name", 0 | |
23005 | .align | |
23006 | t1 | |
23007 | .word 0xff000000 + (t1 - t0) | |
23008 | arm_poke_function_name | |
23009 | mov ip, sp | |
23010 | stmfd sp!, @{fp, ip, lr, pc@} | |
23011 | sub fp, ip, #4 | |
23012 | @end smallexample | |
23013 | ||
23014 | When performing a stack backtrace, code can inspect the value of | |
23015 | @code{pc} stored at @code{fp + 0}. If the trace function then looks at | |
23016 | location @code{pc - 12} and the top 8 bits are set, then we know that | |
23017 | there is a function name embedded immediately preceding this location | |
23018 | and has length @code{((pc[-3]) & 0xff000000)}. | |
23019 | ||
d77de738 ML |
23020 | @opindex marm |
23021 | @opindex mthumb | |
ddf6fe37 AA |
23022 | @item -mthumb |
23023 | @itemx -marm | |
d77de738 ML |
23024 | |
23025 | Select between generating code that executes in ARM and Thumb | |
23026 | states. The default for most configurations is to generate code | |
23027 | that executes in ARM state, but the default can be changed by | |
23028 | configuring GCC with the @option{--with-mode=}@var{state} | |
23029 | configure option. | |
23030 | ||
23031 | You can also override the ARM and Thumb mode for each function | |
23032 | by using the @code{target("thumb")} and @code{target("arm")} function attributes | |
23033 | (@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}). | |
23034 | ||
d77de738 | 23035 | @opindex mflip-thumb |
ddf6fe37 | 23036 | @item -mflip-thumb |
d77de738 ML |
23037 | Switch ARM/Thumb modes on alternating functions. |
23038 | This option is provided for regression testing of mixed Thumb/ARM code | |
23039 | generation, and is not intended for ordinary use in compiling code. | |
23040 | ||
d77de738 | 23041 | @opindex mtpcs-frame |
ddf6fe37 | 23042 | @item -mtpcs-frame |
d77de738 ML |
23043 | Generate a stack frame that is compliant with the Thumb Procedure Call |
23044 | Standard for all non-leaf functions. (A leaf function is one that does | |
23045 | not call any other functions.) The default is @option{-mno-tpcs-frame}. | |
23046 | ||
d77de738 | 23047 | @opindex mtpcs-leaf-frame |
ddf6fe37 | 23048 | @item -mtpcs-leaf-frame |
d77de738 ML |
23049 | Generate a stack frame that is compliant with the Thumb Procedure Call |
23050 | Standard for all leaf functions. (A leaf function is one that does | |
23051 | not call any other functions.) The default is @option{-mno-apcs-leaf-frame}. | |
23052 | ||
d77de738 | 23053 | @opindex mcallee-super-interworking |
ddf6fe37 | 23054 | @item -mcallee-super-interworking |
d77de738 ML |
23055 | Gives all externally visible functions in the file being compiled an ARM |
23056 | instruction set header which switches to Thumb mode before executing the | |
23057 | rest of the function. This allows these functions to be called from | |
23058 | non-interworking code. This option is not valid in AAPCS configurations | |
23059 | because interworking is enabled by default. | |
23060 | ||
d77de738 | 23061 | @opindex mcaller-super-interworking |
ddf6fe37 | 23062 | @item -mcaller-super-interworking |
d77de738 ML |
23063 | Allows calls via function pointers (including virtual functions) to |
23064 | execute correctly regardless of whether the target code has been | |
23065 | compiled for interworking or not. There is a small overhead in the cost | |
23066 | of executing a function pointer if this option is enabled. This option | |
23067 | is not valid in AAPCS configurations because interworking is enabled | |
23068 | by default. | |
23069 | ||
d77de738 | 23070 | @opindex mtp |
ddf6fe37 | 23071 | @item -mtp=@var{name} |
cca8d9e5 KT |
23072 | Specify the access model for the thread local storage pointer. The model |
23073 | @samp{soft} generates calls to @code{__aeabi_read_tp}. Other accepted | |
23074 | models are @samp{tpidrurw}, @samp{tpidruro} and @samp{tpidrprw} which fetch | |
23075 | the thread pointer from the corresponding system register directly | |
23076 | (supported from the arm6k architecture and later). These system registers | |
23077 | are accessed through the CP15 co-processor interface and the argument | |
23078 | @samp{cp15} is also accepted as a convenience alias of @samp{tpidruro}. | |
23079 | The argument @samp{auto} uses the best available method for the selected | |
23080 | processor. The default setting is @samp{auto}. | |
d77de738 | 23081 | |
d77de738 | 23082 | @opindex mtls-dialect |
ddf6fe37 | 23083 | @item -mtls-dialect=@var{dialect} |
d77de738 ML |
23084 | Specify the dialect to use for accessing thread local storage. Two |
23085 | @var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The | |
23086 | @samp{gnu} dialect selects the original GNU scheme for supporting | |
23087 | local and global dynamic TLS models. The @samp{gnu2} dialect | |
23088 | selects the GNU descriptor scheme, which provides better performance | |
23089 | for shared libraries. The GNU descriptor scheme is compatible with | |
23090 | the original scheme, but does require new assembler, linker and | |
23091 | library support. Initial and local exec TLS models are unaffected by | |
23092 | this option and always use the original scheme. | |
23093 | ||
d77de738 | 23094 | @opindex mword-relocations |
ddf6fe37 | 23095 | @item -mword-relocations |
d77de738 ML |
23096 | Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32). |
23097 | This is enabled by default on targets (uClinux, SymbianOS) where the runtime | |
23098 | loader imposes this restriction, and when @option{-fpic} or @option{-fPIC} | |
23099 | is specified. This option conflicts with @option{-mslow-flash-data}. | |
23100 | ||
d77de738 | 23101 | @opindex mfix-cortex-m3-ldrd |
ddf6fe37 | 23102 | @item -mfix-cortex-m3-ldrd |
d77de738 ML |
23103 | Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions |
23104 | with overlapping destination and base registers are used. This option avoids | |
23105 | generating these instructions. This option is enabled by default when | |
23106 | @option{-mcpu=cortex-m3} is specified. | |
23107 | ||
23108 | @item -mfix-cortex-a57-aes-1742098 | |
23109 | @itemx -mno-fix-cortex-a57-aes-1742098 | |
23110 | @itemx -mfix-cortex-a72-aes-1655431 | |
23111 | @itemx -mno-fix-cortex-a72-aes-1655431 | |
23112 | Enable (disable) mitigation for an erratum on Cortex-A57 and | |
23113 | Cortex-A72 that affects the AES cryptographic instructions. This | |
23114 | option is enabled by default when either @option{-mcpu=cortex-a57} or | |
23115 | @option{-mcpu=cortex-a72} is specified. | |
23116 | ||
d77de738 ML |
23117 | @opindex munaligned-access |
23118 | @opindex mno-unaligned-access | |
ddf6fe37 AA |
23119 | @item -munaligned-access |
23120 | @itemx -mno-unaligned-access | |
d77de738 ML |
23121 | Enables (or disables) reading and writing of 16- and 32- bit values |
23122 | from addresses that are not 16- or 32- bit aligned. By default | |
23123 | unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for | |
23124 | ARMv8-M Baseline architectures, and enabled for all other | |
23125 | architectures. If unaligned access is not enabled then words in packed | |
23126 | data structures are accessed a byte at a time. | |
23127 | ||
23128 | The ARM attribute @code{Tag_CPU_unaligned_access} is set in the | |
23129 | generated object file to either true or false, depending upon the | |
23130 | setting of this option. If unaligned access is enabled then the | |
23131 | preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also | |
23132 | defined. | |
23133 | ||
d77de738 | 23134 | @opindex mneon-for-64bits |
ddf6fe37 | 23135 | @item -mneon-for-64bits |
d77de738 ML |
23136 | This option is deprecated and has no effect. |
23137 | ||
d77de738 | 23138 | @opindex mslow-flash-data |
ddf6fe37 | 23139 | @item -mslow-flash-data |
d77de738 ML |
23140 | Assume loading data from flash is slower than fetching instruction. |
23141 | Therefore literal load is minimized for better performance. | |
23142 | This option is only supported when compiling for ARMv7 M-profile and | |
23143 | off by default. It conflicts with @option{-mword-relocations}. | |
23144 | ||
d77de738 | 23145 | @opindex masm-syntax-unified |
ddf6fe37 | 23146 | @item -masm-syntax-unified |
d77de738 ML |
23147 | Assume inline assembler is using unified asm syntax. The default is |
23148 | currently off which implies divided syntax. This option has no impact | |
23149 | on Thumb2. However, this may change in future releases of GCC. | |
23150 | Divided syntax should be considered deprecated. | |
23151 | ||
d77de738 | 23152 | @opindex mrestrict-it |
ddf6fe37 | 23153 | @item -mrestrict-it |
d77de738 ML |
23154 | Restricts generation of IT blocks to conform to the rules of ARMv8-A. |
23155 | IT blocks can only contain a single 16-bit instruction from a select | |
23156 | set of instructions. This option is on by default for ARMv8-A Thumb mode. | |
23157 | ||
d77de738 | 23158 | @opindex mprint-tune-info |
ddf6fe37 | 23159 | @item -mprint-tune-info |
d77de738 ML |
23160 | Print CPU tuning information as comment in assembler file. This is |
23161 | an option used only for regression testing of the compiler and not | |
23162 | intended for ordinary use in compiling code. This option is disabled | |
23163 | by default. | |
23164 | ||
d77de738 | 23165 | @opindex mverbose-cost-dump |
ddf6fe37 | 23166 | @item -mverbose-cost-dump |
d77de738 ML |
23167 | Enable verbose cost model dumping in the debug dump files. This option is |
23168 | provided for use in debugging the compiler. | |
23169 | ||
d77de738 | 23170 | @opindex mpure-code |
ddf6fe37 | 23171 | @item -mpure-code |
d77de738 ML |
23172 | Do not allow constant data to be placed in code sections. |
23173 | Additionally, when compiling for ELF object format give all text sections the | |
23174 | ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option | |
23175 | is only available when generating non-pic code for M-profile targets. | |
23176 | ||
d77de738 | 23177 | @opindex mcmse |
ddf6fe37 | 23178 | @item -mcmse |
d77de738 ML |
23179 | Generate secure code as per the "ARMv8-M Security Extensions: Requirements on |
23180 | Development Tools Engineering Specification", which can be found on | |
23181 | @url{https://developer.arm.com/documentation/ecm0359818/latest/}. | |
23182 | ||
d77de738 | 23183 | @opindex mfix-cmse-cve-2021-35465 |
ddf6fe37 | 23184 | @item -mfix-cmse-cve-2021-35465 |
d77de738 ML |
23185 | Mitigate against a potential security issue with the @code{VLLDM} instruction |
23186 | in some M-profile devices when using CMSE (CVE-2021-365465). This option is | |
23187 | enabled by default when the option @option{-mcpu=} is used with | |
ccfd1e7f SP |
23188 | @code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55}, @code{cortex-m85} |
23189 | or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465} can be used | |
23190 | to disable the mitigation. | |
d77de738 | 23191 | |
d77de738 ML |
23192 | @opindex mstack-protector-guard |
23193 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
23194 | @item -mstack-protector-guard=@var{guard} |
23195 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
23196 | Generate stack protection code using canary at @var{guard}. Supported |
23197 | locations are @samp{global} for a global canary or @samp{tls} for a | |
23198 | canary accessible via the TLS register. The option | |
23199 | @option{-mstack-protector-guard-offset=} is for use with | |
23200 | @option{-fstack-protector-guard=tls} and not for use in user-land code. | |
23201 | ||
d77de738 ML |
23202 | @opindex mfdpic |
23203 | @opindex mno-fdpic | |
ddf6fe37 AA |
23204 | @item -mfdpic |
23205 | @itemx -mno-fdpic | |
d77de738 ML |
23206 | Select the FDPIC ABI, which uses 64-bit function descriptors to |
23207 | represent pointers to functions. When the compiler is configured for | |
23208 | @code{arm-*-uclinuxfdpiceabi} targets, this option is on by default | |
23209 | and implies @option{-fPIE} if none of the PIC/PIE-related options is | |
23210 | provided. On other targets, it only enables the FDPIC-specific code | |
23211 | generation features, and the user should explicitly provide the | |
23212 | PIC/PIE-related options as needed. | |
23213 | ||
23214 | Note that static linking is not supported because it would still | |
23215 | involve the dynamic linker when the program self-relocates. If such | |
23216 | behavior is acceptable, use -static and -Wl,-dynamic-linker options. | |
23217 | ||
23218 | The opposite @option{-mno-fdpic} option is useful (and required) to | |
23219 | build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi}) | |
23220 | toolchain as the one used to build the userland programs. | |
23221 | ||
14fab5fb | 23222 | @opindex mbranch-protection |
ddf6fe37 | 23223 | @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]] |
14fab5fb AC |
23224 | Enable branch protection features (armv8.1-m.main only). |
23225 | @samp{none} generate code without branch protection or return address | |
23226 | signing. | |
23227 | @samp{standard[+@var{leaf}]} generate code with all branch protection | |
23228 | features enabled at their standard level. | |
23229 | @samp{pac-ret[+@var{leaf}]} generate code with return address signing | |
23230 | set to its standard level, which is to sign all functions that save | |
23231 | the return address to memory. | |
23232 | @samp{leaf} When return address signing is enabled, also sign leaf | |
23233 | functions even if they do not write the return address to memory. | |
23234 | +@samp{bti} Add landing-pad instructions at the permitted targets of | |
23235 | indirect branch instructions. | |
23236 | ||
23237 | If the @samp{+pacbti} architecture extension is not enabled, then all | |
23238 | branch protection and return address signing operations are | |
23239 | constrained to use only the instructions defined in the | |
23240 | architectural-NOP space. The generated code will remain | |
23241 | backwards-compatible with earlier versions of the architecture, but | |
23242 | the additional security can be enabled at run time on processors that | |
23243 | support the @samp{PACBTI} extension. | |
23244 | ||
23245 | Branch target enforcement using BTI can only be enabled at runtime if | |
23246 | all code in the application has been compiled with at least | |
23247 | @samp{-mbranch-protection=bti}. | |
23248 | ||
23249 | Any setting other than @samp{none} is supported only on armv8-m.main | |
23250 | or later. | |
23251 | ||
23252 | The default is to generate code without branch protection or return | |
23253 | address signing. | |
23254 | ||
d77de738 ML |
23255 | @end table |
23256 | ||
23257 | @node AVR Options | |
23258 | @subsection AVR Options | |
23259 | @cindex AVR Options | |
23260 | ||
23261 | These options are defined for AVR implementations: | |
23262 | ||
23263 | @table @gcctabopt | |
d77de738 | 23264 | @opindex mmcu |
ddf6fe37 | 23265 | @item -mmcu=@var{mcu} |
d77de738 ML |
23266 | Specify Atmel AVR instruction set architectures (ISA) or MCU type. |
23267 | ||
23268 | The default for this option is@tie{}@samp{avr2}. | |
23269 | ||
23270 | GCC supports the following AVR devices and ISAs: | |
23271 | ||
23272 | @include avr-mmcu.texi | |
23273 | ||
d77de738 | 23274 | @opindex mabsdata |
ddf6fe37 | 23275 | @item -mabsdata |
d77de738 ML |
23276 | |
23277 | Assume that all data in static storage can be accessed by LDS / STS | |
23278 | instructions. This option has only an effect on reduced Tiny devices like | |
23279 | ATtiny40. See also the @code{absdata} | |
23280 | @ref{AVR Variable Attributes,variable attribute}. | |
23281 | ||
d77de738 | 23282 | @opindex maccumulate-args |
ddf6fe37 | 23283 | @item -maccumulate-args |
d77de738 ML |
23284 | Accumulate outgoing function arguments and acquire/release the needed |
23285 | stack space for outgoing function arguments once in function | |
23286 | prologue/epilogue. Without this option, outgoing arguments are pushed | |
23287 | before calling a function and popped afterwards. | |
23288 | ||
23289 | Popping the arguments after the function call can be expensive on | |
23290 | AVR so that accumulating the stack space might lead to smaller | |
23291 | executables because arguments need not be removed from the | |
23292 | stack after such a function call. | |
23293 | ||
23294 | This option can lead to reduced code size for functions that perform | |
23295 | several calls to functions that get their arguments on the stack like | |
23296 | calls to printf-like functions. | |
23297 | ||
d77de738 | 23298 | @opindex mbranch-cost |
ddf6fe37 | 23299 | @item -mbranch-cost=@var{cost} |
d77de738 ML |
23300 | Set the branch costs for conditional branch instructions to |
23301 | @var{cost}. Reasonable values for @var{cost} are small, non-negative | |
23302 | integers. The default branch cost is 0. | |
23303 | ||
d77de738 | 23304 | @opindex mcall-prologues |
ddf6fe37 | 23305 | @item -mcall-prologues |
d77de738 ML |
23306 | Functions prologues/epilogues are expanded as calls to appropriate |
23307 | subroutines. Code size is smaller. | |
23308 | ||
d77de738 ML |
23309 | @opindex mdouble |
23310 | @opindex mlong-double | |
ddf6fe37 AA |
23311 | @item -mdouble=@var{bits} |
23312 | @itemx -mlong-double=@var{bits} | |
d77de738 ML |
23313 | Set the size (in bits) of the @code{double} or @code{long double} type, |
23314 | respectively. Possible values for @var{bits} are 32 and 64. | |
23315 | Whether or not a specific value for @var{bits} is allowed depends on | |
23316 | the @code{--with-double=} and @code{--with-long-double=} | |
23317 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}}, | |
23318 | and the same applies for the default values of the options. | |
23319 | ||
d77de738 | 23320 | @opindex mgas-isr-prologues |
ddf6fe37 | 23321 | @item -mgas-isr-prologues |
d77de738 ML |
23322 | Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo |
23323 | instruction supported by GNU Binutils. | |
23324 | If this option is on, the feature can still be disabled for individual | |
23325 | ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}} | |
23326 | function attribute. This feature is activated per default | |
23327 | if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}), | |
23328 | and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}. | |
23329 | ||
d77de738 | 23330 | @opindex mint8 |
ddf6fe37 | 23331 | @item -mint8 |
d77de738 ML |
23332 | Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a |
23333 | @code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes, | |
23334 | and @code{long long} is 4 bytes. Please note that this option does not | |
23335 | conform to the C standards, but it results in smaller code | |
23336 | size. | |
23337 | ||
d77de738 | 23338 | @opindex mmain-is-OS_task |
ddf6fe37 | 23339 | @item -mmain-is-OS_task |
d77de738 ML |
23340 | Do not save registers in @code{main}. The effect is the same like |
23341 | attaching attribute @ref{AVR Function Attributes,,@code{OS_task}} | |
23342 | to @code{main}. It is activated per default if optimization is on. | |
23343 | ||
d77de738 | 23344 | @opindex mn-flash |
ddf6fe37 | 23345 | @item -mn-flash=@var{num} |
d77de738 ML |
23346 | Assume that the flash memory has a size of |
23347 | @var{num} times 64@tie{}KiB. | |
23348 | ||
d77de738 | 23349 | @opindex mno-interrupts |
ddf6fe37 | 23350 | @item -mno-interrupts |
d77de738 ML |
23351 | Generated code is not compatible with hardware interrupts. |
23352 | Code size is smaller. | |
23353 | ||
d77de738 | 23354 | @opindex mrelax |
ddf6fe37 | 23355 | @item -mrelax |
d77de738 ML |
23356 | Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter |
23357 | @code{RCALL} resp.@: @code{RJMP} instruction if applicable. | |
23358 | Setting @option{-mrelax} just adds the @option{--mlink-relax} option to | |
23359 | the assembler's command line and the @option{--relax} option to the | |
23360 | linker's command line. | |
23361 | ||
23362 | Jump relaxing is performed by the linker because jump offsets are not | |
23363 | known before code is located. Therefore, the assembler code generated by the | |
23364 | compiler is the same, but the instructions in the executable may | |
23365 | differ from instructions in the assembler code. | |
23366 | ||
23367 | Relaxing must be turned on if linker stubs are needed, see the | |
23368 | section on @code{EIND} and linker stubs below. | |
23369 | ||
d77de738 | 23370 | @opindex mrmw |
ddf6fe37 | 23371 | @item -mrmw |
d77de738 ML |
23372 | Assume that the device supports the Read-Modify-Write |
23373 | instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}. | |
23374 | ||
d77de738 | 23375 | @opindex mshort-calls |
ddf6fe37 | 23376 | @item -mshort-calls |
d77de738 ML |
23377 | |
23378 | Assume that @code{RJMP} and @code{RCALL} can target the whole | |
23379 | program memory. | |
23380 | ||
23381 | This option is used internally for multilib selection. It is | |
23382 | not an optimization option, and you don't need to set it by hand. | |
23383 | ||
d77de738 | 23384 | @opindex msp8 |
ddf6fe37 | 23385 | @item -msp8 |
d77de738 ML |
23386 | Treat the stack pointer register as an 8-bit register, |
23387 | i.e.@: assume the high byte of the stack pointer is zero. | |
23388 | In general, you don't need to set this option by hand. | |
23389 | ||
23390 | This option is used internally by the compiler to select and | |
23391 | build multilibs for architectures @code{avr2} and @code{avr25}. | |
23392 | These architectures mix devices with and without @code{SPH}. | |
23393 | For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25} | |
23394 | the compiler driver adds or removes this option from the compiler | |
23395 | proper's command line, because the compiler then knows if the device | |
23396 | or architecture has an 8-bit stack pointer and thus no @code{SPH} | |
23397 | register or not. | |
23398 | ||
d77de738 | 23399 | @opindex mstrict-X |
ddf6fe37 | 23400 | @item -mstrict-X |
d77de738 ML |
23401 | Use address register @code{X} in a way proposed by the hardware. This means |
23402 | that @code{X} is only used in indirect, post-increment or | |
23403 | pre-decrement addressing. | |
23404 | ||
23405 | Without this option, the @code{X} register may be used in the same way | |
23406 | as @code{Y} or @code{Z} which then is emulated by additional | |
23407 | instructions. | |
23408 | For example, loading a value with @code{X+const} addressing with a | |
23409 | small non-negative @code{const < 64} to a register @var{Rn} is | |
23410 | performed as | |
23411 | ||
23412 | @example | |
23413 | adiw r26, const ; X += const | |
23414 | ld @var{Rn}, X ; @var{Rn} = *X | |
23415 | sbiw r26, const ; X -= const | |
23416 | @end example | |
23417 | ||
d77de738 | 23418 | @opindex mtiny-stack |
ddf6fe37 | 23419 | @item -mtiny-stack |
d77de738 ML |
23420 | Only change the lower 8@tie{}bits of the stack pointer. |
23421 | ||
d77de738 | 23422 | @opindex mfract-convert-truncate |
ddf6fe37 | 23423 | @item -mfract-convert-truncate |
d77de738 ML |
23424 | Allow to use truncation instead of rounding towards zero for fractional fixed-point types. |
23425 | ||
d77de738 | 23426 | @opindex nodevicelib |
ddf6fe37 | 23427 | @item -nodevicelib |
d77de738 ML |
23428 | Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}. |
23429 | ||
d77de738 | 23430 | @opindex nodevicespecs |
ddf6fe37 | 23431 | @item -nodevicespecs |
d77de738 ML |
23432 | Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's |
23433 | command line. The user takes responsibility for supplying the sub-processes | |
23434 | like compiler proper, assembler and linker with appropriate command line | |
23435 | options. This means that the user has to supply her private device specs | |
23436 | file by means of @option{-specs=@var{path-to-specs-file}}. There is no | |
23437 | more need for option @option{-mmcu=@var{mcu}}. | |
23438 | ||
23439 | This option can also serve as a replacement for the older way of | |
23440 | specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory | |
23441 | which contains a folder named @code{device-specs} which contains a specs file named | |
23442 | @code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}. | |
23443 | ||
d77de738 ML |
23444 | @opindex Waddr-space-convert |
23445 | @opindex Wno-addr-space-convert | |
ddf6fe37 | 23446 | @item -Waddr-space-convert |
d77de738 ML |
23447 | Warn about conversions between address spaces in the case where the |
23448 | resulting address space is not contained in the incoming address space. | |
23449 | ||
d77de738 ML |
23450 | @opindex Wmisspelled-isr |
23451 | @opindex Wno-misspelled-isr | |
ddf6fe37 | 23452 | @item -Wmisspelled-isr |
d77de738 ML |
23453 | Warn if the ISR is misspelled, i.e.@: without __vector prefix. |
23454 | Enabled by default. | |
23455 | @end table | |
23456 | ||
23457 | @subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash | |
23458 | @cindex @code{EIND} | |
23459 | Pointers in the implementation are 16@tie{}bits wide. | |
23460 | The address of a function or label is represented as word address so | |
23461 | that indirect jumps and calls can target any code address in the | |
23462 | range of 64@tie{}Ki words. | |
23463 | ||
23464 | In order to facilitate indirect jump on devices with more than 128@tie{}Ki | |
23465 | bytes of program memory space, there is a special function register called | |
23466 | @code{EIND} that serves as most significant part of the target address | |
23467 | when @code{EICALL} or @code{EIJMP} instructions are used. | |
23468 | ||
23469 | Indirect jumps and calls on these devices are handled as follows by | |
23470 | the compiler and are subject to some limitations: | |
23471 | ||
23472 | @itemize @bullet | |
23473 | ||
23474 | @item | |
23475 | The compiler never sets @code{EIND}. | |
23476 | ||
23477 | @item | |
23478 | The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP} | |
23479 | instructions or might read @code{EIND} directly in order to emulate an | |
23480 | indirect call/jump by means of a @code{RET} instruction. | |
23481 | ||
23482 | @item | |
23483 | The compiler assumes that @code{EIND} never changes during the startup | |
23484 | code or during the application. In particular, @code{EIND} is not | |
23485 | saved/restored in function or interrupt service routine | |
23486 | prologue/epilogue. | |
23487 | ||
23488 | @item | |
23489 | For indirect calls to functions and computed goto, the linker | |
23490 | generates @emph{stubs}. Stubs are jump pads sometimes also called | |
23491 | @emph{trampolines}. Thus, the indirect call/jump jumps to such a stub. | |
23492 | The stub contains a direct jump to the desired address. | |
23493 | ||
23494 | @item | |
23495 | Linker relaxation must be turned on so that the linker generates | |
23496 | the stubs correctly in all situations. See the compiler option | |
23497 | @option{-mrelax} and the linker option @option{--relax}. | |
23498 | There are corner cases where the linker is supposed to generate stubs | |
23499 | but aborts without relaxation and without a helpful error message. | |
23500 | ||
23501 | @item | |
23502 | The default linker script is arranged for code with @code{EIND = 0}. | |
23503 | If code is supposed to work for a setup with @code{EIND != 0}, a custom | |
23504 | linker script has to be used in order to place the sections whose | |
23505 | name start with @code{.trampolines} into the segment where @code{EIND} | |
23506 | points to. | |
23507 | ||
23508 | @item | |
23509 | The startup code from libgcc never sets @code{EIND}. | |
23510 | Notice that startup code is a blend of code from libgcc and AVR-LibC. | |
23511 | For the impact of AVR-LibC on @code{EIND}, see the | |
a65da9be | 23512 | @w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}. |
d77de738 ML |
23513 | |
23514 | @item | |
23515 | It is legitimate for user-specific startup code to set up @code{EIND} | |
23516 | early, for example by means of initialization code located in | |
23517 | section @code{.init3}. Such code runs prior to general startup code | |
23518 | that initializes RAM and calls constructors, but after the bit | |
23519 | of startup code from AVR-LibC that sets @code{EIND} to the segment | |
23520 | where the vector table is located. | |
23521 | @example | |
23522 | #include <avr/io.h> | |
23523 | ||
23524 | static void | |
23525 | __attribute__((section(".init3"),naked,used,no_instrument_function)) | |
23526 | init3_set_eind (void) | |
23527 | @{ | |
23528 | __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t" | |
23529 | "out %i0,r24" :: "n" (&EIND) : "r24","memory"); | |
23530 | @} | |
23531 | @end example | |
23532 | ||
23533 | @noindent | |
23534 | The @code{__trampolines_start} symbol is defined in the linker script. | |
23535 | ||
23536 | @item | |
23537 | Stubs are generated automatically by the linker if | |
23538 | the following two conditions are met: | |
23539 | @itemize @minus | |
23540 | ||
23541 | @item The address of a label is taken by means of the @code{gs} modifier | |
23542 | (short for @emph{generate stubs}) like so: | |
23543 | @example | |
23544 | LDI r24, lo8(gs(@var{func})) | |
23545 | LDI r25, hi8(gs(@var{func})) | |
23546 | @end example | |
23547 | @item The final location of that label is in a code segment | |
23548 | @emph{outside} the segment where the stubs are located. | |
23549 | @end itemize | |
23550 | ||
23551 | @item | |
23552 | The compiler emits such @code{gs} modifiers for code labels in the | |
23553 | following situations: | |
23554 | @itemize @minus | |
23555 | @item Taking address of a function or code label. | |
23556 | @item Computed goto. | |
23557 | @item If prologue-save function is used, see @option{-mcall-prologues} | |
23558 | command-line option. | |
23559 | @item Switch/case dispatch tables. If you do not want such dispatch | |
23560 | tables you can specify the @option{-fno-jump-tables} command-line option. | |
23561 | @item C and C++ constructors/destructors called during startup/shutdown. | |
23562 | @item If the tools hit a @code{gs()} modifier explained above. | |
23563 | @end itemize | |
23564 | ||
23565 | @item | |
23566 | Jumping to non-symbolic addresses like so is @emph{not} supported: | |
23567 | ||
23568 | @example | |
23569 | int main (void) | |
23570 | @{ | |
23571 | /* Call function at word address 0x2 */ | |
23572 | return ((int(*)(void)) 0x2)(); | |
23573 | @} | |
23574 | @end example | |
23575 | ||
23576 | Instead, a stub has to be set up, i.e.@: the function has to be called | |
23577 | through a symbol (@code{func_4} in the example): | |
23578 | ||
23579 | @example | |
23580 | int main (void) | |
23581 | @{ | |
23582 | extern int func_4 (void); | |
23583 | ||
23584 | /* Call function at byte address 0x4 */ | |
23585 | return func_4(); | |
23586 | @} | |
23587 | @end example | |
23588 | ||
23589 | and the application be linked with @option{-Wl,--defsym,func_4=0x4}. | |
23590 | Alternatively, @code{func_4} can be defined in the linker script. | |
23591 | @end itemize | |
23592 | ||
23593 | @subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers | |
23594 | @cindex @code{RAMPD} | |
23595 | @cindex @code{RAMPX} | |
23596 | @cindex @code{RAMPY} | |
23597 | @cindex @code{RAMPZ} | |
23598 | Some AVR devices support memories larger than the 64@tie{}KiB range | |
23599 | that can be accessed with 16-bit pointers. To access memory locations | |
23600 | outside this 64@tie{}KiB range, the content of a @code{RAMP} | |
23601 | register is used as high part of the address: | |
23602 | The @code{X}, @code{Y}, @code{Z} address register is concatenated | |
23603 | with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function | |
23604 | register, respectively, to get a wide address. Similarly, | |
23605 | @code{RAMPD} is used together with direct addressing. | |
23606 | ||
23607 | @itemize | |
23608 | @item | |
23609 | The startup code initializes the @code{RAMP} special function | |
23610 | registers with zero. | |
23611 | ||
23612 | @item | |
23613 | If a @ref{AVR Named Address Spaces,named address space} other than | |
23614 | generic or @code{__flash} is used, then @code{RAMPZ} is set | |
23615 | as needed before the operation. | |
23616 | ||
23617 | @item | |
23618 | If the device supports RAM larger than 64@tie{}KiB and the compiler | |
23619 | needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ} | |
23620 | is reset to zero after the operation. | |
23621 | ||
23622 | @item | |
23623 | If the device comes with a specific @code{RAMP} register, the ISR | |
23624 | prologue/epilogue saves/restores that SFR and initializes it with | |
23625 | zero in case the ISR code might (implicitly) use it. | |
23626 | ||
23627 | @item | |
23628 | RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets. | |
23629 | If you use inline assembler to read from locations outside the | |
23630 | 16-bit address range and change one of the @code{RAMP} registers, | |
23631 | you must reset it to zero after the access. | |
23632 | ||
23633 | @end itemize | |
23634 | ||
23635 | @subsubsection AVR Built-in Macros | |
23636 | ||
23637 | GCC defines several built-in macros so that the user code can test | |
23638 | for the presence or absence of features. Almost any of the following | |
23639 | built-in macros are deduced from device capabilities and thus | |
23640 | triggered by the @option{-mmcu=} command-line option. | |
23641 | ||
23642 | For even more AVR-specific built-in macros see | |
23643 | @ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}. | |
23644 | ||
23645 | @table @code | |
23646 | ||
23647 | @item __AVR_ARCH__ | |
23648 | Build-in macro that resolves to a decimal number that identifies the | |
23649 | architecture and depends on the @option{-mmcu=@var{mcu}} option. | |
23650 | Possible values are: | |
23651 | ||
23652 | @code{2}, @code{25}, @code{3}, @code{31}, @code{35}, | |
23653 | @code{4}, @code{5}, @code{51}, @code{6} | |
23654 | ||
23655 | for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31}, | |
23656 | @code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6}, | |
23657 | ||
23658 | respectively and | |
23659 | ||
23660 | @code{100}, | |
23661 | @code{102}, @code{103}, @code{104}, | |
23662 | @code{105}, @code{106}, @code{107} | |
23663 | ||
23664 | for @var{mcu}=@code{avrtiny}, | |
23665 | @code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4}, | |
23666 | @code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively. | |
23667 | If @var{mcu} specifies a device, this built-in macro is set | |
23668 | accordingly. For example, with @option{-mmcu=atmega8} the macro is | |
23669 | defined to @code{4}. | |
23670 | ||
23671 | @item __AVR_@var{Device}__ | |
23672 | Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects | |
23673 | the device's name. For example, @option{-mmcu=atmega8} defines the | |
23674 | built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines | |
23675 | @code{__AVR_ATtiny261A__}, etc. | |
23676 | ||
23677 | The built-in macros' names follow | |
23678 | the scheme @code{__AVR_@var{Device}__} where @var{Device} is | |
23679 | the device name as from the AVR user manual. The difference between | |
23680 | @var{Device} in the built-in macro and @var{device} in | |
23681 | @option{-mmcu=@var{device}} is that the latter is always lowercase. | |
23682 | ||
23683 | If @var{device} is not a device but only a core architecture like | |
23684 | @samp{avr51}, this macro is not defined. | |
23685 | ||
23686 | @item __AVR_DEVICE_NAME__ | |
23687 | Setting @option{-mmcu=@var{device}} defines this built-in macro to | |
23688 | the device's name. For example, with @option{-mmcu=atmega8} the macro | |
23689 | is defined to @code{atmega8}. | |
23690 | ||
23691 | If @var{device} is not a device but only a core architecture like | |
23692 | @samp{avr51}, this macro is not defined. | |
23693 | ||
23694 | @item __AVR_XMEGA__ | |
23695 | The device / architecture belongs to the XMEGA family of devices. | |
23696 | ||
23697 | @item __AVR_HAVE_ELPM__ | |
23698 | The device has the @code{ELPM} instruction. | |
23699 | ||
23700 | @item __AVR_HAVE_ELPMX__ | |
23701 | The device has the @code{ELPM R@var{n},Z} and @code{ELPM | |
23702 | R@var{n},Z+} instructions. | |
23703 | ||
23704 | @item __AVR_HAVE_MOVW__ | |
23705 | The device has the @code{MOVW} instruction to perform 16-bit | |
23706 | register-register moves. | |
23707 | ||
23708 | @item __AVR_HAVE_LPMX__ | |
23709 | The device has the @code{LPM R@var{n},Z} and | |
23710 | @code{LPM R@var{n},Z+} instructions. | |
23711 | ||
23712 | @item __AVR_HAVE_MUL__ | |
23713 | The device has a hardware multiplier. | |
23714 | ||
23715 | @item __AVR_HAVE_JMP_CALL__ | |
23716 | The device has the @code{JMP} and @code{CALL} instructions. | |
23717 | This is the case for devices with more than 8@tie{}KiB of program | |
23718 | memory. | |
23719 | ||
23720 | @item __AVR_HAVE_EIJMP_EICALL__ | |
23721 | @itemx __AVR_3_BYTE_PC__ | |
23722 | The device has the @code{EIJMP} and @code{EICALL} instructions. | |
23723 | This is the case for devices with more than 128@tie{}KiB of program memory. | |
23724 | This also means that the program counter | |
23725 | (PC) is 3@tie{}bytes wide. | |
23726 | ||
23727 | @item __AVR_2_BYTE_PC__ | |
23728 | The program counter (PC) is 2@tie{}bytes wide. This is the case for devices | |
23729 | with up to 128@tie{}KiB of program memory. | |
23730 | ||
23731 | @item __AVR_HAVE_8BIT_SP__ | |
23732 | @itemx __AVR_HAVE_16BIT_SP__ | |
23733 | The stack pointer (SP) register is treated as 8-bit respectively | |
23734 | 16-bit register by the compiler. | |
23735 | The definition of these macros is affected by @option{-mtiny-stack}. | |
23736 | ||
23737 | @item __AVR_HAVE_SPH__ | |
23738 | @itemx __AVR_SP8__ | |
23739 | The device has the SPH (high part of stack pointer) special function | |
23740 | register or has an 8-bit stack pointer, respectively. | |
23741 | The definition of these macros is affected by @option{-mmcu=} and | |
23742 | in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also | |
23743 | by @option{-msp8}. | |
23744 | ||
23745 | @item __AVR_HAVE_RAMPD__ | |
23746 | @itemx __AVR_HAVE_RAMPX__ | |
23747 | @itemx __AVR_HAVE_RAMPY__ | |
23748 | @itemx __AVR_HAVE_RAMPZ__ | |
23749 | The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY}, | |
23750 | @code{RAMPZ} special function register, respectively. | |
23751 | ||
23752 | @item __NO_INTERRUPTS__ | |
23753 | This macro reflects the @option{-mno-interrupts} command-line option. | |
23754 | ||
23755 | @item __AVR_ERRATA_SKIP__ | |
23756 | @itemx __AVR_ERRATA_SKIP_JMP_CALL__ | |
23757 | Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit | |
23758 | instructions because of a hardware erratum. Skip instructions are | |
23759 | @code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}. | |
23760 | The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also | |
23761 | set. | |
23762 | ||
23763 | @item __AVR_ISA_RMW__ | |
23764 | The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT). | |
23765 | ||
23766 | @item __AVR_SFR_OFFSET__=@var{offset} | |
23767 | Instructions that can address I/O special function registers directly | |
23768 | like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different | |
23769 | address as if addressed by an instruction to access RAM like @code{LD} | |
23770 | or @code{STS}. This offset depends on the device architecture and has | |
23771 | to be subtracted from the RAM address in order to get the | |
23772 | respective I/O@tie{}address. | |
23773 | ||
23774 | @item __AVR_SHORT_CALLS__ | |
23775 | The @option{-mshort-calls} command line option is set. | |
23776 | ||
23777 | @item __AVR_PM_BASE_ADDRESS__=@var{addr} | |
23778 | Some devices support reading from flash memory by means of @code{LD*} | |
23779 | instructions. The flash memory is seen in the data address space | |
23780 | at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro | |
23781 | is not defined, this feature is not available. If defined, | |
23782 | the address space is linear and there is no need to put | |
23783 | @code{.rodata} into RAM. This is handled by the default linker | |
23784 | description file, and is currently available for | |
23785 | @code{avrtiny} and @code{avrxmega3}. Even more convenient, | |
23786 | there is no need to use address spaces like @code{__flash} or | |
23787 | features like attribute @code{progmem} and @code{pgm_read_*}. | |
23788 | ||
23789 | @item __WITH_AVRLIBC__ | |
23790 | The compiler is configured to be used together with AVR-Libc. | |
23791 | See the @option{--with-avrlibc} configure option. | |
23792 | ||
23793 | @item __HAVE_DOUBLE_MULTILIB__ | |
23794 | Defined if @option{-mdouble=} acts as a multilib option. | |
23795 | ||
23796 | @item __HAVE_DOUBLE32__ | |
23797 | @itemx __HAVE_DOUBLE64__ | |
23798 | Defined if the compiler supports 32-bit double resp. 64-bit double. | |
23799 | The actual layout is specified by option @option{-mdouble=}. | |
23800 | ||
23801 | @item __DEFAULT_DOUBLE__ | |
23802 | The size in bits of @code{double} if @option{-mdouble=} is not set. | |
23803 | To test the layout of @code{double} in a program, use the built-in | |
23804 | macro @code{__SIZEOF_DOUBLE__}. | |
23805 | ||
23806 | @item __HAVE_LONG_DOUBLE32__ | |
23807 | @itemx __HAVE_LONG_DOUBLE64__ | |
23808 | @itemx __HAVE_LONG_DOUBLE_MULTILIB__ | |
23809 | @itemx __DEFAULT_LONG_DOUBLE__ | |
23810 | Same as above, but for @code{long double} instead of @code{double}. | |
23811 | ||
23812 | @item __WITH_DOUBLE_COMPARISON__ | |
23813 | Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}} | |
23814 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}} | |
23815 | and is defined to @code{2} or @code{3}. | |
23816 | ||
23817 | @item __WITH_LIBF7_LIBGCC__ | |
23818 | @itemx __WITH_LIBF7_MATH__ | |
23819 | @itemx __WITH_LIBF7_MATH_SYMBOLS__ | |
23820 | Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}} | |
23821 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}. | |
23822 | ||
23823 | @end table | |
23824 | ||
23825 | @node Blackfin Options | |
23826 | @subsection Blackfin Options | |
23827 | @cindex Blackfin Options | |
23828 | ||
23829 | @table @gcctabopt | |
d77de738 | 23830 | @opindex mcpu= |
ddf6fe37 | 23831 | @item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} |
d77de738 ML |
23832 | Specifies the name of the target Blackfin processor. Currently, @var{cpu} |
23833 | can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518}, | |
23834 | @samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526}, | |
23835 | @samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533}, | |
23836 | @samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539}, | |
23837 | @samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549}, | |
23838 | @samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m}, | |
23839 | @samp{bf561}, @samp{bf592}. | |
23840 | ||
23841 | The optional @var{sirevision} specifies the silicon revision of the target | |
23842 | Blackfin processor. Any workarounds available for the targeted silicon revision | |
23843 | are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled. | |
23844 | If @var{sirevision} is @samp{any}, all workarounds for the targeted processor | |
23845 | are enabled. The @code{__SILICON_REVISION__} macro is defined to two | |
23846 | hexadecimal digits representing the major and minor numbers in the silicon | |
23847 | revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__} | |
23848 | is not defined. If @var{sirevision} is @samp{any}, the | |
23849 | @code{__SILICON_REVISION__} is defined to be @code{0xffff}. | |
23850 | If this optional @var{sirevision} is not used, GCC assumes the latest known | |
23851 | silicon revision of the targeted Blackfin processor. | |
23852 | ||
23853 | GCC defines a preprocessor macro for the specified @var{cpu}. | |
23854 | For the @samp{bfin-elf} toolchain, this option causes the hardware BSP | |
23855 | provided by libgloss to be linked in if @option{-msim} is not given. | |
23856 | ||
23857 | Without this option, @samp{bf532} is used as the processor by default. | |
23858 | ||
23859 | Note that support for @samp{bf561} is incomplete. For @samp{bf561}, | |
23860 | only the preprocessor macro is defined. | |
23861 | ||
d77de738 | 23862 | @opindex msim |
ddf6fe37 | 23863 | @item -msim |
d77de738 ML |
23864 | Specifies that the program will be run on the simulator. This causes |
23865 | the simulator BSP provided by libgloss to be linked in. This option | |
23866 | has effect only for @samp{bfin-elf} toolchain. | |
23867 | Certain other options, such as @option{-mid-shared-library} and | |
23868 | @option{-mfdpic}, imply @option{-msim}. | |
23869 | ||
d77de738 | 23870 | @opindex momit-leaf-frame-pointer |
ddf6fe37 | 23871 | @item -momit-leaf-frame-pointer |
d77de738 ML |
23872 | Don't keep the frame pointer in a register for leaf functions. This |
23873 | avoids the instructions to save, set up and restore frame pointers and | |
23874 | makes an extra register available in leaf functions. | |
23875 | ||
d77de738 | 23876 | @opindex mspecld-anomaly |
ddf6fe37 | 23877 | @item -mspecld-anomaly |
d77de738 ML |
23878 | When enabled, the compiler ensures that the generated code does not |
23879 | contain speculative loads after jump instructions. If this option is used, | |
23880 | @code{__WORKAROUND_SPECULATIVE_LOADS} is defined. | |
23881 | ||
d77de738 ML |
23882 | @opindex mno-specld-anomaly |
23883 | @opindex mspecld-anomaly | |
ddf6fe37 | 23884 | @item -mno-specld-anomaly |
d77de738 ML |
23885 | Don't generate extra code to prevent speculative loads from occurring. |
23886 | ||
d77de738 | 23887 | @opindex mcsync-anomaly |
ddf6fe37 | 23888 | @item -mcsync-anomaly |
d77de738 ML |
23889 | When enabled, the compiler ensures that the generated code does not |
23890 | contain CSYNC or SSYNC instructions too soon after conditional branches. | |
23891 | If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined. | |
23892 | ||
d77de738 ML |
23893 | @opindex mno-csync-anomaly |
23894 | @opindex mcsync-anomaly | |
ddf6fe37 | 23895 | @item -mno-csync-anomaly |
d77de738 ML |
23896 | Don't generate extra code to prevent CSYNC or SSYNC instructions from |
23897 | occurring too soon after a conditional branch. | |
23898 | ||
d77de738 | 23899 | @opindex mlow64k |
ddf6fe37 | 23900 | @item -mlow64k |
d77de738 ML |
23901 | When enabled, the compiler is free to take advantage of the knowledge that |
23902 | the entire program fits into the low 64k of memory. | |
23903 | ||
d77de738 | 23904 | @opindex mno-low64k |
ddf6fe37 | 23905 | @item -mno-low64k |
d77de738 ML |
23906 | Assume that the program is arbitrarily large. This is the default. |
23907 | ||
d77de738 | 23908 | @opindex mstack-check-l1 |
ddf6fe37 | 23909 | @item -mstack-check-l1 |
d77de738 ML |
23910 | Do stack checking using information placed into L1 scratchpad memory by the |
23911 | uClinux kernel. | |
23912 | ||
d77de738 | 23913 | @opindex mid-shared-library |
ddf6fe37 | 23914 | @item -mid-shared-library |
d77de738 ML |
23915 | Generate code that supports shared libraries via the library ID method. |
23916 | This allows for execute in place and shared libraries in an environment | |
23917 | without virtual memory management. This option implies @option{-fPIC}. | |
23918 | With a @samp{bfin-elf} target, this option implies @option{-msim}. | |
23919 | ||
d77de738 ML |
23920 | @opindex mno-id-shared-library |
23921 | @opindex mid-shared-library | |
ddf6fe37 | 23922 | @item -mno-id-shared-library |
d77de738 ML |
23923 | Generate code that doesn't assume ID-based shared libraries are being used. |
23924 | This is the default. | |
23925 | ||
d77de738 | 23926 | @opindex mleaf-id-shared-library |
ddf6fe37 | 23927 | @item -mleaf-id-shared-library |
d77de738 ML |
23928 | Generate code that supports shared libraries via the library ID method, |
23929 | but assumes that this library or executable won't link against any other | |
23930 | ID shared libraries. That allows the compiler to use faster code for jumps | |
23931 | and calls. | |
23932 | ||
d77de738 ML |
23933 | @opindex mno-leaf-id-shared-library |
23934 | @opindex mleaf-id-shared-library | |
ddf6fe37 | 23935 | @item -mno-leaf-id-shared-library |
d77de738 ML |
23936 | Do not assume that the code being compiled won't link against any ID shared |
23937 | libraries. Slower code is generated for jump and call insns. | |
23938 | ||
d77de738 | 23939 | @opindex mshared-library-id |
ddf6fe37 | 23940 | @item -mshared-library-id=n |
d77de738 ML |
23941 | Specifies the identification number of the ID-based shared library being |
23942 | compiled. Specifying a value of 0 generates more compact code; specifying | |
23943 | other values forces the allocation of that number to the current | |
23944 | library but is no more space- or time-efficient than omitting this option. | |
23945 | ||
d77de738 | 23946 | @opindex msep-data |
ddf6fe37 | 23947 | @item -msep-data |
d77de738 ML |
23948 | Generate code that allows the data segment to be located in a different |
23949 | area of memory from the text segment. This allows for execute in place in | |
23950 | an environment without virtual memory management by eliminating relocations | |
23951 | against the text section. | |
23952 | ||
d77de738 ML |
23953 | @opindex mno-sep-data |
23954 | @opindex msep-data | |
ddf6fe37 | 23955 | @item -mno-sep-data |
d77de738 ML |
23956 | Generate code that assumes that the data segment follows the text segment. |
23957 | This is the default. | |
23958 | ||
d77de738 ML |
23959 | @opindex mlong-calls |
23960 | @opindex mno-long-calls | |
ddf6fe37 AA |
23961 | @item -mlong-calls |
23962 | @itemx -mno-long-calls | |
d77de738 ML |
23963 | Tells the compiler to perform function calls by first loading the |
23964 | address of the function into a register and then performing a subroutine | |
23965 | call on this register. This switch is needed if the target function | |
23966 | lies outside of the 24-bit addressing range of the offset-based | |
23967 | version of subroutine call instruction. | |
23968 | ||
23969 | This feature is not enabled by default. Specifying | |
23970 | @option{-mno-long-calls} restores the default behavior. Note these | |
23971 | switches have no effect on how the compiler generates code to handle | |
23972 | function calls via function pointers. | |
23973 | ||
d77de738 | 23974 | @opindex mfast-fp |
ddf6fe37 | 23975 | @item -mfast-fp |
d77de738 ML |
23976 | Link with the fast floating-point library. This library relaxes some of |
23977 | the IEEE floating-point standard's rules for checking inputs against | |
23978 | Not-a-Number (NAN), in the interest of performance. | |
23979 | ||
d77de738 | 23980 | @opindex minline-plt |
ddf6fe37 | 23981 | @item -minline-plt |
d77de738 ML |
23982 | Enable inlining of PLT entries in function calls to functions that are |
23983 | not known to bind locally. It has no effect without @option{-mfdpic}. | |
23984 | ||
d77de738 | 23985 | @opindex mmulticore |
ddf6fe37 | 23986 | @item -mmulticore |
d77de738 ML |
23987 | Build a standalone application for multicore Blackfin processors. |
23988 | This option causes proper start files and link scripts supporting | |
23989 | multicore to be used, and defines the macro @code{__BFIN_MULTICORE}. | |
23990 | It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}. | |
23991 | ||
23992 | This option can be used with @option{-mcorea} or @option{-mcoreb}, which | |
23993 | selects the one-application-per-core programming model. Without | |
23994 | @option{-mcorea} or @option{-mcoreb}, the single-application/dual-core | |
23995 | programming model is used. In this model, the main function of Core B | |
23996 | should be named as @code{coreb_main}. | |
23997 | ||
23998 | If this option is not used, the single-core application programming | |
23999 | model is used. | |
24000 | ||
d77de738 | 24001 | @opindex mcorea |
ddf6fe37 | 24002 | @item -mcorea |
d77de738 ML |
24003 | Build a standalone application for Core A of BF561 when using |
24004 | the one-application-per-core programming model. Proper start files | |
24005 | and link scripts are used to support Core A, and the macro | |
24006 | @code{__BFIN_COREA} is defined. | |
24007 | This option can only be used in conjunction with @option{-mmulticore}. | |
24008 | ||
d77de738 | 24009 | @opindex mcoreb |
ddf6fe37 | 24010 | @item -mcoreb |
d77de738 ML |
24011 | Build a standalone application for Core B of BF561 when using |
24012 | the one-application-per-core programming model. Proper start files | |
24013 | and link scripts are used to support Core B, and the macro | |
24014 | @code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main} | |
24015 | should be used instead of @code{main}. | |
24016 | This option can only be used in conjunction with @option{-mmulticore}. | |
24017 | ||
d77de738 | 24018 | @opindex msdram |
ddf6fe37 | 24019 | @item -msdram |
d77de738 ML |
24020 | Build a standalone application for SDRAM. Proper start files and |
24021 | link scripts are used to put the application into SDRAM, and the macro | |
24022 | @code{__BFIN_SDRAM} is defined. | |
24023 | The loader should initialize SDRAM before loading the application. | |
24024 | ||
d77de738 | 24025 | @opindex micplb |
ddf6fe37 | 24026 | @item -micplb |
d77de738 ML |
24027 | Assume that ICPLBs are enabled at run time. This has an effect on certain |
24028 | anomaly workarounds. For Linux targets, the default is to assume ICPLBs | |
24029 | are enabled; for standalone applications the default is off. | |
24030 | @end table | |
24031 | ||
24032 | @node C6X Options | |
24033 | @subsection C6X Options | |
24034 | @cindex C6X Options | |
24035 | ||
24036 | @table @gcctabopt | |
d77de738 | 24037 | @opindex march |
ddf6fe37 | 24038 | @item -march=@var{name} |
d77de738 ML |
24039 | This specifies the name of the target architecture. GCC uses this |
24040 | name to determine what kind of instructions it can emit when generating | |
24041 | assembly code. Permissible names are: @samp{c62x}, | |
24042 | @samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}. | |
24043 | ||
d77de738 | 24044 | @opindex mbig-endian |
ddf6fe37 | 24045 | @item -mbig-endian |
d77de738 ML |
24046 | Generate code for a big-endian target. |
24047 | ||
d77de738 | 24048 | @opindex mlittle-endian |
ddf6fe37 | 24049 | @item -mlittle-endian |
d77de738 ML |
24050 | Generate code for a little-endian target. This is the default. |
24051 | ||
d77de738 | 24052 | @opindex msim |
ddf6fe37 | 24053 | @item -msim |
d77de738 ML |
24054 | Choose startup files and linker script suitable for the simulator. |
24055 | ||
d77de738 | 24056 | @opindex msdata=default |
ddf6fe37 | 24057 | @item -msdata=default |
d77de738 ML |
24058 | Put small global and static data in the @code{.neardata} section, |
24059 | which is pointed to by register @code{B14}. Put small uninitialized | |
24060 | global and static data in the @code{.bss} section, which is adjacent | |
24061 | to the @code{.neardata} section. Put small read-only data into the | |
24062 | @code{.rodata} section. The corresponding sections used for large | |
24063 | pieces of data are @code{.fardata}, @code{.far} and @code{.const}. | |
24064 | ||
d77de738 | 24065 | @opindex msdata=all |
ddf6fe37 | 24066 | @item -msdata=all |
d77de738 ML |
24067 | Put all data, not just small objects, into the sections reserved for |
24068 | small data, and use addressing relative to the @code{B14} register to | |
24069 | access them. | |
24070 | ||
d77de738 | 24071 | @opindex msdata=none |
ddf6fe37 | 24072 | @item -msdata=none |
d77de738 ML |
24073 | Make no use of the sections reserved for small data, and use absolute |
24074 | addresses to access all data. Put all initialized global and static | |
24075 | data in the @code{.fardata} section, and all uninitialized data in the | |
24076 | @code{.far} section. Put all constant data into the @code{.const} | |
24077 | section. | |
24078 | @end table | |
24079 | ||
24080 | @node CRIS Options | |
24081 | @subsection CRIS Options | |
24082 | @cindex CRIS Options | |
24083 | ||
24084 | These options are defined specifically for the CRIS ports. | |
24085 | ||
24086 | @table @gcctabopt | |
d77de738 ML |
24087 | @opindex march |
24088 | @opindex mcpu | |
ddf6fe37 AA |
24089 | @item -march=@var{architecture-type} |
24090 | @itemx -mcpu=@var{architecture-type} | |
d77de738 ML |
24091 | Generate code for the specified architecture. The choices for |
24092 | @var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for | |
24093 | respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@. | |
24094 | Default is @samp{v0}. | |
24095 | ||
d77de738 | 24096 | @opindex mtune |
ddf6fe37 | 24097 | @item -mtune=@var{architecture-type} |
d77de738 ML |
24098 | Tune to @var{architecture-type} everything applicable about the generated |
24099 | code, except for the ABI and the set of available instructions. The | |
24100 | choices for @var{architecture-type} are the same as for | |
24101 | @option{-march=@var{architecture-type}}. | |
24102 | ||
d77de738 | 24103 | @opindex mmax-stack-frame |
ddf6fe37 | 24104 | @item -mmax-stack-frame=@var{n} |
d77de738 ML |
24105 | Warn when the stack frame of a function exceeds @var{n} bytes. |
24106 | ||
d77de738 ML |
24107 | @opindex metrax4 |
24108 | @opindex metrax100 | |
ddf6fe37 AA |
24109 | @item -metrax4 |
24110 | @itemx -metrax100 | |
d77de738 ML |
24111 | The options @option{-metrax4} and @option{-metrax100} are synonyms for |
24112 | @option{-march=v3} and @option{-march=v8} respectively. | |
24113 | ||
d77de738 ML |
24114 | @opindex mmul-bug-workaround |
24115 | @opindex mno-mul-bug-workaround | |
ddf6fe37 AA |
24116 | @item -mmul-bug-workaround |
24117 | @itemx -mno-mul-bug-workaround | |
d77de738 ML |
24118 | Work around a bug in the @code{muls} and @code{mulu} instructions for CPU |
24119 | models where it applies. This option is disabled by default. | |
24120 | ||
d77de738 | 24121 | @opindex mpdebug |
ddf6fe37 | 24122 | @item -mpdebug |
d77de738 ML |
24123 | Enable CRIS-specific verbose debug-related information in the assembly |
24124 | code. This option also has the effect of turning off the @samp{#NO_APP} | |
24125 | formatted-code indicator to the assembler at the beginning of the | |
24126 | assembly file. | |
24127 | ||
d77de738 | 24128 | @opindex mcc-init |
ddf6fe37 | 24129 | @item -mcc-init |
d77de738 ML |
24130 | Do not use condition-code results from previous instruction; always emit |
24131 | compare and test instructions before use of condition codes. | |
24132 | ||
d77de738 ML |
24133 | @opindex mno-side-effects |
24134 | @opindex mside-effects | |
ddf6fe37 | 24135 | @item -mno-side-effects |
d77de738 ML |
24136 | Do not emit instructions with side effects in addressing modes other than |
24137 | post-increment. | |
24138 | ||
d77de738 ML |
24139 | @opindex mstack-align |
24140 | @opindex mno-stack-align | |
24141 | @opindex mdata-align | |
24142 | @opindex mno-data-align | |
24143 | @opindex mconst-align | |
24144 | @opindex mno-const-align | |
ddf6fe37 AA |
24145 | @item -mstack-align |
24146 | @itemx -mno-stack-align | |
24147 | @itemx -mdata-align | |
24148 | @itemx -mno-data-align | |
24149 | @itemx -mconst-align | |
24150 | @itemx -mno-const-align | |
d77de738 ML |
24151 | These options (@samp{no-} options) arrange (eliminate arrangements) for the |
24152 | stack frame, individual data and constants to be aligned for the maximum | |
24153 | single data access size for the chosen CPU model. The default is to | |
24154 | arrange for 32-bit alignment. ABI details such as structure layout are | |
24155 | not affected by these options. | |
24156 | ||
d77de738 ML |
24157 | @opindex m32-bit |
24158 | @opindex m16-bit | |
24159 | @opindex m8-bit | |
ddf6fe37 AA |
24160 | @item -m32-bit |
24161 | @itemx -m16-bit | |
24162 | @itemx -m8-bit | |
d77de738 ML |
24163 | Similar to the stack- data- and const-align options above, these options |
24164 | arrange for stack frame, writable data and constants to all be 32-bit, | |
24165 | 16-bit or 8-bit aligned. The default is 32-bit alignment. | |
24166 | ||
d77de738 ML |
24167 | @opindex mno-prologue-epilogue |
24168 | @opindex mprologue-epilogue | |
ddf6fe37 AA |
24169 | @item -mno-prologue-epilogue |
24170 | @itemx -mprologue-epilogue | |
d77de738 ML |
24171 | With @option{-mno-prologue-epilogue}, the normal function prologue and |
24172 | epilogue which set up the stack frame are omitted and no return | |
24173 | instructions or return sequences are generated in the code. Use this | |
24174 | option only together with visual inspection of the compiled code: no | |
24175 | warnings or errors are generated when call-saved registers must be saved, | |
24176 | or storage for local variables needs to be allocated. | |
24177 | ||
d77de738 | 24178 | @opindex melf |
ddf6fe37 | 24179 | @item -melf |
d77de738 ML |
24180 | Legacy no-op option. |
24181 | ||
d77de738 | 24182 | @opindex sim |
ddf6fe37 | 24183 | @item -sim |
d77de738 ML |
24184 | This option arranges |
24185 | to link with input-output functions from a simulator library. Code, | |
24186 | initialized data and zero-initialized data are allocated consecutively. | |
24187 | ||
d77de738 | 24188 | @opindex sim2 |
ddf6fe37 | 24189 | @item -sim2 |
d77de738 ML |
24190 | Like @option{-sim}, but pass linker options to locate initialized data at |
24191 | 0x40000000 and zero-initialized data at 0x80000000. | |
24192 | @end table | |
24193 | ||
24194 | @node C-SKY Options | |
24195 | @subsection C-SKY Options | |
24196 | @cindex C-SKY Options | |
24197 | ||
24198 | GCC supports these options when compiling for C-SKY V2 processors. | |
24199 | ||
24200 | @table @gcctabopt | |
24201 | ||
d77de738 | 24202 | @opindex march= |
ddf6fe37 | 24203 | @item -march=@var{arch} |
d77de738 ML |
24204 | Specify the C-SKY target architecture. Valid values for @var{arch} are: |
24205 | @samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}. | |
24206 | The default is @samp{ck810}. | |
24207 | ||
d77de738 | 24208 | @opindex mcpu= |
ddf6fe37 | 24209 | @item -mcpu=@var{cpu} |
d77de738 ML |
24210 | Specify the C-SKY target processor. Valid values for @var{cpu} are: |
24211 | @samp{ck801}, @samp{ck801t}, | |
24212 | @samp{ck802}, @samp{ck802t}, @samp{ck802j}, | |
24213 | @samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht}, | |
24214 | @samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh}, | |
24215 | @samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh}, | |
24216 | @samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1}, | |
24217 | @samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1}, | |
24218 | @samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1}, | |
24219 | @samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1}, | |
24220 | @samp{ck803eftr1}, @samp{ck803efhtr1}, | |
24221 | @samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf}, | |
24222 | @samp{ck803sef}, @samp{ck803seft}, | |
24223 | @samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f}, | |
24224 | @samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft}, | |
24225 | @samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv}, | |
24226 | @samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}. | |
24227 | ||
d77de738 | 24228 | @opindex mbig-endian |
d77de738 | 24229 | @opindex EB |
d77de738 | 24230 | @opindex mlittle-endian |
d77de738 | 24231 | @opindex EL |
ddf6fe37 AA |
24232 | @item -mbig-endian |
24233 | @itemx -EB | |
24234 | @itemx -mlittle-endian | |
24235 | @itemx -EL | |
d77de738 ML |
24236 | |
24237 | Select big- or little-endian code. The default is little-endian. | |
24238 | ||
d77de738 | 24239 | @opindex mfloat-abi |
ddf6fe37 | 24240 | @item -mfloat-abi=@var{name} |
d77de738 ML |
24241 | Specifies which floating-point ABI to use. Permissible values |
24242 | are: @samp{soft}, @samp{softfp} and @samp{hard}. | |
24243 | ||
24244 | Specifying @samp{soft} causes GCC to generate output containing | |
24245 | library calls for floating-point operations. | |
24246 | @samp{softfp} allows the generation of code using hardware floating-point | |
24247 | instructions, but still uses the soft-float calling conventions. | |
24248 | @samp{hard} allows generation of floating-point instructions | |
24249 | and uses FPU-specific calling conventions. | |
24250 | ||
24251 | The default depends on the specific target configuration. Note that | |
24252 | the hard-float and soft-float ABIs are not link-compatible; you must | |
24253 | compile your entire program with the same ABI, and link with a | |
24254 | compatible set of libraries. | |
24255 | ||
d77de738 | 24256 | @opindex mhard-float |
d77de738 | 24257 | @opindex msoft-float |
ddf6fe37 AA |
24258 | @item -mhard-float |
24259 | @itemx -msoft-float | |
d77de738 ML |
24260 | |
24261 | Select hardware or software floating-point implementations. | |
24262 | The default is soft float. | |
24263 | ||
ddf6fe37 | 24264 | @opindex mdouble-float |
d77de738 ML |
24265 | @item -mdouble-float |
24266 | @itemx -mno-double-float | |
d77de738 ML |
24267 | When @option{-mhard-float} is in effect, enable generation of |
24268 | double-precision float instructions. This is the default except | |
24269 | when compiling for CK803. | |
24270 | ||
ddf6fe37 | 24271 | @opindex mfdivdu |
d77de738 ML |
24272 | @item -mfdivdu |
24273 | @itemx -mno-fdivdu | |
d77de738 ML |
24274 | When @option{-mhard-float} is in effect, enable generation of |
24275 | @code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions. | |
24276 | This is the default except when compiling for CK803. | |
24277 | ||
d77de738 | 24278 | @opindex mfpu= |
ddf6fe37 | 24279 | @item -mfpu=@var{fpu} |
d77de738 ML |
24280 | Select the floating-point processor. This option can only be used with |
24281 | @option{-mhard-float}. | |
24282 | Values for @var{fpu} are | |
24283 | @samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}), | |
24284 | @samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and | |
24285 | @samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}). | |
24286 | ||
ddf6fe37 | 24287 | @opindex melrw |
d77de738 ML |
24288 | @item -melrw |
24289 | @itemx -mno-elrw | |
d77de738 ML |
24290 | Enable the extended @code{lrw} instruction. This option defaults to on |
24291 | for CK801 and off otherwise. | |
24292 | ||
ddf6fe37 | 24293 | @opindex mistack |
d77de738 ML |
24294 | @item -mistack |
24295 | @itemx -mno-istack | |
d77de738 ML |
24296 | Enable interrupt stack instructions; the default is off. |
24297 | ||
24298 | The @option{-mistack} option is required to handle the | |
24299 | @code{interrupt} and @code{isr} function attributes | |
24300 | (@pxref{C-SKY Function Attributes}). | |
24301 | ||
d77de738 | 24302 | @opindex mmp |
ddf6fe37 | 24303 | @item -mmp |
d77de738 ML |
24304 | Enable multiprocessor instructions; the default is off. |
24305 | ||
d77de738 | 24306 | @opindex mcp |
ddf6fe37 | 24307 | @item -mcp |
d77de738 ML |
24308 | Enable coprocessor instructions; the default is off. |
24309 | ||
d77de738 | 24310 | @opindex mcache |
ddf6fe37 | 24311 | @item -mcache |
d77de738 ML |
24312 | Enable coprocessor instructions; the default is off. |
24313 | ||
d77de738 | 24314 | @opindex msecurity |
ddf6fe37 | 24315 | @item -msecurity |
d77de738 ML |
24316 | Enable C-SKY security instructions; the default is off. |
24317 | ||
d77de738 | 24318 | @opindex mtrust |
ddf6fe37 | 24319 | @item -mtrust |
d77de738 ML |
24320 | Enable C-SKY trust instructions; the default is off. |
24321 | ||
d77de738 | 24322 | @opindex mdsp |
d77de738 | 24323 | @opindex medsp |
d77de738 | 24324 | @opindex mvdsp |
ddf6fe37 AA |
24325 | @item -mdsp |
24326 | @itemx -medsp | |
24327 | @itemx -mvdsp | |
d77de738 ML |
24328 | Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively. |
24329 | All of these options default to off. | |
24330 | ||
ddf6fe37 | 24331 | @opindex mdiv |
d77de738 ML |
24332 | @item -mdiv |
24333 | @itemx -mno-div | |
d77de738 ML |
24334 | Generate divide instructions. Default is off. |
24335 | ||
ddf6fe37 | 24336 | @opindex msmart |
d77de738 ML |
24337 | @item -msmart |
24338 | @itemx -mno-smart | |
d77de738 ML |
24339 | Generate code for Smart Mode, using only registers numbered 0-7 to allow |
24340 | use of 16-bit instructions. This option is ignored for CK801 where this | |
24341 | is the required behavior, and it defaults to on for CK802. | |
24342 | For other targets, the default is off. | |
24343 | ||
ddf6fe37 | 24344 | @opindex mhigh-registers |
d77de738 ML |
24345 | @item -mhigh-registers |
24346 | @itemx -mno-high-registers | |
d77de738 ML |
24347 | Generate code using the high registers numbered 16-31. This option |
24348 | is not supported on CK801, CK802, or CK803, and is enabled by default | |
24349 | for other processors. | |
24350 | ||
ddf6fe37 | 24351 | @opindex manchor |
d77de738 ML |
24352 | @item -manchor |
24353 | @itemx -mno-anchor | |
d77de738 ML |
24354 | Generate code using global anchor symbol addresses. |
24355 | ||
ddf6fe37 | 24356 | @opindex mpushpop |
d77de738 ML |
24357 | @item -mpushpop |
24358 | @itemx -mno-pushpop | |
d77de738 ML |
24359 | Generate code using @code{push} and @code{pop} instructions. This option |
24360 | defaults to on. | |
24361 | ||
ddf6fe37 | 24362 | @opindex mmultiple-stld |
d77de738 ML |
24363 | @item -mmultiple-stld |
24364 | @itemx -mstm | |
24365 | @itemx -mno-multiple-stld | |
24366 | @itemx -mno-stm | |
d77de738 ML |
24367 | Generate code using @code{stm} and @code{ldm} instructions. This option |
24368 | isn't supported on CK801 but is enabled by default on other processors. | |
24369 | ||
ddf6fe37 | 24370 | @opindex mconstpool |
d77de738 ML |
24371 | @item -mconstpool |
24372 | @itemx -mno-constpool | |
d77de738 ML |
24373 | Create constant pools in the compiler instead of deferring it to the |
24374 | assembler. This option is the default and required for correct code | |
24375 | generation on CK801 and CK802, and is optional on other processors. | |
24376 | ||
ddf6fe37 | 24377 | @opindex mstack-size |
d77de738 ML |
24378 | @item -mstack-size |
24379 | @item -mno-stack-size | |
d77de738 ML |
24380 | Emit @code{.stack_size} directives for each function in the assembly |
24381 | output. This option defaults to off. | |
24382 | ||
ddf6fe37 | 24383 | @opindex mccrt |
d77de738 ML |
24384 | @item -mccrt |
24385 | @itemx -mno-ccrt | |
d77de738 ML |
24386 | Generate code for the C-SKY compiler runtime instead of libgcc. This |
24387 | option defaults to off. | |
24388 | ||
d77de738 | 24389 | @opindex mbranch-cost= |
ddf6fe37 | 24390 | @item -mbranch-cost=@var{n} |
d77de738 ML |
24391 | Set the branch costs to roughly @code{n} instructions. The default is 1. |
24392 | ||
ddf6fe37 | 24393 | @opindex msched-prolog |
d77de738 ML |
24394 | @item -msched-prolog |
24395 | @itemx -mno-sched-prolog | |
d77de738 ML |
24396 | Permit scheduling of function prologue and epilogue sequences. Using |
24397 | this option can result in code that is not compliant with the C-SKY V2 ABI | |
24398 | prologue requirements and that cannot be debugged or backtraced. | |
24399 | It is disabled by default. | |
24400 | ||
d77de738 | 24401 | @opindex msim |
ddf6fe37 | 24402 | @item -msim |
d77de738 ML |
24403 | Links the library libsemi.a which is in compatible with simulator. Applicable |
24404 | to ELF compiler only. | |
24405 | ||
24406 | @end table | |
24407 | ||
24408 | @node Darwin Options | |
24409 | @subsection Darwin Options | |
24410 | @cindex Darwin options | |
24411 | ||
24412 | These options are defined for all architectures running the Darwin operating | |
24413 | system. | |
24414 | ||
24415 | FSF GCC on Darwin does not create ``fat'' object files; it creates | |
24416 | an object file for the single architecture that GCC was built to | |
24417 | target. Apple's GCC on Darwin does create ``fat'' files if multiple | |
24418 | @option{-arch} options are used; it does so by running the compiler or | |
24419 | linker multiple times and joining the results together with | |
24420 | @file{lipo}. | |
24421 | ||
24422 | The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or | |
24423 | @samp{i686}) is determined by the flags that specify the ISA | |
24424 | that GCC is targeting, like @option{-mcpu} or @option{-march}. The | |
24425 | @option{-force_cpusubtype_ALL} option can be used to override this. | |
24426 | ||
24427 | The Darwin tools vary in their behavior when presented with an ISA | |
24428 | mismatch. The assembler, @file{as}, only permits instructions to | |
24429 | be used that are valid for the subtype of the file it is generating, | |
24430 | so you cannot put 64-bit instructions in a @samp{ppc750} object file. | |
24431 | The linker for shared libraries, @file{/usr/bin/libtool}, fails | |
24432 | and prints an error if asked to create a shared library with a less | |
24433 | restrictive subtype than its input files (for instance, trying to put | |
24434 | a @samp{ppc970} object file in a @samp{ppc7400} library). The linker | |
24435 | for executables, @command{ld}, quietly gives the executable the most | |
24436 | restrictive subtype of any of its input files. | |
24437 | ||
24438 | @table @gcctabopt | |
d77de738 | 24439 | @opindex F |
ddf6fe37 | 24440 | @item -F@var{dir} |
d77de738 ML |
24441 | Add the framework directory @var{dir} to the head of the list of |
24442 | directories to be searched for header files. These directories are | |
24443 | interleaved with those specified by @option{-I} options and are | |
24444 | scanned in a left-to-right order. | |
24445 | ||
24446 | A framework directory is a directory with frameworks in it. A | |
24447 | framework is a directory with a @file{Headers} and/or | |
24448 | @file{PrivateHeaders} directory contained directly in it that ends | |
24449 | in @file{.framework}. The name of a framework is the name of this | |
24450 | directory excluding the @file{.framework}. Headers associated with | |
24451 | the framework are found in one of those two directories, with | |
24452 | @file{Headers} being searched first. A subframework is a framework | |
24453 | directory that is in a framework's @file{Frameworks} directory. | |
24454 | Includes of subframework headers can only appear in a header of a | |
24455 | framework that contains the subframework, or in a sibling subframework | |
24456 | header. Two subframeworks are siblings if they occur in the same | |
24457 | framework. A subframework should not have the same name as a | |
24458 | framework; a warning is issued if this is violated. Currently a | |
24459 | subframework cannot have subframeworks; in the future, the mechanism | |
24460 | may be extended to support this. The standard frameworks can be found | |
24461 | in @file{/System/Library/Frameworks} and | |
24462 | @file{/Library/Frameworks}. An example include looks like | |
24463 | @code{#include <Framework/header.h>}, where @file{Framework} denotes | |
24464 | the name of the framework and @file{header.h} is found in the | |
24465 | @file{PrivateHeaders} or @file{Headers} directory. | |
24466 | ||
d77de738 | 24467 | @opindex iframework |
ddf6fe37 | 24468 | @item -iframework@var{dir} |
d77de738 ML |
24469 | Like @option{-F} except the directory is a treated as a system |
24470 | directory. The main difference between this @option{-iframework} and | |
24471 | @option{-F} is that with @option{-iframework} the compiler does not | |
24472 | warn about constructs contained within header files found via | |
24473 | @var{dir}. This option is valid only for the C family of languages. | |
24474 | ||
d77de738 | 24475 | @opindex gused |
ddf6fe37 | 24476 | @item -gused |
d77de738 ML |
24477 | Emit debugging information for symbols that are used. For stabs |
24478 | debugging format, this enables @option{-feliminate-unused-debug-symbols}. | |
24479 | This is by default ON@. | |
24480 | ||
d77de738 | 24481 | @opindex gfull |
ddf6fe37 | 24482 | @item -gfull |
d77de738 ML |
24483 | Emit debugging information for all symbols and types. |
24484 | ||
cdd4b3c0 IS |
24485 | @opindex fconstant-cfstrings |
24486 | @item -fconstant-cfstrings | |
24487 | The @option{-fconstant-cfstrings} is an alias for @option{-mconstant-cfstrings}. | |
24488 | ||
24489 | @opindex mconstant-cfstrings | |
24490 | @item -mconstant-cfstrings | |
24491 | When the NeXT runtime is being used (the default on these systems), override | |
24492 | any @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} | |
24493 | literals to be laid out as constant CoreFoundation strings. | |
24494 | ||
24495 | @opindex mmacosx-version-min | |
d77de738 | 24496 | @item -mmacosx-version-min=@var{version} |
cdd4b3c0 IS |
24497 | The earliest version of MacOS X that this executable will run on is |
24498 | @var{version}. Typical values supported for @var{version} include @code{12}, | |
24499 | @code{10.12}, and @code{10.5.8}. | |
d77de738 ML |
24500 | |
24501 | If the compiler was built to use the system's headers by default, | |
24502 | then the default for this option is the system version on which the | |
24503 | compiler is running, otherwise the default is to make choices that | |
24504 | are compatible with as many systems and code bases as possible. | |
24505 | ||
d77de738 | 24506 | @opindex mkernel |
ddf6fe37 | 24507 | @item -mkernel |
d77de738 ML |
24508 | Enable kernel development mode. The @option{-mkernel} option sets |
24509 | @option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit}, | |
24510 | @option{-fno-exceptions}, @option{-fno-non-call-exceptions}, | |
24511 | @option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where | |
24512 | applicable. This mode also sets @option{-mno-altivec}, | |
24513 | @option{-msoft-float}, @option{-fno-builtin} and | |
24514 | @option{-mlong-branch} for PowerPC targets. | |
24515 | ||
d77de738 | 24516 | @opindex mone-byte-bool |
ddf6fe37 | 24517 | @item -mone-byte-bool |
d77de738 ML |
24518 | Override the defaults for @code{bool} so that @code{sizeof(bool)==1}. |
24519 | By default @code{sizeof(bool)} is @code{4} when compiling for | |
24520 | Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this | |
24521 | option has no effect on x86. | |
24522 | ||
24523 | @strong{Warning:} The @option{-mone-byte-bool} switch causes GCC | |
24524 | to generate code that is not binary compatible with code generated | |
24525 | without that switch. Using this switch may require recompiling all | |
24526 | other modules in a program, including system libraries. Use this | |
24527 | switch to conform to a non-default data model. | |
24528 | ||
d77de738 ML |
24529 | @opindex mfix-and-continue |
24530 | @opindex ffix-and-continue | |
24531 | @opindex findirect-data | |
ddf6fe37 AA |
24532 | @item -mfix-and-continue |
24533 | @itemx -ffix-and-continue | |
24534 | @itemx -findirect-data | |
d77de738 ML |
24535 | Generate code suitable for fast turnaround development, such as to |
24536 | allow GDB to dynamically load @file{.o} files into already-running | |
24537 | programs. @option{-findirect-data} and @option{-ffix-and-continue} | |
24538 | are provided for backwards compatibility. | |
24539 | ||
d77de738 | 24540 | @opindex all_load |
ddf6fe37 | 24541 | @item -all_load |
d77de738 ML |
24542 | Loads all members of static archive libraries. |
24543 | See man ld(1) for more information. | |
24544 | ||
d77de738 | 24545 | @opindex arch_errors_fatal |
ddf6fe37 | 24546 | @item -arch_errors_fatal |
d77de738 ML |
24547 | Cause the errors having to do with files that have the wrong architecture |
24548 | to be fatal. | |
24549 | ||
d77de738 | 24550 | @opindex bind_at_load |
ddf6fe37 | 24551 | @item -bind_at_load |
d77de738 ML |
24552 | Causes the output file to be marked such that the dynamic linker will |
24553 | bind all undefined references when the file is loaded or launched. | |
24554 | ||
d77de738 | 24555 | @opindex bundle |
ddf6fe37 | 24556 | @item -bundle |
d77de738 ML |
24557 | Produce a Mach-o bundle format file. |
24558 | See man ld(1) for more information. | |
24559 | ||
d77de738 | 24560 | @opindex bundle_loader |
ddf6fe37 | 24561 | @item -bundle_loader @var{executable} |
d77de738 ML |
24562 | This option specifies the @var{executable} that will load the build |
24563 | output file being linked. See man ld(1) for more information. | |
24564 | ||
d77de738 | 24565 | @opindex dynamiclib |
ddf6fe37 | 24566 | @item -dynamiclib |
d77de738 ML |
24567 | When passed this option, GCC produces a dynamic library instead of |
24568 | an executable when linking, using the Darwin @file{libtool} command. | |
24569 | ||
d77de738 | 24570 | @opindex force_cpusubtype_ALL |
ddf6fe37 | 24571 | @item -force_cpusubtype_ALL |
d77de738 ML |
24572 | This causes GCC's output file to have the @samp{ALL} subtype, instead of |
24573 | one controlled by the @option{-mcpu} or @option{-march} option. | |
24574 | ||
47b634a3 FXC |
24575 | @opindex nodefaultrpaths |
24576 | @item -nodefaultrpaths | |
24577 | Do not add default run paths for the compiler library directories to | |
24578 | executables, modules or dynamic libraries. On macOS 10.5 and later, | |
24579 | the embedded runpath is added by default unless the user adds | |
24580 | @option{-nodefaultrpaths} to the link line. Run paths are needed | |
24581 | (and therefore enforced) to build on macOS version 10.11 or later. | |
24582 | ||
d77de738 ML |
24583 | @item -allowable_client @var{client_name} |
24584 | @itemx -client_name | |
24585 | @itemx -compatibility_version | |
24586 | @itemx -current_version | |
24587 | @itemx -dead_strip | |
24588 | @itemx -dependency-file | |
24589 | @itemx -dylib_file | |
24590 | @itemx -dylinker_install_name | |
24591 | @itemx -dynamic | |
24592 | @itemx -exported_symbols_list | |
24593 | @itemx -filelist | |
24594 | @need 800 | |
24595 | @itemx -flat_namespace | |
24596 | @itemx -force_flat_namespace | |
24597 | @itemx -headerpad_max_install_names | |
24598 | @itemx -image_base | |
24599 | @itemx -init | |
24600 | @itemx -install_name | |
24601 | @itemx -keep_private_externs | |
24602 | @itemx -multi_module | |
24603 | @itemx -multiply_defined | |
24604 | @itemx -multiply_defined_unused | |
24605 | @need 800 | |
24606 | @itemx -noall_load | |
24607 | @itemx -no_dead_strip_inits_and_terms | |
24608 | @itemx -nofixprebinding | |
24609 | @itemx -nomultidefs | |
24610 | @itemx -noprebind | |
24611 | @itemx -noseglinkedit | |
24612 | @itemx -pagezero_size | |
24613 | @itemx -prebind | |
24614 | @itemx -prebind_all_twolevel_modules | |
24615 | @itemx -private_bundle | |
24616 | @need 800 | |
24617 | @itemx -read_only_relocs | |
24618 | @itemx -sectalign | |
24619 | @itemx -sectobjectsymbols | |
24620 | @itemx -whyload | |
24621 | @itemx -seg1addr | |
24622 | @itemx -sectcreate | |
24623 | @itemx -sectobjectsymbols | |
24624 | @itemx -sectorder | |
24625 | @itemx -segaddr | |
24626 | @itemx -segs_read_only_addr | |
24627 | @need 800 | |
24628 | @itemx -segs_read_write_addr | |
24629 | @itemx -seg_addr_table | |
24630 | @itemx -seg_addr_table_filename | |
24631 | @itemx -seglinkedit | |
24632 | @itemx -segprot | |
24633 | @itemx -segs_read_only_addr | |
24634 | @itemx -segs_read_write_addr | |
24635 | @itemx -single_module | |
24636 | @itemx -static | |
24637 | @itemx -sub_library | |
24638 | @need 800 | |
d77de738 ML |
24639 | @opindex allowable_client |
24640 | @opindex client_name | |
24641 | @opindex compatibility_version | |
24642 | @opindex current_version | |
24643 | @opindex dead_strip | |
24644 | @opindex dependency-file | |
24645 | @opindex dylib_file | |
24646 | @opindex dylinker_install_name | |
24647 | @opindex dynamic | |
24648 | @opindex exported_symbols_list | |
24649 | @opindex filelist | |
24650 | @opindex flat_namespace | |
24651 | @opindex force_flat_namespace | |
24652 | @opindex headerpad_max_install_names | |
24653 | @opindex image_base | |
24654 | @opindex init | |
24655 | @opindex install_name | |
24656 | @opindex keep_private_externs | |
24657 | @opindex multi_module | |
24658 | @opindex multiply_defined | |
24659 | @opindex multiply_defined_unused | |
24660 | @opindex noall_load | |
24661 | @opindex no_dead_strip_inits_and_terms | |
24662 | @opindex nofixprebinding | |
24663 | @opindex nomultidefs | |
24664 | @opindex noprebind | |
24665 | @opindex noseglinkedit | |
24666 | @opindex pagezero_size | |
24667 | @opindex prebind | |
24668 | @opindex prebind_all_twolevel_modules | |
24669 | @opindex private_bundle | |
24670 | @opindex read_only_relocs | |
24671 | @opindex sectalign | |
24672 | @opindex sectobjectsymbols | |
24673 | @opindex whyload | |
24674 | @opindex seg1addr | |
24675 | @opindex sectcreate | |
24676 | @opindex sectobjectsymbols | |
24677 | @opindex sectorder | |
24678 | @opindex segaddr | |
24679 | @opindex segs_read_only_addr | |
24680 | @opindex segs_read_write_addr | |
24681 | @opindex seg_addr_table | |
24682 | @opindex seg_addr_table_filename | |
24683 | @opindex seglinkedit | |
24684 | @opindex segprot | |
24685 | @opindex segs_read_only_addr | |
24686 | @opindex segs_read_write_addr | |
24687 | @opindex single_module | |
24688 | @opindex static | |
24689 | @opindex sub_library | |
24690 | @opindex sub_umbrella | |
24691 | @opindex twolevel_namespace | |
24692 | @opindex umbrella | |
24693 | @opindex undefined | |
24694 | @opindex unexported_symbols_list | |
24695 | @opindex weak_reference_mismatches | |
24696 | @opindex whatsloaded | |
ddf6fe37 AA |
24697 | @itemx -sub_umbrella |
24698 | @itemx -twolevel_namespace | |
24699 | @itemx -umbrella | |
24700 | @itemx -undefined | |
24701 | @itemx -unexported_symbols_list | |
24702 | @itemx -weak_reference_mismatches | |
24703 | @itemx -whatsloaded | |
d77de738 ML |
24704 | These options are passed to the Darwin linker. The Darwin linker man page |
24705 | describes them in detail. | |
24706 | @end table | |
24707 | ||
24708 | @node DEC Alpha Options | |
24709 | @subsection DEC Alpha Options | |
24710 | ||
24711 | These @samp{-m} options are defined for the DEC Alpha implementations: | |
24712 | ||
24713 | @table @gcctabopt | |
d77de738 ML |
24714 | @opindex mno-soft-float |
24715 | @opindex msoft-float | |
ddf6fe37 AA |
24716 | @item -mno-soft-float |
24717 | @itemx -msoft-float | |
d77de738 ML |
24718 | Use (do not use) the hardware floating-point instructions for |
24719 | floating-point operations. When @option{-msoft-float} is specified, | |
24720 | functions in @file{libgcc.a} are used to perform floating-point | |
24721 | operations. Unless they are replaced by routines that emulate the | |
24722 | floating-point operations, or compiled in such a way as to call such | |
24723 | emulations routines, these routines issue floating-point | |
24724 | operations. If you are compiling for an Alpha without floating-point | |
24725 | operations, you must ensure that the library is built so as not to call | |
24726 | them. | |
24727 | ||
24728 | Note that Alpha implementations without floating-point operations are | |
24729 | required to have floating-point registers. | |
24730 | ||
d77de738 ML |
24731 | @opindex mfp-reg |
24732 | @opindex mno-fp-regs | |
ddf6fe37 AA |
24733 | @item -mfp-reg |
24734 | @itemx -mno-fp-regs | |
d77de738 ML |
24735 | Generate code that uses (does not use) the floating-point register set. |
24736 | @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point | |
24737 | register set is not used, floating-point operands are passed in integer | |
24738 | registers as if they were integers and floating-point results are passed | |
24739 | in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence, | |
24740 | so any function with a floating-point argument or return value called by code | |
24741 | compiled with @option{-mno-fp-regs} must also be compiled with that | |
24742 | option. | |
24743 | ||
24744 | A typical use of this option is building a kernel that does not use, | |
24745 | and hence need not save and restore, any floating-point registers. | |
24746 | ||
d77de738 | 24747 | @opindex mieee |
ddf6fe37 | 24748 | @item -mieee |
d77de738 ML |
24749 | The Alpha architecture implements floating-point hardware optimized for |
24750 | maximum performance. It is mostly compliant with the IEEE floating-point | |
24751 | standard. However, for full compliance, software assistance is | |
24752 | required. This option generates code fully IEEE-compliant code | |
24753 | @emph{except} that the @var{inexact-flag} is not maintained (see below). | |
24754 | If this option is turned on, the preprocessor macro @code{_IEEE_FP} is | |
24755 | defined during compilation. The resulting code is less efficient but is | |
24756 | able to correctly support denormalized numbers and exceptional IEEE | |
24757 | values such as not-a-number and plus/minus infinity. Other Alpha | |
24758 | compilers call this option @option{-ieee_with_no_inexact}. | |
24759 | ||
d77de738 | 24760 | @opindex mieee-with-inexact |
ddf6fe37 | 24761 | @item -mieee-with-inexact |
d77de738 ML |
24762 | This is like @option{-mieee} except the generated code also maintains |
24763 | the IEEE @var{inexact-flag}. Turning on this option causes the | |
24764 | generated code to implement fully-compliant IEEE math. In addition to | |
24765 | @code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor | |
24766 | macro. On some Alpha implementations the resulting code may execute | |
24767 | significantly slower than the code generated by default. Since there is | |
24768 | very little code that depends on the @var{inexact-flag}, you should | |
24769 | normally not specify this option. Other Alpha compilers call this | |
24770 | option @option{-ieee_with_inexact}. | |
24771 | ||
d77de738 | 24772 | @opindex mfp-trap-mode |
ddf6fe37 | 24773 | @item -mfp-trap-mode=@var{trap-mode} |
d77de738 ML |
24774 | This option controls what floating-point related traps are enabled. |
24775 | Other Alpha compilers call this option @option{-fptm @var{trap-mode}}. | |
24776 | The trap mode can be set to one of four values: | |
24777 | ||
24778 | @table @samp | |
24779 | @item n | |
24780 | This is the default (normal) setting. The only traps that are enabled | |
24781 | are the ones that cannot be disabled in software (e.g., division by zero | |
24782 | trap). | |
24783 | ||
24784 | @item u | |
24785 | In addition to the traps enabled by @samp{n}, underflow traps are enabled | |
24786 | as well. | |
24787 | ||
24788 | @item su | |
24789 | Like @samp{u}, but the instructions are marked to be safe for software | |
24790 | completion (see Alpha architecture manual for details). | |
24791 | ||
24792 | @item sui | |
24793 | Like @samp{su}, but inexact traps are enabled as well. | |
24794 | @end table | |
24795 | ||
d77de738 | 24796 | @opindex mfp-rounding-mode |
ddf6fe37 | 24797 | @item -mfp-rounding-mode=@var{rounding-mode} |
d77de738 ML |
24798 | Selects the IEEE rounding mode. Other Alpha compilers call this option |
24799 | @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one | |
24800 | of: | |
24801 | ||
24802 | @table @samp | |
24803 | @item n | |
24804 | Normal IEEE rounding mode. Floating-point numbers are rounded towards | |
24805 | the nearest machine number or towards the even machine number in case | |
24806 | of a tie. | |
24807 | ||
24808 | @item m | |
24809 | Round towards minus infinity. | |
24810 | ||
24811 | @item c | |
24812 | Chopped rounding mode. Floating-point numbers are rounded towards zero. | |
24813 | ||
24814 | @item d | |
24815 | Dynamic rounding mode. A field in the floating-point control register | |
24816 | (@var{fpcr}, see Alpha architecture reference manual) controls the | |
24817 | rounding mode in effect. The C library initializes this register for | |
24818 | rounding towards plus infinity. Thus, unless your program modifies the | |
24819 | @var{fpcr}, @samp{d} corresponds to round towards plus infinity. | |
24820 | @end table | |
24821 | ||
d77de738 | 24822 | @opindex mtrap-precision |
ddf6fe37 | 24823 | @item -mtrap-precision=@var{trap-precision} |
d77de738 ML |
24824 | In the Alpha architecture, floating-point traps are imprecise. This |
24825 | means without software assistance it is impossible to recover from a | |
24826 | floating trap and program execution normally needs to be terminated. | |
24827 | GCC can generate code that can assist operating system trap handlers | |
24828 | in determining the exact location that caused a floating-point trap. | |
24829 | Depending on the requirements of an application, different levels of | |
24830 | precisions can be selected: | |
24831 | ||
24832 | @table @samp | |
24833 | @item p | |
24834 | Program precision. This option is the default and means a trap handler | |
24835 | can only identify which program caused a floating-point exception. | |
24836 | ||
24837 | @item f | |
24838 | Function precision. The trap handler can determine the function that | |
24839 | caused a floating-point exception. | |
24840 | ||
24841 | @item i | |
24842 | Instruction precision. The trap handler can determine the exact | |
24843 | instruction that caused a floating-point exception. | |
24844 | @end table | |
24845 | ||
24846 | Other Alpha compilers provide the equivalent options called | |
24847 | @option{-scope_safe} and @option{-resumption_safe}. | |
24848 | ||
d77de738 | 24849 | @opindex mieee-conformant |
ddf6fe37 | 24850 | @item -mieee-conformant |
d77de738 ML |
24851 | This option marks the generated code as IEEE conformant. You must not |
24852 | use this option unless you also specify @option{-mtrap-precision=i} and either | |
24853 | @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect | |
24854 | is to emit the line @samp{.eflag 48} in the function prologue of the | |
24855 | generated assembly file. | |
24856 | ||
d77de738 | 24857 | @opindex mbuild-constants |
ddf6fe37 | 24858 | @item -mbuild-constants |
d77de738 ML |
24859 | Normally GCC examines a 32- or 64-bit integer constant to |
24860 | see if it can construct it from smaller constants in two or three | |
24861 | instructions. If it cannot, it outputs the constant as a literal and | |
24862 | generates code to load it from the data segment at run time. | |
24863 | ||
24864 | Use this option to require GCC to construct @emph{all} integer constants | |
24865 | using code, even if it takes more instructions (the maximum is six). | |
24866 | ||
24867 | You typically use this option to build a shared library dynamic | |
24868 | loader. Itself a shared library, it must relocate itself in memory | |
24869 | before it can find the variables and constants in its own data segment. | |
24870 | ||
d77de738 ML |
24871 | @opindex mbwx |
24872 | @opindex mno-bwx | |
24873 | @opindex mcix | |
24874 | @opindex mno-cix | |
24875 | @opindex mfix | |
24876 | @opindex mno-fix | |
24877 | @opindex mmax | |
24878 | @opindex mno-max | |
ddf6fe37 AA |
24879 | @item -mbwx |
24880 | @itemx -mno-bwx | |
24881 | @itemx -mcix | |
24882 | @itemx -mno-cix | |
24883 | @itemx -mfix | |
24884 | @itemx -mno-fix | |
24885 | @itemx -mmax | |
24886 | @itemx -mno-max | |
d77de738 ML |
24887 | Indicate whether GCC should generate code to use the optional BWX, |
24888 | CIX, FIX and MAX instruction sets. The default is to use the instruction | |
24889 | sets supported by the CPU type specified via @option{-mcpu=} option or that | |
24890 | of the CPU on which GCC was built if none is specified. | |
24891 | ||
d77de738 ML |
24892 | @opindex mfloat-vax |
24893 | @opindex mfloat-ieee | |
ddf6fe37 AA |
24894 | @item -mfloat-vax |
24895 | @itemx -mfloat-ieee | |
d77de738 ML |
24896 | Generate code that uses (does not use) VAX F and G floating-point |
24897 | arithmetic instead of IEEE single and double precision. | |
24898 | ||
d77de738 ML |
24899 | @opindex mexplicit-relocs |
24900 | @opindex mno-explicit-relocs | |
ddf6fe37 AA |
24901 | @item -mexplicit-relocs |
24902 | @itemx -mno-explicit-relocs | |
d77de738 ML |
24903 | Older Alpha assemblers provided no way to generate symbol relocations |
24904 | except via assembler macros. Use of these macros does not allow | |
24905 | optimal instruction scheduling. GNU binutils as of version 2.12 | |
24906 | supports a new syntax that allows the compiler to explicitly mark | |
24907 | which relocations should apply to which instructions. This option | |
24908 | is mostly useful for debugging, as GCC detects the capabilities of | |
24909 | the assembler when it is built and sets the default accordingly. | |
24910 | ||
d77de738 ML |
24911 | @opindex msmall-data |
24912 | @opindex mlarge-data | |
ddf6fe37 AA |
24913 | @item -msmall-data |
24914 | @itemx -mlarge-data | |
d77de738 ML |
24915 | When @option{-mexplicit-relocs} is in effect, static data is |
24916 | accessed via @dfn{gp-relative} relocations. When @option{-msmall-data} | |
24917 | is used, objects 8 bytes long or smaller are placed in a @dfn{small data area} | |
24918 | (the @code{.sdata} and @code{.sbss} sections) and are accessed via | |
24919 | 16-bit relocations off of the @code{$gp} register. This limits the | |
24920 | size of the small data area to 64KB, but allows the variables to be | |
24921 | directly accessed via a single instruction. | |
24922 | ||
24923 | The default is @option{-mlarge-data}. With this option the data area | |
24924 | is limited to just below 2GB@. Programs that require more than 2GB of | |
24925 | data must use @code{malloc} or @code{mmap} to allocate the data in the | |
24926 | heap instead of in the program's data segment. | |
24927 | ||
24928 | When generating code for shared libraries, @option{-fpic} implies | |
24929 | @option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}. | |
24930 | ||
d77de738 ML |
24931 | @opindex msmall-text |
24932 | @opindex mlarge-text | |
ddf6fe37 AA |
24933 | @item -msmall-text |
24934 | @itemx -mlarge-text | |
d77de738 ML |
24935 | When @option{-msmall-text} is used, the compiler assumes that the |
24936 | code of the entire program (or shared library) fits in 4MB, and is | |
24937 | thus reachable with a branch instruction. When @option{-msmall-data} | |
24938 | is used, the compiler can assume that all local symbols share the | |
24939 | same @code{$gp} value, and thus reduce the number of instructions | |
24940 | required for a function call from 4 to 1. | |
24941 | ||
24942 | The default is @option{-mlarge-text}. | |
24943 | ||
d77de738 | 24944 | @opindex mcpu |
ddf6fe37 | 24945 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
24946 | Set the instruction set and instruction scheduling parameters for |
24947 | machine type @var{cpu_type}. You can specify either the @samp{EV} | |
24948 | style name or the corresponding chip number. GCC supports scheduling | |
24949 | parameters for the EV4, EV5 and EV6 family of processors and | |
24950 | chooses the default values for the instruction set from the processor | |
24951 | you specify. If you do not specify a processor type, GCC defaults | |
24952 | to the processor on which the compiler was built. | |
24953 | ||
24954 | Supported values for @var{cpu_type} are | |
24955 | ||
24956 | @table @samp | |
24957 | @item ev4 | |
24958 | @itemx ev45 | |
24959 | @itemx 21064 | |
24960 | Schedules as an EV4 and has no instruction set extensions. | |
24961 | ||
24962 | @item ev5 | |
24963 | @itemx 21164 | |
24964 | Schedules as an EV5 and has no instruction set extensions. | |
24965 | ||
24966 | @item ev56 | |
24967 | @itemx 21164a | |
24968 | Schedules as an EV5 and supports the BWX extension. | |
24969 | ||
24970 | @item pca56 | |
24971 | @itemx 21164pc | |
24972 | @itemx 21164PC | |
24973 | Schedules as an EV5 and supports the BWX and MAX extensions. | |
24974 | ||
24975 | @item ev6 | |
24976 | @itemx 21264 | |
24977 | Schedules as an EV6 and supports the BWX, FIX, and MAX extensions. | |
24978 | ||
24979 | @item ev67 | |
24980 | @itemx 21264a | |
24981 | Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions. | |
24982 | @end table | |
24983 | ||
24984 | Native toolchains also support the value @samp{native}, | |
24985 | which selects the best architecture option for the host processor. | |
24986 | @option{-mcpu=native} has no effect if GCC does not recognize | |
24987 | the processor. | |
24988 | ||
d77de738 | 24989 | @opindex mtune |
ddf6fe37 | 24990 | @item -mtune=@var{cpu_type} |
d77de738 ML |
24991 | Set only the instruction scheduling parameters for machine type |
24992 | @var{cpu_type}. The instruction set is not changed. | |
24993 | ||
24994 | Native toolchains also support the value @samp{native}, | |
24995 | which selects the best architecture option for the host processor. | |
24996 | @option{-mtune=native} has no effect if GCC does not recognize | |
24997 | the processor. | |
24998 | ||
d77de738 | 24999 | @opindex mmemory-latency |
ddf6fe37 | 25000 | @item -mmemory-latency=@var{time} |
d77de738 ML |
25001 | Sets the latency the scheduler should assume for typical memory |
25002 | references as seen by the application. This number is highly | |
25003 | dependent on the memory access patterns used by the application | |
25004 | and the size of the external cache on the machine. | |
25005 | ||
25006 | Valid options for @var{time} are | |
25007 | ||
25008 | @table @samp | |
25009 | @item @var{number} | |
25010 | A decimal number representing clock cycles. | |
25011 | ||
25012 | @item L1 | |
25013 | @itemx L2 | |
25014 | @itemx L3 | |
25015 | @itemx main | |
25016 | The compiler contains estimates of the number of clock cycles for | |
25017 | ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches | |
25018 | (also called Dcache, Scache, and Bcache), as well as to main memory. | |
25019 | Note that L3 is only valid for EV5. | |
25020 | ||
25021 | @end table | |
25022 | @end table | |
25023 | ||
25024 | @node eBPF Options | |
25025 | @subsection eBPF Options | |
25026 | @cindex eBPF Options | |
25027 | ||
25028 | @table @gcctabopt | |
25029 | @item -mframe-limit=@var{bytes} | |
25030 | This specifies the hard limit for frame sizes, in bytes. Currently, | |
25031 | the value that can be specified should be less than or equal to | |
25032 | @samp{32767}. Defaults to whatever limit is imposed by the version of | |
25033 | the Linux kernel targeted. | |
25034 | ||
d77de738 | 25035 | @opindex mbig-endian |
ddf6fe37 | 25036 | @item -mbig-endian |
d77de738 ML |
25037 | Generate code for a big-endian target. |
25038 | ||
d77de738 | 25039 | @opindex mlittle-endian |
ddf6fe37 | 25040 | @item -mlittle-endian |
d77de738 ML |
25041 | Generate code for a little-endian target. This is the default. |
25042 | ||
d77de738 | 25043 | @opindex mjmpext |
ddf6fe37 | 25044 | @item -mjmpext |
9cbf4286 DF |
25045 | @itemx -mno-jmpext |
25046 | Enable or disable generation of extra conditional-branch instructions. | |
d77de738 ML |
25047 | Enabled for CPU v2 and above. |
25048 | ||
d77de738 | 25049 | @opindex mjmp32 |
ddf6fe37 | 25050 | @item -mjmp32 |
9cbf4286 DF |
25051 | @itemx -mno-jmp32 |
25052 | Enable or disable generation of 32-bit jump instructions. | |
25053 | Enabled for CPU v3 and above. | |
d77de738 | 25054 | |
d77de738 | 25055 | @opindex malu32 |
ddf6fe37 | 25056 | @item -malu32 |
9cbf4286 DF |
25057 | @itemx -mno-alu32 |
25058 | Enable or disable generation of 32-bit ALU instructions. | |
25059 | Enabled for CPU v3 and above. | |
25060 | ||
25061 | @opindex mv3-atomics | |
25062 | @item -mv3-atomics | |
25063 | @itemx -mno-v3-atomics | |
25064 | Enable or disable instructions for general atomic operations introduced | |
25065 | in CPU v3. Enabled for CPU v3 and above. | |
d77de738 | 25066 | |
f1e34551 JM |
25067 | @opindex mbswap |
25068 | @item -mbswap | |
9cbf4286 DF |
25069 | @itemx -mno-bswap |
25070 | Enable or disable byte swap instructions. Enabled for CPU v4 and above. | |
f1e34551 | 25071 | |
4be3919f JM |
25072 | @opindex msdiv |
25073 | @item -msdiv | |
9cbf4286 DF |
25074 | @itemx -mno-sdiv |
25075 | Enable or disable signed division and modulus instructions. Enabled for | |
25076 | CPU v4 and above. | |
db189d02 | 25077 | |
14dab1a1 DF |
25078 | @opindex msmov |
25079 | @item -msmov | |
25080 | @itemx -mno-smov | |
25081 | Enable or disable sign-extending move and memory load instructions. | |
25082 | Enabled for CPU v4 and above. | |
25083 | ||
d77de738 | 25084 | @opindex mcpu |
ddf6fe37 | 25085 | @item -mcpu=@var{version} |
d77de738 | 25086 | This specifies which version of the eBPF ISA to target. Newer versions |
f1e34551 | 25087 | may not be supported by all kernels. The default is @samp{v4}. |
d77de738 ML |
25088 | |
25089 | Supported values for @var{version} are: | |
25090 | ||
25091 | @table @samp | |
25092 | @item v1 | |
25093 | The first stable eBPF ISA with no special features or extensions. | |
25094 | ||
25095 | @item v2 | |
25096 | Supports the jump extensions, as in @option{-mjmpext}. | |
25097 | ||
25098 | @item v3 | |
25099 | All features of v2, plus: | |
25100 | @itemize @minus | |
25101 | @item 32-bit jump operations, as in @option{-mjmp32} | |
25102 | @item 32-bit ALU operations, as in @option{-malu32} | |
db189d02 | 25103 | @item general atomic operations, as in @option{-mv3-atomics} |
d77de738 ML |
25104 | @end itemize |
25105 | ||
f1e34551 JM |
25106 | @item v4 |
25107 | All features of v3, plus: | |
25108 | @itemize @minus | |
25109 | @item Byte swap instructions, as in @option{-mbswap} | |
9cbf4286 | 25110 | @item Signed division and modulus instructions, as in @option{-msdiv} |
14dab1a1 | 25111 | @item Sign-extending move and memory load instructions, as in @option{-msmov} |
f1e34551 | 25112 | @end itemize |
d77de738 ML |
25113 | @end table |
25114 | ||
d77de738 | 25115 | @opindex mco-re |
ddf6fe37 | 25116 | @item -mco-re |
d77de738 ML |
25117 | Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and |
25118 | is implied by @option{-gbtf}. | |
25119 | ||
d77de738 | 25120 | @opindex mno-co-re |
ddf6fe37 | 25121 | @item -mno-co-re |
d77de738 ML |
25122 | Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE |
25123 | support is enabled by default when generating BTF debug information for | |
25124 | the BPF target. | |
25125 | ||
25126 | @item -mxbpf | |
25127 | Generate code for an expanded version of BPF, which relaxes some of | |
25128 | the restrictions imposed by the BPF architecture: | |
25129 | @itemize @minus | |
25130 | @item Save and restore callee-saved registers at function entry and | |
25131 | exit, respectively. | |
25132 | @end itemize | |
77d0f9ec CM |
25133 | |
25134 | @opindex masm=@var{dialect} | |
25135 | @item -masm=@var{dialect} | |
25136 | Outputs assembly instructions using eBPF selected @var{dialect}. The default | |
25137 | is @samp{normal}. | |
25138 | ||
25139 | Supported values for @var{dialect} are: | |
25140 | ||
25141 | @table @samp | |
25142 | @item normal | |
25143 | Outputs normal assembly dialect. | |
25144 | ||
25145 | @item pseudoc | |
25146 | Outputs pseudo-c assembly dialect. | |
25147 | ||
25148 | @end table | |
25149 | ||
d77de738 ML |
25150 | @end table |
25151 | ||
25152 | @node FR30 Options | |
25153 | @subsection FR30 Options | |
25154 | @cindex FR30 Options | |
25155 | ||
25156 | These options are defined specifically for the FR30 port. | |
25157 | ||
25158 | @table @gcctabopt | |
25159 | ||
d77de738 | 25160 | @opindex msmall-model |
ddf6fe37 | 25161 | @item -msmall-model |
d77de738 ML |
25162 | Use the small address space model. This can produce smaller code, but |
25163 | it does assume that all symbolic values and addresses fit into a | |
25164 | 20-bit range. | |
25165 | ||
d77de738 | 25166 | @opindex mno-lsim |
ddf6fe37 | 25167 | @item -mno-lsim |
d77de738 ML |
25168 | Assume that runtime support has been provided and so there is no need |
25169 | to include the simulator library (@file{libsim.a}) on the linker | |
25170 | command line. | |
25171 | ||
25172 | @end table | |
25173 | ||
25174 | @node FT32 Options | |
25175 | @subsection FT32 Options | |
25176 | @cindex FT32 Options | |
25177 | ||
25178 | These options are defined specifically for the FT32 port. | |
25179 | ||
25180 | @table @gcctabopt | |
25181 | ||
d77de738 | 25182 | @opindex msim |
ddf6fe37 | 25183 | @item -msim |
d77de738 ML |
25184 | Specifies that the program will be run on the simulator. This causes |
25185 | an alternate runtime startup and library to be linked. | |
25186 | You must not use this option when generating programs that will run on | |
25187 | real hardware; you must provide your own runtime library for whatever | |
25188 | I/O functions are needed. | |
25189 | ||
d77de738 | 25190 | @opindex mlra |
ddf6fe37 | 25191 | @item -mlra |
d77de738 ML |
25192 | Enable Local Register Allocation. This is still experimental for FT32, |
25193 | so by default the compiler uses standard reload. | |
25194 | ||
d77de738 | 25195 | @opindex mnodiv |
ddf6fe37 | 25196 | @item -mnodiv |
d77de738 ML |
25197 | Do not use div and mod instructions. |
25198 | ||
d77de738 | 25199 | @opindex mft32b |
ddf6fe37 | 25200 | @item -mft32b |
d77de738 ML |
25201 | Enable use of the extended instructions of the FT32B processor. |
25202 | ||
d77de738 | 25203 | @opindex mcompress |
ddf6fe37 | 25204 | @item -mcompress |
d77de738 ML |
25205 | Compress all code using the Ft32B code compression scheme. |
25206 | ||
d77de738 | 25207 | @opindex mnopm |
ddf6fe37 | 25208 | @item -mnopm |
d77de738 ML |
25209 | Do not generate code that reads program memory. |
25210 | ||
25211 | @end table | |
25212 | ||
25213 | @node FRV Options | |
25214 | @subsection FRV Options | |
25215 | @cindex FRV Options | |
25216 | ||
25217 | @table @gcctabopt | |
d77de738 | 25218 | @opindex mgpr-32 |
ddf6fe37 | 25219 | @item -mgpr-32 |
d77de738 ML |
25220 | |
25221 | Only use the first 32 general-purpose registers. | |
25222 | ||
d77de738 | 25223 | @opindex mgpr-64 |
ddf6fe37 | 25224 | @item -mgpr-64 |
d77de738 ML |
25225 | |
25226 | Use all 64 general-purpose registers. | |
25227 | ||
d77de738 | 25228 | @opindex mfpr-32 |
ddf6fe37 | 25229 | @item -mfpr-32 |
d77de738 ML |
25230 | |
25231 | Use only the first 32 floating-point registers. | |
25232 | ||
d77de738 | 25233 | @opindex mfpr-64 |
ddf6fe37 | 25234 | @item -mfpr-64 |
d77de738 ML |
25235 | |
25236 | Use all 64 floating-point registers. | |
25237 | ||
d77de738 | 25238 | @opindex mhard-float |
ddf6fe37 | 25239 | @item -mhard-float |
d77de738 ML |
25240 | |
25241 | Use hardware instructions for floating-point operations. | |
25242 | ||
d77de738 | 25243 | @opindex msoft-float |
ddf6fe37 | 25244 | @item -msoft-float |
d77de738 ML |
25245 | |
25246 | Use library routines for floating-point operations. | |
25247 | ||
d77de738 | 25248 | @opindex malloc-cc |
ddf6fe37 | 25249 | @item -malloc-cc |
d77de738 ML |
25250 | |
25251 | Dynamically allocate condition code registers. | |
25252 | ||
d77de738 | 25253 | @opindex mfixed-cc |
ddf6fe37 | 25254 | @item -mfixed-cc |
d77de738 ML |
25255 | |
25256 | Do not try to dynamically allocate condition code registers, only | |
25257 | use @code{icc0} and @code{fcc0}. | |
25258 | ||
d77de738 | 25259 | @opindex mdword |
ddf6fe37 | 25260 | @item -mdword |
d77de738 ML |
25261 | |
25262 | Change ABI to use double word insns. | |
25263 | ||
d77de738 ML |
25264 | @opindex mno-dword |
25265 | @opindex mdword | |
ddf6fe37 | 25266 | @item -mno-dword |
d77de738 ML |
25267 | |
25268 | Do not use double word instructions. | |
25269 | ||
d77de738 | 25270 | @opindex mdouble |
ddf6fe37 | 25271 | @item -mdouble |
d77de738 ML |
25272 | |
25273 | Use floating-point double instructions. | |
25274 | ||
d77de738 | 25275 | @opindex mno-double |
ddf6fe37 | 25276 | @item -mno-double |
d77de738 ML |
25277 | |
25278 | Do not use floating-point double instructions. | |
25279 | ||
d77de738 | 25280 | @opindex mmedia |
ddf6fe37 | 25281 | @item -mmedia |
d77de738 ML |
25282 | |
25283 | Use media instructions. | |
25284 | ||
d77de738 | 25285 | @opindex mno-media |
ddf6fe37 | 25286 | @item -mno-media |
d77de738 ML |
25287 | |
25288 | Do not use media instructions. | |
25289 | ||
d77de738 | 25290 | @opindex mmuladd |
ddf6fe37 | 25291 | @item -mmuladd |
d77de738 ML |
25292 | |
25293 | Use multiply and add/subtract instructions. | |
25294 | ||
d77de738 | 25295 | @opindex mno-muladd |
ddf6fe37 | 25296 | @item -mno-muladd |
d77de738 ML |
25297 | |
25298 | Do not use multiply and add/subtract instructions. | |
25299 | ||
d77de738 | 25300 | @opindex mfdpic |
ddf6fe37 | 25301 | @item -mfdpic |
d77de738 ML |
25302 | |
25303 | Select the FDPIC ABI, which uses function descriptors to represent | |
25304 | pointers to functions. Without any PIC/PIE-related options, it | |
25305 | implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it | |
25306 | assumes GOT entries and small data are within a 12-bit range from the | |
25307 | GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets | |
25308 | are computed with 32 bits. | |
25309 | With a @samp{bfin-elf} target, this option implies @option{-msim}. | |
25310 | ||
d77de738 | 25311 | @opindex minline-plt |
ddf6fe37 | 25312 | @item -minline-plt |
d77de738 ML |
25313 | |
25314 | Enable inlining of PLT entries in function calls to functions that are | |
25315 | not known to bind locally. It has no effect without @option{-mfdpic}. | |
25316 | It's enabled by default if optimizing for speed and compiling for | |
25317 | shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an | |
25318 | optimization option such as @option{-O3} or above is present in the | |
25319 | command line. | |
25320 | ||
d77de738 | 25321 | @opindex mTLS |
ddf6fe37 | 25322 | @item -mTLS |
d77de738 ML |
25323 | |
25324 | Assume a large TLS segment when generating thread-local code. | |
25325 | ||
d77de738 | 25326 | @opindex mtls |
ddf6fe37 | 25327 | @item -mtls |
d77de738 ML |
25328 | |
25329 | Do not assume a large TLS segment when generating thread-local code. | |
25330 | ||
d77de738 | 25331 | @opindex mgprel-ro |
ddf6fe37 | 25332 | @item -mgprel-ro |
d77de738 ML |
25333 | |
25334 | Enable the use of @code{GPREL} relocations in the FDPIC ABI for data | |
25335 | that is known to be in read-only sections. It's enabled by default, | |
25336 | except for @option{-fpic} or @option{-fpie}: even though it may help | |
25337 | make the global offset table smaller, it trades 1 instruction for 4. | |
25338 | With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4, | |
25339 | one of which may be shared by multiple symbols, and it avoids the need | |
25340 | for a GOT entry for the referenced symbol, so it's more likely to be a | |
25341 | win. If it is not, @option{-mno-gprel-ro} can be used to disable it. | |
25342 | ||
d77de738 | 25343 | @opindex multilib-library-pic |
ddf6fe37 | 25344 | @item -multilib-library-pic |
d77de738 ML |
25345 | |
25346 | Link with the (library, not FD) pic libraries. It's implied by | |
25347 | @option{-mlibrary-pic}, as well as by @option{-fPIC} and | |
25348 | @option{-fpic} without @option{-mfdpic}. You should never have to use | |
25349 | it explicitly. | |
25350 | ||
d77de738 | 25351 | @opindex mlinked-fp |
ddf6fe37 | 25352 | @item -mlinked-fp |
d77de738 ML |
25353 | |
25354 | Follow the EABI requirement of always creating a frame pointer whenever | |
25355 | a stack frame is allocated. This option is enabled by default and can | |
25356 | be disabled with @option{-mno-linked-fp}. | |
25357 | ||
d77de738 | 25358 | @opindex mlong-calls |
ddf6fe37 | 25359 | @item -mlong-calls |
d77de738 ML |
25360 | |
25361 | Use indirect addressing to call functions outside the current | |
25362 | compilation unit. This allows the functions to be placed anywhere | |
25363 | within the 32-bit address space. | |
25364 | ||
d77de738 | 25365 | @opindex malign-labels |
ddf6fe37 | 25366 | @item -malign-labels |
d77de738 ML |
25367 | |
25368 | Try to align labels to an 8-byte boundary by inserting NOPs into the | |
25369 | previous packet. This option only has an effect when VLIW packing | |
25370 | is enabled. It doesn't create new packets; it merely adds NOPs to | |
25371 | existing ones. | |
25372 | ||
d77de738 | 25373 | @opindex mlibrary-pic |
ddf6fe37 | 25374 | @item -mlibrary-pic |
d77de738 ML |
25375 | |
25376 | Generate position-independent EABI code. | |
25377 | ||
d77de738 | 25378 | @opindex macc-4 |
ddf6fe37 | 25379 | @item -macc-4 |
d77de738 ML |
25380 | |
25381 | Use only the first four media accumulator registers. | |
25382 | ||
d77de738 | 25383 | @opindex macc-8 |
ddf6fe37 | 25384 | @item -macc-8 |
d77de738 ML |
25385 | |
25386 | Use all eight media accumulator registers. | |
25387 | ||
d77de738 | 25388 | @opindex mpack |
ddf6fe37 | 25389 | @item -mpack |
d77de738 ML |
25390 | |
25391 | Pack VLIW instructions. | |
25392 | ||
d77de738 | 25393 | @opindex mno-pack |
ddf6fe37 | 25394 | @item -mno-pack |
d77de738 ML |
25395 | |
25396 | Do not pack VLIW instructions. | |
25397 | ||
d77de738 | 25398 | @opindex mno-eflags |
ddf6fe37 | 25399 | @item -mno-eflags |
d77de738 ML |
25400 | |
25401 | Do not mark ABI switches in e_flags. | |
25402 | ||
d77de738 | 25403 | @opindex mcond-move |
ddf6fe37 | 25404 | @item -mcond-move |
d77de738 ML |
25405 | |
25406 | Enable the use of conditional-move instructions (default). | |
25407 | ||
25408 | This switch is mainly for debugging the compiler and will likely be removed | |
25409 | in a future version. | |
25410 | ||
d77de738 | 25411 | @opindex mno-cond-move |
ddf6fe37 | 25412 | @item -mno-cond-move |
d77de738 ML |
25413 | |
25414 | Disable the use of conditional-move instructions. | |
25415 | ||
25416 | This switch is mainly for debugging the compiler and will likely be removed | |
25417 | in a future version. | |
25418 | ||
d77de738 | 25419 | @opindex mscc |
ddf6fe37 | 25420 | @item -mscc |
d77de738 ML |
25421 | |
25422 | Enable the use of conditional set instructions (default). | |
25423 | ||
25424 | This switch is mainly for debugging the compiler and will likely be removed | |
25425 | in a future version. | |
25426 | ||
d77de738 | 25427 | @opindex mno-scc |
ddf6fe37 | 25428 | @item -mno-scc |
d77de738 ML |
25429 | |
25430 | Disable the use of conditional set instructions. | |
25431 | ||
25432 | This switch is mainly for debugging the compiler and will likely be removed | |
25433 | in a future version. | |
25434 | ||
d77de738 | 25435 | @opindex mcond-exec |
ddf6fe37 | 25436 | @item -mcond-exec |
d77de738 ML |
25437 | |
25438 | Enable the use of conditional execution (default). | |
25439 | ||
25440 | This switch is mainly for debugging the compiler and will likely be removed | |
25441 | in a future version. | |
25442 | ||
d77de738 | 25443 | @opindex mno-cond-exec |
ddf6fe37 | 25444 | @item -mno-cond-exec |
d77de738 ML |
25445 | |
25446 | Disable the use of conditional execution. | |
25447 | ||
25448 | This switch is mainly for debugging the compiler and will likely be removed | |
25449 | in a future version. | |
25450 | ||
d77de738 | 25451 | @opindex mvliw-branch |
ddf6fe37 | 25452 | @item -mvliw-branch |
d77de738 ML |
25453 | |
25454 | Run a pass to pack branches into VLIW instructions (default). | |
25455 | ||
25456 | This switch is mainly for debugging the compiler and will likely be removed | |
25457 | in a future version. | |
25458 | ||
d77de738 | 25459 | @opindex mno-vliw-branch |
ddf6fe37 | 25460 | @item -mno-vliw-branch |
d77de738 ML |
25461 | |
25462 | Do not run a pass to pack branches into VLIW instructions. | |
25463 | ||
25464 | This switch is mainly for debugging the compiler and will likely be removed | |
25465 | in a future version. | |
25466 | ||
d77de738 | 25467 | @opindex mmulti-cond-exec |
ddf6fe37 | 25468 | @item -mmulti-cond-exec |
d77de738 ML |
25469 | |
25470 | Enable optimization of @code{&&} and @code{||} in conditional execution | |
25471 | (default). | |
25472 | ||
25473 | This switch is mainly for debugging the compiler and will likely be removed | |
25474 | in a future version. | |
25475 | ||
d77de738 | 25476 | @opindex mno-multi-cond-exec |
ddf6fe37 | 25477 | @item -mno-multi-cond-exec |
d77de738 ML |
25478 | |
25479 | Disable optimization of @code{&&} and @code{||} in conditional execution. | |
25480 | ||
25481 | This switch is mainly for debugging the compiler and will likely be removed | |
25482 | in a future version. | |
25483 | ||
d77de738 | 25484 | @opindex mnested-cond-exec |
ddf6fe37 | 25485 | @item -mnested-cond-exec |
d77de738 ML |
25486 | |
25487 | Enable nested conditional execution optimizations (default). | |
25488 | ||
25489 | This switch is mainly for debugging the compiler and will likely be removed | |
25490 | in a future version. | |
25491 | ||
d77de738 | 25492 | @opindex mno-nested-cond-exec |
ddf6fe37 | 25493 | @item -mno-nested-cond-exec |
d77de738 ML |
25494 | |
25495 | Disable nested conditional execution optimizations. | |
25496 | ||
25497 | This switch is mainly for debugging the compiler and will likely be removed | |
25498 | in a future version. | |
25499 | ||
d77de738 | 25500 | @opindex moptimize-membar |
ddf6fe37 | 25501 | @item -moptimize-membar |
d77de738 ML |
25502 | |
25503 | This switch removes redundant @code{membar} instructions from the | |
25504 | compiler-generated code. It is enabled by default. | |
25505 | ||
d77de738 ML |
25506 | @opindex mno-optimize-membar |
25507 | @opindex moptimize-membar | |
ddf6fe37 | 25508 | @item -mno-optimize-membar |
d77de738 ML |
25509 | |
25510 | This switch disables the automatic removal of redundant @code{membar} | |
25511 | instructions from the generated code. | |
25512 | ||
d77de738 | 25513 | @opindex mtomcat-stats |
ddf6fe37 | 25514 | @item -mtomcat-stats |
d77de738 ML |
25515 | |
25516 | Cause gas to print out tomcat statistics. | |
25517 | ||
d77de738 | 25518 | @opindex mcpu |
ddf6fe37 | 25519 | @item -mcpu=@var{cpu} |
d77de738 ML |
25520 | |
25521 | Select the processor type for which to generate code. Possible values are | |
25522 | @samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450}, | |
25523 | @samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}. | |
25524 | ||
25525 | @end table | |
25526 | ||
25527 | @node GNU/Linux Options | |
25528 | @subsection GNU/Linux Options | |
25529 | ||
25530 | These @samp{-m} options are defined for GNU/Linux targets: | |
25531 | ||
25532 | @table @gcctabopt | |
d77de738 | 25533 | @opindex mglibc |
ddf6fe37 | 25534 | @item -mglibc |
d77de738 ML |
25535 | Use the GNU C library. This is the default except |
25536 | on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and | |
25537 | @samp{*-*-linux-*android*} targets. | |
25538 | ||
d77de738 | 25539 | @opindex muclibc |
ddf6fe37 | 25540 | @item -muclibc |
d77de738 ML |
25541 | Use uClibc C library. This is the default on |
25542 | @samp{*-*-linux-*uclibc*} targets. | |
25543 | ||
d77de738 | 25544 | @opindex mmusl |
ddf6fe37 | 25545 | @item -mmusl |
d77de738 ML |
25546 | Use the musl C library. This is the default on |
25547 | @samp{*-*-linux-*musl*} targets. | |
25548 | ||
d77de738 | 25549 | @opindex mbionic |
ddf6fe37 | 25550 | @item -mbionic |
d77de738 ML |
25551 | Use Bionic C library. This is the default on |
25552 | @samp{*-*-linux-*android*} targets. | |
25553 | ||
d77de738 | 25554 | @opindex mandroid |
ddf6fe37 | 25555 | @item -mandroid |
d77de738 ML |
25556 | Compile code compatible with Android platform. This is the default on |
25557 | @samp{*-*-linux-*android*} targets. | |
25558 | ||
25559 | When compiling, this option enables @option{-mbionic}, @option{-fPIC}, | |
25560 | @option{-fno-exceptions} and @option{-fno-rtti} by default. When linking, | |
25561 | this option makes the GCC driver pass Android-specific options to the linker. | |
25562 | Finally, this option causes the preprocessor macro @code{__ANDROID__} | |
25563 | to be defined. | |
25564 | ||
d77de738 | 25565 | @opindex tno-android-cc |
ddf6fe37 | 25566 | @item -tno-android-cc |
d77de738 ML |
25567 | Disable compilation effects of @option{-mandroid}, i.e., do not enable |
25568 | @option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and | |
25569 | @option{-fno-rtti} by default. | |
25570 | ||
d77de738 | 25571 | @opindex tno-android-ld |
ddf6fe37 | 25572 | @item -tno-android-ld |
d77de738 ML |
25573 | Disable linking effects of @option{-mandroid}, i.e., pass standard Linux |
25574 | linking options to the linker. | |
25575 | ||
25576 | @end table | |
25577 | ||
25578 | @node H8/300 Options | |
25579 | @subsection H8/300 Options | |
25580 | ||
25581 | These @samp{-m} options are defined for the H8/300 implementations: | |
25582 | ||
25583 | @table @gcctabopt | |
d77de738 | 25584 | @opindex mrelax |
ddf6fe37 | 25585 | @item -mrelax |
d77de738 ML |
25586 | Shorten some address references at link time, when possible; uses the |
25587 | linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300, | |
25588 | ld, Using ld}, for a fuller description. | |
25589 | ||
d77de738 | 25590 | @opindex mh |
ddf6fe37 | 25591 | @item -mh |
d77de738 ML |
25592 | Generate code for the H8/300H@. |
25593 | ||
d77de738 | 25594 | @opindex ms |
ddf6fe37 | 25595 | @item -ms |
d77de738 ML |
25596 | Generate code for the H8S@. |
25597 | ||
d77de738 | 25598 | @opindex mn |
ddf6fe37 | 25599 | @item -mn |
d77de738 ML |
25600 | Generate code for the H8S and H8/300H in the normal mode. This switch |
25601 | must be used either with @option{-mh} or @option{-ms}. | |
25602 | ||
d77de738 | 25603 | @opindex ms2600 |
ddf6fe37 | 25604 | @item -ms2600 |
d77de738 ML |
25605 | Generate code for the H8S/2600. This switch must be used with @option{-ms}. |
25606 | ||
d77de738 | 25607 | @opindex mexr |
ddf6fe37 | 25608 | @item -mexr |
d77de738 ML |
25609 | Extended registers are stored on stack before execution of function |
25610 | with monitor attribute. Default option is @option{-mexr}. | |
25611 | This option is valid only for H8S targets. | |
25612 | ||
d77de738 ML |
25613 | @opindex mno-exr |
25614 | @opindex mexr | |
ddf6fe37 | 25615 | @item -mno-exr |
d77de738 ML |
25616 | Extended registers are not stored on stack before execution of function |
25617 | with monitor attribute. Default option is @option{-mno-exr}. | |
25618 | This option is valid only for H8S targets. | |
25619 | ||
d77de738 | 25620 | @opindex mint32 |
ddf6fe37 | 25621 | @item -mint32 |
d77de738 ML |
25622 | Make @code{int} data 32 bits by default. |
25623 | ||
d77de738 | 25624 | @opindex malign-300 |
ddf6fe37 | 25625 | @item -malign-300 |
d77de738 ML |
25626 | On the H8/300H and H8S, use the same alignment rules as for the H8/300. |
25627 | The default for the H8/300H and H8S is to align longs and floats on | |
25628 | 4-byte boundaries. | |
25629 | @option{-malign-300} causes them to be aligned on 2-byte boundaries. | |
25630 | This option has no effect on the H8/300. | |
25631 | @end table | |
25632 | ||
25633 | @node HPPA Options | |
25634 | @subsection HPPA Options | |
25635 | @cindex HPPA Options | |
25636 | ||
25637 | These @samp{-m} options are defined for the HPPA family of computers: | |
25638 | ||
25639 | @table @gcctabopt | |
d77de738 | 25640 | @opindex march |
ddf6fe37 | 25641 | @item -march=@var{architecture-type} |
d77de738 ML |
25642 | Generate code for the specified architecture. The choices for |
25643 | @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA | |
25644 | 1.1, and @samp{2.0} for PA 2.0 processors. Refer to | |
25645 | @file{/usr/lib/sched.models} on an HP-UX system to determine the proper | |
25646 | architecture option for your machine. Code compiled for lower numbered | |
25647 | architectures runs on higher numbered architectures, but not the | |
25648 | other way around. | |
25649 | ||
d77de738 ML |
25650 | @opindex mpa-risc-1-0 |
25651 | @opindex mpa-risc-1-1 | |
25652 | @opindex mpa-risc-2-0 | |
ddf6fe37 AA |
25653 | @item -mpa-risc-1-0 |
25654 | @itemx -mpa-risc-1-1 | |
25655 | @itemx -mpa-risc-2-0 | |
d77de738 ML |
25656 | Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively. |
25657 | ||
cf467fb9 JDA |
25658 | @opindex matomic-libcalls |
25659 | @opindex mno-atomic-libcalls | |
ddf6fe37 | 25660 | @item -matomic-libcalls |
cf467fb9 JDA |
25661 | Generate libcalls for atomic loads and stores when sync libcalls are disabled. |
25662 | This option is enabled by default. It only affects the generation of | |
25663 | atomic libcalls by the HPPA backend. | |
25664 | ||
25665 | Both the sync and @file{libatomic} libcall implementations use locking. | |
25666 | As a result, processor stores are not atomic with respect to other | |
25667 | atomic operations. Processor loads up to DImode are atomic with | |
25668 | respect to other atomic operations provided they are implemented as | |
25669 | a single access. | |
25670 | ||
25671 | The PA-RISC architecture does not support any atomic operations in | |
25672 | hardware except for the @code{ldcw} instruction. Thus, all atomic | |
25673 | support is implemented using sync and atomic libcalls. Sync libcall | |
25674 | support is in @file{libgcc.a}. Atomic libcall support is in | |
25675 | @file{libatomic}. | |
25676 | ||
25677 | This option generates @code{__atomic_exchange} calls for atomic stores. | |
25678 | It also provides special handling for atomic DImode accesses on 32-bit | |
25679 | targets. | |
25680 | ||
cf467fb9 | 25681 | @opindex mbig-switch |
ddf6fe37 | 25682 | @item -mbig-switch |
cf467fb9 JDA |
25683 | Does nothing. Preserved for backward compatibility. |
25684 | ||
d77de738 | 25685 | @opindex mcaller-copies |
ddf6fe37 | 25686 | @item -mcaller-copies |
d77de738 ML |
25687 | The caller copies function arguments passed by hidden reference. This |
25688 | option should be used with care as it is not compatible with the default | |
25689 | 32-bit runtime. However, only aggregates larger than eight bytes are | |
25690 | passed by hidden reference and the option provides better compatibility | |
25691 | with OpenMP. | |
25692 | ||
cf467fb9 | 25693 | @opindex mcoherent-ldcw |
ddf6fe37 | 25694 | @item -mcoherent-ldcw |
cf467fb9 | 25695 | Use ldcw/ldcd coherent cache-control hint. |
d77de738 | 25696 | |
d77de738 | 25697 | @opindex mdisable-fpregs |
ddf6fe37 | 25698 | @item -mdisable-fpregs |
cf467fb9 | 25699 | Disable floating-point registers. Equivalent to @code{-msoft-float}. |
d77de738 | 25700 | |
d77de738 | 25701 | @opindex mdisable-indexing |
ddf6fe37 | 25702 | @item -mdisable-indexing |
d77de738 ML |
25703 | Prevent the compiler from using indexing address modes. This avoids some |
25704 | rather obscure problems when compiling MIG generated code under MACH@. | |
25705 | ||
d77de738 | 25706 | @opindex mfast-indirect-calls |
ddf6fe37 | 25707 | @item -mfast-indirect-calls |
d77de738 ML |
25708 | Generate code that assumes calls never cross space boundaries. This |
25709 | allows GCC to emit code that performs faster indirect calls. | |
25710 | ||
25711 | This option does not work in the presence of shared libraries or nested | |
25712 | functions. | |
25713 | ||
d77de738 | 25714 | @opindex mfixed-range |
ddf6fe37 | 25715 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
25716 | Generate code treating the given register range as fixed registers. |
25717 | A fixed register is one that the register allocator cannot use. This is | |
25718 | useful when compiling kernel code. A register range is specified as | |
25719 | two registers separated by a dash. Multiple register ranges can be | |
25720 | specified separated by a comma. | |
25721 | ||
d77de738 | 25722 | @opindex mgas |
ddf6fe37 | 25723 | @item -mgas |
d77de738 ML |
25724 | Enable the use of assembler directives only GAS understands. |
25725 | ||
d77de738 | 25726 | @opindex mgnu-ld |
ddf6fe37 | 25727 | @item -mgnu-ld |
d77de738 ML |
25728 | Use options specific to GNU @command{ld}. |
25729 | This passes @option{-shared} to @command{ld} when | |
25730 | building a shared library. It is the default when GCC is configured, | |
25731 | explicitly or implicitly, with the GNU linker. This option does not | |
25732 | affect which @command{ld} is called; it only changes what parameters | |
25733 | are passed to that @command{ld}. | |
25734 | The @command{ld} that is called is determined by the | |
25735 | @option{--with-ld} configure option, GCC's program search path, and | |
25736 | finally by the user's @env{PATH}. The linker used by GCC can be printed | |
25737 | using @samp{which `gcc -print-prog-name=ld`}. This option is only available | |
25738 | on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}. | |
25739 | ||
d77de738 | 25740 | @opindex mhp-ld |
ddf6fe37 | 25741 | @item -mhp-ld |
d77de738 ML |
25742 | Use options specific to HP @command{ld}. |
25743 | This passes @option{-b} to @command{ld} when building | |
25744 | a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all | |
25745 | links. It is the default when GCC is configured, explicitly or | |
25746 | implicitly, with the HP linker. This option does not affect | |
25747 | which @command{ld} is called; it only changes what parameters are passed to that | |
25748 | @command{ld}. | |
25749 | The @command{ld} that is called is determined by the @option{--with-ld} | |
25750 | configure option, GCC's program search path, and finally by the user's | |
25751 | @env{PATH}. The linker used by GCC can be printed using @samp{which | |
25752 | `gcc -print-prog-name=ld`}. This option is only available on the 64-bit | |
25753 | HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}. | |
25754 | ||
cf467fb9 | 25755 | @opindex mlinker-opt |
ddf6fe37 | 25756 | @item -mlinker-opt |
cf467fb9 JDA |
25757 | Enable the optimization pass in the HP-UX linker. Note this makes symbolic |
25758 | debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9 | |
25759 | linkers in which they give bogus error messages when linking some programs. | |
25760 | ||
d77de738 ML |
25761 | @opindex mno-long-calls |
25762 | @opindex mlong-calls | |
ddf6fe37 | 25763 | @item -mlong-calls |
d77de738 ML |
25764 | Generate code that uses long call sequences. This ensures that a call |
25765 | is always able to reach linker generated stubs. The default is to generate | |
25766 | long calls only when the distance from the call site to the beginning | |
25767 | of the function or translation unit, as the case may be, exceeds a | |
25768 | predefined limit set by the branch type being used. The limits for | |
25769 | normal calls are 7,600,000 and 240,000 bytes, respectively for the | |
25770 | PA 2.0 and PA 1.X architectures. Sibcalls are always limited at | |
25771 | 240,000 bytes. | |
25772 | ||
25773 | Distances are measured from the beginning of functions when using the | |
25774 | @option{-ffunction-sections} option, or when using the @option{-mgas} | |
25775 | and @option{-mno-portable-runtime} options together under HP-UX with | |
25776 | the SOM linker. | |
25777 | ||
25778 | It is normally not desirable to use this option as it degrades | |
25779 | performance. However, it may be useful in large applications, | |
25780 | particularly when partial linking is used to build the application. | |
25781 | ||
25782 | The types of long calls used depends on the capabilities of the | |
25783 | assembler and linker, and the type of code being generated. The | |
25784 | impact on systems that support long absolute calls, and long pic | |
25785 | symbol-difference or pc-relative calls should be relatively small. | |
25786 | However, an indirect call is used on 32-bit ELF systems in pic code | |
25787 | and it is quite long. | |
25788 | ||
cf467fb9 | 25789 | @opindex mlong-load-store |
ddf6fe37 | 25790 | @item -mlong-load-store |
cf467fb9 JDA |
25791 | Generate 3-instruction load and store sequences as sometimes required by |
25792 | the HP-UX 10 linker. This is equivalent to the @samp{+k} option to | |
25793 | the HP compilers. | |
25794 | ||
cf467fb9 | 25795 | @opindex mjump-in-delay |
ddf6fe37 | 25796 | @item -mjump-in-delay |
cf467fb9 JDA |
25797 | This option is ignored and provided for compatibility purposes only. |
25798 | ||
cf467fb9 JDA |
25799 | @opindex mno-space-regs |
25800 | @opindex mspace-regs | |
ddf6fe37 | 25801 | @item -mno-space-regs |
cf467fb9 JDA |
25802 | Generate code that assumes the target has no space registers. This allows |
25803 | GCC to generate faster indirect calls and use unscaled index address modes. | |
25804 | ||
25805 | Such code is suitable for level 0 PA systems and kernels. | |
25806 | ||
cf467fb9 | 25807 | @opindex mordered |
ddf6fe37 | 25808 | @item -mordered |
cf467fb9 JDA |
25809 | Assume memory references are ordered and barriers are not needed. |
25810 | ||
cf467fb9 | 25811 | @opindex mportable-runtime |
ddf6fe37 | 25812 | @item -mportable-runtime |
cf467fb9 JDA |
25813 | Use the portable calling conventions proposed by HP for ELF systems. |
25814 | ||
cf467fb9 | 25815 | @opindex mschedule |
ddf6fe37 | 25816 | @item -mschedule=@var{cpu-type} |
cf467fb9 JDA |
25817 | Schedule code according to the constraints for the machine type |
25818 | @var{cpu-type}. The choices for @var{cpu-type} are @samp{700} | |
25819 | @samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer | |
25820 | to @file{/usr/lib/sched.models} on an HP-UX system to determine the | |
25821 | proper scheduling option for your machine. The default scheduling is | |
25822 | @samp{8000}. | |
25823 | ||
cf467fb9 | 25824 | @opindex msio |
ddf6fe37 | 25825 | @item -msio |
cf467fb9 JDA |
25826 | Generate the predefine, @code{_SIO}, for server IO@. The default is |
25827 | @option{-mwsio}. This generates the predefines, @code{__hp9000s700}, | |
25828 | @code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These | |
25829 | options are available under HP-UX and HI-UX@. | |
25830 | ||
cf467fb9 | 25831 | @opindex msoft-float |
ddf6fe37 | 25832 | @item -msoft-float |
cf467fb9 JDA |
25833 | Generate output containing library calls for floating point. |
25834 | @strong{Warning:} the requisite libraries are not available for all HPPA | |
25835 | targets. Normally the facilities of the machine's usual C compiler are | |
25836 | used, but this cannot be done directly in cross-compilation. You must make | |
25837 | your own arrangements to provide suitable library functions for | |
25838 | cross-compilation. | |
25839 | ||
25840 | @option{-msoft-float} changes the calling convention in the output file; | |
25841 | therefore, it is only useful if you compile @emph{all} of a program with | |
25842 | this option. In particular, you need to compile @file{libgcc.a}, the | |
25843 | library that comes with GCC, with @option{-msoft-float} in order for | |
25844 | this to work. | |
25845 | ||
cf467fb9 | 25846 | @opindex msoft-mult |
ddf6fe37 | 25847 | @item -msoft-mult |
cf467fb9 JDA |
25848 | Use software integer multiplication. |
25849 | ||
25850 | This disables the use of the @code{xmpyu} instruction. | |
25851 | ||
d77de738 | 25852 | @opindex march |
ddf6fe37 | 25853 | @item -munix=@var{unix-std} |
d77de738 ML |
25854 | Generate compiler predefines and select a startfile for the specified |
25855 | UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95} | |
25856 | and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95} | |
25857 | is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX | |
25858 | 11.11 and later. The default values are @samp{93} for HP-UX 10.00, | |
25859 | @samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11 | |
25860 | and later. | |
25861 | ||
25862 | @option{-munix=93} provides the same predefines as GCC 3.3 and 3.4. | |
25863 | @option{-munix=95} provides additional predefines for @code{XOPEN_UNIX} | |
25864 | and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}. | |
25865 | @option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX}, | |
25866 | @code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and | |
25867 | @code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}. | |
25868 | ||
25869 | It is @emph{important} to note that this option changes the interfaces | |
25870 | for various library routines. It also affects the operational behavior | |
25871 | of the C library. Thus, @emph{extreme} care is needed in using this | |
25872 | option. | |
25873 | ||
25874 | Library code that is intended to operate with more than one UNIX | |
25875 | standard must test, set and restore the variable @code{__xpg4_extended_mask} | |
25876 | as appropriate. Most GNU software doesn't provide this capability. | |
25877 | ||
d77de738 | 25878 | @opindex nolibdld |
ddf6fe37 | 25879 | @item -nolibdld |
d77de738 ML |
25880 | Suppress the generation of link options to search libdld.sl when the |
25881 | @option{-static} option is specified on HP-UX 10 and later. | |
25882 | ||
d77de738 | 25883 | @opindex static |
ddf6fe37 | 25884 | @item -static |
d77de738 ML |
25885 | The HP-UX implementation of setlocale in libc has a dependency on |
25886 | libdld.sl. There isn't an archive version of libdld.sl. Thus, | |
25887 | when the @option{-static} option is specified, special link options | |
25888 | are needed to resolve this dependency. | |
25889 | ||
25890 | On HP-UX 10 and later, the GCC driver adds the necessary options to | |
25891 | link with libdld.sl when the @option{-static} option is specified. | |
25892 | This causes the resulting binary to be dynamic. On the 64-bit port, | |
25893 | the linkers generate dynamic binaries by default in any case. The | |
25894 | @option{-nolibdld} option can be used to prevent the GCC driver from | |
25895 | adding these link options. | |
25896 | ||
d77de738 | 25897 | @opindex threads |
ddf6fe37 | 25898 | @item -threads |
d77de738 ML |
25899 | Add support for multithreading with the @dfn{dce thread} library |
25900 | under HP-UX@. This option sets flags for both the preprocessor and | |
25901 | linker. | |
25902 | @end table | |
25903 | ||
25904 | @node IA-64 Options | |
25905 | @subsection IA-64 Options | |
25906 | @cindex IA-64 Options | |
25907 | ||
25908 | These are the @samp{-m} options defined for the Intel IA-64 architecture. | |
25909 | ||
25910 | @table @gcctabopt | |
d77de738 | 25911 | @opindex mbig-endian |
ddf6fe37 | 25912 | @item -mbig-endian |
d77de738 ML |
25913 | Generate code for a big-endian target. This is the default for HP-UX@. |
25914 | ||
d77de738 | 25915 | @opindex mlittle-endian |
ddf6fe37 | 25916 | @item -mlittle-endian |
d77de738 ML |
25917 | Generate code for a little-endian target. This is the default for AIX5 |
25918 | and GNU/Linux. | |
25919 | ||
d77de738 ML |
25920 | @opindex mgnu-as |
25921 | @opindex mno-gnu-as | |
ddf6fe37 AA |
25922 | @item -mgnu-as |
25923 | @itemx -mno-gnu-as | |
d77de738 ML |
25924 | Generate (or don't) code for the GNU assembler. This is the default. |
25925 | @c Also, this is the default if the configure option @option{--with-gnu-as} | |
25926 | @c is used. | |
25927 | ||
d77de738 ML |
25928 | @opindex mgnu-ld |
25929 | @opindex mno-gnu-ld | |
ddf6fe37 AA |
25930 | @item -mgnu-ld |
25931 | @itemx -mno-gnu-ld | |
d77de738 ML |
25932 | Generate (or don't) code for the GNU linker. This is the default. |
25933 | @c Also, this is the default if the configure option @option{--with-gnu-ld} | |
25934 | @c is used. | |
25935 | ||
d77de738 | 25936 | @opindex mno-pic |
ddf6fe37 | 25937 | @item -mno-pic |
d77de738 ML |
25938 | Generate code that does not use a global pointer register. The result |
25939 | is not position independent code, and violates the IA-64 ABI@. | |
25940 | ||
d77de738 ML |
25941 | @opindex mvolatile-asm-stop |
25942 | @opindex mno-volatile-asm-stop | |
ddf6fe37 AA |
25943 | @item -mvolatile-asm-stop |
25944 | @itemx -mno-volatile-asm-stop | |
d77de738 ML |
25945 | Generate (or don't) a stop bit immediately before and after volatile asm |
25946 | statements. | |
25947 | ||
d77de738 ML |
25948 | @opindex mregister-names |
25949 | @opindex mno-register-names | |
ddf6fe37 AA |
25950 | @item -mregister-names |
25951 | @itemx -mno-register-names | |
d77de738 ML |
25952 | Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for |
25953 | the stacked registers. This may make assembler output more readable. | |
25954 | ||
d77de738 ML |
25955 | @opindex mno-sdata |
25956 | @opindex msdata | |
ddf6fe37 AA |
25957 | @item -mno-sdata |
25958 | @itemx -msdata | |
d77de738 ML |
25959 | Disable (or enable) optimizations that use the small data section. This may |
25960 | be useful for working around optimizer bugs. | |
25961 | ||
d77de738 | 25962 | @opindex mconstant-gp |
ddf6fe37 | 25963 | @item -mconstant-gp |
d77de738 ML |
25964 | Generate code that uses a single constant global pointer value. This is |
25965 | useful when compiling kernel code. | |
25966 | ||
d77de738 | 25967 | @opindex mauto-pic |
ddf6fe37 | 25968 | @item -mauto-pic |
d77de738 ML |
25969 | Generate code that is self-relocatable. This implies @option{-mconstant-gp}. |
25970 | This is useful when compiling firmware code. | |
25971 | ||
d77de738 | 25972 | @opindex minline-float-divide-min-latency |
ddf6fe37 | 25973 | @item -minline-float-divide-min-latency |
d77de738 ML |
25974 | Generate code for inline divides of floating-point values |
25975 | using the minimum latency algorithm. | |
25976 | ||
d77de738 | 25977 | @opindex minline-float-divide-max-throughput |
ddf6fe37 | 25978 | @item -minline-float-divide-max-throughput |
d77de738 ML |
25979 | Generate code for inline divides of floating-point values |
25980 | using the maximum throughput algorithm. | |
25981 | ||
d77de738 | 25982 | @opindex mno-inline-float-divide |
ddf6fe37 | 25983 | @item -mno-inline-float-divide |
d77de738 ML |
25984 | Do not generate inline code for divides of floating-point values. |
25985 | ||
d77de738 | 25986 | @opindex minline-int-divide-min-latency |
ddf6fe37 | 25987 | @item -minline-int-divide-min-latency |
d77de738 ML |
25988 | Generate code for inline divides of integer values |
25989 | using the minimum latency algorithm. | |
25990 | ||
d77de738 | 25991 | @opindex minline-int-divide-max-throughput |
ddf6fe37 | 25992 | @item -minline-int-divide-max-throughput |
d77de738 ML |
25993 | Generate code for inline divides of integer values |
25994 | using the maximum throughput algorithm. | |
25995 | ||
d77de738 ML |
25996 | @opindex mno-inline-int-divide |
25997 | @opindex minline-int-divide | |
ddf6fe37 | 25998 | @item -mno-inline-int-divide |
d77de738 ML |
25999 | Do not generate inline code for divides of integer values. |
26000 | ||
d77de738 | 26001 | @opindex minline-sqrt-min-latency |
ddf6fe37 | 26002 | @item -minline-sqrt-min-latency |
d77de738 ML |
26003 | Generate code for inline square roots |
26004 | using the minimum latency algorithm. | |
26005 | ||
d77de738 | 26006 | @opindex minline-sqrt-max-throughput |
ddf6fe37 | 26007 | @item -minline-sqrt-max-throughput |
d77de738 ML |
26008 | Generate code for inline square roots |
26009 | using the maximum throughput algorithm. | |
26010 | ||
d77de738 | 26011 | @opindex mno-inline-sqrt |
ddf6fe37 | 26012 | @item -mno-inline-sqrt |
d77de738 ML |
26013 | Do not generate inline code for @code{sqrt}. |
26014 | ||
d77de738 ML |
26015 | @opindex mfused-madd |
26016 | @opindex mno-fused-madd | |
ddf6fe37 AA |
26017 | @item -mfused-madd |
26018 | @itemx -mno-fused-madd | |
d77de738 ML |
26019 | Do (don't) generate code that uses the fused multiply/add or multiply/subtract |
26020 | instructions. The default is to use these instructions. | |
26021 | ||
d77de738 ML |
26022 | @opindex mno-dwarf2-asm |
26023 | @opindex mdwarf2-asm | |
ddf6fe37 AA |
26024 | @item -mno-dwarf2-asm |
26025 | @itemx -mdwarf2-asm | |
d77de738 ML |
26026 | Don't (or do) generate assembler code for the DWARF line number debugging |
26027 | info. This may be useful when not using the GNU assembler. | |
26028 | ||
d77de738 ML |
26029 | @opindex mearly-stop-bits |
26030 | @opindex mno-early-stop-bits | |
ddf6fe37 AA |
26031 | @item -mearly-stop-bits |
26032 | @itemx -mno-early-stop-bits | |
d77de738 ML |
26033 | Allow stop bits to be placed earlier than immediately preceding the |
26034 | instruction that triggered the stop bit. This can improve instruction | |
26035 | scheduling, but does not always do so. | |
26036 | ||
d77de738 | 26037 | @opindex mfixed-range |
ddf6fe37 | 26038 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
26039 | Generate code treating the given register range as fixed registers. |
26040 | A fixed register is one that the register allocator cannot use. This is | |
26041 | useful when compiling kernel code. A register range is specified as | |
26042 | two registers separated by a dash. Multiple register ranges can be | |
26043 | specified separated by a comma. | |
26044 | ||
d77de738 | 26045 | @opindex mtls-size |
ddf6fe37 | 26046 | @item -mtls-size=@var{tls-size} |
d77de738 ML |
26047 | Specify bit size of immediate TLS offsets. Valid values are 14, 22, and |
26048 | 64. | |
26049 | ||
d77de738 | 26050 | @opindex mtune |
ddf6fe37 | 26051 | @item -mtune=@var{cpu-type} |
d77de738 ML |
26052 | Tune the instruction scheduling for a particular CPU, Valid values are |
26053 | @samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2}, | |
26054 | and @samp{mckinley}. | |
26055 | ||
d77de738 ML |
26056 | @opindex milp32 |
26057 | @opindex mlp64 | |
ddf6fe37 AA |
26058 | @item -milp32 |
26059 | @itemx -mlp64 | |
d77de738 ML |
26060 | Generate code for a 32-bit or 64-bit environment. |
26061 | The 32-bit environment sets int, long and pointer to 32 bits. | |
26062 | The 64-bit environment sets int to 32 bits and long and pointer | |
26063 | to 64 bits. These are HP-UX specific flags. | |
26064 | ||
d77de738 ML |
26065 | @opindex mno-sched-br-data-spec |
26066 | @opindex msched-br-data-spec | |
ddf6fe37 AA |
26067 | @item -mno-sched-br-data-spec |
26068 | @itemx -msched-br-data-spec | |
d77de738 ML |
26069 | (Dis/En)able data speculative scheduling before reload. |
26070 | This results in generation of @code{ld.a} instructions and | |
26071 | the corresponding check instructions (@code{ld.c} / @code{chk.a}). | |
26072 | The default setting is disabled. | |
26073 | ||
d77de738 ML |
26074 | @opindex msched-ar-data-spec |
26075 | @opindex mno-sched-ar-data-spec | |
ddf6fe37 AA |
26076 | @item -msched-ar-data-spec |
26077 | @itemx -mno-sched-ar-data-spec | |
d77de738 ML |
26078 | (En/Dis)able data speculative scheduling after reload. |
26079 | This results in generation of @code{ld.a} instructions and | |
26080 | the corresponding check instructions (@code{ld.c} / @code{chk.a}). | |
26081 | The default setting is enabled. | |
26082 | ||
d77de738 ML |
26083 | @opindex mno-sched-control-spec |
26084 | @opindex msched-control-spec | |
ddf6fe37 AA |
26085 | @item -mno-sched-control-spec |
26086 | @itemx -msched-control-spec | |
d77de738 ML |
26087 | (Dis/En)able control speculative scheduling. This feature is |
26088 | available only during region scheduling (i.e.@: before reload). | |
26089 | This results in generation of the @code{ld.s} instructions and | |
26090 | the corresponding check instructions @code{chk.s}. | |
26091 | The default setting is disabled. | |
26092 | ||
d77de738 ML |
26093 | @opindex msched-br-in-data-spec |
26094 | @opindex mno-sched-br-in-data-spec | |
ddf6fe37 AA |
26095 | @item -msched-br-in-data-spec |
26096 | @itemx -mno-sched-br-in-data-spec | |
d77de738 ML |
26097 | (En/Dis)able speculative scheduling of the instructions that |
26098 | are dependent on the data speculative loads before reload. | |
26099 | This is effective only with @option{-msched-br-data-spec} enabled. | |
26100 | The default setting is enabled. | |
26101 | ||
d77de738 ML |
26102 | @opindex msched-ar-in-data-spec |
26103 | @opindex mno-sched-ar-in-data-spec | |
ddf6fe37 AA |
26104 | @item -msched-ar-in-data-spec |
26105 | @itemx -mno-sched-ar-in-data-spec | |
d77de738 ML |
26106 | (En/Dis)able speculative scheduling of the instructions that |
26107 | are dependent on the data speculative loads after reload. | |
26108 | This is effective only with @option{-msched-ar-data-spec} enabled. | |
26109 | The default setting is enabled. | |
26110 | ||
d77de738 ML |
26111 | @opindex msched-in-control-spec |
26112 | @opindex mno-sched-in-control-spec | |
ddf6fe37 AA |
26113 | @item -msched-in-control-spec |
26114 | @itemx -mno-sched-in-control-spec | |
d77de738 ML |
26115 | (En/Dis)able speculative scheduling of the instructions that |
26116 | are dependent on the control speculative loads. | |
26117 | This is effective only with @option{-msched-control-spec} enabled. | |
26118 | The default setting is enabled. | |
26119 | ||
d77de738 ML |
26120 | @opindex mno-sched-prefer-non-data-spec-insns |
26121 | @opindex msched-prefer-non-data-spec-insns | |
ddf6fe37 AA |
26122 | @item -mno-sched-prefer-non-data-spec-insns |
26123 | @itemx -msched-prefer-non-data-spec-insns | |
d77de738 ML |
26124 | If enabled, data-speculative instructions are chosen for schedule |
26125 | only if there are no other choices at the moment. This makes | |
26126 | the use of the data speculation much more conservative. | |
26127 | The default setting is disabled. | |
26128 | ||
d77de738 ML |
26129 | @opindex mno-sched-prefer-non-control-spec-insns |
26130 | @opindex msched-prefer-non-control-spec-insns | |
ddf6fe37 AA |
26131 | @item -mno-sched-prefer-non-control-spec-insns |
26132 | @itemx -msched-prefer-non-control-spec-insns | |
d77de738 ML |
26133 | If enabled, control-speculative instructions are chosen for schedule |
26134 | only if there are no other choices at the moment. This makes | |
26135 | the use of the control speculation much more conservative. | |
26136 | The default setting is disabled. | |
26137 | ||
d77de738 ML |
26138 | @opindex mno-sched-count-spec-in-critical-path |
26139 | @opindex msched-count-spec-in-critical-path | |
ddf6fe37 AA |
26140 | @item -mno-sched-count-spec-in-critical-path |
26141 | @itemx -msched-count-spec-in-critical-path | |
d77de738 ML |
26142 | If enabled, speculative dependencies are considered during |
26143 | computation of the instructions priorities. This makes the use of the | |
26144 | speculation a bit more conservative. | |
26145 | The default setting is disabled. | |
26146 | ||
d77de738 | 26147 | @opindex msched-spec-ldc |
ddf6fe37 | 26148 | @item -msched-spec-ldc |
d77de738 ML |
26149 | Use a simple data speculation check. This option is on by default. |
26150 | ||
d77de738 | 26151 | @opindex msched-spec-ldc |
ddf6fe37 | 26152 | @item -msched-control-spec-ldc |
d77de738 ML |
26153 | Use a simple check for control speculation. This option is on by default. |
26154 | ||
d77de738 | 26155 | @opindex msched-stop-bits-after-every-cycle |
ddf6fe37 | 26156 | @item -msched-stop-bits-after-every-cycle |
d77de738 ML |
26157 | Place a stop bit after every cycle when scheduling. This option is on |
26158 | by default. | |
26159 | ||
d77de738 | 26160 | @opindex msched-fp-mem-deps-zero-cost |
ddf6fe37 | 26161 | @item -msched-fp-mem-deps-zero-cost |
d77de738 ML |
26162 | Assume that floating-point stores and loads are not likely to cause a conflict |
26163 | when placed into the same instruction group. This option is disabled by | |
26164 | default. | |
26165 | ||
d77de738 | 26166 | @opindex msel-sched-dont-check-control-spec |
ddf6fe37 | 26167 | @item -msel-sched-dont-check-control-spec |
d77de738 ML |
26168 | Generate checks for control speculation in selective scheduling. |
26169 | This flag is disabled by default. | |
26170 | ||
d77de738 | 26171 | @opindex msched-max-memory-insns |
ddf6fe37 | 26172 | @item -msched-max-memory-insns=@var{max-insns} |
d77de738 ML |
26173 | Limit on the number of memory insns per instruction group, giving lower |
26174 | priority to subsequent memory insns attempting to schedule in the same | |
26175 | instruction group. Frequently useful to prevent cache bank conflicts. | |
26176 | The default value is 1. | |
26177 | ||
d77de738 | 26178 | @opindex msched-max-memory-insns-hard-limit |
ddf6fe37 | 26179 | @item -msched-max-memory-insns-hard-limit |
d77de738 ML |
26180 | Makes the limit specified by @option{msched-max-memory-insns} a hard limit, |
26181 | disallowing more than that number in an instruction group. | |
26182 | Otherwise, the limit is ``soft'', meaning that non-memory operations | |
26183 | are preferred when the limit is reached, but memory operations may still | |
26184 | be scheduled. | |
26185 | ||
26186 | @end table | |
26187 | ||
26188 | @node LM32 Options | |
26189 | @subsection LM32 Options | |
26190 | @cindex LM32 options | |
26191 | ||
26192 | These @option{-m} options are defined for the LatticeMico32 architecture: | |
26193 | ||
26194 | @table @gcctabopt | |
d77de738 | 26195 | @opindex mbarrel-shift-enabled |
ddf6fe37 | 26196 | @item -mbarrel-shift-enabled |
d77de738 ML |
26197 | Enable barrel-shift instructions. |
26198 | ||
d77de738 | 26199 | @opindex mdivide-enabled |
ddf6fe37 | 26200 | @item -mdivide-enabled |
d77de738 ML |
26201 | Enable divide and modulus instructions. |
26202 | ||
d77de738 | 26203 | @opindex multiply-enabled |
ddf6fe37 | 26204 | @item -mmultiply-enabled |
d77de738 ML |
26205 | Enable multiply instructions. |
26206 | ||
d77de738 | 26207 | @opindex msign-extend-enabled |
ddf6fe37 | 26208 | @item -msign-extend-enabled |
d77de738 ML |
26209 | Enable sign extend instructions. |
26210 | ||
d77de738 | 26211 | @opindex muser-enabled |
ddf6fe37 | 26212 | @item -muser-enabled |
d77de738 ML |
26213 | Enable user-defined instructions. |
26214 | ||
26215 | @end table | |
26216 | ||
26217 | @node LoongArch Options | |
26218 | @subsection LoongArch Options | |
26219 | @cindex LoongArch Options | |
26220 | ||
26221 | These command-line options are defined for LoongArch targets: | |
26222 | ||
26223 | @table @gcctabopt | |
9c19597c | 26224 | @opindex march |
ddf6fe37 | 26225 | @item -march=@var{cpu-type} |
d77de738 ML |
26226 | Generate instructions for the machine type @var{cpu-type}. In contrast to |
26227 | @option{-mtune=@var{cpu-type}}, which merely tunes the generated code | |
26228 | for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC | |
26229 | to generate code that may not run at all on processors other than the one | |
26230 | indicated. Specifying @option{-march=@var{cpu-type}} implies | |
26231 | @option{-mtune=@var{cpu-type}}, except where noted otherwise. | |
26232 | ||
26233 | The choices for @var{cpu-type} are: | |
26234 | ||
26235 | @table @samp | |
26236 | @item native | |
26237 | This selects the CPU to generate code for at compilation time by determining | |
26238 | the processor type of the compiling machine. Using @option{-march=native} | |
26239 | enables all instruction subsets supported by the local machine (hence | |
26240 | the result might not run on different machines). Using @option{-mtune=native} | |
26241 | produces code optimized for the local machine under the constraints | |
26242 | of the selected instruction set. | |
26243 | @item loongarch64 | |
26244 | A generic CPU with 64-bit extensions. | |
26245 | @item la464 | |
26246 | LoongArch LA464 CPU with LBT, LSX, LASX, LVZ. | |
26247 | @end table | |
26248 | ||
d77de738 | 26249 | @opindex mtune |
ddf6fe37 | 26250 | @item -mtune=@var{cpu-type} |
d77de738 ML |
26251 | Optimize the output for the given processor, specified by microarchitecture |
26252 | name. | |
26253 | ||
d77de738 | 26254 | @opindex mabi |
ddf6fe37 | 26255 | @item -mabi=@var{base-abi-type} |
d77de738 ML |
26256 | Generate code for the specified calling convention. |
26257 | @var{base-abi-type} can be one of: | |
26258 | @table @samp | |
26259 | @item lp64d | |
26260 | Uses 64-bit general purpose registers and 32/64-bit floating-point | |
26261 | registers for parameter passing. Data model is LP64, where @samp{int} | |
26262 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
26263 | @item lp64f | |
26264 | Uses 64-bit general purpose registers and 32-bit floating-point | |
26265 | registers for parameter passing. Data model is LP64, where @samp{int} | |
26266 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
26267 | @item lp64s | |
26268 | Uses 64-bit general purpose registers and no floating-point | |
26269 | registers for parameter passing. Data model is LP64, where @samp{int} | |
26270 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
26271 | @end table | |
26272 | ||
d77de738 | 26273 | @opindex mfpu |
ddf6fe37 | 26274 | @item -mfpu=@var{fpu-type} |
d77de738 ML |
26275 | Generate code for the specified FPU type, which can be one of: |
26276 | @table @samp | |
26277 | @item 64 | |
26278 | Allow the use of hardware floating-point instructions for 32-bit | |
26279 | and 64-bit operations. | |
26280 | @item 32 | |
26281 | Allow the use of hardware floating-point instructions for 32-bit | |
26282 | operations. | |
26283 | @item none | |
26284 | @item 0 | |
26285 | Prevent the use of hardware floating-point instructions. | |
26286 | @end table | |
26287 | ||
bb4a8198 YY |
26288 | @opindex msimd |
26289 | @item -msimd=@var{simd-type} | |
26290 | Enable generation of LoongArch SIMD instructions for vectorization | |
26291 | and via builtin functions. The value can be one of: | |
26292 | @table @samp | |
26293 | @item lasx | |
26294 | Enable generating instructions from the 256-bit LoongArch Advanced | |
26295 | SIMD Extension (LASX) and the 128-bit LoongArch SIMD Extension (LSX). | |
26296 | @item lsx | |
26297 | Enable generating instructions from the 128-bit LoongArch SIMD | |
26298 | Extension (LSX). | |
26299 | @item none | |
26300 | No LoongArch SIMD instruction may be generated. | |
26301 | @end table | |
26302 | ||
d77de738 | 26303 | @opindex msoft-float |
ddf6fe37 | 26304 | @item -msoft-float |
d77de738 ML |
26305 | Force @option{-mfpu=none} and prevents the use of floating-point |
26306 | registers for parameter passing. This option may change the target | |
26307 | ABI. | |
26308 | ||
9c19597c | 26309 | @opindex msingle-float |
ddf6fe37 | 26310 | @item -msingle-float |
d77de738 ML |
26311 | Force @option{-mfpu=32} and allow the use of 32-bit floating-point |
26312 | registers for parameter passing. This option may change the target | |
26313 | ABI. | |
26314 | ||
9c19597c | 26315 | @opindex mdouble-float |
ddf6fe37 | 26316 | @item -mdouble-float |
d77de738 ML |
26317 | Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point |
26318 | registers for parameter passing. This option may change the target | |
26319 | ABI. | |
26320 | ||
bb4a8198 YY |
26321 | @opindex ml[a]sx |
26322 | @item -mlasx | |
26323 | @itemx -mno-lasx | |
26324 | @item -mlsx | |
26325 | @itemx -mno-lsx | |
26326 | Incrementally adjust the scope of the SIMD extensions (none / LSX / LASX) | |
26327 | that can be used by the compiler for code generation. Enabling LASX with | |
26328 | @option{mlasx} automatically enables LSX, and diabling LSX with @option{mno-lsx} | |
26329 | automatically disables LASX. These driver-only options act upon the final | |
26330 | @option{msimd} configuration state and make incremental chagnes in the order | |
26331 | they appear on the GCC driver's command line, deriving the final / canonicalized | |
26332 | @option{msimd} option that is passed to the compiler proper. | |
26333 | ||
9c19597c | 26334 | @opindex mbranch-cost |
ddf6fe37 | 26335 | @item -mbranch-cost=@var{n} |
d77de738 ML |
26336 | Set the cost of branches to roughly @var{n} instructions. |
26337 | ||
ddf6fe37 | 26338 | @opindex mcheck-zero-division |
d77de738 ML |
26339 | @item -mcheck-zero-division |
26340 | @itemx -mno-check-zero-divison | |
d77de738 ML |
26341 | Trap (do not trap) on integer division by zero. The default is |
26342 | @option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and | |
26343 | @option{-mno-check-zero-division} for other optimization levels. | |
26344 | ||
ddf6fe37 | 26345 | @opindex mcond-move-int |
d77de738 ML |
26346 | @item -mcond-move-int |
26347 | @itemx -mno-cond-move-int | |
d77de738 ML |
26348 | Conditional moves for integral data in general-purpose registers |
26349 | are enabled (disabled). The default is @option{-mcond-move-int}. | |
26350 | ||
ddf6fe37 | 26351 | @opindex mcond-move-float |
d77de738 ML |
26352 | @item -mcond-move-float |
26353 | @itemx -mno-cond-move-float | |
d77de738 ML |
26354 | Conditional moves for floating-point registers are enabled (disabled). |
26355 | The default is @option{-mcond-move-float}. | |
26356 | ||
ddf6fe37 | 26357 | @opindex mmemcpy |
d77de738 ML |
26358 | @item -mmemcpy |
26359 | @itemx -mno-memcpy | |
d77de738 ML |
26360 | Force (do not force) the use of @code{memcpy} for non-trivial block moves. |
26361 | The default is @option{-mno-memcpy}, which allows GCC to inline most | |
26362 | constant-sized copies. Setting optimization level to @option{-Os} also | |
26363 | forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this | |
26364 | behavior if explicitly specified, regardless of the order these options on | |
26365 | the command line. | |
26366 | ||
ddf6fe37 | 26367 | @opindex mstrict-align |
d77de738 ML |
26368 | @item -mstrict-align |
26369 | @itemx -mno-strict-align | |
d77de738 ML |
26370 | Avoid or allow generating memory accesses that may not be aligned on a natural |
26371 | object boundary as described in the architecture specification. The default is | |
26372 | @option{-mno-strict-align}. | |
26373 | ||
9c19597c | 26374 | @opindex msmall-data-limit |
ddf6fe37 | 26375 | @item -msmall-data-limit=@var{number} |
d77de738 ML |
26376 | Put global and static data smaller than @var{number} bytes into a special |
26377 | section (on some targets). The default value is 0. | |
26378 | ||
9c19597c | 26379 | @opindex mmax-inline-memcpy-size |
ddf6fe37 | 26380 | @item -mmax-inline-memcpy-size=@var{n} |
d77de738 ML |
26381 | Inline all block moves (such as calls to @code{memcpy} or structure copies) |
26382 | less than or equal to @var{n} bytes. The default value of @var{n} is 1024. | |
26383 | ||
26384 | @item -mcmodel=@var{code-model} | |
26385 | Set the code model to one of: | |
26386 | @table @samp | |
26387 | @item tiny-static (Not implemented yet) | |
26388 | @item tiny (Not implemented yet) | |
26389 | ||
26390 | @item normal | |
26391 | The text segment must be within 128MB addressing space. The data segment must | |
26392 | be within 2GB addressing space. | |
26393 | ||
26394 | @item medium | |
26395 | The text segment and data segment must be within 2GB addressing space. | |
26396 | ||
26397 | @item large (Not implemented yet) | |
26398 | ||
26399 | @item extreme | |
26400 | This mode does not limit the size of the code segment and data segment. | |
e1b1cba1 XR |
26401 | The @option{-mcmodel=extreme} option is incompatible with @option{-fplt}, |
26402 | and it requires @option{-mexplicit-relocs=always}. | |
d77de738 ML |
26403 | @end table |
26404 | The default code model is @code{normal}. | |
26405 | ||
e1b1cba1 XR |
26406 | @item -mexplicit-relocs=@var{style} |
26407 | Set when to use assembler relocation operators when dealing with symbolic | |
d77de738 | 26408 | addresses. The alternative is to use assembler macros instead, which may |
e1b1cba1 XR |
26409 | limit instruction scheduling but allow linker relaxation. |
26410 | with @option{-mexplicit-relocs=none} the assembler macros are always used, | |
26411 | with @option{-mexplicit-relocs=always} the assembler relocation operators | |
26412 | are always used, with @option{-mexplicit-relocs=auto} the compiler will | |
26413 | use the relocation operators where the linker relaxation is impossible to | |
26414 | improve the code quality, and macros elsewhere. The default | |
fe23a2ff XR |
26415 | value for the option is determined with the assembler capability detected |
26416 | during GCC build-time and the setting of @option{-mrelax}: | |
e1b1cba1 XR |
26417 | @option{-mexplicit-relocs=none} if the assembler does not support |
26418 | relocation operators at all, | |
26419 | @option{-mexplicit-relocs=always} if the assembler supports relocation | |
fe23a2ff XR |
26420 | operators but @option{-mrelax} is not enabled, |
26421 | @option{-mexplicit-relocs=auto} if the assembler supports relocation | |
26422 | operators and @option{-mrelax} is enabled. | |
d77de738 | 26423 | |
e1b1cba1 XR |
26424 | @opindex mexplicit-relocs |
26425 | @item -mexplicit-relocs | |
26426 | An alias of @option{-mexplicit-relocs=always} for backward compatibility. | |
26427 | ||
26428 | @opindex mno-explicit-relocs | |
26429 | @item -mno-explicit-relocs | |
26430 | An alias of @option{-mexplicit-relocs=none} for backward compatibility. | |
26431 | ||
ddf6fe37 | 26432 | @opindex mdirect-extern-access |
d77de738 ML |
26433 | @item -mdirect-extern-access |
26434 | @itemx -mno-direct-extern-access | |
d77de738 ML |
26435 | Do not use or use GOT to access external symbols. The default is |
26436 | @option{-mno-direct-extern-access}: GOT is used for external symbols with | |
26437 | default visibility, but not used for other external symbols. | |
26438 | ||
26439 | With @option{-mdirect-extern-access}, GOT is not used and all external | |
26440 | symbols are PC-relatively addressed. It is @strong{only} suitable for | |
26441 | environments where no dynamic link is performed, like firmwares, OS | |
26442 | kernels, executables linked with @option{-static} or @option{-static-pie}. | |
26443 | @option{-mdirect-extern-access} is not compatible with @option{-fPIC} or | |
26444 | @option{-fpic}. | |
8f4bbdc2 | 26445 | |
fe23a2ff XR |
26446 | @item -mrelax |
26447 | @itemx -mno-relax | |
26448 | Take (do not take) advantage of linker relaxations. If | |
26449 | @option{-mpass-mrelax-to-as} is enabled, this option is also passed to | |
26450 | the assembler. The default is determined during GCC build-time by | |
26451 | detecting corresponding assembler support: | |
26452 | @option{-mrelax} if the assembler supports both the @option{-mrelax} | |
26453 | option and the conditional branch relaxation (it's required or the | |
26454 | @code{.align} directives and conditional branch instructions in the | |
26455 | assembly code outputted by GCC may be rejected by the assembler because | |
26456 | of a relocation overflow), @option{-mno-relax} otherwise. | |
26457 | ||
26458 | @item -mpass-mrelax-to-as | |
26459 | @itemx -mno-pass-mrelax-to-as | |
26460 | Pass (do not pass) the @option{-mrelax} or @option{-mno-relax} option | |
26461 | to the assembler. The default is determined during GCC build-time by | |
26462 | detecting corresponding assembler support: | |
26463 | @option{-mpass-mrelax-to-as} if the assembler supports the | |
26464 | @option{-mrelax} option, @option{-mno-pass-mrelax-to-as} otherwise. | |
26465 | This option is mostly useful for debugging, or interoperation with | |
26466 | assemblers different from the build-time one. | |
26467 | ||
8f4bbdc2 JX |
26468 | @item loongarch-vect-unroll-limit |
26469 | The vectorizer will use available tuning information to determine whether it | |
26470 | would be beneficial to unroll the main vectorized loop and by how much. This | |
26471 | parameter set's the upper bound of how much the vectorizer will unroll the main | |
26472 | loop. The default value is six. | |
26473 | ||
d77de738 ML |
26474 | @end table |
26475 | ||
bb4a8198 | 26476 | |
d77de738 ML |
26477 | @node M32C Options |
26478 | @subsection M32C Options | |
26479 | @cindex M32C options | |
26480 | ||
26481 | @table @gcctabopt | |
d77de738 | 26482 | @opindex mcpu= |
ddf6fe37 | 26483 | @item -mcpu=@var{name} |
d77de738 ML |
26484 | Select the CPU for which code is generated. @var{name} may be one of |
26485 | @samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to | |
26486 | /60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for | |
26487 | the M32C/80 series. | |
26488 | ||
d77de738 | 26489 | @opindex msim |
ddf6fe37 | 26490 | @item -msim |
d77de738 ML |
26491 | Specifies that the program will be run on the simulator. This causes |
26492 | an alternate runtime library to be linked in which supports, for | |
26493 | example, file I/O@. You must not use this option when generating | |
26494 | programs that will run on real hardware; you must provide your own | |
26495 | runtime library for whatever I/O functions are needed. | |
26496 | ||
d77de738 | 26497 | @opindex memregs= |
ddf6fe37 | 26498 | @item -memregs=@var{number} |
d77de738 ML |
26499 | Specifies the number of memory-based pseudo-registers GCC uses |
26500 | during code generation. These pseudo-registers are used like real | |
26501 | registers, so there is a tradeoff between GCC's ability to fit the | |
26502 | code into available registers, and the performance penalty of using | |
26503 | memory instead of registers. Note that all modules in a program must | |
26504 | be compiled with the same value for this option. Because of that, you | |
26505 | must not use this option with GCC's default runtime libraries. | |
26506 | ||
26507 | @end table | |
26508 | ||
26509 | @node M32R/D Options | |
26510 | @subsection M32R/D Options | |
26511 | @cindex M32R/D options | |
26512 | ||
26513 | These @option{-m} options are defined for Renesas M32R/D architectures: | |
26514 | ||
26515 | @table @gcctabopt | |
d77de738 | 26516 | @opindex m32r2 |
ddf6fe37 | 26517 | @item -m32r2 |
d77de738 ML |
26518 | Generate code for the M32R/2@. |
26519 | ||
d77de738 | 26520 | @opindex m32rx |
ddf6fe37 | 26521 | @item -m32rx |
d77de738 ML |
26522 | Generate code for the M32R/X@. |
26523 | ||
d77de738 | 26524 | @opindex m32r |
ddf6fe37 | 26525 | @item -m32r |
d77de738 ML |
26526 | Generate code for the M32R@. This is the default. |
26527 | ||
d77de738 | 26528 | @opindex mmodel=small |
ddf6fe37 | 26529 | @item -mmodel=small |
d77de738 ML |
26530 | Assume all objects live in the lower 16MB of memory (so that their addresses |
26531 | can be loaded with the @code{ld24} instruction), and assume all subroutines | |
26532 | are reachable with the @code{bl} instruction. | |
26533 | This is the default. | |
26534 | ||
26535 | The addressability of a particular object can be set with the | |
26536 | @code{model} attribute. | |
26537 | ||
d77de738 | 26538 | @opindex mmodel=medium |
ddf6fe37 | 26539 | @item -mmodel=medium |
d77de738 ML |
26540 | Assume objects may be anywhere in the 32-bit address space (the compiler |
26541 | generates @code{seth/add3} instructions to load their addresses), and | |
26542 | assume all subroutines are reachable with the @code{bl} instruction. | |
26543 | ||
d77de738 | 26544 | @opindex mmodel=large |
ddf6fe37 | 26545 | @item -mmodel=large |
d77de738 ML |
26546 | Assume objects may be anywhere in the 32-bit address space (the compiler |
26547 | generates @code{seth/add3} instructions to load their addresses), and | |
26548 | assume subroutines may not be reachable with the @code{bl} instruction | |
26549 | (the compiler generates the much slower @code{seth/add3/jl} | |
26550 | instruction sequence). | |
26551 | ||
d77de738 | 26552 | @opindex msdata=none |
ddf6fe37 | 26553 | @item -msdata=none |
d77de738 ML |
26554 | Disable use of the small data area. Variables are put into |
26555 | one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the | |
26556 | @code{section} attribute has been specified). | |
26557 | This is the default. | |
26558 | ||
26559 | The small data area consists of sections @code{.sdata} and @code{.sbss}. | |
26560 | Objects may be explicitly put in the small data area with the | |
26561 | @code{section} attribute using one of these sections. | |
26562 | ||
d77de738 | 26563 | @opindex msdata=sdata |
ddf6fe37 | 26564 | @item -msdata=sdata |
d77de738 ML |
26565 | Put small global and static data in the small data area, but do not |
26566 | generate special code to reference them. | |
26567 | ||
d77de738 | 26568 | @opindex msdata=use |
ddf6fe37 | 26569 | @item -msdata=use |
d77de738 ML |
26570 | Put small global and static data in the small data area, and generate |
26571 | special instructions to reference them. | |
26572 | ||
d77de738 ML |
26573 | @opindex G |
26574 | @cindex smaller data references | |
f33d7a88 | 26575 | @item -G @var{num} |
d77de738 ML |
26576 | Put global and static objects less than or equal to @var{num} bytes |
26577 | into the small data or BSS sections instead of the normal data or BSS | |
26578 | sections. The default value of @var{num} is 8. | |
26579 | The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use} | |
26580 | for this option to have any effect. | |
26581 | ||
26582 | All modules should be compiled with the same @option{-G @var{num}} value. | |
26583 | Compiling with different values of @var{num} may or may not work; if it | |
26584 | doesn't the linker gives an error message---incorrect code is not | |
26585 | generated. | |
26586 | ||
d77de738 | 26587 | @opindex mdebug |
ddf6fe37 | 26588 | @item -mdebug |
d77de738 ML |
26589 | Makes the M32R-specific code in the compiler display some statistics |
26590 | that might help in debugging programs. | |
26591 | ||
d77de738 | 26592 | @opindex malign-loops |
ddf6fe37 | 26593 | @item -malign-loops |
d77de738 ML |
26594 | Align all loops to a 32-byte boundary. |
26595 | ||
d77de738 | 26596 | @opindex mno-align-loops |
ddf6fe37 | 26597 | @item -mno-align-loops |
d77de738 ML |
26598 | Do not enforce a 32-byte alignment for loops. This is the default. |
26599 | ||
d77de738 | 26600 | @opindex missue-rate=@var{number} |
ddf6fe37 | 26601 | @item -missue-rate=@var{number} |
d77de738 ML |
26602 | Issue @var{number} instructions per cycle. @var{number} can only be 1 |
26603 | or 2. | |
26604 | ||
d77de738 | 26605 | @opindex mbranch-cost=@var{number} |
ddf6fe37 | 26606 | @item -mbranch-cost=@var{number} |
d77de738 ML |
26607 | @var{number} can only be 1 or 2. If it is 1 then branches are |
26608 | preferred over conditional code, if it is 2, then the opposite applies. | |
26609 | ||
d77de738 | 26610 | @opindex mflush-trap=@var{number} |
ddf6fe37 | 26611 | @item -mflush-trap=@var{number} |
d77de738 ML |
26612 | Specifies the trap number to use to flush the cache. The default is |
26613 | 12. Valid numbers are between 0 and 15 inclusive. | |
26614 | ||
d77de738 | 26615 | @opindex mno-flush-trap |
ddf6fe37 | 26616 | @item -mno-flush-trap |
d77de738 ML |
26617 | Specifies that the cache cannot be flushed by using a trap. |
26618 | ||
d77de738 | 26619 | @opindex mflush-func=@var{name} |
ddf6fe37 | 26620 | @item -mflush-func=@var{name} |
d77de738 ML |
26621 | Specifies the name of the operating system function to call to flush |
26622 | the cache. The default is @samp{_flush_cache}, but a function call | |
26623 | is only used if a trap is not available. | |
26624 | ||
d77de738 | 26625 | @opindex mno-flush-func |
ddf6fe37 | 26626 | @item -mno-flush-func |
d77de738 ML |
26627 | Indicates that there is no OS function for flushing the cache. |
26628 | ||
26629 | @end table | |
26630 | ||
26631 | @node M680x0 Options | |
26632 | @subsection M680x0 Options | |
26633 | @cindex M680x0 options | |
26634 | ||
26635 | These are the @samp{-m} options defined for M680x0 and ColdFire processors. | |
26636 | The default settings depend on which architecture was selected when | |
26637 | the compiler was configured; the defaults for the most common choices | |
26638 | are given below. | |
26639 | ||
26640 | @table @gcctabopt | |
d77de738 | 26641 | @opindex march |
ddf6fe37 | 26642 | @item -march=@var{arch} |
d77de738 ML |
26643 | Generate code for a specific M680x0 or ColdFire instruction set |
26644 | architecture. Permissible values of @var{arch} for M680x0 | |
26645 | architectures are: @samp{68000}, @samp{68010}, @samp{68020}, | |
26646 | @samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire | |
26647 | architectures are selected according to Freescale's ISA classification | |
26648 | and the permissible values are: @samp{isaa}, @samp{isaaplus}, | |
26649 | @samp{isab} and @samp{isac}. | |
26650 | ||
26651 | GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating | |
26652 | code for a ColdFire target. The @var{arch} in this macro is one of the | |
26653 | @option{-march} arguments given above. | |
26654 | ||
26655 | When used together, @option{-march} and @option{-mtune} select code | |
26656 | that runs on a family of similar processors but that is optimized | |
26657 | for a particular microarchitecture. | |
26658 | ||
d77de738 | 26659 | @opindex mcpu |
ddf6fe37 | 26660 | @item -mcpu=@var{cpu} |
d77de738 ML |
26661 | Generate code for a specific M680x0 or ColdFire processor. |
26662 | The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020}, | |
26663 | @samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332} | |
26664 | and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table | |
26665 | below, which also classifies the CPUs into families: | |
26666 | ||
26667 | @multitable @columnfractions 0.20 0.80 | |
26668 | @headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments} | |
26669 | @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} | |
26670 | @item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206} | |
26671 | @item @samp{5206e} @tab @samp{5206e} | |
26672 | @item @samp{5208} @tab @samp{5207} @samp{5208} | |
26673 | @item @samp{5211a} @tab @samp{5210a} @samp{5211a} | |
26674 | @item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213} | |
26675 | @item @samp{5216} @tab @samp{5214} @samp{5216} | |
26676 | @item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235} | |
26677 | @item @samp{5225} @tab @samp{5224} @samp{5225} | |
26678 | @item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259} | |
26679 | @item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x} | |
26680 | @item @samp{5249} @tab @samp{5249} | |
26681 | @item @samp{5250} @tab @samp{5250} | |
26682 | @item @samp{5271} @tab @samp{5270} @samp{5271} | |
26683 | @item @samp{5272} @tab @samp{5272} | |
26684 | @item @samp{5275} @tab @samp{5274} @samp{5275} | |
26685 | @item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x} | |
26686 | @item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017} | |
26687 | @item @samp{5307} @tab @samp{5307} | |
26688 | @item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x} | |
26689 | @item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x} | |
26690 | @item @samp{5407} @tab @samp{5407} | |
26691 | @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} | |
26692 | @end multitable | |
26693 | ||
26694 | @option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if | |
26695 | @var{arch} is compatible with @var{cpu}. Other combinations of | |
26696 | @option{-mcpu} and @option{-march} are rejected. | |
26697 | ||
26698 | GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target | |
26699 | @var{cpu} is selected. It also defines @code{__mcf_family_@var{family}}, | |
26700 | where the value of @var{family} is given by the table above. | |
26701 | ||
d77de738 | 26702 | @opindex mtune |
ddf6fe37 | 26703 | @item -mtune=@var{tune} |
d77de738 ML |
26704 | Tune the code for a particular microarchitecture within the |
26705 | constraints set by @option{-march} and @option{-mcpu}. | |
26706 | The M680x0 microarchitectures are: @samp{68000}, @samp{68010}, | |
26707 | @samp{68020}, @samp{68030}, @samp{68040}, @samp{68060} | |
26708 | and @samp{cpu32}. The ColdFire microarchitectures | |
26709 | are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}. | |
26710 | ||
26711 | You can also use @option{-mtune=68020-40} for code that needs | |
26712 | to run relatively well on 68020, 68030 and 68040 targets. | |
26713 | @option{-mtune=68020-60} is similar but includes 68060 targets | |
26714 | as well. These two options select the same tuning decisions as | |
26715 | @option{-m68020-40} and @option{-m68020-60} respectively. | |
26716 | ||
26717 | GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__} | |
26718 | when tuning for 680x0 architecture @var{arch}. It also defines | |
26719 | @code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std} | |
26720 | option is used. If GCC is tuning for a range of architectures, | |
26721 | as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60}, | |
26722 | it defines the macros for every architecture in the range. | |
26723 | ||
26724 | GCC also defines the macro @code{__m@var{uarch}__} when tuning for | |
26725 | ColdFire microarchitecture @var{uarch}, where @var{uarch} is one | |
26726 | of the arguments given above. | |
26727 | ||
d77de738 ML |
26728 | @opindex m68000 |
26729 | @opindex mc68000 | |
ddf6fe37 AA |
26730 | @item -m68000 |
26731 | @itemx -mc68000 | |
d77de738 ML |
26732 | Generate output for a 68000. This is the default |
26733 | when the compiler is configured for 68000-based systems. | |
26734 | It is equivalent to @option{-march=68000}. | |
26735 | ||
26736 | Use this option for microcontrollers with a 68000 or EC000 core, | |
26737 | including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356. | |
26738 | ||
d77de738 | 26739 | @opindex m68010 |
ddf6fe37 | 26740 | @item -m68010 |
d77de738 ML |
26741 | Generate output for a 68010. This is the default |
26742 | when the compiler is configured for 68010-based systems. | |
26743 | It is equivalent to @option{-march=68010}. | |
26744 | ||
d77de738 ML |
26745 | @opindex m68020 |
26746 | @opindex mc68020 | |
ddf6fe37 AA |
26747 | @item -m68020 |
26748 | @itemx -mc68020 | |
d77de738 ML |
26749 | Generate output for a 68020. This is the default |
26750 | when the compiler is configured for 68020-based systems. | |
26751 | It is equivalent to @option{-march=68020}. | |
26752 | ||
d77de738 | 26753 | @opindex m68030 |
ddf6fe37 | 26754 | @item -m68030 |
d77de738 ML |
26755 | Generate output for a 68030. This is the default when the compiler is |
26756 | configured for 68030-based systems. It is equivalent to | |
26757 | @option{-march=68030}. | |
26758 | ||
d77de738 | 26759 | @opindex m68040 |
ddf6fe37 | 26760 | @item -m68040 |
d77de738 ML |
26761 | Generate output for a 68040. This is the default when the compiler is |
26762 | configured for 68040-based systems. It is equivalent to | |
26763 | @option{-march=68040}. | |
26764 | ||
26765 | This option inhibits the use of 68881/68882 instructions that have to be | |
26766 | emulated by software on the 68040. Use this option if your 68040 does not | |
26767 | have code to emulate those instructions. | |
26768 | ||
d77de738 | 26769 | @opindex m68060 |
ddf6fe37 | 26770 | @item -m68060 |
d77de738 ML |
26771 | Generate output for a 68060. This is the default when the compiler is |
26772 | configured for 68060-based systems. It is equivalent to | |
26773 | @option{-march=68060}. | |
26774 | ||
26775 | This option inhibits the use of 68020 and 68881/68882 instructions that | |
26776 | have to be emulated by software on the 68060. Use this option if your 68060 | |
26777 | does not have code to emulate those instructions. | |
26778 | ||
d77de738 | 26779 | @opindex mcpu32 |
ddf6fe37 | 26780 | @item -mcpu32 |
d77de738 ML |
26781 | Generate output for a CPU32. This is the default |
26782 | when the compiler is configured for CPU32-based systems. | |
26783 | It is equivalent to @option{-march=cpu32}. | |
26784 | ||
26785 | Use this option for microcontrollers with a | |
26786 | CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334, | |
26787 | 68336, 68340, 68341, 68349 and 68360. | |
26788 | ||
d77de738 | 26789 | @opindex m5200 |
ddf6fe37 | 26790 | @item -m5200 |
d77de738 ML |
26791 | Generate output for a 520X ColdFire CPU@. This is the default |
26792 | when the compiler is configured for 520X-based systems. | |
26793 | It is equivalent to @option{-mcpu=5206}, and is now deprecated | |
26794 | in favor of that option. | |
26795 | ||
26796 | Use this option for microcontroller with a 5200 core, including | |
26797 | the MCF5202, MCF5203, MCF5204 and MCF5206. | |
26798 | ||
d77de738 | 26799 | @opindex m5206e |
ddf6fe37 | 26800 | @item -m5206e |
d77de738 ML |
26801 | Generate output for a 5206e ColdFire CPU@. The option is now |
26802 | deprecated in favor of the equivalent @option{-mcpu=5206e}. | |
26803 | ||
d77de738 | 26804 | @opindex m528x |
ddf6fe37 | 26805 | @item -m528x |
d77de738 ML |
26806 | Generate output for a member of the ColdFire 528X family. |
26807 | The option is now deprecated in favor of the equivalent | |
26808 | @option{-mcpu=528x}. | |
26809 | ||
d77de738 | 26810 | @opindex m5307 |
ddf6fe37 | 26811 | @item -m5307 |
d77de738 ML |
26812 | Generate output for a ColdFire 5307 CPU@. The option is now deprecated |
26813 | in favor of the equivalent @option{-mcpu=5307}. | |
26814 | ||
d77de738 | 26815 | @opindex m5407 |
ddf6fe37 | 26816 | @item -m5407 |
d77de738 ML |
26817 | Generate output for a ColdFire 5407 CPU@. The option is now deprecated |
26818 | in favor of the equivalent @option{-mcpu=5407}. | |
26819 | ||
d77de738 | 26820 | @opindex mcfv4e |
ddf6fe37 | 26821 | @item -mcfv4e |
d77de738 ML |
26822 | Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x). |
26823 | This includes use of hardware floating-point instructions. | |
26824 | The option is equivalent to @option{-mcpu=547x}, and is now | |
26825 | deprecated in favor of that option. | |
26826 | ||
d77de738 | 26827 | @opindex m68020-40 |
ddf6fe37 | 26828 | @item -m68020-40 |
d77de738 ML |
26829 | Generate output for a 68040, without using any of the new instructions. |
26830 | This results in code that can run relatively efficiently on either a | |
26831 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
26832 | 68881 instructions that are emulated on the 68040. | |
26833 | ||
26834 | The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}. | |
26835 | ||
d77de738 | 26836 | @opindex m68020-60 |
ddf6fe37 | 26837 | @item -m68020-60 |
d77de738 ML |
26838 | Generate output for a 68060, without using any of the new instructions. |
26839 | This results in code that can run relatively efficiently on either a | |
26840 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
26841 | 68881 instructions that are emulated on the 68060. | |
26842 | ||
26843 | The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}. | |
26844 | ||
d77de738 ML |
26845 | @opindex mhard-float |
26846 | @opindex m68881 | |
ddf6fe37 AA |
26847 | @item -mhard-float |
26848 | @itemx -m68881 | |
d77de738 ML |
26849 | Generate floating-point instructions. This is the default for 68020 |
26850 | and above, and for ColdFire devices that have an FPU@. It defines the | |
26851 | macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__} | |
26852 | on ColdFire targets. | |
26853 | ||
d77de738 | 26854 | @opindex msoft-float |
ddf6fe37 | 26855 | @item -msoft-float |
d77de738 ML |
26856 | Do not generate floating-point instructions; use library calls instead. |
26857 | This is the default for 68000, 68010, and 68832 targets. It is also | |
26858 | the default for ColdFire devices that have no FPU. | |
26859 | ||
d77de738 ML |
26860 | @opindex mdiv |
26861 | @opindex mno-div | |
ddf6fe37 AA |
26862 | @item -mdiv |
26863 | @itemx -mno-div | |
d77de738 ML |
26864 | Generate (do not generate) ColdFire hardware divide and remainder |
26865 | instructions. If @option{-march} is used without @option{-mcpu}, | |
26866 | the default is ``on'' for ColdFire architectures and ``off'' for M680x0 | |
26867 | architectures. Otherwise, the default is taken from the target CPU | |
26868 | (either the default CPU, or the one specified by @option{-mcpu}). For | |
26869 | example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for | |
26870 | @option{-mcpu=5206e}. | |
26871 | ||
26872 | GCC defines the macro @code{__mcfhwdiv__} when this option is enabled. | |
26873 | ||
d77de738 | 26874 | @opindex mshort |
ddf6fe37 | 26875 | @item -mshort |
d77de738 ML |
26876 | Consider type @code{int} to be 16 bits wide, like @code{short int}. |
26877 | Additionally, parameters passed on the stack are also aligned to a | |
26878 | 16-bit boundary even on targets whose API mandates promotion to 32-bit. | |
26879 | ||
d77de738 | 26880 | @opindex mno-short |
ddf6fe37 | 26881 | @item -mno-short |
d77de738 ML |
26882 | Do not consider type @code{int} to be 16 bits wide. This is the default. |
26883 | ||
d77de738 ML |
26884 | @opindex mnobitfield |
26885 | @opindex mno-bitfield | |
ddf6fe37 AA |
26886 | @item -mnobitfield |
26887 | @itemx -mno-bitfield | |
d77de738 ML |
26888 | Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32} |
26889 | and @option{-m5200} options imply @w{@option{-mnobitfield}}. | |
26890 | ||
d77de738 | 26891 | @opindex mbitfield |
ddf6fe37 | 26892 | @item -mbitfield |
d77de738 ML |
26893 | Do use the bit-field instructions. The @option{-m68020} option implies |
26894 | @option{-mbitfield}. This is the default if you use a configuration | |
26895 | designed for a 68020. | |
26896 | ||
d77de738 | 26897 | @opindex mrtd |
ddf6fe37 | 26898 | @item -mrtd |
d77de738 ML |
26899 | Use a different function-calling convention, in which functions |
26900 | that take a fixed number of arguments return with the @code{rtd} | |
26901 | instruction, which pops their arguments while returning. This | |
26902 | saves one instruction in the caller since there is no need to pop | |
26903 | the arguments there. | |
26904 | ||
26905 | This calling convention is incompatible with the one normally | |
26906 | used on Unix, so you cannot use it if you need to call libraries | |
26907 | compiled with the Unix compiler. | |
26908 | ||
26909 | Also, you must provide function prototypes for all functions that | |
26910 | take variable numbers of arguments (including @code{printf}); | |
26911 | otherwise incorrect code is generated for calls to those | |
26912 | functions. | |
26913 | ||
26914 | In addition, seriously incorrect code results if you call a | |
26915 | function with too many arguments. (Normally, extra arguments are | |
26916 | harmlessly ignored.) | |
26917 | ||
26918 | The @code{rtd} instruction is supported by the 68010, 68020, 68030, | |
26919 | 68040, 68060 and CPU32 processors, but not by the 68000 or 5200. | |
26920 | ||
26921 | The default is @option{-mno-rtd}. | |
26922 | ||
d77de738 ML |
26923 | @opindex malign-int |
26924 | @opindex mno-align-int | |
ddf6fe37 AA |
26925 | @item -malign-int |
26926 | @itemx -mno-align-int | |
d77de738 ML |
26927 | Control whether GCC aligns @code{int}, @code{long}, @code{long long}, |
26928 | @code{float}, @code{double}, and @code{long double} variables on a 32-bit | |
26929 | boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}). | |
26930 | Aligning variables on 32-bit boundaries produces code that runs somewhat | |
26931 | faster on processors with 32-bit busses at the expense of more memory. | |
26932 | ||
26933 | @strong{Warning:} if you use the @option{-malign-int} switch, GCC | |
26934 | aligns structures containing the above types differently than | |
26935 | most published application binary interface specifications for the m68k. | |
26936 | ||
26937 | @opindex mpcrel | |
26938 | Use the pc-relative addressing mode of the 68000 directly, instead of | |
26939 | using a global offset table. At present, this option implies @option{-fpic}, | |
26940 | allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is | |
26941 | not presently supported with @option{-mpcrel}, though this could be supported for | |
26942 | 68020 and higher processors. | |
26943 | ||
d77de738 ML |
26944 | @opindex mno-strict-align |
26945 | @opindex mstrict-align | |
ddf6fe37 AA |
26946 | @item -mno-strict-align |
26947 | @itemx -mstrict-align | |
d77de738 ML |
26948 | Do not (do) assume that unaligned memory references are handled by |
26949 | the system. | |
26950 | ||
26951 | @item -msep-data | |
26952 | Generate code that allows the data segment to be located in a different | |
26953 | area of memory from the text segment. This allows for execute-in-place in | |
26954 | an environment without virtual memory management. This option implies | |
26955 | @option{-fPIC}. | |
26956 | ||
26957 | @item -mno-sep-data | |
26958 | Generate code that assumes that the data segment follows the text segment. | |
26959 | This is the default. | |
26960 | ||
26961 | @item -mid-shared-library | |
26962 | Generate code that supports shared libraries via the library ID method. | |
26963 | This allows for execute-in-place and shared libraries in an environment | |
26964 | without virtual memory management. This option implies @option{-fPIC}. | |
26965 | ||
26966 | @item -mno-id-shared-library | |
26967 | Generate code that doesn't assume ID-based shared libraries are being used. | |
26968 | This is the default. | |
26969 | ||
26970 | @item -mshared-library-id=n | |
26971 | Specifies the identification number of the ID-based shared library being | |
26972 | compiled. Specifying a value of 0 generates more compact code; specifying | |
26973 | other values forces the allocation of that number to the current | |
26974 | library, but is no more space- or time-efficient than omitting this option. | |
26975 | ||
d77de738 ML |
26976 | @opindex mxgot |
26977 | @opindex mno-xgot | |
ddf6fe37 AA |
26978 | @item -mxgot |
26979 | @itemx -mno-xgot | |
d77de738 ML |
26980 | When generating position-independent code for ColdFire, generate code |
26981 | that works if the GOT has more than 8192 entries. This code is | |
26982 | larger and slower than code generated without this option. On M680x0 | |
26983 | processors, this option is not needed; @option{-fPIC} suffices. | |
26984 | ||
26985 | GCC normally uses a single instruction to load values from the GOT@. | |
26986 | While this is relatively efficient, it only works if the GOT | |
26987 | is smaller than about 64k. Anything larger causes the linker | |
26988 | to report an error such as: | |
26989 | ||
26990 | @cindex relocation truncated to fit (ColdFire) | |
26991 | @smallexample | |
26992 | relocation truncated to fit: R_68K_GOT16O foobar | |
26993 | @end smallexample | |
26994 | ||
26995 | If this happens, you should recompile your code with @option{-mxgot}. | |
26996 | It should then work with very large GOTs. However, code generated with | |
26997 | @option{-mxgot} is less efficient, since it takes 4 instructions to fetch | |
26998 | the value of a global symbol. | |
26999 | ||
27000 | Note that some linkers, including newer versions of the GNU linker, | |
27001 | can create multiple GOTs and sort GOT entries. If you have such a linker, | |
27002 | you should only need to use @option{-mxgot} when compiling a single | |
27003 | object file that accesses more than 8192 GOT entries. Very few do. | |
27004 | ||
27005 | These options have no effect unless GCC is generating | |
27006 | position-independent code. | |
27007 | ||
d77de738 | 27008 | @opindex mlong-jump-table-offsets |
ddf6fe37 | 27009 | @item -mlong-jump-table-offsets |
d77de738 ML |
27010 | Use 32-bit offsets in @code{switch} tables. The default is to use |
27011 | 16-bit offsets. | |
27012 | ||
27013 | @end table | |
27014 | ||
27015 | @node MCore Options | |
27016 | @subsection MCore Options | |
27017 | @cindex MCore options | |
27018 | ||
27019 | These are the @samp{-m} options defined for the Motorola M*Core | |
27020 | processors. | |
27021 | ||
27022 | @table @gcctabopt | |
27023 | ||
d77de738 ML |
27024 | @opindex mhardlit |
27025 | @opindex mno-hardlit | |
ddf6fe37 AA |
27026 | @item -mhardlit |
27027 | @itemx -mno-hardlit | |
d77de738 ML |
27028 | Inline constants into the code stream if it can be done in two |
27029 | instructions or less. | |
27030 | ||
d77de738 ML |
27031 | @opindex mdiv |
27032 | @opindex mno-div | |
ddf6fe37 AA |
27033 | @item -mdiv |
27034 | @itemx -mno-div | |
d77de738 ML |
27035 | Use the divide instruction. (Enabled by default). |
27036 | ||
d77de738 ML |
27037 | @opindex mrelax-immediate |
27038 | @opindex mno-relax-immediate | |
ddf6fe37 AA |
27039 | @item -mrelax-immediate |
27040 | @itemx -mno-relax-immediate | |
d77de738 ML |
27041 | Allow arbitrary-sized immediates in bit operations. |
27042 | ||
d77de738 ML |
27043 | @opindex mwide-bitfields |
27044 | @opindex mno-wide-bitfields | |
ddf6fe37 AA |
27045 | @item -mwide-bitfields |
27046 | @itemx -mno-wide-bitfields | |
d77de738 ML |
27047 | Always treat bit-fields as @code{int}-sized. |
27048 | ||
d77de738 ML |
27049 | @opindex m4byte-functions |
27050 | @opindex mno-4byte-functions | |
ddf6fe37 AA |
27051 | @item -m4byte-functions |
27052 | @itemx -mno-4byte-functions | |
d77de738 ML |
27053 | Force all functions to be aligned to a 4-byte boundary. |
27054 | ||
d77de738 ML |
27055 | @opindex mcallgraph-data |
27056 | @opindex mno-callgraph-data | |
ddf6fe37 AA |
27057 | @item -mcallgraph-data |
27058 | @itemx -mno-callgraph-data | |
d77de738 ML |
27059 | Emit callgraph information. |
27060 | ||
d77de738 ML |
27061 | @opindex mslow-bytes |
27062 | @opindex mno-slow-bytes | |
ddf6fe37 AA |
27063 | @item -mslow-bytes |
27064 | @itemx -mno-slow-bytes | |
d77de738 ML |
27065 | Prefer word access when reading byte quantities. |
27066 | ||
d77de738 ML |
27067 | @opindex mlittle-endian |
27068 | @opindex mbig-endian | |
ddf6fe37 AA |
27069 | @item -mlittle-endian |
27070 | @itemx -mbig-endian | |
d77de738 ML |
27071 | Generate code for a little-endian target. |
27072 | ||
d77de738 ML |
27073 | @opindex m210 |
27074 | @opindex m340 | |
ddf6fe37 AA |
27075 | @item -m210 |
27076 | @itemx -m340 | |
d77de738 ML |
27077 | Generate code for the 210 processor. |
27078 | ||
d77de738 | 27079 | @opindex mno-lsim |
ddf6fe37 | 27080 | @item -mno-lsim |
d77de738 ML |
27081 | Assume that runtime support has been provided and so omit the |
27082 | simulator library (@file{libsim.a)} from the linker command line. | |
27083 | ||
d77de738 | 27084 | @opindex mstack-increment |
ddf6fe37 | 27085 | @item -mstack-increment=@var{size} |
d77de738 ML |
27086 | Set the maximum amount for a single stack increment operation. Large |
27087 | values can increase the speed of programs that contain functions | |
27088 | that need a large amount of stack space, but they can also trigger a | |
27089 | segmentation fault if the stack is extended too much. The default | |
27090 | value is 0x1000. | |
27091 | ||
27092 | @end table | |
27093 | ||
d77de738 ML |
27094 | @node MicroBlaze Options |
27095 | @subsection MicroBlaze Options | |
27096 | @cindex MicroBlaze Options | |
27097 | ||
27098 | @table @gcctabopt | |
27099 | ||
d77de738 | 27100 | @opindex msoft-float |
ddf6fe37 | 27101 | @item -msoft-float |
d77de738 ML |
27102 | Use software emulation for floating point (default). |
27103 | ||
d77de738 | 27104 | @opindex mhard-float |
ddf6fe37 | 27105 | @item -mhard-float |
d77de738 ML |
27106 | Use hardware floating-point instructions. |
27107 | ||
d77de738 | 27108 | @opindex mmemcpy |
ddf6fe37 | 27109 | @item -mmemcpy |
d77de738 ML |
27110 | Do not optimize block moves, use @code{memcpy}. |
27111 | ||
d77de738 | 27112 | @opindex mno-clearbss |
ddf6fe37 | 27113 | @item -mno-clearbss |
d77de738 ML |
27114 | This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead. |
27115 | ||
d77de738 | 27116 | @opindex mcpu= |
ddf6fe37 | 27117 | @item -mcpu=@var{cpu-type} |
d77de738 ML |
27118 | Use features of, and schedule code for, the given CPU. |
27119 | Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}}, | |
27120 | where @var{X} is a major version, @var{YY} is the minor version, and | |
27121 | @var{Z} is compatibility code. Example values are @samp{v3.00.a}, | |
27122 | @samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}. | |
27123 | ||
d77de738 | 27124 | @opindex mxl-soft-mul |
ddf6fe37 | 27125 | @item -mxl-soft-mul |
d77de738 ML |
27126 | Use software multiply emulation (default). |
27127 | ||
d77de738 | 27128 | @opindex mxl-soft-div |
ddf6fe37 | 27129 | @item -mxl-soft-div |
d77de738 ML |
27130 | Use software emulation for divides (default). |
27131 | ||
d77de738 | 27132 | @opindex mxl-barrel-shift |
ddf6fe37 | 27133 | @item -mxl-barrel-shift |
d77de738 ML |
27134 | Use the hardware barrel shifter. |
27135 | ||
d77de738 | 27136 | @opindex mxl-pattern-compare |
ddf6fe37 | 27137 | @item -mxl-pattern-compare |
d77de738 ML |
27138 | Use pattern compare instructions. |
27139 | ||
d77de738 | 27140 | @opindex msmall-divides |
ddf6fe37 | 27141 | @item -msmall-divides |
d77de738 ML |
27142 | Use table lookup optimization for small signed integer divisions. |
27143 | ||
d77de738 | 27144 | @opindex mxl-stack-check |
ddf6fe37 | 27145 | @item -mxl-stack-check |
d77de738 ML |
27146 | This option is deprecated. Use @option{-fstack-check} instead. |
27147 | ||
d77de738 | 27148 | @opindex mxl-gp-opt |
ddf6fe37 | 27149 | @item -mxl-gp-opt |
d77de738 ML |
27150 | Use GP-relative @code{.sdata}/@code{.sbss} sections. |
27151 | ||
d77de738 | 27152 | @opindex mxl-multiply-high |
ddf6fe37 | 27153 | @item -mxl-multiply-high |
d77de738 ML |
27154 | Use multiply high instructions for high part of 32x32 multiply. |
27155 | ||
d77de738 | 27156 | @opindex mxl-float-convert |
ddf6fe37 | 27157 | @item -mxl-float-convert |
d77de738 ML |
27158 | Use hardware floating-point conversion instructions. |
27159 | ||
d77de738 | 27160 | @opindex mxl-float-sqrt |
ddf6fe37 | 27161 | @item -mxl-float-sqrt |
d77de738 ML |
27162 | Use hardware floating-point square root instruction. |
27163 | ||
d77de738 | 27164 | @opindex mbig-endian |
ddf6fe37 | 27165 | @item -mbig-endian |
d77de738 ML |
27166 | Generate code for a big-endian target. |
27167 | ||
d77de738 | 27168 | @opindex mlittle-endian |
ddf6fe37 | 27169 | @item -mlittle-endian |
d77de738 ML |
27170 | Generate code for a little-endian target. |
27171 | ||
d77de738 | 27172 | @opindex mxl-reorder |
ddf6fe37 | 27173 | @item -mxl-reorder |
d77de738 ML |
27174 | Use reorder instructions (swap and byte reversed load/store). |
27175 | ||
27176 | @item -mxl-mode-@var{app-model} | |
27177 | Select application model @var{app-model}. Valid models are | |
27178 | @table @samp | |
27179 | @item executable | |
27180 | normal executable (default), uses startup code @file{crt0.o}. | |
27181 | ||
27182 | @item xmdstub | |
27183 | for use with Xilinx Microprocessor Debugger (XMD) based | |
27184 | software intrusive debug agent called xmdstub. This uses startup file | |
27185 | @file{crt1.o} and sets the start address of the program to 0x800. | |
27186 | ||
27187 | @item bootstrap | |
27188 | for applications that are loaded using a bootloader. | |
27189 | This model uses startup file @file{crt2.o} which does not contain a processor | |
27190 | reset vector handler. This is suitable for transferring control on a | |
27191 | processor reset to the bootloader rather than the application. | |
27192 | ||
27193 | @item novectors | |
27194 | for applications that do not require any of the | |
27195 | MicroBlaze vectors. This option may be useful for applications running | |
27196 | within a monitoring application. This model uses @file{crt3.o} as a startup file. | |
27197 | @end table | |
27198 | ||
27199 | Option @option{-xl-mode-@var{app-model}} is a deprecated alias for | |
27200 | @option{-mxl-mode-@var{app-model}}. | |
27201 | ||
d77de738 | 27202 | @opindex mpic-data-is-text-relative |
ddf6fe37 | 27203 | @item -mpic-data-is-text-relative |
d77de738 ML |
27204 | Assume that the displacement between the text and data segments is fixed |
27205 | at static link time. This allows data to be referenced by offset from start of | |
27206 | text address instead of GOT since PC-relative addressing is not supported. | |
27207 | ||
27208 | @end table | |
27209 | ||
27210 | @node MIPS Options | |
27211 | @subsection MIPS Options | |
27212 | @cindex MIPS options | |
27213 | ||
27214 | @table @gcctabopt | |
27215 | ||
d77de738 | 27216 | @opindex EB |
ddf6fe37 | 27217 | @item -EB |
d77de738 ML |
27218 | Generate big-endian code. |
27219 | ||
d77de738 | 27220 | @opindex EL |
ddf6fe37 | 27221 | @item -EL |
d77de738 ML |
27222 | Generate little-endian code. This is the default for @samp{mips*el-*-*} |
27223 | configurations. | |
27224 | ||
d77de738 | 27225 | @opindex march |
ddf6fe37 | 27226 | @item -march=@var{arch} |
d77de738 ML |
27227 | Generate code that runs on @var{arch}, which can be the name of a |
27228 | generic MIPS ISA, or the name of a particular processor. | |
27229 | The ISA names are: | |
27230 | @samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4}, | |
27231 | @samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5}, | |
27232 | @samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3}, | |
27233 | @samp{mips64r5} and @samp{mips64r6}. | |
27234 | The processor names are: | |
27235 | @samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc}, | |
27236 | @samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd}, | |
27237 | @samp{5kc}, @samp{5kf}, | |
27238 | @samp{20kc}, | |
27239 | @samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1}, | |
27240 | @samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1}, | |
27241 | @samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn}, | |
27242 | @samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2}, | |
27243 | @samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1}, | |
27244 | @samp{i6400}, @samp{i6500}, | |
27245 | @samp{interaptiv}, | |
27246 | @samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464}, | |
27247 | @samp{gs464e}, @samp{gs264e}, | |
27248 | @samp{m4k}, | |
27249 | @samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec}, | |
27250 | @samp{m5100}, @samp{m5101}, | |
27251 | @samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3}, | |
27252 | @samp{orion}, | |
27253 | @samp{p5600}, @samp{p6600}, | |
27254 | @samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400}, | |
27255 | @samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900}, | |
27256 | @samp{r6000}, @samp{r8000}, | |
27257 | @samp{rm7000}, @samp{rm9000}, | |
27258 | @samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000}, | |
27259 | @samp{sb1}, | |
27260 | @samp{sr71000}, | |
27261 | @samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300}, | |
27262 | @samp{vr5000}, @samp{vr5400}, @samp{vr5500}, | |
27263 | @samp{xlr} and @samp{xlp}. | |
27264 | The special value @samp{from-abi} selects the | |
27265 | most compatible architecture for the selected ABI (that is, | |
27266 | @samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@. | |
27267 | ||
27268 | The native Linux/GNU toolchain also supports the value @samp{native}, | |
27269 | which selects the best architecture option for the host processor. | |
27270 | @option{-march=native} has no effect if GCC does not recognize | |
27271 | the processor. | |
27272 | ||
27273 | In processor names, a final @samp{000} can be abbreviated as @samp{k} | |
27274 | (for example, @option{-march=r2k}). Prefixes are optional, and | |
27275 | @samp{vr} may be written @samp{r}. | |
27276 | ||
27277 | Names of the form @samp{@var{n}f2_1} refer to processors with | |
27278 | FPUs clocked at half the rate of the core, names of the form | |
27279 | @samp{@var{n}f1_1} refer to processors with FPUs clocked at the same | |
27280 | rate as the core, and names of the form @samp{@var{n}f3_2} refer to | |
27281 | processors with FPUs clocked a ratio of 3:2 with respect to the core. | |
27282 | For compatibility reasons, @samp{@var{n}f} is accepted as a synonym | |
27283 | for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are | |
27284 | accepted as synonyms for @samp{@var{n}f1_1}. | |
27285 | ||
27286 | GCC defines two macros based on the value of this option. The first | |
27287 | is @code{_MIPS_ARCH}, which gives the name of target architecture, as | |
27288 | a string. The second has the form @code{_MIPS_ARCH_@var{foo}}, | |
27289 | where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@. | |
27290 | For example, @option{-march=r2000} sets @code{_MIPS_ARCH} | |
27291 | to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}. | |
27292 | ||
27293 | Note that the @code{_MIPS_ARCH} macro uses the processor names given | |
27294 | above. In other words, it has the full prefix and does not | |
27295 | abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi}, | |
27296 | the macro names the resolved architecture (either @code{"mips1"} or | |
27297 | @code{"mips3"}). It names the default architecture when no | |
27298 | @option{-march} option is given. | |
27299 | ||
d77de738 | 27300 | @opindex mtune |
ddf6fe37 | 27301 | @item -mtune=@var{arch} |
d77de738 ML |
27302 | Optimize for @var{arch}. Among other things, this option controls |
27303 | the way instructions are scheduled, and the perceived cost of arithmetic | |
27304 | operations. The list of @var{arch} values is the same as for | |
27305 | @option{-march}. | |
27306 | ||
27307 | When this option is not used, GCC optimizes for the processor | |
27308 | specified by @option{-march}. By using @option{-march} and | |
27309 | @option{-mtune} together, it is possible to generate code that | |
27310 | runs on a family of processors, but optimize the code for one | |
27311 | particular member of that family. | |
27312 | ||
27313 | @option{-mtune} defines the macros @code{_MIPS_TUNE} and | |
27314 | @code{_MIPS_TUNE_@var{foo}}, which work in the same way as the | |
27315 | @option{-march} ones described above. | |
27316 | ||
d77de738 | 27317 | @opindex mips1 |
ddf6fe37 | 27318 | @item -mips1 |
d77de738 ML |
27319 | Equivalent to @option{-march=mips1}. |
27320 | ||
d77de738 | 27321 | @opindex mips2 |
ddf6fe37 | 27322 | @item -mips2 |
d77de738 ML |
27323 | Equivalent to @option{-march=mips2}. |
27324 | ||
d77de738 | 27325 | @opindex mips3 |
ddf6fe37 | 27326 | @item -mips3 |
d77de738 ML |
27327 | Equivalent to @option{-march=mips3}. |
27328 | ||
d77de738 | 27329 | @opindex mips4 |
ddf6fe37 | 27330 | @item -mips4 |
d77de738 ML |
27331 | Equivalent to @option{-march=mips4}. |
27332 | ||
d77de738 | 27333 | @opindex mips32 |
ddf6fe37 | 27334 | @item -mips32 |
d77de738 ML |
27335 | Equivalent to @option{-march=mips32}. |
27336 | ||
d77de738 | 27337 | @opindex mips32r3 |
ddf6fe37 | 27338 | @item -mips32r3 |
d77de738 ML |
27339 | Equivalent to @option{-march=mips32r3}. |
27340 | ||
d77de738 | 27341 | @opindex mips32r5 |
ddf6fe37 | 27342 | @item -mips32r5 |
d77de738 ML |
27343 | Equivalent to @option{-march=mips32r5}. |
27344 | ||
d77de738 | 27345 | @opindex mips32r6 |
ddf6fe37 | 27346 | @item -mips32r6 |
d77de738 ML |
27347 | Equivalent to @option{-march=mips32r6}. |
27348 | ||
d77de738 | 27349 | @opindex mips64 |
ddf6fe37 | 27350 | @item -mips64 |
d77de738 ML |
27351 | Equivalent to @option{-march=mips64}. |
27352 | ||
d77de738 | 27353 | @opindex mips64r2 |
ddf6fe37 | 27354 | @item -mips64r2 |
d77de738 ML |
27355 | Equivalent to @option{-march=mips64r2}. |
27356 | ||
d77de738 | 27357 | @opindex mips64r3 |
ddf6fe37 | 27358 | @item -mips64r3 |
d77de738 ML |
27359 | Equivalent to @option{-march=mips64r3}. |
27360 | ||
d77de738 | 27361 | @opindex mips64r5 |
ddf6fe37 | 27362 | @item -mips64r5 |
d77de738 ML |
27363 | Equivalent to @option{-march=mips64r5}. |
27364 | ||
d77de738 | 27365 | @opindex mips64r6 |
ddf6fe37 | 27366 | @item -mips64r6 |
d77de738 ML |
27367 | Equivalent to @option{-march=mips64r6}. |
27368 | ||
d77de738 ML |
27369 | @opindex mips16 |
27370 | @opindex mno-mips16 | |
ddf6fe37 AA |
27371 | @item -mips16 |
27372 | @itemx -mno-mips16 | |
d77de738 ML |
27373 | Generate (do not generate) MIPS16 code. If GCC is targeting a |
27374 | MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@. | |
27375 | ||
27376 | MIPS16 code generation can also be controlled on a per-function basis | |
27377 | by means of @code{mips16} and @code{nomips16} attributes. | |
27378 | @xref{Function Attributes}, for more information. | |
27379 | ||
926f2d09 JM |
27380 | @opindex mmips16e2 |
27381 | @opindex mno-mips16e2 | |
27382 | @item -mmips16e2 | |
27383 | @itemx -mno-mips16e2 | |
27384 | Use (do not use) the MIPS16e2 ASE. This option modifies the behavior | |
27385 | of the @option{-mips16} option such that it targets the MIPS16e2 ASE@. | |
27386 | ||
d77de738 | 27387 | @opindex mflip-mips16 |
ddf6fe37 | 27388 | @item -mflip-mips16 |
d77de738 ML |
27389 | Generate MIPS16 code on alternating functions. This option is provided |
27390 | for regression testing of mixed MIPS16/non-MIPS16 code generation, and is | |
27391 | not intended for ordinary use in compiling user code. | |
27392 | ||
d77de738 ML |
27393 | @opindex minterlink-compressed |
27394 | @opindex mno-interlink-compressed | |
ddf6fe37 AA |
27395 | @item -minterlink-compressed |
27396 | @itemx -mno-interlink-compressed | |
d77de738 ML |
27397 | Require (do not require) that code using the standard (uncompressed) MIPS ISA |
27398 | be link-compatible with MIPS16 and microMIPS code, and vice versa. | |
27399 | ||
27400 | For example, code using the standard ISA encoding cannot jump directly | |
27401 | to MIPS16 or microMIPS code; it must either use a call or an indirect jump. | |
27402 | @option{-minterlink-compressed} therefore disables direct jumps unless GCC | |
27403 | knows that the target of the jump is not compressed. | |
27404 | ||
d77de738 ML |
27405 | @opindex minterlink-mips16 |
27406 | @opindex mno-interlink-mips16 | |
ddf6fe37 AA |
27407 | @item -minterlink-mips16 |
27408 | @itemx -mno-interlink-mips16 | |
d77de738 ML |
27409 | Aliases of @option{-minterlink-compressed} and |
27410 | @option{-mno-interlink-compressed}. These options predate the microMIPS ASE | |
27411 | and are retained for backwards compatibility. | |
27412 | ||
d77de738 ML |
27413 | @opindex mabi=32 |
27414 | @opindex mabi=o64 | |
27415 | @opindex mabi=n32 | |
27416 | @opindex mabi=64 | |
27417 | @opindex mabi=eabi | |
ddf6fe37 AA |
27418 | @item -mabi=32 |
27419 | @itemx -mabi=o64 | |
27420 | @itemx -mabi=n32 | |
27421 | @itemx -mabi=64 | |
27422 | @itemx -mabi=eabi | |
d77de738 ML |
27423 | Generate code for the given ABI@. |
27424 | ||
27425 | Note that the EABI has a 32-bit and a 64-bit variant. GCC normally | |
27426 | generates 64-bit code when you select a 64-bit architecture, but you | |
27427 | can use @option{-mgp32} to get 32-bit code instead. | |
27428 | ||
27429 | For information about the O64 ABI, see | |
27430 | @uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}. | |
27431 | ||
27432 | GCC supports a variant of the o32 ABI in which floating-point registers | |
27433 | are 64 rather than 32 bits wide. You can select this combination with | |
27434 | @option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1} | |
27435 | and @code{mfhc1} instructions and is therefore only supported for | |
27436 | MIPS32R2, MIPS32R3 and MIPS32R5 processors. | |
27437 | ||
27438 | The register assignments for arguments and return values remain the | |
27439 | same, but each scalar value is passed in a single 64-bit register | |
27440 | rather than a pair of 32-bit registers. For example, scalar | |
27441 | floating-point values are returned in @samp{$f0} only, not a | |
27442 | @samp{$f0}/@samp{$f1} pair. The set of call-saved registers also | |
27443 | remains the same in that the even-numbered double-precision registers | |
27444 | are saved. | |
27445 | ||
27446 | Two additional variants of the o32 ABI are supported to enable | |
27447 | a transition from 32-bit to 64-bit registers. These are FPXX | |
27448 | (@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}). | |
27449 | The FPXX extension mandates that all code must execute correctly | |
27450 | when run using 32-bit or 64-bit registers. The code can be interlinked | |
27451 | with either FP32 or FP64, but not both. | |
27452 | The FP64A extension is similar to the FP64 extension but forbids the | |
27453 | use of odd-numbered single-precision registers. This can be used | |
27454 | in conjunction with the @code{FRE} mode of FPUs in MIPS32R5 | |
27455 | processors and allows both FP32 and FP64A code to interlink and | |
27456 | run in the same process without changing FPU modes. | |
27457 | ||
d77de738 ML |
27458 | @opindex mabicalls |
27459 | @opindex mno-abicalls | |
ddf6fe37 AA |
27460 | @item -mabicalls |
27461 | @itemx -mno-abicalls | |
d77de738 ML |
27462 | Generate (do not generate) code that is suitable for SVR4-style |
27463 | dynamic objects. @option{-mabicalls} is the default for SVR4-based | |
27464 | systems. | |
27465 | ||
27466 | @item -mshared | |
27467 | @itemx -mno-shared | |
27468 | Generate (do not generate) code that is fully position-independent, | |
27469 | and that can therefore be linked into shared libraries. This option | |
27470 | only affects @option{-mabicalls}. | |
27471 | ||
27472 | All @option{-mabicalls} code has traditionally been position-independent, | |
27473 | regardless of options like @option{-fPIC} and @option{-fpic}. However, | |
27474 | as an extension, the GNU toolchain allows executables to use absolute | |
27475 | accesses for locally-binding symbols. It can also use shorter GP | |
27476 | initialization sequences and generate direct calls to locally-defined | |
27477 | functions. This mode is selected by @option{-mno-shared}. | |
27478 | ||
27479 | @option{-mno-shared} depends on binutils 2.16 or higher and generates | |
27480 | objects that can only be linked by the GNU linker. However, the option | |
27481 | does not affect the ABI of the final executable; it only affects the ABI | |
27482 | of relocatable objects. Using @option{-mno-shared} generally makes | |
27483 | executables both smaller and quicker. | |
27484 | ||
27485 | @option{-mshared} is the default. | |
27486 | ||
d77de738 ML |
27487 | @opindex mplt |
27488 | @opindex mno-plt | |
ddf6fe37 AA |
27489 | @item -mplt |
27490 | @itemx -mno-plt | |
d77de738 ML |
27491 | Assume (do not assume) that the static and dynamic linkers |
27492 | support PLTs and copy relocations. This option only affects | |
27493 | @option{-mno-shared -mabicalls}. For the n64 ABI, this option | |
27494 | has no effect without @option{-msym32}. | |
27495 | ||
27496 | You can make @option{-mplt} the default by configuring | |
27497 | GCC with @option{--with-mips-plt}. The default is | |
27498 | @option{-mno-plt} otherwise. | |
27499 | ||
d77de738 ML |
27500 | @opindex mxgot |
27501 | @opindex mno-xgot | |
ddf6fe37 AA |
27502 | @item -mxgot |
27503 | @itemx -mno-xgot | |
d77de738 ML |
27504 | Lift (do not lift) the usual restrictions on the size of the global |
27505 | offset table. | |
27506 | ||
27507 | GCC normally uses a single instruction to load values from the GOT@. | |
27508 | While this is relatively efficient, it only works if the GOT | |
27509 | is smaller than about 64k. Anything larger causes the linker | |
27510 | to report an error such as: | |
27511 | ||
27512 | @cindex relocation truncated to fit (MIPS) | |
27513 | @smallexample | |
27514 | relocation truncated to fit: R_MIPS_GOT16 foobar | |
27515 | @end smallexample | |
27516 | ||
27517 | If this happens, you should recompile your code with @option{-mxgot}. | |
27518 | This works with very large GOTs, although the code is also | |
27519 | less efficient, since it takes three instructions to fetch the | |
27520 | value of a global symbol. | |
27521 | ||
27522 | Note that some linkers can create multiple GOTs. If you have such a | |
27523 | linker, you should only need to use @option{-mxgot} when a single object | |
27524 | file accesses more than 64k's worth of GOT entries. Very few do. | |
27525 | ||
27526 | These options have no effect unless GCC is generating position | |
27527 | independent code. | |
27528 | ||
d77de738 | 27529 | @opindex mgp32 |
ddf6fe37 | 27530 | @item -mgp32 |
d77de738 ML |
27531 | Assume that general-purpose registers are 32 bits wide. |
27532 | ||
d77de738 | 27533 | @opindex mgp64 |
ddf6fe37 | 27534 | @item -mgp64 |
d77de738 ML |
27535 | Assume that general-purpose registers are 64 bits wide. |
27536 | ||
d77de738 | 27537 | @opindex mfp32 |
ddf6fe37 | 27538 | @item -mfp32 |
d77de738 ML |
27539 | Assume that floating-point registers are 32 bits wide. |
27540 | ||
d77de738 | 27541 | @opindex mfp64 |
ddf6fe37 | 27542 | @item -mfp64 |
d77de738 ML |
27543 | Assume that floating-point registers are 64 bits wide. |
27544 | ||
d77de738 | 27545 | @opindex mfpxx |
ddf6fe37 | 27546 | @item -mfpxx |
d77de738 ML |
27547 | Do not assume the width of floating-point registers. |
27548 | ||
d77de738 | 27549 | @opindex mhard-float |
ddf6fe37 | 27550 | @item -mhard-float |
d77de738 ML |
27551 | Use floating-point coprocessor instructions. |
27552 | ||
d77de738 | 27553 | @opindex msoft-float |
ddf6fe37 | 27554 | @item -msoft-float |
d77de738 ML |
27555 | Do not use floating-point coprocessor instructions. Implement |
27556 | floating-point calculations using library calls instead. | |
27557 | ||
d77de738 | 27558 | @opindex mno-float |
ddf6fe37 | 27559 | @item -mno-float |
d77de738 ML |
27560 | Equivalent to @option{-msoft-float}, but additionally asserts that the |
27561 | program being compiled does not perform any floating-point operations. | |
27562 | This option is presently supported only by some bare-metal MIPS | |
27563 | configurations, where it may select a special set of libraries | |
27564 | that lack all floating-point support (including, for example, the | |
27565 | floating-point @code{printf} formats). | |
27566 | If code compiled with @option{-mno-float} accidentally contains | |
27567 | floating-point operations, it is likely to suffer a link-time | |
27568 | or run-time failure. | |
27569 | ||
d77de738 | 27570 | @opindex msingle-float |
ddf6fe37 | 27571 | @item -msingle-float |
d77de738 ML |
27572 | Assume that the floating-point coprocessor only supports single-precision |
27573 | operations. | |
27574 | ||
d77de738 | 27575 | @opindex mdouble-float |
ddf6fe37 | 27576 | @item -mdouble-float |
d77de738 ML |
27577 | Assume that the floating-point coprocessor supports double-precision |
27578 | operations. This is the default. | |
27579 | ||
d77de738 ML |
27580 | @opindex modd-spreg |
27581 | @opindex mno-odd-spreg | |
ddf6fe37 AA |
27582 | @item -modd-spreg |
27583 | @itemx -mno-odd-spreg | |
d77de738 ML |
27584 | Enable the use of odd-numbered single-precision floating-point registers |
27585 | for the o32 ABI. This is the default for processors that are known to | |
27586 | support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg} | |
27587 | is set by default. | |
27588 | ||
d77de738 ML |
27589 | @opindex mabs=2008 |
27590 | @opindex mabs=legacy | |
ddf6fe37 AA |
27591 | @item -mabs=2008 |
27592 | @itemx -mabs=legacy | |
d77de738 ML |
27593 | These options control the treatment of the special not-a-number (NaN) |
27594 | IEEE 754 floating-point data with the @code{abs.@i{fmt}} and | |
27595 | @code{neg.@i{fmt}} machine instructions. | |
27596 | ||
27597 | By default or when @option{-mabs=legacy} is used the legacy | |
27598 | treatment is selected. In this case these instructions are considered | |
27599 | arithmetic and avoided where correct operation is required and the | |
27600 | input operand might be a NaN. A longer sequence of instructions that | |
27601 | manipulate the sign bit of floating-point datum manually is used | |
27602 | instead unless the @option{-ffinite-math-only} option has also been | |
27603 | specified. | |
27604 | ||
27605 | The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In | |
27606 | this case these instructions are considered non-arithmetic and therefore | |
27607 | operating correctly in all cases, including in particular where the | |
27608 | input operand is a NaN. These instructions are therefore always used | |
27609 | for the respective operations. | |
27610 | ||
d77de738 ML |
27611 | @opindex mnan=2008 |
27612 | @opindex mnan=legacy | |
ddf6fe37 AA |
27613 | @item -mnan=2008 |
27614 | @itemx -mnan=legacy | |
d77de738 ML |
27615 | These options control the encoding of the special not-a-number (NaN) |
27616 | IEEE 754 floating-point data. | |
27617 | ||
27618 | The @option{-mnan=legacy} option selects the legacy encoding. In this | |
27619 | case quiet NaNs (qNaNs) are denoted by the first bit of their trailing | |
27620 | significand field being 0, whereas signaling NaNs (sNaNs) are denoted | |
27621 | by the first bit of their trailing significand field being 1. | |
27622 | ||
27623 | The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In | |
27624 | this case qNaNs are denoted by the first bit of their trailing | |
27625 | significand field being 1, whereas sNaNs are denoted by the first bit of | |
27626 | their trailing significand field being 0. | |
27627 | ||
27628 | The default is @option{-mnan=legacy} unless GCC has been configured with | |
27629 | @option{--with-nan=2008}. | |
27630 | ||
d77de738 ML |
27631 | @opindex mllsc |
27632 | @opindex mno-llsc | |
ddf6fe37 AA |
27633 | @item -mllsc |
27634 | @itemx -mno-llsc | |
d77de738 ML |
27635 | Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to |
27636 | implement atomic memory built-in functions. When neither option is | |
27637 | specified, GCC uses the instructions if the target architecture | |
27638 | supports them. | |
27639 | ||
27640 | @option{-mllsc} is useful if the runtime environment can emulate the | |
27641 | instructions and @option{-mno-llsc} can be useful when compiling for | |
27642 | nonstandard ISAs. You can make either option the default by | |
27643 | configuring GCC with @option{--with-llsc} and @option{--without-llsc} | |
27644 | respectively. @option{--with-llsc} is the default for some | |
27645 | configurations; see the installation documentation for details. | |
27646 | ||
d77de738 ML |
27647 | @opindex mdsp |
27648 | @opindex mno-dsp | |
ddf6fe37 AA |
27649 | @item -mdsp |
27650 | @itemx -mno-dsp | |
d77de738 ML |
27651 | Use (do not use) revision 1 of the MIPS DSP ASE@. |
27652 | @xref{MIPS DSP Built-in Functions}. This option defines the | |
27653 | preprocessor macro @code{__mips_dsp}. It also defines | |
27654 | @code{__mips_dsp_rev} to 1. | |
27655 | ||
d77de738 ML |
27656 | @opindex mdspr2 |
27657 | @opindex mno-dspr2 | |
ddf6fe37 AA |
27658 | @item -mdspr2 |
27659 | @itemx -mno-dspr2 | |
d77de738 ML |
27660 | Use (do not use) revision 2 of the MIPS DSP ASE@. |
27661 | @xref{MIPS DSP Built-in Functions}. This option defines the | |
27662 | preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}. | |
27663 | It also defines @code{__mips_dsp_rev} to 2. | |
27664 | ||
d77de738 ML |
27665 | @opindex msmartmips |
27666 | @opindex mno-smartmips | |
ddf6fe37 AA |
27667 | @item -msmartmips |
27668 | @itemx -mno-smartmips | |
d77de738 ML |
27669 | Use (do not use) the MIPS SmartMIPS ASE. |
27670 | ||
d77de738 ML |
27671 | @opindex mpaired-single |
27672 | @opindex mno-paired-single | |
ddf6fe37 AA |
27673 | @item -mpaired-single |
27674 | @itemx -mno-paired-single | |
d77de738 ML |
27675 | Use (do not use) paired-single floating-point instructions. |
27676 | @xref{MIPS Paired-Single Support}. This option requires | |
27677 | hardware floating-point support to be enabled. | |
27678 | ||
d77de738 ML |
27679 | @opindex mdmx |
27680 | @opindex mno-mdmx | |
ddf6fe37 AA |
27681 | @item -mdmx |
27682 | @itemx -mno-mdmx | |
d77de738 ML |
27683 | Use (do not use) MIPS Digital Media Extension instructions. |
27684 | This option can only be used when generating 64-bit code and requires | |
27685 | hardware floating-point support to be enabled. | |
27686 | ||
d77de738 ML |
27687 | @opindex mips3d |
27688 | @opindex mno-mips3d | |
ddf6fe37 AA |
27689 | @item -mips3d |
27690 | @itemx -mno-mips3d | |
d77de738 ML |
27691 | Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}. |
27692 | The option @option{-mips3d} implies @option{-mpaired-single}. | |
27693 | ||
d77de738 ML |
27694 | @opindex mmicromips |
27695 | @opindex mno-mmicromips | |
ddf6fe37 AA |
27696 | @item -mmicromips |
27697 | @itemx -mno-micromips | |
d77de738 ML |
27698 | Generate (do not generate) microMIPS code. |
27699 | ||
27700 | MicroMIPS code generation can also be controlled on a per-function basis | |
27701 | by means of @code{micromips} and @code{nomicromips} attributes. | |
27702 | @xref{Function Attributes}, for more information. | |
27703 | ||
d77de738 ML |
27704 | @opindex mmt |
27705 | @opindex mno-mt | |
ddf6fe37 AA |
27706 | @item -mmt |
27707 | @itemx -mno-mt | |
d77de738 ML |
27708 | Use (do not use) MT Multithreading instructions. |
27709 | ||
d77de738 ML |
27710 | @opindex mmcu |
27711 | @opindex mno-mcu | |
ddf6fe37 AA |
27712 | @item -mmcu |
27713 | @itemx -mno-mcu | |
d77de738 ML |
27714 | Use (do not use) the MIPS MCU ASE instructions. |
27715 | ||
d77de738 ML |
27716 | @opindex meva |
27717 | @opindex mno-eva | |
ddf6fe37 AA |
27718 | @item -meva |
27719 | @itemx -mno-eva | |
d77de738 ML |
27720 | Use (do not use) the MIPS Enhanced Virtual Addressing instructions. |
27721 | ||
d77de738 ML |
27722 | @opindex mvirt |
27723 | @opindex mno-virt | |
ddf6fe37 AA |
27724 | @item -mvirt |
27725 | @itemx -mno-virt | |
d77de738 ML |
27726 | Use (do not use) the MIPS Virtualization (VZ) instructions. |
27727 | ||
d77de738 ML |
27728 | @opindex mxpa |
27729 | @opindex mno-xpa | |
ddf6fe37 AA |
27730 | @item -mxpa |
27731 | @itemx -mno-xpa | |
d77de738 ML |
27732 | Use (do not use) the MIPS eXtended Physical Address (XPA) instructions. |
27733 | ||
d77de738 ML |
27734 | @opindex mcrc |
27735 | @opindex mno-crc | |
ddf6fe37 AA |
27736 | @item -mcrc |
27737 | @itemx -mno-crc | |
d77de738 ML |
27738 | Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions. |
27739 | ||
d77de738 ML |
27740 | @opindex mginv |
27741 | @opindex mno-ginv | |
ddf6fe37 AA |
27742 | @item -mginv |
27743 | @itemx -mno-ginv | |
d77de738 ML |
27744 | Use (do not use) the MIPS Global INValidate (GINV) instructions. |
27745 | ||
d77de738 ML |
27746 | @opindex mloongson-mmi |
27747 | @opindex mno-loongson-mmi | |
ddf6fe37 AA |
27748 | @item -mloongson-mmi |
27749 | @itemx -mno-loongson-mmi | |
d77de738 ML |
27750 | Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI). |
27751 | ||
d77de738 ML |
27752 | @opindex mloongson-ext |
27753 | @opindex mno-loongson-ext | |
ddf6fe37 AA |
27754 | @item -mloongson-ext |
27755 | @itemx -mno-loongson-ext | |
d77de738 ML |
27756 | Use (do not use) the MIPS Loongson EXTensions (EXT) instructions. |
27757 | ||
d77de738 ML |
27758 | @opindex mloongson-ext2 |
27759 | @opindex mno-loongson-ext2 | |
ddf6fe37 AA |
27760 | @item -mloongson-ext2 |
27761 | @itemx -mno-loongson-ext2 | |
d77de738 ML |
27762 | Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions. |
27763 | ||
d77de738 | 27764 | @opindex mlong64 |
ddf6fe37 | 27765 | @item -mlong64 |
d77de738 ML |
27766 | Force @code{long} types to be 64 bits wide. See @option{-mlong32} for |
27767 | an explanation of the default and the way that the pointer size is | |
27768 | determined. | |
27769 | ||
d77de738 | 27770 | @opindex mlong32 |
ddf6fe37 | 27771 | @item -mlong32 |
d77de738 ML |
27772 | Force @code{long}, @code{int}, and pointer types to be 32 bits wide. |
27773 | ||
27774 | The default size of @code{int}s, @code{long}s and pointers depends on | |
27775 | the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI | |
27776 | uses 64-bit @code{long}s, as does the 64-bit EABI; the others use | |
27777 | 32-bit @code{long}s. Pointers are the same size as @code{long}s, | |
27778 | or the same size as integer registers, whichever is smaller. | |
27779 | ||
d77de738 ML |
27780 | @opindex msym32 |
27781 | @opindex mno-sym32 | |
ddf6fe37 AA |
27782 | @item -msym32 |
27783 | @itemx -mno-sym32 | |
d77de738 ML |
27784 | Assume (do not assume) that all symbols have 32-bit values, regardless |
27785 | of the selected ABI@. This option is useful in combination with | |
27786 | @option{-mabi=64} and @option{-mno-abicalls} because it allows GCC | |
27787 | to generate shorter and faster references to symbolic addresses. | |
27788 | ||
d77de738 | 27789 | @opindex G |
ddf6fe37 | 27790 | @item -G @var{num} |
d77de738 ML |
27791 | Put definitions of externally-visible data in a small data section |
27792 | if that data is no bigger than @var{num} bytes. GCC can then generate | |
27793 | more efficient accesses to the data; see @option{-mgpopt} for details. | |
27794 | ||
27795 | The default @option{-G} option depends on the configuration. | |
27796 | ||
d77de738 ML |
27797 | @opindex mlocal-sdata |
27798 | @opindex mno-local-sdata | |
ddf6fe37 AA |
27799 | @item -mlocal-sdata |
27800 | @itemx -mno-local-sdata | |
d77de738 ML |
27801 | Extend (do not extend) the @option{-G} behavior to local data too, |
27802 | such as to static variables in C@. @option{-mlocal-sdata} is the | |
27803 | default for all configurations. | |
27804 | ||
27805 | If the linker complains that an application is using too much small data, | |
27806 | you might want to try rebuilding the less performance-critical parts with | |
27807 | @option{-mno-local-sdata}. You might also want to build large | |
27808 | libraries with @option{-mno-local-sdata}, so that the libraries leave | |
27809 | more room for the main program. | |
27810 | ||
d77de738 ML |
27811 | @opindex mextern-sdata |
27812 | @opindex mno-extern-sdata | |
ddf6fe37 AA |
27813 | @item -mextern-sdata |
27814 | @itemx -mno-extern-sdata | |
d77de738 ML |
27815 | Assume (do not assume) that externally-defined data is in |
27816 | a small data section if the size of that data is within the @option{-G} limit. | |
27817 | @option{-mextern-sdata} is the default for all configurations. | |
27818 | ||
27819 | If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G | |
27820 | @var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var} | |
27821 | that is no bigger than @var{num} bytes, you must make sure that @var{Var} | |
27822 | is placed in a small data section. If @var{Var} is defined by another | |
27823 | module, you must either compile that module with a high-enough | |
27824 | @option{-G} setting or attach a @code{section} attribute to @var{Var}'s | |
27825 | definition. If @var{Var} is common, you must link the application | |
27826 | with a high-enough @option{-G} setting. | |
27827 | ||
27828 | The easiest way of satisfying these restrictions is to compile | |
27829 | and link every module with the same @option{-G} option. However, | |
27830 | you may wish to build a library that supports several different | |
27831 | small data limits. You can do this by compiling the library with | |
27832 | the highest supported @option{-G} setting and additionally using | |
27833 | @option{-mno-extern-sdata} to stop the library from making assumptions | |
27834 | about externally-defined data. | |
27835 | ||
d77de738 ML |
27836 | @opindex mgpopt |
27837 | @opindex mno-gpopt | |
ddf6fe37 AA |
27838 | @item -mgpopt |
27839 | @itemx -mno-gpopt | |
d77de738 ML |
27840 | Use (do not use) GP-relative accesses for symbols that are known to be |
27841 | in a small data section; see @option{-G}, @option{-mlocal-sdata} and | |
27842 | @option{-mextern-sdata}. @option{-mgpopt} is the default for all | |
27843 | configurations. | |
27844 | ||
27845 | @option{-mno-gpopt} is useful for cases where the @code{$gp} register | |
27846 | might not hold the value of @code{_gp}. For example, if the code is | |
27847 | part of a library that might be used in a boot monitor, programs that | |
27848 | call boot monitor routines pass an unknown value in @code{$gp}. | |
27849 | (In such situations, the boot monitor itself is usually compiled | |
27850 | with @option{-G0}.) | |
27851 | ||
27852 | @option{-mno-gpopt} implies @option{-mno-local-sdata} and | |
27853 | @option{-mno-extern-sdata}. | |
27854 | ||
d77de738 ML |
27855 | @opindex membedded-data |
27856 | @opindex mno-embedded-data | |
ddf6fe37 AA |
27857 | @item -membedded-data |
27858 | @itemx -mno-embedded-data | |
d77de738 ML |
27859 | Allocate variables to the read-only data section first if possible, then |
27860 | next in the small data section if possible, otherwise in data. This gives | |
27861 | slightly slower code than the default, but reduces the amount of RAM required | |
27862 | when executing, and thus may be preferred for some embedded systems. | |
27863 | ||
d77de738 ML |
27864 | @opindex muninit-const-in-rodata |
27865 | @opindex mno-uninit-const-in-rodata | |
ddf6fe37 AA |
27866 | @item -muninit-const-in-rodata |
27867 | @itemx -mno-uninit-const-in-rodata | |
d77de738 ML |
27868 | Put uninitialized @code{const} variables in the read-only data section. |
27869 | This option is only meaningful in conjunction with @option{-membedded-data}. | |
27870 | ||
d77de738 | 27871 | @opindex mcode-readable |
ddf6fe37 | 27872 | @item -mcode-readable=@var{setting} |
d77de738 ML |
27873 | Specify whether GCC may generate code that reads from executable sections. |
27874 | There are three possible settings: | |
27875 | ||
27876 | @table @gcctabopt | |
27877 | @item -mcode-readable=yes | |
27878 | Instructions may freely access executable sections. This is the | |
27879 | default setting. | |
27880 | ||
27881 | @item -mcode-readable=pcrel | |
27882 | MIPS16 PC-relative load instructions can access executable sections, | |
27883 | but other instructions must not do so. This option is useful on 4KSc | |
27884 | and 4KSd processors when the code TLBs have the Read Inhibit bit set. | |
27885 | It is also useful on processors that can be configured to have a dual | |
27886 | instruction/data SRAM interface and that, like the M4K, automatically | |
27887 | redirect PC-relative loads to the instruction RAM. | |
27888 | ||
27889 | @item -mcode-readable=no | |
27890 | Instructions must not access executable sections. This option can be | |
27891 | useful on targets that are configured to have a dual instruction/data | |
27892 | SRAM interface but that (unlike the M4K) do not automatically redirect | |
27893 | PC-relative loads to the instruction RAM. | |
27894 | @end table | |
27895 | ||
d77de738 ML |
27896 | @opindex msplit-addresses |
27897 | @opindex mno-split-addresses | |
ddf6fe37 AA |
27898 | @item -msplit-addresses |
27899 | @itemx -mno-split-addresses | |
d77de738 ML |
27900 | Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler |
27901 | relocation operators. This option has been superseded by | |
27902 | @option{-mexplicit-relocs} but is retained for backwards compatibility. | |
27903 | ||
d77de738 ML |
27904 | @opindex mexplicit-relocs |
27905 | @opindex mno-explicit-relocs | |
ddf6fe37 AA |
27906 | @item -mexplicit-relocs |
27907 | @itemx -mno-explicit-relocs | |
d77de738 ML |
27908 | Use (do not use) assembler relocation operators when dealing with symbolic |
27909 | addresses. The alternative, selected by @option{-mno-explicit-relocs}, | |
27910 | is to use assembler macros instead. | |
27911 | ||
27912 | @option{-mexplicit-relocs} is the default if GCC was configured | |
27913 | to use an assembler that supports relocation operators. | |
27914 | ||
d77de738 ML |
27915 | @opindex mcheck-zero-division |
27916 | @opindex mno-check-zero-division | |
ddf6fe37 AA |
27917 | @item -mcheck-zero-division |
27918 | @itemx -mno-check-zero-division | |
d77de738 ML |
27919 | Trap (do not trap) on integer division by zero. |
27920 | ||
27921 | The default is @option{-mcheck-zero-division}. | |
27922 | ||
d77de738 ML |
27923 | @opindex mdivide-traps |
27924 | @opindex mdivide-breaks | |
ddf6fe37 AA |
27925 | @item -mdivide-traps |
27926 | @itemx -mdivide-breaks | |
d77de738 ML |
27927 | MIPS systems check for division by zero by generating either a |
27928 | conditional trap or a break instruction. Using traps results in | |
27929 | smaller code, but is only supported on MIPS II and later. Also, some | |
27930 | versions of the Linux kernel have a bug that prevents trap from | |
27931 | generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to | |
27932 | allow conditional traps on architectures that support them and | |
27933 | @option{-mdivide-breaks} to force the use of breaks. | |
27934 | ||
27935 | The default is usually @option{-mdivide-traps}, but this can be | |
27936 | overridden at configure time using @option{--with-divide=breaks}. | |
27937 | Divide-by-zero checks can be completely disabled using | |
27938 | @option{-mno-check-zero-division}. | |
27939 | ||
d77de738 ML |
27940 | @opindex mload-store-pairs |
27941 | @opindex mno-load-store-pairs | |
ddf6fe37 AA |
27942 | @item -mload-store-pairs |
27943 | @itemx -mno-load-store-pairs | |
d77de738 ML |
27944 | Enable (disable) an optimization that pairs consecutive load or store |
27945 | instructions to enable load/store bonding. This option is enabled by | |
27946 | default but only takes effect when the selected architecture is known | |
27947 | to support bonding. | |
27948 | ||
d77de738 ML |
27949 | @opindex munaligned-access |
27950 | @opindex mno-unaligned-access | |
ddf6fe37 AA |
27951 | @item -munaligned-access |
27952 | @itemx -mno-unaligned-access | |
d77de738 ML |
27953 | Enable (disable) direct unaligned access for MIPS Release 6. |
27954 | MIPSr6 requires load/store unaligned-access support, | |
27955 | by hardware or trap&emulate. | |
27956 | So @option{-mno-unaligned-access} may be needed by kernel. | |
27957 | ||
d77de738 ML |
27958 | @opindex mmemcpy |
27959 | @opindex mno-memcpy | |
ddf6fe37 AA |
27960 | @item -mmemcpy |
27961 | @itemx -mno-memcpy | |
d77de738 ML |
27962 | Force (do not force) the use of @code{memcpy} for non-trivial block |
27963 | moves. The default is @option{-mno-memcpy}, which allows GCC to inline | |
27964 | most constant-sized copies. | |
27965 | ||
d77de738 ML |
27966 | @opindex mlong-calls |
27967 | @opindex mno-long-calls | |
ddf6fe37 AA |
27968 | @item -mlong-calls |
27969 | @itemx -mno-long-calls | |
d77de738 ML |
27970 | Disable (do not disable) use of the @code{jal} instruction. Calling |
27971 | functions using @code{jal} is more efficient but requires the caller | |
27972 | and callee to be in the same 256 megabyte segment. | |
27973 | ||
27974 | This option has no effect on abicalls code. The default is | |
27975 | @option{-mno-long-calls}. | |
27976 | ||
d77de738 ML |
27977 | @opindex mmad |
27978 | @opindex mno-mad | |
ddf6fe37 AA |
27979 | @item -mmad |
27980 | @itemx -mno-mad | |
d77de738 ML |
27981 | Enable (disable) use of the @code{mad}, @code{madu} and @code{mul} |
27982 | instructions, as provided by the R4650 ISA@. | |
27983 | ||
d77de738 ML |
27984 | @opindex mimadd |
27985 | @opindex mno-imadd | |
ddf6fe37 AA |
27986 | @item -mimadd |
27987 | @itemx -mno-imadd | |
d77de738 ML |
27988 | Enable (disable) use of the @code{madd} and @code{msub} integer |
27989 | instructions. The default is @option{-mimadd} on architectures | |
27990 | that support @code{madd} and @code{msub} except for the 74k | |
27991 | architecture where it was found to generate slower code. | |
27992 | ||
d77de738 ML |
27993 | @opindex mfused-madd |
27994 | @opindex mno-fused-madd | |
ddf6fe37 AA |
27995 | @item -mfused-madd |
27996 | @itemx -mno-fused-madd | |
d77de738 ML |
27997 | Enable (disable) use of the floating-point multiply-accumulate |
27998 | instructions, when they are available. The default is | |
27999 | @option{-mfused-madd}. | |
28000 | ||
28001 | On the R8000 CPU when multiply-accumulate instructions are used, | |
28002 | the intermediate product is calculated to infinite precision | |
28003 | and is not subject to the FCSR Flush to Zero bit. This may be | |
28004 | undesirable in some circumstances. On other processors the result | |
28005 | is numerically identical to the equivalent computation using | |
28006 | separate multiply, add, subtract and negate instructions. | |
28007 | ||
d77de738 | 28008 | @opindex nocpp |
ddf6fe37 | 28009 | @item -nocpp |
d77de738 ML |
28010 | Tell the MIPS assembler to not run its preprocessor over user |
28011 | assembler files (with a @samp{.s} suffix) when assembling them. | |
28012 | ||
d77de738 ML |
28013 | @opindex mfix-24k |
28014 | @opindex mno-fix-24k | |
ddf6fe37 AA |
28015 | @item -mfix-24k |
28016 | @itemx -mno-fix-24k | |
d77de738 ML |
28017 | Work around the 24K E48 (lost data on stores during refill) errata. |
28018 | The workarounds are implemented by the assembler rather than by GCC@. | |
28019 | ||
d77de738 ML |
28020 | @opindex mfix-r4000 |
28021 | @opindex mno-fix-r4000 | |
ddf6fe37 AA |
28022 | @item -mfix-r4000 |
28023 | @itemx -mno-fix-r4000 | |
d77de738 ML |
28024 | Work around certain R4000 CPU errata: |
28025 | @itemize @minus | |
28026 | @item | |
28027 | A double-word or a variable shift may give an incorrect result if executed | |
28028 | immediately after starting an integer division. | |
28029 | @item | |
28030 | A double-word or a variable shift may give an incorrect result if executed | |
28031 | while an integer multiplication is in progress. | |
28032 | @item | |
28033 | An integer division may give an incorrect result if started in a delay slot | |
28034 | of a taken branch or a jump. | |
28035 | @end itemize | |
28036 | ||
d77de738 ML |
28037 | @opindex mfix-r4400 |
28038 | @opindex mno-fix-r4400 | |
ddf6fe37 AA |
28039 | @item -mfix-r4400 |
28040 | @itemx -mno-fix-r4400 | |
d77de738 ML |
28041 | Work around certain R4400 CPU errata: |
28042 | @itemize @minus | |
28043 | @item | |
28044 | A double-word or a variable shift may give an incorrect result if executed | |
28045 | immediately after starting an integer division. | |
28046 | @end itemize | |
28047 | ||
d77de738 ML |
28048 | @opindex mfix-r10000 |
28049 | @opindex mno-fix-r10000 | |
ddf6fe37 AA |
28050 | @item -mfix-r10000 |
28051 | @itemx -mno-fix-r10000 | |
d77de738 ML |
28052 | Work around certain R10000 errata: |
28053 | @itemize @minus | |
28054 | @item | |
28055 | @code{ll}/@code{sc} sequences may not behave atomically on revisions | |
28056 | prior to 3.0. They may deadlock on revisions 2.6 and earlier. | |
28057 | @end itemize | |
28058 | ||
28059 | This option can only be used if the target architecture supports | |
28060 | branch-likely instructions. @option{-mfix-r10000} is the default when | |
28061 | @option{-march=r10000} is used; @option{-mno-fix-r10000} is the default | |
28062 | otherwise. | |
28063 | ||
ddf6fe37 | 28064 | @opindex mfix-r5900 |
d77de738 ML |
28065 | @item -mfix-r5900 |
28066 | @itemx -mno-fix-r5900 | |
d77de738 ML |
28067 | Do not attempt to schedule the preceding instruction into the delay slot |
28068 | of a branch instruction placed at the end of a short loop of six | |
28069 | instructions or fewer and always schedule a @code{nop} instruction there | |
28070 | instead. The short loop bug under certain conditions causes loops to | |
28071 | execute only once or twice, due to a hardware bug in the R5900 chip. The | |
28072 | workaround is implemented by the assembler rather than by GCC@. | |
28073 | ||
ddf6fe37 | 28074 | @opindex mfix-rm7000 |
d77de738 ML |
28075 | @item -mfix-rm7000 |
28076 | @itemx -mno-fix-rm7000 | |
d77de738 ML |
28077 | Work around the RM7000 @code{dmult}/@code{dmultu} errata. The |
28078 | workarounds are implemented by the assembler rather than by GCC@. | |
28079 | ||
ddf6fe37 | 28080 | @opindex mfix-vr4120 |
d77de738 ML |
28081 | @item -mfix-vr4120 |
28082 | @itemx -mno-fix-vr4120 | |
d77de738 ML |
28083 | Work around certain VR4120 errata: |
28084 | @itemize @minus | |
28085 | @item | |
28086 | @code{dmultu} does not always produce the correct result. | |
28087 | @item | |
28088 | @code{div} and @code{ddiv} do not always produce the correct result if one | |
28089 | of the operands is negative. | |
28090 | @end itemize | |
28091 | The workarounds for the division errata rely on special functions in | |
28092 | @file{libgcc.a}. At present, these functions are only provided by | |
28093 | the @code{mips64vr*-elf} configurations. | |
28094 | ||
28095 | Other VR4120 errata require a NOP to be inserted between certain pairs of | |
28096 | instructions. These errata are handled by the assembler, not by GCC itself. | |
28097 | ||
d77de738 | 28098 | @opindex mfix-vr4130 |
ddf6fe37 | 28099 | @item -mfix-vr4130 |
d77de738 ML |
28100 | Work around the VR4130 @code{mflo}/@code{mfhi} errata. The |
28101 | workarounds are implemented by the assembler rather than by GCC, | |
28102 | although GCC avoids using @code{mflo} and @code{mfhi} if the | |
28103 | VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi} | |
28104 | instructions are available instead. | |
28105 | ||
ddf6fe37 | 28106 | @opindex mfix-sb1 |
d77de738 ML |
28107 | @item -mfix-sb1 |
28108 | @itemx -mno-fix-sb1 | |
d77de738 ML |
28109 | Work around certain SB-1 CPU core errata. |
28110 | (This flag currently works around the SB-1 revision 2 | |
28111 | ``F1'' and ``F2'' floating-point errata.) | |
28112 | ||
d77de738 | 28113 | @opindex mr10k-cache-barrier |
ddf6fe37 | 28114 | @item -mr10k-cache-barrier=@var{setting} |
d77de738 ML |
28115 | Specify whether GCC should insert cache barriers to avoid the |
28116 | side effects of speculation on R10K processors. | |
28117 | ||
28118 | In common with many processors, the R10K tries to predict the outcome | |
28119 | of a conditional branch and speculatively executes instructions from | |
28120 | the ``taken'' branch. It later aborts these instructions if the | |
28121 | predicted outcome is wrong. However, on the R10K, even aborted | |
28122 | instructions can have side effects. | |
28123 | ||
28124 | This problem only affects kernel stores and, depending on the system, | |
28125 | kernel loads. As an example, a speculatively-executed store may load | |
28126 | the target memory into cache and mark the cache line as dirty, even if | |
28127 | the store itself is later aborted. If a DMA operation writes to the | |
28128 | same area of memory before the ``dirty'' line is flushed, the cached | |
28129 | data overwrites the DMA-ed data. See the R10K processor manual | |
28130 | for a full description, including other potential problems. | |
28131 | ||
28132 | One workaround is to insert cache barrier instructions before every memory | |
28133 | access that might be speculatively executed and that might have side | |
28134 | effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}} | |
28135 | controls GCC's implementation of this workaround. It assumes that | |
28136 | aborted accesses to any byte in the following regions does not have | |
28137 | side effects: | |
28138 | ||
28139 | @enumerate | |
28140 | @item | |
28141 | the memory occupied by the current function's stack frame; | |
28142 | ||
28143 | @item | |
28144 | the memory occupied by an incoming stack argument; | |
28145 | ||
28146 | @item | |
28147 | the memory occupied by an object with a link-time-constant address. | |
28148 | @end enumerate | |
28149 | ||
28150 | It is the kernel's responsibility to ensure that speculative | |
28151 | accesses to these regions are indeed safe. | |
28152 | ||
28153 | If the input program contains a function declaration such as: | |
28154 | ||
28155 | @smallexample | |
28156 | void foo (void); | |
28157 | @end smallexample | |
28158 | ||
28159 | then the implementation of @code{foo} must allow @code{j foo} and | |
28160 | @code{jal foo} to be executed speculatively. GCC honors this | |
28161 | restriction for functions it compiles itself. It expects non-GCC | |
28162 | functions (such as hand-written assembly code) to do the same. | |
28163 | ||
28164 | The option has three forms: | |
28165 | ||
28166 | @table @gcctabopt | |
28167 | @item -mr10k-cache-barrier=load-store | |
28168 | Insert a cache barrier before a load or store that might be | |
28169 | speculatively executed and that might have side effects even | |
28170 | if aborted. | |
28171 | ||
28172 | @item -mr10k-cache-barrier=store | |
28173 | Insert a cache barrier before a store that might be speculatively | |
28174 | executed and that might have side effects even if aborted. | |
28175 | ||
28176 | @item -mr10k-cache-barrier=none | |
28177 | Disable the insertion of cache barriers. This is the default setting. | |
28178 | @end table | |
28179 | ||
ddf6fe37 | 28180 | @opindex mflush-func |
d77de738 ML |
28181 | @item -mflush-func=@var{func} |
28182 | @itemx -mno-flush-func | |
d77de738 ML |
28183 | Specifies the function to call to flush the I and D caches, or to not |
28184 | call any such function. If called, the function must take the same | |
28185 | arguments as the common @code{_flush_func}, that is, the address of the | |
28186 | memory range for which the cache is being flushed, the size of the | |
28187 | memory range, and the number 3 (to flush both caches). The default | |
28188 | depends on the target GCC was configured for, but commonly is either | |
28189 | @code{_flush_func} or @code{__cpu_flush}. | |
28190 | ||
d77de738 | 28191 | @opindex mbranch-cost |
ddf6fe37 | 28192 | @item mbranch-cost=@var{num} |
d77de738 ML |
28193 | Set the cost of branches to roughly @var{num} ``simple'' instructions. |
28194 | This cost is only a heuristic and is not guaranteed to produce | |
28195 | consistent results across releases. A zero cost redundantly selects | |
28196 | the default, which is based on the @option{-mtune} setting. | |
28197 | ||
d77de738 ML |
28198 | @opindex mbranch-likely |
28199 | @opindex mno-branch-likely | |
ddf6fe37 AA |
28200 | @item -mbranch-likely |
28201 | @itemx -mno-branch-likely | |
d77de738 ML |
28202 | Enable or disable use of Branch Likely instructions, regardless of the |
28203 | default for the selected architecture. By default, Branch Likely | |
28204 | instructions may be generated if they are supported by the selected | |
28205 | architecture. An exception is for the MIPS32 and MIPS64 architectures | |
28206 | and processors that implement those architectures; for those, Branch | |
28207 | Likely instructions are not be generated by default because the MIPS32 | |
28208 | and MIPS64 architectures specifically deprecate their use. | |
28209 | ||
d77de738 ML |
28210 | @opindex mcompact-branches=never |
28211 | @opindex mcompact-branches=optimal | |
28212 | @opindex mcompact-branches=always | |
ddf6fe37 AA |
28213 | @item -mcompact-branches=never |
28214 | @itemx -mcompact-branches=optimal | |
28215 | @itemx -mcompact-branches=always | |
d77de738 ML |
28216 | These options control which form of branches will be generated. The |
28217 | default is @option{-mcompact-branches=optimal}. | |
28218 | ||
28219 | The @option{-mcompact-branches=never} option ensures that compact branch | |
28220 | instructions will never be generated. | |
28221 | ||
28222 | The @option{-mcompact-branches=always} option ensures that a compact | |
28223 | branch instruction will be generated if available for MIPS Release 6 onwards. | |
28224 | If a compact branch instruction is not available (or pre-R6), | |
28225 | a delay slot form of the branch will be used instead. | |
28226 | ||
28227 | If it is used for MIPS16/microMIPS targets, it will be just ignored now. | |
28228 | The behaviour for MIPS16/microMIPS may change in future, | |
28229 | since they do have some compact branch instructions. | |
28230 | ||
28231 | The @option{-mcompact-branches=optimal} option will cause a delay slot | |
28232 | branch to be used if one is available in the current ISA and the delay | |
28233 | slot is successfully filled. If the delay slot is not filled, a compact | |
28234 | branch will be chosen if one is available. | |
28235 | ||
ddf6fe37 | 28236 | @opindex mfp-exceptions |
d77de738 ML |
28237 | @item -mfp-exceptions |
28238 | @itemx -mno-fp-exceptions | |
d77de738 ML |
28239 | Specifies whether FP exceptions are enabled. This affects how |
28240 | FP instructions are scheduled for some processors. | |
28241 | The default is that FP exceptions are | |
28242 | enabled. | |
28243 | ||
28244 | For instance, on the SB-1, if FP exceptions are disabled, and we are emitting | |
28245 | 64-bit code, then we can use both FP pipes. Otherwise, we can only use one | |
28246 | FP pipe. | |
28247 | ||
ddf6fe37 | 28248 | @opindex mvr4130-align |
d77de738 ML |
28249 | @item -mvr4130-align |
28250 | @itemx -mno-vr4130-align | |
d77de738 ML |
28251 | The VR4130 pipeline is two-way superscalar, but can only issue two |
28252 | instructions together if the first one is 8-byte aligned. When this | |
28253 | option is enabled, GCC aligns pairs of instructions that it | |
28254 | thinks should execute in parallel. | |
28255 | ||
28256 | This option only has an effect when optimizing for the VR4130. | |
28257 | It normally makes code faster, but at the expense of making it bigger. | |
28258 | It is enabled by default at optimization level @option{-O3}. | |
28259 | ||
ddf6fe37 | 28260 | @opindex msynci |
d77de738 ML |
28261 | @item -msynci |
28262 | @itemx -mno-synci | |
d77de738 ML |
28263 | Enable (disable) generation of @code{synci} instructions on |
28264 | architectures that support it. The @code{synci} instructions (if | |
28265 | enabled) are generated when @code{__builtin___clear_cache} is | |
28266 | compiled. | |
28267 | ||
28268 | This option defaults to @option{-mno-synci}, but the default can be | |
28269 | overridden by configuring GCC with @option{--with-synci}. | |
28270 | ||
28271 | When compiling code for single processor systems, it is generally safe | |
28272 | to use @code{synci}. However, on many multi-core (SMP) systems, it | |
28273 | does not invalidate the instruction caches on all cores and may lead | |
28274 | to undefined behavior. | |
28275 | ||
ddf6fe37 | 28276 | @opindex mrelax-pic-calls |
d77de738 ML |
28277 | @item -mrelax-pic-calls |
28278 | @itemx -mno-relax-pic-calls | |
d77de738 ML |
28279 | Try to turn PIC calls that are normally dispatched via register |
28280 | @code{$25} into direct calls. This is only possible if the linker can | |
28281 | resolve the destination at link time and if the destination is within | |
28282 | range for a direct call. | |
28283 | ||
28284 | @option{-mrelax-pic-calls} is the default if GCC was configured to use | |
28285 | an assembler and a linker that support the @code{.reloc} assembly | |
28286 | directive and @option{-mexplicit-relocs} is in effect. With | |
28287 | @option{-mno-explicit-relocs}, this optimization can be performed by the | |
28288 | assembler and the linker alone without help from the compiler. | |
28289 | ||
d77de738 ML |
28290 | @opindex mmcount-ra-address |
28291 | @opindex mno-mcount-ra-address | |
ddf6fe37 AA |
28292 | @item -mmcount-ra-address |
28293 | @itemx -mno-mcount-ra-address | |
d77de738 ML |
28294 | Emit (do not emit) code that allows @code{_mcount} to modify the |
28295 | calling function's return address. When enabled, this option extends | |
28296 | the usual @code{_mcount} interface with a new @var{ra-address} | |
28297 | parameter, which has type @code{intptr_t *} and is passed in register | |
28298 | @code{$12}. @code{_mcount} can then modify the return address by | |
28299 | doing both of the following: | |
28300 | @itemize | |
28301 | @item | |
28302 | Returning the new address in register @code{$31}. | |
28303 | @item | |
28304 | Storing the new address in @code{*@var{ra-address}}, | |
28305 | if @var{ra-address} is nonnull. | |
28306 | @end itemize | |
28307 | ||
28308 | The default is @option{-mno-mcount-ra-address}. | |
28309 | ||
ddf6fe37 | 28310 | @opindex mframe-header-opt |
d77de738 ML |
28311 | @item -mframe-header-opt |
28312 | @itemx -mno-frame-header-opt | |
d77de738 ML |
28313 | Enable (disable) frame header optimization in the o32 ABI. When using the |
28314 | o32 ABI, calling functions will allocate 16 bytes on the stack for the called | |
28315 | function to write out register arguments. When enabled, this optimization | |
28316 | will suppress the allocation of the frame header if it can be determined that | |
28317 | it is unused. | |
28318 | ||
28319 | This optimization is off by default at all optimization levels. | |
28320 | ||
ddf6fe37 | 28321 | @opindex mlxc1-sxc1 |
d77de738 ML |
28322 | @item -mlxc1-sxc1 |
28323 | @itemx -mno-lxc1-sxc1 | |
d77de738 ML |
28324 | When applicable, enable (disable) the generation of @code{lwxc1}, |
28325 | @code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default. | |
28326 | ||
ddf6fe37 | 28327 | @opindex mmadd4 |
d77de738 ML |
28328 | @item -mmadd4 |
28329 | @itemx -mno-madd4 | |
d77de738 ML |
28330 | When applicable, enable (disable) the generation of 4-operand @code{madd.s}, |
28331 | @code{madd.d} and related instructions. Enabled by default. | |
28332 | ||
28333 | @end table | |
28334 | ||
28335 | @node MMIX Options | |
28336 | @subsection MMIX Options | |
28337 | @cindex MMIX Options | |
28338 | ||
28339 | These options are defined for the MMIX: | |
28340 | ||
28341 | @table @gcctabopt | |
d77de738 ML |
28342 | @opindex mlibfuncs |
28343 | @opindex mno-libfuncs | |
ddf6fe37 AA |
28344 | @item -mlibfuncs |
28345 | @itemx -mno-libfuncs | |
d77de738 ML |
28346 | Specify that intrinsic library functions are being compiled, passing all |
28347 | values in registers, no matter the size. | |
28348 | ||
d77de738 ML |
28349 | @opindex mepsilon |
28350 | @opindex mno-epsilon | |
ddf6fe37 AA |
28351 | @item -mepsilon |
28352 | @itemx -mno-epsilon | |
d77de738 ML |
28353 | Generate floating-point comparison instructions that compare with respect |
28354 | to the @code{rE} epsilon register. | |
28355 | ||
d77de738 ML |
28356 | @opindex mabi=mmixware |
28357 | @opindex mabi=gnu | |
ddf6fe37 AA |
28358 | @item -mabi=mmixware |
28359 | @itemx -mabi=gnu | |
d77de738 ML |
28360 | Generate code that passes function parameters and return values that (in |
28361 | the called function) are seen as registers @code{$0} and up, as opposed to | |
28362 | the GNU ABI which uses global registers @code{$231} and up. | |
28363 | ||
d77de738 ML |
28364 | @opindex mzero-extend |
28365 | @opindex mno-zero-extend | |
ddf6fe37 AA |
28366 | @item -mzero-extend |
28367 | @itemx -mno-zero-extend | |
d77de738 ML |
28368 | When reading data from memory in sizes shorter than 64 bits, use (do not |
28369 | use) zero-extending load instructions by default, rather than | |
28370 | sign-extending ones. | |
28371 | ||
d77de738 ML |
28372 | @opindex mknuthdiv |
28373 | @opindex mno-knuthdiv | |
ddf6fe37 AA |
28374 | @item -mknuthdiv |
28375 | @itemx -mno-knuthdiv | |
d77de738 ML |
28376 | Make the result of a division yielding a remainder have the same sign as |
28377 | the divisor. With the default, @option{-mno-knuthdiv}, the sign of the | |
28378 | remainder follows the sign of the dividend. Both methods are | |
28379 | arithmetically valid, the latter being almost exclusively used. | |
28380 | ||
d77de738 ML |
28381 | @opindex mtoplevel-symbols |
28382 | @opindex mno-toplevel-symbols | |
ddf6fe37 AA |
28383 | @item -mtoplevel-symbols |
28384 | @itemx -mno-toplevel-symbols | |
d77de738 ML |
28385 | Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly |
28386 | code can be used with the @code{PREFIX} assembly directive. | |
28387 | ||
d77de738 | 28388 | @opindex melf |
ddf6fe37 | 28389 | @item -melf |
d77de738 ML |
28390 | Generate an executable in the ELF format, rather than the default |
28391 | @samp{mmo} format used by the @command{mmix} simulator. | |
28392 | ||
d77de738 ML |
28393 | @opindex mbranch-predict |
28394 | @opindex mno-branch-predict | |
ddf6fe37 AA |
28395 | @item -mbranch-predict |
28396 | @itemx -mno-branch-predict | |
d77de738 ML |
28397 | Use (do not use) the probable-branch instructions, when static branch |
28398 | prediction indicates a probable branch. | |
28399 | ||
d77de738 ML |
28400 | @opindex mbase-addresses |
28401 | @opindex mno-base-addresses | |
ddf6fe37 AA |
28402 | @item -mbase-addresses |
28403 | @itemx -mno-base-addresses | |
d77de738 ML |
28404 | Generate (do not generate) code that uses @emph{base addresses}. Using a |
28405 | base address automatically generates a request (handled by the assembler | |
28406 | and the linker) for a constant to be set up in a global register. The | |
28407 | register is used for one or more base address requests within the range 0 | |
28408 | to 255 from the value held in the register. The generally leads to short | |
28409 | and fast code, but the number of different data items that can be | |
28410 | addressed is limited. This means that a program that uses lots of static | |
28411 | data may require @option{-mno-base-addresses}. | |
28412 | ||
d77de738 ML |
28413 | @opindex msingle-exit |
28414 | @opindex mno-single-exit | |
ddf6fe37 AA |
28415 | @item -msingle-exit |
28416 | @itemx -mno-single-exit | |
d77de738 ML |
28417 | Force (do not force) generated code to have a single exit point in each |
28418 | function. | |
28419 | @end table | |
28420 | ||
28421 | @node MN10300 Options | |
28422 | @subsection MN10300 Options | |
28423 | @cindex MN10300 options | |
28424 | ||
28425 | These @option{-m} options are defined for Matsushita MN10300 architectures: | |
28426 | ||
28427 | @table @gcctabopt | |
d77de738 | 28428 | @opindex mmult-bug |
ddf6fe37 | 28429 | @item -mmult-bug |
d77de738 ML |
28430 | Generate code to avoid bugs in the multiply instructions for the MN10300 |
28431 | processors. This is the default. | |
28432 | ||
d77de738 | 28433 | @opindex mno-mult-bug |
ddf6fe37 | 28434 | @item -mno-mult-bug |
d77de738 ML |
28435 | Do not generate code to avoid bugs in the multiply instructions for the |
28436 | MN10300 processors. | |
28437 | ||
d77de738 | 28438 | @opindex mam33 |
ddf6fe37 | 28439 | @item -mam33 |
d77de738 ML |
28440 | Generate code using features specific to the AM33 processor. |
28441 | ||
d77de738 | 28442 | @opindex mno-am33 |
ddf6fe37 | 28443 | @item -mno-am33 |
d77de738 ML |
28444 | Do not generate code using features specific to the AM33 processor. This |
28445 | is the default. | |
28446 | ||
d77de738 | 28447 | @opindex mam33-2 |
ddf6fe37 | 28448 | @item -mam33-2 |
d77de738 ML |
28449 | Generate code using features specific to the AM33/2.0 processor. |
28450 | ||
d77de738 | 28451 | @opindex mam34 |
ddf6fe37 | 28452 | @item -mam34 |
d77de738 ML |
28453 | Generate code using features specific to the AM34 processor. |
28454 | ||
d77de738 | 28455 | @opindex mtune |
ddf6fe37 | 28456 | @item -mtune=@var{cpu-type} |
d77de738 ML |
28457 | Use the timing characteristics of the indicated CPU type when |
28458 | scheduling instructions. This does not change the targeted processor | |
28459 | type. The CPU type must be one of @samp{mn10300}, @samp{am33}, | |
28460 | @samp{am33-2} or @samp{am34}. | |
28461 | ||
d77de738 | 28462 | @opindex mreturn-pointer-on-d0 |
ddf6fe37 | 28463 | @item -mreturn-pointer-on-d0 |
d77de738 ML |
28464 | When generating a function that returns a pointer, return the pointer |
28465 | in both @code{a0} and @code{d0}. Otherwise, the pointer is returned | |
28466 | only in @code{a0}, and attempts to call such functions without a prototype | |
28467 | result in errors. Note that this option is on by default; use | |
28468 | @option{-mno-return-pointer-on-d0} to disable it. | |
28469 | ||
d77de738 | 28470 | @opindex mno-crt0 |
ddf6fe37 | 28471 | @item -mno-crt0 |
d77de738 ML |
28472 | Do not link in the C run-time initialization object file. |
28473 | ||
d77de738 | 28474 | @opindex mrelax |
ddf6fe37 | 28475 | @item -mrelax |
d77de738 ML |
28476 | Indicate to the linker that it should perform a relaxation optimization pass |
28477 | to shorten branches, calls and absolute memory addresses. This option only | |
28478 | has an effect when used on the command line for the final link step. | |
28479 | ||
28480 | This option makes symbolic debugging impossible. | |
28481 | ||
d77de738 | 28482 | @opindex mliw |
ddf6fe37 | 28483 | @item -mliw |
d77de738 ML |
28484 | Allow the compiler to generate @emph{Long Instruction Word} |
28485 | instructions if the target is the @samp{AM33} or later. This is the | |
28486 | default. This option defines the preprocessor macro @code{__LIW__}. | |
28487 | ||
d77de738 | 28488 | @opindex mno-liw |
ddf6fe37 | 28489 | @item -mno-liw |
d77de738 ML |
28490 | Do not allow the compiler to generate @emph{Long Instruction Word} |
28491 | instructions. This option defines the preprocessor macro | |
28492 | @code{__NO_LIW__}. | |
28493 | ||
d77de738 | 28494 | @opindex msetlb |
ddf6fe37 | 28495 | @item -msetlb |
d77de738 ML |
28496 | Allow the compiler to generate the @emph{SETLB} and @emph{Lcc} |
28497 | instructions if the target is the @samp{AM33} or later. This is the | |
28498 | default. This option defines the preprocessor macro @code{__SETLB__}. | |
28499 | ||
d77de738 | 28500 | @opindex mno-setlb |
ddf6fe37 | 28501 | @item -mno-setlb |
d77de738 ML |
28502 | Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc} |
28503 | instructions. This option defines the preprocessor macro | |
28504 | @code{__NO_SETLB__}. | |
28505 | ||
28506 | @end table | |
28507 | ||
28508 | @node Moxie Options | |
28509 | @subsection Moxie Options | |
28510 | @cindex Moxie Options | |
28511 | ||
28512 | @table @gcctabopt | |
28513 | ||
d77de738 | 28514 | @opindex meb |
ddf6fe37 | 28515 | @item -meb |
d77de738 ML |
28516 | Generate big-endian code. This is the default for @samp{moxie-*-*} |
28517 | configurations. | |
28518 | ||
d77de738 | 28519 | @opindex mel |
ddf6fe37 | 28520 | @item -mel |
d77de738 ML |
28521 | Generate little-endian code. |
28522 | ||
d77de738 | 28523 | @opindex mmul.x |
ddf6fe37 | 28524 | @item -mmul.x |
d77de738 ML |
28525 | Generate mul.x and umul.x instructions. This is the default for |
28526 | @samp{moxiebox-*-*} configurations. | |
28527 | ||
d77de738 | 28528 | @opindex mno-crt0 |
ddf6fe37 | 28529 | @item -mno-crt0 |
d77de738 ML |
28530 | Do not link in the C run-time initialization object file. |
28531 | ||
28532 | @end table | |
28533 | ||
28534 | @node MSP430 Options | |
28535 | @subsection MSP430 Options | |
28536 | @cindex MSP430 Options | |
28537 | ||
28538 | These options are defined for the MSP430: | |
28539 | ||
28540 | @table @gcctabopt | |
28541 | ||
d77de738 | 28542 | @opindex masm-hex |
ddf6fe37 | 28543 | @item -masm-hex |
d77de738 ML |
28544 | Force assembly output to always use hex constants. Normally such |
28545 | constants are signed decimals, but this option is available for | |
28546 | testsuite and/or aesthetic purposes. | |
28547 | ||
d77de738 | 28548 | @opindex mmcu= |
ddf6fe37 | 28549 | @item -mmcu= |
d77de738 ML |
28550 | Select the MCU to target. This is used to create a C preprocessor |
28551 | symbol based upon the MCU name, converted to upper case and pre- and | |
28552 | post-fixed with @samp{__}. This in turn is used by the | |
28553 | @file{msp430.h} header file to select an MCU-specific supplementary | |
28554 | header file. | |
28555 | ||
28556 | The option also sets the ISA to use. If the MCU name is one that is | |
28557 | known to only support the 430 ISA then that is selected, otherwise the | |
28558 | 430X ISA is selected. A generic MCU name of @samp{msp430} can also be | |
28559 | used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU | |
28560 | name selects the 430X ISA. | |
28561 | ||
28562 | In addition an MCU-specific linker script is added to the linker | |
28563 | command line. The script's name is the name of the MCU with | |
28564 | @file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc} | |
28565 | command line defines the C preprocessor symbol @code{__XXX__} and | |
28566 | cause the linker to search for a script called @file{xxx.ld}. | |
28567 | ||
28568 | The ISA and hardware multiply supported for the different MCUs is hard-coded | |
28569 | into GCC. However, an external @samp{devices.csv} file can be used to | |
28570 | extend device support beyond those that have been hard-coded. | |
28571 | ||
28572 | GCC searches for the @samp{devices.csv} file using the following methods in the | |
28573 | given precedence order, where the first method takes precendence over the | |
28574 | second which takes precedence over the third. | |
28575 | ||
28576 | @table @asis | |
28577 | @item Include path specified with @code{-I} and @code{-L} | |
28578 | @samp{devices.csv} will be searched for in each of the directories specified by | |
28579 | include paths and linker library search paths. | |
28580 | @item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR} | |
28581 | Define the value of the global environment variable | |
28582 | @samp{MSP430_GCC_INCLUDE_DIR} | |
28583 | to the full path to the directory containing devices.csv, and GCC will search | |
28584 | this directory for devices.csv. If devices.csv is found, this directory will | |
28585 | also be registered as an include path, and linker library path. Header files | |
28586 | and linker scripts in this directory can therefore be used without manually | |
28587 | specifying @code{-I} and @code{-L} on the command line. | |
28588 | @item The @samp{msp430-elf@{,bare@}/include/devices} directory | |
28589 | Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the | |
28590 | toolchain root directory. This directory does not exist in a default | |
28591 | installation, but if the user has created it and copied @samp{devices.csv} | |
28592 | there, then the MCU data will be read. As above, this directory will | |
28593 | also be registered as an include path, and linker library path. | |
28594 | ||
28595 | @end table | |
28596 | If none of the above search methods find @samp{devices.csv}, then the | |
28597 | hard-coded MCU data is used. | |
28598 | ||
28599 | ||
d77de738 ML |
28600 | @opindex mwarn-mcu |
28601 | @opindex mno-warn-mcu | |
ddf6fe37 AA |
28602 | @item -mwarn-mcu |
28603 | @itemx -mno-warn-mcu | |
d77de738 ML |
28604 | This option enables or disables warnings about conflicts between the |
28605 | MCU name specified by the @option{-mmcu} option and the ISA set by the | |
28606 | @option{-mcpu} option and/or the hardware multiply support set by the | |
28607 | @option{-mhwmult} option. It also toggles warnings about unrecognized | |
28608 | MCU names. This option is on by default. | |
28609 | ||
d77de738 | 28610 | @opindex mcpu= |
ddf6fe37 | 28611 | @item -mcpu= |
d77de738 ML |
28612 | Specifies the ISA to use. Accepted values are @samp{msp430}, |
28613 | @samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The | |
28614 | @option{-mmcu=} option should be used to select the ISA. | |
28615 | ||
d77de738 | 28616 | @opindex msim |
ddf6fe37 | 28617 | @item -msim |
d77de738 ML |
28618 | Link to the simulator runtime libraries and linker script. Overrides |
28619 | any scripts that would be selected by the @option{-mmcu=} option. | |
28620 | ||
d77de738 | 28621 | @opindex mlarge |
ddf6fe37 | 28622 | @item -mlarge |
d77de738 ML |
28623 | Use large-model addressing (20-bit pointers, 20-bit @code{size_t}). |
28624 | ||
d77de738 | 28625 | @opindex msmall |
ddf6fe37 | 28626 | @item -msmall |
d77de738 ML |
28627 | Use small-model addressing (16-bit pointers, 16-bit @code{size_t}). |
28628 | ||
d77de738 | 28629 | @opindex mrelax |
ddf6fe37 | 28630 | @item -mrelax |
d77de738 ML |
28631 | This option is passed to the assembler and linker, and allows the |
28632 | linker to perform certain optimizations that cannot be done until | |
28633 | the final link. | |
28634 | ||
d77de738 | 28635 | @opindex mhwmult= |
ddf6fe37 | 28636 | @item mhwmult= |
d77de738 ML |
28637 | Describes the type of hardware multiply supported by the target. |
28638 | Accepted values are @samp{none} for no hardware multiply, @samp{16bit} | |
28639 | for the original 16-bit-only multiply supported by early MCUs. | |
28640 | @samp{32bit} for the 16/32-bit multiply supported by later MCUs and | |
28641 | @samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs. | |
28642 | A value of @samp{auto} can also be given. This tells GCC to deduce | |
28643 | the hardware multiply support based upon the MCU name provided by the | |
28644 | @option{-mmcu} option. If no @option{-mmcu} option is specified or if | |
28645 | the MCU name is not recognized then no hardware multiply support is | |
28646 | assumed. @code{auto} is the default setting. | |
28647 | ||
28648 | Hardware multiplies are normally performed by calling a library | |
28649 | routine. This saves space in the generated code. When compiling at | |
28650 | @option{-O3} or higher however the hardware multiplier is invoked | |
28651 | inline. This makes for bigger, but faster code. | |
28652 | ||
28653 | The hardware multiply routines disable interrupts whilst running and | |
28654 | restore the previous interrupt state when they finish. This makes | |
28655 | them safe to use inside interrupt handlers as well as in normal code. | |
28656 | ||
d77de738 | 28657 | @opindex minrt |
ddf6fe37 | 28658 | @item -minrt |
d77de738 ML |
28659 | Enable the use of a minimum runtime environment - no static |
28660 | initializers or constructors. This is intended for memory-constrained | |
28661 | devices. The compiler includes special symbols in some objects | |
28662 | that tell the linker and runtime which code fragments are required. | |
28663 | ||
d77de738 | 28664 | @opindex mtiny-printf |
ddf6fe37 | 28665 | @item -mtiny-printf |
d77de738 ML |
28666 | Enable reduced code size @code{printf} and @code{puts} library functions. |
28667 | The @samp{tiny} implementations of these functions are not reentrant, so | |
28668 | must be used with caution in multi-threaded applications. | |
28669 | ||
28670 | Support for streams has been removed and the string to be printed will | |
28671 | always be sent to stdout via the @code{write} syscall. The string is not | |
28672 | buffered before it is sent to write. | |
28673 | ||
28674 | This option requires Newlib Nano IO, so GCC must be configured with | |
28675 | @samp{--enable-newlib-nano-formatted-io}. | |
28676 | ||
d77de738 | 28677 | @opindex mmax-inline-shift= |
ddf6fe37 | 28678 | @item -mmax-inline-shift= |
d77de738 ML |
28679 | This option takes an integer between 0 and 64 inclusive, and sets |
28680 | the maximum number of inline shift instructions which should be emitted to | |
28681 | perform a shift operation by a constant amount. When this value needs to be | |
28682 | exceeded, an mspabi helper function is used instead. The default value is 4. | |
28683 | ||
28684 | This only affects cases where a shift by multiple positions cannot be | |
28685 | completed with a single instruction (e.g. all shifts >1 on the 430 ISA). | |
28686 | ||
28687 | Shifts of a 32-bit value are at least twice as costly, so the value passed for | |
28688 | this option is divided by 2 and the resulting value used instead. | |
28689 | ||
d77de738 ML |
28690 | @opindex mcode-region |
28691 | @opindex mdata-region | |
ddf6fe37 AA |
28692 | @item -mcode-region= |
28693 | @itemx -mdata-region= | |
d77de738 ML |
28694 | These options tell the compiler where to place functions and data that |
28695 | do not have one of the @code{lower}, @code{upper}, @code{either} or | |
28696 | @code{section} attributes. Possible values are @code{lower}, | |
28697 | @code{upper}, @code{either} or @code{any}. The first three behave | |
28698 | like the corresponding attribute. The fourth possible value - | |
28699 | @code{any} - is the default. It leaves placement entirely up to the | |
28700 | linker script and how it assigns the standard sections | |
28701 | (@code{.text}, @code{.data}, etc) to the memory regions. | |
28702 | ||
d77de738 | 28703 | @opindex msilicon-errata |
ddf6fe37 | 28704 | @item -msilicon-errata= |
d77de738 ML |
28705 | This option passes on a request to assembler to enable the fixes for |
28706 | the named silicon errata. | |
28707 | ||
d77de738 | 28708 | @opindex msilicon-errata-warn |
ddf6fe37 | 28709 | @item -msilicon-errata-warn= |
d77de738 ML |
28710 | This option passes on a request to the assembler to enable warning |
28711 | messages when a silicon errata might need to be applied. | |
28712 | ||
d77de738 ML |
28713 | @opindex mwarn-devices-csv |
28714 | @opindex mno-warn-devices-csv | |
ddf6fe37 AA |
28715 | @item -mwarn-devices-csv |
28716 | @itemx -mno-warn-devices-csv | |
d77de738 ML |
28717 | Warn if @samp{devices.csv} is not found or there are problem parsing it |
28718 | (default: on). | |
28719 | ||
28720 | @end table | |
28721 | ||
28722 | @node NDS32 Options | |
28723 | @subsection NDS32 Options | |
28724 | @cindex NDS32 Options | |
28725 | ||
28726 | These options are defined for NDS32 implementations: | |
28727 | ||
28728 | @table @gcctabopt | |
28729 | ||
d77de738 | 28730 | @opindex mbig-endian |
ddf6fe37 | 28731 | @item -mbig-endian |
d77de738 ML |
28732 | Generate code in big-endian mode. |
28733 | ||
d77de738 | 28734 | @opindex mlittle-endian |
ddf6fe37 | 28735 | @item -mlittle-endian |
d77de738 ML |
28736 | Generate code in little-endian mode. |
28737 | ||
d77de738 | 28738 | @opindex mreduced-regs |
ddf6fe37 | 28739 | @item -mreduced-regs |
d77de738 ML |
28740 | Use reduced-set registers for register allocation. |
28741 | ||
d77de738 | 28742 | @opindex mfull-regs |
ddf6fe37 | 28743 | @item -mfull-regs |
d77de738 ML |
28744 | Use full-set registers for register allocation. |
28745 | ||
d77de738 | 28746 | @opindex mcmov |
ddf6fe37 | 28747 | @item -mcmov |
d77de738 ML |
28748 | Generate conditional move instructions. |
28749 | ||
d77de738 | 28750 | @opindex mno-cmov |
ddf6fe37 | 28751 | @item -mno-cmov |
d77de738 ML |
28752 | Do not generate conditional move instructions. |
28753 | ||
d77de738 | 28754 | @opindex mext-perf |
ddf6fe37 | 28755 | @item -mext-perf |
d77de738 ML |
28756 | Generate performance extension instructions. |
28757 | ||
d77de738 | 28758 | @opindex mno-ext-perf |
ddf6fe37 | 28759 | @item -mno-ext-perf |
d77de738 ML |
28760 | Do not generate performance extension instructions. |
28761 | ||
d77de738 | 28762 | @opindex mext-perf2 |
ddf6fe37 | 28763 | @item -mext-perf2 |
d77de738 ML |
28764 | Generate performance extension 2 instructions. |
28765 | ||
d77de738 | 28766 | @opindex mno-ext-perf2 |
ddf6fe37 | 28767 | @item -mno-ext-perf2 |
d77de738 ML |
28768 | Do not generate performance extension 2 instructions. |
28769 | ||
d77de738 | 28770 | @opindex mext-string |
ddf6fe37 | 28771 | @item -mext-string |
d77de738 ML |
28772 | Generate string extension instructions. |
28773 | ||
d77de738 | 28774 | @opindex mno-ext-string |
ddf6fe37 | 28775 | @item -mno-ext-string |
d77de738 ML |
28776 | Do not generate string extension instructions. |
28777 | ||
d77de738 | 28778 | @opindex mv3push |
ddf6fe37 | 28779 | @item -mv3push |
d77de738 ML |
28780 | Generate v3 push25/pop25 instructions. |
28781 | ||
d77de738 | 28782 | @opindex mno-v3push |
ddf6fe37 | 28783 | @item -mno-v3push |
d77de738 ML |
28784 | Do not generate v3 push25/pop25 instructions. |
28785 | ||
d77de738 | 28786 | @opindex m16-bit |
ddf6fe37 | 28787 | @item -m16-bit |
d77de738 ML |
28788 | Generate 16-bit instructions. |
28789 | ||
d77de738 | 28790 | @opindex mno-16-bit |
ddf6fe37 | 28791 | @item -mno-16-bit |
d77de738 ML |
28792 | Do not generate 16-bit instructions. |
28793 | ||
d77de738 | 28794 | @opindex misr-vector-size |
ddf6fe37 | 28795 | @item -misr-vector-size=@var{num} |
d77de738 ML |
28796 | Specify the size of each interrupt vector, which must be 4 or 16. |
28797 | ||
d77de738 | 28798 | @opindex mcache-block-size |
ddf6fe37 | 28799 | @item -mcache-block-size=@var{num} |
d77de738 ML |
28800 | Specify the size of each cache block, |
28801 | which must be a power of 2 between 4 and 512. | |
28802 | ||
d77de738 | 28803 | @opindex march |
ddf6fe37 | 28804 | @item -march=@var{arch} |
d77de738 ML |
28805 | Specify the name of the target architecture. |
28806 | ||
d77de738 | 28807 | @opindex mcmodel |
ddf6fe37 | 28808 | @item -mcmodel=@var{code-model} |
d77de738 ML |
28809 | Set the code model to one of |
28810 | @table @asis | |
28811 | @item @samp{small} | |
28812 | All the data and read-only data segments must be within 512KB addressing space. | |
28813 | The text segment must be within 16MB addressing space. | |
28814 | @item @samp{medium} | |
28815 | The data segment must be within 512KB while the read-only data segment can be | |
28816 | within 4GB addressing space. The text segment should be still within 16MB | |
28817 | addressing space. | |
28818 | @item @samp{large} | |
28819 | All the text and data segments can be within 4GB addressing space. | |
28820 | @end table | |
28821 | ||
d77de738 | 28822 | @opindex mctor-dtor |
ddf6fe37 | 28823 | @item -mctor-dtor |
d77de738 ML |
28824 | Enable constructor/destructor feature. |
28825 | ||
d77de738 | 28826 | @opindex mrelax |
ddf6fe37 | 28827 | @item -mrelax |
d77de738 ML |
28828 | Guide linker to relax instructions. |
28829 | ||
28830 | @end table | |
28831 | ||
28832 | @node Nios II Options | |
28833 | @subsection Nios II Options | |
28834 | @cindex Nios II options | |
28835 | @cindex Altera Nios II options | |
28836 | ||
28837 | These are the options defined for the Altera Nios II processor. | |
28838 | ||
28839 | @table @gcctabopt | |
28840 | ||
d77de738 ML |
28841 | @opindex G |
28842 | @cindex smaller data references | |
f33d7a88 | 28843 | @item -G @var{num} |
d77de738 ML |
28844 | Put global and static objects less than or equal to @var{num} bytes |
28845 | into the small data or BSS sections instead of the normal data or BSS | |
28846 | sections. The default value of @var{num} is 8. | |
28847 | ||
ddf6fe37 AA |
28848 | @opindex mgpopt |
28849 | @opindex mno-gpopt | |
d77de738 ML |
28850 | @item -mgpopt=@var{option} |
28851 | @itemx -mgpopt | |
28852 | @itemx -mno-gpopt | |
d77de738 ML |
28853 | Generate (do not generate) GP-relative accesses. The following |
28854 | @var{option} names are recognized: | |
28855 | ||
28856 | @table @samp | |
28857 | ||
28858 | @item none | |
28859 | Do not generate GP-relative accesses. | |
28860 | ||
28861 | @item local | |
28862 | Generate GP-relative accesses for small data objects that are not | |
28863 | external, weak, or uninitialized common symbols. | |
28864 | Also use GP-relative addressing for objects that | |
28865 | have been explicitly placed in a small data section via a @code{section} | |
28866 | attribute. | |
28867 | ||
28868 | @item global | |
28869 | As for @samp{local}, but also generate GP-relative accesses for | |
28870 | small data objects that are external, weak, or common. If you use this option, | |
28871 | you must ensure that all parts of your program (including libraries) are | |
28872 | compiled with the same @option{-G} setting. | |
28873 | ||
28874 | @item data | |
28875 | Generate GP-relative accesses for all data objects in the program. If you | |
28876 | use this option, the entire data and BSS segments | |
28877 | of your program must fit in 64K of memory and you must use an appropriate | |
28878 | linker script to allocate them within the addressable range of the | |
28879 | global pointer. | |
28880 | ||
28881 | @item all | |
28882 | Generate GP-relative addresses for function pointers as well as data | |
28883 | pointers. If you use this option, the entire text, data, and BSS segments | |
28884 | of your program must fit in 64K of memory and you must use an appropriate | |
28885 | linker script to allocate them within the addressable range of the | |
28886 | global pointer. | |
28887 | ||
28888 | @end table | |
28889 | ||
28890 | @option{-mgpopt} is equivalent to @option{-mgpopt=local}, and | |
28891 | @option{-mno-gpopt} is equivalent to @option{-mgpopt=none}. | |
28892 | ||
28893 | The default is @option{-mgpopt} except when @option{-fpic} or | |
28894 | @option{-fPIC} is specified to generate position-independent code. | |
28895 | Note that the Nios II ABI does not permit GP-relative accesses from | |
28896 | shared libraries. | |
28897 | ||
28898 | You may need to specify @option{-mno-gpopt} explicitly when building | |
28899 | programs that include large amounts of small data, including large | |
28900 | GOT data sections. In this case, the 16-bit offset for GP-relative | |
28901 | addressing may not be large enough to allow access to the entire | |
28902 | small data section. | |
28903 | ||
d77de738 | 28904 | @opindex mgprel-sec |
ddf6fe37 | 28905 | @item -mgprel-sec=@var{regexp} |
d77de738 ML |
28906 | This option specifies additional section names that can be accessed via |
28907 | GP-relative addressing. It is most useful in conjunction with | |
28908 | @code{section} attributes on variable declarations | |
28909 | (@pxref{Common Variable Attributes}) and a custom linker script. | |
28910 | The @var{regexp} is a POSIX Extended Regular Expression. | |
28911 | ||
28912 | This option does not affect the behavior of the @option{-G} option, and | |
28913 | the specified sections are in addition to the standard @code{.sdata} | |
28914 | and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}. | |
28915 | ||
d77de738 | 28916 | @opindex mr0rel-sec |
ddf6fe37 | 28917 | @item -mr0rel-sec=@var{regexp} |
d77de738 ML |
28918 | This option specifies names of sections that can be accessed via a |
28919 | 16-bit offset from @code{r0}; that is, in the low 32K or high 32K | |
28920 | of the 32-bit address space. It is most useful in conjunction with | |
28921 | @code{section} attributes on variable declarations | |
28922 | (@pxref{Common Variable Attributes}) and a custom linker script. | |
28923 | The @var{regexp} is a POSIX Extended Regular Expression. | |
28924 | ||
28925 | In contrast to the use of GP-relative addressing for small data, | |
28926 | zero-based addressing is never generated by default and there are no | |
28927 | conventional section names used in standard linker scripts for sections | |
28928 | in the low or high areas of memory. | |
28929 | ||
d77de738 ML |
28930 | @opindex mel |
28931 | @opindex meb | |
ddf6fe37 AA |
28932 | @item -mel |
28933 | @itemx -meb | |
d77de738 ML |
28934 | Generate little-endian (default) or big-endian (experimental) code, |
28935 | respectively. | |
28936 | ||
d77de738 | 28937 | @opindex march |
ddf6fe37 | 28938 | @item -march=@var{arch} |
d77de738 ML |
28939 | This specifies the name of the target Nios II architecture. GCC uses this |
28940 | name to determine what kind of instructions it can emit when generating | |
28941 | assembly code. Permissible names are: @samp{r1}, @samp{r2}. | |
28942 | ||
28943 | The preprocessor macro @code{__nios2_arch__} is available to programs, | |
28944 | with value 1 or 2, indicating the targeted ISA level. | |
28945 | ||
d77de738 ML |
28946 | @opindex mno-bypass-cache |
28947 | @opindex mbypass-cache | |
ddf6fe37 AA |
28948 | @item -mbypass-cache |
28949 | @itemx -mno-bypass-cache | |
d77de738 ML |
28950 | Force all load and store instructions to always bypass cache by |
28951 | using I/O variants of the instructions. The default is not to | |
28952 | bypass the cache. | |
28953 | ||
d77de738 ML |
28954 | @opindex mcache-volatile |
28955 | @opindex mno-cache-volatile | |
ddf6fe37 AA |
28956 | @item -mno-cache-volatile |
28957 | @itemx -mcache-volatile | |
d77de738 ML |
28958 | Volatile memory access bypass the cache using the I/O variants of |
28959 | the load and store instructions. The default is not to bypass the cache. | |
28960 | ||
d77de738 ML |
28961 | @opindex mno-fast-sw-div |
28962 | @opindex mfast-sw-div | |
ddf6fe37 AA |
28963 | @item -mno-fast-sw-div |
28964 | @itemx -mfast-sw-div | |
d77de738 ML |
28965 | Do not use table-based fast divide for small numbers. The default |
28966 | is to use the fast divide at @option{-O3} and above. | |
28967 | ||
d77de738 ML |
28968 | @opindex mno-hw-mul |
28969 | @opindex mhw-mul | |
28970 | @opindex mno-hw-mulx | |
28971 | @opindex mhw-mulx | |
28972 | @opindex mno-hw-div | |
28973 | @opindex mhw-div | |
ddf6fe37 AA |
28974 | @item -mno-hw-mul |
28975 | @itemx -mhw-mul | |
28976 | @itemx -mno-hw-mulx | |
28977 | @itemx -mhw-mulx | |
28978 | @itemx -mno-hw-div | |
28979 | @itemx -mhw-div | |
d77de738 ML |
28980 | Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of |
28981 | instructions by the compiler. The default is to emit @code{mul} | |
28982 | and not emit @code{div} and @code{mulx}. | |
28983 | ||
28984 | @item -mbmx | |
28985 | @itemx -mno-bmx | |
28986 | @itemx -mcdx | |
28987 | @itemx -mno-cdx | |
28988 | Enable or disable generation of Nios II R2 BMX (bit manipulation) and | |
28989 | CDX (code density) instructions. Enabling these instructions also | |
28990 | requires @option{-march=r2}. Since these instructions are optional | |
28991 | extensions to the R2 architecture, the default is not to emit them. | |
28992 | ||
d77de738 ML |
28993 | @opindex mcustom-@var{insn} |
28994 | @opindex mno-custom-@var{insn} | |
ddf6fe37 AA |
28995 | @item -mcustom-@var{insn}=@var{N} |
28996 | @itemx -mno-custom-@var{insn} | |
d77de738 ML |
28997 | Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a |
28998 | custom instruction with encoding @var{N} when generating code that uses | |
28999 | @var{insn}. For example, @option{-mcustom-fadds=253} generates custom | |
29000 | instruction 253 for single-precision floating-point add operations instead | |
29001 | of the default behavior of using a library call. | |
29002 | ||
29003 | The following values of @var{insn} are supported. Except as otherwise | |
29004 | noted, floating-point operations are expected to be implemented with | |
29005 | normal IEEE 754 semantics and correspond directly to the C operators or the | |
29006 | equivalent GCC built-in functions (@pxref{Other Builtins}). | |
29007 | ||
29008 | Single-precision floating point: | |
29009 | @table @asis | |
29010 | ||
29011 | @item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls} | |
29012 | Binary arithmetic operations. | |
29013 | ||
29014 | @item @samp{fnegs} | |
29015 | Unary negation. | |
29016 | ||
29017 | @item @samp{fabss} | |
29018 | Unary absolute value. | |
29019 | ||
29020 | @item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes} | |
29021 | Comparison operations. | |
29022 | ||
29023 | @item @samp{fmins}, @samp{fmaxs} | |
29024 | Floating-point minimum and maximum. These instructions are only | |
29025 | generated if @option{-ffinite-math-only} is specified. | |
29026 | ||
29027 | @item @samp{fsqrts} | |
29028 | Unary square root operation. | |
29029 | ||
29030 | @item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs} | |
29031 | Floating-point trigonometric and exponential functions. These instructions | |
29032 | are only generated if @option{-funsafe-math-optimizations} is also specified. | |
29033 | ||
29034 | @end table | |
29035 | ||
29036 | Double-precision floating point: | |
29037 | @table @asis | |
29038 | ||
29039 | @item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld} | |
29040 | Binary arithmetic operations. | |
29041 | ||
29042 | @item @samp{fnegd} | |
29043 | Unary negation. | |
29044 | ||
29045 | @item @samp{fabsd} | |
29046 | Unary absolute value. | |
29047 | ||
29048 | @item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned} | |
29049 | Comparison operations. | |
29050 | ||
29051 | @item @samp{fmind}, @samp{fmaxd} | |
29052 | Double-precision minimum and maximum. These instructions are only | |
29053 | generated if @option{-ffinite-math-only} is specified. | |
29054 | ||
29055 | @item @samp{fsqrtd} | |
29056 | Unary square root operation. | |
29057 | ||
29058 | @item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd} | |
29059 | Double-precision trigonometric and exponential functions. These instructions | |
29060 | are only generated if @option{-funsafe-math-optimizations} is also specified. | |
29061 | ||
29062 | @end table | |
29063 | ||
29064 | Conversions: | |
29065 | @table @asis | |
29066 | @item @samp{fextsd} | |
29067 | Conversion from single precision to double precision. | |
29068 | ||
29069 | @item @samp{ftruncds} | |
29070 | Conversion from double precision to single precision. | |
29071 | ||
29072 | @item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu} | |
29073 | Conversion from floating point to signed or unsigned integer types, with | |
29074 | truncation towards zero. | |
29075 | ||
29076 | @item @samp{round} | |
29077 | Conversion from single-precision floating point to signed integer, | |
29078 | rounding to the nearest integer and ties away from zero. | |
29079 | This corresponds to the @code{__builtin_lroundf} function when | |
29080 | @option{-fno-math-errno} is used. | |
29081 | ||
29082 | @item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud} | |
29083 | Conversion from signed or unsigned integer types to floating-point types. | |
29084 | ||
29085 | @end table | |
29086 | ||
29087 | In addition, all of the following transfer instructions for internal | |
29088 | registers X and Y must be provided to use any of the double-precision | |
29089 | floating-point instructions. Custom instructions taking two | |
29090 | double-precision source operands expect the first operand in the | |
29091 | 64-bit register X. The other operand (or only operand of a unary | |
29092 | operation) is given to the custom arithmetic instruction with the | |
29093 | least significant half in source register @var{src1} and the most | |
29094 | significant half in @var{src2}. A custom instruction that returns a | |
29095 | double-precision result returns the most significant 32 bits in the | |
29096 | destination register and the other half in 32-bit register Y. | |
29097 | GCC automatically generates the necessary code sequences to write | |
29098 | register X and/or read register Y when double-precision floating-point | |
29099 | instructions are used. | |
29100 | ||
29101 | @table @asis | |
29102 | ||
29103 | @item @samp{fwrx} | |
29104 | Write @var{src1} into the least significant half of X and @var{src2} into | |
29105 | the most significant half of X. | |
29106 | ||
29107 | @item @samp{fwry} | |
29108 | Write @var{src1} into Y. | |
29109 | ||
29110 | @item @samp{frdxhi}, @samp{frdxlo} | |
29111 | Read the most or least (respectively) significant half of X and store it in | |
29112 | @var{dest}. | |
29113 | ||
29114 | @item @samp{frdy} | |
29115 | Read the value of Y and store it into @var{dest}. | |
29116 | @end table | |
29117 | ||
29118 | Note that you can gain more local control over generation of Nios II custom | |
29119 | instructions by using the @code{target("custom-@var{insn}=@var{N}")} | |
29120 | and @code{target("no-custom-@var{insn}")} function attributes | |
29121 | (@pxref{Function Attributes}) | |
29122 | or pragmas (@pxref{Function Specific Option Pragmas}). | |
29123 | ||
d77de738 | 29124 | @opindex mcustom-fpu-cfg |
ddf6fe37 | 29125 | @item -mcustom-fpu-cfg=@var{name} |
d77de738 ML |
29126 | |
29127 | This option enables a predefined, named set of custom instruction encodings | |
29128 | (see @option{-mcustom-@var{insn}} above). | |
29129 | Currently, the following sets are defined: | |
29130 | ||
29131 | @option{-mcustom-fpu-cfg=60-1} is equivalent to: | |
43b72ede AA |
29132 | @gccoptlist{-mcustom-fmuls=252 |
29133 | -mcustom-fadds=253 | |
29134 | -mcustom-fsubs=254 | |
d77de738 ML |
29135 | -fsingle-precision-constant} |
29136 | ||
29137 | @option{-mcustom-fpu-cfg=60-2} is equivalent to: | |
43b72ede AA |
29138 | @gccoptlist{-mcustom-fmuls=252 |
29139 | -mcustom-fadds=253 | |
29140 | -mcustom-fsubs=254 | |
29141 | -mcustom-fdivs=255 | |
d77de738 ML |
29142 | -fsingle-precision-constant} |
29143 | ||
29144 | @option{-mcustom-fpu-cfg=72-3} is equivalent to: | |
43b72ede AA |
29145 | @gccoptlist{-mcustom-floatus=243 |
29146 | -mcustom-fixsi=244 | |
29147 | -mcustom-floatis=245 | |
29148 | -mcustom-fcmpgts=246 | |
29149 | -mcustom-fcmples=249 | |
29150 | -mcustom-fcmpeqs=250 | |
29151 | -mcustom-fcmpnes=251 | |
29152 | -mcustom-fmuls=252 | |
29153 | -mcustom-fadds=253 | |
29154 | -mcustom-fsubs=254 | |
29155 | -mcustom-fdivs=255 | |
d77de738 ML |
29156 | -fsingle-precision-constant} |
29157 | ||
29158 | @option{-mcustom-fpu-cfg=fph2} is equivalent to: | |
43b72ede AA |
29159 | @gccoptlist{-mcustom-fabss=224 |
29160 | -mcustom-fnegs=225 | |
29161 | -mcustom-fcmpnes=226 | |
29162 | -mcustom-fcmpeqs=227 | |
29163 | -mcustom-fcmpges=228 | |
29164 | -mcustom-fcmpgts=229 | |
29165 | -mcustom-fcmples=230 | |
29166 | -mcustom-fcmplts=231 | |
29167 | -mcustom-fmaxs=232 | |
29168 | -mcustom-fmins=233 | |
29169 | -mcustom-round=248 | |
29170 | -mcustom-fixsi=249 | |
29171 | -mcustom-floatis=250 | |
29172 | -mcustom-fsqrts=251 | |
29173 | -mcustom-fmuls=252 | |
29174 | -mcustom-fadds=253 | |
29175 | -mcustom-fsubs=254 | |
29176 | -mcustom-fdivs=255} | |
d77de738 ML |
29177 | |
29178 | Custom instruction assignments given by individual | |
29179 | @option{-mcustom-@var{insn}=} options override those given by | |
29180 | @option{-mcustom-fpu-cfg=}, regardless of the | |
29181 | order of the options on the command line. | |
29182 | ||
29183 | Note that you can gain more local control over selection of a FPU | |
29184 | configuration by using the @code{target("custom-fpu-cfg=@var{name}")} | |
29185 | function attribute (@pxref{Function Attributes}) | |
29186 | or pragma (@pxref{Function Specific Option Pragmas}). | |
29187 | ||
29188 | The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point | |
29189 | Hardware 2 Component}. Please note that the custom instructions enabled by | |
29190 | @option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated | |
29191 | if @option{-ffinite-math-only} is specified. The custom instruction enabled by | |
29192 | @option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is | |
29193 | specified. In contrast to the other configurations, | |
29194 | @option{-fsingle-precision-constant} is not set. | |
29195 | ||
29196 | @end table | |
29197 | ||
29198 | These additional @samp{-m} options are available for the Altera Nios II | |
29199 | ELF (bare-metal) target: | |
29200 | ||
29201 | @table @gcctabopt | |
29202 | ||
d77de738 | 29203 | @opindex mhal |
ddf6fe37 | 29204 | @item -mhal |
d77de738 ML |
29205 | Link with HAL BSP. This suppresses linking with the GCC-provided C runtime |
29206 | startup and termination code, and is typically used in conjunction with | |
29207 | @option{-msys-crt0=} to specify the location of the alternate startup code | |
29208 | provided by the HAL BSP. | |
29209 | ||
d77de738 | 29210 | @opindex msmallc |
ddf6fe37 | 29211 | @item -msmallc |
d77de738 ML |
29212 | Link with a limited version of the C library, @option{-lsmallc}, rather than |
29213 | Newlib. | |
29214 | ||
d77de738 | 29215 | @opindex msys-crt0 |
ddf6fe37 | 29216 | @item -msys-crt0=@var{startfile} |
d77de738 ML |
29217 | @var{startfile} is the file name of the startfile (crt0) to use |
29218 | when linking. This option is only useful in conjunction with @option{-mhal}. | |
29219 | ||
d77de738 | 29220 | @opindex msys-lib |
ddf6fe37 | 29221 | @item -msys-lib=@var{systemlib} |
d77de738 ML |
29222 | @var{systemlib} is the library name of the library that provides |
29223 | low-level system calls required by the C library, | |
29224 | e.g.@: @code{read} and @code{write}. | |
29225 | This option is typically used to link with a library provided by a HAL BSP. | |
29226 | ||
29227 | @end table | |
29228 | ||
29229 | @node Nvidia PTX Options | |
29230 | @subsection Nvidia PTX Options | |
29231 | @cindex Nvidia PTX options | |
29232 | @cindex nvptx options | |
29233 | ||
29234 | These options are defined for Nvidia PTX: | |
29235 | ||
29236 | @table @gcctabopt | |
29237 | ||
d77de738 | 29238 | @opindex m64 |
ddf6fe37 | 29239 | @item -m64 |
d77de738 ML |
29240 | Ignored, but preserved for backward compatibility. Only 64-bit ABI is |
29241 | supported. | |
29242 | ||
d77de738 | 29243 | @opindex march |
ddf6fe37 | 29244 | @item -march=@var{architecture-string} |
d77de738 ML |
29245 | Generate code for the specified PTX ISA target architecture |
29246 | (e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30}, | |
29247 | @samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and | |
29248 | @samp{sm_80}. | |
29249 | The default depends on how the compiler has been configured, see | |
29250 | @option{--with-arch}. | |
29251 | ||
29252 | This option sets the value of the preprocessor macro | |
29253 | @code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value | |
29254 | @samp{350}. | |
29255 | ||
d77de738 | 29256 | @opindex misa |
ddf6fe37 | 29257 | @item -misa=@var{architecture-string} |
d77de738 ML |
29258 | Alias of @option{-march=}. |
29259 | ||
d77de738 | 29260 | @opindex march |
ddf6fe37 | 29261 | @item -march-map=@var{architecture-string} |
d77de738 ML |
29262 | Select the closest available @option{-march=} value that is not more |
29263 | capable. For instance, for @option{-march-map=sm_50} select | |
29264 | @option{-march=sm_35}, and for @option{-march-map=sm_53} select | |
29265 | @option{-march=sm_53}. | |
29266 | ||
d77de738 | 29267 | @opindex mptx |
ddf6fe37 | 29268 | @item -mptx=@var{version-string} |
d77de738 ML |
29269 | Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}). |
29270 | Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and | |
29271 | @samp{7.0}. The default PTX ISA version is 6.0, unless a higher | |
29272 | version is required for specified PTX ISA target architecture via | |
29273 | option @option{-march=}. | |
29274 | ||
29275 | This option sets the values of the preprocessor macros | |
29276 | @code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__}; | |
29277 | for instance, for @samp{3.1} the macros have the values @samp{3} and | |
29278 | @samp{1}, respectively. | |
29279 | ||
d77de738 | 29280 | @opindex mmainkernel |
ddf6fe37 | 29281 | @item -mmainkernel |
d77de738 ML |
29282 | Link in code for a __main kernel. This is for stand-alone instead of |
29283 | offloading execution. | |
29284 | ||
d77de738 | 29285 | @opindex moptimize |
ddf6fe37 | 29286 | @item -moptimize |
d77de738 ML |
29287 | Apply partitioned execution optimizations. This is the default when any |
29288 | level of optimization is selected. | |
29289 | ||
d77de738 | 29290 | @opindex msoft-stack |
ddf6fe37 | 29291 | @item -msoft-stack |
d77de738 ML |
29292 | Generate code that does not use @code{.local} memory |
29293 | directly for stack storage. Instead, a per-warp stack pointer is | |
29294 | maintained explicitly. This enables variable-length stack allocation (with | |
29295 | variable-length arrays or @code{alloca}), and when global memory is used for | |
29296 | underlying storage, makes it possible to access automatic variables from other | |
29297 | threads, or with atomic instructions. This code generation variant is used | |
29298 | for OpenMP offloading, but the option is exposed on its own for the purpose | |
29299 | of testing the compiler; to generate code suitable for linking into programs | |
29300 | using OpenMP offloading, use option @option{-mgomp}. | |
29301 | ||
d77de738 | 29302 | @opindex muniform-simt |
ddf6fe37 | 29303 | @item -muniform-simt |
d77de738 ML |
29304 | Switch to code generation variant that allows to execute all threads in each |
29305 | warp, while maintaining memory state and side effects as if only one thread | |
29306 | in each warp was active outside of OpenMP SIMD regions. All atomic operations | |
29307 | and calls to runtime (malloc, free, vprintf) are conditionally executed (iff | |
29308 | current lane index equals the master lane index), and the register being | |
29309 | assigned is copied via a shuffle instruction from the master lane. Outside of | |
29310 | SIMD regions lane 0 is the master; inside, each thread sees itself as the | |
29311 | master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or | |
29312 | all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD | |
29313 | regions). Each thread can bitwise-and the bitmask at position @code{tid.y} | |
29314 | with current lane index to compute the master lane index. | |
29315 | ||
d77de738 | 29316 | @opindex mgomp |
ddf6fe37 | 29317 | @item -mgomp |
d77de738 ML |
29318 | Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and |
29319 | @option{-muniform-simt} options, and selects corresponding multilib variant. | |
29320 | ||
29321 | @end table | |
29322 | ||
29323 | @node OpenRISC Options | |
29324 | @subsection OpenRISC Options | |
29325 | @cindex OpenRISC Options | |
29326 | ||
29327 | These options are defined for OpenRISC: | |
29328 | ||
29329 | @table @gcctabopt | |
29330 | ||
d77de738 | 29331 | @opindex mboard |
ddf6fe37 | 29332 | @item -mboard=@var{name} |
d77de738 ML |
29333 | Configure a board specific runtime. This will be passed to the linker for |
29334 | newlib board library linking. The default is @code{or1ksim}. | |
29335 | ||
d77de738 | 29336 | @opindex mnewlib |
ddf6fe37 | 29337 | @item -mnewlib |
d77de738 ML |
29338 | This option is ignored; it is for compatibility purposes only. This used to |
29339 | select linker and preprocessor options for use with newlib. | |
29340 | ||
d77de738 ML |
29341 | @opindex msoft-div |
29342 | @opindex mhard-div | |
ddf6fe37 AA |
29343 | @item -msoft-div |
29344 | @itemx -mhard-div | |
d77de738 ML |
29345 | Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions. |
29346 | This default is hardware divide. | |
29347 | ||
d77de738 ML |
29348 | @opindex msoft-mul |
29349 | @opindex mhard-mul | |
ddf6fe37 AA |
29350 | @item -msoft-mul |
29351 | @itemx -mhard-mul | |
d77de738 ML |
29352 | Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions. |
29353 | This default is hardware multiply. | |
29354 | ||
d77de738 ML |
29355 | @opindex msoft-float |
29356 | @opindex mhard-float | |
ddf6fe37 AA |
29357 | @item -msoft-float |
29358 | @itemx -mhard-float | |
d77de738 ML |
29359 | Select software or hardware for floating point operations. |
29360 | The default is software. | |
29361 | ||
d77de738 | 29362 | @opindex mdouble-float |
ddf6fe37 | 29363 | @item -mdouble-float |
d77de738 ML |
29364 | When @option{-mhard-float} is selected, enables generation of double-precision |
29365 | floating point instructions. By default functions from @file{libgcc} are used | |
29366 | to perform double-precision floating point operations. | |
29367 | ||
d77de738 | 29368 | @opindex munordered-float |
ddf6fe37 | 29369 | @item -munordered-float |
d77de738 ML |
29370 | When @option{-mhard-float} is selected, enables generation of unordered |
29371 | floating point compare and set flag (@code{lf.sfun*}) instructions. By default | |
29372 | functions from @file{libgcc} are used to perform unordered floating point | |
29373 | compare and set flag operations. | |
29374 | ||
d77de738 | 29375 | @opindex mcmov |
ddf6fe37 | 29376 | @item -mcmov |
d77de738 ML |
29377 | Enable generation of conditional move (@code{l.cmov}) instructions. By |
29378 | default the equivalent will be generated using set and branch. | |
29379 | ||
d77de738 | 29380 | @opindex mror |
ddf6fe37 | 29381 | @item -mror |
d77de738 ML |
29382 | Enable generation of rotate right (@code{l.ror}) instructions. By default |
29383 | functions from @file{libgcc} are used to perform rotate right operations. | |
29384 | ||
d77de738 | 29385 | @opindex mrori |
ddf6fe37 | 29386 | @item -mrori |
d77de738 ML |
29387 | Enable generation of rotate right with immediate (@code{l.rori}) instructions. |
29388 | By default functions from @file{libgcc} are used to perform rotate right with | |
29389 | immediate operations. | |
29390 | ||
d77de738 | 29391 | @opindex msext |
ddf6fe37 | 29392 | @item -msext |
d77de738 ML |
29393 | Enable generation of sign extension (@code{l.ext*}) instructions. By default |
29394 | memory loads are used to perform sign extension. | |
29395 | ||
d77de738 | 29396 | @opindex msfimm |
ddf6fe37 | 29397 | @item -msfimm |
d77de738 ML |
29398 | Enable generation of compare and set flag with immediate (@code{l.sf*i}) |
29399 | instructions. By default extra instructions will be generated to store the | |
29400 | immediate to a register first. | |
29401 | ||
d77de738 | 29402 | @opindex mshftimm |
ddf6fe37 | 29403 | @item -mshftimm |
d77de738 ML |
29404 | Enable generation of shift with immediate (@code{l.srai}, @code{l.srli}, |
29405 | @code{l.slli}) instructions. By default extra instructions will be generated | |
29406 | to store the immediate to a register first. | |
29407 | ||
d77de738 | 29408 | @opindex mcmodel=small |
ddf6fe37 | 29409 | @item -mcmodel=small |
d77de738 ML |
29410 | Generate OpenRISC code for the small model: The GOT is limited to 64k. This is |
29411 | the default model. | |
29412 | ||
d77de738 | 29413 | @opindex mcmodel=large |
ddf6fe37 | 29414 | @item -mcmodel=large |
d77de738 ML |
29415 | Generate OpenRISC code for the large model: The GOT may grow up to 4G in size. |
29416 | ||
29417 | ||
29418 | @end table | |
29419 | ||
29420 | @node PDP-11 Options | |
29421 | @subsection PDP-11 Options | |
29422 | @cindex PDP-11 Options | |
29423 | ||
29424 | These options are defined for the PDP-11: | |
29425 | ||
29426 | @table @gcctabopt | |
d77de738 | 29427 | @opindex mfpu |
ddf6fe37 | 29428 | @item -mfpu |
d77de738 ML |
29429 | Use hardware FPP floating point. This is the default. (FIS floating |
29430 | point on the PDP-11/40 is not supported.) Implies -m45. | |
29431 | ||
d77de738 | 29432 | @opindex msoft-float |
ddf6fe37 | 29433 | @item -msoft-float |
d77de738 ML |
29434 | Do not use hardware floating point. |
29435 | ||
d77de738 | 29436 | @opindex mac0 |
ddf6fe37 | 29437 | @item -mac0 |
d77de738 ML |
29438 | Return floating-point results in ac0 (fr0 in Unix assembler syntax). |
29439 | ||
d77de738 | 29440 | @opindex mno-ac0 |
ddf6fe37 | 29441 | @item -mno-ac0 |
d77de738 ML |
29442 | Return floating-point results in memory. This is the default. |
29443 | ||
d77de738 | 29444 | @opindex m40 |
ddf6fe37 | 29445 | @item -m40 |
d77de738 ML |
29446 | Generate code for a PDP-11/40. Implies -msoft-float -mno-split. |
29447 | ||
d77de738 | 29448 | @opindex m45 |
ddf6fe37 | 29449 | @item -m45 |
d77de738 ML |
29450 | Generate code for a PDP-11/45. This is the default. |
29451 | ||
d77de738 | 29452 | @opindex m10 |
ddf6fe37 | 29453 | @item -m10 |
d77de738 ML |
29454 | Generate code for a PDP-11/10. Implies -msoft-float -mno-split. |
29455 | ||
d77de738 ML |
29456 | @opindex mint16 |
29457 | @opindex mno-int32 | |
ddf6fe37 AA |
29458 | @item -mint16 |
29459 | @itemx -mno-int32 | |
d77de738 ML |
29460 | Use 16-bit @code{int}. This is the default. |
29461 | ||
d77de738 ML |
29462 | @opindex mint32 |
29463 | @opindex mno-int16 | |
ddf6fe37 AA |
29464 | @item -mint32 |
29465 | @itemx -mno-int16 | |
d77de738 ML |
29466 | Use 32-bit @code{int}. |
29467 | ||
d77de738 | 29468 | @opindex msplit |
ddf6fe37 | 29469 | @item -msplit |
d77de738 ML |
29470 | Target has split instruction and data space. Implies -m45. |
29471 | ||
d77de738 | 29472 | @opindex munix-asm |
ddf6fe37 | 29473 | @item -munix-asm |
d77de738 ML |
29474 | Use Unix assembler syntax. |
29475 | ||
d77de738 | 29476 | @opindex mdec-asm |
ddf6fe37 | 29477 | @item -mdec-asm |
d77de738 ML |
29478 | Use DEC assembler syntax. |
29479 | ||
d77de738 | 29480 | @opindex mgnu-asm |
ddf6fe37 | 29481 | @item -mgnu-asm |
d77de738 ML |
29482 | Use GNU assembler syntax. This is the default. |
29483 | ||
d77de738 | 29484 | @opindex mlra |
ddf6fe37 | 29485 | @item -mlra |
d77de738 ML |
29486 | Use the new LRA register allocator. By default, the old ``reload'' |
29487 | allocator is used. | |
29488 | @end table | |
29489 | ||
d77de738 ML |
29490 | @node PowerPC Options |
29491 | @subsection PowerPC Options | |
29492 | @cindex PowerPC options | |
29493 | ||
29494 | These are listed under @xref{RS/6000 and PowerPC Options}. | |
29495 | ||
29496 | @node PRU Options | |
29497 | @subsection PRU Options | |
29498 | @cindex PRU Options | |
29499 | ||
29500 | These command-line options are defined for PRU target: | |
29501 | ||
29502 | @table @gcctabopt | |
d77de738 | 29503 | @opindex minrt |
ddf6fe37 | 29504 | @item -minrt |
d77de738 ML |
29505 | Link with a minimum runtime environment, with no support for static |
29506 | initializers and constructors. Using this option can significantly reduce | |
29507 | the size of the final ELF binary. Beware that the compiler could still | |
29508 | generate code with static initializers and constructors. It is up to the | |
29509 | programmer to ensure that the source program will not use those features. | |
29510 | ||
d77de738 | 29511 | @opindex mmcu |
ddf6fe37 | 29512 | @item -mmcu=@var{mcu} |
d77de738 ML |
29513 | Specify the PRU MCU variant to use. Check Newlib for the exact list of |
29514 | supported MCUs. | |
29515 | ||
d77de738 | 29516 | @opindex mno-relax |
ddf6fe37 | 29517 | @item -mno-relax |
d77de738 ML |
29518 | Make GCC pass the @option{--no-relax} command-line option to the linker |
29519 | instead of the @option{--relax} option. | |
29520 | ||
d77de738 | 29521 | @opindex mloop |
ddf6fe37 | 29522 | @item -mloop |
d77de738 ML |
29523 | Allow (or do not allow) GCC to use the LOOP instruction. |
29524 | ||
d77de738 | 29525 | @opindex mabi |
ddf6fe37 | 29526 | @item -mabi=@var{variant} |
d77de738 ML |
29527 | Specify the ABI variant to output code for. @option{-mabi=ti} selects the |
29528 | unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes | |
29529 | more naturally with certain GCC assumptions. These are the differences: | |
29530 | ||
29531 | @table @samp | |
29532 | @item Function Pointer Size | |
29533 | TI ABI specifies that function (code) pointers are 16-bit, whereas GNU | |
29534 | supports only 32-bit data and code pointers. | |
29535 | ||
29536 | @item Optional Return Value Pointer | |
29537 | Function return values larger than 64 bits are passed by using a hidden | |
29538 | pointer as the first argument of the function. TI ABI, though, mandates that | |
29539 | the pointer can be NULL in case the caller is not using the returned value. | |
29540 | GNU always passes and expects a valid return value pointer. | |
29541 | ||
29542 | @end table | |
29543 | ||
29544 | The current @option{-mabi=ti} implementation simply raises a compile error | |
29545 | when any of the above code constructs is detected. As a consequence | |
29546 | the standard C library cannot be built and it is omitted when linking with | |
29547 | @option{-mabi=ti}. | |
29548 | ||
29549 | Relaxation is a GNU feature and for safety reasons is disabled when using | |
29550 | @option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx | |
29551 | instructions, so the GNU linker cannot adjust them when shortening adjacent | |
29552 | LDI32 pseudo instructions. | |
29553 | ||
29554 | @end table | |
29555 | ||
29556 | @node RISC-V Options | |
29557 | @subsection RISC-V Options | |
29558 | @cindex RISC-V Options | |
29559 | ||
29560 | These command-line options are defined for RISC-V targets: | |
29561 | ||
29562 | @table @gcctabopt | |
d77de738 | 29563 | @opindex mbranch-cost |
ddf6fe37 | 29564 | @item -mbranch-cost=@var{n} |
d77de738 ML |
29565 | Set the cost of branches to roughly @var{n} instructions. |
29566 | ||
ddf6fe37 | 29567 | @opindex plt |
d77de738 ML |
29568 | @item -mplt |
29569 | @itemx -mno-plt | |
d77de738 ML |
29570 | When generating PIC code, do or don't allow the use of PLTs. Ignored for |
29571 | non-PIC. The default is @option{-mplt}. | |
29572 | ||
d77de738 | 29573 | @opindex mabi |
ddf6fe37 | 29574 | @item -mabi=@var{ABI-string} |
d77de738 ML |
29575 | Specify integer and floating-point calling convention. @var{ABI-string} |
29576 | contains two parts: the size of integer types and the registers used for | |
29577 | floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that | |
29578 | @samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be | |
29579 | 32-bit), and that floating-point values up to 64 bits wide are passed in F | |
29580 | registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still | |
29581 | allows the compiler to generate code that uses the F and D extensions but only | |
29582 | allows floating-point values up to 32 bits long to be passed in registers; or | |
29583 | @samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be | |
29584 | passed in registers. | |
29585 | ||
29586 | The default for this argument is system dependent, users who want a specific | |
29587 | calling convention should specify one explicitly. The valid calling | |
29588 | conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64}, | |
29589 | @samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to | |
29590 | implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is | |
29591 | invalid because the ABI requires 64-bit values be passed in F registers, but F | |
29592 | registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can | |
29593 | only be used with the @samp{rv32e} architecture. This ABI is not well | |
29594 | specified at present, and is subject to change. | |
29595 | ||
ddf6fe37 | 29596 | @opindex mfdiv |
d77de738 ML |
29597 | @item -mfdiv |
29598 | @itemx -mno-fdiv | |
d77de738 ML |
29599 | Do or don't use hardware floating-point divide and square root instructions. |
29600 | This requires the F or D extensions for floating-point registers. The default | |
29601 | is to use them if the specified architecture has these instructions. | |
29602 | ||
ddf6fe37 | 29603 | @opindex mdiv |
d77de738 ML |
29604 | @item -mdiv |
29605 | @itemx -mno-div | |
d77de738 ML |
29606 | Do or don't use hardware instructions for integer division. This requires the |
29607 | M extension. The default is to use them if the specified architecture has | |
29608 | these instructions. | |
29609 | ||
d77de738 | 29610 | @opindex misa-spec |
ddf6fe37 | 29611 | @item -misa-spec=@var{ISA-spec-string} |
d77de738 ML |
29612 | Specify the version of the RISC-V Unprivileged (formerly User-Level) |
29613 | ISA specification to produce code conforming to. The possibilities | |
29614 | for @var{ISA-spec-string} are: | |
29615 | @table @code | |
29616 | @item 2.2 | |
29617 | Produce code conforming to version 2.2. | |
29618 | @item 20190608 | |
29619 | Produce code conforming to version 20190608. | |
29620 | @item 20191213 | |
29621 | Produce code conforming to version 20191213. | |
29622 | @end table | |
29623 | The default is @option{-misa-spec=20191213} unless GCC has been configured | |
29624 | with @option{--with-isa-spec=} specifying a different default version. | |
29625 | ||
d77de738 | 29626 | @opindex march |
ddf6fe37 | 29627 | @item -march=@var{ISA-string} |
d77de738 ML |
29628 | Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be |
29629 | lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and | |
29630 | @samp{rv32imaf}. | |
29631 | ||
29632 | When @option{-march=} is not specified, use the setting from @option{-mcpu}. | |
29633 | ||
29634 | If both @option{-march} and @option{-mcpu=} are not specified, the default for | |
29635 | this argument is system dependent, users who want a specific architecture | |
29636 | extensions should specify one explicitly. | |
29637 | ||
d77de738 | 29638 | @opindex mcpu |
ddf6fe37 | 29639 | @item -mcpu=@var{processor-string} |
d77de738 ML |
29640 | Use architecture of and optimize the output for the given processor, specified |
29641 | by particular CPU name. | |
29642 | Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21}, | |
29643 | @samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76}, | |
29644 | @samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76}, | |
aa37a91c | 29645 | @samp{sifive-u54}, and @samp{sifive-u74}. |
d77de738 | 29646 | |
d77de738 | 29647 | @opindex mtune |
ddf6fe37 | 29648 | @item -mtune=@var{processor-string} |
d77de738 ML |
29649 | Optimize the output for the given processor, specified by microarchitecture or |
29650 | particular CPU name. Permissible values for this option are: @samp{rocket}, | |
29651 | @samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series}, | |
aa37a91c | 29652 | @samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}. |
d77de738 ML |
29653 | |
29654 | When @option{-mtune=} is not specified, use the setting from @option{-mcpu}, | |
29655 | the default is @samp{rocket} if both are not specified. | |
29656 | ||
29657 | The @samp{size} choice is not intended for use by end-users. This is used | |
29658 | when @option{-Os} is specified. It overrides the instruction cost info | |
29659 | provided by @option{-mtune=}, but does not override the pipeline info. This | |
29660 | helps reduce code size while still giving good performance. | |
29661 | ||
d77de738 | 29662 | @opindex mpreferred-stack-boundary |
ddf6fe37 | 29663 | @item -mpreferred-stack-boundary=@var{num} |
d77de738 ML |
29664 | Attempt to keep the stack boundary aligned to a 2 raised to @var{num} |
29665 | byte boundary. If @option{-mpreferred-stack-boundary} is not specified, | |
29666 | the default is 4 (16 bytes or 128-bits). | |
29667 | ||
29668 | @strong{Warning:} If you use this switch, then you must build all modules with | |
29669 | the same value, including any libraries. This includes the system libraries | |
29670 | and startup modules. | |
29671 | ||
d77de738 | 29672 | @opindex msmall-data-limit |
ddf6fe37 | 29673 | @item -msmall-data-limit=@var{n} |
d77de738 ML |
29674 | Put global and static data smaller than @var{n} bytes into a special section |
29675 | (on some targets). | |
29676 | ||
ddf6fe37 | 29677 | @opindex msave-restore |
d77de738 ML |
29678 | @item -msave-restore |
29679 | @itemx -mno-save-restore | |
d77de738 ML |
29680 | Do or don't use smaller but slower prologue and epilogue code that uses |
29681 | library function calls. The default is to use fast inline prologues and | |
29682 | epilogues. | |
29683 | ||
f797260a PN |
29684 | @opindex minline-atomics |
29685 | @item -minline-atomics | |
29686 | @itemx -mno-inline-atomics | |
29687 | Do or don't use smaller but slower subword atomic emulation code that uses | |
29688 | libatomic function calls. The default is to use fast inline subword atomics | |
29689 | that do not require libatomic. | |
29690 | ||
df48285b CM |
29691 | @opindex minline-strlen |
29692 | @item -minline-strlen | |
29693 | @itemx -mno-inline-strlen | |
29694 | Do or do not attempt to inline strlen calls if possible. | |
29695 | Inlining will only be done if the string is properly aligned | |
29696 | and instructions for accelerated processing are available. | |
29697 | The default is to not inline strlen calls. | |
29698 | ||
949f1ccf CM |
29699 | @opindex minline-strcmp |
29700 | @item -minline-strcmp | |
29701 | @itemx -mno-inline-strcmp | |
29702 | Do or do not attempt to inline strcmp calls if possible. | |
29703 | Inlining will only be done if the strings are properly aligned | |
29704 | and instructions for accelerated processing are available. | |
29705 | The default is to not inline strcmp calls. | |
29706 | ||
29707 | @opindex minline-strncmp | |
29708 | @item -minline-strncmp | |
29709 | @itemx -mno-inline-strncmp | |
29710 | Do or do not attempt to inline strncmp calls if possible. | |
29711 | Inlining will only be done if the strings are properly aligned | |
29712 | and instructions for accelerated processing are available. | |
29713 | The default is to not inline strncmp calls. | |
29714 | ||
ddf6fe37 | 29715 | @opindex mshorten-memrefs |
d77de738 ML |
29716 | @item -mshorten-memrefs |
29717 | @itemx -mno-shorten-memrefs | |
d77de738 ML |
29718 | Do or do not attempt to make more use of compressed load/store instructions by |
29719 | replacing a load/store of 'base register + large offset' with a new load/store | |
29720 | of 'new base + small offset'. If the new base gets stored in a compressed | |
29721 | register, then the new load/store can be compressed. Currently targets 32-bit | |
29722 | integer load/stores only. | |
29723 | ||
ddf6fe37 | 29724 | @opindex mstrict-align |
d77de738 ML |
29725 | @item -mstrict-align |
29726 | @itemx -mno-strict-align | |
d77de738 ML |
29727 | Do not or do generate unaligned memory accesses. The default is set depending |
29728 | on whether the processor we are optimizing for supports fast unaligned access | |
29729 | or not. | |
29730 | ||
d77de738 | 29731 | @opindex mcmodel=medlow |
ddf6fe37 | 29732 | @item -mcmodel=medlow |
d77de738 ML |
29733 | Generate code for the medium-low code model. The program and its statically |
29734 | defined symbols must lie within a single 2 GiB address range and must lie | |
29735 | between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be | |
29736 | statically or dynamically linked. This is the default code model. | |
29737 | ||
d77de738 | 29738 | @opindex mcmodel=medany |
ddf6fe37 | 29739 | @item -mcmodel=medany |
d77de738 ML |
29740 | Generate code for the medium-any code model. The program and its statically |
29741 | defined symbols must be within any single 2 GiB address range. Programs can be | |
29742 | statically or dynamically linked. | |
29743 | ||
29744 | The code generated by the medium-any code model is position-independent, but is | |
29745 | not guaranteed to function correctly when linked into position-independent | |
29746 | executables or libraries. | |
29747 | ||
29748 | @item -mexplicit-relocs | |
29749 | @itemx -mno-exlicit-relocs | |
29750 | Use or do not use assembler relocation operators when dealing with symbolic | |
29751 | addresses. The alternative is to use assembler macros instead, which may | |
29752 | limit optimization. | |
29753 | ||
ddf6fe37 | 29754 | @opindex mrelax |
d77de738 ML |
29755 | @item -mrelax |
29756 | @itemx -mno-relax | |
d77de738 ML |
29757 | Take advantage of linker relaxations to reduce the number of instructions |
29758 | required to materialize symbol addresses. The default is to take advantage of | |
29759 | linker relaxations. | |
29760 | ||
ddf6fe37 | 29761 | @opindex mriscv-attribute |
d77de738 ML |
29762 | @item -mriscv-attribute |
29763 | @itemx -mno-riscv-attribute | |
d77de738 ML |
29764 | Emit (do not emit) RISC-V attribute to record extra information into ELF |
29765 | objects. This feature requires at least binutils 2.32. | |
29766 | ||
ddf6fe37 | 29767 | @opindex mcsr-check |
d77de738 ML |
29768 | @item -mcsr-check |
29769 | @itemx -mno-csr-check | |
d77de738 ML |
29770 | Enables or disables the CSR checking. |
29771 | ||
d77de738 | 29772 | @opindex malign-data |
ddf6fe37 | 29773 | @item -malign-data=@var{type} |
d77de738 ML |
29774 | Control how GCC aligns variables and constants of array, structure, or union |
29775 | types. Supported values for @var{type} are @samp{xlen} which uses x register | |
29776 | width as the alignment value, and @samp{natural} which uses natural alignment. | |
29777 | @samp{xlen} is the default. | |
29778 | ||
d77de738 | 29779 | @opindex mbig-endian |
ddf6fe37 | 29780 | @item -mbig-endian |
d77de738 ML |
29781 | Generate big-endian code. This is the default when GCC is configured for a |
29782 | @samp{riscv64be-*-*} or @samp{riscv32be-*-*} target. | |
29783 | ||
d77de738 | 29784 | @opindex mlittle-endian |
ddf6fe37 | 29785 | @item -mlittle-endian |
d77de738 ML |
29786 | Generate little-endian code. This is the default when GCC is configured for a |
29787 | @samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or | |
29788 | @samp{riscv32be-*-*} target. | |
29789 | ||
d77de738 ML |
29790 | @opindex mstack-protector-guard |
29791 | @opindex mstack-protector-guard-reg | |
29792 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
29793 | @item -mstack-protector-guard=@var{guard} |
29794 | @itemx -mstack-protector-guard-reg=@var{reg} | |
29795 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
29796 | Generate stack protection code using canary at @var{guard}. Supported |
29797 | locations are @samp{global} for a global canary or @samp{tls} for per-thread | |
29798 | canary in the TLS block. | |
29799 | ||
29800 | With the latter choice the options | |
29801 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
29802 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
29803 | which register to use as base register for reading the canary, | |
29804 | and from what offset from that base register. There is no default | |
29805 | register or offset as this is entirely for use within the Linux | |
29806 | kernel. | |
29807 | @end table | |
29808 | ||
29809 | @node RL78 Options | |
29810 | @subsection RL78 Options | |
29811 | @cindex RL78 Options | |
29812 | ||
29813 | @table @gcctabopt | |
29814 | ||
d77de738 | 29815 | @opindex msim |
ddf6fe37 | 29816 | @item -msim |
d77de738 ML |
29817 | Links in additional target libraries to support operation within a |
29818 | simulator. | |
29819 | ||
ddf6fe37 | 29820 | @opindex mmul |
d77de738 ML |
29821 | @item -mmul=none |
29822 | @itemx -mmul=g10 | |
29823 | @itemx -mmul=g13 | |
29824 | @itemx -mmul=g14 | |
29825 | @itemx -mmul=rl78 | |
d77de738 ML |
29826 | Specifies the type of hardware multiplication and division support to |
29827 | be used. The simplest is @code{none}, which uses software for both | |
29828 | multiplication and division. This is the default. The @code{g13} | |
29829 | value is for the hardware multiply/divide peripheral found on the | |
29830 | RL78/G13 (S2 core) targets. The @code{g14} value selects the use of | |
29831 | the multiplication and division instructions supported by the RL78/G14 | |
29832 | (S3 core) parts. The value @code{rl78} is an alias for @code{g14} and | |
29833 | the value @code{mg10} is an alias for @code{none}. | |
29834 | ||
29835 | In addition a C preprocessor macro is defined, based upon the setting | |
29836 | of this option. Possible values are: @code{__RL78_MUL_NONE__}, | |
29837 | @code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}. | |
29838 | ||
ddf6fe37 | 29839 | @opindex mcpu |
d77de738 ML |
29840 | @item -mcpu=g10 |
29841 | @itemx -mcpu=g13 | |
29842 | @itemx -mcpu=g14 | |
29843 | @itemx -mcpu=rl78 | |
d77de738 ML |
29844 | Specifies the RL78 core to target. The default is the G14 core, also |
29845 | known as an S3 core or just RL78. The G13 or S2 core does not have | |
29846 | multiply or divide instructions, instead it uses a hardware peripheral | |
29847 | for these operations. The G10 or S1 core does not have register | |
29848 | banks, so it uses a different calling convention. | |
29849 | ||
29850 | If this option is set it also selects the type of hardware multiply | |
29851 | support to use, unless this is overridden by an explicit | |
29852 | @option{-mmul=none} option on the command line. Thus specifying | |
29853 | @option{-mcpu=g13} enables the use of the G13 hardware multiply | |
29854 | peripheral and specifying @option{-mcpu=g10} disables the use of | |
29855 | hardware multiplications altogether. | |
29856 | ||
29857 | Note, although the RL78/G14 core is the default target, specifying | |
29858 | @option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does | |
29859 | change the behavior of the toolchain since it also enables G14 | |
29860 | hardware multiply support. If these options are not specified on the | |
29861 | command line then software multiplication routines will be used even | |
29862 | though the code targets the RL78 core. This is for backwards | |
29863 | compatibility with older toolchains which did not have hardware | |
29864 | multiply and divide support. | |
29865 | ||
29866 | In addition a C preprocessor macro is defined, based upon the setting | |
29867 | of this option. Possible values are: @code{__RL78_G10__}, | |
29868 | @code{__RL78_G13__} or @code{__RL78_G14__}. | |
29869 | ||
d77de738 ML |
29870 | @opindex mg10 |
29871 | @opindex mg13 | |
29872 | @opindex mg14 | |
29873 | @opindex mrl78 | |
ddf6fe37 AA |
29874 | @item -mg10 |
29875 | @itemx -mg13 | |
29876 | @itemx -mg14 | |
29877 | @itemx -mrl78 | |
d77de738 ML |
29878 | These are aliases for the corresponding @option{-mcpu=} option. They |
29879 | are provided for backwards compatibility. | |
29880 | ||
d77de738 | 29881 | @opindex mallregs |
ddf6fe37 | 29882 | @item -mallregs |
d77de738 ML |
29883 | Allow the compiler to use all of the available registers. By default |
29884 | registers @code{r24..r31} are reserved for use in interrupt handlers. | |
29885 | With this option enabled these registers can be used in ordinary | |
29886 | functions as well. | |
29887 | ||
d77de738 ML |
29888 | @opindex m64bit-doubles |
29889 | @opindex m32bit-doubles | |
ddf6fe37 AA |
29890 | @item -m64bit-doubles |
29891 | @itemx -m32bit-doubles | |
d77de738 ML |
29892 | Make the @code{double} data type be 64 bits (@option{-m64bit-doubles}) |
29893 | or 32 bits (@option{-m32bit-doubles}) in size. The default is | |
29894 | @option{-m32bit-doubles}. | |
29895 | ||
d77de738 ML |
29896 | @opindex msave-mduc-in-interrupts |
29897 | @opindex mno-save-mduc-in-interrupts | |
ddf6fe37 AA |
29898 | @item -msave-mduc-in-interrupts |
29899 | @itemx -mno-save-mduc-in-interrupts | |
d77de738 ML |
29900 | Specifies that interrupt handler functions should preserve the |
29901 | MDUC registers. This is only necessary if normal code might use | |
29902 | the MDUC registers, for example because it performs multiplication | |
29903 | and division operations. The default is to ignore the MDUC registers | |
29904 | as this makes the interrupt handlers faster. The target option -mg13 | |
29905 | needs to be passed for this to work as this feature is only available | |
29906 | on the G13 target (S2 core). The MDUC registers will only be saved | |
29907 | if the interrupt handler performs a multiplication or division | |
29908 | operation or it calls another function. | |
29909 | ||
29910 | @end table | |
29911 | ||
29912 | @node RS/6000 and PowerPC Options | |
29913 | @subsection IBM RS/6000 and PowerPC Options | |
29914 | @cindex RS/6000 and PowerPC Options | |
29915 | @cindex IBM RS/6000 and PowerPC Options | |
29916 | ||
29917 | These @samp{-m} options are defined for the IBM RS/6000 and PowerPC: | |
29918 | @table @gcctabopt | |
29919 | @item -mpowerpc-gpopt | |
29920 | @itemx -mno-powerpc-gpopt | |
29921 | @itemx -mpowerpc-gfxopt | |
29922 | @itemx -mno-powerpc-gfxopt | |
29923 | @need 800 | |
29924 | @itemx -mpowerpc64 | |
29925 | @itemx -mno-powerpc64 | |
29926 | @itemx -mmfcrf | |
29927 | @itemx -mno-mfcrf | |
29928 | @itemx -mpopcntb | |
29929 | @itemx -mno-popcntb | |
29930 | @itemx -mpopcntd | |
29931 | @itemx -mno-popcntd | |
29932 | @itemx -mfprnd | |
29933 | @itemx -mno-fprnd | |
29934 | @need 800 | |
d77de738 ML |
29935 | @opindex mpowerpc-gpopt |
29936 | @opindex mno-powerpc-gpopt | |
29937 | @opindex mpowerpc-gfxopt | |
29938 | @opindex mno-powerpc-gfxopt | |
29939 | @opindex mpowerpc64 | |
29940 | @opindex mno-powerpc64 | |
29941 | @opindex mmfcrf | |
29942 | @opindex mno-mfcrf | |
29943 | @opindex mpopcntb | |
29944 | @opindex mno-popcntb | |
29945 | @opindex mpopcntd | |
29946 | @opindex mno-popcntd | |
29947 | @opindex mfprnd | |
29948 | @opindex mno-fprnd | |
29949 | @opindex mcmpb | |
29950 | @opindex mno-cmpb | |
29951 | @opindex mhard-dfp | |
29952 | @opindex mno-hard-dfp | |
ddf6fe37 AA |
29953 | @itemx -mcmpb |
29954 | @itemx -mno-cmpb | |
29955 | @itemx -mhard-dfp | |
29956 | @itemx -mno-hard-dfp | |
d77de738 ML |
29957 | You use these options to specify which instructions are available on the |
29958 | processor you are using. The default value of these options is | |
29959 | determined when configuring GCC@. Specifying the | |
29960 | @option{-mcpu=@var{cpu_type}} overrides the specification of these | |
29961 | options. We recommend you use the @option{-mcpu=@var{cpu_type}} option | |
29962 | rather than the options listed above. | |
29963 | ||
29964 | Specifying @option{-mpowerpc-gpopt} allows | |
29965 | GCC to use the optional PowerPC architecture instructions in the | |
29966 | General Purpose group, including floating-point square root. Specifying | |
29967 | @option{-mpowerpc-gfxopt} allows GCC to | |
29968 | use the optional PowerPC architecture instructions in the Graphics | |
29969 | group, including floating-point select. | |
29970 | ||
29971 | The @option{-mmfcrf} option allows GCC to generate the move from | |
29972 | condition register field instruction implemented on the POWER4 | |
29973 | processor and other processors that support the PowerPC V2.01 | |
29974 | architecture. | |
29975 | The @option{-mpopcntb} option allows GCC to generate the popcount and | |
29976 | double-precision FP reciprocal estimate instruction implemented on the | |
29977 | POWER5 processor and other processors that support the PowerPC V2.02 | |
29978 | architecture. | |
29979 | The @option{-mpopcntd} option allows GCC to generate the popcount | |
29980 | instruction implemented on the POWER7 processor and other processors | |
29981 | that support the PowerPC V2.06 architecture. | |
29982 | The @option{-mfprnd} option allows GCC to generate the FP round to | |
29983 | integer instructions implemented on the POWER5+ processor and other | |
29984 | processors that support the PowerPC V2.03 architecture. | |
29985 | The @option{-mcmpb} option allows GCC to generate the compare bytes | |
29986 | instruction implemented on the POWER6 processor and other processors | |
29987 | that support the PowerPC V2.05 architecture. | |
29988 | The @option{-mhard-dfp} option allows GCC to generate the decimal | |
29989 | floating-point instructions implemented on some POWER processors. | |
29990 | ||
29991 | The @option{-mpowerpc64} option allows GCC to generate the additional | |
29992 | 64-bit instructions that are found in the full PowerPC64 architecture | |
29993 | and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to | |
29994 | @option{-mno-powerpc64}. | |
29995 | ||
d77de738 | 29996 | @opindex mcpu |
ddf6fe37 | 29997 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
29998 | Set architecture type, register usage, and |
29999 | instruction scheduling parameters for machine type @var{cpu_type}. | |
30000 | Supported values for @var{cpu_type} are @samp{401}, @samp{403}, | |
30001 | @samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp}, | |
30002 | @samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603}, | |
30003 | @samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740}, | |
30004 | @samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823}, | |
30005 | @samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2}, | |
30006 | @samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500}, | |
30007 | @samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5}, | |
30008 | @samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+}, | |
30009 | @samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8}, | |
30010 | @samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64}, | |
30011 | @samp{powerpc64le}, @samp{rs64}, and @samp{native}. | |
30012 | ||
30013 | @option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and | |
30014 | @option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either | |
30015 | endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC | |
30016 | architecture machine types, with an appropriate, generic processor | |
30017 | model assumed for scheduling purposes. | |
30018 | ||
30019 | Specifying @samp{native} as cpu type detects and selects the | |
30020 | architecture option that corresponds to the host processor of the | |
30021 | system performing the compilation. | |
30022 | @option{-mcpu=native} has no effect if GCC does not recognize the | |
30023 | processor. | |
30024 | ||
30025 | The other options specify a specific processor. Code generated under | |
30026 | those options runs best on that processor, and may not run at all on | |
30027 | others. | |
30028 | ||
30029 | The @option{-mcpu} options automatically enable or disable the | |
30030 | following options: | |
30031 | ||
43b72ede AA |
30032 | @gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple |
30033 | -mpopcntb -mpopcntd -mpowerpc64 | |
30034 | -mpowerpc-gpopt -mpowerpc-gfxopt | |
30035 | -mmulhw -mdlmzb -mmfpgpr -mvsx | |
30036 | -mcrypto -mhtm -mpower8-fusion -mpower8-vector | |
30037 | -mquad-memory -mquad-memory-atomic -mfloat128 | |
30038 | -mfloat128-hardware -mprefixed -mpcrel -mmma | |
d77de738 ML |
30039 | -mrop-protect} |
30040 | ||
30041 | The particular options set for any particular CPU varies between | |
30042 | compiler versions, depending on what setting seems to produce optimal | |
30043 | code for that CPU; it doesn't necessarily reflect the actual hardware's | |
30044 | capabilities. If you wish to set an individual option to a particular | |
30045 | value, you may specify it after the @option{-mcpu} option, like | |
30046 | @option{-mcpu=970 -mno-altivec}. | |
30047 | ||
30048 | On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are | |
30049 | not enabled or disabled by the @option{-mcpu} option at present because | |
30050 | AIX does not have full support for these options. You may still | |
30051 | enable or disable them individually if you're sure it'll work in your | |
30052 | environment. | |
30053 | ||
d77de738 | 30054 | @opindex mtune |
ddf6fe37 | 30055 | @item -mtune=@var{cpu_type} |
d77de738 ML |
30056 | Set the instruction scheduling parameters for machine type |
30057 | @var{cpu_type}, but do not set the architecture type or register usage, | |
30058 | as @option{-mcpu=@var{cpu_type}} does. The same | |
30059 | values for @var{cpu_type} are used for @option{-mtune} as for | |
30060 | @option{-mcpu}. If both are specified, the code generated uses the | |
30061 | architecture and registers set by @option{-mcpu}, but the | |
30062 | scheduling parameters set by @option{-mtune}. | |
30063 | ||
d77de738 | 30064 | @opindex mcmodel=small |
ddf6fe37 | 30065 | @item -mcmodel=small |
d77de738 ML |
30066 | Generate PowerPC64 code for the small model: The TOC is limited to |
30067 | 64k. | |
30068 | ||
d77de738 | 30069 | @opindex mcmodel=medium |
ddf6fe37 | 30070 | @item -mcmodel=medium |
d77de738 ML |
30071 | Generate PowerPC64 code for the medium model: The TOC and other static |
30072 | data may be up to a total of 4G in size. This is the default for 64-bit | |
30073 | Linux. | |
30074 | ||
d77de738 | 30075 | @opindex mcmodel=large |
ddf6fe37 | 30076 | @item -mcmodel=large |
d77de738 ML |
30077 | Generate PowerPC64 code for the large model: The TOC may be up to 4G |
30078 | in size. Other data and code is only limited by the 64-bit address | |
30079 | space. | |
30080 | ||
d77de738 ML |
30081 | @opindex maltivec |
30082 | @opindex mno-altivec | |
ddf6fe37 AA |
30083 | @item -maltivec |
30084 | @itemx -mno-altivec | |
d77de738 ML |
30085 | Generate code that uses (does not use) AltiVec instructions, and also |
30086 | enable the use of built-in functions that allow more direct access to | |
30087 | the AltiVec instruction set. You may also need to set | |
30088 | @option{-mabi=altivec} to adjust the current ABI with AltiVec ABI | |
30089 | enhancements. | |
30090 | ||
30091 | When @option{-maltivec} is used, the element order for AltiVec intrinsics | |
30092 | such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert} | |
30093 | match array element order corresponding to the endianness of the | |
30094 | target. That is, element zero identifies the leftmost element in a | |
30095 | vector register when targeting a big-endian platform, and identifies | |
30096 | the rightmost element in a vector register when targeting a | |
30097 | little-endian platform. | |
30098 | ||
d77de738 ML |
30099 | @opindex mvrsave |
30100 | @opindex mno-vrsave | |
ddf6fe37 AA |
30101 | @item -mvrsave |
30102 | @itemx -mno-vrsave | |
d77de738 ML |
30103 | Generate VRSAVE instructions when generating AltiVec code. |
30104 | ||
d77de738 | 30105 | @opindex msecure-plt |
ddf6fe37 | 30106 | @item -msecure-plt |
d77de738 ML |
30107 | Generate code that allows @command{ld} and @command{ld.so} |
30108 | to build executables and shared | |
30109 | libraries with non-executable @code{.plt} and @code{.got} sections. | |
30110 | This is a PowerPC | |
30111 | 32-bit SYSV ABI option. | |
30112 | ||
d77de738 | 30113 | @opindex mbss-plt |
ddf6fe37 | 30114 | @item -mbss-plt |
d77de738 ML |
30115 | Generate code that uses a BSS @code{.plt} section that @command{ld.so} |
30116 | fills in, and | |
30117 | requires @code{.plt} and @code{.got} | |
30118 | sections that are both writable and executable. | |
30119 | This is a PowerPC 32-bit SYSV ABI option. | |
30120 | ||
d77de738 ML |
30121 | @opindex misel |
30122 | @opindex mno-isel | |
ddf6fe37 AA |
30123 | @item -misel |
30124 | @itemx -mno-isel | |
d77de738 ML |
30125 | This switch enables or disables the generation of ISEL instructions. |
30126 | ||
d77de738 ML |
30127 | @opindex mvsx |
30128 | @opindex mno-vsx | |
ddf6fe37 AA |
30129 | @item -mvsx |
30130 | @itemx -mno-vsx | |
d77de738 ML |
30131 | Generate code that uses (does not use) vector/scalar (VSX) |
30132 | instructions, and also enable the use of built-in functions that allow | |
30133 | more direct access to the VSX instruction set. | |
30134 | ||
d77de738 ML |
30135 | @opindex mcrypto |
30136 | @opindex mno-crypto | |
ddf6fe37 AA |
30137 | @item -mcrypto |
30138 | @itemx -mno-crypto | |
d77de738 ML |
30139 | Enable the use (disable) of the built-in functions that allow direct |
30140 | access to the cryptographic instructions that were added in version | |
30141 | 2.07 of the PowerPC ISA. | |
30142 | ||
d77de738 ML |
30143 | @opindex mhtm |
30144 | @opindex mno-htm | |
ddf6fe37 AA |
30145 | @item -mhtm |
30146 | @itemx -mno-htm | |
d77de738 ML |
30147 | Enable (disable) the use of the built-in functions that allow direct |
30148 | access to the Hardware Transactional Memory (HTM) instructions that | |
30149 | were added in version 2.07 of the PowerPC ISA. | |
30150 | ||
d77de738 ML |
30151 | @opindex mpower8-fusion |
30152 | @opindex mno-power8-fusion | |
ddf6fe37 AA |
30153 | @item -mpower8-fusion |
30154 | @itemx -mno-power8-fusion | |
d77de738 ML |
30155 | Generate code that keeps (does not keeps) some integer operations |
30156 | adjacent so that the instructions can be fused together on power8 and | |
30157 | later processors. | |
30158 | ||
d77de738 ML |
30159 | @opindex mpower8-vector |
30160 | @opindex mno-power8-vector | |
ddf6fe37 AA |
30161 | @item -mpower8-vector |
30162 | @itemx -mno-power8-vector | |
d77de738 ML |
30163 | Generate code that uses (does not use) the vector and scalar |
30164 | instructions that were added in version 2.07 of the PowerPC ISA. Also | |
30165 | enable the use of built-in functions that allow more direct access to | |
30166 | the vector instructions. | |
30167 | ||
d77de738 ML |
30168 | @opindex mquad-memory |
30169 | @opindex mno-quad-memory | |
ddf6fe37 AA |
30170 | @item -mquad-memory |
30171 | @itemx -mno-quad-memory | |
d77de738 ML |
30172 | Generate code that uses (does not use) the non-atomic quad word memory |
30173 | instructions. The @option{-mquad-memory} option requires use of | |
30174 | 64-bit mode. | |
30175 | ||
d77de738 ML |
30176 | @opindex mquad-memory-atomic |
30177 | @opindex mno-quad-memory-atomic | |
ddf6fe37 AA |
30178 | @item -mquad-memory-atomic |
30179 | @itemx -mno-quad-memory-atomic | |
d77de738 ML |
30180 | Generate code that uses (does not use) the atomic quad word memory |
30181 | instructions. The @option{-mquad-memory-atomic} option requires use of | |
30182 | 64-bit mode. | |
30183 | ||
d77de738 ML |
30184 | @opindex mfloat128 |
30185 | @opindex mno-float128 | |
ddf6fe37 AA |
30186 | @item -mfloat128 |
30187 | @itemx -mno-float128 | |
d77de738 ML |
30188 | Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point |
30189 | and use either software emulation for IEEE 128-bit floating point or | |
30190 | hardware instructions. | |
30191 | ||
30192 | The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE | |
30193 | 128-bit floating point support. The IEEE 128-bit floating point is only | |
30194 | supported on Linux. | |
30195 | ||
30196 | The default for @option{-mfloat128} is enabled on PowerPC Linux | |
30197 | systems using the VSX instruction set, and disabled on other systems. | |
30198 | ||
30199 | If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or | |
30200 | @option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating | |
30201 | point support will also enable the generation of ISA 3.0 IEEE 128-bit | |
30202 | floating point instructions. Otherwise, if you do not specify to | |
30203 | generate ISA 3.0 instructions or you are targeting a 32-bit big endian | |
30204 | system, IEEE 128-bit floating point will be done with software | |
30205 | emulation. | |
30206 | ||
d77de738 ML |
30207 | @opindex mfloat128-hardware |
30208 | @opindex mno-float128-hardware | |
ddf6fe37 AA |
30209 | @item -mfloat128-hardware |
30210 | @itemx -mno-float128-hardware | |
d77de738 ML |
30211 | Enable/disable using ISA 3.0 hardware instructions to support the |
30212 | @var{__float128} data type. | |
30213 | ||
30214 | The default for @option{-mfloat128-hardware} is enabled on PowerPC | |
30215 | Linux systems using the ISA 3.0 instruction set, and disabled on other | |
30216 | systems. | |
30217 | ||
d77de738 ML |
30218 | @opindex m32 |
30219 | @opindex m64 | |
ddf6fe37 AA |
30220 | @item -m32 |
30221 | @itemx -m64 | |
d77de738 ML |
30222 | Generate code for 32-bit or 64-bit environments of Darwin and SVR4 |
30223 | targets (including GNU/Linux). The 32-bit environment sets int, long | |
30224 | and pointer to 32 bits and generates code that runs on any PowerPC | |
30225 | variant. The 64-bit environment sets int to 32 bits and long and | |
30226 | pointer to 64 bits, and generates code for PowerPC64, as for | |
30227 | @option{-mpowerpc64}. | |
30228 | ||
d77de738 ML |
30229 | @opindex mfull-toc |
30230 | @opindex mno-fp-in-toc | |
30231 | @opindex mno-sum-in-toc | |
30232 | @opindex mminimal-toc | |
ddf6fe37 AA |
30233 | @item -mfull-toc |
30234 | @itemx -mno-fp-in-toc | |
30235 | @itemx -mno-sum-in-toc | |
30236 | @itemx -mminimal-toc | |
d77de738 ML |
30237 | Modify generation of the TOC (Table Of Contents), which is created for |
30238 | every executable file. The @option{-mfull-toc} option is selected by | |
30239 | default. In that case, GCC allocates at least one TOC entry for | |
30240 | each unique non-automatic variable reference in your program. GCC | |
30241 | also places floating-point constants in the TOC@. However, only | |
30242 | 16,384 entries are available in the TOC@. | |
30243 | ||
30244 | If you receive a linker error message that saying you have overflowed | |
30245 | the available TOC space, you can reduce the amount of TOC space used | |
30246 | with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options. | |
30247 | @option{-mno-fp-in-toc} prevents GCC from putting floating-point | |
30248 | constants in the TOC and @option{-mno-sum-in-toc} forces GCC to | |
30249 | generate code to calculate the sum of an address and a constant at | |
30250 | run time instead of putting that sum into the TOC@. You may specify one | |
30251 | or both of these options. Each causes GCC to produce very slightly | |
30252 | slower and larger code at the expense of conserving TOC space. | |
30253 | ||
30254 | If you still run out of space in the TOC even when you specify both of | |
30255 | these options, specify @option{-mminimal-toc} instead. This option causes | |
30256 | GCC to make only one TOC entry for every file. When you specify this | |
30257 | option, GCC produces code that is slower and larger but which | |
30258 | uses extremely little TOC space. You may wish to use this option | |
30259 | only on files that contain less frequently-executed code. | |
30260 | ||
d77de738 ML |
30261 | @opindex maix64 |
30262 | @opindex maix32 | |
ddf6fe37 AA |
30263 | @item -maix64 |
30264 | @itemx -maix32 | |
d77de738 ML |
30265 | Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit |
30266 | @code{long} type, and the infrastructure needed to support them. | |
30267 | Specifying @option{-maix64} implies @option{-mpowerpc64}, | |
30268 | while @option{-maix32} disables the 64-bit ABI and | |
30269 | implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}. | |
30270 | ||
d77de738 ML |
30271 | @opindex mxl-compat |
30272 | @opindex mno-xl-compat | |
ddf6fe37 AA |
30273 | @item -mxl-compat |
30274 | @itemx -mno-xl-compat | |
d77de738 ML |
30275 | Produce code that conforms more closely to IBM XL compiler semantics |
30276 | when using AIX-compatible ABI@. Pass floating-point arguments to | |
30277 | prototyped functions beyond the register save area (RSA) on the stack | |
30278 | in addition to argument FPRs. Do not assume that most significant | |
30279 | double in 128-bit long double value is properly rounded when comparing | |
30280 | values and converting to double. Use XL symbol names for long double | |
30281 | support routines. | |
30282 | ||
30283 | The AIX calling convention was extended but not initially documented to | |
30284 | handle an obscure K&R C case of calling a function that takes the | |
30285 | address of its arguments with fewer arguments than declared. IBM XL | |
30286 | compilers access floating-point arguments that do not fit in the | |
30287 | RSA from the stack when a subroutine is compiled without | |
30288 | optimization. Because always storing floating-point arguments on the | |
30289 | stack is inefficient and rarely needed, this option is not enabled by | |
30290 | default and only is necessary when calling subroutines compiled by IBM | |
30291 | XL compilers without optimization. | |
30292 | ||
d77de738 | 30293 | @opindex mpe |
ddf6fe37 | 30294 | @item -mpe |
d77de738 ML |
30295 | Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an |
30296 | application written to use message passing with special startup code to | |
30297 | enable the application to run. The system must have PE installed in the | |
30298 | standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file | |
30299 | must be overridden with the @option{-specs=} option to specify the | |
30300 | appropriate directory location. The Parallel Environment does not | |
30301 | support threads, so the @option{-mpe} option and the @option{-pthread} | |
30302 | option are incompatible. | |
30303 | ||
d77de738 ML |
30304 | @opindex malign-natural |
30305 | @opindex malign-power | |
ddf6fe37 AA |
30306 | @item -malign-natural |
30307 | @itemx -malign-power | |
d77de738 ML |
30308 | On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option |
30309 | @option{-malign-natural} overrides the ABI-defined alignment of larger | |
30310 | types, such as floating-point doubles, on their natural size-based boundary. | |
30311 | The option @option{-malign-power} instructs GCC to follow the ABI-specified | |
30312 | alignment rules. GCC defaults to the standard alignment defined in the ABI@. | |
30313 | ||
30314 | On 64-bit Darwin, natural alignment is the default, and @option{-malign-power} | |
30315 | is not supported. | |
30316 | ||
d77de738 ML |
30317 | @opindex msoft-float |
30318 | @opindex mhard-float | |
ddf6fe37 AA |
30319 | @item -msoft-float |
30320 | @itemx -mhard-float | |
d77de738 ML |
30321 | Generate code that does not use (uses) the floating-point register set. |
30322 | Software floating-point emulation is provided if you use the | |
30323 | @option{-msoft-float} option, and pass the option to GCC when linking. | |
30324 | ||
d77de738 ML |
30325 | @opindex mmultiple |
30326 | @opindex mno-multiple | |
ddf6fe37 AA |
30327 | @item -mmultiple |
30328 | @itemx -mno-multiple | |
d77de738 ML |
30329 | Generate code that uses (does not use) the load multiple word |
30330 | instructions and the store multiple word instructions. These | |
30331 | instructions are generated by default on POWER systems, and not | |
30332 | generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian | |
30333 | PowerPC systems, since those instructions do not work when the | |
30334 | processor is in little-endian mode. The exceptions are PPC740 and | |
30335 | PPC750 which permit these instructions in little-endian mode. | |
30336 | ||
d77de738 ML |
30337 | @opindex mupdate |
30338 | @opindex mno-update | |
ddf6fe37 AA |
30339 | @item -mupdate |
30340 | @itemx -mno-update | |
d77de738 ML |
30341 | Generate code that uses (does not use) the load or store instructions |
30342 | that update the base register to the address of the calculated memory | |
30343 | location. These instructions are generated by default. If you use | |
30344 | @option{-mno-update}, there is a small window between the time that the | |
30345 | stack pointer is updated and the address of the previous frame is | |
30346 | stored, which means code that walks the stack frame across interrupts or | |
30347 | signals may get corrupted data. | |
30348 | ||
d77de738 ML |
30349 | @opindex mavoid-indexed-addresses |
30350 | @opindex mno-avoid-indexed-addresses | |
ddf6fe37 AA |
30351 | @item -mavoid-indexed-addresses |
30352 | @itemx -mno-avoid-indexed-addresses | |
d77de738 ML |
30353 | Generate code that tries to avoid (not avoid) the use of indexed load |
30354 | or store instructions. These instructions can incur a performance | |
30355 | penalty on Power6 processors in certain situations, such as when | |
30356 | stepping through large arrays that cross a 16M boundary. This option | |
30357 | is enabled by default when targeting Power6 and disabled otherwise. | |
30358 | ||
d77de738 ML |
30359 | @opindex mfused-madd |
30360 | @opindex mno-fused-madd | |
ddf6fe37 AA |
30361 | @item -mfused-madd |
30362 | @itemx -mno-fused-madd | |
d77de738 ML |
30363 | Generate code that uses (does not use) the floating-point multiply and |
30364 | accumulate instructions. These instructions are generated by default | |
30365 | if hardware floating point is used. The machine-dependent | |
30366 | @option{-mfused-madd} option is now mapped to the machine-independent | |
30367 | @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is | |
30368 | mapped to @option{-ffp-contract=off}. | |
30369 | ||
d77de738 ML |
30370 | @opindex mmulhw |
30371 | @opindex mno-mulhw | |
ddf6fe37 AA |
30372 | @item -mmulhw |
30373 | @itemx -mno-mulhw | |
d77de738 ML |
30374 | Generate code that uses (does not use) the half-word multiply and |
30375 | multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors. | |
30376 | These instructions are generated by default when targeting those | |
30377 | processors. | |
30378 | ||
d77de738 ML |
30379 | @opindex mdlmzb |
30380 | @opindex mno-dlmzb | |
ddf6fe37 AA |
30381 | @item -mdlmzb |
30382 | @itemx -mno-dlmzb | |
d77de738 ML |
30383 | Generate code that uses (does not use) the string-search @samp{dlmzb} |
30384 | instruction on the IBM 405, 440, 464 and 476 processors. This instruction is | |
30385 | generated by default when targeting those processors. | |
30386 | ||
d77de738 ML |
30387 | @opindex mno-bit-align |
30388 | @opindex mbit-align | |
ddf6fe37 AA |
30389 | @item -mno-bit-align |
30390 | @itemx -mbit-align | |
d77de738 ML |
30391 | On System V.4 and embedded PowerPC systems do not (do) force structures |
30392 | and unions that contain bit-fields to be aligned to the base type of the | |
30393 | bit-field. | |
30394 | ||
30395 | For example, by default a structure containing nothing but 8 | |
30396 | @code{unsigned} bit-fields of length 1 is aligned to a 4-byte | |
30397 | boundary and has a size of 4 bytes. By using @option{-mno-bit-align}, | |
30398 | the structure is aligned to a 1-byte boundary and is 1 byte in | |
30399 | size. | |
30400 | ||
d77de738 ML |
30401 | @opindex mno-strict-align |
30402 | @opindex mstrict-align | |
ddf6fe37 AA |
30403 | @item -mno-strict-align |
30404 | @itemx -mstrict-align | |
d77de738 ML |
30405 | On System V.4 and embedded PowerPC systems do not (do) assume that |
30406 | unaligned memory references are handled by the system. | |
30407 | ||
d77de738 ML |
30408 | @opindex mrelocatable |
30409 | @opindex mno-relocatable | |
ddf6fe37 AA |
30410 | @item -mrelocatable |
30411 | @itemx -mno-relocatable | |
d77de738 ML |
30412 | Generate code that allows (does not allow) a static executable to be |
30413 | relocated to a different address at run time. A simple embedded | |
30414 | PowerPC system loader should relocate the entire contents of | |
30415 | @code{.got2} and 4-byte locations listed in the @code{.fixup} section, | |
30416 | a table of 32-bit addresses generated by this option. For this to | |
30417 | work, all objects linked together must be compiled with | |
30418 | @option{-mrelocatable} or @option{-mrelocatable-lib}. | |
30419 | @option{-mrelocatable} code aligns the stack to an 8-byte boundary. | |
30420 | ||
d77de738 ML |
30421 | @opindex mrelocatable-lib |
30422 | @opindex mno-relocatable-lib | |
ddf6fe37 AA |
30423 | @item -mrelocatable-lib |
30424 | @itemx -mno-relocatable-lib | |
d77de738 ML |
30425 | Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a |
30426 | @code{.fixup} section to allow static executables to be relocated at | |
30427 | run time, but @option{-mrelocatable-lib} does not use the smaller stack | |
30428 | alignment of @option{-mrelocatable}. Objects compiled with | |
30429 | @option{-mrelocatable-lib} may be linked with objects compiled with | |
30430 | any combination of the @option{-mrelocatable} options. | |
30431 | ||
d77de738 ML |
30432 | @opindex mno-toc |
30433 | @opindex mtoc | |
ddf6fe37 AA |
30434 | @item -mno-toc |
30435 | @itemx -mtoc | |
d77de738 ML |
30436 | On System V.4 and embedded PowerPC systems do not (do) assume that |
30437 | register 2 contains a pointer to a global area pointing to the addresses | |
30438 | used in the program. | |
30439 | ||
d77de738 ML |
30440 | @opindex mlittle |
30441 | @opindex mlittle-endian | |
ddf6fe37 AA |
30442 | @item -mlittle |
30443 | @itemx -mlittle-endian | |
d77de738 ML |
30444 | On System V.4 and embedded PowerPC systems compile code for the |
30445 | processor in little-endian mode. The @option{-mlittle-endian} option is | |
30446 | the same as @option{-mlittle}. | |
30447 | ||
d77de738 ML |
30448 | @opindex mbig |
30449 | @opindex mbig-endian | |
ddf6fe37 AA |
30450 | @item -mbig |
30451 | @itemx -mbig-endian | |
d77de738 ML |
30452 | On System V.4 and embedded PowerPC systems compile code for the |
30453 | processor in big-endian mode. The @option{-mbig-endian} option is | |
30454 | the same as @option{-mbig}. | |
30455 | ||
d77de738 | 30456 | @opindex mdynamic-no-pic |
ddf6fe37 | 30457 | @item -mdynamic-no-pic |
a335cf24 | 30458 | On Darwin / macOS systems, compile code so that it is not |
d77de738 ML |
30459 | relocatable, but that its external references are relocatable. The |
30460 | resulting code is suitable for applications, but not shared | |
30461 | libraries. | |
30462 | ||
d77de738 | 30463 | @opindex msingle-pic-base |
ddf6fe37 | 30464 | @item -msingle-pic-base |
d77de738 ML |
30465 | Treat the register used for PIC addressing as read-only, rather than |
30466 | loading it in the prologue for each function. The runtime system is | |
30467 | responsible for initializing this register with an appropriate value | |
30468 | before execution begins. | |
30469 | ||
d77de738 | 30470 | @opindex mprioritize-restricted-insns |
ddf6fe37 | 30471 | @item -mprioritize-restricted-insns=@var{priority} |
d77de738 ML |
30472 | This option controls the priority that is assigned to |
30473 | dispatch-slot restricted instructions during the second scheduling | |
30474 | pass. The argument @var{priority} takes the value @samp{0}, @samp{1}, | |
30475 | or @samp{2} to assign no, highest, or second-highest (respectively) | |
30476 | priority to dispatch-slot restricted | |
30477 | instructions. | |
30478 | ||
d77de738 | 30479 | @opindex msched-costly-dep |
ddf6fe37 | 30480 | @item -msched-costly-dep=@var{dependence_type} |
d77de738 ML |
30481 | This option controls which dependences are considered costly |
30482 | by the target during instruction scheduling. The argument | |
30483 | @var{dependence_type} takes one of the following values: | |
30484 | ||
30485 | @table @asis | |
30486 | @item @samp{no} | |
30487 | No dependence is costly. | |
30488 | ||
30489 | @item @samp{all} | |
30490 | All dependences are costly. | |
30491 | ||
30492 | @item @samp{true_store_to_load} | |
30493 | A true dependence from store to load is costly. | |
30494 | ||
30495 | @item @samp{store_to_load} | |
30496 | Any dependence from store to load is costly. | |
30497 | ||
30498 | @item @var{number} | |
30499 | Any dependence for which the latency is greater than or equal to | |
30500 | @var{number} is costly. | |
30501 | @end table | |
30502 | ||
d77de738 | 30503 | @opindex minsert-sched-nops |
ddf6fe37 | 30504 | @item -minsert-sched-nops=@var{scheme} |
d77de738 ML |
30505 | This option controls which NOP insertion scheme is used during |
30506 | the second scheduling pass. The argument @var{scheme} takes one of the | |
30507 | following values: | |
30508 | ||
30509 | @table @asis | |
30510 | @item @samp{no} | |
30511 | Don't insert NOPs. | |
30512 | ||
30513 | @item @samp{pad} | |
30514 | Pad with NOPs any dispatch group that has vacant issue slots, | |
30515 | according to the scheduler's grouping. | |
30516 | ||
30517 | @item @samp{regroup_exact} | |
30518 | Insert NOPs to force costly dependent insns into | |
30519 | separate groups. Insert exactly as many NOPs as needed to force an insn | |
30520 | to a new group, according to the estimated processor grouping. | |
30521 | ||
30522 | @item @var{number} | |
30523 | Insert NOPs to force costly dependent insns into | |
30524 | separate groups. Insert @var{number} NOPs to force an insn to a new group. | |
30525 | @end table | |
30526 | ||
d77de738 | 30527 | @opindex mcall-sysv |
ddf6fe37 | 30528 | @item -mcall-sysv |
d77de738 ML |
30529 | On System V.4 and embedded PowerPC systems compile code using calling |
30530 | conventions that adhere to the March 1995 draft of the System V | |
30531 | Application Binary Interface, PowerPC processor supplement. This is the | |
30532 | default unless you configured GCC using @samp{powerpc-*-eabiaix}. | |
30533 | ||
d77de738 ML |
30534 | @opindex mcall-sysv-eabi |
30535 | @opindex mcall-eabi | |
ddf6fe37 AA |
30536 | @item -mcall-sysv-eabi |
30537 | @itemx -mcall-eabi | |
d77de738 ML |
30538 | Specify both @option{-mcall-sysv} and @option{-meabi} options. |
30539 | ||
d77de738 | 30540 | @opindex mcall-sysv-noeabi |
ddf6fe37 | 30541 | @item -mcall-sysv-noeabi |
d77de738 ML |
30542 | Specify both @option{-mcall-sysv} and @option{-mno-eabi} options. |
30543 | ||
d7971cf7 | 30544 | @opindex mcall-aixdesc |
ddf6fe37 | 30545 | @item -mcall-aixdesc |
d77de738 ML |
30546 | On System V.4 and embedded PowerPC systems compile code for the AIX |
30547 | operating system. | |
30548 | ||
d77de738 | 30549 | @opindex mcall-linux |
ddf6fe37 | 30550 | @item -mcall-linux |
d77de738 ML |
30551 | On System V.4 and embedded PowerPC systems compile code for the |
30552 | Linux-based GNU system. | |
30553 | ||
d77de738 | 30554 | @opindex mcall-freebsd |
ddf6fe37 | 30555 | @item -mcall-freebsd |
d77de738 ML |
30556 | On System V.4 and embedded PowerPC systems compile code for the |
30557 | FreeBSD operating system. | |
30558 | ||
d77de738 | 30559 | @opindex mcall-netbsd |
ddf6fe37 | 30560 | @item -mcall-netbsd |
d77de738 ML |
30561 | On System V.4 and embedded PowerPC systems compile code for the |
30562 | NetBSD operating system. | |
30563 | ||
d7971cf7 | 30564 | @opindex mcall-openbsd |
ddf6fe37 | 30565 | @item -mcall-openbsd |
d77de738 ML |
30566 | On System V.4 and embedded PowerPC systems compile code for the |
30567 | OpenBSD operating system. | |
30568 | ||
d77de738 | 30569 | @opindex mtraceback |
ddf6fe37 | 30570 | @item -mtraceback=@var{traceback_type} |
d77de738 ML |
30571 | Select the type of traceback table. Valid values for @var{traceback_type} |
30572 | are @samp{full}, @samp{part}, and @samp{no}. | |
30573 | ||
d77de738 | 30574 | @opindex maix-struct-return |
ddf6fe37 | 30575 | @item -maix-struct-return |
d77de738 ML |
30576 | Return all structures in memory (as specified by the AIX ABI)@. |
30577 | ||
d77de738 | 30578 | @opindex msvr4-struct-return |
ddf6fe37 | 30579 | @item -msvr4-struct-return |
d77de738 ML |
30580 | Return structures smaller than 8 bytes in registers (as specified by the |
30581 | SVR4 ABI)@. | |
30582 | ||
d77de738 | 30583 | @opindex mabi |
ddf6fe37 | 30584 | @item -mabi=@var{abi-type} |
d77de738 ML |
30585 | Extend the current ABI with a particular extension, or remove such extension. |
30586 | Valid values are: @samp{altivec}, @samp{no-altivec}, | |
30587 | @samp{ibmlongdouble}, @samp{ieeelongdouble}, | |
30588 | @samp{elfv1}, @samp{elfv2}, | |
30589 | and for AIX: @samp{vec-extabi}, @samp{vec-default}@. | |
30590 | ||
d77de738 | 30591 | @opindex mabi=ibmlongdouble |
ddf6fe37 | 30592 | @item -mabi=ibmlongdouble |
d77de738 ML |
30593 | Change the current ABI to use IBM extended-precision long double. |
30594 | This is not likely to work if your system defaults to using IEEE | |
30595 | extended-precision long double. If you change the long double type | |
30596 | from IEEE extended-precision, the compiler will issue a warning unless | |
30597 | you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128} | |
30598 | to be enabled. | |
30599 | ||
d77de738 | 30600 | @opindex mabi=ieeelongdouble |
ddf6fe37 | 30601 | @item -mabi=ieeelongdouble |
d77de738 ML |
30602 | Change the current ABI to use IEEE extended-precision long double. |
30603 | This is not likely to work if your system defaults to using IBM | |
30604 | extended-precision long double. If you change the long double type | |
30605 | from IBM extended-precision, the compiler will issue a warning unless | |
30606 | you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128} | |
30607 | to be enabled. | |
30608 | ||
d77de738 | 30609 | @opindex mabi=elfv1 |
ddf6fe37 | 30610 | @item -mabi=elfv1 |
d77de738 ML |
30611 | Change the current ABI to use the ELFv1 ABI. |
30612 | This is the default ABI for big-endian PowerPC 64-bit Linux. | |
30613 | Overriding the default ABI requires special system support and is | |
30614 | likely to fail in spectacular ways. | |
30615 | ||
d77de738 | 30616 | @opindex mabi=elfv2 |
ddf6fe37 | 30617 | @item -mabi=elfv2 |
d77de738 ML |
30618 | Change the current ABI to use the ELFv2 ABI. |
30619 | This is the default ABI for little-endian PowerPC 64-bit Linux. | |
30620 | Overriding the default ABI requires special system support and is | |
30621 | likely to fail in spectacular ways. | |
30622 | ||
d77de738 ML |
30623 | @opindex mgnu-attribute |
30624 | @opindex mno-gnu-attribute | |
ddf6fe37 AA |
30625 | @item -mgnu-attribute |
30626 | @itemx -mno-gnu-attribute | |
d77de738 ML |
30627 | Emit .gnu_attribute assembly directives to set tag/value pairs in a |
30628 | .gnu.attributes section that specify ABI variations in function | |
30629 | parameters or return values. | |
30630 | ||
d77de738 ML |
30631 | @opindex mprototype |
30632 | @opindex mno-prototype | |
ddf6fe37 AA |
30633 | @item -mprototype |
30634 | @itemx -mno-prototype | |
d77de738 ML |
30635 | On System V.4 and embedded PowerPC systems assume that all calls to |
30636 | variable argument functions are properly prototyped. Otherwise, the | |
30637 | compiler must insert an instruction before every non-prototyped call to | |
30638 | set or clear bit 6 of the condition code register (@code{CR}) to | |
30639 | indicate whether floating-point values are passed in the floating-point | |
30640 | registers in case the function takes variable arguments. With | |
30641 | @option{-mprototype}, only calls to prototyped variable argument functions | |
30642 | set or clear the bit. | |
30643 | ||
d77de738 | 30644 | @opindex msim |
ddf6fe37 | 30645 | @item -msim |
d77de738 ML |
30646 | On embedded PowerPC systems, assume that the startup module is called |
30647 | @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and | |
30648 | @file{libc.a}. This is the default for @samp{powerpc-*-eabisim} | |
30649 | configurations. | |
30650 | ||
d77de738 | 30651 | @opindex mmvme |
ddf6fe37 | 30652 | @item -mmvme |
d77de738 ML |
30653 | On embedded PowerPC systems, assume that the startup module is called |
30654 | @file{crt0.o} and the standard C libraries are @file{libmvme.a} and | |
30655 | @file{libc.a}. | |
30656 | ||
d77de738 | 30657 | @opindex mads |
ddf6fe37 | 30658 | @item -mads |
d77de738 ML |
30659 | On embedded PowerPC systems, assume that the startup module is called |
30660 | @file{crt0.o} and the standard C libraries are @file{libads.a} and | |
30661 | @file{libc.a}. | |
30662 | ||
d77de738 | 30663 | @opindex myellowknife |
ddf6fe37 | 30664 | @item -myellowknife |
d77de738 ML |
30665 | On embedded PowerPC systems, assume that the startup module is called |
30666 | @file{crt0.o} and the standard C libraries are @file{libyk.a} and | |
30667 | @file{libc.a}. | |
30668 | ||
d77de738 | 30669 | @opindex mvxworks |
ddf6fe37 | 30670 | @item -mvxworks |
d77de738 ML |
30671 | On System V.4 and embedded PowerPC systems, specify that you are |
30672 | compiling for a VxWorks system. | |
30673 | ||
d77de738 | 30674 | @opindex memb |
ddf6fe37 | 30675 | @item -memb |
d77de738 ML |
30676 | On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags |
30677 | header to indicate that @samp{eabi} extended relocations are used. | |
30678 | ||
d77de738 ML |
30679 | @opindex meabi |
30680 | @opindex mno-eabi | |
ddf6fe37 AA |
30681 | @item -meabi |
30682 | @itemx -mno-eabi | |
d77de738 ML |
30683 | On System V.4 and embedded PowerPC systems do (do not) adhere to the |
30684 | Embedded Applications Binary Interface (EABI), which is a set of | |
30685 | modifications to the System V.4 specifications. Selecting @option{-meabi} | |
30686 | means that the stack is aligned to an 8-byte boundary, a function | |
30687 | @code{__eabi} is called from @code{main} to set up the EABI | |
30688 | environment, and the @option{-msdata} option can use both @code{r2} and | |
30689 | @code{r13} to point to two separate small data areas. Selecting | |
30690 | @option{-mno-eabi} means that the stack is aligned to a 16-byte boundary, | |
30691 | no EABI initialization function is called from @code{main}, and the | |
30692 | @option{-msdata} option only uses @code{r13} to point to a single | |
30693 | small data area. The @option{-meabi} option is on by default if you | |
30694 | configured GCC using one of the @samp{powerpc*-*-eabi*} options. | |
30695 | ||
d77de738 | 30696 | @opindex msdata=eabi |
ddf6fe37 | 30697 | @item -msdata=eabi |
d77de738 ML |
30698 | On System V.4 and embedded PowerPC systems, put small initialized |
30699 | @code{const} global and static data in the @code{.sdata2} section, which | |
30700 | is pointed to by register @code{r2}. Put small initialized | |
30701 | non-@code{const} global and static data in the @code{.sdata} section, | |
30702 | which is pointed to by register @code{r13}. Put small uninitialized | |
30703 | global and static data in the @code{.sbss} section, which is adjacent to | |
30704 | the @code{.sdata} section. The @option{-msdata=eabi} option is | |
30705 | incompatible with the @option{-mrelocatable} option. The | |
30706 | @option{-msdata=eabi} option also sets the @option{-memb} option. | |
30707 | ||
d77de738 | 30708 | @opindex msdata=sysv |
ddf6fe37 | 30709 | @item -msdata=sysv |
d77de738 ML |
30710 | On System V.4 and embedded PowerPC systems, put small global and static |
30711 | data in the @code{.sdata} section, which is pointed to by register | |
30712 | @code{r13}. Put small uninitialized global and static data in the | |
30713 | @code{.sbss} section, which is adjacent to the @code{.sdata} section. | |
30714 | The @option{-msdata=sysv} option is incompatible with the | |
30715 | @option{-mrelocatable} option. | |
30716 | ||
d77de738 ML |
30717 | @opindex msdata=default |
30718 | @opindex msdata | |
ddf6fe37 AA |
30719 | @item -msdata=default |
30720 | @itemx -msdata | |
d77de738 ML |
30721 | On System V.4 and embedded PowerPC systems, if @option{-meabi} is used, |
30722 | compile code the same as @option{-msdata=eabi}, otherwise compile code the | |
30723 | same as @option{-msdata=sysv}. | |
30724 | ||
d77de738 | 30725 | @opindex msdata=data |
ddf6fe37 | 30726 | @item -msdata=data |
d77de738 ML |
30727 | On System V.4 and embedded PowerPC systems, put small global |
30728 | data in the @code{.sdata} section. Put small uninitialized global | |
30729 | data in the @code{.sbss} section. Do not use register @code{r13} | |
30730 | to address small data however. This is the default behavior unless | |
30731 | other @option{-msdata} options are used. | |
30732 | ||
d77de738 ML |
30733 | @opindex msdata=none |
30734 | @opindex mno-sdata | |
ddf6fe37 AA |
30735 | @item -msdata=none |
30736 | @itemx -mno-sdata | |
d77de738 ML |
30737 | On embedded PowerPC systems, put all initialized global and static data |
30738 | in the @code{.data} section, and all uninitialized data in the | |
30739 | @code{.bss} section. | |
30740 | ||
d77de738 ML |
30741 | @opindex mreadonly-in-sdata |
30742 | @opindex mno-readonly-in-sdata | |
ddf6fe37 | 30743 | @item -mreadonly-in-sdata |
d77de738 ML |
30744 | Put read-only objects in the @code{.sdata} section as well. This is the |
30745 | default. | |
30746 | ||
d77de738 | 30747 | @opindex mblock-move-inline-limit |
ddf6fe37 | 30748 | @item -mblock-move-inline-limit=@var{num} |
d77de738 ML |
30749 | Inline all block moves (such as calls to @code{memcpy} or structure |
30750 | copies) less than or equal to @var{num} bytes. The minimum value for | |
30751 | @var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit | |
30752 | targets. The default value is target-specific. | |
30753 | ||
d77de738 | 30754 | @opindex mblock-compare-inline-limit |
ddf6fe37 | 30755 | @item -mblock-compare-inline-limit=@var{num} |
d77de738 ML |
30756 | Generate non-looping inline code for all block compares (such as calls |
30757 | to @code{memcmp} or structure compares) less than or equal to @var{num} | |
30758 | bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of | |
30759 | block compare is disabled. The default value is target-specific. | |
30760 | ||
d77de738 | 30761 | @opindex mblock-compare-inline-loop-limit |
ddf6fe37 | 30762 | @item -mblock-compare-inline-loop-limit=@var{num} |
d77de738 ML |
30763 | Generate an inline expansion using loop code for all block compares that |
30764 | are less than or equal to @var{num} bytes, but greater than the limit | |
30765 | for non-loop inline block compare expansion. If the block length is not | |
30766 | constant, at most @var{num} bytes will be compared before @code{memcmp} | |
30767 | is called to compare the remainder of the block. The default value is | |
30768 | target-specific. | |
30769 | ||
d77de738 | 30770 | @opindex mstring-compare-inline-limit |
ddf6fe37 | 30771 | @item -mstring-compare-inline-limit=@var{num} |
d77de738 ML |
30772 | Compare at most @var{num} string bytes with inline code. |
30773 | If the difference or end of string is not found at the | |
30774 | end of the inline compare a call to @code{strcmp} or @code{strncmp} will | |
30775 | take care of the rest of the comparison. The default is 64 bytes. | |
30776 | ||
d77de738 ML |
30777 | @opindex G |
30778 | @cindex smaller data references (PowerPC) | |
30779 | @cindex .sdata/.sdata2 references (PowerPC) | |
f33d7a88 | 30780 | @item -G @var{num} |
d77de738 ML |
30781 | On embedded PowerPC systems, put global and static items less than or |
30782 | equal to @var{num} bytes into the small data or BSS sections instead of | |
30783 | the normal data or BSS section. By default, @var{num} is 8. The | |
30784 | @option{-G @var{num}} switch is also passed to the linker. | |
30785 | All modules should be compiled with the same @option{-G @var{num}} value. | |
30786 | ||
d77de738 ML |
30787 | @opindex mregnames |
30788 | @opindex mno-regnames | |
ddf6fe37 AA |
30789 | @item -mregnames |
30790 | @itemx -mno-regnames | |
d77de738 ML |
30791 | On System V.4 and embedded PowerPC systems do (do not) emit register |
30792 | names in the assembly language output using symbolic forms. | |
30793 | ||
d77de738 ML |
30794 | @opindex mlongcall |
30795 | @opindex mno-longcall | |
ddf6fe37 AA |
30796 | @item -mlongcall |
30797 | @itemx -mno-longcall | |
d77de738 ML |
30798 | By default assume that all calls are far away so that a longer and more |
30799 | expensive calling sequence is required. This is required for calls | |
30800 | farther than 32 megabytes (33,554,432 bytes) from the current location. | |
30801 | A short call is generated if the compiler knows | |
30802 | the call cannot be that far away. This setting can be overridden by | |
30803 | the @code{shortcall} function attribute, or by @code{#pragma | |
30804 | longcall(0)}. | |
30805 | ||
30806 | Some linkers are capable of detecting out-of-range calls and generating | |
30807 | glue code on the fly. On these systems, long calls are unnecessary and | |
30808 | generate slower code. As of this writing, the AIX linker can do this, | |
30809 | as can the GNU linker for PowerPC/64. It is planned to add this feature | |
30810 | to the GNU linker for 32-bit PowerPC systems as well. | |
30811 | ||
30812 | On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers, | |
30813 | GCC can generate long calls using an inline PLT call sequence (see | |
30814 | @option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64 | |
30815 | ELFv1 (big-endian) do not support inline PLT calls. | |
30816 | ||
30817 | On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr | |
30818 | callee, L42}, plus a @dfn{branch island} (glue code). The two target | |
30819 | addresses represent the callee and the branch island. The | |
30820 | Darwin/PPC linker prefers the first address and generates a @code{bl | |
30821 | callee} if the PPC @code{bl} instruction reaches the callee directly; | |
30822 | otherwise, the linker generates @code{bl L42} to call the branch | |
30823 | island. The branch island is appended to the body of the | |
30824 | calling function; it computes the full 32-bit address of the callee | |
30825 | and jumps to it. | |
30826 | ||
30827 | On Mach-O (Darwin) systems, this option directs the compiler emit to | |
30828 | the glue for every direct call, and the Darwin linker decides whether | |
30829 | to use or discard it. | |
30830 | ||
30831 | In the future, GCC may ignore all longcall specifications | |
30832 | when the linker is known to generate glue. | |
30833 | ||
d77de738 ML |
30834 | @opindex mpltseq |
30835 | @opindex mno-pltseq | |
ddf6fe37 AA |
30836 | @item -mpltseq |
30837 | @itemx -mno-pltseq | |
d77de738 ML |
30838 | Implement (do not implement) -fno-plt and long calls using an inline |
30839 | PLT call sequence that supports lazy linking and long calls to | |
30840 | functions in dlopen'd shared libraries. Inline PLT calls are only | |
30841 | supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU | |
30842 | linkers, and are enabled by default if the support is detected when | |
30843 | configuring GCC, and, in the case of 32-bit PowerPC, if GCC is | |
30844 | configured with @option{--enable-secureplt}. @option{-mpltseq} code | |
30845 | and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be | |
30846 | linked together. | |
30847 | ||
d77de738 ML |
30848 | @opindex mtls-markers |
30849 | @opindex mno-tls-markers | |
ddf6fe37 AA |
30850 | @item -mtls-markers |
30851 | @itemx -mno-tls-markers | |
d77de738 ML |
30852 | Mark (do not mark) calls to @code{__tls_get_addr} with a relocation |
30853 | specifying the function argument. The relocation allows the linker to | |
30854 | reliably associate function call with argument setup instructions for | |
30855 | TLS optimization, which in turn allows GCC to better schedule the | |
30856 | sequence. | |
30857 | ||
ddf6fe37 | 30858 | @opindex mrecip |
d77de738 ML |
30859 | @item -mrecip |
30860 | @itemx -mno-recip | |
d77de738 ML |
30861 | This option enables use of the reciprocal estimate and |
30862 | reciprocal square root estimate instructions with additional | |
30863 | Newton-Raphson steps to increase precision instead of doing a divide or | |
30864 | square root and divide for floating-point arguments. You should use | |
30865 | the @option{-ffast-math} option when using @option{-mrecip} (or at | |
30866 | least @option{-funsafe-math-optimizations}, | |
30867 | @option{-ffinite-math-only}, @option{-freciprocal-math} and | |
30868 | @option{-fno-trapping-math}). Note that while the throughput of the | |
30869 | sequence is generally higher than the throughput of the non-reciprocal | |
30870 | instruction, the precision of the sequence can be decreased by up to 2 | |
30871 | ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square | |
30872 | roots. | |
30873 | ||
d77de738 | 30874 | @opindex mrecip=opt |
ddf6fe37 | 30875 | @item -mrecip=@var{opt} |
d77de738 ML |
30876 | This option controls which reciprocal estimate instructions |
30877 | may be used. @var{opt} is a comma-separated list of options, which may | |
30878 | be preceded by a @code{!} to invert the option: | |
30879 | ||
30880 | @table @samp | |
30881 | ||
30882 | @item all | |
30883 | Enable all estimate instructions. | |
30884 | ||
30885 | @item default | |
30886 | Enable the default instructions, equivalent to @option{-mrecip}. | |
30887 | ||
30888 | @item none | |
30889 | Disable all estimate instructions, equivalent to @option{-mno-recip}. | |
30890 | ||
30891 | @item div | |
30892 | Enable the reciprocal approximation instructions for both | |
30893 | single and double precision. | |
30894 | ||
30895 | @item divf | |
30896 | Enable the single-precision reciprocal approximation instructions. | |
30897 | ||
30898 | @item divd | |
30899 | Enable the double-precision reciprocal approximation instructions. | |
30900 | ||
30901 | @item rsqrt | |
30902 | Enable the reciprocal square root approximation instructions for both | |
30903 | single and double precision. | |
30904 | ||
30905 | @item rsqrtf | |
30906 | Enable the single-precision reciprocal square root approximation instructions. | |
30907 | ||
30908 | @item rsqrtd | |
30909 | Enable the double-precision reciprocal square root approximation instructions. | |
30910 | ||
30911 | @end table | |
30912 | ||
30913 | So, for example, @option{-mrecip=all,!rsqrtd} enables | |
30914 | all of the reciprocal estimate instructions, except for the | |
30915 | @code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions | |
30916 | which handle the double-precision reciprocal square root calculations. | |
30917 | ||
ddf6fe37 | 30918 | @opindex mrecip-precision |
d77de738 ML |
30919 | @item -mrecip-precision |
30920 | @itemx -mno-recip-precision | |
d77de738 ML |
30921 | Assume (do not assume) that the reciprocal estimate instructions |
30922 | provide higher-precision estimates than is mandated by the PowerPC | |
30923 | ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or | |
30924 | @option{-mcpu=power8} automatically selects @option{-mrecip-precision}. | |
30925 | The double-precision square root estimate instructions are not generated by | |
30926 | default on low-precision machines, since they do not provide an | |
30927 | estimate that converges after three steps. | |
30928 | ||
d77de738 | 30929 | @opindex mveclibabi |
ddf6fe37 | 30930 | @item -mveclibabi=@var{type} |
d77de738 ML |
30931 | Specifies the ABI type to use for vectorizing intrinsics using an |
30932 | external library. The only type supported at present is @samp{mass}, | |
30933 | which specifies to use IBM's Mathematical Acceleration Subsystem | |
30934 | (MASS) libraries for vectorizing intrinsics using external libraries. | |
30935 | GCC currently emits calls to @code{acosd2}, @code{acosf4}, | |
30936 | @code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4}, | |
30937 | @code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4}, | |
30938 | @code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4}, | |
30939 | @code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4}, | |
30940 | @code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4}, | |
30941 | @code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4}, | |
30942 | @code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4}, | |
30943 | @code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4}, | |
30944 | @code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4}, | |
30945 | @code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4}, | |
30946 | @code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2}, | |
30947 | @code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2}, | |
30948 | @code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code | |
30949 | for power7. Both @option{-ftree-vectorize} and | |
30950 | @option{-funsafe-math-optimizations} must also be enabled. The MASS | |
30951 | libraries must be specified at link time. | |
30952 | ||
ddf6fe37 | 30953 | @opindex mfriz |
d77de738 ML |
30954 | @item -mfriz |
30955 | @itemx -mno-friz | |
d77de738 ML |
30956 | Generate (do not generate) the @code{friz} instruction when the |
30957 | @option{-funsafe-math-optimizations} option is used to optimize | |
30958 | rounding of floating-point values to 64-bit integer and back to floating | |
30959 | point. The @code{friz} instruction does not return the same value if | |
30960 | the floating-point number is too large to fit in an integer. | |
30961 | ||
ddf6fe37 | 30962 | @opindex mpointers-to-nested-functions |
d77de738 ML |
30963 | @item -mpointers-to-nested-functions |
30964 | @itemx -mno-pointers-to-nested-functions | |
d77de738 ML |
30965 | Generate (do not generate) code to load up the static chain register |
30966 | (@code{r11}) when calling through a pointer on AIX and 64-bit Linux | |
30967 | systems where a function pointer points to a 3-word descriptor giving | |
30968 | the function address, TOC value to be loaded in register @code{r2}, and | |
30969 | static chain value to be loaded in register @code{r11}. The | |
30970 | @option{-mpointers-to-nested-functions} is on by default. You cannot | |
30971 | call through pointers to nested functions or pointers | |
30972 | to functions compiled in other languages that use the static chain if | |
30973 | you use @option{-mno-pointers-to-nested-functions}. | |
30974 | ||
ddf6fe37 | 30975 | @opindex msave-toc-indirect |
d77de738 ML |
30976 | @item -msave-toc-indirect |
30977 | @itemx -mno-save-toc-indirect | |
d77de738 ML |
30978 | Generate (do not generate) code to save the TOC value in the reserved |
30979 | stack location in the function prologue if the function calls through | |
30980 | a pointer on AIX and 64-bit Linux systems. If the TOC value is not | |
30981 | saved in the prologue, it is saved just before the call through the | |
30982 | pointer. The @option{-mno-save-toc-indirect} option is the default. | |
30983 | ||
ddf6fe37 | 30984 | @opindex mcompat-align-parm |
d77de738 ML |
30985 | @item -mcompat-align-parm |
30986 | @itemx -mno-compat-align-parm | |
d77de738 ML |
30987 | Generate (do not generate) code to pass structure parameters with a |
30988 | maximum alignment of 64 bits, for compatibility with older versions | |
30989 | of GCC. | |
30990 | ||
30991 | Older versions of GCC (prior to 4.9.0) incorrectly did not align a | |
30992 | structure parameter on a 128-bit boundary when that structure contained | |
30993 | a member requiring 128-bit alignment. This is corrected in more | |
30994 | recent versions of GCC. This option may be used to generate code | |
30995 | that is compatible with functions compiled with older versions of | |
30996 | GCC. | |
30997 | ||
30998 | The @option{-mno-compat-align-parm} option is the default. | |
30999 | ||
d77de738 ML |
31000 | @opindex mstack-protector-guard |
31001 | @opindex mstack-protector-guard-reg | |
31002 | @opindex mstack-protector-guard-offset | |
31003 | @opindex mstack-protector-guard-symbol | |
ddf6fe37 AA |
31004 | @item -mstack-protector-guard=@var{guard} |
31005 | @itemx -mstack-protector-guard-reg=@var{reg} | |
31006 | @itemx -mstack-protector-guard-offset=@var{offset} | |
31007 | @itemx -mstack-protector-guard-symbol=@var{symbol} | |
d77de738 ML |
31008 | Generate stack protection code using canary at @var{guard}. Supported |
31009 | locations are @samp{global} for global canary or @samp{tls} for per-thread | |
31010 | canary in the TLS block (the default with GNU libc version 2.4 or later). | |
31011 | ||
31012 | With the latter choice the options | |
31013 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
31014 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
31015 | which register to use as base register for reading the canary, and from what | |
31016 | offset from that base register. The default for those is as specified in the | |
31017 | relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides | |
31018 | the offset with a symbol reference to a canary in the TLS block. | |
31019 | ||
d77de738 ML |
31020 | @opindex mpcrel |
31021 | @opindex mno-pcrel | |
ddf6fe37 AA |
31022 | @item -mpcrel |
31023 | @itemx -mno-pcrel | |
d77de738 ML |
31024 | Generate (do not generate) pc-relative addressing. The @option{-mpcrel} |
31025 | option requires that the medium code model (@option{-mcmodel=medium}) | |
31026 | and prefixed addressing (@option{-mprefixed}) options are enabled. | |
31027 | ||
d77de738 ML |
31028 | @opindex mprefixed |
31029 | @opindex mno-prefixed | |
ddf6fe37 AA |
31030 | @item -mprefixed |
31031 | @itemx -mno-prefixed | |
d77de738 ML |
31032 | Generate (do not generate) addressing modes using prefixed load and |
31033 | store instructions. The @option{-mprefixed} option requires that | |
31034 | the option @option{-mcpu=power10} (or later) is enabled. | |
31035 | ||
d77de738 ML |
31036 | @opindex mmma |
31037 | @opindex mno-mma | |
ddf6fe37 AA |
31038 | @item -mmma |
31039 | @itemx -mno-mma | |
d77de738 ML |
31040 | Generate (do not generate) the MMA instructions. The @option{-mma} |
31041 | option requires that the option @option{-mcpu=power10} (or later) | |
31042 | is enabled. | |
31043 | ||
d77de738 ML |
31044 | @opindex mrop-protect |
31045 | @opindex mno-rop-protect | |
ddf6fe37 AA |
31046 | @item -mrop-protect |
31047 | @itemx -mno-rop-protect | |
d77de738 ML |
31048 | Generate (do not generate) ROP protection instructions when the target |
31049 | processor supports them. Currently this option disables the shrink-wrap | |
31050 | optimization (@option{-fshrink-wrap}). | |
31051 | ||
d77de738 ML |
31052 | @opindex mprivileged |
31053 | @opindex mno-privileged | |
ddf6fe37 AA |
31054 | @item -mprivileged |
31055 | @itemx -mno-privileged | |
d77de738 ML |
31056 | Generate (do not generate) code that will run in privileged state. |
31057 | ||
d77de738 ML |
31058 | @opindex block-ops-unaligned-vsx |
31059 | @opindex no-block-ops-unaligned-vsx | |
ddf6fe37 AA |
31060 | @item -mblock-ops-unaligned-vsx |
31061 | @itemx -mno-block-ops-unaligned-vsx | |
d77de738 ML |
31062 | Generate (do not generate) unaligned vsx loads and stores for |
31063 | inline expansion of @code{memcpy} and @code{memmove}. | |
31064 | ||
31065 | @item --param rs6000-vect-unroll-limit= | |
31066 | The vectorizer will check with target information to determine whether it | |
31067 | would be beneficial to unroll the main vectorized loop and by how much. This | |
31068 | parameter sets the upper bound of how much the vectorizer will unroll the main | |
31069 | loop. The default value is four. | |
31070 | ||
31071 | @end table | |
31072 | ||
31073 | @node RX Options | |
31074 | @subsection RX Options | |
31075 | @cindex RX Options | |
31076 | ||
31077 | These command-line options are defined for RX targets: | |
31078 | ||
31079 | @table @gcctabopt | |
d77de738 ML |
31080 | @opindex m64bit-doubles |
31081 | @opindex m32bit-doubles | |
ddf6fe37 AA |
31082 | @item -m64bit-doubles |
31083 | @itemx -m32bit-doubles | |
d77de738 ML |
31084 | Make the @code{double} data type be 64 bits (@option{-m64bit-doubles}) |
31085 | or 32 bits (@option{-m32bit-doubles}) in size. The default is | |
31086 | @option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only | |
31087 | works on 32-bit values, which is why the default is | |
31088 | @option{-m32bit-doubles}. | |
31089 | ||
d77de738 ML |
31090 | @opindex fpu |
31091 | @opindex nofpu | |
ddf6fe37 AA |
31092 | @item -fpu |
31093 | @itemx -nofpu | |
d77de738 ML |
31094 | Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX |
31095 | floating-point hardware. The default is enabled for the RX600 | |
31096 | series and disabled for the RX200 series. | |
31097 | ||
31098 | Floating-point instructions are only generated for 32-bit floating-point | |
31099 | values, however, so the FPU hardware is not used for doubles if the | |
31100 | @option{-m64bit-doubles} option is used. | |
31101 | ||
31102 | @emph{Note} If the @option{-fpu} option is enabled then | |
31103 | @option{-funsafe-math-optimizations} is also enabled automatically. | |
31104 | This is because the RX FPU instructions are themselves unsafe. | |
31105 | ||
d77de738 | 31106 | @opindex mcpu |
ddf6fe37 | 31107 | @item -mcpu=@var{name} |
d77de738 ML |
31108 | Selects the type of RX CPU to be targeted. Currently three types are |
31109 | supported, the generic @samp{RX600} and @samp{RX200} series hardware and | |
31110 | the specific @samp{RX610} CPU. The default is @samp{RX600}. | |
31111 | ||
31112 | The only difference between @samp{RX600} and @samp{RX610} is that the | |
31113 | @samp{RX610} does not support the @code{MVTIPL} instruction. | |
31114 | ||
31115 | The @samp{RX200} series does not have a hardware floating-point unit | |
31116 | and so @option{-nofpu} is enabled by default when this type is | |
31117 | selected. | |
31118 | ||
d77de738 ML |
31119 | @opindex mbig-endian-data |
31120 | @opindex mlittle-endian-data | |
ddf6fe37 AA |
31121 | @item -mbig-endian-data |
31122 | @itemx -mlittle-endian-data | |
d77de738 ML |
31123 | Store data (but not code) in the big-endian format. The default is |
31124 | @option{-mlittle-endian-data}, i.e.@: to store data in the little-endian | |
31125 | format. | |
31126 | ||
d77de738 | 31127 | @opindex msmall-data-limit |
ddf6fe37 | 31128 | @item -msmall-data-limit=@var{N} |
d77de738 ML |
31129 | Specifies the maximum size in bytes of global and static variables |
31130 | which can be placed into the small data area. Using the small data | |
31131 | area can lead to smaller and faster code, but the size of area is | |
31132 | limited and it is up to the programmer to ensure that the area does | |
31133 | not overflow. Also when the small data area is used one of the RX's | |
31134 | registers (usually @code{r13}) is reserved for use pointing to this | |
31135 | area, so it is no longer available for use by the compiler. This | |
31136 | could result in slower and/or larger code if variables are pushed onto | |
31137 | the stack instead of being held in this register. | |
31138 | ||
31139 | Note, common variables (variables that have not been initialized) and | |
31140 | constants are not placed into the small data area as they are assigned | |
31141 | to other sections in the output executable. | |
31142 | ||
31143 | The default value is zero, which disables this feature. Note, this | |
31144 | feature is not enabled by default with higher optimization levels | |
31145 | (@option{-O2} etc) because of the potentially detrimental effects of | |
31146 | reserving a register. It is up to the programmer to experiment and | |
31147 | discover whether this feature is of benefit to their program. See the | |
31148 | description of the @option{-mpid} option for a description of how the | |
31149 | actual register to hold the small data area pointer is chosen. | |
31150 | ||
d77de738 ML |
31151 | @opindex msim |
31152 | @opindex mno-sim | |
ddf6fe37 AA |
31153 | @item -msim |
31154 | @itemx -mno-sim | |
d77de738 ML |
31155 | Use the simulator runtime. The default is to use the libgloss |
31156 | board-specific runtime. | |
31157 | ||
d77de738 ML |
31158 | @opindex mas100-syntax |
31159 | @opindex mno-as100-syntax | |
ddf6fe37 AA |
31160 | @item -mas100-syntax |
31161 | @itemx -mno-as100-syntax | |
d77de738 ML |
31162 | When generating assembler output use a syntax that is compatible with |
31163 | Renesas's AS100 assembler. This syntax can also be handled by the GAS | |
31164 | assembler, but it has some restrictions so it is not generated by default. | |
31165 | ||
d77de738 | 31166 | @opindex mmax-constant-size |
ddf6fe37 | 31167 | @item -mmax-constant-size=@var{N} |
d77de738 ML |
31168 | Specifies the maximum size, in bytes, of a constant that can be used as |
31169 | an operand in a RX instruction. Although the RX instruction set does | |
31170 | allow constants of up to 4 bytes in length to be used in instructions, | |
31171 | a longer value equates to a longer instruction. Thus in some | |
31172 | circumstances it can be beneficial to restrict the size of constants | |
31173 | that are used in instructions. Constants that are too big are instead | |
31174 | placed into a constant pool and referenced via register indirection. | |
31175 | ||
31176 | The value @var{N} can be between 0 and 4. A value of 0 (the default) | |
31177 | or 4 means that constants of any size are allowed. | |
31178 | ||
d77de738 | 31179 | @opindex mrelax |
ddf6fe37 | 31180 | @item -mrelax |
d77de738 ML |
31181 | Enable linker relaxation. Linker relaxation is a process whereby the |
31182 | linker attempts to reduce the size of a program by finding shorter | |
31183 | versions of various instructions. Disabled by default. | |
31184 | ||
d77de738 | 31185 | @opindex mint-register |
ddf6fe37 | 31186 | @item -mint-register=@var{N} |
d77de738 ML |
31187 | Specify the number of registers to reserve for fast interrupt handler |
31188 | functions. The value @var{N} can be between 0 and 4. A value of 1 | |
31189 | means that register @code{r13} is reserved for the exclusive use | |
31190 | of fast interrupt handlers. A value of 2 reserves @code{r13} and | |
31191 | @code{r12}. A value of 3 reserves @code{r13}, @code{r12} and | |
31192 | @code{r11}, and a value of 4 reserves @code{r13} through @code{r10}. | |
31193 | A value of 0, the default, does not reserve any registers. | |
31194 | ||
d77de738 | 31195 | @opindex msave-acc-in-interrupts |
ddf6fe37 | 31196 | @item -msave-acc-in-interrupts |
d77de738 ML |
31197 | Specifies that interrupt handler functions should preserve the |
31198 | accumulator register. This is only necessary if normal code might use | |
31199 | the accumulator register, for example because it performs 64-bit | |
31200 | multiplications. The default is to ignore the accumulator as this | |
31201 | makes the interrupt handlers faster. | |
31202 | ||
d77de738 ML |
31203 | @opindex mpid |
31204 | @opindex mno-pid | |
ddf6fe37 AA |
31205 | @item -mpid |
31206 | @itemx -mno-pid | |
d77de738 ML |
31207 | Enables the generation of position independent data. When enabled any |
31208 | access to constant data is done via an offset from a base address | |
31209 | held in a register. This allows the location of constant data to be | |
31210 | determined at run time without requiring the executable to be | |
31211 | relocated, which is a benefit to embedded applications with tight | |
31212 | memory constraints. Data that can be modified is not affected by this | |
31213 | option. | |
31214 | ||
31215 | Note, using this feature reserves a register, usually @code{r13}, for | |
31216 | the constant data base address. This can result in slower and/or | |
31217 | larger code, especially in complicated functions. | |
31218 | ||
31219 | The actual register chosen to hold the constant data base address | |
31220 | depends upon whether the @option{-msmall-data-limit} and/or the | |
31221 | @option{-mint-register} command-line options are enabled. Starting | |
31222 | with register @code{r13} and proceeding downwards, registers are | |
31223 | allocated first to satisfy the requirements of @option{-mint-register}, | |
31224 | then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it | |
31225 | is possible for the small data area register to be @code{r8} if both | |
31226 | @option{-mint-register=4} and @option{-mpid} are specified on the | |
31227 | command line. | |
31228 | ||
31229 | By default this feature is not enabled. The default can be restored | |
31230 | via the @option{-mno-pid} command-line option. | |
31231 | ||
d77de738 ML |
31232 | @opindex mno-warn-multiple-fast-interrupts |
31233 | @opindex mwarn-multiple-fast-interrupts | |
ddf6fe37 AA |
31234 | @item -mno-warn-multiple-fast-interrupts |
31235 | @itemx -mwarn-multiple-fast-interrupts | |
d77de738 ML |
31236 | Prevents GCC from issuing a warning message if it finds more than one |
31237 | fast interrupt handler when it is compiling a file. The default is to | |
31238 | issue a warning for each extra fast interrupt handler found, as the RX | |
31239 | only supports one such interrupt. | |
31240 | ||
d77de738 ML |
31241 | @opindex mallow-string-insns |
31242 | @opindex mno-allow-string-insns | |
ddf6fe37 AA |
31243 | @item -mallow-string-insns |
31244 | @itemx -mno-allow-string-insns | |
d77de738 ML |
31245 | Enables or disables the use of the string manipulation instructions |
31246 | @code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL} | |
31247 | @code{SWHILE} and also the @code{RMPA} instruction. These | |
31248 | instructions may prefetch data, which is not safe to do if accessing | |
31249 | an I/O register. (See section 12.2.7 of the RX62N Group User's Manual | |
31250 | for more information). | |
31251 | ||
31252 | The default is to allow these instructions, but it is not possible for | |
31253 | GCC to reliably detect all circumstances where a string instruction | |
31254 | might be used to access an I/O register, so their use cannot be | |
31255 | disabled automatically. Instead it is reliant upon the programmer to | |
31256 | use the @option{-mno-allow-string-insns} option if their program | |
31257 | accesses I/O space. | |
31258 | ||
31259 | When the instructions are enabled GCC defines the C preprocessor | |
31260 | symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the | |
31261 | symbol @code{__RX_DISALLOW_STRING_INSNS__}. | |
31262 | ||
d77de738 ML |
31263 | @opindex mjsr |
31264 | @opindex mno-jsr | |
ddf6fe37 AA |
31265 | @item -mjsr |
31266 | @itemx -mno-jsr | |
d77de738 ML |
31267 | Use only (or not only) @code{JSR} instructions to access functions. |
31268 | This option can be used when code size exceeds the range of @code{BSR} | |
31269 | instructions. Note that @option{-mno-jsr} does not mean to not use | |
31270 | @code{JSR} but instead means that any type of branch may be used. | |
31271 | @end table | |
31272 | ||
31273 | @emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}} | |
31274 | has special significance to the RX port when used with the | |
31275 | @code{interrupt} function attribute. This attribute indicates a | |
31276 | function intended to process fast interrupts. GCC ensures | |
31277 | that it only uses the registers @code{r10}, @code{r11}, @code{r12} | |
31278 | and/or @code{r13} and only provided that the normal use of the | |
31279 | corresponding registers have been restricted via the | |
31280 | @option{-ffixed-@var{reg}} or @option{-mint-register} command-line | |
31281 | options. | |
31282 | ||
31283 | @node S/390 and zSeries Options | |
31284 | @subsection S/390 and zSeries Options | |
31285 | @cindex S/390 and zSeries Options | |
31286 | ||
31287 | These are the @samp{-m} options defined for the S/390 and zSeries architecture. | |
31288 | ||
31289 | @table @gcctabopt | |
d77de738 ML |
31290 | @opindex mhard-float |
31291 | @opindex msoft-float | |
ddf6fe37 AA |
31292 | @item -mhard-float |
31293 | @itemx -msoft-float | |
d77de738 ML |
31294 | Use (do not use) the hardware floating-point instructions and registers |
31295 | for floating-point operations. When @option{-msoft-float} is specified, | |
31296 | functions in @file{libgcc.a} are used to perform floating-point | |
31297 | operations. When @option{-mhard-float} is specified, the compiler | |
31298 | generates IEEE floating-point instructions. This is the default. | |
31299 | ||
d77de738 ML |
31300 | @opindex mhard-dfp |
31301 | @opindex mno-hard-dfp | |
ddf6fe37 AA |
31302 | @item -mhard-dfp |
31303 | @itemx -mno-hard-dfp | |
d77de738 ML |
31304 | Use (do not use) the hardware decimal-floating-point instructions for |
31305 | decimal-floating-point operations. When @option{-mno-hard-dfp} is | |
31306 | specified, functions in @file{libgcc.a} are used to perform | |
31307 | decimal-floating-point operations. When @option{-mhard-dfp} is | |
31308 | specified, the compiler generates decimal-floating-point hardware | |
31309 | instructions. This is the default for @option{-march=z9-ec} or higher. | |
31310 | ||
d77de738 ML |
31311 | @opindex mlong-double-64 |
31312 | @opindex mlong-double-128 | |
ddf6fe37 AA |
31313 | @item -mlong-double-64 |
31314 | @itemx -mlong-double-128 | |
d77de738 ML |
31315 | These switches control the size of @code{long double} type. A size |
31316 | of 64 bits makes the @code{long double} type equivalent to the @code{double} | |
31317 | type. This is the default. | |
31318 | ||
d77de738 ML |
31319 | @opindex mbackchain |
31320 | @opindex mno-backchain | |
ddf6fe37 AA |
31321 | @item -mbackchain |
31322 | @itemx -mno-backchain | |
d77de738 ML |
31323 | Store (do not store) the address of the caller's frame as backchain pointer |
31324 | into the callee's stack frame. | |
31325 | A backchain may be needed to allow debugging using tools that do not understand | |
31326 | DWARF call frame information. | |
31327 | When @option{-mno-packed-stack} is in effect, the backchain pointer is stored | |
31328 | at the bottom of the stack frame; when @option{-mpacked-stack} is in effect, | |
31329 | the backchain is placed into the topmost word of the 96/160 byte register | |
31330 | save area. | |
31331 | ||
31332 | In general, code compiled with @option{-mbackchain} is call-compatible with | |
31333 | code compiled with @option{-mno-backchain}; however, use of the backchain | |
31334 | for debugging purposes usually requires that the whole binary is built with | |
31335 | @option{-mbackchain}. Note that the combination of @option{-mbackchain}, | |
31336 | @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order | |
31337 | to build a linux kernel use @option{-msoft-float}. | |
31338 | ||
31339 | The default is to not maintain the backchain. | |
31340 | ||
d77de738 ML |
31341 | @opindex mpacked-stack |
31342 | @opindex mno-packed-stack | |
ddf6fe37 AA |
31343 | @item -mpacked-stack |
31344 | @itemx -mno-packed-stack | |
d77de738 ML |
31345 | Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is |
31346 | specified, the compiler uses the all fields of the 96/160 byte register save | |
31347 | area only for their default purpose; unused fields still take up stack space. | |
31348 | When @option{-mpacked-stack} is specified, register save slots are densely | |
31349 | packed at the top of the register save area; unused space is reused for other | |
31350 | purposes, allowing for more efficient use of the available stack space. | |
31351 | However, when @option{-mbackchain} is also in effect, the topmost word of | |
31352 | the save area is always used to store the backchain, and the return address | |
31353 | register is always saved two words below the backchain. | |
31354 | ||
31355 | As long as the stack frame backchain is not used, code generated with | |
31356 | @option{-mpacked-stack} is call-compatible with code generated with | |
31357 | @option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for | |
31358 | S/390 or zSeries generated code that uses the stack frame backchain at run | |
31359 | time, not just for debugging purposes. Such code is not call-compatible | |
31360 | with code compiled with @option{-mpacked-stack}. Also, note that the | |
31361 | combination of @option{-mbackchain}, | |
31362 | @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order | |
31363 | to build a linux kernel use @option{-msoft-float}. | |
31364 | ||
31365 | The default is to not use the packed stack layout. | |
31366 | ||
d77de738 ML |
31367 | @opindex msmall-exec |
31368 | @opindex mno-small-exec | |
ddf6fe37 AA |
31369 | @item -msmall-exec |
31370 | @itemx -mno-small-exec | |
d77de738 ML |
31371 | Generate (or do not generate) code using the @code{bras} instruction |
31372 | to do subroutine calls. | |
31373 | This only works reliably if the total executable size does not | |
31374 | exceed 64k. The default is to use the @code{basr} instruction instead, | |
31375 | which does not have this limitation. | |
31376 | ||
d77de738 ML |
31377 | @opindex m64 |
31378 | @opindex m31 | |
ddf6fe37 AA |
31379 | @item -m64 |
31380 | @itemx -m31 | |
d77de738 ML |
31381 | When @option{-m31} is specified, generate code compliant to the |
31382 | GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate | |
31383 | code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in | |
31384 | particular to generate 64-bit instructions. For the @samp{s390} | |
31385 | targets, the default is @option{-m31}, while the @samp{s390x} | |
31386 | targets default to @option{-m64}. | |
31387 | ||
d77de738 ML |
31388 | @opindex mzarch |
31389 | @opindex mesa | |
ddf6fe37 AA |
31390 | @item -mzarch |
31391 | @itemx -mesa | |
d77de738 ML |
31392 | When @option{-mzarch} is specified, generate code using the |
31393 | instructions available on z/Architecture. | |
31394 | When @option{-mesa} is specified, generate code using the | |
31395 | instructions available on ESA/390. Note that @option{-mesa} is | |
31396 | not possible with @option{-m64}. | |
31397 | When generating code compliant to the GNU/Linux for S/390 ABI, | |
31398 | the default is @option{-mesa}. When generating code compliant | |
31399 | to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}. | |
31400 | ||
d77de738 ML |
31401 | @opindex mhtm |
31402 | @opindex mno-htm | |
ddf6fe37 AA |
31403 | @item -mhtm |
31404 | @itemx -mno-htm | |
d77de738 ML |
31405 | The @option{-mhtm} option enables a set of builtins making use of |
31406 | instructions available with the transactional execution facility | |
31407 | introduced with the IBM zEnterprise EC12 machine generation | |
31408 | @ref{S/390 System z Built-in Functions}. | |
31409 | @option{-mhtm} is enabled by default when using @option{-march=zEC12}. | |
31410 | ||
d77de738 ML |
31411 | @opindex mvx |
31412 | @opindex mno-vx | |
ddf6fe37 AA |
31413 | @item -mvx |
31414 | @itemx -mno-vx | |
d77de738 ML |
31415 | When @option{-mvx} is specified, generate code using the instructions |
31416 | available with the vector extension facility introduced with the IBM | |
31417 | z13 machine generation. | |
31418 | This option changes the ABI for some vector type values with regard to | |
31419 | alignment and calling conventions. In case vector type values are | |
31420 | being used in an ABI-relevant context a GAS @samp{.gnu_attribute} | |
31421 | command will be added to mark the resulting binary with the ABI used. | |
31422 | @option{-mvx} is enabled by default when using @option{-march=z13}. | |
31423 | ||
d77de738 ML |
31424 | @opindex mzvector |
31425 | @opindex mno-zvector | |
ddf6fe37 AA |
31426 | @item -mzvector |
31427 | @itemx -mno-zvector | |
d77de738 ML |
31428 | The @option{-mzvector} option enables vector language extensions and |
31429 | builtins using instructions available with the vector extension | |
31430 | facility introduced with the IBM z13 machine generation. | |
31431 | This option adds support for @samp{vector} to be used as a keyword to | |
31432 | define vector type variables and arguments. @samp{vector} is only | |
31433 | available when GNU extensions are enabled. It will not be expanded | |
31434 | when requesting strict standard compliance e.g.@: with @option{-std=c99}. | |
31435 | In addition to the GCC low-level builtins @option{-mzvector} enables | |
31436 | a set of builtins added for compatibility with AltiVec-style | |
31437 | implementations like Power and Cell. In order to make use of these | |
31438 | builtins the header file @file{vecintrin.h} needs to be included. | |
31439 | @option{-mzvector} is disabled by default. | |
31440 | ||
d77de738 ML |
31441 | @opindex mmvcle |
31442 | @opindex mno-mvcle | |
ddf6fe37 AA |
31443 | @item -mmvcle |
31444 | @itemx -mno-mvcle | |
d77de738 ML |
31445 | Generate (or do not generate) code using the @code{mvcle} instruction |
31446 | to perform block moves. When @option{-mno-mvcle} is specified, | |
31447 | use a @code{mvc} loop instead. This is the default unless optimizing for | |
31448 | size. | |
31449 | ||
d77de738 ML |
31450 | @opindex mdebug |
31451 | @opindex mno-debug | |
ddf6fe37 AA |
31452 | @item -mdebug |
31453 | @itemx -mno-debug | |
d77de738 ML |
31454 | Print (or do not print) additional debug information when compiling. |
31455 | The default is to not print debug information. | |
31456 | ||
d77de738 | 31457 | @opindex march |
ddf6fe37 | 31458 | @item -march=@var{cpu-type} |
d77de738 ML |
31459 | Generate code that runs on @var{cpu-type}, which is the name of a |
31460 | system representing a certain processor type. Possible values for | |
31461 | @var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6}, | |
31462 | @samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8}, | |
31463 | @samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11}, | |
31464 | @samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13}, | |
31465 | @samp{z16}/@samp{arch14}, and @samp{native}. | |
31466 | ||
31467 | The default is @option{-march=z900}. | |
31468 | ||
31469 | Specifying @samp{native} as cpu type can be used to select the best | |
31470 | architecture option for the host processor. | |
31471 | @option{-march=native} has no effect if GCC does not recognize the | |
31472 | processor. | |
31473 | ||
d77de738 | 31474 | @opindex mtune |
ddf6fe37 | 31475 | @item -mtune=@var{cpu-type} |
d77de738 ML |
31476 | Tune to @var{cpu-type} everything applicable about the generated code, |
31477 | except for the ABI and the set of available instructions. | |
31478 | The list of @var{cpu-type} values is the same as for @option{-march}. | |
31479 | The default is the value used for @option{-march}. | |
31480 | ||
d77de738 ML |
31481 | @opindex mtpf-trace |
31482 | @opindex mno-tpf-trace | |
ddf6fe37 AA |
31483 | @item -mtpf-trace |
31484 | @itemx -mno-tpf-trace | |
d77de738 ML |
31485 | Generate code that adds (does not add) in TPF OS specific branches to trace |
31486 | routines in the operating system. This option is off by default, even | |
31487 | when compiling for the TPF OS@. | |
31488 | ||
d77de738 ML |
31489 | @opindex mtpf-trace-skip |
31490 | @opindex mno-tpf-trace-skip | |
ddf6fe37 AA |
31491 | @item -mtpf-trace-skip |
31492 | @itemx -mno-tpf-trace-skip | |
d77de738 ML |
31493 | Generate code that changes (does not change) the default branch |
31494 | targets enabled by @option{-mtpf-trace} to point to specialized trace | |
31495 | routines providing the ability of selectively skipping function trace | |
31496 | entries for the TPF OS. This option is off by default, even when | |
31497 | compiling for the TPF OS and specifying @option{-mtpf-trace}. | |
31498 | ||
d77de738 ML |
31499 | @opindex mfused-madd |
31500 | @opindex mno-fused-madd | |
ddf6fe37 AA |
31501 | @item -mfused-madd |
31502 | @itemx -mno-fused-madd | |
d77de738 ML |
31503 | Generate code that uses (does not use) the floating-point multiply and |
31504 | accumulate instructions. These instructions are generated by default if | |
31505 | hardware floating point is used. | |
31506 | ||
d77de738 | 31507 | @opindex mwarn-framesize |
ddf6fe37 | 31508 | @item -mwarn-framesize=@var{framesize} |
d77de738 ML |
31509 | Emit a warning if the current function exceeds the given frame size. Because |
31510 | this is a compile-time check it doesn't need to be a real problem when the program | |
31511 | runs. It is intended to identify functions that most probably cause | |
31512 | a stack overflow. It is useful to be used in an environment with limited stack | |
31513 | size e.g.@: the linux kernel. | |
31514 | ||
d77de738 | 31515 | @opindex mwarn-dynamicstack |
ddf6fe37 | 31516 | @item -mwarn-dynamicstack |
d77de738 ML |
31517 | Emit a warning if the function calls @code{alloca} or uses dynamically-sized |
31518 | arrays. This is generally a bad idea with a limited stack size. | |
31519 | ||
d77de738 ML |
31520 | @opindex mstack-guard |
31521 | @opindex mstack-size | |
ddf6fe37 AA |
31522 | @item -mstack-guard=@var{stack-guard} |
31523 | @itemx -mstack-size=@var{stack-size} | |
d77de738 ML |
31524 | If these options are provided the S/390 back end emits additional instructions in |
31525 | the function prologue that trigger a trap if the stack size is @var{stack-guard} | |
31526 | bytes above the @var{stack-size} (remember that the stack on S/390 grows downward). | |
31527 | If the @var{stack-guard} option is omitted the smallest power of 2 larger than | |
31528 | the frame size of the compiled function is chosen. | |
31529 | These options are intended to be used to help debugging stack overflow problems. | |
31530 | The additionally emitted code causes only little overhead and hence can also be | |
31531 | used in production-like systems without greater performance degradation. The given | |
31532 | values have to be exact powers of 2 and @var{stack-size} has to be greater than | |
31533 | @var{stack-guard} without exceeding 64k. | |
31534 | In order to be efficient the extra code makes the assumption that the stack starts | |
31535 | at an address aligned to the value given by @var{stack-size}. | |
31536 | The @var{stack-guard} option can only be used in conjunction with @var{stack-size}. | |
31537 | ||
d77de738 | 31538 | @opindex mhotpatch |
ddf6fe37 | 31539 | @item -mhotpatch=@var{pre-halfwords},@var{post-halfwords} |
d77de738 ML |
31540 | If the hotpatch option is enabled, a ``hot-patching'' function |
31541 | prologue is generated for all functions in the compilation unit. | |
31542 | The funtion label is prepended with the given number of two-byte | |
31543 | NOP instructions (@var{pre-halfwords}, maximum 1000000). After | |
31544 | the label, 2 * @var{post-halfwords} bytes are appended, using the | |
31545 | largest NOP like instructions the architecture allows (maximum | |
31546 | 1000000). | |
31547 | ||
31548 | If both arguments are zero, hotpatching is disabled. | |
31549 | ||
31550 | This option can be overridden for individual functions with the | |
31551 | @code{hotpatch} attribute. | |
31552 | @end table | |
31553 | ||
d77de738 ML |
31554 | @node SH Options |
31555 | @subsection SH Options | |
31556 | ||
31557 | These @samp{-m} options are defined for the SH implementations: | |
31558 | ||
31559 | @table @gcctabopt | |
d77de738 | 31560 | @opindex m1 |
ddf6fe37 | 31561 | @item -m1 |
d77de738 ML |
31562 | Generate code for the SH1. |
31563 | ||
d77de738 | 31564 | @opindex m2 |
ddf6fe37 | 31565 | @item -m2 |
d77de738 ML |
31566 | Generate code for the SH2. |
31567 | ||
31568 | @item -m2e | |
31569 | Generate code for the SH2e. | |
31570 | ||
d77de738 | 31571 | @opindex m2a-nofpu |
ddf6fe37 | 31572 | @item -m2a-nofpu |
d77de738 ML |
31573 | Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way |
31574 | that the floating-point unit is not used. | |
31575 | ||
d77de738 | 31576 | @opindex m2a-single-only |
ddf6fe37 | 31577 | @item -m2a-single-only |
d77de738 ML |
31578 | Generate code for the SH2a-FPU, in such a way that no double-precision |
31579 | floating-point operations are used. | |
31580 | ||
d77de738 | 31581 | @opindex m2a-single |
ddf6fe37 | 31582 | @item -m2a-single |
d77de738 ML |
31583 | Generate code for the SH2a-FPU assuming the floating-point unit is in |
31584 | single-precision mode by default. | |
31585 | ||
d77de738 | 31586 | @opindex m2a |
ddf6fe37 | 31587 | @item -m2a |
d77de738 ML |
31588 | Generate code for the SH2a-FPU assuming the floating-point unit is in |
31589 | double-precision mode by default. | |
31590 | ||
d77de738 | 31591 | @opindex m3 |
ddf6fe37 | 31592 | @item -m3 |
d77de738 ML |
31593 | Generate code for the SH3. |
31594 | ||
d77de738 | 31595 | @opindex m3e |
ddf6fe37 | 31596 | @item -m3e |
d77de738 ML |
31597 | Generate code for the SH3e. |
31598 | ||
d77de738 | 31599 | @opindex m4-nofpu |
ddf6fe37 | 31600 | @item -m4-nofpu |
d77de738 ML |
31601 | Generate code for the SH4 without a floating-point unit. |
31602 | ||
d77de738 | 31603 | @opindex m4-single-only |
ddf6fe37 | 31604 | @item -m4-single-only |
d77de738 ML |
31605 | Generate code for the SH4 with a floating-point unit that only |
31606 | supports single-precision arithmetic. | |
31607 | ||
d77de738 | 31608 | @opindex m4-single |
ddf6fe37 | 31609 | @item -m4-single |
d77de738 ML |
31610 | Generate code for the SH4 assuming the floating-point unit is in |
31611 | single-precision mode by default. | |
31612 | ||
d77de738 | 31613 | @opindex m4 |
ddf6fe37 | 31614 | @item -m4 |
d77de738 ML |
31615 | Generate code for the SH4. |
31616 | ||
d77de738 | 31617 | @opindex m4-100 |
ddf6fe37 | 31618 | @item -m4-100 |
d77de738 ML |
31619 | Generate code for SH4-100. |
31620 | ||
d77de738 | 31621 | @opindex m4-100-nofpu |
ddf6fe37 | 31622 | @item -m4-100-nofpu |
d77de738 ML |
31623 | Generate code for SH4-100 in such a way that the |
31624 | floating-point unit is not used. | |
31625 | ||
d77de738 | 31626 | @opindex m4-100-single |
ddf6fe37 | 31627 | @item -m4-100-single |
d77de738 ML |
31628 | Generate code for SH4-100 assuming the floating-point unit is in |
31629 | single-precision mode by default. | |
31630 | ||
d77de738 | 31631 | @opindex m4-100-single-only |
ddf6fe37 | 31632 | @item -m4-100-single-only |
d77de738 ML |
31633 | Generate code for SH4-100 in such a way that no double-precision |
31634 | floating-point operations are used. | |
31635 | ||
d77de738 | 31636 | @opindex m4-200 |
ddf6fe37 | 31637 | @item -m4-200 |
d77de738 ML |
31638 | Generate code for SH4-200. |
31639 | ||
d77de738 | 31640 | @opindex m4-200-nofpu |
ddf6fe37 | 31641 | @item -m4-200-nofpu |
d77de738 ML |
31642 | Generate code for SH4-200 without in such a way that the |
31643 | floating-point unit is not used. | |
31644 | ||
d77de738 | 31645 | @opindex m4-200-single |
ddf6fe37 | 31646 | @item -m4-200-single |
d77de738 ML |
31647 | Generate code for SH4-200 assuming the floating-point unit is in |
31648 | single-precision mode by default. | |
31649 | ||
d77de738 | 31650 | @opindex m4-200-single-only |
ddf6fe37 | 31651 | @item -m4-200-single-only |
d77de738 ML |
31652 | Generate code for SH4-200 in such a way that no double-precision |
31653 | floating-point operations are used. | |
31654 | ||
d77de738 | 31655 | @opindex m4-300 |
ddf6fe37 | 31656 | @item -m4-300 |
d77de738 ML |
31657 | Generate code for SH4-300. |
31658 | ||
d77de738 | 31659 | @opindex m4-300-nofpu |
ddf6fe37 | 31660 | @item -m4-300-nofpu |
d77de738 ML |
31661 | Generate code for SH4-300 without in such a way that the |
31662 | floating-point unit is not used. | |
31663 | ||
d77de738 | 31664 | @opindex m4-300-single |
ddf6fe37 | 31665 | @item -m4-300-single |
d77de738 ML |
31666 | Generate code for SH4-300 in such a way that no double-precision |
31667 | floating-point operations are used. | |
31668 | ||
d77de738 | 31669 | @opindex m4-300-single-only |
ddf6fe37 | 31670 | @item -m4-300-single-only |
d77de738 ML |
31671 | Generate code for SH4-300 in such a way that no double-precision |
31672 | floating-point operations are used. | |
31673 | ||
d77de738 | 31674 | @opindex m4-340 |
ddf6fe37 | 31675 | @item -m4-340 |
d77de738 ML |
31676 | Generate code for SH4-340 (no MMU, no FPU). |
31677 | ||
d77de738 | 31678 | @opindex m4-500 |
ddf6fe37 | 31679 | @item -m4-500 |
d77de738 ML |
31680 | Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the |
31681 | assembler. | |
31682 | ||
d77de738 | 31683 | @opindex m4a-nofpu |
ddf6fe37 | 31684 | @item -m4a-nofpu |
d77de738 ML |
31685 | Generate code for the SH4al-dsp, or for a SH4a in such a way that the |
31686 | floating-point unit is not used. | |
31687 | ||
d77de738 | 31688 | @opindex m4a-single-only |
ddf6fe37 | 31689 | @item -m4a-single-only |
d77de738 ML |
31690 | Generate code for the SH4a, in such a way that no double-precision |
31691 | floating-point operations are used. | |
31692 | ||
d77de738 | 31693 | @opindex m4a-single |
ddf6fe37 | 31694 | @item -m4a-single |
d77de738 ML |
31695 | Generate code for the SH4a assuming the floating-point unit is in |
31696 | single-precision mode by default. | |
31697 | ||
d77de738 | 31698 | @opindex m4a |
ddf6fe37 | 31699 | @item -m4a |
d77de738 ML |
31700 | Generate code for the SH4a. |
31701 | ||
d77de738 | 31702 | @opindex m4al |
ddf6fe37 | 31703 | @item -m4al |
d77de738 ML |
31704 | Same as @option{-m4a-nofpu}, except that it implicitly passes |
31705 | @option{-dsp} to the assembler. GCC doesn't generate any DSP | |
31706 | instructions at the moment. | |
31707 | ||
d77de738 | 31708 | @opindex mb |
ddf6fe37 | 31709 | @item -mb |
d77de738 ML |
31710 | Compile code for the processor in big-endian mode. |
31711 | ||
d77de738 | 31712 | @opindex ml |
ddf6fe37 | 31713 | @item -ml |
d77de738 ML |
31714 | Compile code for the processor in little-endian mode. |
31715 | ||
d77de738 | 31716 | @opindex mdalign |
ddf6fe37 | 31717 | @item -mdalign |
d77de738 ML |
31718 | Align doubles at 64-bit boundaries. Note that this changes the calling |
31719 | conventions, and thus some functions from the standard C library do | |
31720 | not work unless you recompile it first with @option{-mdalign}. | |
31721 | ||
d77de738 | 31722 | @opindex mrelax |
ddf6fe37 | 31723 | @item -mrelax |
d77de738 ML |
31724 | Shorten some address references at link time, when possible; uses the |
31725 | linker option @option{-relax}. | |
31726 | ||
d77de738 | 31727 | @opindex mbigtable |
ddf6fe37 | 31728 | @item -mbigtable |
d77de738 ML |
31729 | Use 32-bit offsets in @code{switch} tables. The default is to use |
31730 | 16-bit offsets. | |
31731 | ||
d77de738 | 31732 | @opindex mbitops |
ddf6fe37 | 31733 | @item -mbitops |
d77de738 ML |
31734 | Enable the use of bit manipulation instructions on SH2A. |
31735 | ||
d77de738 | 31736 | @opindex mfmovd |
ddf6fe37 | 31737 | @item -mfmovd |
d77de738 ML |
31738 | Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for |
31739 | alignment constraints. | |
31740 | ||
d77de738 | 31741 | @opindex mrenesas |
ddf6fe37 | 31742 | @item -mrenesas |
d77de738 ML |
31743 | Comply with the calling conventions defined by Renesas. |
31744 | ||
d77de738 | 31745 | @opindex mno-renesas |
ddf6fe37 | 31746 | @item -mno-renesas |
d77de738 ML |
31747 | Comply with the calling conventions defined for GCC before the Renesas |
31748 | conventions were available. This option is the default for all | |
31749 | targets of the SH toolchain. | |
31750 | ||
d77de738 | 31751 | @opindex mnomacsave |
ddf6fe37 | 31752 | @item -mnomacsave |
d77de738 ML |
31753 | Mark the @code{MAC} register as call-clobbered, even if |
31754 | @option{-mrenesas} is given. | |
31755 | ||
d77de738 ML |
31756 | @opindex mieee |
31757 | @opindex mno-ieee | |
ddf6fe37 AA |
31758 | @item -mieee |
31759 | @itemx -mno-ieee | |
d77de738 ML |
31760 | Control the IEEE compliance of floating-point comparisons, which affects the |
31761 | handling of cases where the result of a comparison is unordered. By default | |
31762 | @option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is | |
31763 | enabled @option{-mno-ieee} is implicitly set, which results in faster | |
31764 | floating-point greater-equal and less-equal comparisons. The implicit settings | |
31765 | can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}. | |
31766 | ||
d77de738 | 31767 | @opindex minline-ic_invalidate |
ddf6fe37 | 31768 | @item -minline-ic_invalidate |
d77de738 ML |
31769 | Inline code to invalidate instruction cache entries after setting up |
31770 | nested function trampolines. | |
31771 | This option has no effect if @option{-musermode} is in effect and the selected | |
31772 | code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi} | |
31773 | instruction. | |
31774 | If the selected code generation option does not allow the use of the @code{icbi} | |
31775 | instruction, and @option{-musermode} is not in effect, the inlined code | |
31776 | manipulates the instruction cache address array directly with an associative | |
31777 | write. This not only requires privileged mode at run time, but it also | |
31778 | fails if the cache line had been mapped via the TLB and has become unmapped. | |
31779 | ||
d77de738 | 31780 | @opindex misize |
ddf6fe37 | 31781 | @item -misize |
d77de738 ML |
31782 | Dump instruction size and location in the assembly code. |
31783 | ||
d77de738 | 31784 | @opindex mpadstruct |
ddf6fe37 | 31785 | @item -mpadstruct |
d77de738 ML |
31786 | This option is deprecated. It pads structures to multiple of 4 bytes, |
31787 | which is incompatible with the SH ABI@. | |
31788 | ||
d77de738 | 31789 | @opindex matomic-model=@var{model} |
ddf6fe37 | 31790 | @item -matomic-model=@var{model} |
d77de738 ML |
31791 | Sets the model of atomic operations and additional parameters as a comma |
31792 | separated list. For details on the atomic built-in functions see | |
31793 | @ref{__atomic Builtins}. The following models and parameters are supported: | |
31794 | ||
31795 | @table @samp | |
31796 | ||
31797 | @item none | |
31798 | Disable compiler generated atomic sequences and emit library calls for atomic | |
31799 | operations. This is the default if the target is not @code{sh*-*-linux*}. | |
31800 | ||
31801 | @item soft-gusa | |
31802 | Generate GNU/Linux compatible gUSA software atomic sequences for the atomic | |
31803 | built-in functions. The generated atomic sequences require additional support | |
31804 | from the interrupt/exception handling code of the system and are only suitable | |
31805 | for SH3* and SH4* single-core systems. This option is enabled by default when | |
31806 | the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A, | |
31807 | this option also partially utilizes the hardware atomic instructions | |
31808 | @code{movli.l} and @code{movco.l} to create more efficient code, unless | |
31809 | @samp{strict} is specified. | |
31810 | ||
31811 | @item soft-tcb | |
31812 | Generate software atomic sequences that use a variable in the thread control | |
31813 | block. This is a variation of the gUSA sequences which can also be used on | |
31814 | SH1* and SH2* targets. The generated atomic sequences require additional | |
31815 | support from the interrupt/exception handling code of the system and are only | |
31816 | suitable for single-core systems. When using this model, the @samp{gbr-offset=} | |
31817 | parameter has to be specified as well. | |
31818 | ||
31819 | @item soft-imask | |
31820 | Generate software atomic sequences that temporarily disable interrupts by | |
31821 | setting @code{SR.IMASK = 1111}. This model works only when the program runs | |
31822 | in privileged mode and is only suitable for single-core systems. Additional | |
31823 | support from the interrupt/exception handling code of the system is not | |
31824 | required. This model is enabled by default when the target is | |
31825 | @code{sh*-*-linux*} and SH1* or SH2*. | |
31826 | ||
31827 | @item hard-llcs | |
31828 | Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l} | |
31829 | instructions only. This is only available on SH4A and is suitable for | |
31830 | multi-core systems. Since the hardware instructions support only 32 bit atomic | |
31831 | variables access to 8 or 16 bit variables is emulated with 32 bit accesses. | |
31832 | Code compiled with this option is also compatible with other software | |
31833 | atomic model interrupt/exception handling systems if executed on an SH4A | |
31834 | system. Additional support from the interrupt/exception handling code of the | |
31835 | system is not required for this model. | |
31836 | ||
31837 | @item gbr-offset= | |
31838 | This parameter specifies the offset in bytes of the variable in the thread | |
31839 | control block structure that should be used by the generated atomic sequences | |
31840 | when the @samp{soft-tcb} model has been selected. For other models this | |
31841 | parameter is ignored. The specified value must be an integer multiple of four | |
31842 | and in the range 0-1020. | |
31843 | ||
31844 | @item strict | |
31845 | This parameter prevents mixed usage of multiple atomic models, even if they | |
31846 | are compatible, and makes the compiler generate atomic sequences of the | |
31847 | specified model only. | |
31848 | ||
31849 | @end table | |
31850 | ||
d77de738 | 31851 | @opindex mtas |
ddf6fe37 | 31852 | @item -mtas |
d77de738 ML |
31853 | Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}. |
31854 | Notice that depending on the particular hardware and software configuration | |
31855 | this can degrade overall performance due to the operand cache line flushes | |
31856 | that are implied by the @code{tas.b} instruction. On multi-core SH4A | |
31857 | processors the @code{tas.b} instruction must be used with caution since it | |
31858 | can result in data corruption for certain cache configurations. | |
31859 | ||
d77de738 | 31860 | @opindex mprefergot |
ddf6fe37 | 31861 | @item -mprefergot |
d77de738 ML |
31862 | When generating position-independent code, emit function calls using |
31863 | the Global Offset Table instead of the Procedure Linkage Table. | |
31864 | ||
d77de738 ML |
31865 | @opindex musermode |
31866 | @opindex mno-usermode | |
ddf6fe37 AA |
31867 | @item -musermode |
31868 | @itemx -mno-usermode | |
d77de738 ML |
31869 | Don't allow (allow) the compiler generating privileged mode code. Specifying |
31870 | @option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the | |
31871 | inlined code would not work in user mode. @option{-musermode} is the default | |
31872 | when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2* | |
31873 | @option{-musermode} has no effect, since there is no user mode. | |
31874 | ||
d77de738 | 31875 | @opindex multcost=@var{number} |
ddf6fe37 | 31876 | @item -multcost=@var{number} |
d77de738 ML |
31877 | Set the cost to assume for a multiply insn. |
31878 | ||
d77de738 | 31879 | @opindex mdiv=@var{strategy} |
ddf6fe37 | 31880 | @item -mdiv=@var{strategy} |
d77de738 ML |
31881 | Set the division strategy to be used for integer division operations. |
31882 | @var{strategy} can be one of: | |
31883 | ||
31884 | @table @samp | |
31885 | ||
31886 | @item call-div1 | |
31887 | Calls a library function that uses the single-step division instruction | |
31888 | @code{div1} to perform the operation. Division by zero calculates an | |
31889 | unspecified result and does not trap. This is the default except for SH4, | |
31890 | SH2A and SHcompact. | |
31891 | ||
31892 | @item call-fp | |
31893 | Calls a library function that performs the operation in double precision | |
31894 | floating point. Division by zero causes a floating-point exception. This is | |
31895 | the default for SHcompact with FPU. Specifying this for targets that do not | |
31896 | have a double precision FPU defaults to @code{call-div1}. | |
31897 | ||
31898 | @item call-table | |
31899 | Calls a library function that uses a lookup table for small divisors and | |
31900 | the @code{div1} instruction with case distinction for larger divisors. Division | |
31901 | by zero calculates an unspecified result and does not trap. This is the default | |
31902 | for SH4. Specifying this for targets that do not have dynamic shift | |
31903 | instructions defaults to @code{call-div1}. | |
31904 | ||
31905 | @end table | |
31906 | ||
31907 | When a division strategy has not been specified the default strategy is | |
31908 | selected based on the current target. For SH2A the default strategy is to | |
31909 | use the @code{divs} and @code{divu} instructions instead of library function | |
31910 | calls. | |
31911 | ||
d77de738 | 31912 | @opindex maccumulate-outgoing-args |
ddf6fe37 | 31913 | @item -maccumulate-outgoing-args |
d77de738 ML |
31914 | Reserve space once for outgoing arguments in the function prologue rather |
31915 | than around each call. Generally beneficial for performance and size. Also | |
31916 | needed for unwinding to avoid changing the stack frame around conditional code. | |
31917 | ||
d77de738 | 31918 | @opindex mdivsi3_libfunc=@var{name} |
ddf6fe37 | 31919 | @item -mdivsi3_libfunc=@var{name} |
d77de738 ML |
31920 | Set the name of the library function used for 32-bit signed division to |
31921 | @var{name}. | |
31922 | This only affects the name used in the @samp{call} division strategies, and | |
31923 | the compiler still expects the same sets of input/output/clobbered registers as | |
31924 | if this option were not present. | |
31925 | ||
d77de738 | 31926 | @opindex mfixed-range |
ddf6fe37 | 31927 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
31928 | Generate code treating the given register range as fixed registers. |
31929 | A fixed register is one that the register allocator cannot use. This is | |
31930 | useful when compiling kernel code. A register range is specified as | |
31931 | two registers separated by a dash. Multiple register ranges can be | |
31932 | specified separated by a comma. | |
31933 | ||
d77de738 | 31934 | @opindex mbranch-cost=@var{num} |
ddf6fe37 | 31935 | @item -mbranch-cost=@var{num} |
d77de738 ML |
31936 | Assume @var{num} to be the cost for a branch instruction. Higher numbers |
31937 | make the compiler try to generate more branch-free code if possible. | |
31938 | If not specified the value is selected depending on the processor type that | |
31939 | is being compiled for. | |
31940 | ||
d77de738 ML |
31941 | @opindex mzdcbranch |
31942 | @opindex mno-zdcbranch | |
ddf6fe37 AA |
31943 | @item -mzdcbranch |
31944 | @itemx -mno-zdcbranch | |
d77de738 ML |
31945 | Assume (do not assume) that zero displacement conditional branch instructions |
31946 | @code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the | |
31947 | compiler prefers zero displacement branch code sequences. This is | |
31948 | enabled by default when generating code for SH4 and SH4A. It can be explicitly | |
31949 | disabled by specifying @option{-mno-zdcbranch}. | |
31950 | ||
d77de738 | 31951 | @opindex mcbranch-force-delay-slot |
ddf6fe37 | 31952 | @item -mcbranch-force-delay-slot |
d77de738 ML |
31953 | Force the usage of delay slots for conditional branches, which stuffs the delay |
31954 | slot with a @code{nop} if a suitable instruction cannot be found. By default | |
31955 | this option is disabled. It can be enabled to work around hardware bugs as | |
31956 | found in the original SH7055. | |
31957 | ||
d77de738 ML |
31958 | @opindex mfused-madd |
31959 | @opindex mno-fused-madd | |
ddf6fe37 AA |
31960 | @item -mfused-madd |
31961 | @itemx -mno-fused-madd | |
d77de738 ML |
31962 | Generate code that uses (does not use) the floating-point multiply and |
31963 | accumulate instructions. These instructions are generated by default | |
31964 | if hardware floating point is used. The machine-dependent | |
31965 | @option{-mfused-madd} option is now mapped to the machine-independent | |
31966 | @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is | |
31967 | mapped to @option{-ffp-contract=off}. | |
31968 | ||
d77de738 ML |
31969 | @opindex mfsca |
31970 | @opindex mno-fsca | |
ddf6fe37 AA |
31971 | @item -mfsca |
31972 | @itemx -mno-fsca | |
d77de738 ML |
31973 | Allow or disallow the compiler to emit the @code{fsca} instruction for sine |
31974 | and cosine approximations. The option @option{-mfsca} must be used in | |
31975 | combination with @option{-funsafe-math-optimizations}. It is enabled by default | |
31976 | when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine | |
31977 | approximations even if @option{-funsafe-math-optimizations} is in effect. | |
31978 | ||
d77de738 ML |
31979 | @opindex mfsrra |
31980 | @opindex mno-fsrra | |
ddf6fe37 AA |
31981 | @item -mfsrra |
31982 | @itemx -mno-fsrra | |
d77de738 ML |
31983 | Allow or disallow the compiler to emit the @code{fsrra} instruction for |
31984 | reciprocal square root approximations. The option @option{-mfsrra} must be used | |
31985 | in combination with @option{-funsafe-math-optimizations} and | |
31986 | @option{-ffinite-math-only}. It is enabled by default when generating code for | |
31987 | SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations | |
31988 | even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are | |
31989 | in effect. | |
31990 | ||
d77de738 | 31991 | @opindex mpretend-cmove |
ddf6fe37 | 31992 | @item -mpretend-cmove |
d77de738 ML |
31993 | Prefer zero-displacement conditional branches for conditional move instruction |
31994 | patterns. This can result in faster code on the SH4 processor. | |
31995 | ||
d77de738 | 31996 | @opindex fdpic |
ddf6fe37 | 31997 | @item -mfdpic |
d77de738 ML |
31998 | Generate code using the FDPIC ABI. |
31999 | ||
32000 | @end table | |
32001 | ||
32002 | @node Solaris 2 Options | |
32003 | @subsection Solaris 2 Options | |
32004 | @cindex Solaris 2 options | |
32005 | ||
32006 | These @samp{-m} options are supported on Solaris 2: | |
32007 | ||
32008 | @table @gcctabopt | |
d77de738 | 32009 | @opindex mclear-hwcap |
ddf6fe37 | 32010 | @item -mclear-hwcap |
d77de738 ML |
32011 | @option{-mclear-hwcap} tells the compiler to remove the hardware |
32012 | capabilities generated by the Solaris assembler. This is only necessary | |
32013 | when object files use ISA extensions not supported by the current | |
32014 | machine, but check at runtime whether or not to use them. | |
32015 | ||
d77de738 | 32016 | @opindex mimpure-text |
ddf6fe37 | 32017 | @item -mimpure-text |
d77de738 ML |
32018 | @option{-mimpure-text}, used in addition to @option{-shared}, tells |
32019 | the compiler to not pass @option{-z text} to the linker when linking a | |
32020 | shared object. Using this option, you can link position-dependent | |
32021 | code into a shared object. | |
32022 | ||
32023 | @option{-mimpure-text} suppresses the ``relocations remain against | |
32024 | allocatable but non-writable sections'' linker error message. | |
32025 | However, the necessary relocations trigger copy-on-write, and the | |
32026 | shared object is not actually shared across processes. Instead of | |
32027 | using @option{-mimpure-text}, you should compile all source code with | |
32028 | @option{-fpic} or @option{-fPIC}. | |
32029 | ||
32030 | @end table | |
32031 | ||
32032 | These switches are supported in addition to the above on Solaris 2: | |
32033 | ||
32034 | @table @gcctabopt | |
d77de738 | 32035 | @opindex pthreads |
ddf6fe37 | 32036 | @item -pthreads |
d77de738 ML |
32037 | This is a synonym for @option{-pthread}. |
32038 | @end table | |
32039 | ||
32040 | @node SPARC Options | |
32041 | @subsection SPARC Options | |
32042 | @cindex SPARC options | |
32043 | ||
32044 | These @samp{-m} options are supported on the SPARC: | |
32045 | ||
32046 | @table @gcctabopt | |
d77de738 ML |
32047 | @opindex mno-app-regs |
32048 | @opindex mapp-regs | |
ddf6fe37 AA |
32049 | @item -mno-app-regs |
32050 | @itemx -mapp-regs | |
d77de738 ML |
32051 | Specify @option{-mapp-regs} to generate output using the global registers |
32052 | 2 through 4, which the SPARC SVR4 ABI reserves for applications. Like the | |
32053 | global register 1, each global register 2 through 4 is then treated as an | |
32054 | allocable register that is clobbered by function calls. This is the default. | |
32055 | ||
32056 | To be fully SVR4 ABI-compliant at the cost of some performance loss, | |
32057 | specify @option{-mno-app-regs}. You should compile libraries and system | |
32058 | software with this option. | |
32059 | ||
d77de738 ML |
32060 | @opindex mflat |
32061 | @opindex mno-flat | |
ddf6fe37 AA |
32062 | @item -mflat |
32063 | @itemx -mno-flat | |
d77de738 ML |
32064 | With @option{-mflat}, the compiler does not generate save/restore instructions |
32065 | and uses a ``flat'' or single register window model. This model is compatible | |
32066 | with the regular register window model. The local registers and the input | |
32067 | registers (0--5) are still treated as ``call-saved'' registers and are | |
32068 | saved on the stack as needed. | |
32069 | ||
32070 | With @option{-mno-flat} (the default), the compiler generates save/restore | |
32071 | instructions (except for leaf functions). This is the normal operating mode. | |
32072 | ||
d77de738 ML |
32073 | @opindex mfpu |
32074 | @opindex mhard-float | |
ddf6fe37 AA |
32075 | @item -mfpu |
32076 | @itemx -mhard-float | |
d77de738 ML |
32077 | Generate output containing floating-point instructions. This is the |
32078 | default. | |
32079 | ||
d77de738 ML |
32080 | @opindex mno-fpu |
32081 | @opindex msoft-float | |
ddf6fe37 AA |
32082 | @item -mno-fpu |
32083 | @itemx -msoft-float | |
d77de738 ML |
32084 | Generate output containing library calls for floating point. |
32085 | @strong{Warning:} the requisite libraries are not available for all SPARC | |
32086 | targets. Normally the facilities of the machine's usual C compiler are | |
32087 | used, but this cannot be done directly in cross-compilation. You must make | |
32088 | your own arrangements to provide suitable library functions for | |
32089 | cross-compilation. The embedded targets @samp{sparc-*-aout} and | |
32090 | @samp{sparclite-*-*} do provide software floating-point support. | |
32091 | ||
32092 | @option{-msoft-float} changes the calling convention in the output file; | |
32093 | therefore, it is only useful if you compile @emph{all} of a program with | |
32094 | this option. In particular, you need to compile @file{libgcc.a}, the | |
32095 | library that comes with GCC, with @option{-msoft-float} in order for | |
32096 | this to work. | |
32097 | ||
d77de738 | 32098 | @opindex mhard-quad-float |
ddf6fe37 | 32099 | @item -mhard-quad-float |
d77de738 ML |
32100 | Generate output containing quad-word (long double) floating-point |
32101 | instructions. | |
32102 | ||
d77de738 | 32103 | @opindex msoft-quad-float |
ddf6fe37 | 32104 | @item -msoft-quad-float |
d77de738 ML |
32105 | Generate output containing library calls for quad-word (long double) |
32106 | floating-point instructions. The functions called are those specified | |
32107 | in the SPARC ABI@. This is the default. | |
32108 | ||
32109 | As of this writing, there are no SPARC implementations that have hardware | |
32110 | support for the quad-word floating-point instructions. They all invoke | |
32111 | a trap handler for one of these instructions, and then the trap handler | |
32112 | emulates the effect of the instruction. Because of the trap handler overhead, | |
32113 | this is much slower than calling the ABI library routines. Thus the | |
32114 | @option{-msoft-quad-float} option is the default. | |
32115 | ||
d77de738 ML |
32116 | @opindex mno-unaligned-doubles |
32117 | @opindex munaligned-doubles | |
ddf6fe37 AA |
32118 | @item -mno-unaligned-doubles |
32119 | @itemx -munaligned-doubles | |
d77de738 ML |
32120 | Assume that doubles have 8-byte alignment. This is the default. |
32121 | ||
32122 | With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte | |
32123 | alignment only if they are contained in another type, or if they have an | |
32124 | absolute address. Otherwise, it assumes they have 4-byte alignment. | |
32125 | Specifying this option avoids some rare compatibility problems with code | |
32126 | generated by other compilers. It is not the default because it results | |
32127 | in a performance loss, especially for floating-point code. | |
32128 | ||
d77de738 ML |
32129 | @opindex muser-mode |
32130 | @opindex mno-user-mode | |
ddf6fe37 AA |
32131 | @item -muser-mode |
32132 | @itemx -mno-user-mode | |
d77de738 ML |
32133 | Do not generate code that can only run in supervisor mode. This is relevant |
32134 | only for the @code{casa} instruction emitted for the LEON3 processor. This | |
32135 | is the default. | |
32136 | ||
d77de738 ML |
32137 | @opindex mfaster-structs |
32138 | @opindex mno-faster-structs | |
ddf6fe37 AA |
32139 | @item -mfaster-structs |
32140 | @itemx -mno-faster-structs | |
d77de738 ML |
32141 | With @option{-mfaster-structs}, the compiler assumes that structures |
32142 | should have 8-byte alignment. This enables the use of pairs of | |
32143 | @code{ldd} and @code{std} instructions for copies in structure | |
32144 | assignment, in place of twice as many @code{ld} and @code{st} pairs. | |
32145 | However, the use of this changed alignment directly violates the SPARC | |
32146 | ABI@. Thus, it's intended only for use on targets where the developer | |
32147 | acknowledges that their resulting code is not directly in line with | |
32148 | the rules of the ABI@. | |
32149 | ||
d77de738 ML |
32150 | @opindex mstd-struct-return |
32151 | @opindex mno-std-struct-return | |
ddf6fe37 AA |
32152 | @item -mstd-struct-return |
32153 | @itemx -mno-std-struct-return | |
d77de738 ML |
32154 | With @option{-mstd-struct-return}, the compiler generates checking code |
32155 | in functions returning structures or unions to detect size mismatches | |
32156 | between the two sides of function calls, as per the 32-bit ABI@. | |
32157 | ||
32158 | The default is @option{-mno-std-struct-return}. This option has no effect | |
32159 | in 64-bit mode. | |
32160 | ||
d77de738 ML |
32161 | @opindex mlra |
32162 | @opindex mno-lra | |
ddf6fe37 AA |
32163 | @item -mlra |
32164 | @itemx -mno-lra | |
d77de738 ML |
32165 | Enable Local Register Allocation. This is the default for SPARC since GCC 7 |
32166 | so @option{-mno-lra} needs to be passed to get old Reload. | |
32167 | ||
d77de738 | 32168 | @opindex mcpu |
ddf6fe37 | 32169 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
32170 | Set the instruction set, register set, and instruction scheduling parameters |
32171 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
32172 | @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc}, | |
32173 | @samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite}, | |
32174 | @samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701}, | |
32175 | @samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara}, | |
32176 | @samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and | |
32177 | @samp{m8}. | |
32178 | ||
32179 | Native Solaris and GNU/Linux toolchains also support the value @samp{native}, | |
32180 | which selects the best architecture option for the host processor. | |
32181 | @option{-mcpu=native} has no effect if GCC does not recognize | |
32182 | the processor. | |
32183 | ||
32184 | Default instruction scheduling parameters are used for values that select | |
32185 | an architecture and not an implementation. These are @samp{v7}, @samp{v8}, | |
32186 | @samp{sparclite}, @samp{sparclet}, @samp{v9}. | |
32187 | ||
32188 | Here is a list of each supported architecture and their supported | |
32189 | implementations. | |
32190 | ||
32191 | @table @asis | |
32192 | @item v7 | |
32193 | cypress, leon3v7 | |
32194 | ||
32195 | @item v8 | |
32196 | supersparc, hypersparc, leon, leon3, leon5 | |
32197 | ||
32198 | @item sparclite | |
32199 | f930, f934, sparclite86x | |
32200 | ||
32201 | @item sparclet | |
32202 | tsc701 | |
32203 | ||
32204 | @item v9 | |
32205 | ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4, | |
32206 | niagara7, m8 | |
32207 | @end table | |
32208 | ||
32209 | By default (unless configured otherwise), GCC generates code for the V7 | |
32210 | variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler | |
32211 | additionally optimizes it for the Cypress CY7C602 chip, as used in the | |
32212 | SPARCStation/SPARCServer 3xx series. This is also appropriate for the older | |
32213 | SPARCStation 1, 2, IPX etc. | |
32214 | ||
32215 | With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC | |
32216 | architecture. The only difference from V7 code is that the compiler emits | |
32217 | the integer multiply and integer divide instructions which exist in SPARC-V8 | |
32218 | but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally | |
32219 | optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and | |
32220 | 2000 series. | |
32221 | ||
32222 | With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of | |
32223 | the SPARC architecture. This adds the integer multiply, integer divide step | |
32224 | and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7. | |
32225 | With @option{-mcpu=f930}, the compiler additionally optimizes it for the | |
32226 | Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With | |
32227 | @option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu | |
32228 | MB86934 chip, which is the more recent SPARClite with FPU@. | |
32229 | ||
32230 | With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of | |
32231 | the SPARC architecture. This adds the integer multiply, multiply/accumulate, | |
32232 | integer divide step and scan (@code{ffs}) instructions which exist in SPARClet | |
32233 | but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally | |
32234 | optimizes it for the TEMIC SPARClet chip. | |
32235 | ||
32236 | With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC | |
32237 | architecture. This adds 64-bit integer and floating-point move instructions, | |
32238 | 3 additional floating-point condition code registers and conditional move | |
32239 | instructions. With @option{-mcpu=ultrasparc}, the compiler additionally | |
32240 | optimizes it for the Sun UltraSPARC I/II/IIi chips. With | |
32241 | @option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the | |
32242 | Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With | |
32243 | @option{-mcpu=niagara}, the compiler additionally optimizes it for | |
32244 | Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler | |
32245 | additionally optimizes it for Sun UltraSPARC T2 chips. With | |
32246 | @option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun | |
32247 | UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler | |
32248 | additionally optimizes it for Sun UltraSPARC T4 chips. With | |
32249 | @option{-mcpu=niagara7}, the compiler additionally optimizes it for | |
32250 | Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler | |
32251 | additionally optimizes it for Oracle M8 chips. | |
32252 | ||
d77de738 | 32253 | @opindex mtune |
ddf6fe37 | 32254 | @item -mtune=@var{cpu_type} |
d77de738 ML |
32255 | Set the instruction scheduling parameters for machine type |
32256 | @var{cpu_type}, but do not set the instruction set or register set that the | |
32257 | option @option{-mcpu=@var{cpu_type}} does. | |
32258 | ||
32259 | The same values for @option{-mcpu=@var{cpu_type}} can be used for | |
32260 | @option{-mtune=@var{cpu_type}}, but the only useful values are those | |
32261 | that select a particular CPU implementation. Those are | |
32262 | @samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon}, | |
32263 | @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934}, | |
32264 | @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc}, | |
32265 | @samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3}, | |
32266 | @samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris | |
32267 | and GNU/Linux toolchains, @samp{native} can also be used. | |
32268 | ||
d77de738 ML |
32269 | @opindex mv8plus |
32270 | @opindex mno-v8plus | |
ddf6fe37 AA |
32271 | @item -mv8plus |
32272 | @itemx -mno-v8plus | |
d77de738 ML |
32273 | With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The |
32274 | difference from the V8 ABI is that the global and out registers are | |
32275 | considered 64 bits wide. This is enabled by default on Solaris in 32-bit | |
32276 | mode for all SPARC-V9 processors. | |
32277 | ||
d77de738 ML |
32278 | @opindex mvis |
32279 | @opindex mno-vis | |
ddf6fe37 AA |
32280 | @item -mvis |
32281 | @itemx -mno-vis | |
d77de738 ML |
32282 | With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC |
32283 | Visual Instruction Set extensions. The default is @option{-mno-vis}. | |
32284 | ||
d77de738 ML |
32285 | @opindex mvis2 |
32286 | @opindex mno-vis2 | |
ddf6fe37 AA |
32287 | @item -mvis2 |
32288 | @itemx -mno-vis2 | |
d77de738 ML |
32289 | With @option{-mvis2}, GCC generates code that takes advantage of |
32290 | version 2.0 of the UltraSPARC Visual Instruction Set extensions. The | |
32291 | default is @option{-mvis2} when targeting a cpu that supports such | |
32292 | instructions, such as UltraSPARC-III and later. Setting @option{-mvis2} | |
32293 | also sets @option{-mvis}. | |
32294 | ||
d77de738 ML |
32295 | @opindex mvis3 |
32296 | @opindex mno-vis3 | |
ddf6fe37 AA |
32297 | @item -mvis3 |
32298 | @itemx -mno-vis3 | |
d77de738 ML |
32299 | With @option{-mvis3}, GCC generates code that takes advantage of |
32300 | version 3.0 of the UltraSPARC Visual Instruction Set extensions. The | |
32301 | default is @option{-mvis3} when targeting a cpu that supports such | |
32302 | instructions, such as niagara-3 and later. Setting @option{-mvis3} | |
32303 | also sets @option{-mvis2} and @option{-mvis}. | |
32304 | ||
d77de738 ML |
32305 | @opindex mvis4 |
32306 | @opindex mno-vis4 | |
ddf6fe37 AA |
32307 | @item -mvis4 |
32308 | @itemx -mno-vis4 | |
d77de738 ML |
32309 | With @option{-mvis4}, GCC generates code that takes advantage of |
32310 | version 4.0 of the UltraSPARC Visual Instruction Set extensions. The | |
32311 | default is @option{-mvis4} when targeting a cpu that supports such | |
32312 | instructions, such as niagara-7 and later. Setting @option{-mvis4} | |
32313 | also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}. | |
32314 | ||
d77de738 ML |
32315 | @opindex mvis4b |
32316 | @opindex mno-vis4b | |
ddf6fe37 AA |
32317 | @item -mvis4b |
32318 | @itemx -mno-vis4b | |
d77de738 ML |
32319 | With @option{-mvis4b}, GCC generates code that takes advantage of |
32320 | version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus | |
32321 | the additional VIS instructions introduced in the Oracle SPARC | |
32322 | Architecture 2017. The default is @option{-mvis4b} when targeting a | |
32323 | cpu that supports such instructions, such as m8 and later. Setting | |
32324 | @option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3}, | |
32325 | @option{-mvis2} and @option{-mvis}. | |
32326 | ||
d77de738 ML |
32327 | @opindex mcbcond |
32328 | @opindex mno-cbcond | |
ddf6fe37 AA |
32329 | @item -mcbcond |
32330 | @itemx -mno-cbcond | |
d77de738 ML |
32331 | With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC |
32332 | Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond} | |
32333 | when targeting a CPU that supports such instructions, such as Niagara-4 and | |
32334 | later. | |
32335 | ||
d77de738 ML |
32336 | @opindex mfmaf |
32337 | @opindex mno-fmaf | |
ddf6fe37 AA |
32338 | @item -mfmaf |
32339 | @itemx -mno-fmaf | |
d77de738 ML |
32340 | With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC |
32341 | Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf} | |
32342 | when targeting a CPU that supports such instructions, such as Niagara-3 and | |
32343 | later. | |
32344 | ||
d77de738 ML |
32345 | @opindex mfsmuld |
32346 | @opindex mno-fsmuld | |
ddf6fe37 AA |
32347 | @item -mfsmuld |
32348 | @itemx -mno-fsmuld | |
d77de738 ML |
32349 | With @option{-mfsmuld}, GCC generates code that takes advantage of the |
32350 | Floating-point Multiply Single to Double (FsMULd) instruction. The default is | |
32351 | @option{-mfsmuld} when targeting a CPU supporting the architecture versions V8 | |
32352 | or V9 with FPU except @option{-mcpu=leon}. | |
32353 | ||
d77de738 ML |
32354 | @opindex mpopc |
32355 | @opindex mno-popc | |
ddf6fe37 AA |
32356 | @item -mpopc |
32357 | @itemx -mno-popc | |
d77de738 ML |
32358 | With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC |
32359 | Population Count instruction. The default is @option{-mpopc} | |
32360 | when targeting a CPU that supports such an instruction, such as Niagara-2 and | |
32361 | later. | |
32362 | ||
d77de738 ML |
32363 | @opindex msubxc |
32364 | @opindex mno-subxc | |
ddf6fe37 AA |
32365 | @item -msubxc |
32366 | @itemx -mno-subxc | |
d77de738 ML |
32367 | With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC |
32368 | Subtract-Extended-with-Carry instruction. The default is @option{-msubxc} | |
32369 | when targeting a CPU that supports such an instruction, such as Niagara-7 and | |
32370 | later. | |
32371 | ||
d77de738 | 32372 | @opindex mfix-at697f |
ddf6fe37 | 32373 | @item -mfix-at697f |
d77de738 ML |
32374 | Enable the documented workaround for the single erratum of the Atmel AT697F |
32375 | processor (which corresponds to erratum #13 of the AT697E processor). | |
32376 | ||
d77de738 | 32377 | @opindex mfix-ut699 |
ddf6fe37 | 32378 | @item -mfix-ut699 |
d77de738 ML |
32379 | Enable the documented workarounds for the floating-point errata and the data |
32380 | cache nullify errata of the UT699 processor. | |
32381 | ||
d77de738 | 32382 | @opindex mfix-ut700 |
ddf6fe37 | 32383 | @item -mfix-ut700 |
d77de738 ML |
32384 | Enable the documented workaround for the back-to-back store errata of |
32385 | the UT699E/UT700 processor. | |
32386 | ||
d77de738 | 32387 | @opindex mfix-gr712rc |
ddf6fe37 | 32388 | @item -mfix-gr712rc |
d77de738 ML |
32389 | Enable the documented workaround for the back-to-back store errata of |
32390 | the GR712RC processor. | |
32391 | @end table | |
32392 | ||
32393 | These @samp{-m} options are supported in addition to the above | |
32394 | on SPARC-V9 processors in 64-bit environments: | |
32395 | ||
32396 | @table @gcctabopt | |
d77de738 ML |
32397 | @opindex m32 |
32398 | @opindex m64 | |
ddf6fe37 AA |
32399 | @item -m32 |
32400 | @itemx -m64 | |
d77de738 ML |
32401 | Generate code for a 32-bit or 64-bit environment. |
32402 | The 32-bit environment sets int, long and pointer to 32 bits. | |
32403 | The 64-bit environment sets int to 32 bits and long and pointer | |
32404 | to 64 bits. | |
32405 | ||
d77de738 | 32406 | @opindex mcmodel |
ddf6fe37 | 32407 | @item -mcmodel=@var{which} |
d77de738 ML |
32408 | Set the code model to one of |
32409 | ||
32410 | @table @samp | |
32411 | @item medlow | |
32412 | The Medium/Low code model: 64-bit addresses, programs | |
32413 | must be linked in the low 32 bits of memory. Programs can be statically | |
32414 | or dynamically linked. | |
32415 | ||
32416 | @item medmid | |
32417 | The Medium/Middle code model: 64-bit addresses, programs | |
32418 | must be linked in the low 44 bits of memory, the text and data segments must | |
32419 | be less than 2GB in size and the data segment must be located within 2GB of | |
32420 | the text segment. | |
32421 | ||
32422 | @item medany | |
32423 | The Medium/Anywhere code model: 64-bit addresses, programs | |
32424 | may be linked anywhere in memory, the text and data segments must be less | |
32425 | than 2GB in size and the data segment must be located within 2GB of the | |
32426 | text segment. | |
32427 | ||
32428 | @item embmedany | |
32429 | The Medium/Anywhere code model for embedded systems: | |
32430 | 64-bit addresses, the text and data segments must be less than 2GB in | |
32431 | size, both starting anywhere in memory (determined at link time). The | |
32432 | global register %g4 points to the base of the data segment. Programs | |
32433 | are statically linked and PIC is not supported. | |
32434 | @end table | |
32435 | ||
d77de738 | 32436 | @opindex mmemory-model |
ddf6fe37 | 32437 | @item -mmemory-model=@var{mem-model} |
d77de738 ML |
32438 | Set the memory model in force on the processor to one of |
32439 | ||
32440 | @table @samp | |
32441 | @item default | |
32442 | The default memory model for the processor and operating system. | |
32443 | ||
32444 | @item rmo | |
32445 | Relaxed Memory Order | |
32446 | ||
32447 | @item pso | |
32448 | Partial Store Order | |
32449 | ||
32450 | @item tso | |
32451 | Total Store Order | |
32452 | ||
32453 | @item sc | |
32454 | Sequential Consistency | |
32455 | @end table | |
32456 | ||
32457 | These memory models are formally defined in Appendix D of the SPARC-V9 | |
32458 | architecture manual, as set in the processor's @code{PSTATE.MM} field. | |
32459 | ||
d77de738 ML |
32460 | @opindex mstack-bias |
32461 | @opindex mno-stack-bias | |
ddf6fe37 AA |
32462 | @item -mstack-bias |
32463 | @itemx -mno-stack-bias | |
d77de738 ML |
32464 | With @option{-mstack-bias}, GCC assumes that the stack pointer, and |
32465 | frame pointer if present, are offset by @minus{}2047 which must be added back | |
32466 | when making stack frame references. This is the default in 64-bit mode. | |
32467 | Otherwise, assume no such offset is present. | |
32468 | @end table | |
32469 | ||
32470 | @node System V Options | |
32471 | @subsection Options for System V | |
32472 | ||
32473 | These additional options are available on System V Release 4 for | |
32474 | compatibility with other compilers on those systems: | |
32475 | ||
32476 | @table @gcctabopt | |
d77de738 | 32477 | @opindex G |
ddf6fe37 | 32478 | @item -G |
d77de738 ML |
32479 | Create a shared object. |
32480 | It is recommended that @option{-symbolic} or @option{-shared} be used instead. | |
32481 | ||
d77de738 | 32482 | @opindex Qy |
ddf6fe37 | 32483 | @item -Qy |
d77de738 ML |
32484 | Identify the versions of each tool used by the compiler, in a |
32485 | @code{.ident} assembler directive in the output. | |
32486 | ||
d77de738 | 32487 | @opindex Qn |
ddf6fe37 | 32488 | @item -Qn |
d77de738 ML |
32489 | Refrain from adding @code{.ident} directives to the output file (this is |
32490 | the default). | |
32491 | ||
d77de738 | 32492 | @opindex YP |
ddf6fe37 | 32493 | @item -YP,@var{dirs} |
d77de738 ML |
32494 | Search the directories @var{dirs}, and no others, for libraries |
32495 | specified with @option{-l}. | |
32496 | ||
d77de738 | 32497 | @opindex Ym |
ddf6fe37 | 32498 | @item -Ym,@var{dir} |
d77de738 ML |
32499 | Look in the directory @var{dir} to find the M4 preprocessor. |
32500 | The assembler uses this option. | |
32501 | @c This is supposed to go with a -Yd for predefined M4 macro files, but | |
32502 | @c the generic assembler that comes with Solaris takes just -Ym. | |
32503 | @end table | |
32504 | ||
32505 | @node V850 Options | |
32506 | @subsection V850 Options | |
32507 | @cindex V850 Options | |
32508 | ||
32509 | These @samp{-m} options are defined for V850 implementations: | |
32510 | ||
32511 | @table @gcctabopt | |
d77de738 ML |
32512 | @opindex mlong-calls |
32513 | @opindex mno-long-calls | |
ddf6fe37 AA |
32514 | @item -mlong-calls |
32515 | @itemx -mno-long-calls | |
d77de738 ML |
32516 | Treat all calls as being far away (near). If calls are assumed to be |
32517 | far away, the compiler always loads the function's address into a | |
32518 | register, and calls indirect through the pointer. | |
32519 | ||
d77de738 ML |
32520 | @opindex mno-ep |
32521 | @opindex mep | |
ddf6fe37 AA |
32522 | @item -mno-ep |
32523 | @itemx -mep | |
d77de738 ML |
32524 | Do not optimize (do optimize) basic blocks that use the same index |
32525 | pointer 4 or more times to copy pointer into the @code{ep} register, and | |
32526 | use the shorter @code{sld} and @code{sst} instructions. The @option{-mep} | |
32527 | option is on by default if you optimize. | |
32528 | ||
d77de738 ML |
32529 | @opindex mno-prolog-function |
32530 | @opindex mprolog-function | |
ddf6fe37 AA |
32531 | @item -mno-prolog-function |
32532 | @itemx -mprolog-function | |
d77de738 ML |
32533 | Do not use (do use) external functions to save and restore registers |
32534 | at the prologue and epilogue of a function. The external functions | |
32535 | are slower, but use less code space if more than one function saves | |
32536 | the same number of registers. The @option{-mprolog-function} option | |
32537 | is on by default if you optimize. | |
32538 | ||
d77de738 | 32539 | @opindex mspace |
ddf6fe37 | 32540 | @item -mspace |
d77de738 ML |
32541 | Try to make the code as small as possible. At present, this just turns |
32542 | on the @option{-mep} and @option{-mprolog-function} options. | |
32543 | ||
d77de738 | 32544 | @opindex mtda |
ddf6fe37 | 32545 | @item -mtda=@var{n} |
d77de738 ML |
32546 | Put static or global variables whose size is @var{n} bytes or less into |
32547 | the tiny data area that register @code{ep} points to. The tiny data | |
32548 | area can hold up to 256 bytes in total (128 bytes for byte references). | |
32549 | ||
d77de738 | 32550 | @opindex msda |
ddf6fe37 | 32551 | @item -msda=@var{n} |
d77de738 ML |
32552 | Put static or global variables whose size is @var{n} bytes or less into |
32553 | the small data area that register @code{gp} points to. The small data | |
32554 | area can hold up to 64 kilobytes. | |
32555 | ||
d77de738 | 32556 | @opindex mzda |
ddf6fe37 | 32557 | @item -mzda=@var{n} |
d77de738 ML |
32558 | Put static or global variables whose size is @var{n} bytes or less into |
32559 | the first 32 kilobytes of memory. | |
32560 | ||
d77de738 | 32561 | @opindex mv850 |
ddf6fe37 | 32562 | @item -mv850 |
d77de738 ML |
32563 | Specify that the target processor is the V850. |
32564 | ||
d77de738 | 32565 | @opindex mv850e3v5 |
ddf6fe37 | 32566 | @item -mv850e3v5 |
d77de738 ML |
32567 | Specify that the target processor is the V850E3V5. The preprocessor |
32568 | constant @code{__v850e3v5__} is defined if this option is used. | |
32569 | ||
d77de738 | 32570 | @opindex mv850e2v4 |
ddf6fe37 | 32571 | @item -mv850e2v4 |
d77de738 ML |
32572 | Specify that the target processor is the V850E3V5. This is an alias for |
32573 | the @option{-mv850e3v5} option. | |
32574 | ||
d77de738 | 32575 | @opindex mv850e2v3 |
ddf6fe37 | 32576 | @item -mv850e2v3 |
d77de738 ML |
32577 | Specify that the target processor is the V850E2V3. The preprocessor |
32578 | constant @code{__v850e2v3__} is defined if this option is used. | |
32579 | ||
d77de738 | 32580 | @opindex mv850e2 |
ddf6fe37 | 32581 | @item -mv850e2 |
d77de738 ML |
32582 | Specify that the target processor is the V850E2. The preprocessor |
32583 | constant @code{__v850e2__} is defined if this option is used. | |
32584 | ||
d77de738 | 32585 | @opindex mv850e1 |
ddf6fe37 | 32586 | @item -mv850e1 |
d77de738 ML |
32587 | Specify that the target processor is the V850E1. The preprocessor |
32588 | constants @code{__v850e1__} and @code{__v850e__} are defined if | |
32589 | this option is used. | |
32590 | ||
d77de738 | 32591 | @opindex mv850es |
ddf6fe37 | 32592 | @item -mv850es |
d77de738 ML |
32593 | Specify that the target processor is the V850ES. This is an alias for |
32594 | the @option{-mv850e1} option. | |
32595 | ||
d77de738 | 32596 | @opindex mv850e |
ddf6fe37 | 32597 | @item -mv850e |
d77de738 ML |
32598 | Specify that the target processor is the V850E@. The preprocessor |
32599 | constant @code{__v850e__} is defined if this option is used. | |
32600 | ||
32601 | If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1} | |
32602 | nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5} | |
32603 | are defined then a default target processor is chosen and the | |
32604 | relevant @samp{__v850*__} preprocessor constant is defined. | |
32605 | ||
32606 | The preprocessor constants @code{__v850} and @code{__v851__} are always | |
32607 | defined, regardless of which processor variant is the target. | |
32608 | ||
d77de738 ML |
32609 | @opindex mdisable-callt |
32610 | @opindex mno-disable-callt | |
ddf6fe37 AA |
32611 | @item -mdisable-callt |
32612 | @itemx -mno-disable-callt | |
d77de738 ML |
32613 | This option suppresses generation of the @code{CALLT} instruction for the |
32614 | v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850 | |
32615 | architecture. | |
32616 | ||
32617 | This option is enabled by default when the RH850 ABI is | |
32618 | in use (see @option{-mrh850-abi}), and disabled by default when the | |
32619 | GCC ABI is in use. If @code{CALLT} instructions are being generated | |
32620 | then the C preprocessor symbol @code{__V850_CALLT__} is defined. | |
32621 | ||
d77de738 ML |
32622 | @opindex mrelax |
32623 | @opindex mno-relax | |
ddf6fe37 AA |
32624 | @item -mrelax |
32625 | @itemx -mno-relax | |
d77de738 ML |
32626 | Pass on (or do not pass on) the @option{-mrelax} command-line option |
32627 | to the assembler. | |
32628 | ||
d77de738 ML |
32629 | @opindex mlong-jumps |
32630 | @opindex mno-long-jumps | |
ddf6fe37 AA |
32631 | @item -mlong-jumps |
32632 | @itemx -mno-long-jumps | |
d77de738 ML |
32633 | Disable (or re-enable) the generation of PC-relative jump instructions. |
32634 | ||
d77de738 ML |
32635 | @opindex msoft-float |
32636 | @opindex mhard-float | |
ddf6fe37 AA |
32637 | @item -msoft-float |
32638 | @itemx -mhard-float | |
d77de738 ML |
32639 | Disable (or re-enable) the generation of hardware floating point |
32640 | instructions. This option is only significant when the target | |
32641 | architecture is @samp{V850E2V3} or higher. If hardware floating point | |
32642 | instructions are being generated then the C preprocessor symbol | |
32643 | @code{__FPU_OK__} is defined, otherwise the symbol | |
32644 | @code{__NO_FPU__} is defined. | |
32645 | ||
d77de738 | 32646 | @opindex mloop |
ddf6fe37 | 32647 | @item -mloop |
d77de738 ML |
32648 | Enables the use of the e3v5 LOOP instruction. The use of this |
32649 | instruction is not enabled by default when the e3v5 architecture is | |
32650 | selected because its use is still experimental. | |
32651 | ||
d77de738 ML |
32652 | @opindex mrh850-abi |
32653 | @opindex mghs | |
ddf6fe37 AA |
32654 | @item -mrh850-abi |
32655 | @itemx -mghs | |
d77de738 ML |
32656 | Enables support for the RH850 version of the V850 ABI. This is the |
32657 | default. With this version of the ABI the following rules apply: | |
32658 | ||
32659 | @itemize | |
32660 | @item | |
32661 | Integer sized structures and unions are returned via a memory pointer | |
32662 | rather than a register. | |
32663 | ||
32664 | @item | |
32665 | Large structures and unions (more than 8 bytes in size) are passed by | |
32666 | value. | |
32667 | ||
32668 | @item | |
32669 | Functions are aligned to 16-bit boundaries. | |
32670 | ||
32671 | @item | |
32672 | The @option{-m8byte-align} command-line option is supported. | |
32673 | ||
32674 | @item | |
32675 | The @option{-mdisable-callt} command-line option is enabled by | |
32676 | default. The @option{-mno-disable-callt} command-line option is not | |
32677 | supported. | |
32678 | @end itemize | |
32679 | ||
32680 | When this version of the ABI is enabled the C preprocessor symbol | |
32681 | @code{__V850_RH850_ABI__} is defined. | |
32682 | ||
d77de738 | 32683 | @opindex mgcc-abi |
ddf6fe37 | 32684 | @item -mgcc-abi |
d77de738 ML |
32685 | Enables support for the old GCC version of the V850 ABI. With this |
32686 | version of the ABI the following rules apply: | |
32687 | ||
32688 | @itemize | |
32689 | @item | |
32690 | Integer sized structures and unions are returned in register @code{r10}. | |
32691 | ||
32692 | @item | |
32693 | Large structures and unions (more than 8 bytes in size) are passed by | |
32694 | reference. | |
32695 | ||
32696 | @item | |
32697 | Functions are aligned to 32-bit boundaries, unless optimizing for | |
32698 | size. | |
32699 | ||
32700 | @item | |
32701 | The @option{-m8byte-align} command-line option is not supported. | |
32702 | ||
32703 | @item | |
32704 | The @option{-mdisable-callt} command-line option is supported but not | |
32705 | enabled by default. | |
32706 | @end itemize | |
32707 | ||
32708 | When this version of the ABI is enabled the C preprocessor symbol | |
32709 | @code{__V850_GCC_ABI__} is defined. | |
32710 | ||
d77de738 ML |
32711 | @opindex m8byte-align |
32712 | @opindex mno-8byte-align | |
ddf6fe37 AA |
32713 | @item -m8byte-align |
32714 | @itemx -mno-8byte-align | |
d77de738 ML |
32715 | Enables support for @code{double} and @code{long long} types to be |
32716 | aligned on 8-byte boundaries. The default is to restrict the | |
32717 | alignment of all objects to at most 4-bytes. When | |
32718 | @option{-m8byte-align} is in effect the C preprocessor symbol | |
32719 | @code{__V850_8BYTE_ALIGN__} is defined. | |
32720 | ||
d77de738 | 32721 | @opindex mbig-switch |
ddf6fe37 | 32722 | @item -mbig-switch |
d77de738 ML |
32723 | Generate code suitable for big switch tables. Use this option only if |
32724 | the assembler/linker complain about out of range branches within a switch | |
32725 | table. | |
32726 | ||
d77de738 | 32727 | @opindex mapp-regs |
ddf6fe37 | 32728 | @item -mapp-regs |
d77de738 ML |
32729 | This option causes r2 and r5 to be used in the code generated by |
32730 | the compiler. This setting is the default. | |
32731 | ||
d77de738 | 32732 | @opindex mno-app-regs |
ddf6fe37 | 32733 | @item -mno-app-regs |
d77de738 ML |
32734 | This option causes r2 and r5 to be treated as fixed registers. |
32735 | ||
32736 | @end table | |
32737 | ||
32738 | @node VAX Options | |
32739 | @subsection VAX Options | |
32740 | @cindex VAX options | |
32741 | ||
32742 | These @samp{-m} options are defined for the VAX: | |
32743 | ||
32744 | @table @gcctabopt | |
d77de738 | 32745 | @opindex munix |
ddf6fe37 | 32746 | @item -munix |
d77de738 ML |
32747 | Do not output certain jump instructions (@code{aobleq} and so on) |
32748 | that the Unix assembler for the VAX cannot handle across long | |
32749 | ranges. | |
32750 | ||
d77de738 | 32751 | @opindex mgnu |
ddf6fe37 | 32752 | @item -mgnu |
d77de738 ML |
32753 | Do output those jump instructions, on the assumption that the |
32754 | GNU assembler is being used. | |
32755 | ||
d77de738 | 32756 | @opindex mg |
ddf6fe37 | 32757 | @item -mg |
d77de738 ML |
32758 | Output code for G-format floating-point numbers instead of D-format. |
32759 | ||
d77de738 ML |
32760 | @opindex mlra |
32761 | @opindex mno-lra | |
ddf6fe37 AA |
32762 | @item -mlra |
32763 | @itemx -mno-lra | |
d77de738 ML |
32764 | Enable Local Register Allocation. This is still experimental for the VAX, |
32765 | so by default the compiler uses standard reload. | |
32766 | @end table | |
32767 | ||
32768 | @node Visium Options | |
32769 | @subsection Visium Options | |
32770 | @cindex Visium options | |
32771 | ||
32772 | @table @gcctabopt | |
32773 | ||
d77de738 | 32774 | @opindex mdebug |
ddf6fe37 | 32775 | @item -mdebug |
d77de738 ML |
32776 | A program which performs file I/O and is destined to run on an MCM target |
32777 | should be linked with this option. It causes the libraries libc.a and | |
32778 | libdebug.a to be linked. The program should be run on the target under | |
32779 | the control of the GDB remote debugging stub. | |
32780 | ||
d77de738 | 32781 | @opindex msim |
ddf6fe37 | 32782 | @item -msim |
d77de738 ML |
32783 | A program which performs file I/O and is destined to run on the simulator |
32784 | should be linked with option. This causes libraries libc.a and libsim.a to | |
32785 | be linked. | |
32786 | ||
d77de738 ML |
32787 | @opindex mfpu |
32788 | @opindex mhard-float | |
ddf6fe37 AA |
32789 | @item -mfpu |
32790 | @itemx -mhard-float | |
d77de738 ML |
32791 | Generate code containing floating-point instructions. This is the |
32792 | default. | |
32793 | ||
d77de738 ML |
32794 | @opindex mno-fpu |
32795 | @opindex msoft-float | |
ddf6fe37 AA |
32796 | @item -mno-fpu |
32797 | @itemx -msoft-float | |
d77de738 ML |
32798 | Generate code containing library calls for floating-point. |
32799 | ||
32800 | @option{-msoft-float} changes the calling convention in the output file; | |
32801 | therefore, it is only useful if you compile @emph{all} of a program with | |
32802 | this option. In particular, you need to compile @file{libgcc.a}, the | |
32803 | library that comes with GCC, with @option{-msoft-float} in order for | |
32804 | this to work. | |
32805 | ||
d77de738 | 32806 | @opindex mcpu |
ddf6fe37 | 32807 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
32808 | Set the instruction set, register set, and instruction scheduling parameters |
32809 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
32810 | @samp{mcm}, @samp{gr5} and @samp{gr6}. | |
32811 | ||
32812 | @samp{mcm} is a synonym of @samp{gr5} present for backward compatibility. | |
32813 | ||
32814 | By default (unless configured otherwise), GCC generates code for the GR5 | |
32815 | variant of the Visium architecture. | |
32816 | ||
32817 | With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium | |
32818 | architecture. The only difference from GR5 code is that the compiler will | |
32819 | generate block move instructions. | |
32820 | ||
d77de738 | 32821 | @opindex mtune |
ddf6fe37 | 32822 | @item -mtune=@var{cpu_type} |
d77de738 ML |
32823 | Set the instruction scheduling parameters for machine type @var{cpu_type}, |
32824 | but do not set the instruction set or register set that the option | |
32825 | @option{-mcpu=@var{cpu_type}} would. | |
32826 | ||
d77de738 | 32827 | @opindex msv-mode |
ddf6fe37 | 32828 | @item -msv-mode |
d77de738 ML |
32829 | Generate code for the supervisor mode, where there are no restrictions on |
32830 | the access to general registers. This is the default. | |
32831 | ||
d77de738 | 32832 | @opindex muser-mode |
ddf6fe37 | 32833 | @item -muser-mode |
d77de738 ML |
32834 | Generate code for the user mode, where the access to some general registers |
32835 | is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this | |
32836 | mode; on the GR6, only registers r29 to r31 are affected. | |
32837 | @end table | |
32838 | ||
32839 | @node VMS Options | |
32840 | @subsection VMS Options | |
32841 | ||
32842 | These @samp{-m} options are defined for the VMS implementations: | |
32843 | ||
32844 | @table @gcctabopt | |
d77de738 | 32845 | @opindex mvms-return-codes |
ddf6fe37 | 32846 | @item -mvms-return-codes |
d77de738 ML |
32847 | Return VMS condition codes from @code{main}. The default is to return POSIX-style |
32848 | condition (e.g.@: error) codes. | |
32849 | ||
d77de738 | 32850 | @opindex mdebug-main=@var{prefix} |
ddf6fe37 | 32851 | @item -mdebug-main=@var{prefix} |
d77de738 ML |
32852 | Flag the first routine whose name starts with @var{prefix} as the main |
32853 | routine for the debugger. | |
32854 | ||
d77de738 | 32855 | @opindex mmalloc64 |
ddf6fe37 | 32856 | @item -mmalloc64 |
d77de738 ML |
32857 | Default to 64-bit memory allocation routines. |
32858 | ||
d77de738 | 32859 | @opindex mpointer-size=@var{size} |
ddf6fe37 | 32860 | @item -mpointer-size=@var{size} |
d77de738 ML |
32861 | Set the default size of pointers. Possible options for @var{size} are |
32862 | @samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long} | |
32863 | for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers. | |
32864 | The later option disables @code{pragma pointer_size}. | |
32865 | @end table | |
32866 | ||
32867 | @node VxWorks Options | |
32868 | @subsection VxWorks Options | |
32869 | @cindex VxWorks Options | |
32870 | ||
32871 | The options in this section are defined for all VxWorks targets. | |
32872 | Options specific to the target hardware are listed with the other | |
32873 | options for that target. | |
32874 | ||
32875 | @table @gcctabopt | |
d77de738 | 32876 | @opindex mrtp |
ddf6fe37 | 32877 | @item -mrtp |
d77de738 ML |
32878 | GCC can generate code for both VxWorks kernels and real time processes |
32879 | (RTPs). This option switches from the former to the latter. It also | |
32880 | defines the preprocessor macro @code{__RTP__}. | |
32881 | ||
b6f4b000 AO |
32882 | @opindex msmp |
32883 | @item -msmp | |
32884 | Select SMP runtimes for linking. Not available on architectures other | |
32885 | than PowerPC, nor on VxWorks version 7 or later, in which the selection | |
32886 | is part of the VxWorks build configuration and the library paths are the | |
32887 | same for either choice. | |
32888 | ||
d77de738 | 32889 | @opindex non-static |
ddf6fe37 | 32890 | @item -non-static |
d77de738 ML |
32891 | Link an RTP executable against shared libraries rather than static |
32892 | libraries. The options @option{-static} and @option{-shared} can | |
32893 | also be used for RTPs (@pxref{Link Options}); @option{-static} | |
32894 | is the default. | |
32895 | ||
d77de738 ML |
32896 | @opindex Bstatic |
32897 | @opindex Bdynamic | |
ddf6fe37 AA |
32898 | @item -Bstatic |
32899 | @itemx -Bdynamic | |
d77de738 ML |
32900 | These options are passed down to the linker. They are defined for |
32901 | compatibility with Diab. | |
32902 | ||
d77de738 | 32903 | @opindex Xbind-lazy |
ddf6fe37 | 32904 | @item -Xbind-lazy |
d77de738 ML |
32905 | Enable lazy binding of function calls. This option is equivalent to |
32906 | @option{-Wl,-z,now} and is defined for compatibility with Diab. | |
32907 | ||
d77de738 | 32908 | @opindex Xbind-now |
ddf6fe37 | 32909 | @item -Xbind-now |
d77de738 ML |
32910 | Disable lazy binding of function calls. This option is the default and |
32911 | is defined for compatibility with Diab. | |
32912 | @end table | |
32913 | ||
32914 | @node x86 Options | |
32915 | @subsection x86 Options | |
32916 | @cindex x86 Options | |
32917 | ||
32918 | These @samp{-m} options are defined for the x86 family of computers. | |
32919 | ||
32920 | @table @gcctabopt | |
32921 | ||
d77de738 | 32922 | @opindex march |
ddf6fe37 | 32923 | @item -march=@var{cpu-type} |
d77de738 ML |
32924 | Generate instructions for the machine type @var{cpu-type}. In contrast to |
32925 | @option{-mtune=@var{cpu-type}}, which merely tunes the generated code | |
32926 | for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC | |
32927 | to generate code that may not run at all on processors other than the one | |
32928 | indicated. Specifying @option{-march=@var{cpu-type}} implies | |
32929 | @option{-mtune=@var{cpu-type}}, except where noted otherwise. | |
32930 | ||
32931 | The choices for @var{cpu-type} are: | |
32932 | ||
32933 | @table @samp | |
32934 | @item native | |
32935 | This selects the CPU to generate code for at compilation time by determining | |
32936 | the processor type of the compiling machine. Using @option{-march=native} | |
32937 | enables all instruction subsets supported by the local machine (hence | |
32938 | the result might not run on different machines). Using @option{-mtune=native} | |
32939 | produces code optimized for the local machine under the constraints | |
32940 | of the selected instruction set. | |
32941 | ||
32942 | @item x86-64 | |
32943 | A generic CPU with 64-bit extensions. | |
32944 | ||
32945 | @item x86-64-v2 | |
32946 | @itemx x86-64-v3 | |
32947 | @itemx x86-64-v4 | |
32948 | These choices for @var{cpu-type} select the corresponding | |
32949 | micro-architecture level from the x86-64 psABI. On ABIs other than | |
32950 | the x86-64 psABI they select the same CPU features as the x86-64 psABI | |
32951 | documents for the particular micro-architecture level. | |
32952 | ||
32953 | Since these @var{cpu-type} values do not have a corresponding | |
32954 | @option{-mtune} setting, using @option{-march} with these values enables | |
32955 | generic tuning. Specific tuning can be enabled using the | |
32956 | @option{-mtune=@var{other-cpu-type}} option with an appropriate | |
32957 | @var{other-cpu-type} value. | |
32958 | ||
32959 | @item i386 | |
32960 | Original Intel i386 CPU@. | |
32961 | ||
32962 | @item i486 | |
32963 | Intel i486 CPU@. (No scheduling is implemented for this chip.) | |
32964 | ||
32965 | @item i586 | |
32966 | @itemx pentium | |
32967 | Intel Pentium CPU with no MMX support. | |
32968 | ||
32969 | @item lakemont | |
32970 | Intel Lakemont MCU, based on Intel Pentium CPU. | |
32971 | ||
32972 | @item pentium-mmx | |
32973 | Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support. | |
32974 | ||
32975 | @item pentiumpro | |
32976 | Intel Pentium Pro CPU@. | |
32977 | ||
32978 | @item i686 | |
32979 | When used with @option{-march}, the Pentium Pro | |
32980 | instruction set is used, so the code runs on all i686 family chips. | |
32981 | When used with @option{-mtune}, it has the same meaning as @samp{generic}. | |
32982 | ||
32983 | @item pentium2 | |
32984 | Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction | |
32985 | set support. | |
32986 | ||
32987 | @item pentium3 | |
32988 | @itemx pentium3m | |
32989 | Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE | |
32990 | instruction set support. | |
32991 | ||
32992 | @item pentium-m | |
32993 | Intel Pentium M; low-power version of Intel Pentium III CPU | |
32994 | with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino | |
32995 | notebooks. | |
32996 | ||
32997 | @item pentium4 | |
32998 | @itemx pentium4m | |
32999 | Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support. | |
33000 | ||
33001 | @item prescott | |
33002 | Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR | |
33003 | instruction set support. | |
33004 | ||
33005 | @item nocona | |
33006 | Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE, | |
33007 | SSE2, SSE3 and FXSR instruction set support. | |
33008 | ||
33009 | @item core2 | |
33010 | Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16, | |
33011 | SAHF and FXSR instruction set support. | |
33012 | ||
33013 | @item nehalem | |
33014 | Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
33015 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support. | |
33016 | ||
33017 | @item westmere | |
33018 | Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
33019 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support. | |
33020 | ||
33021 | @item sandybridge | |
33022 | Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
33023 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set | |
33024 | support. | |
33025 | ||
33026 | @item ivybridge | |
33027 | Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
33028 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND | |
33029 | and F16C instruction set support. | |
33030 | ||
33031 | @item haswell | |
33032 | Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33033 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33034 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support. | |
33035 | ||
33036 | @item broadwell | |
33037 | Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33038 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33039 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW | |
33040 | instruction set support. | |
33041 | ||
33042 | @item skylake | |
33043 | Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33044 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33045 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
33046 | CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support. | |
33047 | ||
33048 | @item bonnell | |
33049 | Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3 | |
33050 | instruction set support. | |
33051 | ||
33052 | @item silvermont | |
33053 | Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33054 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND | |
33055 | instruction set support. | |
33056 | ||
33057 | @item goldmont | |
33058 | Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33059 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA, | |
33060 | RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction | |
33061 | set support. | |
33062 | ||
33063 | @item goldmont-plus | |
33064 | Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33065 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, | |
33066 | SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, | |
33067 | RDPID and SGX instruction set support. | |
33068 | ||
33069 | @item tremont | |
33070 | Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33071 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA, | |
33072 | RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID, | |
33073 | SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set | |
33074 | support. | |
33075 | ||
33076 | @item sierraforest | |
33077 | Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33078 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
33079 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
33080 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
33081 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
503643e8 LC |
33082 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set |
33083 | support. | |
d77de738 ML |
33084 | |
33085 | @item grandridge | |
33086 | Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33087 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
33088 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
33089 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
33090 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
503643e8 LC |
33091 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD, UINTR and RAOINT |
33092 | instruction set support. | |
d77de738 | 33093 | |
7370c479 HJ |
33094 | @item clearwaterforest |
33095 | Intel Clearwater Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, | |
33096 | SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, | |
33097 | XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, | |
33098 | MOVDIRI, MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, | |
33099 | LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
faa0e82b HJ |
33100 | ENQCMD, UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, |
33101 | SHA512, SM3, SM4, USER_MSR and PREFETCHI instruction set support. | |
f019251a | 33102 | |
d77de738 ML |
33103 | @item knl |
33104 | Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33105 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33106 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33107 | AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support. | |
33108 | ||
33109 | @item knm | |
33110 | Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33111 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33112 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33113 | AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW, | |
33114 | AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support. | |
33115 | ||
33116 | @item skylake-avx512 | |
33117 | Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33118 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33119 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33120 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, | |
33121 | AVX512DQ and AVX512CD instruction set support. | |
33122 | ||
33123 | @item cannonlake | |
33124 | Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, | |
33125 | SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, | |
33126 | FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, | |
33127 | PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, | |
33128 | AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set | |
33129 | support. | |
33130 | ||
33131 | @item icelake-client | |
33132 | Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33133 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33134 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33135 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
33136 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 | |
33137 | , VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. | |
33138 | ||
33139 | @item icelake-server | |
33140 | Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33141 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33142 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33143 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
33144 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 | |
33145 | , VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB | |
33146 | instruction set support. | |
33147 | ||
33148 | @item cascadelake | |
33149 | Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33150 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33151 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
33152 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, | |
33153 | AVX512CD and AVX512VNNI instruction set support. | |
33154 | ||
33155 | @item cooperlake | |
33156 | Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33157 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33158 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
33159 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, | |
33160 | AVX512CD, AVX512VNNI and AVX512BF16 instruction set support. | |
33161 | ||
33162 | @item tigerlake | |
33163 | Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33164 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33165 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
33166 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD | |
33167 | PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
33168 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB, | |
33169 | AVX512VP2INTERSECT and KEYLOCKER instruction set support. | |
33170 | ||
33171 | @item sapphirerapids | |
33172 | Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33173 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33174 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33175 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
33176 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
33177 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
33178 | MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, | |
29ecb952 | 33179 | UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16 |
d77de738 ML |
33180 | instruction set support. |
33181 | ||
33182 | @item alderlake | |
33183 | Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33184 | SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES, | |
33185 | XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B, | |
33186 | CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU, | |
33187 | VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set | |
33188 | support. | |
33189 | ||
33190 | @item rocketlake | |
33191 | Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3 | |
33192 | , SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33193 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
33194 | CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD | |
33195 | PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
33196 | VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. | |
33197 | ||
33198 | @item graniterapids | |
33199 | Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33200 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33201 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33202 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
33203 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
33204 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
38daaaa9 HJ |
33205 | MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, |
33206 | UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16, AVX512BF16, AMX-FP16 | |
33207 | and PREFETCHI instruction set support. | |
d77de738 | 33208 | |
a0cb65d3 MZ |
33209 | @item graniterapids-d |
33210 | Intel graniterapids D CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33211 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33212 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33213 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
33214 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
33215 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
38daaaa9 HJ |
33216 | MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, |
33217 | UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16, AVX512BF16, AMX-FP16, | |
33218 | PREFETCHI and AMX-COMPLEX instruction set support. | |
a0cb65d3 | 33219 | |
faa0e82b HJ |
33220 | @item arrowlake |
33221 | Intel Arrow Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33222 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
33223 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
33224 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
33225 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
33226 | UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set | |
33227 | support. | |
33228 | ||
33229 | @item arrowlake-s | |
33230 | Intel Arrow Lake S CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33231 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
33232 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
33233 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
33234 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
33235 | UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, | |
33236 | SM3 and SM4 instruction set support. | |
33237 | ||
33238 | @item pantherlake | |
33239 | Intel Panther Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33240 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
33241 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
33242 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
33243 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
33244 | UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, | |
33245 | SM3, SM4 and PREFETCHI instruction set support. | |
33246 | ||
d77de738 ML |
33247 | @item k6 |
33248 | AMD K6 CPU with MMX instruction set support. | |
33249 | ||
33250 | @item k6-2 | |
33251 | @itemx k6-3 | |
33252 | Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support. | |
33253 | ||
33254 | @item athlon | |
33255 | @itemx athlon-tbird | |
33256 | AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions | |
33257 | support. | |
33258 | ||
33259 | @item athlon-4 | |
33260 | @itemx athlon-xp | |
33261 | @itemx athlon-mp | |
33262 | Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE | |
33263 | instruction set support. | |
33264 | ||
33265 | @item k8 | |
33266 | @itemx opteron | |
33267 | @itemx athlon64 | |
33268 | @itemx athlon-fx | |
33269 | Processors based on the AMD K8 core with x86-64 instruction set support, | |
33270 | including the AMD Opteron, Athlon 64, and Athlon 64 FX processors. | |
33271 | (This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit | |
33272 | instruction set extensions.) | |
33273 | ||
33274 | @item k8-sse3 | |
33275 | @itemx opteron-sse3 | |
33276 | @itemx athlon64-sse3 | |
33277 | Improved versions of AMD K8 cores with SSE3 instruction set support. | |
33278 | ||
33279 | @item amdfam10 | |
33280 | @itemx barcelona | |
33281 | CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This | |
33282 | supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit | |
33283 | instruction set extensions.) | |
33284 | ||
33285 | @item bdver1 | |
33286 | CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This | |
33287 | supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, | |
33288 | SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.) | |
33289 | ||
33290 | @item bdver2 | |
33291 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
33292 | supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, | |
33293 | SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set | |
33294 | extensions.) | |
33295 | ||
33296 | @item bdver3 | |
33297 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
33298 | supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES, | |
33299 | PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and | |
33300 | 64-bit instruction set extensions.) | |
33301 | ||
33302 | @item bdver4 | |
33303 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
33304 | supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP, | |
33305 | AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, | |
33306 | SSE4.2, ABM and 64-bit instruction set extensions.) | |
33307 | ||
33308 | @item znver1 | |
33309 | AMD Family 17h core based CPUs with x86-64 instruction set support. (This | |
33310 | supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX, | |
33311 | SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, | |
33312 | SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit | |
33313 | instruction set extensions.) | |
33314 | ||
33315 | @item znver2 | |
33316 | AMD Family 17h core based CPUs with x86-64 instruction set support. (This | |
33317 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
33318 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
33319 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
33320 | WBNOINVD, and 64-bit instruction set extensions.) | |
33321 | ||
33322 | @item znver3 | |
33323 | AMD Family 19h core based CPUs with x86-64 instruction set support. (This | |
33324 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
33325 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
33326 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
33327 | WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.) | |
33328 | ||
33329 | @item znver4 | |
33330 | AMD Family 19h core based CPUs with x86-64 instruction set support. (This | |
33331 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
33332 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
33333 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
33334 | WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD, | |
33335 | AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI, | |
33336 | AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.) | |
33337 | ||
33338 | @item btver1 | |
33339 | CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This | |
33340 | supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit | |
33341 | instruction set extensions.) | |
33342 | ||
33343 | @item btver2 | |
33344 | CPUs based on AMD Family 16h cores with x86-64 instruction set support. This | |
33345 | includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM, | |
33346 | SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions. | |
33347 | ||
33348 | @item winchip-c6 | |
33349 | IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction | |
33350 | set support. | |
33351 | ||
33352 | @item winchip2 | |
33353 | IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@: | |
33354 | instruction set support. | |
33355 | ||
33356 | @item c3 | |
33357 | VIA C3 CPU with MMX and 3DNow!@: instruction set support. | |
33358 | (No scheduling is implemented for this chip.) | |
33359 | ||
33360 | @item c3-2 | |
33361 | VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support. | |
33362 | (No scheduling is implemented for this chip.) | |
33363 | ||
33364 | @item c7 | |
33365 | VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support. | |
33366 | (No scheduling is implemented for this chip.) | |
33367 | ||
33368 | @item samuel-2 | |
33369 | VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support. | |
33370 | (No scheduling is implemented for this chip.) | |
33371 | ||
33372 | @item nehemiah | |
33373 | VIA Eden Nehemiah CPU with MMX and SSE instruction set support. | |
33374 | (No scheduling is implemented for this chip.) | |
33375 | ||
33376 | @item esther | |
33377 | VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support. | |
33378 | (No scheduling is implemented for this chip.) | |
33379 | ||
33380 | @item eden-x2 | |
33381 | VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support. | |
33382 | (No scheduling is implemented for this chip.) | |
33383 | ||
33384 | @item eden-x4 | |
33385 | VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, | |
33386 | AVX and AVX2 instruction set support. | |
33387 | (No scheduling is implemented for this chip.) | |
33388 | ||
33389 | @item nano | |
33390 | Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
33391 | instruction set support. | |
33392 | (No scheduling is implemented for this chip.) | |
33393 | ||
33394 | @item nano-1000 | |
33395 | VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
33396 | instruction set support. | |
33397 | (No scheduling is implemented for this chip.) | |
33398 | ||
33399 | @item nano-2000 | |
33400 | VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
33401 | instruction set support. | |
33402 | (No scheduling is implemented for this chip.) | |
33403 | ||
33404 | @item nano-3000 | |
33405 | VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
33406 | instruction set support. | |
33407 | (No scheduling is implemented for this chip.) | |
33408 | ||
33409 | @item nano-x2 | |
33410 | VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
33411 | instruction set support. | |
33412 | (No scheduling is implemented for this chip.) | |
33413 | ||
33414 | @item nano-x4 | |
33415 | VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
33416 | instruction set support. | |
33417 | (No scheduling is implemented for this chip.) | |
33418 | ||
33419 | @item lujiazui | |
33420 | ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, | |
33421 | SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16, | |
33422 | ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support. | |
33423 | ||
94c0b26f M |
33424 | @item yongfeng |
33425 | ZHAOXIN yongfeng CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, | |
33426 | SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16, | |
33427 | ABM, BMI, BMI2, F16C, FXSR, RDSEED, AVX2, FMA, SHA, LZCNT | |
33428 | instruction set support. | |
33429 | ||
d77de738 ML |
33430 | @item geode |
33431 | AMD Geode embedded processor with MMX and 3DNow!@: instruction set support. | |
33432 | @end table | |
33433 | ||
d77de738 | 33434 | @opindex mtune |
ddf6fe37 | 33435 | @item -mtune=@var{cpu-type} |
d77de738 ML |
33436 | Tune to @var{cpu-type} everything applicable about the generated code, except |
33437 | for the ABI and the set of available instructions. | |
33438 | While picking a specific @var{cpu-type} schedules things appropriately | |
33439 | for that particular chip, the compiler does not generate any code that | |
33440 | cannot run on the default machine type unless you use a | |
33441 | @option{-march=@var{cpu-type}} option. | |
33442 | For example, if GCC is configured for i686-pc-linux-gnu | |
33443 | then @option{-mtune=pentium4} generates code that is tuned for Pentium 4 | |
33444 | but still runs on i686 machines. | |
33445 | ||
33446 | The choices for @var{cpu-type} are the same as for @option{-march}. | |
33447 | In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}: | |
33448 | ||
33449 | @table @samp | |
33450 | @item generic | |
33451 | Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors. | |
33452 | If you know the CPU on which your code will run, then you should use | |
33453 | the corresponding @option{-mtune} or @option{-march} option instead of | |
33454 | @option{-mtune=generic}. But, if you do not know exactly what CPU users | |
33455 | of your application will have, then you should use this option. | |
33456 | ||
33457 | As new processors are deployed in the marketplace, the behavior of this | |
33458 | option will change. Therefore, if you upgrade to a newer version of | |
33459 | GCC, code generation controlled by this option will change to reflect | |
33460 | the processors | |
33461 | that are most common at the time that version of GCC is released. | |
33462 | ||
33463 | There is no @option{-march=generic} option because @option{-march} | |
33464 | indicates the instruction set the compiler can use, and there is no | |
33465 | generic instruction set applicable to all processors. In contrast, | |
33466 | @option{-mtune} indicates the processor (or, in this case, collection of | |
33467 | processors) for which the code is optimized. | |
33468 | ||
33469 | @item intel | |
33470 | Produce code optimized for the most current Intel processors, which are | |
33471 | Haswell and Silvermont for this version of GCC. If you know the CPU | |
33472 | on which your code will run, then you should use the corresponding | |
33473 | @option{-mtune} or @option{-march} option instead of @option{-mtune=intel}. | |
33474 | But, if you want your application performs better on both Haswell and | |
33475 | Silvermont, then you should use this option. | |
33476 | ||
33477 | As new Intel processors are deployed in the marketplace, the behavior of | |
33478 | this option will change. Therefore, if you upgrade to a newer version of | |
33479 | GCC, code generation controlled by this option will change to reflect | |
33480 | the most current Intel processors at the time that version of GCC is | |
33481 | released. | |
33482 | ||
33483 | There is no @option{-march=intel} option because @option{-march} indicates | |
33484 | the instruction set the compiler can use, and there is no common | |
33485 | instruction set applicable to all processors. In contrast, | |
33486 | @option{-mtune} indicates the processor (or, in this case, collection of | |
33487 | processors) for which the code is optimized. | |
33488 | @end table | |
33489 | ||
d77de738 | 33490 | @opindex mcpu |
ddf6fe37 | 33491 | @item -mcpu=@var{cpu-type} |
d77de738 ML |
33492 | A deprecated synonym for @option{-mtune}. |
33493 | ||
d77de738 | 33494 | @opindex mfpmath |
ddf6fe37 | 33495 | @item -mfpmath=@var{unit} |
d77de738 ML |
33496 | Generate floating-point arithmetic for selected unit @var{unit}. The choices |
33497 | for @var{unit} are: | |
33498 | ||
33499 | @table @samp | |
33500 | @item 387 | |
33501 | Use the standard 387 floating-point coprocessor present on the majority of chips and | |
33502 | emulated otherwise. Code compiled with this option runs almost everywhere. | |
33503 | The temporary results are computed in 80-bit precision instead of the precision | |
33504 | specified by the type, resulting in slightly different results compared to most | |
33505 | of other chips. See @option{-ffloat-store} for more detailed description. | |
33506 | ||
33507 | This is the default choice for non-Darwin x86-32 targets. | |
33508 | ||
33509 | @item sse | |
33510 | Use scalar floating-point instructions present in the SSE instruction set. | |
33511 | This instruction set is supported by Pentium III and newer chips, | |
33512 | and in the AMD line | |
33513 | by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE | |
33514 | instruction set supports only single-precision arithmetic, thus the double and | |
33515 | extended-precision arithmetic are still done using 387. A later version, present | |
33516 | only in Pentium 4 and AMD x86-64 chips, supports double-precision | |
33517 | arithmetic too. | |
33518 | ||
33519 | For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse} | |
33520 | or @option{-msse2} switches to enable SSE extensions and make this option | |
33521 | effective. For the x86-64 compiler, these extensions are enabled by default. | |
33522 | ||
33523 | The resulting code should be considerably faster in the majority of cases and avoid | |
33524 | the numerical instability problems of 387 code, but may break some existing | |
33525 | code that expects temporaries to be 80 bits. | |
33526 | ||
33527 | This is the default choice for the x86-64 compiler, Darwin x86-32 targets, | |
33528 | and the default choice for x86-32 targets with the SSE2 instruction set | |
33529 | when @option{-ffast-math} is enabled. | |
33530 | ||
33531 | @item sse,387 | |
33532 | @itemx sse+387 | |
33533 | @itemx both | |
33534 | Attempt to utilize both instruction sets at once. This effectively doubles the | |
33535 | amount of available registers, and on chips with separate execution units for | |
33536 | 387 and SSE the execution resources too. Use this option with care, as it is | |
33537 | still experimental, because the GCC register allocator does not model separate | |
33538 | functional units well, resulting in unstable performance. | |
33539 | @end table | |
33540 | ||
d77de738 | 33541 | @opindex masm=@var{dialect} |
ddf6fe37 | 33542 | @item -masm=@var{dialect} |
d77de738 ML |
33543 | Output assembly instructions using selected @var{dialect}. Also affects |
33544 | which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and | |
33545 | extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect | |
33546 | order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does | |
33547 | not support @samp{intel}. | |
33548 | ||
d77de738 ML |
33549 | @opindex mieee-fp |
33550 | @opindex mno-ieee-fp | |
ddf6fe37 AA |
33551 | @item -mieee-fp |
33552 | @itemx -mno-ieee-fp | |
d77de738 ML |
33553 | Control whether or not the compiler uses IEEE floating-point |
33554 | comparisons. These correctly handle the case where the result of a | |
33555 | comparison is unordered. | |
33556 | ||
30348d30 | 33557 | @opindex m80387 |
d77de738 | 33558 | @opindex mhard-float |
ddf6fe37 AA |
33559 | @item -m80387 |
33560 | @itemx -mhard-float | |
d77de738 ML |
33561 | Generate output containing 80387 instructions for floating point. |
33562 | ||
d77de738 ML |
33563 | @opindex no-80387 |
33564 | @opindex msoft-float | |
ddf6fe37 AA |
33565 | @item -mno-80387 |
33566 | @itemx -msoft-float | |
d77de738 ML |
33567 | Generate output containing library calls for floating point. |
33568 | ||
33569 | @strong{Warning:} the requisite libraries are not part of GCC@. | |
33570 | Normally the facilities of the machine's usual C compiler are used, but | |
33571 | this cannot be done directly in cross-compilation. You must make your | |
33572 | own arrangements to provide suitable library functions for | |
33573 | cross-compilation. | |
33574 | ||
33575 | On machines where a function returns floating-point results in the 80387 | |
33576 | register stack, some floating-point opcodes may be emitted even if | |
33577 | @option{-msoft-float} is used. | |
33578 | ||
d77de738 ML |
33579 | @opindex mno-fp-ret-in-387 |
33580 | @opindex mfp-ret-in-387 | |
ddf6fe37 | 33581 | @item -mno-fp-ret-in-387 |
d77de738 ML |
33582 | Do not use the FPU registers for return values of functions. |
33583 | ||
33584 | The usual calling convention has functions return values of types | |
33585 | @code{float} and @code{double} in an FPU register, even if there | |
33586 | is no FPU@. The idea is that the operating system should emulate | |
33587 | an FPU@. | |
33588 | ||
33589 | The option @option{-mno-fp-ret-in-387} causes such values to be returned | |
33590 | in ordinary CPU registers instead. | |
33591 | ||
d77de738 ML |
33592 | @opindex mno-fancy-math-387 |
33593 | @opindex mfancy-math-387 | |
ddf6fe37 | 33594 | @item -mno-fancy-math-387 |
d77de738 ML |
33595 | Some 387 emulators do not support the @code{sin}, @code{cos} and |
33596 | @code{sqrt} instructions for the 387. Specify this option to avoid | |
33597 | generating those instructions. | |
33598 | This option is overridden when @option{-march} | |
33599 | indicates that the target CPU always has an FPU and so the | |
33600 | instruction does not need emulation. These | |
33601 | instructions are not generated unless you also use the | |
33602 | @option{-funsafe-math-optimizations} switch. | |
33603 | ||
d77de738 ML |
33604 | @opindex malign-double |
33605 | @opindex mno-align-double | |
ddf6fe37 AA |
33606 | @item -malign-double |
33607 | @itemx -mno-align-double | |
d77de738 ML |
33608 | Control whether GCC aligns @code{double}, @code{long double}, and |
33609 | @code{long long} variables on a two-word boundary or a one-word | |
33610 | boundary. Aligning @code{double} variables on a two-word boundary | |
33611 | produces code that runs somewhat faster on a Pentium at the | |
33612 | expense of more memory. | |
33613 | ||
33614 | On x86-64, @option{-malign-double} is enabled by default. | |
33615 | ||
33616 | @strong{Warning:} if you use the @option{-malign-double} switch, | |
33617 | structures containing the above types are aligned differently than | |
33618 | the published application binary interface specifications for the x86-32 | |
33619 | and are not binary compatible with structures in code compiled | |
33620 | without that switch. | |
33621 | ||
d77de738 ML |
33622 | @opindex m96bit-long-double |
33623 | @opindex m128bit-long-double | |
ddf6fe37 AA |
33624 | @item -m96bit-long-double |
33625 | @itemx -m128bit-long-double | |
d77de738 ML |
33626 | These switches control the size of @code{long double} type. The x86-32 |
33627 | application binary interface specifies the size to be 96 bits, | |
33628 | so @option{-m96bit-long-double} is the default in 32-bit mode. | |
33629 | ||
33630 | Modern architectures (Pentium and newer) prefer @code{long double} | |
33631 | to be aligned to an 8- or 16-byte boundary. In arrays or structures | |
33632 | conforming to the ABI, this is not possible. So specifying | |
33633 | @option{-m128bit-long-double} aligns @code{long double} | |
33634 | to a 16-byte boundary by padding the @code{long double} with an additional | |
33635 | 32-bit zero. | |
33636 | ||
33637 | In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as | |
33638 | its ABI specifies that @code{long double} is aligned on 16-byte boundary. | |
33639 | ||
33640 | Notice that neither of these options enable any extra precision over the x87 | |
33641 | standard of 80 bits for a @code{long double}. | |
33642 | ||
33643 | @strong{Warning:} if you override the default value for your target ABI, this | |
33644 | changes the size of | |
33645 | structures and arrays containing @code{long double} variables, | |
33646 | as well as modifying the function calling convention for functions taking | |
33647 | @code{long double}. Hence they are not binary-compatible | |
33648 | with code compiled without that switch. | |
33649 | ||
d77de738 ML |
33650 | @opindex mlong-double-64 |
33651 | @opindex mlong-double-80 | |
33652 | @opindex mlong-double-128 | |
ddf6fe37 AA |
33653 | @item -mlong-double-64 |
33654 | @itemx -mlong-double-80 | |
33655 | @itemx -mlong-double-128 | |
d77de738 ML |
33656 | These switches control the size of @code{long double} type. A size |
33657 | of 64 bits makes the @code{long double} type equivalent to the @code{double} | |
33658 | type. This is the default for 32-bit Bionic C library. A size | |
33659 | of 128 bits makes the @code{long double} type equivalent to the | |
33660 | @code{__float128} type. This is the default for 64-bit Bionic C library. | |
33661 | ||
33662 | @strong{Warning:} if you override the default value for your target ABI, this | |
33663 | changes the size of | |
33664 | structures and arrays containing @code{long double} variables, | |
33665 | as well as modifying the function calling convention for functions taking | |
33666 | @code{long double}. Hence they are not binary-compatible | |
33667 | with code compiled without that switch. | |
33668 | ||
d77de738 | 33669 | @opindex malign-data |
ddf6fe37 | 33670 | @item -malign-data=@var{type} |
d77de738 ML |
33671 | Control how GCC aligns variables. Supported values for @var{type} are |
33672 | @samp{compat} uses increased alignment value compatible uses GCC 4.8 | |
33673 | and earlier, @samp{abi} uses alignment value as specified by the | |
33674 | psABI, and @samp{cacheline} uses increased alignment value to match | |
33675 | the cache line size. @samp{compat} is the default. | |
33676 | ||
d77de738 | 33677 | @opindex mlarge-data-threshold |
ddf6fe37 | 33678 | @item -mlarge-data-threshold=@var{threshold} |
1a64156c UB |
33679 | When @option{-mcmodel=medium} or @option{-mcmodel=large} is specified, data |
33680 | objects larger than @var{threshold} are placed in large data sections. The | |
33681 | default is 65535. | |
d77de738 | 33682 | |
d77de738 | 33683 | @opindex mrtd |
ddf6fe37 | 33684 | @item -mrtd |
d77de738 ML |
33685 | Use a different function-calling convention, in which functions that |
33686 | take a fixed number of arguments return with the @code{ret @var{num}} | |
33687 | instruction, which pops their arguments while returning. This saves one | |
33688 | instruction in the caller since there is no need to pop the arguments | |
33689 | there. | |
33690 | ||
33691 | You can specify that an individual function is called with this calling | |
33692 | sequence with the function attribute @code{stdcall}. You can also | |
33693 | override the @option{-mrtd} option by using the function attribute | |
33694 | @code{cdecl}. @xref{Function Attributes}. | |
33695 | ||
33696 | @strong{Warning:} this calling convention is incompatible with the one | |
33697 | normally used on Unix, so you cannot use it if you need to call | |
33698 | libraries compiled with the Unix compiler. | |
33699 | ||
33700 | Also, you must provide function prototypes for all functions that | |
33701 | take variable numbers of arguments (including @code{printf}); | |
33702 | otherwise incorrect code is generated for calls to those | |
33703 | functions. | |
33704 | ||
33705 | In addition, seriously incorrect code results if you call a | |
33706 | function with too many arguments. (Normally, extra arguments are | |
33707 | harmlessly ignored.) | |
33708 | ||
d77de738 | 33709 | @opindex mregparm |
ddf6fe37 | 33710 | @item -mregparm=@var{num} |
d77de738 ML |
33711 | Control how many registers are used to pass integer arguments. By |
33712 | default, no registers are used to pass arguments, and at most 3 | |
33713 | registers can be used. You can control this behavior for a specific | |
33714 | function by using the function attribute @code{regparm}. | |
33715 | @xref{Function Attributes}. | |
33716 | ||
33717 | @strong{Warning:} if you use this switch, and | |
33718 | @var{num} is nonzero, then you must build all modules with the same | |
33719 | value, including any libraries. This includes the system libraries and | |
33720 | startup modules. | |
33721 | ||
d77de738 | 33722 | @opindex msseregparm |
ddf6fe37 | 33723 | @item -msseregparm |
d77de738 ML |
33724 | Use SSE register passing conventions for float and double arguments |
33725 | and return values. You can control this behavior for a specific | |
33726 | function by using the function attribute @code{sseregparm}. | |
33727 | @xref{Function Attributes}. | |
33728 | ||
33729 | @strong{Warning:} if you use this switch then you must build all | |
33730 | modules with the same value, including any libraries. This includes | |
33731 | the system libraries and startup modules. | |
33732 | ||
d77de738 | 33733 | @opindex mvect8-ret-in-mem |
ddf6fe37 | 33734 | @item -mvect8-ret-in-mem |
d77de738 ML |
33735 | Return 8-byte vectors in memory instead of MMX registers. This is the |
33736 | default on VxWorks to match the ABI of the Sun Studio compilers until | |
33737 | version 12. @emph{Only} use this option if you need to remain | |
33738 | compatible with existing code produced by those previous compiler | |
33739 | versions or older versions of GCC@. | |
33740 | ||
d77de738 ML |
33741 | @opindex mpc32 |
33742 | @opindex mpc64 | |
33743 | @opindex mpc80 | |
ddf6fe37 AA |
33744 | @item -mpc32 |
33745 | @itemx -mpc64 | |
33746 | @itemx -mpc80 | |
d77de738 ML |
33747 | |
33748 | Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32} | |
33749 | is specified, the significands of results of floating-point operations are | |
33750 | rounded to 24 bits (single precision); @option{-mpc64} rounds the | |
33751 | significands of results of floating-point operations to 53 bits (double | |
33752 | precision) and @option{-mpc80} rounds the significands of results of | |
33753 | floating-point operations to 64 bits (extended double precision), which is | |
33754 | the default. When this option is used, floating-point operations in higher | |
33755 | precisions are not available to the programmer without setting the FPU | |
33756 | control word explicitly. | |
33757 | ||
33758 | Setting the rounding of floating-point operations to less than the default | |
33759 | 80 bits can speed some programs by 2% or more. Note that some mathematical | |
33760 | libraries assume that extended-precision (80-bit) floating-point operations | |
33761 | are enabled by default; routines in such libraries could suffer significant | |
33762 | loss of accuracy, typically through so-called ``catastrophic cancellation'', | |
33763 | when this option is used to set the precision to less than extended precision. | |
33764 | ||
e54375d8 | 33765 | @opindex mdaz-ftz |
ddf6fe37 | 33766 | @item -mdaz-ftz |
e54375d8 | 33767 | |
33768 | The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register | |
33769 | are used to control floating-point calculations.SSE and AVX instructions | |
33770 | including scalar and vector instructions could benefit from enabling the FTZ | |
33771 | and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags | |
33772 | when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz} | |
33773 | will set FTZ/DAZ flags even with @option{-shared}. | |
33774 | ||
d77de738 | 33775 | @opindex mstackrealign |
ddf6fe37 | 33776 | @item -mstackrealign |
d77de738 ML |
33777 | Realign the stack at entry. On the x86, the @option{-mstackrealign} |
33778 | option generates an alternate prologue and epilogue that realigns the | |
33779 | run-time stack if necessary. This supports mixing legacy codes that keep | |
33780 | 4-byte stack alignment with modern codes that keep 16-byte stack alignment for | |
33781 | SSE compatibility. See also the attribute @code{force_align_arg_pointer}, | |
33782 | applicable to individual functions. | |
33783 | ||
d77de738 | 33784 | @opindex mpreferred-stack-boundary |
ddf6fe37 | 33785 | @item -mpreferred-stack-boundary=@var{num} |
d77de738 ML |
33786 | Attempt to keep the stack boundary aligned to a 2 raised to @var{num} |
33787 | byte boundary. If @option{-mpreferred-stack-boundary} is not specified, | |
33788 | the default is 4 (16 bytes or 128 bits). | |
33789 | ||
33790 | @strong{Warning:} When generating code for the x86-64 architecture with | |
33791 | SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be | |
33792 | used to keep the stack boundary aligned to 8 byte boundary. Since | |
33793 | x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and | |
33794 | intended to be used in controlled environment where stack space is | |
33795 | important limitation. This option leads to wrong code when functions | |
33796 | compiled with 16 byte stack alignment (such as functions from a standard | |
33797 | library) are called with misaligned stack. In this case, SSE | |
33798 | instructions may lead to misaligned memory access traps. In addition, | |
33799 | variable arguments are handled incorrectly for 16 byte aligned | |
33800 | objects (including x87 long double and __int128), leading to wrong | |
33801 | results. You must build all modules with | |
33802 | @option{-mpreferred-stack-boundary=3}, including any libraries. This | |
33803 | includes the system libraries and startup modules. | |
33804 | ||
d77de738 | 33805 | @opindex mincoming-stack-boundary |
ddf6fe37 | 33806 | @item -mincoming-stack-boundary=@var{num} |
d77de738 ML |
33807 | Assume the incoming stack is aligned to a 2 raised to @var{num} byte |
33808 | boundary. If @option{-mincoming-stack-boundary} is not specified, | |
33809 | the one specified by @option{-mpreferred-stack-boundary} is used. | |
33810 | ||
33811 | On Pentium and Pentium Pro, @code{double} and @code{long double} values | |
33812 | should be aligned to an 8-byte boundary (see @option{-malign-double}) or | |
33813 | suffer significant run time performance penalties. On Pentium III, the | |
33814 | Streaming SIMD Extension (SSE) data type @code{__m128} may not work | |
33815 | properly if it is not 16-byte aligned. | |
33816 | ||
33817 | To ensure proper alignment of this values on the stack, the stack boundary | |
33818 | must be as aligned as that required by any value stored on the stack. | |
33819 | Further, every function must be generated such that it keeps the stack | |
33820 | aligned. Thus calling a function compiled with a higher preferred | |
33821 | stack boundary from a function compiled with a lower preferred stack | |
33822 | boundary most likely misaligns the stack. It is recommended that | |
33823 | libraries that use callbacks always use the default setting. | |
33824 | ||
33825 | This extra alignment does consume extra stack space, and generally | |
33826 | increases code size. Code that is sensitive to stack space usage, such | |
33827 | as embedded systems and operating system kernels, may want to reduce the | |
33828 | preferred alignment to @option{-mpreferred-stack-boundary=2}. | |
33829 | ||
33830 | @need 200 | |
d77de738 | 33831 | @opindex mmmx |
ddf6fe37 | 33832 | @item -mmmx |
d77de738 | 33833 | @need 200 |
d77de738 | 33834 | @opindex msse |
ddf6fe37 | 33835 | @itemx -msse |
d77de738 | 33836 | @need 200 |
d77de738 | 33837 | @opindex msse2 |
ddf6fe37 | 33838 | @itemx -msse2 |
d77de738 | 33839 | @need 200 |
d77de738 | 33840 | @opindex msse3 |
ddf6fe37 | 33841 | @itemx -msse3 |
d77de738 | 33842 | @need 200 |
d77de738 | 33843 | @opindex mssse3 |
ddf6fe37 | 33844 | @itemx -mssse3 |
d77de738 | 33845 | @need 200 |
d77de738 | 33846 | @opindex msse4 |
ddf6fe37 | 33847 | @itemx -msse4 |
d77de738 | 33848 | @need 200 |
d77de738 | 33849 | @opindex msse4a |
ddf6fe37 | 33850 | @itemx -msse4a |
d77de738 | 33851 | @need 200 |
d77de738 | 33852 | @opindex msse4.1 |
ddf6fe37 | 33853 | @itemx -msse4.1 |
d77de738 | 33854 | @need 200 |
d77de738 | 33855 | @opindex msse4.2 |
ddf6fe37 | 33856 | @itemx -msse4.2 |
d77de738 | 33857 | @need 200 |
d77de738 | 33858 | @opindex mavx |
ddf6fe37 | 33859 | @itemx -mavx |
d77de738 | 33860 | @need 200 |
d77de738 | 33861 | @opindex mavx2 |
ddf6fe37 | 33862 | @itemx -mavx2 |
d77de738 | 33863 | @need 200 |
d77de738 | 33864 | @opindex mavx512f |
ddf6fe37 | 33865 | @itemx -mavx512f |
d77de738 | 33866 | @need 200 |
d77de738 | 33867 | @opindex mavx512pf |
ddf6fe37 | 33868 | @itemx -mavx512pf |
d77de738 | 33869 | @need 200 |
d77de738 | 33870 | @opindex mavx512er |
ddf6fe37 | 33871 | @itemx -mavx512er |
d77de738 | 33872 | @need 200 |
d77de738 | 33873 | @opindex mavx512cd |
ddf6fe37 | 33874 | @itemx -mavx512cd |
d77de738 | 33875 | @need 200 |
d77de738 | 33876 | @opindex mavx512vl |
ddf6fe37 | 33877 | @itemx -mavx512vl |
d77de738 | 33878 | @need 200 |
d77de738 | 33879 | @opindex mavx512bw |
ddf6fe37 | 33880 | @itemx -mavx512bw |
d77de738 | 33881 | @need 200 |
d77de738 | 33882 | @opindex mavx512dq |
ddf6fe37 | 33883 | @itemx -mavx512dq |
d77de738 | 33884 | @need 200 |
d77de738 | 33885 | @opindex mavx512ifma |
ddf6fe37 | 33886 | @itemx -mavx512ifma |
d77de738 | 33887 | @need 200 |
d77de738 | 33888 | @opindex mavx512vbmi |
ddf6fe37 | 33889 | @itemx -mavx512vbmi |
d77de738 | 33890 | @need 200 |
d77de738 | 33891 | @opindex msha |
ddf6fe37 | 33892 | @itemx -msha |
d77de738 | 33893 | @need 200 |
d77de738 | 33894 | @opindex maes |
ddf6fe37 | 33895 | @itemx -maes |
d77de738 | 33896 | @need 200 |
d77de738 | 33897 | @opindex mpclmul |
ddf6fe37 | 33898 | @itemx -mpclmul |
d77de738 | 33899 | @need 200 |
d77de738 | 33900 | @opindex mclflushopt |
ddf6fe37 | 33901 | @itemx -mclflushopt |
d77de738 | 33902 | @need 200 |
d77de738 | 33903 | @opindex mclwb |
ddf6fe37 | 33904 | @itemx -mclwb |
d77de738 | 33905 | @need 200 |
d77de738 | 33906 | @opindex mfsgsbase |
ddf6fe37 | 33907 | @itemx -mfsgsbase |
d77de738 | 33908 | @need 200 |
d77de738 | 33909 | @opindex mptwrite |
ddf6fe37 | 33910 | @itemx -mptwrite |
d77de738 | 33911 | @need 200 |
d77de738 | 33912 | @opindex mrdrnd |
ddf6fe37 | 33913 | @itemx -mrdrnd |
d77de738 | 33914 | @need 200 |
d77de738 | 33915 | @opindex mf16c |
ddf6fe37 | 33916 | @itemx -mf16c |
d77de738 | 33917 | @need 200 |
d77de738 | 33918 | @opindex mfma |
ddf6fe37 | 33919 | @itemx -mfma |
d77de738 | 33920 | @need 200 |
d77de738 | 33921 | @opindex mpconfig |
ddf6fe37 | 33922 | @itemx -mpconfig |
d77de738 | 33923 | @need 200 |
d77de738 | 33924 | @opindex mwbnoinvd |
ddf6fe37 | 33925 | @itemx -mwbnoinvd |
d77de738 | 33926 | @need 200 |
d77de738 | 33927 | @opindex mfma4 |
ddf6fe37 | 33928 | @itemx -mfma4 |
d77de738 | 33929 | @need 200 |
d77de738 | 33930 | @opindex mprfchw |
ddf6fe37 | 33931 | @itemx -mprfchw |
d77de738 | 33932 | @need 200 |
d77de738 | 33933 | @opindex mrdpid |
ddf6fe37 | 33934 | @itemx -mrdpid |
d77de738 | 33935 | @need 200 |
d77de738 | 33936 | @opindex mprefetchwt1 |
ddf6fe37 | 33937 | @itemx -mprefetchwt1 |
d77de738 | 33938 | @need 200 |
d77de738 | 33939 | @opindex mrdseed |
ddf6fe37 | 33940 | @itemx -mrdseed |
d77de738 | 33941 | @need 200 |
d77de738 | 33942 | @opindex msgx |
ddf6fe37 | 33943 | @itemx -msgx |
d77de738 | 33944 | @need 200 |
d77de738 | 33945 | @opindex mxop |
ddf6fe37 | 33946 | @itemx -mxop |
d77de738 | 33947 | @need 200 |
d77de738 | 33948 | @opindex mlwp |
ddf6fe37 | 33949 | @itemx -mlwp |
d77de738 | 33950 | @need 200 |
d77de738 | 33951 | @opindex m3dnow |
ddf6fe37 | 33952 | @itemx -m3dnow |
d77de738 | 33953 | @need 200 |
d77de738 | 33954 | @opindex m3dnowa |
ddf6fe37 | 33955 | @itemx -m3dnowa |
d77de738 | 33956 | @need 200 |
d77de738 | 33957 | @opindex mpopcnt |
ddf6fe37 | 33958 | @itemx -mpopcnt |
d77de738 | 33959 | @need 200 |
d77de738 | 33960 | @opindex mabm |
ddf6fe37 | 33961 | @itemx -mabm |
d77de738 | 33962 | @need 200 |
d77de738 | 33963 | @opindex madx |
ddf6fe37 | 33964 | @itemx -madx |
d77de738 | 33965 | @need 200 |
d77de738 | 33966 | @opindex mbmi |
ddf6fe37 | 33967 | @itemx -mbmi |
d77de738 | 33968 | @need 200 |
d77de738 | 33969 | @opindex mbmi2 |
ddf6fe37 | 33970 | @itemx -mbmi2 |
d77de738 | 33971 | @need 200 |
d77de738 | 33972 | @opindex mlzcnt |
ddf6fe37 | 33973 | @itemx -mlzcnt |
d77de738 | 33974 | @need 200 |
d77de738 | 33975 | @opindex mfxsr |
ddf6fe37 | 33976 | @itemx -mfxsr |
d77de738 | 33977 | @need 200 |
d77de738 | 33978 | @opindex mxsave |
ddf6fe37 | 33979 | @itemx -mxsave |
d77de738 | 33980 | @need 200 |
d77de738 | 33981 | @opindex mxsaveopt |
ddf6fe37 | 33982 | @itemx -mxsaveopt |
d77de738 | 33983 | @need 200 |
d77de738 | 33984 | @opindex mxsavec |
ddf6fe37 | 33985 | @itemx -mxsavec |
d77de738 | 33986 | @need 200 |
d77de738 | 33987 | @opindex mxsaves |
ddf6fe37 | 33988 | @itemx -mxsaves |
d77de738 | 33989 | @need 200 |
d77de738 | 33990 | @opindex mrtm |
ddf6fe37 | 33991 | @itemx -mrtm |
d77de738 | 33992 | @need 200 |
d77de738 | 33993 | @opindex mhle |
ddf6fe37 | 33994 | @itemx -mhle |
d77de738 | 33995 | @need 200 |
d77de738 | 33996 | @opindex mtbm |
ddf6fe37 | 33997 | @itemx -mtbm |
d77de738 | 33998 | @need 200 |
d77de738 | 33999 | @opindex mmwaitx |
ddf6fe37 | 34000 | @itemx -mmwaitx |
d77de738 | 34001 | @need 200 |
d77de738 | 34002 | @opindex mclzero |
ddf6fe37 | 34003 | @itemx -mclzero |
d77de738 | 34004 | @need 200 |
d77de738 | 34005 | @opindex mpku |
ddf6fe37 | 34006 | @itemx -mpku |
d77de738 | 34007 | @need 200 |
d77de738 | 34008 | @opindex mavx512vbmi2 |
ddf6fe37 | 34009 | @itemx -mavx512vbmi2 |
d77de738 | 34010 | @need 200 |
d77de738 | 34011 | @opindex mavx512bf16 |
ddf6fe37 | 34012 | @itemx -mavx512bf16 |
d77de738 | 34013 | @need 200 |
d77de738 | 34014 | @opindex mavx512fp16 |
ddf6fe37 | 34015 | @itemx -mavx512fp16 |
d77de738 | 34016 | @need 200 |
d77de738 | 34017 | @opindex mgfni |
ddf6fe37 | 34018 | @itemx -mgfni |
d77de738 | 34019 | @need 200 |
d77de738 | 34020 | @opindex mvaes |
ddf6fe37 | 34021 | @itemx -mvaes |
d77de738 | 34022 | @need 200 |
d77de738 | 34023 | @opindex mwaitpkg |
ddf6fe37 | 34024 | @itemx -mwaitpkg |
d77de738 | 34025 | @need 200 |
d77de738 | 34026 | @opindex mvpclmulqdq |
ddf6fe37 | 34027 | @itemx -mvpclmulqdq |
d77de738 | 34028 | @need 200 |
d77de738 | 34029 | @opindex mavx512bitalg |
ddf6fe37 | 34030 | @itemx -mavx512bitalg |
d77de738 | 34031 | @need 200 |
d77de738 | 34032 | @opindex mmovdiri |
ddf6fe37 | 34033 | @itemx -mmovdiri |
d77de738 | 34034 | @need 200 |
d77de738 | 34035 | @opindex mmovdir64b |
ddf6fe37 | 34036 | @itemx -mmovdir64b |
d77de738 | 34037 | @need 200 |
d77de738 | 34038 | @opindex menqcmd |
d77de738 | 34039 | @opindex muintr |
ddf6fe37 AA |
34040 | @itemx -menqcmd |
34041 | @itemx -muintr | |
d77de738 | 34042 | @need 200 |
d77de738 | 34043 | @opindex mtsxldtrk |
ddf6fe37 | 34044 | @itemx -mtsxldtrk |
d77de738 | 34045 | @need 200 |
d77de738 | 34046 | @opindex mavx512vpopcntdq |
ddf6fe37 | 34047 | @itemx -mavx512vpopcntdq |
d77de738 | 34048 | @need 200 |
d77de738 | 34049 | @opindex mavx512vp2intersect |
ddf6fe37 | 34050 | @itemx -mavx512vp2intersect |
d77de738 | 34051 | @need 200 |
d77de738 | 34052 | @opindex mavx5124fmaps |
ddf6fe37 | 34053 | @itemx -mavx5124fmaps |
d77de738 | 34054 | @need 200 |
d77de738 | 34055 | @opindex mavx512vnni |
ddf6fe37 | 34056 | @itemx -mavx512vnni |
d77de738 | 34057 | @need 200 |
d77de738 | 34058 | @opindex mavxvnni |
ddf6fe37 | 34059 | @itemx -mavxvnni |
d77de738 | 34060 | @need 200 |
d77de738 | 34061 | @opindex mavx5124vnniw |
ddf6fe37 | 34062 | @itemx -mavx5124vnniw |
d77de738 | 34063 | @need 200 |
d77de738 | 34064 | @opindex mcldemote |
ddf6fe37 | 34065 | @itemx -mcldemote |
d77de738 | 34066 | @need 200 |
d77de738 | 34067 | @opindex mserialize |
ddf6fe37 | 34068 | @itemx -mserialize |
d77de738 | 34069 | @need 200 |
d77de738 | 34070 | @opindex mamx-tile |
ddf6fe37 | 34071 | @itemx -mamx-tile |
d77de738 | 34072 | @need 200 |
d77de738 | 34073 | @opindex mamx-int8 |
ddf6fe37 | 34074 | @itemx -mamx-int8 |
d77de738 | 34075 | @need 200 |
d77de738 | 34076 | @opindex mamx-bf16 |
ddf6fe37 | 34077 | @itemx -mamx-bf16 |
d77de738 | 34078 | @need 200 |
d77de738 | 34079 | @opindex mhreset |
d77de738 | 34080 | @opindex mkl |
ddf6fe37 AA |
34081 | @itemx -mhreset |
34082 | @itemx -mkl | |
d77de738 | 34083 | @need 200 |
d77de738 | 34084 | @opindex mwidekl |
ddf6fe37 | 34085 | @itemx -mwidekl |
d77de738 | 34086 | @need 200 |
d77de738 | 34087 | @opindex mavxifma |
ddf6fe37 | 34088 | @itemx -mavxifma |
d77de738 | 34089 | @need 200 |
d77de738 | 34090 | @opindex mavxvnniint8 |
ddf6fe37 | 34091 | @itemx -mavxvnniint8 |
d77de738 | 34092 | @need 200 |
d77de738 | 34093 | @opindex mavxneconvert |
ddf6fe37 | 34094 | @itemx -mavxneconvert |
d77de738 | 34095 | @need 200 |
d77de738 | 34096 | @opindex mcmpccxadd |
ddf6fe37 | 34097 | @itemx -mcmpccxadd |
d77de738 | 34098 | @need 200 |
d77de738 | 34099 | @opindex mamx-fp16 |
ddf6fe37 | 34100 | @itemx -mamx-fp16 |
d77de738 | 34101 | @need 200 |
d77de738 | 34102 | @opindex mprefetchi |
ddf6fe37 | 34103 | @itemx -mprefetchi |
d77de738 | 34104 | @need 200 |
d77de738 | 34105 | @opindex mraoint |
ddf6fe37 | 34106 | @itemx -mraoint |
efa6a82b HJ |
34107 | @need 200 |
34108 | @opindex mamx-complex | |
34109 | @itemx -mamx-complex | |
1dbc1081 KL |
34110 | @need 200 |
34111 | @opindex mavxvnniint16 | |
34112 | @itemx -mavxvnniint16 | |
8643bcba HJ |
34113 | @need 200 |
34114 | @opindex msm3 | |
34115 | @itemx -msm3 | |
86446132 HJ |
34116 | @need 200 |
34117 | @opindex msha512 | |
34118 | @itemx -msha512 | |
37bdeb8f HJ |
34119 | @need 200 |
34120 | @opindex msm4 | |
34121 | @itemx -msm4 | |
e686416b KL |
34122 | @need 200 |
34123 | @opindex mapxf | |
34124 | @itemx -mapxf | |
5fbd91b1 HL |
34125 | @need 200 |
34126 | @opindex musermsr | |
34127 | @itemx -musermsr | |
2f8f7ee2 HJ |
34128 | @need 200 |
34129 | @opindex mavx10.1 | |
34130 | @itemx -mavx10.1 | |
34131 | @need 200 | |
34132 | @opindex mavx10.1-256 | |
34133 | @itemx -mavx10.1-256 | |
34134 | @need 200 | |
34135 | @opindex mavx10.1-512 | |
34136 | @itemx -mavx10.1-512 | |
d77de738 | 34137 | These switches enable the use of instructions in the MMX, SSE, |
d77de738 ML |
34138 | AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA, |
34139 | AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG, | |
34140 | WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP, | |
34141 | 3DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE, | |
34142 | XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2, | |
34143 | GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16, | |
34144 | ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE, | |
29ecb952 | 34145 | UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16, |
efa6a82b | 34146 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT, |
2f8f7ee2 HJ |
34147 | AMX-COMPLEX, AVXVNNIINT16, SM3, SHA512, SM4, APX_F, USER_MSR, AVX10.1 or |
34148 | CLDEMOTE extended instruction sets. Each has a corresponding @option{-mno-} | |
34149 | option to disable use of these instructions. | |
d77de738 ML |
34150 | |
34151 | These extensions are also available as built-in functions: see | |
34152 | @ref{x86 Built-in Functions}, for details of the functions enabled and | |
34153 | disabled by these switches. | |
34154 | ||
34155 | To generate SSE/SSE2 instructions automatically from floating-point | |
34156 | code (as opposed to 387 instructions), see @option{-mfpmath=sse}. | |
34157 | ||
34158 | GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it | |
34159 | generates new AVX instructions or AVX equivalence for all SSEx instructions | |
34160 | when needed. | |
34161 | ||
34162 | These options enable GCC to use these extended instructions in | |
34163 | generated code, even without @option{-mfpmath=sse}. Applications that | |
34164 | perform run-time CPU detection must compile separate files for each | |
34165 | supported architecture, using the appropriate flags. In particular, | |
34166 | the file containing the CPU detection code should be compiled without | |
34167 | these options. | |
34168 | ||
d77de738 | 34169 | @opindex mdump-tune-features |
ddf6fe37 | 34170 | @item -mdump-tune-features |
d77de738 ML |
34171 | This option instructs GCC to dump the names of the x86 performance |
34172 | tuning features and default settings. The names can be used in | |
34173 | @option{-mtune-ctrl=@var{feature-list}}. | |
34174 | ||
d77de738 | 34175 | @opindex mtune-ctrl=@var{feature-list} |
ddf6fe37 | 34176 | @item -mtune-ctrl=@var{feature-list} |
d77de738 ML |
34177 | This option is used to do fine grain control of x86 code generation features. |
34178 | @var{feature-list} is a comma separated list of @var{feature} names. See also | |
34179 | @option{-mdump-tune-features}. When specified, the @var{feature} is turned | |
34180 | on if it is not preceded with @samp{^}, otherwise, it is turned off. | |
34181 | @option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC | |
34182 | developers. Using it may lead to code paths not covered by testing and can | |
34183 | potentially result in compiler ICEs or runtime errors. | |
34184 | ||
d77de738 | 34185 | @opindex mno-default |
ddf6fe37 | 34186 | @item -mno-default |
d77de738 ML |
34187 | This option instructs GCC to turn off all tunable features. See also |
34188 | @option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}. | |
34189 | ||
d77de738 | 34190 | @opindex mcld |
ddf6fe37 | 34191 | @item -mcld |
d77de738 ML |
34192 | This option instructs GCC to emit a @code{cld} instruction in the prologue |
34193 | of functions that use string instructions. String instructions depend on | |
34194 | the DF flag to select between autoincrement or autodecrement mode. While the | |
34195 | ABI specifies the DF flag to be cleared on function entry, some operating | |
34196 | systems violate this specification by not clearing the DF flag in their | |
34197 | exception dispatchers. The exception handler can be invoked with the DF flag | |
34198 | set, which leads to wrong direction mode when string instructions are used. | |
34199 | This option can be enabled by default on 32-bit x86 targets by configuring | |
34200 | GCC with the @option{--enable-cld} configure option. Generation of @code{cld} | |
34201 | instructions can be suppressed with the @option{-mno-cld} compiler option | |
34202 | in this case. | |
34203 | ||
d77de738 | 34204 | @opindex mvzeroupper |
ddf6fe37 | 34205 | @item -mvzeroupper |
d77de738 ML |
34206 | This option instructs GCC to emit a @code{vzeroupper} instruction |
34207 | before a transfer of control flow out of the function to minimize | |
34208 | the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper} | |
34209 | intrinsics. | |
34210 | ||
d77de738 | 34211 | @opindex mprefer-avx128 |
ddf6fe37 | 34212 | @item -mprefer-avx128 |
d77de738 ML |
34213 | This option instructs GCC to use 128-bit AVX instructions instead of |
34214 | 256-bit AVX instructions in the auto-vectorizer. | |
34215 | ||
d77de738 | 34216 | @opindex mprefer-vector-width |
ddf6fe37 | 34217 | @item -mprefer-vector-width=@var{opt} |
d77de738 ML |
34218 | This option instructs GCC to use @var{opt}-bit vector width in instructions |
34219 | instead of default on the selected platform. | |
34220 | ||
ad5b757d UB |
34221 | @opindex mpartial-vector-fp-math |
34222 | @item -mpartial-vector-fp-math | |
34223 | This option enables GCC to generate floating-point operations that might | |
34224 | affect the set of floating-point status flags on partial vectors, where | |
34225 | vector elements reside in the low part of the 128-bit SSE register. Unless | |
34226 | @option{-fno-trapping-math} is specified, the compiler guarantees correct | |
34227 | behavior by sanitizing all input operands to have zeroes in the unused | |
34228 | upper part of the vector register. Note that by using built-in functions | |
34229 | or inline assembly with partial vector arguments, NaNs, denormal or invalid | |
34230 | values can leak into the upper part of the vector, causing possible | |
34231 | performance issues when @option{-fno-trapping-math} is in effect. These | |
34232 | issues can be mitigated by manually sanitizing the upper part of the partial | |
34233 | vector argument register or by using @option{-mdaz-ftz} to set | |
34234 | denormals-are-zero (DAZ) flag in the MXCSR register. | |
34235 | ||
34236 | This option is enabled by default. | |
34237 | ||
d77de738 | 34238 | @opindex mmove-max |
ddf6fe37 | 34239 | @item -mmove-max=@var{bits} |
d77de738 ML |
34240 | This option instructs GCC to set the maximum number of bits can be |
34241 | moved from memory to memory efficiently to @var{bits}. The valid | |
34242 | @var{bits} are 128, 256 and 512. | |
34243 | ||
d77de738 | 34244 | @opindex mstore-max |
ddf6fe37 | 34245 | @item -mstore-max=@var{bits} |
d77de738 ML |
34246 | This option instructs GCC to set the maximum number of bits can be |
34247 | stored to memory efficiently to @var{bits}. The valid @var{bits} are | |
34248 | 128, 256 and 512. | |
34249 | ||
34250 | @table @samp | |
34251 | @item none | |
34252 | No extra limitations applied to GCC other than defined by the selected platform. | |
34253 | ||
34254 | @item 128 | |
34255 | Prefer 128-bit vector width for instructions. | |
34256 | ||
34257 | @item 256 | |
34258 | Prefer 256-bit vector width for instructions. | |
34259 | ||
34260 | @item 512 | |
34261 | Prefer 512-bit vector width for instructions. | |
34262 | @end table | |
34263 | ||
d77de738 | 34264 | @opindex mcx16 |
ddf6fe37 | 34265 | @item -mcx16 |
d77de738 ML |
34266 | This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit |
34267 | code to implement compare-and-exchange operations on 16-byte aligned 128-bit | |
34268 | objects. This is useful for atomic updates of data structures exceeding one | |
34269 | machine word in size. The compiler uses this instruction to implement | |
34270 | @ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on | |
34271 | 128-bit integers, a library call is always used. | |
34272 | ||
d77de738 | 34273 | @opindex msahf |
ddf6fe37 | 34274 | @item -msahf |
d77de738 ML |
34275 | This option enables generation of @code{SAHF} instructions in 64-bit code. |
34276 | Early Intel Pentium 4 CPUs with Intel 64 support, | |
34277 | prior to the introduction of Pentium 4 G1 step in December 2005, | |
34278 | lacked the @code{LAHF} and @code{SAHF} instructions | |
34279 | which are supported by AMD64. | |
34280 | These are load and store instructions, respectively, for certain status flags. | |
34281 | In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod}, | |
34282 | @code{drem}, and @code{remainder} built-in functions; | |
34283 | see @ref{Other Builtins} for details. | |
34284 | ||
d77de738 | 34285 | @opindex mmovbe |
ddf6fe37 | 34286 | @item -mmovbe |
d77de738 ML |
34287 | This option enables use of the @code{movbe} instruction to implement |
34288 | @code{__builtin_bswap32} and @code{__builtin_bswap64}. | |
34289 | ||
d77de738 | 34290 | @opindex mshstk |
ddf6fe37 | 34291 | @item -mshstk |
d77de738 ML |
34292 | The @option{-mshstk} option enables shadow stack built-in functions |
34293 | from x86 Control-flow Enforcement Technology (CET). | |
34294 | ||
d77de738 | 34295 | @opindex mcrc32 |
ddf6fe37 | 34296 | @item -mcrc32 |
d77de738 ML |
34297 | This option enables built-in functions @code{__builtin_ia32_crc32qi}, |
34298 | @code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and | |
34299 | @code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction. | |
34300 | ||
d77de738 | 34301 | @opindex mmwait |
ddf6fe37 | 34302 | @item -mmwait |
d77de738 ML |
34303 | This option enables built-in functions @code{__builtin_ia32_monitor}, |
34304 | and @code{__builtin_ia32_mwait} to generate the @code{monitor} and | |
34305 | @code{mwait} machine instructions. | |
34306 | ||
d77de738 | 34307 | @opindex mrecip |
ddf6fe37 | 34308 | @item -mrecip |
d77de738 ML |
34309 | This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions |
34310 | (and their vectorized variants @code{RCPPS} and @code{RSQRTPS}) | |
34311 | with an additional Newton-Raphson step | |
34312 | to increase precision instead of @code{DIVSS} and @code{SQRTSS} | |
34313 | (and their vectorized | |
34314 | variants) for single-precision floating-point arguments. These instructions | |
34315 | are generated only when @option{-funsafe-math-optimizations} is enabled | |
34316 | together with @option{-ffinite-math-only} and @option{-fno-trapping-math}. | |
34317 | Note that while the throughput of the sequence is higher than the throughput | |
34318 | of the non-reciprocal instruction, the precision of the sequence can be | |
34319 | decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994). | |
34320 | ||
34321 | Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS} | |
34322 | (or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option | |
34323 | combination), and doesn't need @option{-mrecip}. | |
34324 | ||
34325 | Also note that GCC emits the above sequence with additional Newton-Raphson step | |
34326 | for vectorized single-float division and vectorized @code{sqrtf(@var{x})} | |
34327 | already with @option{-ffast-math} (or the above option combination), and | |
34328 | doesn't need @option{-mrecip}. | |
34329 | ||
d77de738 | 34330 | @opindex mrecip=opt |
ddf6fe37 | 34331 | @item -mrecip=@var{opt} |
d77de738 ML |
34332 | This option controls which reciprocal estimate instructions |
34333 | may be used. @var{opt} is a comma-separated list of options, which may | |
34334 | be preceded by a @samp{!} to invert the option: | |
34335 | ||
34336 | @table @samp | |
34337 | @item all | |
34338 | Enable all estimate instructions. | |
34339 | ||
34340 | @item default | |
34341 | Enable the default instructions, equivalent to @option{-mrecip}. | |
34342 | ||
34343 | @item none | |
34344 | Disable all estimate instructions, equivalent to @option{-mno-recip}. | |
34345 | ||
34346 | @item div | |
34347 | Enable the approximation for scalar division. | |
34348 | ||
34349 | @item vec-div | |
34350 | Enable the approximation for vectorized division. | |
34351 | ||
34352 | @item sqrt | |
34353 | Enable the approximation for scalar square root. | |
34354 | ||
34355 | @item vec-sqrt | |
34356 | Enable the approximation for vectorized square root. | |
34357 | @end table | |
34358 | ||
34359 | So, for example, @option{-mrecip=all,!sqrt} enables | |
34360 | all of the reciprocal approximations, except for square root. | |
34361 | ||
d77de738 | 34362 | @opindex mveclibabi |
ddf6fe37 | 34363 | @item -mveclibabi=@var{type} |
d77de738 ML |
34364 | Specifies the ABI type to use for vectorizing intrinsics using an |
34365 | external library. Supported values for @var{type} are @samp{svml} | |
34366 | for the Intel short | |
34367 | vector math library and @samp{acml} for the AMD math core library. | |
34368 | To use this option, both @option{-ftree-vectorize} and | |
34369 | @option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML | |
34370 | ABI-compatible library must be specified at link time. | |
34371 | ||
34372 | GCC currently emits calls to @code{vmldExp2}, | |
34373 | @code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2}, | |
34374 | @code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2}, | |
34375 | @code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2}, | |
34376 | @code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2}, | |
34377 | @code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4}, | |
34378 | @code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4}, | |
34379 | @code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4}, | |
34380 | @code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4}, | |
34381 | @code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding | |
34382 | function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin}, | |
34383 | @code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2}, | |
34384 | @code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf}, | |
34385 | @code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f}, | |
34386 | @code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type | |
34387 | when @option{-mveclibabi=acml} is used. | |
34388 | ||
d77de738 | 34389 | @opindex mabi |
ddf6fe37 | 34390 | @item -mabi=@var{name} |
d77de738 ML |
34391 | Generate code for the specified calling convention. Permissible values |
34392 | are @samp{sysv} for the ABI used on GNU/Linux and other systems, and | |
34393 | @samp{ms} for the Microsoft ABI. The default is to use the Microsoft | |
34394 | ABI when targeting Microsoft Windows and the SysV ABI on all other systems. | |
34395 | You can control this behavior for specific functions by | |
34396 | using the function attributes @code{ms_abi} and @code{sysv_abi}. | |
34397 | @xref{Function Attributes}. | |
34398 | ||
d77de738 | 34399 | @opindex mforce-indirect-call |
ddf6fe37 | 34400 | @item -mforce-indirect-call |
d77de738 ML |
34401 | Force all calls to functions to be indirect. This is useful |
34402 | when using Intel Processor Trace where it generates more precise timing | |
34403 | information for function calls. | |
34404 | ||
d77de738 | 34405 | @opindex mmanual-endbr |
ddf6fe37 | 34406 | @item -mmanual-endbr |
d77de738 ML |
34407 | Insert ENDBR instruction at function entry only via the @code{cf_check} |
34408 | function attribute. This is useful when used with the option | |
34409 | @option{-fcf-protection=branch} to control ENDBR insertion at the | |
34410 | function entry. | |
34411 | ||
d77de738 | 34412 | @opindex mcet-switch |
ddf6fe37 | 34413 | @item -mcet-switch |
d77de738 ML |
34414 | By default, CET instrumentation is turned off on switch statements that |
34415 | use a jump table and indirect branch track is disabled. Since jump | |
34416 | tables are stored in read-only memory, this does not result in a direct | |
34417 | loss of hardening. But if the jump table index is attacker-controlled, | |
34418 | the indirect jump may not be constrained by CET. This option turns on | |
34419 | CET instrumentation to enable indirect branch track for switch statements | |
34420 | with jump tables which leads to the jump targets reachable via any indirect | |
34421 | jumps. | |
34422 | ||
d77de738 ML |
34423 | @opindex mcall-ms2sysv-xlogues |
34424 | @opindex mno-call-ms2sysv-xlogues | |
ddf6fe37 | 34425 | @item -mcall-ms2sysv-xlogues |
d77de738 ML |
34426 | Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a |
34427 | System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By | |
34428 | default, the code for saving and restoring these registers is emitted inline, | |
34429 | resulting in fairly lengthy prologues and epilogues. Using | |
34430 | @option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that | |
34431 | use stubs in the static portion of libgcc to perform these saves and restores, | |
34432 | thus reducing function size at the cost of a few extra instructions. | |
34433 | ||
d77de738 | 34434 | @opindex mtls-dialect |
ddf6fe37 | 34435 | @item -mtls-dialect=@var{type} |
d77de738 ML |
34436 | Generate code to access thread-local storage using the @samp{gnu} or |
34437 | @samp{gnu2} conventions. @samp{gnu} is the conservative default; | |
34438 | @samp{gnu2} is more efficient, but it may add compile- and run-time | |
34439 | requirements that cannot be satisfied on all systems. | |
34440 | ||
d77de738 ML |
34441 | @opindex mpush-args |
34442 | @opindex mno-push-args | |
ddf6fe37 AA |
34443 | @item -mpush-args |
34444 | @itemx -mno-push-args | |
d77de738 ML |
34445 | Use PUSH operations to store outgoing parameters. This method is shorter |
34446 | and usually equally fast as method using SUB/MOV operations and is enabled | |
34447 | by default. In some cases disabling it may improve performance because of | |
34448 | improved scheduling and reduced dependencies. | |
34449 | ||
d77de738 | 34450 | @opindex maccumulate-outgoing-args |
ddf6fe37 | 34451 | @item -maccumulate-outgoing-args |
d77de738 ML |
34452 | If enabled, the maximum amount of space required for outgoing arguments is |
34453 | computed in the function prologue. This is faster on most modern CPUs | |
34454 | because of reduced dependencies, improved scheduling and reduced stack usage | |
34455 | when the preferred stack boundary is not equal to 2. The drawback is a notable | |
34456 | increase in code size. This switch implies @option{-mno-push-args}. | |
34457 | ||
d77de738 | 34458 | @opindex mthreads |
ddf6fe37 | 34459 | @item -mthreads |
d77de738 ML |
34460 | Support thread-safe exception handling on MinGW. Programs that rely |
34461 | on thread-safe exception handling must compile and link all code with the | |
34462 | @option{-mthreads} option. When compiling, @option{-mthreads} defines | |
34463 | @option{-D_MT}; when linking, it links in a special thread helper library | |
34464 | @option{-lmingwthrd} which cleans up per-thread exception-handling data. | |
34465 | ||
d77de738 ML |
34466 | @opindex mms-bitfields |
34467 | @opindex mno-ms-bitfields | |
ddf6fe37 AA |
34468 | @item -mms-bitfields |
34469 | @itemx -mno-ms-bitfields | |
d77de738 ML |
34470 | |
34471 | Enable/disable bit-field layout compatible with the native Microsoft | |
34472 | Windows compiler. | |
34473 | ||
34474 | If @code{packed} is used on a structure, or if bit-fields are used, | |
34475 | it may be that the Microsoft ABI lays out the structure differently | |
34476 | than the way GCC normally does. Particularly when moving packed | |
34477 | data between functions compiled with GCC and the native Microsoft compiler | |
34478 | (either via function call or as data in a file), it may be necessary to access | |
34479 | either format. | |
34480 | ||
34481 | This option is enabled by default for Microsoft Windows | |
34482 | targets. This behavior can also be controlled locally by use of variable | |
34483 | or type attributes. For more information, see @ref{x86 Variable Attributes} | |
34484 | and @ref{x86 Type Attributes}. | |
34485 | ||
34486 | The Microsoft structure layout algorithm is fairly simple with the exception | |
34487 | of the bit-field packing. | |
34488 | The padding and alignment of members of structures and whether a bit-field | |
34489 | can straddle a storage-unit boundary are determine by these rules: | |
34490 | ||
34491 | @enumerate | |
34492 | @item Structure members are stored sequentially in the order in which they are | |
34493 | declared: the first member has the lowest memory address and the last member | |
34494 | the highest. | |
34495 | ||
34496 | @item Every data object has an alignment requirement. The alignment requirement | |
34497 | for all data except structures, unions, and arrays is either the size of the | |
34498 | object or the current packing size (specified with either the | |
34499 | @code{aligned} attribute or the @code{pack} pragma), | |
34500 | whichever is less. For structures, unions, and arrays, | |
34501 | the alignment requirement is the largest alignment requirement of its members. | |
34502 | Every object is allocated an offset so that: | |
34503 | ||
34504 | @smallexample | |
34505 | offset % alignment_requirement == 0 | |
34506 | @end smallexample | |
34507 | ||
34508 | @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation | |
34509 | unit if the integral types are the same size and if the next bit-field fits | |
34510 | into the current allocation unit without crossing the boundary imposed by the | |
34511 | common alignment requirements of the bit-fields. | |
34512 | @end enumerate | |
34513 | ||
34514 | MSVC interprets zero-length bit-fields in the following ways: | |
34515 | ||
34516 | @enumerate | |
34517 | @item If a zero-length bit-field is inserted between two bit-fields that | |
34518 | are normally coalesced, the bit-fields are not coalesced. | |
34519 | ||
34520 | For example: | |
34521 | ||
34522 | @smallexample | |
34523 | struct | |
34524 | @{ | |
34525 | unsigned long bf_1 : 12; | |
34526 | unsigned long : 0; | |
34527 | unsigned long bf_2 : 12; | |
34528 | @} t1; | |
34529 | @end smallexample | |
34530 | ||
34531 | @noindent | |
34532 | The size of @code{t1} is 8 bytes with the zero-length bit-field. If the | |
34533 | zero-length bit-field were removed, @code{t1}'s size would be 4 bytes. | |
34534 | ||
34535 | @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the | |
34536 | alignment of the zero-length bit-field is greater than the member that follows it, | |
34537 | @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field. | |
34538 | ||
34539 | For example: | |
34540 | ||
34541 | @smallexample | |
34542 | struct | |
34543 | @{ | |
34544 | char foo : 4; | |
34545 | short : 0; | |
34546 | char bar; | |
34547 | @} t2; | |
34548 | ||
34549 | struct | |
34550 | @{ | |
34551 | char foo : 4; | |
34552 | short : 0; | |
34553 | double bar; | |
34554 | @} t3; | |
34555 | @end smallexample | |
34556 | ||
34557 | @noindent | |
34558 | For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1. | |
34559 | Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length | |
34560 | bit-field does not affect the alignment of @code{bar} or, as a result, the size | |
34561 | of the structure. | |
34562 | ||
34563 | Taking this into account, it is important to note the following: | |
34564 | ||
34565 | @enumerate | |
34566 | @item If a zero-length bit-field follows a normal bit-field, the type of the | |
34567 | zero-length bit-field may affect the alignment of the structure as whole. For | |
34568 | example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a | |
34569 | normal bit-field, and is of type short. | |
34570 | ||
34571 | @item Even if a zero-length bit-field is not followed by a normal bit-field, it may | |
34572 | still affect the alignment of the structure: | |
34573 | ||
34574 | @smallexample | |
34575 | struct | |
34576 | @{ | |
34577 | char foo : 6; | |
34578 | long : 0; | |
34579 | @} t4; | |
34580 | @end smallexample | |
34581 | ||
34582 | @noindent | |
34583 | Here, @code{t4} takes up 4 bytes. | |
34584 | @end enumerate | |
34585 | ||
34586 | @item Zero-length bit-fields following non-bit-field members are ignored: | |
34587 | ||
34588 | @smallexample | |
34589 | struct | |
34590 | @{ | |
34591 | char foo; | |
34592 | long : 0; | |
34593 | char bar; | |
34594 | @} t5; | |
34595 | @end smallexample | |
34596 | ||
34597 | @noindent | |
34598 | Here, @code{t5} takes up 2 bytes. | |
34599 | @end enumerate | |
34600 | ||
34601 | ||
d77de738 ML |
34602 | @opindex mno-align-stringops |
34603 | @opindex malign-stringops | |
ddf6fe37 | 34604 | @item -mno-align-stringops |
d77de738 ML |
34605 | Do not align the destination of inlined string operations. This switch reduces |
34606 | code size and improves performance in case the destination is already aligned, | |
34607 | but GCC doesn't know about it. | |
34608 | ||
d77de738 | 34609 | @opindex minline-all-stringops |
ddf6fe37 | 34610 | @item -minline-all-stringops |
d77de738 ML |
34611 | By default GCC inlines string operations only when the destination is |
34612 | known to be aligned to least a 4-byte boundary. | |
34613 | This enables more inlining and increases code | |
34614 | size, but may improve performance of code that depends on fast | |
34615 | @code{memcpy} and @code{memset} for short lengths. | |
34616 | The option enables inline expansion of @code{strlen} for all | |
34617 | pointer alignments. | |
34618 | ||
d77de738 | 34619 | @opindex minline-stringops-dynamically |
ddf6fe37 | 34620 | @item -minline-stringops-dynamically |
d77de738 ML |
34621 | For string operations of unknown size, use run-time checks with |
34622 | inline code for small blocks and a library call for large blocks. | |
34623 | ||
d77de738 | 34624 | @opindex mstringop-strategy=@var{alg} |
ddf6fe37 | 34625 | @item -mstringop-strategy=@var{alg} |
d77de738 ML |
34626 | Override the internal decision heuristic for the particular algorithm to use |
34627 | for inlining string operations. The allowed values for @var{alg} are: | |
34628 | ||
34629 | @table @samp | |
34630 | @item rep_byte | |
34631 | @itemx rep_4byte | |
34632 | @itemx rep_8byte | |
34633 | Expand using i386 @code{rep} prefix of the specified size. | |
34634 | ||
34635 | @item byte_loop | |
34636 | @itemx loop | |
34637 | @itemx unrolled_loop | |
34638 | Expand into an inline loop. | |
34639 | ||
34640 | @item libcall | |
34641 | Always use a library call. | |
34642 | @end table | |
34643 | ||
d77de738 | 34644 | @opindex mmemcpy-strategy=@var{strategy} |
ddf6fe37 | 34645 | @item -mmemcpy-strategy=@var{strategy} |
d77de738 ML |
34646 | Override the internal decision heuristic to decide if @code{__builtin_memcpy} |
34647 | should be inlined and what inline algorithm to use when the expected size | |
34648 | of the copy operation is known. @var{strategy} | |
34649 | is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets. | |
34650 | @var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies | |
34651 | the max byte size with which inline algorithm @var{alg} is allowed. For the last | |
34652 | triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets | |
34653 | in the list must be specified in increasing order. The minimal byte size for | |
34654 | @var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the | |
34655 | preceding range. | |
34656 | ||
d77de738 | 34657 | @opindex mmemset-strategy=@var{strategy} |
ddf6fe37 | 34658 | @item -mmemset-strategy=@var{strategy} |
d77de738 ML |
34659 | The option is similar to @option{-mmemcpy-strategy=} except that it is to control |
34660 | @code{__builtin_memset} expansion. | |
34661 | ||
d77de738 | 34662 | @opindex momit-leaf-frame-pointer |
ddf6fe37 | 34663 | @item -momit-leaf-frame-pointer |
d77de738 ML |
34664 | Don't keep the frame pointer in a register for leaf functions. This |
34665 | avoids the instructions to save, set up, and restore frame pointers and | |
34666 | makes an extra register available in leaf functions. The option | |
34667 | @option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions, | |
34668 | which might make debugging harder. | |
34669 | ||
ddf6fe37 | 34670 | @opindex mtls-direct-seg-refs |
d77de738 ML |
34671 | @item -mtls-direct-seg-refs |
34672 | @itemx -mno-tls-direct-seg-refs | |
d77de738 ML |
34673 | Controls whether TLS variables may be accessed with offsets from the |
34674 | TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit), | |
34675 | or whether the thread base pointer must be added. Whether or not this | |
34676 | is valid depends on the operating system, and whether it maps the | |
34677 | segment to cover the entire TLS area. | |
34678 | ||
34679 | For systems that use the GNU C Library, the default is on. | |
34680 | ||
ddf6fe37 | 34681 | @opindex msse2avx |
d77de738 ML |
34682 | @item -msse2avx |
34683 | @itemx -mno-sse2avx | |
d77de738 ML |
34684 | Specify that the assembler should encode SSE instructions with VEX |
34685 | prefix. The option @option{-mavx} turns this on by default. | |
34686 | ||
ddf6fe37 | 34687 | @opindex mfentry |
d77de738 ML |
34688 | @item -mfentry |
34689 | @itemx -mno-fentry | |
d77de738 ML |
34690 | If profiling is active (@option{-pg}), put the profiling |
34691 | counter call before the prologue. | |
34692 | Note: On x86 architectures the attribute @code{ms_hook_prologue} | |
34693 | isn't possible at the moment for @option{-mfentry} and @option{-pg}. | |
34694 | ||
ddf6fe37 | 34695 | @opindex mrecord-mcount |
d77de738 ML |
34696 | @item -mrecord-mcount |
34697 | @itemx -mno-record-mcount | |
d77de738 ML |
34698 | If profiling is active (@option{-pg}), generate a __mcount_loc section |
34699 | that contains pointers to each profiling call. This is useful for | |
34700 | automatically patching and out calls. | |
34701 | ||
ddf6fe37 | 34702 | @opindex mnop-mcount |
d77de738 ML |
34703 | @item -mnop-mcount |
34704 | @itemx -mno-nop-mcount | |
d77de738 ML |
34705 | If profiling is active (@option{-pg}), generate the calls to |
34706 | the profiling functions as NOPs. This is useful when they | |
34707 | should be patched in later dynamically. This is likely only | |
34708 | useful together with @option{-mrecord-mcount}. | |
34709 | ||
d77de738 | 34710 | @opindex minstrument-return |
ddf6fe37 | 34711 | @item -minstrument-return=@var{type} |
d77de738 ML |
34712 | Instrument function exit in -pg -mfentry instrumented functions with |
34713 | call to specified function. This only instruments true returns ending | |
34714 | with ret, but not sibling calls ending with jump. Valid types | |
34715 | are @var{none} to not instrument, @var{call} to generate a call to __return__, | |
34716 | or @var{nop5} to generate a 5 byte nop. | |
34717 | ||
ddf6fe37 | 34718 | @opindex mrecord-return |
d77de738 ML |
34719 | @item -mrecord-return |
34720 | @itemx -mno-record-return | |
d77de738 ML |
34721 | Generate a __return_loc section pointing to all return instrumentation code. |
34722 | ||
d77de738 | 34723 | @opindex mfentry-name |
ddf6fe37 | 34724 | @item -mfentry-name=@var{name} |
d77de738 ML |
34725 | Set name of __fentry__ symbol called at function entry for -pg -mfentry functions. |
34726 | ||
d77de738 | 34727 | @opindex mfentry-section |
ddf6fe37 | 34728 | @item -mfentry-section=@var{name} |
d77de738 ML |
34729 | Set name of section to record -mrecord-mcount calls (default __mcount_loc). |
34730 | ||
ddf6fe37 | 34731 | @opindex mskip-rax-setup |
d77de738 ML |
34732 | @item -mskip-rax-setup |
34733 | @itemx -mno-skip-rax-setup | |
d77de738 ML |
34734 | When generating code for the x86-64 architecture with SSE extensions |
34735 | disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX | |
34736 | register when there are no variable arguments passed in vector registers. | |
34737 | ||
34738 | @strong{Warning:} Since RAX register is used to avoid unnecessarily | |
34739 | saving vector registers on stack when passing variable arguments, the | |
34740 | impacts of this option are callees may waste some stack space, | |
34741 | misbehave or jump to a random location. GCC 4.4 or newer don't have | |
34742 | those issues, regardless the RAX register value. | |
34743 | ||
ddf6fe37 | 34744 | @opindex m8bit-idiv |
d77de738 ML |
34745 | @item -m8bit-idiv |
34746 | @itemx -mno-8bit-idiv | |
d77de738 ML |
34747 | On some processors, like Intel Atom, 8-bit unsigned integer divide is |
34748 | much faster than 32-bit/64-bit integer divide. This option generates a | |
34749 | run-time check. If both dividend and divisor are within range of 0 | |
34750 | to 255, 8-bit unsigned integer divide is used instead of | |
34751 | 32-bit/64-bit integer divide. | |
34752 | ||
d77de738 ML |
34753 | @opindex mavx256-split-unaligned-load |
34754 | @opindex mavx256-split-unaligned-store | |
ddf6fe37 AA |
34755 | @item -mavx256-split-unaligned-load |
34756 | @itemx -mavx256-split-unaligned-store | |
d77de738 ML |
34757 | Split 32-byte AVX unaligned load and store. |
34758 | ||
d77de738 ML |
34759 | @opindex mstack-protector-guard |
34760 | @opindex mstack-protector-guard-reg | |
34761 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
34762 | @item -mstack-protector-guard=@var{guard} |
34763 | @itemx -mstack-protector-guard-reg=@var{reg} | |
34764 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
34765 | Generate stack protection code using canary at @var{guard}. Supported |
34766 | locations are @samp{global} for global canary or @samp{tls} for per-thread | |
34767 | canary in the TLS block (the default). This option has effect only when | |
34768 | @option{-fstack-protector} or @option{-fstack-protector-all} is specified. | |
34769 | ||
34770 | With the latter choice the options | |
34771 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
34772 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
34773 | which segment register (@code{%fs} or @code{%gs}) to use as base register | |
34774 | for reading the canary, and from what offset from that base register. | |
34775 | The default for those is as specified in the relevant ABI. | |
34776 | ||
d77de738 | 34777 | @opindex mgeneral-regs-only |
ddf6fe37 | 34778 | @item -mgeneral-regs-only |
d77de738 ML |
34779 | Generate code that uses only the general-purpose registers. This |
34780 | prevents the compiler from using floating-point, vector, mask and bound | |
34781 | registers. | |
34782 | ||
d77de738 | 34783 | @opindex mrelax-cmpxchg-loop |
ddf6fe37 | 34784 | @item -mrelax-cmpxchg-loop |
85966f0d AM |
34785 | When emitting a compare-and-swap loop for @ref{__sync Builtins} |
34786 | and @ref{__atomic Builtins} lacking a native instruction, optimize | |
34787 | for the highly contended case by issuing an atomic load before the | |
34788 | @code{CMPXCHG} instruction, and using the @code{PAUSE} instruction | |
34789 | to save CPU power when restarting the loop. | |
d77de738 | 34790 | |
d77de738 | 34791 | @opindex mindirect-branch |
ddf6fe37 | 34792 | @item -mindirect-branch=@var{choice} |
d77de738 ML |
34793 | Convert indirect call and jump with @var{choice}. The default is |
34794 | @samp{keep}, which keeps indirect call and jump unmodified. | |
34795 | @samp{thunk} converts indirect call and jump to call and return thunk. | |
34796 | @samp{thunk-inline} converts indirect call and jump to inlined call | |
34797 | and return thunk. @samp{thunk-extern} converts indirect call and jump | |
34798 | to external call and return thunk provided in a separate object file. | |
34799 | You can control this behavior for a specific function by using the | |
34800 | function attribute @code{indirect_branch}. @xref{Function Attributes}. | |
34801 | ||
34802 | Note that @option{-mcmodel=large} is incompatible with | |
34803 | @option{-mindirect-branch=thunk} and | |
34804 | @option{-mindirect-branch=thunk-extern} since the thunk function may | |
34805 | not be reachable in the large code model. | |
34806 | ||
34807 | Note that @option{-mindirect-branch=thunk-extern} is compatible with | |
34808 | @option{-fcf-protection=branch} since the external thunk can be made | |
34809 | to enable control-flow check. | |
34810 | ||
d77de738 | 34811 | @opindex mfunction-return |
ddf6fe37 | 34812 | @item -mfunction-return=@var{choice} |
d77de738 ML |
34813 | Convert function return with @var{choice}. The default is @samp{keep}, |
34814 | which keeps function return unmodified. @samp{thunk} converts function | |
34815 | return to call and return thunk. @samp{thunk-inline} converts function | |
34816 | return to inlined call and return thunk. @samp{thunk-extern} converts | |
34817 | function return to external call and return thunk provided in a separate | |
34818 | object file. You can control this behavior for a specific function by | |
34819 | using the function attribute @code{function_return}. | |
34820 | @xref{Function Attributes}. | |
34821 | ||
34822 | Note that @option{-mindirect-return=thunk-extern} is compatible with | |
34823 | @option{-fcf-protection=branch} since the external thunk can be made | |
34824 | to enable control-flow check. | |
34825 | ||
34826 | Note that @option{-mcmodel=large} is incompatible with | |
34827 | @option{-mfunction-return=thunk} and | |
34828 | @option{-mfunction-return=thunk-extern} since the thunk function may | |
34829 | not be reachable in the large code model. | |
34830 | ||
34831 | ||
d77de738 | 34832 | @opindex mindirect-branch-register |
ddf6fe37 | 34833 | @item -mindirect-branch-register |
d77de738 ML |
34834 | Force indirect call and jump via register. |
34835 | ||
d77de738 | 34836 | @opindex mharden-sls |
ddf6fe37 | 34837 | @item -mharden-sls=@var{choice} |
d77de738 ML |
34838 | Generate code to mitigate against straight line speculation (SLS) with |
34839 | @var{choice}. The default is @samp{none} which disables all SLS | |
34840 | hardening. @samp{return} enables SLS hardening for function returns. | |
34841 | @samp{indirect-jmp} enables SLS hardening for indirect jumps. | |
34842 | @samp{all} enables all SLS hardening. | |
34843 | ||
d77de738 | 34844 | @opindex mindirect-branch-cs-prefix |
ddf6fe37 | 34845 | @item -mindirect-branch-cs-prefix |
d77de738 ML |
34846 | Add CS prefix to call and jmp to indirect thunk with branch target in |
34847 | r8-r15 registers so that the call and jmp instruction length is 6 bytes | |
34848 | to allow them to be replaced with @samp{lfence; call *%r8-r15} or | |
34849 | @samp{lfence; jmp *%r8-r15} at run-time. | |
34850 | ||
34851 | @end table | |
34852 | ||
34853 | These @samp{-m} switches are supported in addition to the above | |
34854 | on x86-64 processors in 64-bit environments. | |
34855 | ||
34856 | @table @gcctabopt | |
d77de738 ML |
34857 | @opindex m32 |
34858 | @opindex m64 | |
34859 | @opindex mx32 | |
34860 | @opindex m16 | |
34861 | @opindex miamcu | |
ddf6fe37 AA |
34862 | @item -m32 |
34863 | @itemx -m64 | |
34864 | @itemx -mx32 | |
34865 | @itemx -m16 | |
34866 | @itemx -miamcu | |
d77de738 ML |
34867 | Generate code for a 16-bit, 32-bit or 64-bit environment. |
34868 | The @option{-m32} option sets @code{int}, @code{long}, and pointer types | |
34869 | to 32 bits, and | |
eeb92704 | 34870 | generates code that runs in 32-bit mode. |
d77de738 ML |
34871 | |
34872 | The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer | |
34873 | types to 64 bits, and generates code for the x86-64 architecture. | |
34874 | For Darwin only the @option{-m64} option also turns off the @option{-fno-pic} | |
34875 | and @option{-mdynamic-no-pic} options. | |
34876 | ||
34877 | The @option{-mx32} option sets @code{int}, @code{long}, and pointer types | |
34878 | to 32 bits, and | |
34879 | generates code for the x86-64 architecture. | |
34880 | ||
34881 | The @option{-m16} option is the same as @option{-m32}, except for that | |
34882 | it outputs the @code{.code16gcc} assembly directive at the beginning of | |
34883 | the assembly output so that the binary can run in 16-bit mode. | |
34884 | ||
34885 | The @option{-miamcu} option generates code which conforms to Intel MCU | |
34886 | psABI. It requires the @option{-m32} option to be turned on. | |
34887 | ||
d77de738 ML |
34888 | @opindex mno-red-zone |
34889 | @opindex mred-zone | |
ddf6fe37 | 34890 | @item -mno-red-zone |
d77de738 ML |
34891 | Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated |
34892 | by the x86-64 ABI; it is a 128-byte area beyond the location of the | |
34893 | stack pointer that is not modified by signal or interrupt handlers | |
34894 | and therefore can be used for temporary data without adjusting the stack | |
34895 | pointer. The flag @option{-mno-red-zone} disables this red zone. | |
34896 | ||
d77de738 | 34897 | @opindex mcmodel=small |
ddf6fe37 | 34898 | @item -mcmodel=small |
d77de738 ML |
34899 | Generate code for the small code model: the program and its symbols must |
34900 | be linked in the lower 2 GB of the address space. Pointers are 64 bits. | |
34901 | Programs can be statically or dynamically linked. This is the default | |
34902 | code model. | |
34903 | ||
d77de738 | 34904 | @opindex mcmodel=kernel |
ddf6fe37 | 34905 | @item -mcmodel=kernel |
d77de738 ML |
34906 | Generate code for the kernel code model. The kernel runs in the |
34907 | negative 2 GB of the address space. | |
34908 | This model has to be used for Linux kernel code. | |
34909 | ||
d77de738 | 34910 | @opindex mcmodel=medium |
ddf6fe37 | 34911 | @item -mcmodel=medium |
d77de738 ML |
34912 | Generate code for the medium model: the program is linked in the lower 2 |
34913 | GB of the address space. Small symbols are also placed there. Symbols | |
34914 | with sizes larger than @option{-mlarge-data-threshold} are put into | |
34915 | large data or BSS sections and can be located above 2GB. Programs can | |
34916 | be statically or dynamically linked. | |
34917 | ||
d77de738 | 34918 | @opindex mcmodel=large |
ddf6fe37 | 34919 | @item -mcmodel=large |
d77de738 ML |
34920 | Generate code for the large model. This model makes no assumptions |
34921 | about addresses and sizes of sections. | |
34922 | ||
d77de738 | 34923 | @opindex maddress-mode=long |
ddf6fe37 | 34924 | @item -maddress-mode=long |
d77de738 ML |
34925 | Generate code for long address mode. This is only supported for 64-bit |
34926 | and x32 environments. It is the default address mode for 64-bit | |
34927 | environments. | |
34928 | ||
d77de738 | 34929 | @opindex maddress-mode=short |
ddf6fe37 | 34930 | @item -maddress-mode=short |
d77de738 ML |
34931 | Generate code for short address mode. This is only supported for 32-bit |
34932 | and x32 environments. It is the default address mode for 32-bit and | |
34933 | x32 environments. | |
34934 | ||
ddf6fe37 | 34935 | @opindex mneeded |
d77de738 ML |
34936 | @item -mneeded |
34937 | @itemx -mno-needed | |
d77de738 ML |
34938 | Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to |
34939 | indicate the micro-architecture ISA level required to execute the binary. | |
34940 | ||
d77de738 ML |
34941 | @opindex mno-direct-extern-access |
34942 | @opindex mdirect-extern-access | |
ddf6fe37 | 34943 | @item -mno-direct-extern-access |
d77de738 ML |
34944 | Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer |
34945 | to access external symbols. With @option{-fpic} or @option{-fPIC}, | |
34946 | treat access to protected symbols as local symbols. The default is | |
34947 | @option{-mdirect-extern-access}. | |
34948 | ||
34949 | @strong{Warning:} shared libraries compiled with | |
34950 | @option{-mno-direct-extern-access} and executable compiled with | |
34951 | @option{-mdirect-extern-access} may not be binary compatible if | |
34952 | protected symbols are used in shared libraries and executable. | |
ce51e843 | 34953 | |
ce51e843 ML |
34954 | @opindex munroll-only-small-loops |
34955 | @opindex mno-unroll-only-small-loops | |
ddf6fe37 | 34956 | @item -munroll-only-small-loops |
ce51e843 ML |
34957 | Controls conservative small loop unrolling. It is default enabled by |
34958 | O2, and unrolls loop with less than 4 insns by 1 time. Explicit | |
34959 | -f[no-]unroll-[all-]loops would disable this flag to avoid any | |
34960 | unintended unrolling behavior that user does not want. | |
bb576017 | 34961 | |
bb576017 | 34962 | @opindex mlam |
ddf6fe37 | 34963 | @item -mlam=@var{choice} |
bb576017 | 34964 | LAM(linear-address masking) allows special bits in the pointer to be used |
34965 | for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in | |
34966 | positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in | |
34967 | positions 62:57 can be used for metadata. | |
d77de738 ML |
34968 | @end table |
34969 | ||
34970 | @node x86 Windows Options | |
34971 | @subsection x86 Windows Options | |
34972 | @cindex x86 Windows Options | |
34973 | @cindex Windows Options for x86 | |
34974 | ||
34975 | These additional options are available for Microsoft Windows targets: | |
34976 | ||
34977 | @table @gcctabopt | |
d77de738 | 34978 | @opindex mconsole |
ddf6fe37 | 34979 | @item -mconsole |
d77de738 ML |
34980 | This option |
34981 | specifies that a console application is to be generated, by | |
34982 | instructing the linker to set the PE header subsystem type | |
34983 | required for console applications. | |
34984 | This option is available for Cygwin and MinGW targets and is | |
34985 | enabled by default on those targets. | |
34986 | ||
453cb585 PR |
34987 | @opindex mcrtdll |
34988 | @item -mcrtdll=@var{library} | |
34989 | Preprocess, compile or link with specified C RunTime DLL @var{library}. | |
34990 | This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__} | |
34991 | and @code{__MSVCRT_VERSION__} for specified CRT @var{library}, choose | |
34992 | start file for CRT @var{library} and link with CRT @var{library}. | |
34993 | Recognized CRT library names for proprocessor are: | |
34994 | @code{crtdll}, @code{msvcrt10}, @code{msvcrt20}, @code{msvcrt40}, | |
34995 | @code{msvcrt-os}, @code{msvcr70}, @code{msvcr80}, @code{msvcr90}, | |
34996 | @code{msvcr100}, @code{msvcr110}, @code{msvcr120} and @code{ucrt}. | |
34997 | If this options is not specified then the default MinGW import library | |
34998 | @code{msvcrt} is used for linking and no other adjustment for | |
34999 | preprocessor is done. MinGW import library @code{msvcrt} is just a | |
35000 | symlink to (or a copy of) another MinGW CRT import library | |
35001 | chosen during MinGW compilation. MinGW import library @code{msvcrt-os} | |
35002 | is for Windows system CRT DLL library @code{msvcrt.dll} and | |
35003 | in most cases is the default MinGW import library. | |
35004 | Generally speaking, changing the CRT DLL requires recompiling | |
35005 | the entire MinGW CRT. This option is for experimental and testing | |
35006 | purposes only. | |
35007 | This option is available for MinGW targets. | |
35008 | ||
d77de738 | 35009 | @opindex mdll |
ddf6fe37 | 35010 | @item -mdll |
d77de738 ML |
35011 | This option is available for Cygwin and MinGW targets. It |
35012 | specifies that a DLL---a dynamic link library---is to be | |
35013 | generated, enabling the selection of the required runtime | |
35014 | startup object and entry point. | |
35015 | ||
d77de738 | 35016 | @opindex mnop-fun-dllimport |
ddf6fe37 | 35017 | @item -mnop-fun-dllimport |
d77de738 ML |
35018 | This option is available for Cygwin and MinGW targets. It |
35019 | specifies that the @code{dllimport} attribute should be ignored. | |
35020 | ||
d77de738 | 35021 | @opindex mthreads |
ddf6fe37 | 35022 | @item -mthreads |
d77de738 ML |
35023 | This option is available for MinGW targets. It specifies |
35024 | that MinGW-specific thread support is to be used. | |
35025 | ||
d77de738 | 35026 | @opindex municode |
ddf6fe37 | 35027 | @item -municode |
d77de738 ML |
35028 | This option is available for MinGW-w64 targets. It causes |
35029 | the @code{UNICODE} preprocessor macro to be predefined, and | |
35030 | chooses Unicode-capable runtime startup code. | |
35031 | ||
d77de738 | 35032 | @opindex mwin32 |
ddf6fe37 | 35033 | @item -mwin32 |
d77de738 ML |
35034 | This option is available for Cygwin and MinGW targets. It |
35035 | specifies that the typical Microsoft Windows predefined macros are to | |
35036 | be set in the pre-processor, but does not influence the choice | |
35037 | of runtime library/startup code. | |
35038 | ||
d77de738 | 35039 | @opindex mwindows |
ddf6fe37 | 35040 | @item -mwindows |
d77de738 ML |
35041 | This option is available for Cygwin and MinGW targets. It |
35042 | specifies that a GUI application is to be generated by | |
35043 | instructing the linker to set the PE header subsystem type | |
35044 | appropriately. | |
35045 | ||
d77de738 ML |
35046 | @opindex fno-set-stack-executable |
35047 | @opindex fset-stack-executable | |
ddf6fe37 | 35048 | @item -fno-set-stack-executable |
d77de738 ML |
35049 | This option is available for MinGW targets. It specifies that |
35050 | the executable flag for the stack used by nested functions isn't | |
35051 | set. This is necessary for binaries running in kernel mode of | |
35052 | Microsoft Windows, as there the User32 API, which is used to set executable | |
35053 | privileges, isn't available. | |
35054 | ||
d77de738 ML |
35055 | @opindex fno-writable-relocated-rdata |
35056 | @opindex fwritable-relocated-rdata | |
ddf6fe37 | 35057 | @item -fwritable-relocated-rdata |
d77de738 ML |
35058 | This option is available for MinGW and Cygwin targets. It specifies |
35059 | that relocated-data in read-only section is put into the @code{.data} | |
35060 | section. This is a necessary for older runtimes not supporting | |
35061 | modification of @code{.rdata} sections for pseudo-relocation. | |
35062 | ||
d77de738 | 35063 | @opindex mpe-aligned-commons |
ddf6fe37 | 35064 | @item -mpe-aligned-commons |
d77de738 ML |
35065 | This option is available for Cygwin and MinGW targets. It |
35066 | specifies that the GNU extension to the PE file format that | |
35067 | permits the correct alignment of COMMON variables should be | |
35068 | used when generating code. It is enabled by default if | |
35069 | GCC detects that the target assembler found during configuration | |
35070 | supports the feature. | |
35071 | @end table | |
35072 | ||
35073 | See also under @ref{x86 Options} for standard options. | |
35074 | ||
35075 | @node Xstormy16 Options | |
35076 | @subsection Xstormy16 Options | |
35077 | @cindex Xstormy16 Options | |
35078 | ||
35079 | These options are defined for Xstormy16: | |
35080 | ||
35081 | @table @gcctabopt | |
d77de738 | 35082 | @opindex msim |
ddf6fe37 | 35083 | @item -msim |
d77de738 ML |
35084 | Choose startup files and linker script suitable for the simulator. |
35085 | @end table | |
35086 | ||
35087 | @node Xtensa Options | |
35088 | @subsection Xtensa Options | |
35089 | @cindex Xtensa Options | |
35090 | ||
35091 | These options are supported for Xtensa targets: | |
35092 | ||
35093 | @table @gcctabopt | |
d77de738 ML |
35094 | @opindex mconst16 |
35095 | @opindex mno-const16 | |
ddf6fe37 AA |
35096 | @item -mconst16 |
35097 | @itemx -mno-const16 | |
d77de738 ML |
35098 | Enable or disable use of @code{CONST16} instructions for loading |
35099 | constant values. The @code{CONST16} instruction is currently not a | |
35100 | standard option from Tensilica. When enabled, @code{CONST16} | |
35101 | instructions are always used in place of the standard @code{L32R} | |
35102 | instructions. The use of @code{CONST16} is enabled by default only if | |
35103 | the @code{L32R} instruction is not available. | |
35104 | ||
d77de738 ML |
35105 | @opindex mfused-madd |
35106 | @opindex mno-fused-madd | |
ddf6fe37 AA |
35107 | @item -mfused-madd |
35108 | @itemx -mno-fused-madd | |
d77de738 ML |
35109 | Enable or disable use of fused multiply/add and multiply/subtract |
35110 | instructions in the floating-point option. This has no effect if the | |
35111 | floating-point option is not also enabled. Disabling fused multiply/add | |
35112 | and multiply/subtract instructions forces the compiler to use separate | |
35113 | instructions for the multiply and add/subtract operations. This may be | |
35114 | desirable in some cases where strict IEEE 754-compliant results are | |
35115 | required: the fused multiply add/subtract instructions do not round the | |
35116 | intermediate result, thereby producing results with @emph{more} bits of | |
35117 | precision than specified by the IEEE standard. Disabling fused multiply | |
35118 | add/subtract instructions also ensures that the program output is not | |
35119 | sensitive to the compiler's ability to combine multiply and add/subtract | |
35120 | operations. | |
35121 | ||
d77de738 ML |
35122 | @opindex mserialize-volatile |
35123 | @opindex mno-serialize-volatile | |
ddf6fe37 AA |
35124 | @item -mserialize-volatile |
35125 | @itemx -mno-serialize-volatile | |
d77de738 ML |
35126 | When this option is enabled, GCC inserts @code{MEMW} instructions before |
35127 | @code{volatile} memory references to guarantee sequential consistency. | |
35128 | The default is @option{-mserialize-volatile}. Use | |
35129 | @option{-mno-serialize-volatile} to omit the @code{MEMW} instructions. | |
35130 | ||
d77de738 | 35131 | @opindex mforce-no-pic |
ddf6fe37 | 35132 | @item -mforce-no-pic |
d77de738 ML |
35133 | For targets, like GNU/Linux, where all user-mode Xtensa code must be |
35134 | position-independent code (PIC), this option disables PIC for compiling | |
35135 | kernel code. | |
35136 | ||
d77de738 ML |
35137 | @opindex mtext-section-literals |
35138 | @opindex mno-text-section-literals | |
ddf6fe37 AA |
35139 | @item -mtext-section-literals |
35140 | @itemx -mno-text-section-literals | |
d77de738 ML |
35141 | These options control the treatment of literal pools. The default is |
35142 | @option{-mno-text-section-literals}, which places literals in a separate | |
35143 | section in the output file. This allows the literal pool to be placed | |
35144 | in a data RAM/ROM, and it also allows the linker to combine literal | |
35145 | pools from separate object files to remove redundant literals and | |
35146 | improve code size. With @option{-mtext-section-literals}, the literals | |
35147 | are interspersed in the text section in order to keep them as close as | |
35148 | possible to their references. This may be necessary for large assembly | |
35149 | files. Literals for each function are placed right before that function. | |
35150 | ||
d77de738 ML |
35151 | @opindex mauto-litpools |
35152 | @opindex mno-auto-litpools | |
ddf6fe37 AA |
35153 | @item -mauto-litpools |
35154 | @itemx -mno-auto-litpools | |
d77de738 ML |
35155 | These options control the treatment of literal pools. The default is |
35156 | @option{-mno-auto-litpools}, which places literals in a separate | |
35157 | section in the output file unless @option{-mtext-section-literals} is | |
35158 | used. With @option{-mauto-litpools} the literals are interspersed in | |
35159 | the text section by the assembler. Compiler does not produce explicit | |
35160 | @code{.literal} directives and loads literals into registers with | |
35161 | @code{MOVI} instructions instead of @code{L32R} to let the assembler | |
35162 | do relaxation and place literals as necessary. This option allows | |
35163 | assembler to create several literal pools per function and assemble | |
35164 | very big functions, which may not be possible with | |
35165 | @option{-mtext-section-literals}. | |
35166 | ||
d77de738 ML |
35167 | @opindex mtarget-align |
35168 | @opindex mno-target-align | |
ddf6fe37 AA |
35169 | @item -mtarget-align |
35170 | @itemx -mno-target-align | |
d77de738 ML |
35171 | When this option is enabled, GCC instructs the assembler to |
35172 | automatically align instructions to reduce branch penalties at the | |
35173 | expense of some code density. The assembler attempts to widen density | |
35174 | instructions to align branch targets and the instructions following call | |
35175 | instructions. If there are not enough preceding safe density | |
35176 | instructions to align a target, no widening is performed. The | |
35177 | default is @option{-mtarget-align}. These options do not affect the | |
35178 | treatment of auto-aligned instructions like @code{LOOP}, which the | |
35179 | assembler always aligns, either by widening density instructions or | |
35180 | by inserting NOP instructions. | |
35181 | ||
d77de738 ML |
35182 | @opindex mlongcalls |
35183 | @opindex mno-longcalls | |
ddf6fe37 AA |
35184 | @item -mlongcalls |
35185 | @itemx -mno-longcalls | |
d77de738 ML |
35186 | When this option is enabled, GCC instructs the assembler to translate |
35187 | direct calls to indirect calls unless it can determine that the target | |
35188 | of a direct call is in the range allowed by the call instruction. This | |
35189 | translation typically occurs for calls to functions in other source | |
35190 | files. Specifically, the assembler translates a direct @code{CALL} | |
35191 | instruction into an @code{L32R} followed by a @code{CALLX} instruction. | |
35192 | The default is @option{-mno-longcalls}. This option should be used in | |
35193 | programs where the call target can potentially be out of range. This | |
35194 | option is implemented in the assembler, not the compiler, so the | |
35195 | assembly code generated by GCC still shows direct call | |
35196 | instructions---look at the disassembled object code to see the actual | |
35197 | instructions. Note that the assembler uses an indirect call for | |
35198 | every cross-file call, not just those that really are out of range. | |
35199 | ||
d77de738 | 35200 | @opindex mabi |
ddf6fe37 | 35201 | @item -mabi=@var{name} |
d77de738 ML |
35202 | Generate code for the specified ABI@. Permissible values are: @samp{call0}, |
35203 | @samp{windowed}. Default ABI is chosen by the Xtensa core configuration. | |
35204 | ||
d77de738 | 35205 | @opindex mabi=call0 |
ddf6fe37 | 35206 | @item -mabi=call0 |
d77de738 ML |
35207 | When this option is enabled function parameters are passed in registers |
35208 | @code{a2} through @code{a7}, registers @code{a12} through @code{a15} are | |
35209 | caller-saved, and register @code{a15} may be used as a frame pointer. | |
35210 | When this version of the ABI is enabled the C preprocessor symbol | |
35211 | @code{__XTENSA_CALL0_ABI__} is defined. | |
35212 | ||
d77de738 | 35213 | @opindex mabi=windowed |
ddf6fe37 | 35214 | @item -mabi=windowed |
d77de738 ML |
35215 | When this option is enabled function parameters are passed in registers |
35216 | @code{a10} through @code{a15}, and called function rotates register window | |
35217 | by 8 registers on entry so that its arguments are found in registers | |
35218 | @code{a2} through @code{a7}. Register @code{a7} may be used as a frame | |
35219 | pointer. Register window is rotated 8 registers back upon return. | |
35220 | When this version of the ABI is enabled the C preprocessor symbol | |
35221 | @code{__XTENSA_WINDOWED_ABI__} is defined. | |
35222 | ||
d77de738 | 35223 | @opindex mextra-l32r-costs |
ddf6fe37 | 35224 | @item -mextra-l32r-costs=@var{n} |
d77de738 ML |
35225 | Specify an extra cost of instruction RAM/ROM access for @code{L32R} |
35226 | instructions, in clock cycles. This affects, when optimizing for speed, | |
35227 | whether loading a constant from literal pool using @code{L32R} or | |
35228 | synthesizing the constant from a small one with a couple of arithmetic | |
35229 | instructions. The default value is 0. | |
675b390e MF |
35230 | |
35231 | @opindex mstrict-align | |
35232 | @opindex mno-strict-align | |
35233 | @item -mstrict-align | |
35234 | @itemx -mno-strict-align | |
35235 | Avoid or allow generating memory accesses that may not be aligned on a natural | |
35236 | object boundary as described in the architecture specification. | |
35237 | The default is @option{-mno-strict-align} for cores that support both | |
35238 | unaligned loads and stores in hardware and @option{-mstrict-align} for all | |
35239 | other cores. | |
35240 | ||
d77de738 ML |
35241 | @end table |
35242 | ||
35243 | @node zSeries Options | |
35244 | @subsection zSeries Options | |
35245 | @cindex zSeries options | |
35246 | ||
35247 | These are listed under @xref{S/390 and zSeries Options}. | |
35248 | ||
35249 | ||
35250 | @c man end | |
35251 | ||
35252 | @node Spec Files | |
35253 | @section Specifying Subprocesses and the Switches to Pass to Them | |
35254 | @cindex Spec Files | |
35255 | ||
35256 | @command{gcc} is a driver program. It performs its job by invoking a | |
35257 | sequence of other programs to do the work of compiling, assembling and | |
35258 | linking. GCC interprets its command-line parameters and uses these to | |
35259 | deduce which programs it should invoke, and which command-line options | |
35260 | it ought to place on their command lines. This behavior is controlled | |
35261 | by @dfn{spec strings}. In most cases there is one spec string for each | |
35262 | program that GCC can invoke, but a few programs have multiple spec | |
35263 | strings to control their behavior. The spec strings built into GCC can | |
35264 | be overridden by using the @option{-specs=} command-line switch to specify | |
35265 | a spec file. | |
35266 | ||
35267 | @dfn{Spec files} are plain-text files that are used to construct spec | |
35268 | strings. They consist of a sequence of directives separated by blank | |
35269 | lines. The type of directive is determined by the first non-whitespace | |
35270 | character on the line, which can be one of the following: | |
35271 | ||
35272 | @table @code | |
35273 | @item %@var{command} | |
35274 | Issues a @var{command} to the spec file processor. The commands that can | |
35275 | appear here are: | |
35276 | ||
35277 | @table @code | |
d77de738 | 35278 | @cindex @code{%include} |
f33d7a88 | 35279 | @item %include <@var{file}> |
d77de738 ML |
35280 | Search for @var{file} and insert its text at the current point in the |
35281 | specs file. | |
35282 | ||
d77de738 | 35283 | @cindex @code{%include_noerr} |
f33d7a88 | 35284 | @item %include_noerr <@var{file}> |
d77de738 ML |
35285 | Just like @samp{%include}, but do not generate an error message if the include |
35286 | file cannot be found. | |
35287 | ||
d77de738 | 35288 | @cindex @code{%rename} |
f33d7a88 | 35289 | @item %rename @var{old_name} @var{new_name} |
d77de738 ML |
35290 | Rename the spec string @var{old_name} to @var{new_name}. |
35291 | ||
35292 | @end table | |
35293 | ||
35294 | @item *[@var{spec_name}]: | |
35295 | This tells the compiler to create, override or delete the named spec | |
35296 | string. All lines after this directive up to the next directive or | |
35297 | blank line are considered to be the text for the spec string. If this | |
35298 | results in an empty string then the spec is deleted. (Or, if the | |
35299 | spec did not exist, then nothing happens.) Otherwise, if the spec | |
35300 | does not currently exist a new spec is created. If the spec does | |
35301 | exist then its contents are overridden by the text of this | |
35302 | directive, unless the first character of that text is the @samp{+} | |
35303 | character, in which case the text is appended to the spec. | |
35304 | ||
35305 | @item [@var{suffix}]: | |
35306 | Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive | |
35307 | and up to the next directive or blank line are considered to make up the | |
35308 | spec string for the indicated suffix. When the compiler encounters an | |
35309 | input file with the named suffix, it processes the spec string in | |
35310 | order to work out how to compile that file. For example: | |
35311 | ||
35312 | @smallexample | |
35313 | .ZZ: | |
35314 | z-compile -input %i | |
35315 | @end smallexample | |
35316 | ||
35317 | This says that any input file whose name ends in @samp{.ZZ} should be | |
35318 | passed to the program @samp{z-compile}, which should be invoked with the | |
35319 | command-line switch @option{-input} and with the result of performing the | |
35320 | @samp{%i} substitution. (See below.) | |
35321 | ||
35322 | As an alternative to providing a spec string, the text following a | |
35323 | suffix directive can be one of the following: | |
35324 | ||
35325 | @table @code | |
35326 | @item @@@var{language} | |
35327 | This says that the suffix is an alias for a known @var{language}. This is | |
35328 | similar to using the @option{-x} command-line switch to GCC to specify a | |
35329 | language explicitly. For example: | |
35330 | ||
35331 | @smallexample | |
35332 | .ZZ: | |
35333 | @@c++ | |
35334 | @end smallexample | |
35335 | ||
35336 | Says that .ZZ files are, in fact, C++ source files. | |
35337 | ||
35338 | @item #@var{name} | |
35339 | This causes an error messages saying: | |
35340 | ||
35341 | @smallexample | |
35342 | @var{name} compiler not installed on this system. | |
35343 | @end smallexample | |
35344 | @end table | |
35345 | ||
35346 | GCC already has an extensive list of suffixes built into it. | |
35347 | This directive adds an entry to the end of the list of suffixes, but | |
35348 | since the list is searched from the end backwards, it is effectively | |
35349 | possible to override earlier entries using this technique. | |
35350 | ||
35351 | @end table | |
35352 | ||
35353 | GCC has the following spec strings built into it. Spec files can | |
35354 | override these strings or create their own. Note that individual | |
35355 | targets can also add their own spec strings to this list. | |
35356 | ||
35357 | @smallexample | |
35358 | asm Options to pass to the assembler | |
35359 | asm_final Options to pass to the assembler post-processor | |
35360 | cpp Options to pass to the C preprocessor | |
35361 | cc1 Options to pass to the C compiler | |
35362 | cc1plus Options to pass to the C++ compiler | |
35363 | endfile Object files to include at the end of the link | |
35364 | link Options to pass to the linker | |
35365 | lib Libraries to include on the command line to the linker | |
35366 | libgcc Decides which GCC support library to pass to the linker | |
35367 | linker Sets the name of the linker | |
35368 | predefines Defines to be passed to the C preprocessor | |
35369 | signed_char Defines to pass to CPP to say whether @code{char} is signed | |
35370 | by default | |
35371 | startfile Object files to include at the start of the link | |
35372 | @end smallexample | |
35373 | ||
35374 | Here is a small example of a spec file: | |
35375 | ||
35376 | @smallexample | |
35377 | %rename lib old_lib | |
35378 | ||
35379 | *lib: | |
35380 | --start-group -lgcc -lc -leval1 --end-group %(old_lib) | |
35381 | @end smallexample | |
35382 | ||
35383 | This example renames the spec called @samp{lib} to @samp{old_lib} and | |
35384 | then overrides the previous definition of @samp{lib} with a new one. | |
35385 | The new definition adds in some extra command-line options before | |
35386 | including the text of the old definition. | |
35387 | ||
35388 | @dfn{Spec strings} are a list of command-line options to be passed to their | |
35389 | corresponding program. In addition, the spec strings can contain | |
35390 | @samp{%}-prefixed sequences to substitute variable text or to | |
35391 | conditionally insert text into the command line. Using these constructs | |
35392 | it is possible to generate quite complex command lines. | |
35393 | ||
35394 | Here is a table of all defined @samp{%}-sequences for spec | |
35395 | strings. Note that spaces are not generated automatically around the | |
35396 | results of expanding these sequences. Therefore you can concatenate them | |
35397 | together or combine them with constant text in a single argument. | |
35398 | ||
35399 | @table @code | |
35400 | @item %% | |
35401 | Substitute one @samp{%} into the program name or argument. | |
35402 | ||
35403 | @item %" | |
35404 | Substitute an empty argument. | |
35405 | ||
35406 | @item %i | |
35407 | Substitute the name of the input file being processed. | |
35408 | ||
35409 | @item %b | |
35410 | Substitute the basename for outputs related with the input file being | |
35411 | processed. This is often the substring up to (and not including) the | |
35412 | last period and not including the directory but, unless %w is active, it | |
35413 | expands to the basename for auxiliary outputs, which may be influenced | |
35414 | by an explicit output name, and by various other options that control | |
35415 | how auxiliary outputs are named. | |
35416 | ||
35417 | @item %B | |
35418 | This is the same as @samp{%b}, but include the file suffix (text after | |
35419 | the last period). Without %w, it expands to the basename for dump | |
35420 | outputs. | |
35421 | ||
35422 | @item %d | |
35423 | Marks the argument containing or following the @samp{%d} as a | |
35424 | temporary file name, so that that file is deleted if GCC exits | |
35425 | successfully. Unlike @samp{%g}, this contributes no text to the | |
35426 | argument. | |
35427 | ||
35428 | @item %g@var{suffix} | |
35429 | Substitute a file name that has suffix @var{suffix} and is chosen | |
35430 | once per compilation, and mark the argument in the same way as | |
35431 | @samp{%d}. To reduce exposure to denial-of-service attacks, the file | |
35432 | name is now chosen in a way that is hard to predict even when previously | |
35433 | chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s} | |
35434 | might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches | |
35435 | the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is | |
35436 | treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g} | |
35437 | was simply substituted with a file name chosen once per compilation, | |
35438 | without regard to any appended suffix (which was therefore treated | |
35439 | just like ordinary text), making such attacks more likely to succeed. | |
35440 | ||
35441 | @item %u@var{suffix} | |
35442 | Like @samp{%g}, but generates a new temporary file name | |
35443 | each time it appears instead of once per compilation. | |
35444 | ||
35445 | @item %U@var{suffix} | |
35446 | Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a | |
35447 | new one if there is no such last file name. In the absence of any | |
35448 | @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share | |
35449 | the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s} | |
35450 | involves the generation of two distinct file names, one | |
35451 | for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was | |
35452 | simply substituted with a file name chosen for the previous @samp{%u}, | |
35453 | without regard to any appended suffix. | |
35454 | ||
35455 | @item %j@var{suffix} | |
35456 | Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is | |
35457 | writable, and if @option{-save-temps} is not used; | |
35458 | otherwise, substitute the name | |
35459 | of a temporary file, just like @samp{%u}. This temporary file is not | |
35460 | meant for communication between processes, but rather as a junk | |
35461 | disposal mechanism. | |
35462 | ||
35463 | @item %|@var{suffix} | |
35464 | @itemx %m@var{suffix} | |
35465 | Like @samp{%g}, except if @option{-pipe} is in effect. In that case | |
35466 | @samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at | |
35467 | all. These are the two most common ways to instruct a program that it | |
35468 | should read from standard input or write to standard output. If you | |
35469 | need something more elaborate you can use an @samp{%@{pipe:@code{X}@}} | |
35470 | construct: see for example @file{gcc/fortran/lang-specs.h}. | |
35471 | ||
35472 | @item %.@var{SUFFIX} | |
35473 | Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args | |
35474 | when it is subsequently output with @samp{%*}. @var{SUFFIX} is | |
35475 | terminated by the next space or %. | |
35476 | ||
35477 | @item %w | |
35478 | Marks the argument containing or following the @samp{%w} as the | |
35479 | designated output file of this compilation. This puts the argument | |
35480 | into the sequence of arguments that @samp{%o} substitutes. | |
35481 | ||
35482 | @item %V | |
35483 | Indicates that this compilation produces no output file. | |
35484 | ||
35485 | @item %o | |
35486 | Substitutes the names of all the output files, with spaces | |
35487 | automatically placed around them. You should write spaces | |
35488 | around the @samp{%o} as well or the results are undefined. | |
35489 | @samp{%o} is for use in the specs for running the linker. | |
35490 | Input files whose names have no recognized suffix are not compiled | |
35491 | at all, but they are included among the output files, so they are | |
35492 | linked. | |
35493 | ||
35494 | @item %O | |
35495 | Substitutes the suffix for object files. Note that this is | |
35496 | handled specially when it immediately follows @samp{%g, %u, or %U}, | |
35497 | because of the need for those to form complete file names. The | |
35498 | handling is such that @samp{%O} is treated exactly as if it had already | |
35499 | been substituted, except that @samp{%g, %u, and %U} do not currently | |
35500 | support additional @var{suffix} characters following @samp{%O} as they do | |
35501 | following, for example, @samp{.o}. | |
35502 | ||
35503 | @item %I | |
35504 | Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}), | |
35505 | @option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}), | |
35506 | @option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options) | |
35507 | and @option{-imultilib} as necessary. | |
35508 | ||
35509 | @item %s | |
35510 | Current argument is the name of a library or startup file of some sort. | |
35511 | Search for that file in a standard list of directories and substitute | |
35512 | the full name found. The current working directory is included in the | |
35513 | list of directories scanned. | |
35514 | ||
35515 | @item %T | |
35516 | Current argument is the name of a linker script. Search for that file | |
35517 | in the current list of directories to scan for libraries. If the file | |
35518 | is located insert a @option{--script} option into the command line | |
35519 | followed by the full path name found. If the file is not found then | |
35520 | generate an error message. Note: the current working directory is not | |
35521 | searched. | |
35522 | ||
35523 | @item %e@var{str} | |
35524 | Print @var{str} as an error message. @var{str} is terminated by a newline. | |
35525 | Use this when inconsistent options are detected. | |
35526 | ||
35527 | @item %n@var{str} | |
35528 | Print @var{str} as a notice. @var{str} is terminated by a newline. | |
35529 | ||
35530 | @item %(@var{name}) | |
35531 | Substitute the contents of spec string @var{name} at this point. | |
35532 | ||
35533 | @item %x@{@var{option}@} | |
35534 | Accumulate an option for @samp{%X}. | |
35535 | ||
35536 | @item %X | |
35537 | Output the accumulated linker options specified by a @samp{%x} spec string. | |
35538 | ||
35539 | @item %Y | |
35540 | Output the accumulated assembler options specified by @option{-Wa}. | |
35541 | ||
35542 | @item %Z | |
35543 | Output the accumulated preprocessor options specified by @option{-Wp}. | |
35544 | ||
35545 | @item %M | |
35546 | Output @code{multilib_os_dir}. | |
35547 | ||
35548 | @item %R | |
35549 | Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}. | |
35550 | ||
35551 | @item %a | |
35552 | Process the @code{asm} spec. This is used to compute the | |
35553 | switches to be passed to the assembler. | |
35554 | ||
35555 | @item %A | |
35556 | Process the @code{asm_final} spec. This is a spec string for | |
35557 | passing switches to an assembler post-processor, if such a program is | |
35558 | needed. | |
35559 | ||
35560 | @item %l | |
35561 | Process the @code{link} spec. This is the spec for computing the | |
35562 | command line passed to the linker. Typically it makes use of the | |
35563 | @samp{%L %G %S %D and %E} sequences. | |
35564 | ||
35565 | @item %D | |
35566 | Dump out a @option{-L} option for each directory that GCC believes might | |
35567 | contain startup files. If the target supports multilibs then the | |
35568 | current multilib directory is prepended to each of these paths. | |
35569 | ||
35570 | @item %L | |
35571 | Process the @code{lib} spec. This is a spec string for deciding which | |
35572 | libraries are included on the command line to the linker. | |
35573 | ||
35574 | @item %G | |
35575 | Process the @code{libgcc} spec. This is a spec string for deciding | |
35576 | which GCC support library is included on the command line to the linker. | |
35577 | ||
35578 | @item %S | |
35579 | Process the @code{startfile} spec. This is a spec for deciding which | |
35580 | object files are the first ones passed to the linker. Typically | |
35581 | this might be a file named @file{crt0.o}. | |
35582 | ||
35583 | @item %E | |
35584 | Process the @code{endfile} spec. This is a spec string that specifies | |
35585 | the last object files that are passed to the linker. | |
35586 | ||
35587 | @item %C | |
35588 | Process the @code{cpp} spec. This is used to construct the arguments | |
35589 | to be passed to the C preprocessor. | |
35590 | ||
35591 | @item %1 | |
35592 | Process the @code{cc1} spec. This is used to construct the options to be | |
35593 | passed to the actual C compiler (@command{cc1}). | |
35594 | ||
35595 | @item %2 | |
35596 | Process the @code{cc1plus} spec. This is used to construct the options to be | |
35597 | passed to the actual C++ compiler (@command{cc1plus}). | |
35598 | ||
35599 | @item %* | |
35600 | Substitute the variable part of a matched option. See below. | |
35601 | Note that each comma in the substituted string is replaced by | |
35602 | a single space. | |
35603 | ||
35604 | @item %<S | |
35605 | Remove all occurrences of @code{-S} from the command line. Note---this | |
35606 | command is position dependent. @samp{%} commands in the spec string | |
35607 | before this one see @code{-S}, @samp{%} commands in the spec string | |
35608 | after this one do not. | |
35609 | ||
35610 | @item %<S* | |
35611 | Similar to @samp{%<S}, but match all switches beginning with @code{-S}. | |
35612 | ||
35613 | @item %>S | |
35614 | Similar to @samp{%<S}, but keep @code{-S} in the GCC command line. | |
35615 | ||
35616 | @item %:@var{function}(@var{args}) | |
35617 | Call the named function @var{function}, passing it @var{args}. | |
35618 | @var{args} is first processed as a nested spec string, then split | |
35619 | into an argument vector in the usual fashion. The function returns | |
35620 | a string which is processed as if it had appeared literally as part | |
35621 | of the current spec. | |
35622 | ||
35623 | The following built-in spec functions are provided: | |
35624 | ||
35625 | @table @code | |
35626 | @item @code{getenv} | |
35627 | The @code{getenv} spec function takes two arguments: an environment | |
35628 | variable name and a string. If the environment variable is not | |
35629 | defined, a fatal error is issued. Otherwise, the return value is the | |
35630 | value of the environment variable concatenated with the string. For | |
35631 | example, if @env{TOPDIR} is defined as @file{/path/to/top}, then: | |
35632 | ||
35633 | @smallexample | |
35634 | %:getenv(TOPDIR /include) | |
35635 | @end smallexample | |
35636 | ||
35637 | expands to @file{/path/to/top/include}. | |
35638 | ||
35639 | @item @code{if-exists} | |
35640 | The @code{if-exists} spec function takes one argument, an absolute | |
35641 | pathname to a file. If the file exists, @code{if-exists} returns the | |
35642 | pathname. Here is a small example of its usage: | |
35643 | ||
35644 | @smallexample | |
35645 | *startfile: | |
35646 | crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s | |
35647 | @end smallexample | |
35648 | ||
35649 | @item @code{if-exists-else} | |
35650 | The @code{if-exists-else} spec function is similar to the @code{if-exists} | |
35651 | spec function, except that it takes two arguments. The first argument is | |
35652 | an absolute pathname to a file. If the file exists, @code{if-exists-else} | |
35653 | returns the pathname. If it does not exist, it returns the second argument. | |
35654 | This way, @code{if-exists-else} can be used to select one file or another, | |
35655 | based on the existence of the first. Here is a small example of its usage: | |
35656 | ||
35657 | @smallexample | |
35658 | *startfile: | |
35659 | crt0%O%s %:if-exists(crti%O%s) \ | |
35660 | %:if-exists-else(crtbeginT%O%s crtbegin%O%s) | |
35661 | @end smallexample | |
35662 | ||
35663 | @item @code{if-exists-then-else} | |
35664 | The @code{if-exists-then-else} spec function takes at least two arguments | |
35665 | and an optional third one. The first argument is an absolute pathname to a | |
35666 | file. If the file exists, the function returns the second argument. | |
35667 | If the file does not exist, the function returns the third argument if there | |
35668 | is one, or NULL otherwise. This can be used to expand one text, or optionally | |
35669 | another, based on the existence of a file. Here is a small example of its | |
35670 | usage: | |
35671 | ||
35672 | @smallexample | |
35673 | -l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net) | |
35674 | @end smallexample | |
35675 | ||
35676 | @item @code{sanitize} | |
35677 | The @code{sanitize} spec function takes no arguments. It returns non-NULL if | |
35678 | any address, thread or undefined behavior sanitizers are active. | |
35679 | ||
35680 | @smallexample | |
35681 | %@{%:sanitize(address):-funwind-tables@} | |
35682 | @end smallexample | |
35683 | ||
35684 | @item @code{replace-outfile} | |
35685 | The @code{replace-outfile} spec function takes two arguments. It looks for the | |
35686 | first argument in the outfiles array and replaces it with the second argument. Here | |
35687 | is a small example of its usage: | |
35688 | ||
35689 | @smallexample | |
35690 | %@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@} | |
35691 | @end smallexample | |
35692 | ||
35693 | @item @code{remove-outfile} | |
35694 | The @code{remove-outfile} spec function takes one argument. It looks for the | |
35695 | first argument in the outfiles array and removes it. Here is a small example | |
35696 | its usage: | |
35697 | ||
35698 | @smallexample | |
35699 | %:remove-outfile(-lm) | |
35700 | @end smallexample | |
35701 | ||
35702 | @item @code{version-compare} | |
35703 | The @code{version-compare} spec function takes four or five arguments of the following | |
35704 | form: | |
35705 | ||
35706 | @smallexample | |
35707 | <comparison-op> <arg1> [<arg2>] <switch> <result> | |
35708 | @end smallexample | |
35709 | ||
35710 | It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't. | |
35711 | The supported @code{comparison-op} values are: | |
35712 | ||
35713 | @table @code | |
35714 | @item >= | |
35715 | True if @code{switch} is a later (or same) version than @code{arg1} | |
35716 | ||
35717 | @item !> | |
35718 | Opposite of @code{>=} | |
35719 | ||
35720 | @item < | |
35721 | True if @code{switch} is an earlier version than @code{arg1} | |
35722 | ||
35723 | @item !< | |
35724 | Opposite of @code{<} | |
35725 | ||
35726 | @item >< | |
35727 | True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2} | |
35728 | ||
35729 | @item <> | |
35730 | True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later | |
35731 | @end table | |
35732 | ||
35733 | If the @code{switch} is not present at all, the condition is false unless the first character | |
35734 | of the @code{comparison-op} is @code{!}. | |
35735 | ||
35736 | @smallexample | |
35737 | %:version-compare(>= 10.3 mmacosx-version-min= -lmx) | |
35738 | @end smallexample | |
35739 | ||
35740 | The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was | |
35741 | passed. | |
35742 | ||
35743 | @item @code{include} | |
35744 | The @code{include} spec function behaves much like @code{%include}, with the advantage | |
35745 | that it can be nested inside a spec and thus be conditionalized. It takes one argument, | |
35746 | the filename, and looks for it in the startfile path. It always returns NULL. | |
35747 | ||
35748 | @smallexample | |
35749 | %@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@} | |
35750 | @end smallexample | |
35751 | ||
35752 | @item @code{pass-through-libs} | |
35753 | The @code{pass-through-libs} spec function takes any number of arguments. It | |
35754 | finds any @option{-l} options and any non-options ending in @file{.a} (which it | |
35755 | assumes are the names of linker input library archive files) and returns a | |
35756 | result containing all the found arguments each prepended by | |
35757 | @option{-plugin-opt=-pass-through=} and joined by spaces. This list is | |
35758 | intended to be passed to the LTO linker plugin. | |
35759 | ||
35760 | @smallexample | |
35761 | %:pass-through-libs(%G %L %G) | |
35762 | @end smallexample | |
35763 | ||
35764 | @item @code{print-asm-header} | |
35765 | The @code{print-asm-header} function takes no arguments and simply | |
35766 | prints a banner like: | |
35767 | ||
35768 | @smallexample | |
35769 | Assembler options | |
35770 | ================= | |
35771 | ||
35772 | Use "-Wa,OPTION" to pass "OPTION" to the assembler. | |
35773 | @end smallexample | |
35774 | ||
35775 | It is used to separate compiler options from assembler options | |
35776 | in the @option{--target-help} output. | |
35777 | ||
35778 | @item @code{gt} | |
35779 | The @code{gt} spec function takes two or more arguments. It returns @code{""} (the | |
35780 | empty string) if the second-to-last argument is greater than the last argument, and NULL | |
35781 | otherwise. The following example inserts the @code{link_gomp} spec if the last | |
35782 | @option{-ftree-parallelize-loops=} option given on the command line is greater than 1: | |
35783 | ||
35784 | @smallexample | |
35785 | %@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@} | |
35786 | @end smallexample | |
35787 | ||
35788 | @item @code{debug-level-gt} | |
35789 | The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the | |
35790 | empty string) if @code{debug_info_level} is greater than the specified number, and NULL | |
35791 | otherwise. | |
35792 | ||
35793 | @smallexample | |
35794 | %@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@} | |
35795 | @end smallexample | |
35796 | @end table | |
35797 | ||
35798 | @item %@{S@} | |
35799 | Substitutes the @code{-S} switch, if that switch is given to GCC@. | |
35800 | If that switch is not specified, this substitutes nothing. Note that | |
35801 | the leading dash is omitted when specifying this option, and it is | |
35802 | automatically inserted if the substitution is performed. Thus the spec | |
35803 | string @samp{%@{foo@}} matches the command-line option @option{-foo} | |
35804 | and outputs the command-line option @option{-foo}. | |
35805 | ||
35806 | @item %W@{S@} | |
35807 | Like %@{@code{S}@} but mark last argument supplied within as a file to be | |
35808 | deleted on failure. | |
35809 | ||
35810 | @item %@@@{S@} | |
35811 | Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes | |
35812 | @code{@@FILE} if an @code{@@file} argument has been supplied. | |
35813 | ||
35814 | @item %@{S*@} | |
35815 | Substitutes all the switches specified to GCC whose names start | |
35816 | with @code{-S}, but which also take an argument. This is used for | |
35817 | switches like @option{-o}, @option{-D}, @option{-I}, etc. | |
35818 | GCC considers @option{-o foo} as being | |
35819 | one switch whose name starts with @samp{o}. %@{o*@} substitutes this | |
35820 | text, including the space. Thus two arguments are generated. | |
35821 | ||
35822 | @item %@{S*&T*@} | |
35823 | Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options | |
35824 | (the order of @code{S} and @code{T} in the spec is not significant). | |
35825 | There can be any number of ampersand-separated variables; for each the | |
35826 | wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}. | |
35827 | ||
35828 | @item %@{S:X@} | |
35829 | Substitutes @code{X}, if the @option{-S} switch is given to GCC@. | |
35830 | ||
35831 | @item %@{!S:X@} | |
35832 | Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@. | |
35833 | ||
35834 | @item %@{S*:X@} | |
35835 | Substitutes @code{X} if one or more switches whose names start with | |
35836 | @code{-S} are specified to GCC@. Normally @code{X} is substituted only | |
35837 | once, no matter how many such switches appeared. However, if @code{%*} | |
35838 | appears somewhere in @code{X}, then @code{X} is substituted once | |
35839 | for each matching switch, with the @code{%*} replaced by the part of | |
35840 | that switch matching the @code{*}. | |
35841 | ||
35842 | If @code{%*} appears as the last part of a spec sequence then a space | |
35843 | is added after the end of the last substitution. If there is more | |
35844 | text in the sequence, however, then a space is not generated. This | |
35845 | allows the @code{%*} substitution to be used as part of a larger | |
35846 | string. For example, a spec string like this: | |
35847 | ||
35848 | @smallexample | |
35849 | %@{mcu=*:--script=%*/memory.ld@} | |
35850 | @end smallexample | |
35851 | ||
35852 | @noindent | |
35853 | when matching an option like @option{-mcu=newchip} produces: | |
35854 | ||
35855 | @smallexample | |
35856 | --script=newchip/memory.ld | |
35857 | @end smallexample | |
35858 | ||
35859 | @item %@{.S:X@} | |
35860 | Substitutes @code{X}, if processing a file with suffix @code{S}. | |
35861 | ||
35862 | @item %@{!.S:X@} | |
35863 | Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}. | |
35864 | ||
35865 | @item %@{,S:X@} | |
35866 | Substitutes @code{X}, if processing a file for language @code{S}. | |
35867 | ||
35868 | @item %@{!,S:X@} | |
35869 | Substitutes @code{X}, if not processing a file for language @code{S}. | |
35870 | ||
35871 | @item %@{S|P:X@} | |
35872 | Substitutes @code{X} if either @code{-S} or @code{-P} is given to | |
35873 | GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and | |
35874 | @code{*} sequences as well, although they have a stronger binding than | |
35875 | the @samp{|}. If @code{%*} appears in @code{X}, all of the | |
35876 | alternatives must be starred, and only the first matching alternative | |
35877 | is substituted. | |
35878 | ||
35879 | For example, a spec string like this: | |
35880 | ||
35881 | @smallexample | |
35882 | %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@} | |
35883 | @end smallexample | |
35884 | ||
35885 | @noindent | |
35886 | outputs the following command-line options from the following input | |
35887 | command-line options: | |
35888 | ||
35889 | @smallexample | |
35890 | fred.c -foo -baz | |
35891 | jim.d -bar -boggle | |
35892 | -d fred.c -foo -baz -boggle | |
35893 | -d jim.d -bar -baz -boggle | |
35894 | @end smallexample | |
35895 | ||
35896 | @item %@{%:@var{function}(@var{args}):X@} | |
35897 | ||
35898 | Call function named @var{function} with args @var{args}. If the | |
35899 | function returns non-NULL, then @code{X} is substituted, if it returns | |
35900 | NULL, it isn't substituted. | |
35901 | ||
35902 | @item %@{S:X; T:Y; :D@} | |
35903 | ||
35904 | If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is | |
35905 | given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can | |
35906 | be as many clauses as you need. This may be combined with @code{.}, | |
35907 | @code{,}, @code{!}, @code{|}, and @code{*} as needed. | |
35908 | ||
35909 | ||
35910 | @end table | |
35911 | ||
35912 | The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}} | |
35913 | or similar construct can use a backslash to ignore the special meaning | |
35914 | of the character following it, thus allowing literal matching of a | |
35915 | character that is otherwise specially treated. For example, | |
35916 | @samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the | |
35917 | @option{-std=iso9899:1999} option is given. | |
35918 | ||
35919 | The conditional text @code{X} in a @samp{%@{S:X@}} or similar | |
35920 | construct may contain other nested @samp{%} constructs or spaces, or | |
35921 | even newlines. They are processed as usual, as described above. | |
35922 | Trailing white space in @code{X} is ignored. White space may also | |
35923 | appear anywhere on the left side of the colon in these constructs, | |
35924 | except between @code{.} or @code{*} and the corresponding word. | |
35925 | ||
35926 | The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are | |
35927 | handled specifically in these constructs. If another value of | |
35928 | @option{-O} or the negated form of a @option{-f}, @option{-m}, or | |
35929 | @option{-W} switch is found later in the command line, the earlier | |
35930 | switch value is ignored, except with @{@code{S}*@} where @code{S} is | |
35931 | just one letter, which passes all matching options. | |
35932 | ||
35933 | The character @samp{|} at the beginning of the predicate text is used to | |
35934 | indicate that a command should be piped to the following command, but | |
35935 | only if @option{-pipe} is specified. | |
35936 | ||
35937 | It is built into GCC which switches take arguments and which do not. | |
35938 | (You might think it would be useful to generalize this to allow each | |
35939 | compiler's spec to say which switches take arguments. But this cannot | |
35940 | be done in a consistent fashion. GCC cannot even decide which input | |
35941 | files have been specified without knowing which switches take arguments, | |
35942 | and it must know which input files to compile in order to tell which | |
35943 | compilers to run). | |
35944 | ||
35945 | GCC also knows implicitly that arguments starting in @option{-l} are to be | |
35946 | treated as compiler output files, and passed to the linker in their | |
35947 | proper position among the other output files. | |
35948 | ||
35949 | @node Environment Variables | |
35950 | @section Environment Variables Affecting GCC | |
35951 | @cindex environment variables | |
35952 | ||
35953 | @c man begin ENVIRONMENT | |
35954 | This section describes several environment variables that affect how GCC | |
35955 | operates. Some of them work by specifying directories or prefixes to use | |
35956 | when searching for various kinds of files. Some are used to specify other | |
35957 | aspects of the compilation environment. | |
35958 | ||
35959 | Note that you can also specify places to search using options such as | |
35960 | @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These | |
35961 | take precedence over places specified using environment variables, which | |
35962 | in turn take precedence over those specified by the configuration of GCC@. | |
35963 | @xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint, | |
35964 | GNU Compiler Collection (GCC) Internals}. | |
35965 | ||
35966 | @table @env | |
f33d7a88 AA |
35967 | @vindex LANG |
35968 | @vindex LC_CTYPE | |
35969 | @c @vindex LC_COLLATE | |
35970 | @vindex LC_MESSAGES | |
35971 | @c @vindex LC_MONETARY | |
35972 | @c @vindex LC_NUMERIC | |
35973 | @c @vindex LC_TIME | |
35974 | @vindex LC_ALL | |
35975 | @cindex locale | |
d77de738 ML |
35976 | @item LANG |
35977 | @itemx LC_CTYPE | |
35978 | @c @itemx LC_COLLATE | |
35979 | @itemx LC_MESSAGES | |
35980 | @c @itemx LC_MONETARY | |
35981 | @c @itemx LC_NUMERIC | |
35982 | @c @itemx LC_TIME | |
35983 | @itemx LC_ALL | |
d77de738 ML |
35984 | These environment variables control the way that GCC uses |
35985 | localization information which allows GCC to work with different | |
35986 | national conventions. GCC inspects the locale categories | |
35987 | @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do | |
35988 | so. These locale categories can be set to any value supported by your | |
35989 | installation. A typical value is @samp{en_GB.UTF-8} for English in the United | |
35990 | Kingdom encoded in UTF-8. | |
35991 | ||
35992 | The @env{LC_CTYPE} environment variable specifies character | |
35993 | classification. GCC uses it to determine the character boundaries in | |
35994 | a string; this is needed for some multibyte encodings that contain quote | |
35995 | and escape characters that are otherwise interpreted as a string | |
35996 | end or escape. | |
35997 | ||
35998 | The @env{LC_MESSAGES} environment variable specifies the language to | |
35999 | use in diagnostic messages. | |
36000 | ||
36001 | If the @env{LC_ALL} environment variable is set, it overrides the value | |
36002 | of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE} | |
36003 | and @env{LC_MESSAGES} default to the value of the @env{LANG} | |
36004 | environment variable. If none of these variables are set, GCC | |
36005 | defaults to traditional C English behavior. | |
36006 | ||
f33d7a88 | 36007 | @vindex TMPDIR |
d77de738 | 36008 | @item TMPDIR |
d77de738 ML |
36009 | If @env{TMPDIR} is set, it specifies the directory to use for temporary |
36010 | files. GCC uses temporary files to hold the output of one stage of | |
36011 | compilation which is to be used as input to the next stage: for example, | |
36012 | the output of the preprocessor, which is the input to the compiler | |
36013 | proper. | |
36014 | ||
f33d7a88 | 36015 | @vindex GCC_COMPARE_DEBUG |
d77de738 | 36016 | @item GCC_COMPARE_DEBUG |
d77de738 ML |
36017 | Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing |
36018 | @option{-fcompare-debug} to the compiler driver. See the documentation | |
36019 | of this option for more details. | |
36020 | ||
f33d7a88 | 36021 | @vindex GCC_EXEC_PREFIX |
d77de738 | 36022 | @item GCC_EXEC_PREFIX |
d77de738 ML |
36023 | If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the |
36024 | names of the subprograms executed by the compiler. No slash is added | |
36025 | when this prefix is combined with the name of a subprogram, but you can | |
36026 | specify a prefix that ends with a slash if you wish. | |
36027 | ||
36028 | If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out | |
36029 | an appropriate prefix to use based on the pathname it is invoked with. | |
36030 | ||
36031 | If GCC cannot find the subprogram using the specified prefix, it | |
36032 | tries looking in the usual places for the subprogram. | |
36033 | ||
36034 | The default value of @env{GCC_EXEC_PREFIX} is | |
36035 | @file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to | |
36036 | the installed compiler. In many cases @var{prefix} is the value | |
36037 | of @code{prefix} when you ran the @file{configure} script. | |
36038 | ||
36039 | Other prefixes specified with @option{-B} take precedence over this prefix. | |
36040 | ||
36041 | This prefix is also used for finding files such as @file{crt0.o} that are | |
36042 | used for linking. | |
36043 | ||
36044 | In addition, the prefix is used in an unusual way in finding the | |
36045 | directories to search for header files. For each of the standard | |
36046 | directories whose name normally begins with @samp{/usr/local/lib/gcc} | |
36047 | (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries | |
36048 | replacing that beginning with the specified prefix to produce an | |
36049 | alternate directory name. Thus, with @option{-Bfoo/}, GCC searches | |
36050 | @file{foo/bar} just before it searches the standard directory | |
36051 | @file{/usr/local/lib/bar}. | |
36052 | If a standard directory begins with the configured | |
36053 | @var{prefix} then the value of @var{prefix} is replaced by | |
36054 | @env{GCC_EXEC_PREFIX} when looking for header files. | |
36055 | ||
f33d7a88 | 36056 | @vindex COMPILER_PATH |
d77de738 | 36057 | @item COMPILER_PATH |
d77de738 ML |
36058 | The value of @env{COMPILER_PATH} is a colon-separated list of |
36059 | directories, much like @env{PATH}. GCC tries the directories thus | |
36060 | specified when searching for subprograms, if it cannot find the | |
36061 | subprograms using @env{GCC_EXEC_PREFIX}. | |
36062 | ||
f33d7a88 | 36063 | @vindex LIBRARY_PATH |
d77de738 | 36064 | @item LIBRARY_PATH |
d77de738 ML |
36065 | The value of @env{LIBRARY_PATH} is a colon-separated list of |
36066 | directories, much like @env{PATH}. When configured as a native compiler, | |
36067 | GCC tries the directories thus specified when searching for special | |
36068 | linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking | |
36069 | using GCC also uses these directories when searching for ordinary | |
36070 | libraries for the @option{-l} option (but directories specified with | |
36071 | @option{-L} come first). | |
36072 | ||
f33d7a88 | 36073 | @vindex LANG |
d77de738 | 36074 | @cindex locale definition |
f33d7a88 | 36075 | @item LANG |
d77de738 ML |
36076 | This variable is used to pass locale information to the compiler. One way in |
36077 | which this information is used is to determine the character set to be used | |
36078 | when character literals, string literals and comments are parsed in C and C++. | |
36079 | When the compiler is configured to allow multibyte characters, | |
36080 | the following values for @env{LANG} are recognized: | |
36081 | ||
36082 | @table @samp | |
36083 | @item C-JIS | |
36084 | Recognize JIS characters. | |
36085 | @item C-SJIS | |
36086 | Recognize SJIS characters. | |
36087 | @item C-EUCJP | |
36088 | Recognize EUCJP characters. | |
36089 | @end table | |
36090 | ||
36091 | If @env{LANG} is not defined, or if it has some other value, then the | |
36092 | compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to | |
36093 | recognize and translate multibyte characters. | |
36094 | ||
f33d7a88 | 36095 | @vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT |
d77de738 | 36096 | @item GCC_EXTRA_DIAGNOSTIC_OUTPUT |
d77de738 ML |
36097 | If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values, |
36098 | then additional text will be emitted to stderr when fix-it hints are | |
36099 | emitted. @option{-fdiagnostics-parseable-fixits} and | |
36100 | @option{-fno-diagnostics-parseable-fixits} take precedence over this | |
36101 | environment variable. | |
36102 | ||
36103 | @table @samp | |
36104 | @item fixits-v1 | |
36105 | Emit parseable fix-it hints, equivalent to | |
36106 | @option{-fdiagnostics-parseable-fixits}. In particular, columns are | |
36107 | expressed as a count of bytes, starting at byte 1 for the initial column. | |
36108 | ||
36109 | @item fixits-v2 | |
36110 | As @code{fixits-v1}, but columns are expressed as display columns, | |
36111 | as per @option{-fdiagnostics-column-unit=display}. | |
36112 | @end table | |
36113 | ||
36114 | @end table | |
36115 | ||
36116 | @noindent | |
36117 | Some additional environment variables affect the behavior of the | |
36118 | preprocessor. | |
36119 | ||
36120 | @include cppenv.texi | |
36121 | ||
36122 | @c man end | |
36123 | ||
36124 | @node Precompiled Headers | |
36125 | @section Using Precompiled Headers | |
36126 | @cindex precompiled headers | |
36127 | @cindex speed of compilation | |
36128 | ||
36129 | Often large projects have many header files that are included in every | |
36130 | source file. The time the compiler takes to process these header files | |
36131 | over and over again can account for nearly all of the time required to | |
36132 | build the project. To make builds faster, GCC allows you to | |
36133 | @dfn{precompile} a header file. | |
36134 | ||
36135 | To create a precompiled header file, simply compile it as you would any | |
36136 | other file, if necessary using the @option{-x} option to make the driver | |
36137 | treat it as a C or C++ header file. You may want to use a | |
36138 | tool like @command{make} to keep the precompiled header up-to-date when | |
36139 | the headers it contains change. | |
36140 | ||
36141 | A precompiled header file is searched for when @code{#include} is | |
36142 | seen in the compilation. As it searches for the included file | |
36143 | (@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the | |
36144 | compiler looks for a precompiled header in each directory just before it | |
36145 | looks for the include file in that directory. The name searched for is | |
36146 | the name specified in the @code{#include} with @samp{.gch} appended. If | |
36147 | the precompiled header file cannot be used, it is ignored. | |
36148 | ||
36149 | For instance, if you have @code{#include "all.h"}, and you have | |
36150 | @file{all.h.gch} in the same directory as @file{all.h}, then the | |
36151 | precompiled header file is used if possible, and the original | |
36152 | header is used otherwise. | |
36153 | ||
36154 | Alternatively, you might decide to put the precompiled header file in a | |
36155 | directory and use @option{-I} to ensure that directory is searched | |
36156 | before (or instead of) the directory containing the original header. | |
36157 | Then, if you want to check that the precompiled header file is always | |
36158 | used, you can put a file of the same name as the original header in this | |
36159 | directory containing an @code{#error} command. | |
36160 | ||
36161 | This also works with @option{-include}. So yet another way to use | |
36162 | precompiled headers, good for projects not designed with precompiled | |
36163 | header files in mind, is to simply take most of the header files used by | |
36164 | a project, include them from another header file, precompile that header | |
36165 | file, and @option{-include} the precompiled header. If the header files | |
36166 | have guards against multiple inclusion, they are skipped because | |
36167 | they've already been included (in the precompiled header). | |
36168 | ||
36169 | If you need to precompile the same header file for different | |
36170 | languages, targets, or compiler options, you can instead make a | |
36171 | @emph{directory} named like @file{all.h.gch}, and put each precompiled | |
36172 | header in the directory, perhaps using @option{-o}. It doesn't matter | |
36173 | what you call the files in the directory; every precompiled header in | |
36174 | the directory is considered. The first precompiled header | |
36175 | encountered in the directory that is valid for this compilation is | |
36176 | used; they're searched in no particular order. | |
36177 | ||
36178 | There are many other possibilities, limited only by your imagination, | |
36179 | good sense, and the constraints of your build system. | |
36180 | ||
36181 | A precompiled header file can be used only when these conditions apply: | |
36182 | ||
36183 | @itemize | |
36184 | @item | |
36185 | Only one precompiled header can be used in a particular compilation. | |
36186 | ||
36187 | @item | |
36188 | A precompiled header cannot be used once the first C token is seen. You | |
36189 | can have preprocessor directives before a precompiled header; you cannot | |
36190 | include a precompiled header from inside another header. | |
36191 | ||
36192 | @item | |
36193 | The precompiled header file must be produced for the same language as | |
36194 | the current compilation. You cannot use a C precompiled header for a C++ | |
36195 | compilation. | |
36196 | ||
36197 | @item | |
36198 | The precompiled header file must have been produced by the same compiler | |
36199 | binary as the current compilation is using. | |
36200 | ||
36201 | @item | |
36202 | Any macros defined before the precompiled header is included must | |
36203 | either be defined in the same way as when the precompiled header was | |
36204 | generated, or must not affect the precompiled header, which usually | |
36205 | means that they don't appear in the precompiled header at all. | |
36206 | ||
36207 | The @option{-D} option is one way to define a macro before a | |
36208 | precompiled header is included; using a @code{#define} can also do it. | |
36209 | There are also some options that define macros implicitly, like | |
36210 | @option{-O} and @option{-Wdeprecated}; the same rule applies to macros | |
36211 | defined this way. | |
36212 | ||
36213 | @item If debugging information is output when using the precompiled | |
36214 | header, using @option{-g} or similar, the same kind of debugging information | |
36215 | must have been output when building the precompiled header. However, | |
36216 | a precompiled header built using @option{-g} can be used in a compilation | |
36217 | when no debugging information is being output. | |
36218 | ||
36219 | @item The same @option{-m} options must generally be used when building | |
36220 | and using the precompiled header. @xref{Submodel Options}, | |
36221 | for any cases where this rule is relaxed. | |
36222 | ||
36223 | @item Each of the following options must be the same when building and using | |
36224 | the precompiled header: | |
36225 | ||
36226 | @gccoptlist{-fexceptions} | |
36227 | ||
36228 | @item | |
36229 | Some other command-line options starting with @option{-f}, | |
36230 | @option{-p}, or @option{-O} must be defined in the same way as when | |
36231 | the precompiled header was generated. At present, it's not clear | |
36232 | which options are safe to change and which are not; the safest choice | |
36233 | is to use exactly the same options when generating and using the | |
36234 | precompiled header. The following are known to be safe: | |
36235 | ||
43b72ede AA |
36236 | @gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock |
36237 | -fsched-spec -fsched-spec-load -fsched-spec-load-dangerous | |
36238 | -fsched-verbose=@var{number} -fschedule-insns -fvisibility= | |
d77de738 ML |
36239 | -pedantic-errors} |
36240 | ||
36241 | @item Address space layout randomization (ASLR) can lead to not binary identical | |
36242 | PCH files. If you rely on stable PCH file contents disable ASLR when generating | |
36243 | PCH files. | |
36244 | ||
36245 | @end itemize | |
36246 | ||
36247 | For all of these except the last, the compiler automatically | |
36248 | ignores the precompiled header if the conditions aren't met. If you | |
36249 | find an option combination that doesn't work and doesn't cause the | |
36250 | precompiled header to be ignored, please consider filing a bug report, | |
36251 | see @ref{Bugs}. | |
36252 | ||
36253 | If you do use differing options when generating and using the | |
36254 | precompiled header, the actual behavior is a mixture of the | |
36255 | behavior for the options. For instance, if you use @option{-g} to | |
36256 | generate the precompiled header but not when using it, you may or may | |
36257 | not get debugging information for routines in the precompiled header. | |
36258 | ||
36259 | @node C++ Modules | |
36260 | @section C++ Modules | |
36261 | @cindex speed of compilation | |
36262 | ||
36263 | Modules are a C++20 language feature. As the name suggests, they | |
36264 | provides a modular compilation system, intending to provide both | |
36265 | faster builds and better library isolation. The ``Merging Modules'' | |
36266 | paper @uref{https://wg21.link/p1103}, provides the easiest to read set | |
36267 | of changes to the standard, although it does not capture later | |
36268 | changes. | |
36269 | ||
36270 | @emph{G++'s modules support is not complete.} Other than bugs, the | |
36271 | known missing pieces are: | |
36272 | ||
36273 | @table @emph | |
36274 | ||
36275 | @item Private Module Fragment | |
36276 | The Private Module Fragment is recognized, but an error is emitted. | |
36277 | ||
36278 | @item Partition definition visibility rules | |
36279 | Entities may be defined in implementation partitions, and those | |
36280 | definitions are not available outside of the module. This is not | |
36281 | implemented, and the definitions are available to extra-module use. | |
36282 | ||
36283 | @item Textual merging of reachable GM entities | |
36284 | Entities may be multiply defined across different header-units. | |
36285 | These must be de-duplicated, and this is implemented across imports, | |
36286 | or when an import redefines a textually-defined entity. However the | |
36287 | reverse is not implemented---textually redefining an entity that has | |
36288 | been defined in an imported header-unit. A redefinition error is | |
36289 | emitted. | |
36290 | ||
36291 | @item Translation-Unit local referencing rules | |
36292 | Papers p1815 (@uref{https://wg21.link/p1815}) and p2003 | |
36293 | (@uref{https://wg21.link/p2003}) add limitations on which entities an | |
36294 | exported region may reference (for instance, the entities an exported | |
36295 | template definition may reference). These are not fully implemented. | |
36296 | ||
36297 | @item Standard Library Header Units | |
36298 | The Standard Library is not provided as importable header units. If | |
36299 | you want to import such units, you must explicitly build them first. | |
36300 | If you do not do this with care, you may have multiple declarations, | |
36301 | which the module machinery must merge---compiler resource usage can be | |
36302 | affected by how you partition header files into header units. | |
36303 | ||
36304 | @end table | |
36305 | ||
36306 | Modular compilation is @emph{not} enabled with just the | |
36307 | @option{-std=c++20} option. You must explicitly enable it with the | |
36308 | @option{-fmodules-ts} option. It is independent of the language | |
36309 | version selected, although in pre-C++20 versions, it is of course an | |
36310 | extension. | |
36311 | ||
36312 | No new source file suffixes are required or supported. If you wish to | |
36313 | use a non-standard suffix (@pxref{Overall Options}), you also need | |
36314 | to provide a @option{-x c++} option too.@footnote{Some users like to | |
36315 | distinguish module interface files with a new suffix, such as naming | |
36316 | the source @code{module.cppm}, which involves | |
36317 | teaching all tools about the new suffix. A different scheme, such as | |
36318 | naming @code{module-m.cpp} would be less invasive.} | |
36319 | ||
36320 | Compiling a module interface unit produces an additional output (to | |
36321 | the assembly or object file), called a Compiled Module Interface | |
36322 | (CMI). This encodes the exported declarations of the module. | |
36323 | Importing a module reads in the CMI. The import graph is a Directed | |
36324 | Acyclic Graph (DAG). You must build imports before the importer. | |
36325 | ||
36326 | Header files may themselves be compiled to header units, which are a | |
36327 | transitional ability aiming at faster compilation. The | |
36328 | @option{-fmodule-header} option is used to enable this, and implies | |
36329 | the @option{-fmodules-ts} option. These CMIs are named by the fully | |
36330 | resolved underlying header file, and thus may be a complete pathname | |
36331 | containing subdirectories. If the header file is found at an absolute | |
36332 | pathname, the CMI location is still relative to a CMI root directory. | |
36333 | ||
36334 | As header files often have no suffix, you commonly have to specify a | |
36335 | @option{-x} option to tell the compiler the source is a header file. | |
36336 | You may use @option{-x c++-header}, @option{-x c++-user-header} or | |
36337 | @option{-x c++-system-header}. When used in conjunction with | |
36338 | @option{-fmodules-ts}, these all imply an appropriate | |
36339 | @option{-fmodule-header} option. The latter two variants use the | |
36340 | user or system include path to search for the file specified. This | |
36341 | allows you to, for instance, compile standard library header files as | |
36342 | header units, without needing to know exactly where they are | |
36343 | installed. Specifying the language as one of these variants also | |
36344 | inhibits output of the object file, as header files have no associated | |
36345 | object file. | |
36346 | ||
36347 | The @option{-fmodule-only} option disables generation of the | |
36348 | associated object file for compiling a module interface. Only the CMI | |
36349 | is generated. This option is implied when using the | |
36350 | @option{-fmodule-header} option. | |
36351 | ||
36352 | The @option{-flang-info-include-translate} and | |
36353 | @option{-flang-info-include-translate-not} options notes whether | |
36354 | include translation occurs or not. With no argument, the first will | |
36355 | note all include translation. The second will note all | |
36356 | non-translations of include files not known to intentionally be | |
36357 | textual. With an argument, queries about include translation of a | |
36358 | header files with that particular trailing pathname are noted. You | |
36359 | may repeat this form to cover several different header files. This | |
36360 | option may be helpful in determining whether include translation is | |
36361 | happening---if it is working correctly, it behaves as if it isn't | |
36362 | there at all. | |
36363 | ||
36364 | The @option{-flang-info-module-cmi} option can be used to determine | |
36365 | where the compiler is reading a CMI from. Without the option, the | |
36366 | compiler is silent when such a read is successful. This option has an | |
36367 | optional argument, which will restrict the notification to just the | |
36368 | set of named modules or header units specified. | |
36369 | ||
36370 | The @option{-Winvalid-imported-macros} option causes all imported macros | |
36371 | to be resolved at the end of compilation. Without this, imported | |
36372 | macros are only resolved when expanded or (re)defined. This option | |
36373 | detects conflicting import definitions for all macros. | |
36374 | ||
36375 | For details of the @option{-fmodule-mapper} family of options, | |
36376 | @pxref{C++ Module Mapper}. | |
36377 | ||
36378 | @menu | |
36379 | * C++ Module Mapper:: Module Mapper | |
36380 | * C++ Module Preprocessing:: Module Preprocessing | |
36381 | * C++ Compiled Module Interface:: Compiled Module Interface | |
36382 | @end menu | |
36383 | ||
36384 | @node C++ Module Mapper | |
36385 | @subsection Module Mapper | |
36386 | @cindex C++ Module Mapper | |
36387 | ||
36388 | A module mapper provides a server or file that the compiler queries to | |
36389 | determine the mapping between module names and CMI files. It is also | |
36390 | used to build CMIs on demand. @emph{Mapper functionality is in its | |
36391 | infancy and is intended for experimentation with build system | |
36392 | interactions.} | |
36393 | ||
36394 | You can specify a mapper with the @option{-fmodule-mapper=@var{val}} | |
36395 | option or @env{CXX_MODULE_MAPPER} environment variable. The value may | |
36396 | have one of the following forms: | |
36397 | ||
36398 | @table @gcctabopt | |
36399 | ||
36400 | @item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]} | |
36401 | An optional hostname and a numeric port number to connect to. If the | |
36402 | hostname is omitted, the loopback address is used. If the hostname | |
36403 | corresponds to multiple IPV6 addresses, these are tried in turn, until | |
36404 | one is successful. If your host lacks IPv6, this form is | |
36405 | non-functional. If you must use IPv4 use | |
36406 | @option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}. | |
36407 | ||
36408 | @item =@var{socket}@r{[}?@var{ident}@r{]} | |
36409 | A local domain socket. If your host lacks local domain sockets, this | |
36410 | form is non-functional. | |
36411 | ||
36412 | @item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]} | |
36413 | A program to spawn, and communicate with on its stdin/stdout streams. | |
36414 | Your @var{PATH} environment variable is searched for the program. | |
36415 | Arguments are separated by space characters, (it is not possible for | |
36416 | one of the arguments delivered to the program to contain a space). An | |
36417 | exception is if @var{program} begins with @@. In that case | |
36418 | @var{program} (sans @@) is looked for in the compiler's internal | |
36419 | binary directory. Thus the sample mapper-server can be specified | |
36420 | with @code{@@g++-mapper-server}. | |
36421 | ||
36422 | @item <>@r{[}?@var{ident}@r{]} | |
36423 | @item <>@var{inout}@r{[}?@var{ident}@r{]} | |
36424 | @item <@var{in}>@var{out}@r{[}?@var{ident}@r{]} | |
36425 | Named pipes or file descriptors to communicate over. The first form, | |
36426 | @option{<>}, communicates over stdin and stdout. The other forms | |
36427 | allow you to specify a file descriptor or name a pipe. A numeric value | |
36428 | is interpreted as a file descriptor, otherwise named pipe is opened. | |
36429 | The second form specifies a bidirectional pipe and the last form | |
36430 | allows specifying two independent pipes. Using file descriptors | |
36431 | directly in this manner is fragile in general, as it can require the | |
36432 | cooperation of intermediate processes. In particular using stdin & | |
36433 | stdout is fraught with danger as other compiler options might also | |
36434 | cause the compiler to read stdin or write stdout, and it can have | |
36435 | unfortunate interactions with signal delivery from the terminal. | |
36436 | ||
36437 | @item @var{file}@r{[}?@var{ident}@r{]} | |
36438 | A mapping file consisting of space-separated module-name, filename | |
36439 | pairs, one per line. Only the mappings for the direct imports and any | |
36440 | module export name need be provided. If other mappings are provided, | |
36441 | they override those stored in any imported CMI files. A repository | |
36442 | root may be specified in the mapping file by using @samp{$root} as the | |
36443 | module name in the first active line. Use of this option will disable | |
36444 | any default module->CMI name mapping. | |
36445 | ||
36446 | @end table | |
36447 | ||
36448 | As shown, an optional @var{ident} may suffix the first word of the | |
36449 | option, indicated by a @samp{?} prefix. The value is used in the | |
36450 | initial handshake with the module server, or to specify a prefix on | |
36451 | mapping file lines. In the server case, the main source file name is | |
36452 | used if no @var{ident} is specified. In the file case, all non-blank | |
36453 | lines are significant, unless a value is specified, in which case only | |
36454 | lines beginning with @var{ident} are significant. The @var{ident} | |
36455 | must be separated by whitespace from the module name. Be aware that | |
36456 | @samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often | |
36457 | significant to the shell, and therefore may need quoting. | |
36458 | ||
36459 | The mapper is connected to or loaded lazily, when the first module | |
36460 | mapping is required. The networking protocols are only supported on | |
36461 | hosts that provide networking. If no mapper is specified a default is | |
36462 | provided. | |
36463 | ||
36464 | A project-specific mapper is expected to be provided by the build | |
36465 | system that invokes the compiler. It is not expected that a | |
36466 | general-purpose server is provided for all compilations. As such, the | |
36467 | server will know the build configuration, the compiler it invoked, and | |
36468 | the environment (such as working directory) in which that is | |
36469 | operating. As it may parallelize builds, several compilations may | |
36470 | connect to the same socket. | |
36471 | ||
36472 | The default mapper generates CMI files in a @samp{gcm.cache} | |
36473 | directory. CMI files have a @samp{.gcm} suffix. The module unit name | |
36474 | is used directly to provide the basename. Header units construct a | |
36475 | relative path using the underlying header file name. If the path is | |
36476 | already relative, a @samp{,} directory is prepended. Internal | |
36477 | @samp{..} components are translated to @samp{,,}. No attempt is made | |
36478 | to canonicalize these filenames beyond that done by the preprocessor's | |
36479 | include search algorithm, as in general it is ambiguous when symbolic | |
36480 | links are present. | |
36481 | ||
36482 | The mapper protocol was published as ``A Module Mapper'' | |
36483 | @uref{https://wg21.link/p1184}. The implementation is provided by | |
36484 | @command{libcody}, @uref{https://github.com/urnathan/libcody}, | |
36485 | which specifies the canonical protocol definition. A proof of concept | |
36486 | server implementation embedded in @command{make} was described in | |
36487 | ''Make Me A Module'', @uref{https://wg21.link/p1602}. | |
36488 | ||
36489 | @node C++ Module Preprocessing | |
36490 | @subsection Module Preprocessing | |
36491 | @cindex C++ Module Preprocessing | |
36492 | ||
36493 | Modules affect preprocessing because of header units and include | |
36494 | translation. Some uses of the preprocessor as a separate step either | |
36495 | do not produce a correct output, or require CMIs to be available. | |
36496 | ||
36497 | Header units import macros. These macros can affect later conditional | |
36498 | inclusion, which therefore can cascade to differing import sets. When | |
36499 | preprocessing, it is necessary to load the CMI. If a header unit is | |
36500 | unavailable, the preprocessor issues a warning and continue (when | |
36501 | not just preprocessing, an error is emitted). Detecting such imports | |
36502 | requires preprocessor tokenization of the input stream to phase 4 | |
36503 | (macro expansion). | |
36504 | ||
36505 | Include translation converts @code{#include}, @code{#include_next} and | |
36506 | @code{#import} directives to internal @code{import} declarations. | |
36507 | Whether a particular directive is translated is controlled by the | |
36508 | module mapper. Header unit names are canonicalized during | |
36509 | preprocessing. | |
36510 | ||
36511 | Dependency information can be emitted for macro import, extending the | |
36512 | functionality of @option{-MD} and @option{-MMD} options. Detection of | |
36513 | import declarations also requires phase 4 preprocessing, and thus | |
36514 | requires full preprocessing (or compilation). | |
36515 | ||
36516 | The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt | |
36517 | preprocessing before phase 4. | |
36518 | ||
36519 | The @option{-save-temps} option uses @option{-fdirectives-only} for | |
36520 | preprocessing, and preserve the macro definitions in the preprocessed | |
36521 | output. Usually you also want to use this option when explicitly | |
36522 | preprocessing a header-unit, or consuming such preprocessed output: | |
36523 | ||
36524 | @smallexample | |
36525 | g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii | |
36526 | g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii | |
36527 | @end smallexample | |
36528 | ||
36529 | @node C++ Compiled Module Interface | |
36530 | @subsection Compiled Module Interface | |
36531 | @cindex C++ Compiled Module Interface | |
36532 | ||
36533 | CMIs are an additional artifact when compiling named module | |
36534 | interfaces, partitions or header units. These are read when | |
36535 | importing. CMI contents are implementation-specific, and in GCC's | |
36536 | case tied to the compiler version. Consider them a rebuildable cache | |
36537 | artifact, not a distributable object. | |
36538 | ||
36539 | When creating an output CMI, any missing directory components are | |
36540 | created in a manner that is safe for concurrent builds creating | |
36541 | multiple, different, CMIs within a common subdirectory tree. | |
36542 | ||
36543 | CMI contents are written to a temporary file, which is then atomically | |
36544 | renamed. Observers either see old contents (if there is an | |
36545 | existing file), or complete new contents. They do not observe the | |
36546 | CMI during its creation. This is unlike object file writing, which | |
36547 | may be observed by an external process. | |
36548 | ||
36549 | CMIs are read in lazily, if the host OS provides @code{mmap} | |
36550 | functionality. Generally blocks are read when name lookup or template | |
36551 | instantiation occurs. To inhibit this, the @option{-fno-module-lazy} | |
36552 | option may be used. | |
36553 | ||
36554 | The @option{--param lazy-modules=@var{n}} parameter controls the limit | |
36555 | on the number of concurrently open module files during lazy loading. | |
36556 | Should more modules be imported, an LRU algorithm is used to determine | |
36557 | which files to close---until that file is needed again. This limit | |
36558 | may be exceeded with deep module dependency hierarchies. With large | |
36559 | code bases there may be more imports than the process limit of file | |
36560 | descriptors. By default, the limit is a few less than the per-process | |
36561 | file descriptor hard limit, if that is determinable.@footnote{Where | |
36562 | applicable the soft limit is incremented as needed towards the hard limit.} | |
36563 | ||
36564 | GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism. | |
36565 | You may use @command{readelf} to inspect them, although section | |
36566 | contents are largely undecipherable. There is a section named | |
36567 | @code{.gnu.c++.README}, which contains human-readable text. Other | |
36568 | than the first line, each line consists of @code{@var{tag}: @code{value}} | |
36569 | tuples. | |
36570 | ||
36571 | @smallexample | |
36572 | > @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm} | |
36573 | ||
36574 | String dump of section '.gnu.c++.README': | |
36575 | [ 0] GNU C++ primary module interface | |
36576 | [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454] | |
36577 | [ 6f] version: 2020/11/16-04:54 | |
36578 | [ 89] module: foo | |
36579 | [ 95] source: c_b.ii | |
36580 | [ a4] dialect: C++20/coroutines | |
36581 | [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc | |
36582 | [ ee] repository: gcm.cache | |
36583 | [ 104] buildtime: 2020/11/16 15:03:21 UTC | |
36584 | [ 127] localtime: 2020/11/16 07:03:21 PST | |
36585 | [ 14a] export: foo:part1 foo-part1.gcm | |
36586 | @end smallexample | |
36587 | ||
36588 | Amongst other things, this lists the source that was built, C++ | |
36589 | dialect used and imports of the module.@footnote{The precise contents | |
36590 | of this output may change.} The timestamp is the same value as that | |
36591 | provided by the @code{__DATE__} & @code{__TIME__} macros, and may be | |
36592 | explicitly specified with the environment variable | |
36593 | @code{SOURCE_DATE_EPOCH}. For further details | |
36594 | @pxref{Environment Variables}. | |
36595 | ||
36596 | A set of related CMIs may be copied, provided the relative pathnames | |
36597 | are preserved. | |
36598 | ||
36599 | The @code{.gnu.c++.README} contents do not affect CMI integrity, and | |
36600 | it may be removed or altered. The section numbering of the sections | |
36601 | whose names do not begin with @code{.gnu.c++.}, or are not the string | |
36602 | section is significant and must not be altered. |